/* ==========================================================================
   ourcord — design language
   Dark charcoal chrome framing a warm-paper chat pane. One amber accent.
   Strong type: system sans for UI, old-style serif for voice & headings.
   ========================================================================== */

:root {
  /* charcoal chrome */
  --bg-0: #141519;
  --bg-1: #17181d;
  --bg-2: #1d1f25;
  --bg-3: #23262d;
  --bg-4: #2a2e37;
  --line: #2e323c;
  --line-soft: #262a33;

  /* warm paper */
  --paper: #faf7f0;
  --paper-2: #f3eee2;
  --paper-3: #ece6d6;
  --paper-line: #e2dac6;
  --paper-line-soft: #eae4d4;

  /* ink on paper */
  --ink: #23252b;
  --ink-2: #5b5f68;
  --ink-3: #8b8f99;

  /* light text on chrome */
  --lt: #e9e7e0;
  --lt-2: #aeb1bb;
  --lt-3: #7f838e;

  /* the one accent (amber) + helpers */
  --accent: #e2a03c;
  --accent-2: #f0b45f;
  --accent-deep: #b26f14; /* accent text on paper */
  --accent-wash: #f7e8cd;
  --danger: #d84e4e;
  --ok: #57a878;

  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --radius: 12px;
  --rail-w: 72px;
  --side-w: 264px;
  --members-w: 244px;
  --chat-max: 860px;
}

/* ------------------------------------------------------------------ base */

* { box-sizing: border-box; }

/* author display rules (grid/flex) must not defeat the hidden attribute */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  color: var(--lt);
  background: var(--bg-0);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: rgba(226, 160, 60, 0.32); }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

h1, h2, h3, p { margin: 0; }

a { color: var(--accent-deep); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* scrollbars — dark chrome */
.sidebar, .rail-scroll { scrollbar-width: thin; scrollbar-color: #383d48 transparent; }
.sidebar::-webkit-scrollbar, .rail-scroll::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb, .rail-scroll::-webkit-scrollbar-thumb {
  background: #383d48; border-radius: 4px;
}
.messages, .members { scrollbar-width: thin; scrollbar-color: #cfc5ad transparent; }
.messages::-webkit-scrollbar, .members::-webkit-scrollbar { width: 10px; }
.messages::-webkit-scrollbar-thumb, .members::-webkit-scrollbar-thumb {
  background: #cfc5ad; border-radius: 5px; border: 2px solid var(--paper);
}
.members::-webkit-scrollbar-thumb { border-color: var(--paper-2); }

/* icons injected by app.js */
svg { display: block; }

/* ------------------------------------------------------- shared controls */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 11px 16px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14.5px;
  transition: background-color 0.15s, transform 0.05s, border-color 0.15s;
}
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--accent);
  color: #20150a;
}
.btn-primary:hover { background: var(--accent-2); }

.btn-ghost {
  border: 1px solid var(--paper-line);
  color: var(--ink);
  background: transparent;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent-deep); }

.btn-ic { display: inline-flex; color: var(--accent-deep); }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { filter: brightness(1.08); }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: inherit;
  opacity: 0.85;
  transition: background-color 0.15s, opacity 0.15s;
  flex: none;
}
.icon-btn:hover { opacity: 1; background: rgba(128, 128, 128, 0.18); }

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  flex: none;
  font-weight: 700;
  font-size: 13.5px;
  letter-spacing: 0.02em;
  color: #fff;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.25);
  user-select: none;
}
.avatar.sm { width: 26px; height: 26px; font-size: 10.5px; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--lt-3); }
.dot-on { background: var(--ok); }
.dot-on.pulse { animation: dot-pulse 2.4s ease-out infinite; }

@keyframes dot-pulse {
  0% { box-shadow: 0 0 0 0 rgba(87, 168, 120, 0.5); }
  70% { box-shadow: 0 0 0 6px rgba(87, 168, 120, 0); }
  100% { box-shadow: 0 0 0 0 rgba(87, 168, 120, 0); }
}

/* form fields (auth + modals, on paper) */
.field, .form-field { display: block; margin-bottom: 14px; }
.field-label {
  display: block;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 6px;
}
.field input, .form-field input, .form-field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--paper-line);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 14.5px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus, .form-field input:focus, .form-field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(226, 160, 60, 0.18);
}
.field input::placeholder, .form-field input::placeholder, .form-field textarea::placeholder { color: #b3ac9c; }

.form-error {
  margin: 0 0 12px;
  padding: 9px 12px;
  border-radius: 8px;
  background: #fbe9e7;
  border: 1px solid #eec2bd;
  color: #a03535;
  font-size: 13.5px;
}

/* ----------------------------------------------------------------- toasts */

.toasts {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
  padding: 0 16px;
}
.toast {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  color: var(--lt);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13.5px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.4);
  animation: toast-in 0.22s ease-out;
  max-width: min(92vw, 460px);
}
.toast.danger { border-left-color: var(--danger); }
.toast.fade { opacity: 0; transition: opacity 0.3s; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* =================================================================== AUTH */

.auth {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
}

.auth-left {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px clamp(28px, 7vw, 96px);
  background:
    radial-gradient(1100px 560px at -12% -12%, rgba(226, 160, 60, 0.13), transparent 60%),
    radial-gradient(800px 500px at 110% 115%, rgba(226, 160, 60, 0.05), transparent 55%),
    var(--bg-0);
  overflow: hidden;
}
.auth-left::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.028) 1px, transparent 1px);
  background-size: 26px 26px;
  pointer-events: none;
}

.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 40px; position: relative; z-index: 1; }
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 3px solid var(--accent);
  position: relative;
}
.brand-mark::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 4px;
  border: 3px solid var(--accent);
}
.brand-name {
  font-family: var(--font-serif);
  font-size: 22px;
  color: var(--lt);
  letter-spacing: 0.01em;
}

.auth-headline {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: clamp(38px, 4.6vw, 62px);
  line-height: 1.08;
  color: var(--lt);
  margin-bottom: 18px;
  position: relative;
  z-index: 1;
}
.auth-sub { color: var(--lt-2); font-size: 16px; max-width: 42ch; margin-bottom: 30px; position: relative; z-index: 1; }

.auth-points { list-style: none; margin: 0 0 30px; padding: 0; display: grid; gap: 12px; position: relative; z-index: 1; }
.auth-points li { display: flex; align-items: center; gap: 12px; color: var(--lt-2); font-size: 14.5px; }
.pt-ic { display: inline-flex; color: var(--accent); }

.auth-seed {
  color: var(--lt-3);
  font-size: 13px;
  border-top: 1px solid var(--line-soft);
  padding-top: 18px;
  max-width: 52ch;
  position: relative;
  z-index: 1;
}
.auth-seed strong { color: var(--lt-2); font-weight: 600; }

.auth-right {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  background: var(--paper);
}

.auth-card {
  width: min(400px, 100%);
  background: #fff;
  border: 1px solid var(--paper-line);
  border-radius: 18px;
  padding: 26px 26px 22px;
  box-shadow: 0 18px 50px -18px rgba(35, 37, 43, 0.28);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  background: var(--paper-2);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 22px;
}
.auth-tab {
  padding: 8px 10px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  color: var(--ink-2);
  transition: background-color 0.15s, color 0.15s;
}
.auth-tab.is-active { background: #fff; color: var(--ink); box-shadow: 0 1px 4px rgba(35, 37, 43, 0.12); }

.auth-or {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink-3);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 18px 0 14px;
}
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: var(--paper-line); }

.auth-hint { color: var(--ink-3); font-size: 12.5px; margin-top: 12px; text-align: center; }
.auth-foot { margin-top: 26px; color: var(--ink-3); font-size: 12.5px; }

/* ==================================================================== APP */

.app {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-columns: var(--rail-w) var(--side-w) minmax(0, 1fr);
  overflow: hidden;
}

/* ------------------------------------------------------------------- rail */

.rail {
  background: var(--bg-0);
  display: flex;
  flex-direction: column;
  padding: 12px 0;
  z-index: 30;
}
.rail-scroll {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 0 0 10px;
}
.rail-btn {
  width: 46px;
  height: 46px;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--lt-2);
  background: var(--bg-2);
  transition: border-radius 0.18s, background-color 0.15s, color 0.15s;
  position: relative;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.02em;
}
.rail-btn:hover { border-radius: 50%; background: var(--bg-4); color: var(--lt); }
.rail-btn.is-active {
  border-radius: 16px;
  background: var(--accent);
  color: #20150a;
  box-shadow: 0 0 0 2px var(--bg-0), 0 0 0 4px var(--accent);
}
.rail-btn.is-active:hover { background: var(--accent-2); }
.rail-add { border: 1.5px dashed var(--line); background: transparent; color: var(--lt-3); }
.rail-add:hover { border-color: var(--accent); color: var(--accent); background: transparent; }
.rail-discover:hover { color: var(--accent); }
.rail-actions { display: grid; gap: 10px; justify-items: center; padding-top: 10px; border-top: 1px solid var(--line-soft); margin: 0 12px; }

/* --------------------------------------------------------------- sidebar */

.sidebar {
  background: var(--bg-1);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line-soft);
  min-height: 0;
  z-index: 40;
}

.sidebar-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 14px 14px 18px;
  border-bottom: 1px solid var(--line-soft);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.15);
}
.sidebar-head-text { flex: 1; min-width: 0; }
.sidebar-head h2 {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 600;
  color: var(--lt);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-head p {
  color: var(--lt-3);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.sidebar-head .icon-btn { color: var(--lt-2); }

.channel-list { flex: 1; overflow-y: auto; padding: 14px 10px; min-height: 0; }

.chan-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  margin: 4px 0 6px;
}
.chan-section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--lt-3);
}
.chan-add {
  display: none;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  color: var(--lt-3);
}
.chan-add:hover { color: var(--accent); background: var(--bg-3); }
.chan-section.is-owner .chan-add { display: inline-flex; }

.channel {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--lt-2);
  font-size: 14.5px;
  position: relative;
  margin-bottom: 1px;
  transition: background-color 0.12s, color 0.12s;
}
.channel::before {
  content: "";
  position: absolute;
  left: 0;
  top: 20%;
  bottom: 20%;
  width: 3px;
  border-radius: 2px;
  background: var(--accent);
  opacity: 0;
  transition: opacity 0.12s;
}
.channel:hover { background: var(--bg-2); color: var(--lt); }
.channel.is-active { background: var(--bg-3); color: var(--lt); }
.channel.is-active::before { opacity: 1; }
.channel .hash-ic { display: inline-flex; color: var(--lt-3); flex: none; }
.channel.is-active .hash-ic, .channel:hover .hash-ic { color: var(--accent); }
.channel .chan-name { flex: 1; min-width: 0; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.channel .chan-unread {
  flex: none;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--accent);
  color: #20150a;
  font-size: 11.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.channel .chan-del {
  display: none;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  color: var(--lt-3);
}
.channel:hover .chan-del, .channel.is-active .chan-del { display: inline-flex; }
.channel .chan-del:hover { color: var(--danger); background: var(--bg-4); }

.user-panel {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-0);
  border-top: 1px solid var(--line-soft);
}
.user-panel .avatar { width: 34px; height: 34px; font-size: 12.5px; }
.user-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.user-meta strong { font-size: 13.5px; color: var(--lt); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.presence-text { font-size: 11.5px; color: var(--lt-3); display: inline-flex; align-items: center; gap: 6px; }
.user-panel .icon-btn { color: var(--lt-2); }

/* ------------------------------------------------------------------- chat */

.chat {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--paper);
  color: var(--ink);
}

.chat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  height: 58px;
  border-bottom: 1px solid var(--paper-line);
  background: var(--paper);
  flex: none;
}
.chat-head .hash {
  font-family: var(--font-serif);
  font-size: 22px;
  color: var(--ink-3);
  margin-left: 2px;
}
.chat-head h1 {
  font-size: 16.5px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.head-sep { width: 1px; height: 22px; background: var(--paper-line); flex: none; }
.topic {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.head-online {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
}
.chat-head .icon-btn { color: var(--ink-2); }
.chat-head .icon-btn:hover { background: var(--paper-2); }
.menu-btn { display: none; }

/* messages column */
.messages {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding: 18px 0 10px;
}
.messages-inner { max-width: var(--chat-max); margin: 0 auto; padding: 0 22px; }

.day-divider {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 18px 0 10px;
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.day-divider::before, .day-divider::after { content: ""; flex: 1; height: 1px; background: var(--paper-line); }

.msg {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 0 14px;
  padding: 3px 12px;
  border-radius: 8px;
  position: relative;
}
.msg:hover { background: rgba(35, 37, 43, 0.035); }
.msg + .msg { margin-top: 1px; }

.msg-gutter { grid-column: 1; width: 40px; display: flex; justify-content: center; }
.msg-compact .msg-gutter {
  align-items: flex-start;
  padding-top: 4px;
  color: var(--ink-3);
  font-size: 10.5px;
  visibility: hidden;
}
.msg:hover .msg-compact-gutter,
.msg.msg-compact:hover .msg-gutter { visibility: visible; }

.msg-main { grid-column: 2; min-width: 0; }
.msg-head { display: flex; align-items: baseline; gap: 8px; margin: 2px 0 1px; }
.msg-author { font-weight: 700; font-size: 14.5px; color: var(--ink); }
.msg-author.me-tag::after {
  content: "you";
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-deep);
  background: var(--accent-wash);
  border-radius: 4px;
  padding: 1.5px 5px;
  margin-left: 6px;
  vertical-align: 1px;
}
.msg-time { font-size: 11.5px; color: var(--ink-3); }
.msg-time .edited { font-style: italic; }

.msg-body {
  font-size: 15px;
  color: var(--ink);
  white-space: pre-wrap;
  overflow-wrap: break-word;
  padding-bottom: 2px;
}
.msg-body code {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--paper-2);
  border: 1px solid var(--paper-line);
  border-radius: 5px;
  padding: 0.5px 5px;
}
.msg-body strong { font-weight: 700; }
.msg-body em { font-style: italic; }

/* hover actions (own messages only) */
.msg-actions {
  position: absolute;
  top: -12px;
  right: 14px;
  display: none;
  gap: 2px;
  background: #fff;
  border: 1px solid var(--paper-line);
  border-radius: 9px;
  padding: 2px;
  box-shadow: 0 4px 14px rgba(35, 37, 43, 0.12);
}
.msg:hover .msg-actions, .msg:focus-within .msg-actions { display: flex; }
.msg-actions .icon-btn { width: 28px; height: 28px; color: var(--ink-2); }
.msg-actions .icon-btn:hover { background: var(--paper-2); }
.msg-actions .icon-btn.danger:hover { color: var(--danger); }

/* inline editor */
.msg-edit { display: flex; flex-direction: column; gap: 8px; padding: 4px 0 6px; }
.msg-edit textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--accent);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 14.5px;
  resize: vertical;
  min-height: 44px;
}
.msg-edit textarea:focus { outline: none; box-shadow: 0 0 0 3px rgba(226, 160, 60, 0.18); }
.edit-actions { display: flex; gap: 8px; }
.edit-actions .btn { width: auto; padding: 6px 14px; font-size: 13px; }
.btn-subtle {
  border: 1px solid var(--paper-line);
  color: var(--ink-2);
  border-radius: 8px;
}
.btn-subtle:hover { color: var(--ink); border-color: var(--ink-3); }

.empty-channel {
  max-width: var(--chat-max);
  margin: 8vh auto 0;
  padding: 0 24px;
  text-align: center;
}
.empty-channel h3 {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 500;
  font-size: 26px;
  color: var(--ink-2);
  margin-bottom: 8px;
}
.empty-channel p { color: var(--ink-3); font-size: 14px; }

.load-earlier {
  display: flex;
  justify-content: center;
  padding: 6px 0 14px;
}
.load-earlier button {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--paper-line);
  background: #fff;
}
.load-earlier button:hover { color: var(--accent-deep); border-color: var(--accent); }
.load-earlier .spinner { color: var(--ink-3); font-size: 12.5px; }

/* composer */
.chat-foot {
  flex: none;
  max-width: var(--chat-max);
  width: 100%;
  margin: 0 auto;
  padding: 0 22px 6px;
}
.typing {
  min-height: 20px;
  font-size: 12.5px;
  color: var(--ink-2);
  font-style: italic;
  padding: 2px 6px;
  display: flex;
  align-items: center;
  gap: 7px;
}
.typing .who { font-style: normal; font-weight: 600; color: var(--ink-2); }

.typing-dots { display: inline-flex; gap: 3px; }
.typing-dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ink-3);
  animation: typing-bounce 0.9s infinite ease-in-out;
}
.typing-dots i:nth-child(2) { animation-delay: 0.15s; }
.typing-dots i:nth-child(3) { animation-delay: 0.3s; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--paper-line);
  border-radius: 14px;
  padding: 8px 8px 8px 16px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.composer:focus-within {
  border-color: var(--accent);
  box-shadow: 0 3px 16px rgba(226, 160, 60, 0.14);
}
.composer textarea {
  flex: 1;
  border: none;
  resize: none;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  line-height: 1.45;
  max-height: 170px;
  padding: 7px 0;
}
.composer textarea:focus { outline: none; }
.composer textarea::placeholder { color: #b3ac9c; }

.send-btn {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--accent);
  color: #20150a;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  transition: background-color 0.15s, transform 0.06s, opacity 0.15s;
}
.send-btn:hover { background: var(--accent-2); }
.send-btn:active { transform: scale(0.94); }
.send-btn:disabled { opacity: 0.35; cursor: default; }

.composer-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px 4px;
  font-size: 11.5px;
  color: var(--ink-3);
}
.composer-meta .hint { flex: 1; }
.char-count { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink-3); }
.char-count.warn { color: var(--accent-deep); }

.conn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 10.5px;
}
.conn::before { content: ""; width: 7px; height: 7px; border-radius: 50%; }
.conn-live { color: var(--ok); }
.conn-live::before { background: var(--ok); }
.conn-connecting { color: var(--accent-deep); }
.conn-connecting::before { background: var(--accent); animation: conn-blink 1s infinite; }
.conn-offline { color: var(--danger); }
.conn-offline::before { background: var(--danger); }

@keyframes conn-blink { 50% { opacity: 0.3; } }

.jump-btn {
  position: absolute;
  bottom: 118px;
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--bg-2);
  color: var(--lt);
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  z-index: 10;
}
.jump-btn:hover { background: var(--bg-3); }

/* ---------------------------------------------------------------- members */

.members {
  background: var(--paper-2);
  border-left: 1px solid var(--paper-line);
  padding: 16px 14px;
  overflow-y: auto;
  min-height: 0;
  display: none;
}
.members h3 {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 14px 0 8px;
}
.members h3:first-child { margin-top: 0; }
.member-group { display: grid; gap: 2px; }
.member-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 8px;
  border-radius: 8px;
  color: var(--ink);
  font-size: 14px;
}
.member-row:hover { background: rgba(35, 37, 43, 0.05); }
.member-row .avatar { width: 30px; height: 30px; font-size: 11.5px; }
.member-row .m-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member-row .m-role {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--accent-deep);
  background: var(--accent-wash);
  padding: 2px 6px;
  border-radius: 4px;
}
.member-row.offline { opacity: 0.55; }
.member-row.offline:hover { opacity: 0.8; }

@media (min-width: 1280px) {
  .app:not(.members-off) .members { display: block; }
  .app { grid-template-columns: var(--rail-w) var(--side-w) minmax(0, 1fr) var(--members-w); }
}
.members-overlay .members {
  display: block;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(300px, 84vw);
  z-index: 60;
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.25);
  animation: slide-in-right 0.22s ease-out;
}

@keyframes slide-in-right {
  from { transform: translateX(30px); opacity: 0.4; }
  to { transform: none; opacity: 1; }
}

/* ------------------------------------------------------------ modal/scrim */

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(10, 11, 14, 0.6);
  backdrop-filter: blur(2px);
  z-index: 100;
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 110;
  pointer-events: none;
}
.modal-card {
  pointer-events: auto;
  width: min(440px, 100%);
  max-height: min(84vh, 720px);
  overflow-y: auto;
  background: var(--paper);
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.55);
  animation: modal-in 0.2s ease-out;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.modal-title {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 600;
  color: var(--ink);
}
.modal-sub { color: var(--ink-2); font-size: 13.5px; margin-bottom: 16px; }
.modal-close { color: var(--ink-2); }

.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions .btn { flex: 1; }

.invite-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px dashed var(--accent);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 6px;
}
.invite-code {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--accent-deep);
  text-align: center;
  user-select: all;
}
.invite-note { color: var(--ink-3); font-size: 12.5px; margin-top: 8px; }

.discover-list { display: grid; gap: 10px; margin-top: 4px; }
.discover-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  border: 1px solid var(--paper-line);
  border-radius: 12px;
  padding: 12px 14px;
}
.discover-item .d-body { flex: 1; min-width: 0; }
.discover-item .d-name { font-weight: 700; font-size: 14.5px; color: var(--ink); }
.discover-item .d-desc { font-size: 12.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.discover-item .d-count { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }
.discover-item .btn { width: auto; padding: 7px 16px; font-size: 13px; }
.discover-empty { color: var(--ink-2); font-size: 14px; text-align: center; padding: 18px 0 8px; }

/* ------------------------------------------------------------ responsive */

@media (max-width: 1100px) {
  :root { --side-w: 232px; --members-w: 232px; }
  .messages-inner, .chat-foot { padding-left: 16px; padding-right: 16px; }
}

@media (max-width: 940px) {
  .auth { grid-template-columns: 1fr; }
  .auth-left { padding: 40px 28px 28px; min-height: 38vh; }
  .auth-headline br { display: none; }
  .auth-headline { font-size: clamp(30px, 7vw, 44px); }
  .auth-points { margin-bottom: 22px; }
  .auth-right { padding: 20px 20px 32px; }
}

@media (max-width: 859px) {
  .app { grid-template-columns: var(--rail-w) minmax(0, 1fr); }
  .menu-btn { display: inline-flex; }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: var(--rail-w);
    width: min(78vw, 300px);
    transform: translateX(-115%);
    transition: transform 0.24s ease-out;
    box-shadow: none;
  }
  .app.sidebar-open .sidebar {
    transform: none;
    box-shadow: 24px 0 60px rgba(0, 0, 0, 0.45);
  }

  .chat-head { padding: 0 10px; gap: 8px; }
  .topic { display: none; }
  .head-sep { display: none; }
  .messages-inner, .chat-foot { padding-left: 12px; padding-right: 12px; }
  .msg { padding-left: 8px; padding-right: 8px; grid-template-columns: 34px minmax(0, 1fr); gap: 0 10px; }
  .msg-gutter { width: 34px; }
  .chat-foot { padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px)); }
  .jump-btn { bottom: 128px; }
}

@media (max-width: 560px) {
  :root { --rail-w: 60px; }
  .rail-btn { width: 42px; height: 42px; }
  .rail-actions { margin: 0 8px; }
  .msg-head .msg-time { font-size: 11px; }
  .modal-card { padding: 20px 18px; }
  .head-online span.u-label { display: none; }
  .composer-meta .hint { display: none; }
  .toasts { bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
