:root {
  color-scheme: light;
  --ink: #132625;
  --muted: #687977;
  --forest: #172d2b;
  --forest-2: #203b38;
  --paper: #f7f6f1;
  --white: #fffefa;
  --line: #e0e4df;
  --accent: #e9734c;
  --accent-dark: #c65334;
  --mint: #72c7a7;
  --shadow: 0 18px 55px rgba(23, 45, 43, .14);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  overflow: hidden;
}

button, input, textarea { font: inherit; }
button { color: inherit; }

.app-shell {
  display: grid;
  grid-template-columns: 274px minmax(0, 1fr);
  height: 100dvh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 25px 18px 18px;
  color: #f6f4eb;
  background:
    radial-gradient(circle at 20% -10%, rgba(114, 199, 167, .17), transparent 35%),
    var(--forest);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 8px 27px;
  font-size: 18px;
  font-weight: 760;
  letter-spacing: -.02em;
}

.brand-mark {
  display: grid;
  width: 35px;
  height: 35px;
  place-items: center;
  color: var(--forest);
  background: var(--mint);
  border-radius: 11px 11px 11px 4px;
}

.brand-mark svg { width: 25px; }

.sidebar-section { margin-top: 9px; }
.people-section { min-height: 0; margin-top: 31px; }

.eyebrow {
  margin: 0 9px 10px;
  color: #91aaa6;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.room {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  color: #d7e1de;
  background: transparent;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
}

.room.active {
  color: #fff;
  background: rgba(255, 255, 255, .09);
  box-shadow: inset 3px 0 var(--accent);
}

.room-icon { color: #91aaa6; font-size: 19px; font-weight: 400; }
.live-dot { width: 7px; height: 7px; margin-left: auto; background: var(--mint); border-radius: 50%; box-shadow: 0 0 0 3px rgba(114, 199, 167, .13); }

.section-heading { display: flex; align-items: center; justify-content: space-between; }
.section-heading .eyebrow { margin-bottom: 8px; }
.count-pill { min-width: 24px; padding: 2px 7px; color: #a9bcb9; background: rgba(255, 255, 255, .07); border-radius: 999px; font-size: 11px; text-align: center; }

.people-list {
  max-height: calc(100dvh - 340px);
  margin: 0;
  padding: 0 4px;
  overflow-y: auto;
  list-style: none;
}

.person {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  color: #c8d6d3;
  font-size: 13px;
}

.mini-avatar, .avatar {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  color: #f9f8f2;
  background: #476b65;
  border-radius: 50%;
  font-weight: 730;
  text-transform: uppercase;
}

.mini-avatar { width: 27px; height: 27px; font-size: 10px; }
.avatar { width: 35px; height: 35px; font-size: 12px; }

.profile-card {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding: 14px 8px 2px;
  border-top: 1px solid rgba(255, 255, 255, .08);
}

.profile-copy { display: flex; min-width: 0; flex: 1; flex-direction: column; }
.profile-copy strong { overflow: hidden; color: #fff; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.profile-copy span { margin-top: 3px; color: #91aaa6; font-size: 11px; }
.status-light { display: inline-block; width: 6px; height: 6px; margin-right: 5px; background: var(--mint); border-radius: 50%; }

.icon-button {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  padding: 0;
  color: #9db0ac;
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.icon-button:hover { color: #fff; background: rgba(255,255,255,.08); }
.icon-button svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.chat-panel { display: grid; min-width: 0; height: 100dvh; grid-template-rows: auto minmax(0, 1fr) auto; background: var(--white); }

.chat-header {
  z-index: 2;
  display: flex;
  min-height: 79px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 30px;
  background: rgba(255, 254, 250, .93);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.channel-title { font-size: 17px; font-weight: 760; letter-spacing: -.015em; }
.channel-title span { margin-right: 4px; color: var(--accent); font-size: 20px; font-weight: 500; }
.chat-header p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.header-actions { display: flex; align-items: center; gap: 13px; }

.connection-badge {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  color: #467262;
  background: #e8f4ed;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 680;
}

.connection-badge > span:first-child { width: 7px; height: 7px; background: #46a47e; border-radius: 50%; }
.connection-badge.connecting { color: #8a7044; background: #f6eddc; }
.connection-badge.connecting > span:first-child { background: #d6a14b; animation: pulse 1.3s infinite; }
.connection-badge.offline { color: #925444; background: #f8e7e2; }
.connection-badge.offline > span:first-child { background: #d9684b; }

@keyframes pulse { 50% { opacity: .35; } }

.quiet-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 9px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 650;
}

.quiet-button:hover { color: var(--ink); background: var(--paper); }
.quiet-button svg { width: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.message-scroller {
  min-height: 0;
  padding: 26px clamp(20px, 4vw, 58px) 18px;
  overflow-y: auto;
  scroll-behavior: smooth;
  scrollbar-color: #c8cfca transparent;
}

.empty-state { max-width: 580px; margin: 28px auto 36px 0; }
.empty-mark { display: grid; width: 54px; height: 54px; place-items: center; color: var(--accent); background: #fce9df; border-radius: 18px; font-family: Georgia, serif; font-size: 28px; }
.empty-state h1 { margin: 18px 0 7px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(25px, 3vw, 36px); font-weight: 500; letter-spacing: -.025em; }
.empty-state p { max-width: 570px; margin: 0; color: var(--muted); font-size: 14px; line-height: 1.6; }

.message-list { display: flex; flex-direction: column; }
.date-divider { display: flex; align-items: center; gap: 12px; margin: 26px 0 18px; color: #8a9693; font-size: 10px; font-weight: 760; letter-spacing: .08em; text-transform: uppercase; }
.date-divider::before, .date-divider::after { height: 1px; flex: 1; background: var(--line); content: ""; }

.message { display: grid; grid-template-columns: 39px minmax(0, 1fr); gap: 12px; padding: 9px 8px; border-radius: 12px; }
.message:hover { background: #faf9f5; }
.message + .message.compact { padding-top: 2px; }
.message.compact .message-avatar { visibility: hidden; }
.message-avatar { width: 39px; height: 39px; }
.message-content { min-width: 0; }
.message-meta { display: flex; align-items: baseline; gap: 8px; margin: 1px 0 3px; }
.message-author { font-size: 13px; font-weight: 770; }
.message-time { color: #909b98; font-size: 10px; }
.message-body { margin: 0; color: #2c3f3d; font-size: 14px; line-height: 1.52; overflow-wrap: anywhere; white-space: pre-wrap; }
.message.mine .message-author { color: var(--accent-dark); }

.composer-zone { padding: 0 clamp(20px, 4vw, 58px) max(18px, env(safe-area-inset-bottom)); }
.typing-indicator { height: 22px; padding: 2px 3px; color: var(--muted); font-size: 11px; }
.composer { display: flex; align-items: flex-end; gap: 10px; padding: 10px 10px 10px 16px; background: #fbfaf6; border: 1px solid #d9ded9; border-radius: 15px; box-shadow: 0 7px 25px rgba(23,45,43,.05); transition: border-color .2s, box-shadow .2s; }
.composer:focus-within { border-color: #9cb7af; box-shadow: 0 7px 25px rgba(23,45,43,.08), 0 0 0 3px rgba(114,199,167,.12); }
.composer textarea { width: 100%; max-height: 130px; padding: 7px 0; color: var(--ink); background: transparent; border: 0; outline: 0; resize: none; line-height: 1.45; }
.composer textarea::placeholder { color: #98a3a0; }
.send-button { display: grid; width: 39px; height: 39px; flex: 0 0 auto; place-items: center; padding: 0; color: white; background: var(--accent); border: 0; border-radius: 11px; cursor: pointer; transition: transform .15s, background .15s; }
.send-button:hover:not(:disabled) { background: var(--accent-dark); transform: translateY(-1px); }
.send-button:disabled { cursor: default; opacity: .35; }
.send-button svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.composer-hint { display: flex; justify-content: space-between; padding: 6px 3px 0; color: #9ba5a2; font-size: 9px; }
kbd { padding: 1px 4px; background: #f2f1ed; border: 1px solid #dddeda; border-radius: 4px; font-family: inherit; }

.identity-dialog { width: min(450px, calc(100% - 30px)); padding: 0; background: transparent; border: 0; border-radius: 22px; box-shadow: var(--shadow); }
.identity-dialog::backdrop { background: rgba(10, 28, 27, .72); backdrop-filter: blur(7px); }
.identity-dialog form { padding: 36px; background: var(--white); border-radius: 22px; }
.dialog-mark { display: grid; width: 51px; height: 51px; place-items: center; color: var(--forest); background: var(--mint); border-radius: 16px 16px 16px 6px; }
.dialog-mark svg { width: 34px; }
.identity-dialog .eyebrow { margin: 25px 0 8px; color: var(--accent-dark); }
.identity-dialog h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 29px; font-weight: 500; letter-spacing: -.025em; }
.dialog-copy { margin: 10px 0 23px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.identity-dialog label { display: block; margin-bottom: 7px; font-size: 12px; font-weight: 720; }
.identity-dialog input { width: 100%; padding: 12px 13px; color: var(--ink); background: #fbfaf6; border: 1px solid #d8ded9; border-radius: 10px; outline: 0; }
.identity-dialog input:focus { border-color: #79aa9b; box-shadow: 0 0 0 3px rgba(114,199,167,.15); }
.field-error { min-height: 19px; margin: 4px 0; color: #b9462d; font-size: 11px; }
.primary-button { width: 100%; padding: 12px 16px; color: #fff; background: var(--forest); border: 0; border-radius: 10px; cursor: pointer; font-weight: 720; }
.primary-button:hover { background: var(--forest-2); }

.toast { position: fixed; right: 25px; bottom: 25px; z-index: 10; max-width: 330px; padding: 12px 15px; color: white; background: var(--forest); border-radius: 10px; box-shadow: var(--shadow); font-size: 12px; opacity: 0; pointer-events: none; transform: translateY(12px); transition: .2s ease; }
.toast.visible { opacity: 1; transform: translateY(0); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .chat-header { min-height: 67px; padding: 11px 16px; }
  .chat-header p { display: none; }
  .quiet-button { padding: 7px; }
  .quiet-button:not([hidden]) { font-size: 0; }
  .message-scroller { padding: 15px 12px 12px; }
  .composer-zone { padding: 0 12px max(12px, env(safe-area-inset-bottom)); }
  .message { grid-template-columns: 34px minmax(0, 1fr); gap: 9px; }
  .message-avatar { width: 34px; height: 34px; }
  .identity-dialog form { padding: 28px 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
