:root {
  color-scheme: light;
  --bg: #f6f7f2;
  --panel: #ffffff;
  --ink: #18201f;
  --muted: #66706f;
  --line: #dfe6df;
  --teal: #0d8b76;
  --teal-dark: #096956;
  --coral: #e76854;
  --yellow: #e5ad22;
  --shadow: 0 24px 70px rgba(24, 32, 31, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(13, 139, 118, 0.12), rgba(229, 173, 34, 0.09)),
    var(--bg);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.join-form {
  display: grid;
  gap: 10px;
}

.join-form label,
.profile-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.join-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.join-button {
  min-height: 52px;
  border: 0;
  border-radius: 12px;
  padding: 0 18px;
  color: #ffffff;
  background: var(--teal);
  font-weight: 800;
  transition:
    background 160ms ease,
    transform 160ms ease;
}

.join-button:hover {
  background: var(--teal-dark);
  transform: translateY(-1px);
}

.join-hint {
  min-height: 42px;
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.join-hint.is-error {
  color: #a43f31;
}

.menu-backdrop {
  display: none;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
  gap: 18px;
  width: min(1180px, calc(100% - 28px));
  height: min(820px, calc(100vh - 28px));
  min-height: 620px;
  margin: 14px auto;
}

.sidebar,
.chat-panel {
  min-width: 0;
  border: 1px solid rgba(24, 32, 31, 0.08);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px;
  border-radius: 18px;
}

.sidebar-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  color: #ffffff;
  background: var(--teal);
  font-weight: 800;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.77rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 1.55rem;
}

h2 {
  font-size: 1.3rem;
}

.profile-panel {
  display: grid;
  gap: 10px;
}

.locked-profile {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px 10px 6px 6px;
  background: #ffffff;
}

.mini-avatar {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: #ffffff;
  background: var(--teal);
  font-size: 0.86rem;
  font-weight: 800;
  text-transform: uppercase;
}

.locked-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: 0;
  color: var(--ink);
  background: #ffffff;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease;
}

input:focus {
  border-color: rgba(13, 139, 118, 0.75);
  box-shadow: 0 0 0 4px rgba(13, 139, 118, 0.12);
}

#entryName {
  height: 52px;
  padding: 0 14px;
}

.icon-button,
.menu-button,
.close-menu-button,
.send-button {
  display: grid;
  place-items: center;
  border: 0;
  color: #ffffff;
  background: var(--teal);
  transition:
    background 160ms ease,
    transform 160ms ease;
}

.icon-button {
  width: 42px;
  height: 42px;
  border-radius: 10px;
}

.menu-button,
.close-menu-button {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 10px;
}

.menu-button,
.close-menu-button {
  display: none;
}

.icon-button:hover,
.menu-button:hover,
.close-menu-button:hover,
.send-button:hover {
  background: var(--teal-dark);
  transform: translateY(-1px);
}

.icon-button svg,
.menu-button svg,
.close-menu-button svg,
.send-button svg,
.logout-button svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.logout-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  width: 100%;
  border: 1px solid rgba(231, 104, 84, 0.28);
  border-radius: 10px;
  color: #9f3f33;
  background: #fff7f3;
  font-weight: 800;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    transform 160ms ease;
}

.logout-button:hover {
  border-color: rgba(231, 104, 84, 0.5);
  background: #ffede6;
  transform: translateY(-1px);
}

.room-list {
  display: grid;
  gap: 8px;
}

.room-button {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0 12px;
  color: var(--ink);
  background: transparent;
  font-weight: 750;
  text-align: left;
}

.room-button:hover,
.room-button.is-active {
  border-color: var(--line);
  background: #ffffff;
}

.room-button.is-active {
  box-shadow: 0 10px 28px rgba(24, 32, 31, 0.08);
}

.room-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 10px;
  border-radius: 50%;
}

.dot-green {
  background: var(--teal);
}

.dot-coral {
  background: var(--coral);
}

.dot-yellow {
  background: var(--yellow);
}

.chat-panel {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  border-radius: 18px;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 78px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
}

.chat-title {
  min-width: 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  max-width: 180px;
  border-radius: 999px;
  padding: 0 12px;
  color: var(--teal-dark);
  background: rgba(13, 139, 118, 0.12);
  font-size: 0.84rem;
  font-weight: 750;
  white-space: nowrap;
}

.setup-notice {
  align-self: start;
  width: min(680px, calc(100% - 32px));
  margin: 18px auto 0;
  border: 1px solid rgba(231, 104, 84, 0.35);
  border-radius: 12px;
  padding: 18px;
  background: #fff7f3;
}

.setup-notice h2 {
  margin-bottom: 8px;
}

.setup-notice p {
  margin: 0;
  color: #5f433d;
  line-height: 1.5;
}

.welcome-notice {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  min-height: 0;
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.welcome-notice h2 {
  color: var(--ink);
}

.welcome-notice p {
  max-width: 380px;
  margin: 0;
  line-height: 1.5;
}

.message-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  min-height: 0;
  padding: 22px;
}

.message-list:empty::before {
  content: "Még nincs üzenet ebben a szobában.";
  display: grid;
  place-items: center;
  min-height: 100%;
  color: var(--muted);
  text-align: center;
}

.message {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  max-width: min(720px, 88%);
  align-self: flex-start;
}

.message.is-mine {
  align-self: flex-end;
  grid-template-columns: minmax(0, 1fr) 42px;
}

.message.is-mine .avatar {
  grid-column: 2;
  grid-row: 1;
  background: var(--coral);
}

.message.is-mine .message-body {
  grid-column: 1;
  grid-row: 1;
  background: #fef1ed;
}

.avatar {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  color: #ffffff;
  background: var(--teal);
  font-size: 0.9rem;
  font-weight: 800;
  text-transform: uppercase;
}

.message-body {
  min-width: 0;
  border: 1px solid rgba(24, 32, 31, 0.08);
  border-radius: 14px;
  padding: 10px 12px;
  background: #ffffff;
}

.message-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}

.author {
  min-width: 0;
  overflow: hidden;
  font-size: 0.9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.time {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.78rem;
}

.text {
  margin: 0;
  overflow-wrap: anywhere;
  line-height: 1.45;
}

.message-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 52px;
  gap: 10px;
  padding: 16px 22px 20px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.8);
}

#messageInput {
  min-height: 52px;
  padding: 0 16px;
  font-size: 1rem;
}

.send-button {
  width: 52px;
  height: 52px;
  border-radius: 14px;
}

.send-button:disabled,
.icon-button:disabled,
.join-button:disabled,
.logout-button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

@media (max-width: 760px) {
  body.menu-open {
    overflow: hidden;
  }

  .menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: block;
    background: rgba(24, 32, 31, 0.42);
    backdrop-filter: blur(2px);
  }

  .join-row {
    grid-template-columns: 1fr;
  }

  .app-shell {
    grid-template-columns: 1fr;
    width: 100%;
    height: 100dvh;
    min-height: 0;
    margin: 0;
    gap: 0;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    width: min(86vw, 340px);
    max-width: 100%;
    gap: 18px;
    overflow-y: auto;
    border-width: 0 1px 0 0;
    border-radius: 0 18px 18px 0;
    padding: 16px;
    box-shadow: 18px 0 44px rgba(24, 32, 31, 0.18);
    transform: translateX(-104%);
    transition: transform 180ms ease;
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .chat-panel {
    height: 100dvh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .brand {
    align-items: flex-start;
  }

  .menu-button,
  .close-menu-button {
    display: grid;
  }

  .profile-panel {
    max-width: none;
  }

  .room-list {
    grid-template-columns: 1fr;
  }

  .room-button {
    justify-content: flex-start;
    min-height: 46px;
    padding: 0 12px;
    font-size: 1rem;
  }

  .chat-header {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    min-height: 64px;
    padding: 10px 12px;
    gap: 10px;
  }

  .chat-header h2 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .status-pill {
    min-height: 32px;
    max-width: 130px;
    padding: 0 10px;
    font-size: 0.78rem;
  }

  .message-list {
    padding: 12px;
  }

  .message {
    max-width: 100%;
    grid-template-columns: 36px minmax(0, 1fr);
  }

  .message.is-mine {
    grid-template-columns: minmax(0, 1fr) 36px;
  }

  .avatar {
    width: 36px;
    height: 36px;
    font-size: 0.78rem;
  }

  .message-body {
    border-radius: 12px;
  }

  .message-form {
    grid-template-columns: minmax(0, 1fr) 48px;
    gap: 8px;
    padding: 10px 12px 12px;
  }

  #messageInput,
  .send-button {
    min-height: 48px;
    height: 48px;
  }
}
