@font-face {
  font-family: "Young Serif";
  src: url("/fonts/young-serif-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Figtree";
  src: url("/fonts/figtree-latin-wght-normal.woff2") format("woff2");
  font-weight: 300 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Figtree";
  src: url("/fonts/figtree-latin-wght-italic.woff2") format("woff2");
  font-weight: 300 900;
  font-style: italic;
  font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
  --display: "Young Serif", Georgia, "Times New Roman", serif;
  --sans: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --ink: #262552;
  --paper: #f7f6fb;
  --paper-2: #ffffff;
  --mist: #ebe9f5;
  --mist-2: #dfdcef;
  --hover: rgba(38, 37, 82, 0.045);
  --text: #23213f;
  --muted: #67648a;
  --faint: #8f8cae;
  --line: rgba(38, 37, 82, 0.11);

  --teal: #17806f;
  --teal-ink: #ffffff;
  --teal-soft: rgba(23, 128, 111, 0.12);
  --gold: #e3a02f;
  --gold-ink: #3a2704;
  --rose: #c23a63;
  --online: #2a9d72;
  --shadow: 0 12px 44px rgba(38, 37, 82, 0.2);
}

:root[data-theme="dark"] { color-scheme: dark; }
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] {
  --ink: #0e0e24;
  --paper: #16162e;
  --paper-2: #1f1f3d;
  --mist: #1b1b36;
  --mist-2: #28284c;
  --hover: rgba(255, 255, 255, 0.04);
  --text: #e8e7f5;
  --muted: #a3a1c2;
  --faint: #76749a;
  --line: rgba(255, 255, 255, 0.09);

  --teal: #46c7ac;
  --teal-ink: #06251f;
  --teal-soft: rgba(70, 199, 172, 0.16);
  --gold: #f2b84b;
  --rose: #ff86a5;
  --online: #4cd39b;
  --shadow: 0 12px 44px rgba(0, 0, 0, 0.55);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #0e0e24;
    --paper: #16162e;
    --paper-2: #1f1f3d;
    --mist: #1b1b36;
    --mist-2: #28284c;
    --hover: rgba(255, 255, 255, 0.04);
    --text: #e8e7f5;
    --muted: #a3a1c2;
    --faint: #76749a;
    --line: rgba(255, 255, 255, 0.09);

    --teal: #46c7ac;
    --teal-ink: #06251f;
    --teal-soft: rgba(70, 199, 172, 0.16);
    --gold: #f2b84b;
    --rose: #ff86a5;
    --online: #4cd39b;
    --shadow: 0 12px 44px rgba(0, 0, 0, 0.55);
  }
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--paper);
  color: var(--text);
  font: 400 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.icon { display: inline-grid; place-items: center; flex-shrink: 0; }
.grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* The mark: two solid C's, one per voice, overlapping */
.mark { --d: 1.15em; display: inline-block; width: calc(var(--d) * 1.6); height: var(--d); flex-shrink: 0; overflow: visible; }
.mark path { fill: none; stroke-width: 15; stroke-linecap: round; stroke-linejoin: round; shape-rendering: geometricPrecision; }
.mark .a { stroke: #2fb59a; }
.mark .b { stroke: #f0b445; }
.mark path.cut { stroke: #000; stroke-width: 24; } /* the gap where the gold C passes in front of the teal one */

.splash { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; background: var(--paper); }
.splash-inner { position: relative; display: grid; justify-items: center; gap: 24px; }
.mark-splash { font-size: 80px; position: relative; }
.splash-glow {
  position: absolute; top: 0; left: 50%; width: 260px; height: 180px; translate: -50% -22px; filter: blur(22px); opacity: 0;
  background: radial-gradient(circle at 38% 50%, rgba(47, 181, 154, 0.3), transparent 55%), radial-gradient(circle at 62% 50%, rgba(240, 180, 69, 0.28), transparent 55%);
  animation: splash-glow-in 1.4s ease forwards, splash-glow 2.4s ease-in-out 1.4s infinite;
}
.splash-label { position: relative; margin: 0; font-weight: 650; letter-spacing: 0.04em; color: var(--text); }
.splash-quip { position: relative; margin: -16px 0 0; min-height: 1.4em; font-size: 13px; color: var(--muted); opacity: 0; animation: splash-quip 0.5s ease forwards; }
.splash-label .dots::after { content: ""; animation: splash-dots 1.4s steps(4) infinite; }

/* The logo draws itself in once, then the two C's ease apart and click back together on a loop. */
.mark-splash path { stroke-dasharray: 100; stroke-dashoffset: 100; }
.mark-splash .a { animation: splash-draw 1.1s cubic-bezier(0.22, 1, 0.36, 1) forwards, splash-a 2.4s ease-in-out 1.4s infinite; }
.mark-splash .b, .mark-splash .cut { animation: splash-draw 1.1s cubic-bezier(0.22, 1, 0.36, 1) 0.15s forwards, splash-b 2.4s ease-in-out 1.4s infinite; }
@keyframes splash-draw { to { stroke-dashoffset: 0; } }
@keyframes splash-a { 50% { transform: translateX(-5px); } }
@keyframes splash-b { 50% { transform: translateX(5px); } }
@keyframes splash-glow-in { to { opacity: 0.7; } }
@keyframes splash-glow { 50% { opacity: 1; scale: 1.08; } }
@keyframes splash-dots { 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }
@keyframes splash-quip { to { opacity: 1; } }

/* ---------- Buttons and fields ---------- */
.btn {
  height: 42px; padding: 0 18px; border-radius: 10px; font-weight: 650;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-primary { background: var(--teal); color: var(--teal-ink); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: var(--mist); color: var(--text); }
.btn-ghost:hover { background: var(--mist-2); }
.btn-danger { background: var(--rose); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); }
.btn-block { width: 100%; height: 48px; }
.btn:disabled { opacity: 0.6; cursor: default; }
.link { color: var(--teal); font-weight: 650; text-decoration: underline; text-underline-offset: 3px; }

.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 13px; font-weight: 650; }
.hint { font-size: 13px; color: var(--muted); }
.input {
  width: 100%; height: 46px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--paper-2);
}
.input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-soft); }
.form-error { color: var(--rose); font-size: 14px; min-height: 20px; margin: 0 0 8px; }
.form-error.ok { color: var(--teal); }

.field-error { color: var(--rose); font-size: 13px; min-height: 18px; display: block; }
.field-success { color: var(--teal); font-size: 13px; min-height: 18px; display: block; }

/* Strength meter */
.strength-meter { margin-top: 6px; }
.strength-bar { display: flex; gap: 4px; height: 4px; }
.strength-bar i { flex: 1; border-radius: 2px; background: var(--line); transition: background 0.2s ease; }
.strength-bar i:nth-child(1) { background: var(--rose); }
.strength-meter[data-level="1"] .strength-bar i:nth-child(1) { background: var(--rose); }
.strength-meter[data-level="2"] .strength-bar i:nth-child(1),
.strength-meter[data-level="2"] .strength-bar i:nth-child(2) { background: var(--gold); }
.strength-meter[data-level="3"] .strength-bar i:nth-child(1),
.strength-meter[data-level="3"] .strength-bar i:nth-child(2),
.strength-meter[data-level="3"] .strength-bar i:nth-child(3) { background: var(--gold); }
.strength-meter[data-level="4"] .strength-bar i { background: var(--teal); }
.strength-label { display: block; margin-top: 4px; font-size: 12px; color: var(--muted); }
.strength-meter[data-level="1"] .strength-label::after { content: "Very weak"; color: var(--rose); }
.strength-meter[data-level="2"] .strength-label::after { content: "Weak"; color: var(--gold); }
.strength-meter[data-level="3"] .strength-label::after { content: "Good"; color: var(--gold); }
.strength-meter[data-level="4"] .strength-label::after { content: "Strong"; color: var(--teal); }

/* Input validation states */
.input.valid { border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-soft); }
.input.invalid { border-color: var(--rose); box-shadow: 0 0 0 3px rgba(194, 58, 99, 0.15); }

/* ---------- Auth ---------- */
.auth { min-height: 100%; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); }
.auth-art {
  position: relative; overflow: hidden; background: #262552; color: #f3f1ff;
  padding: 40px 48px; display: flex; flex-direction: column; justify-content: space-between; min-height: 100vh;
}
.brand { position: relative; z-index: 1; display: flex; align-items: center; gap: 12px; font: 400 26px var(--display); }
.brand .mark { font-size: 22px; }
/* Soft colour blobs behind the sign-in art. Decorative and still. */
.blobs { position: absolute; inset: 0; pointer-events: none; }
.blob { position: absolute; display: block; filter: blur(64px); opacity: 0.5; }
.b1 { width: 420px; height: 400px; top: -140px; right: -120px; background: #7c5cf0; border-radius: 58% 42% 51% 49% / 46% 55% 45% 54%; }
.b2 { width: 360px; height: 340px; bottom: -110px; left: -110px; background: #2fb59a; border-radius: 44% 56% 62% 38% / 52% 40% 60% 48%; }
.b3 { width: 260px; height: 250px; bottom: 9%; right: 7%; background: #f0b445; border-radius: 55% 45% 40% 60% / 50% 58% 42% 50%; opacity: 0.42; }
.b4 { width: 220px; height: 230px; top: 36%; left: -80px; background: #d9527f; border-radius: 48% 52% 57% 43% / 55% 45% 55% 45%; opacity: 0.4; }
.art-copy { position: relative; z-index: 1; max-width: 560px; }
.art-copy h1 { margin: 0 0 14px; font: 400 clamp(42px, 5.4vw, 76px) / 1.02 var(--display); letter-spacing: -0.015em; }
.art-copy p { margin: 0; max-width: 38ch; font-size: 18px; line-height: 1.5; color: #c9c6e6; }

.auth-panel { display: grid; place-items: center; padding: 32px; background: var(--paper); }
.auth-card { width: min(380px, 100%); }
.auth-card h2 { margin: 0 0 6px; font: 400 36px / 1.1 var(--display); letter-spacing: -0.01em; }
.auth-sub { margin: 0 0 28px; color: var(--muted); }
.auth-switch { margin: 22px 0 0; color: var(--muted); }
.auth-legal { margin: 0 0 14px; font-size: 13px; color: var(--muted); }
.auth-links { margin: 18px 0 0; font-size: 13px; color: var(--faint); }
.auth-links a { color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- App shell ---------- */
.app {
  height: 100vh; height: 100dvh; display: grid;
  grid-template-columns: 72px 256px minmax(0, 1fr) 240px;
}
.app.no-members { grid-template-columns: 72px 256px minmax(0, 1fr); }
.app.no-members .members { display: none; }

/* Rail */
.rail {
  background: var(--ink); display: flex; flex-direction: column; align-items: center;
  gap: 10px; padding: 12px 0; overflow-y: auto; scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }
.rail-btn {
  --h: 170; position: relative; width: 48px; height: 48px; border-radius: 24px; flex-shrink: 0;
  display: grid; place-items: center; background: rgba(255, 255, 255, 0.09); color: #ebe9fb;
  font-weight: 700; font-size: 15px; transition: border-radius 0.15s, background 0.15s;
}
.rail-btn:hover, .rail-btn.active {
  border-radius: 16px; color: #fff;
  background: linear-gradient(135deg, hsl(var(--h) 52% 44%), hsl(calc(var(--h) + 28) 55% 34%));
}
.rail-btn.active::before {
  content: ""; position: absolute; left: -12px; top: 10px; width: 5px; height: 28px;
  border-radius: 0 4px 4px 0; background: var(--gold);
}
.rail-btn.unread::after {
  content: ""; position: absolute; right: -3px; top: -3px; width: 13px; height: 13px;
  border-radius: 50%; background: var(--gold); border: 3px solid var(--ink);
}
.rail-btn.rail-home { --h: 255; }
.rail-btn.rail-home .mark { font-size: 20px; }
.rail-btn.add { background: transparent; border: 1.5px dashed rgba(255, 255, 255, 0.32); color: #cfcce9; }
.rail-btn.add:hover { border-style: solid; border-color: transparent; background: var(--teal); color: var(--teal-ink); }
.rail-sep { width: 28px; height: 2px; border-radius: 1px; background: rgba(255, 255, 255, 0.14); flex-shrink: 0; }
.badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; flex-shrink: 0;
  display: inline-grid; place-items: center; background: var(--gold); color: var(--gold-ink);
  font-size: 12px; font-weight: 700;
}
.rail-badge { position: absolute; right: -6px; bottom: -4px; border: 3px solid var(--ink); box-sizing: content-box; }

/* Sidebar */
.sidebar { position: relative; background: var(--mist); display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); }
.side-head {
  width: 100%; height: 56px; flex-shrink: 0; display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 0 16px; border-bottom: 1px solid var(--line); text-align: left;
  font: 400 19px var(--display);
}
button.side-head:hover { background: var(--mist-2); }
.side-body { flex: 1; overflow-y: auto; padding: 8px 10px 12px; }
.group-label { display: flex; align-items: center; justify-content: space-between; padding: 12px 8px 6px; color: var(--muted); font-size: 13px; font-weight: 650; }
.icon-btn { width: 28px; height: 28px; border-radius: 8px; display: inline-grid; place-items: center; color: var(--muted); flex-shrink: 0; }
.icon-btn:hover { background: var(--mist-2); color: var(--text); }
.row {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 36px; padding: 6px 10px;
  border-radius: 8px; color: var(--muted); text-align: left;
}
.row:hover { background: var(--mist-2); color: var(--text); }
.row.active { background: var(--paper); color: var(--text); font-weight: 650; box-shadow: 0 1px 0 var(--line); }
.row.unread { color: var(--text); font-weight: 650; }
.row.offline .avatar { filter: saturate(0.5); opacity: 0.75; }
.hash { color: var(--faint); display: inline-grid; }
.pip { width: 8px; height: 8px; border-radius: 50%; background: var(--teal); flex-shrink: 0; }
.tag { font-size: 12px; color: var(--muted); font-weight: 600; }
.empty { padding: 16px 10px; color: var(--muted); }
.empty p { margin: 0 0 12px; }
.empty .btn-ghost { background: var(--paper); }
.empty .btn-ghost:hover { background: var(--paper-2); }

.menu {
  position: absolute; left: 10px; right: 10px; top: 60px; z-index: 20; padding: 6px;
  background: var(--paper-2); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
}
.menu-item { display: block; width: 100%; padding: 9px 10px; border-radius: 8px; text-align: left; font-weight: 550; }
.menu-item:hover { background: var(--teal-soft); }
.menu-item.danger { color: var(--rose); }
.menu-sep { height: 1px; margin: 6px 4px; background: var(--line); }

.user-panel { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-top: 1px solid var(--line); }
.user-text { flex: 1; min-width: 0; line-height: 1.25; }
.user-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-status { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }

/* Connection quality: three bars beside the status. Green for good, amber for slow, red for poor; none lit and pulsing while reconnecting. */
.signal { display: inline-flex; align-items: flex-end; gap: 2px; height: 11px; color: var(--faint); }
.signal i { width: 3px; border-radius: 1px; background: currentColor; opacity: 0.3; }
.signal i:nth-child(1) { height: 4px; }
.signal i:nth-child(2) { height: 7px; }
.signal i:nth-child(3) { height: 11px; }
.signal[data-level="good"] { color: var(--online); }
.signal[data-level="fair"] { color: var(--gold); }
.signal[data-level="poor"], .signal[data-level="off"] { color: var(--rose); }
.signal[data-level="good"] i, .signal[data-level="fair"] i:nth-child(-n + 2), .signal[data-level="poor"] i:nth-child(1) { opacity: 1; }
.signal[data-level="off"] { animation: signal-pulse 1.4s ease-in-out infinite; }
@keyframes signal-pulse { 50% { opacity: 0.4; } }

/* Avatars */
.av { position: relative; display: inline-grid; flex-shrink: 0; }
.avatar {
  --h: 200; --s: 40px; position: relative; overflow: hidden; width: var(--s); height: var(--s); border-radius: 50%; display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: calc(var(--s) * 0.42);
  background: linear-gradient(135deg, hsl(var(--h) 52% 42%), hsl(calc(var(--h) + 28) 55% 32%));
}
.dot {
  position: absolute; right: -2px; bottom: -2px; width: 11px; height: 11px; border-radius: 50%;
  background: var(--faint); border: 2px solid var(--dot-bg, var(--mist));
}
.dot.on { background: var(--online); }
.main-head .dot { --dot-bg: var(--paper); }
.row.active .dot { --dot-bg: var(--paper); }

/* Main */
.main { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--paper); }
.main-head {
  height: 56px; flex-shrink: 0; display: flex; align-items: center; gap: 12px; padding: 0 20px;
  border-bottom: 1px solid var(--line);
}
.head-title { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.head-sub { padding-left: 12px; border-left: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.menu-btn { display: none; width: 36px; height: 36px; margin-left: -8px; border-radius: 8px; place-items: center; color: var(--muted); }
.menu-btn:hover { background: var(--mist); }

.home { flex: 1; display: grid; place-items: center; padding: 32px; overflow-y: auto; }
.home-inner { width: min(520px, 100%); }
.home-inner h1 { margin: 0 0 10px; font: 400 clamp(34px, 4.4vw, 48px) / 1.08 var(--display); letter-spacing: -0.01em; }
.home-inner p { margin: 0; color: var(--muted); font-size: 17px; }
.home-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 26px 0 28px; }
.home-inner .hint { font-size: 14px; }

.chat { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.messages { flex: 1; overflow-y: auto; padding: 8px 0 12px; }
.welcome { padding: 36px 24px 20px; }
.welcome h2 { margin: 12px 0 6px; font: 400 32px / 1.1 var(--display); letter-spacing: -0.01em; }
.welcome p { margin: 0; max-width: 52ch; color: var(--muted); }
.welcome .av { margin-bottom: 4px; }
.day { display: flex; align-items: center; gap: 12px; margin: 18px 24px 6px; color: var(--muted); font-size: 12px; font-weight: 650; }
.day::before, .day::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.msg { position: relative; display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 14px; padding: 6px 24px; }
.msg:hover { background: var(--hover); }
.msg.cont { padding-top: 0; padding-bottom: 0; }
.msg.cont .av { visibility: hidden; height: 0; }
/* A message you've sent that the server hasn't confirmed yet: dimmed, with a line under it while it waits or if it failed. */
.msg.pending .msg-text, .msg.pending .attachments { opacity: 0.6; }
.msg-state { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; margin-top: 2px; font-size: 12px; color: var(--muted); }
.msg-state button { color: inherit; font: inherit; font-weight: 700; text-decoration: underline; }
.msg.failed .msg-state { color: var(--rose); }
.msg-meta { display: flex; align-items: baseline; gap: 8px; }
.author { font-weight: 700; }
.time { font-size: 12px; color: var(--faint); }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; }
.msg-text a { color: var(--teal); text-underline-offset: 2px; }
.msg-text code, .hint code { padding: 1px 6px; border-radius: 5px; background: var(--mist); font: 0.9em ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.msg-text pre { margin: 4px 0; padding: 10px 12px; border-radius: 10px; background: var(--mist); white-space: pre; overflow-x: auto; }
.msg-text pre code { padding: 0; background: none; }
.older-note { text-align: center; color: var(--muted); font-size: 13px; padding: 8px; }

.typing { height: 24px; flex-shrink: 0; padding: 0 24px; font-size: 13px; color: var(--muted); }
.dots i { display: inline-block; width: 4px; height: 4px; margin-left: 3px; border-radius: 50%; background: currentColor; animation: blink 1.2s infinite both; }
.dots i:nth-child(2) { animation-delay: 0.15s; }
.dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

.composer { flex-shrink: 0; padding: 0 20px 20px; }
.composer-box {
  display: flex; align-items: flex-end; gap: 8px; padding: 8px 8px 8px 16px; border-radius: 14px;
  background: var(--paper-2); border: 1px solid var(--line); box-shadow: 0 1px 2px rgba(38, 37, 82, 0.05);
}
.composer-box:focus-within { border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-soft); }
.composer textarea {
  flex: 1; min-height: 24px; max-height: 160px; padding: 6px 0; border: 0; outline: none;
  background: transparent; resize: none; line-height: 1.5;
}
.send { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; background: var(--teal); color: var(--teal-ink); }
.send:disabled { background: var(--mist-2); color: var(--faint); cursor: default; }

/* Members */
.members { background: var(--mist); border-left: 1px solid var(--line); overflow-y: auto; padding: 8px 10px 12px; }

/* ---------- Modal, toast, banner ---------- */
.backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(18, 18, 50, 0.5); animation: fade 0.12s ease-out; }
@keyframes fade { from { opacity: 0; } }
.modal { width: min(440px, 100%); max-height: calc(100dvh - 32px); overflow: auto; padding: 26px; border-radius: 16px; background: var(--paper-2); box-shadow: var(--shadow); }
.modal h3 { margin: 0 0 14px; font: 400 27px / 1.15 var(--display); letter-spacing: -0.01em; }
.modal .lede { margin: -8px 0 18px; color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.seg { display: inline-flex; margin-bottom: 18px; padding: 3px; border-radius: 10px; background: var(--mist); }
.seg button { padding: 7px 14px; border-radius: 8px; font-weight: 650; color: var(--muted); }
.seg button[aria-selected="true"] { background: var(--paper-2); color: var(--text); box-shadow: 0 1px 2px rgba(38, 37, 82, 0.14); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.chip { padding: 6px 12px; border-radius: 999px; background: var(--mist); font-size: 14px; font-weight: 600; }
.chip:hover { background: var(--teal-soft); }
.invite-code { margin: 4px 0 18px; padding: 14px; border-radius: 12px; background: var(--mist); text-align: center; font-size: 30px; font-weight: 700; letter-spacing: 0.14em; user-select: all; }

.invite-modal-body { max-height: 60vh; overflow: auto; }
.invite-list { display: flex; flex-direction: column; gap: 10px; }
.invite-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; padding: 12px; border-radius: 10px; background: var(--mist); }
.invite-row.inactive { opacity: 0.5; }
.invite-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.invite-info code { font-size: 18px; font-weight: 700; letter-spacing: 0.08em; }
.invite-meta { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--muted); }
.invite-actions { display: flex; gap: 6px; }
.invite-actions .btn { padding: 6px 10px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; max-width: min(92vw, 460px);
  padding: 11px 16px; border-radius: 10px; background: var(--ink); color: #f3f1ff;
  border: 1px solid rgba(255, 255, 255, 0.12); box-shadow: var(--shadow); animation: fade 0.15s ease-out;
}
.conn { position: fixed; top: 0; left: 50%; transform: translateX(-50%); z-index: 70; padding: 6px 14px; border-radius: 0 0 10px 10px; background: var(--gold); color: var(--gold-ink); font-size: 13px; font-weight: 700; }
.scrim { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .app, .app.no-members { grid-template-columns: 72px 240px minmax(0, 1fr); }
  .members { display: none; }
}
@media (max-width: 820px) {
  .auth { grid-template-columns: 1fr; }
  .auth-art { min-height: 0; padding: 24px; gap: 28px; }
  .preview { display: none; }
  .b1 { width: 300px; height: 280px; top: -110px; right: -90px; }
  .b2 { width: 260px; height: 240px; bottom: -100px; left: -80px; }
  .b3 { width: 180px; height: 170px; bottom: 12%; right: 4%; }
  .b4 { display: none; }
  .art-copy h1 { font-size: 40px; }
  .art-copy p { font-size: 16px; }
  .auth-panel { padding: 28px 20px 40px; align-items: start; }
}
@media (max-width: 720px) {
  .app, .app.no-members { grid-template-columns: minmax(0, 1fr); }
  .rail, .sidebar { position: fixed; top: 0; bottom: 0; z-index: 30; transition: transform 0.2s ease; }
  .rail { left: 0; width: 72px; transform: translateX(-110%); }
  .sidebar { left: 72px; width: min(256px, calc(100vw - 104px)); transform: translateX(calc(-100% - 80px)); }
  .app.nav-open .rail, .app.nav-open .sidebar { transform: none; }
  .app.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(18, 18, 50, 0.45); }
  .menu-btn { display: grid; }
  .msg { padding-left: 16px; padding-right: 16px; }
  .welcome, .typing { padding-left: 16px; padding-right: 16px; }
  .main-head { padding: 0 16px; }
  .composer { padding: 0 12px 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .mark-splash path { stroke-dashoffset: 0; }
  .splash-glow { opacity: 0.7; }
  .splash-quip { opacity: 1; }
}
:root[data-reduce-motion] *, :root[data-reduce-motion] *::before, :root[data-reduce-motion] *::after { animation: none !important; transition: none !important; }

.msg-tools { position: absolute; top: -14px; right: 20px; display: none; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper-2, #fff); box-shadow: 0 2px 8px rgba(20, 20, 60, 0.12); z-index: 2; }
.msg:hover .msg-tools, .msg:focus-within .msg-tools { display: flex; }
@media (hover: none) { .msg-tools { display: flex; position: static; grid-column: 2; justify-self: start; box-shadow: none; border: 0; padding: 0; } }
.tool { display: grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 7px; background: none; color: var(--muted); cursor: pointer; }
.tool:hover, .tool:focus-visible { background: var(--mist); color: inherit; }
.tool.danger:hover, .tool.danger:focus-visible { color: #c0392b; }
.edited { color: var(--muted); font-size: 11px; }
.edit-box { width: 100%; box-sizing: border-box; resize: none; padding: 8px 10px; border: 1px solid var(--teal); border-radius: 8px; background: var(--mist); color: inherit; font: inherit; line-height: 1.5; }
.edit-box:focus { outline: 2px solid var(--teal); outline-offset: 1px; }
.edit-hint { margin-top: 3px; color: var(--muted); font-size: 11px; }

.form-error.ok { color: var(--teal); }
.forgot { margin-top: 6px; font-size: 14px; align-self: flex-start; }
.input.mono, .codes code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: 0.06em; }
.codes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 4px 0 12px; }
.codes code { padding: 9px 10px; border-radius: 8px; background: var(--mist); text-align: center; user-select: all; font-size: 15px; }

.reactions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 5px; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border: 1px solid var(--line); border-radius: 999px; background: var(--mist); color: inherit; font: inherit; font-size: 13px; cursor: pointer; }
.chip:hover { border-color: var(--teal); }
.chip.mine { border-color: var(--teal); background: color-mix(in srgb, var(--teal) 16%, var(--mist)); }
.chip .emoji { font-size: 15px; line-height: 1; }
.chip .count { font-weight: 650; font-variant-numeric: tabular-nums; }
.picker { position: absolute; top: 20px; right: 20px; z-index: 4; display: flex; flex-wrap: wrap; gap: 2px; max-width: 200px; padding: 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper-2, #fff); box-shadow: 0 6px 20px rgba(20, 20, 60, 0.18); }
.pick { width: 36px; height: 36px; border: 0; border-radius: 8px; background: none; font-size: 20px; line-height: 1; cursor: pointer; }
.pick:hover, .pick:focus-visible { background: var(--mist); }

/* ---------- Replies ---------- */
.reply-ref { display: flex; align-items: center; gap: 6px; min-width: 0; max-width: 100%; margin: 0 0 2px; padding: 0; border: 0; background: none; color: var(--muted); font-size: 13px; text-align: left; cursor: pointer; }
.reply-ref .icon { color: var(--faint); }
.reply-ref b { flex-shrink: 0; font-weight: 650; color: var(--text); }
.reply-ref .snip { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-ref:hover .snip, .reply-ref:focus-visible .snip { color: var(--text); text-decoration: underline; text-underline-offset: 2px; }
.reply-ref.gone { cursor: default; font-style: italic; }
/* Highlights: a message replying to you is tinted, and the original flashes when you jump to it. */
.msg.reply-to-me { background: var(--teal-soft); box-shadow: inset 3px 0 0 var(--teal); }
.msg.reply-to-me:hover { background: color-mix(in srgb, var(--teal) 20%, transparent); }
.msg.flash { animation: flash 2.2s ease-out; }
@keyframes flash {
  0%, 35% { background: color-mix(in srgb, var(--gold) 32%, transparent); box-shadow: inset 3px 0 0 var(--gold); }
  100% { background: transparent; box-shadow: inset 3px 0 0 transparent; }
}
.reply-bar { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 14px; border: 1px solid var(--line); border-bottom: 0; border-radius: 14px 14px 0 0; background: var(--mist); color: var(--muted); font-size: 13px; }
.reply-bar .reply-who { flex-shrink: 0; }
.reply-bar b { color: var(--text); font-weight: 650; }
.reply-bar .snip { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-bar:not(.hidden) + .composer-box { border-radius: 0 0 14px 14px; }

/* ---------- Profiles ---------- */
.avatar.has-img { color: transparent; }
.avatar-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.av-btn { display: block; align-self: start; border-radius: 50%; }
.msg.cont .av-btn { visibility: hidden; height: 0; overflow: hidden; }
button.author { color: inherit; font-weight: 700; text-align: left; }
button.author:hover { text-decoration: underline; text-underline-offset: 2px; }
.user-btn { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; margin: -4px; padding: 4px; border-radius: 10px; text-align: left; }
.user-btn:hover { background: var(--mist-2); }
.btn-sm { height: 36px; padding: 0 14px; font-size: 14px; }

.modal.profile-card { width: min(380px, 100%); padding: 0; overflow: hidden; }
.pc-banner { position: relative; height: 128px; background: linear-gradient(135deg, hsl(var(--h) 52% 42%), hsl(calc(var(--h) + 28) 55% 32%)); }
.pc-banner img { display: block; width: 100%; height: 100%; object-fit: cover; }
.pc-close { position: absolute; top: 10px; right: 10px; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: rgba(14, 14, 36, 0.45); color: #fff; }
.pc-close:hover { background: rgba(14, 14, 36, 0.65); }
.pc-body { padding: 0 24px 24px; }
.pc-av { --dot-bg: var(--paper-2); width: fit-content; margin-top: -44px; padding: 5px; border-radius: 50%; background: var(--paper-2); }
.pc-av .dot { width: 18px; height: 18px; right: 2px; bottom: 2px; border-width: 4px; }
.pc-name { margin: 8px 0 0; font: 400 28px / 1.15 var(--display); letter-spacing: -0.01em; overflow-wrap: anywhere; }
.pc-status { color: var(--muted); font-size: 14px; }
.pc-actions { display: flex; gap: 10px; margin-top: 18px; }

.pe-preview { position: relative; margin-bottom: 52px; }
.pe-preview .pc-banner { height: 104px; border-radius: 12px; overflow: hidden; }
.pe-av { position: absolute; left: 16px; bottom: -40px; padding: 4px; border-radius: 50%; background: var(--paper-2); }
.pe-row { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; }
.pe-label { flex: 1; font-weight: 650; }
.modal .hint { margin: 4px 0 14px; }
@media (max-width: 720px) { .user-btn { margin: -2px; padding: 2px; } }

/* Crop adjuster */
.crop-view { position: relative; width: var(--w); height: var(--h); margin: 0 auto 16px; overflow: hidden; border-radius: 12px; background: var(--mist-2); cursor: grab; touch-action: none; user-select: none; }
.crop-view:active { cursor: grabbing; }
.crop-canvas { display: block; width: 100%; height: 100%; }
.crop-guide { position: absolute; inset: 0; pointer-events: none; }
.crop-view.round .crop-guide { border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.9); box-shadow: 0 0 0 999px rgba(14, 14, 36, 0.5); }
.crop-zoom { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; color: var(--muted); }
.crop-range { flex: 1; min-width: 0; accent-color: var(--teal); }

.load-older { display: flex; justify-content: center; padding: 14px 0 6px; }

/* Animated avatars and banners: the original sits over the still and fades in once it has loaded. */
.anim-frame { position: absolute; inset: 0; overflow: hidden; opacity: 0; }
.anim-frame.ready { opacity: 1; }
.anim-img { position: absolute; max-width: none; }
.pe-tag { margin-left: 8px; padding: 2px 8px; border-radius: 999px; background: var(--teal-soft); color: var(--teal); font-size: 12px; font-weight: 650; }
.keep-anim { margin: 0 0 14px; }
.keep-anim label { display: flex; align-items: center; gap: 8px; font-weight: 650; cursor: pointer; }
.keep-anim input { width: 18px; height: 18px; accent-color: var(--teal); }
.keep-anim .hint { margin: 4px 0 0 26px; }

/* ---------- Sign-in chat preview ---------- */
/* The art panel is always dark, so the preview carries its own colours instead of following the theme. */
.auth-art .preview {
  --pv-bg: #1b1b3a; --pv-bar: #16162f; --pv-line: rgba(255, 255, 255, 0.09); --pv-text: #e8e7f5; --pv-muted: #a3a1c2;
  position: relative; z-index: 1; width: min(100%, 440px); margin: 0 auto; border-radius: 16px; overflow: hidden;
  background: var(--pv-bg); border: 1px solid var(--pv-line); color: var(--pv-text); font-size: 14px;
  box-shadow: 0 24px 60px rgba(8, 8, 30, 0.5); transform: rotate(-1.5deg);
}
.pv-head { display: flex; align-items: center; gap: 8px; padding: 12px 16px; background: var(--pv-bar); border-bottom: 1px solid var(--pv-line); }
.pv-hash { color: var(--pv-muted); font-weight: 700; }
.pv-head b { font: 400 16px var(--display); }
.pv-sub { padding-left: 10px; border-left: 1px solid var(--pv-line); color: var(--pv-muted); font-size: 12px; }
.pv-online { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; color: var(--pv-muted); font-size: 12px; }
.pv-online i { width: 8px; height: 8px; border-radius: 50%; background: #4cd39b; }
.pv-body { display: flex; flex-direction: column; gap: 12px; padding: 14px 0 8px; }
.pv-msg { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 12px; padding: 4px 16px; }
.pv-msg.pv-mine { background: rgba(70, 199, 172, 0.14); box-shadow: inset 3px 0 0 #46c7ac; transition: background 0.6s ease, box-shadow 0.6s ease; }
.pv-av {
  --h: 200; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 14px;
  background: linear-gradient(135deg, hsl(var(--h) 52% 46%), hsl(calc(var(--h) + 28) 55% 34%));
}
/* Hues for the sign-in preview avatars. These are classes, not style attributes, because the CSP blocks inline styles. */
.pv-h262 { --h: 262; }
.pv-h170 { --h: 170; }
.pv-h340 { --h: 340; }
.pv-meta { display: flex; align-items: baseline; gap: 8px; }
.pv-meta b { font-weight: 700; }
.pv-meta span { color: var(--pv-muted); font-size: 11px; opacity: 0.8; }
.pv-text { line-height: 1.5; }
.pv-ref { display: flex; align-items: center; gap: 6px; min-width: 0; margin-bottom: 2px; color: var(--pv-muted); font-size: 12px; }
.pv-ref b { flex-shrink: 0; color: var(--pv-text); font-weight: 650; }
.pv-ref span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pv-chips { display: flex; gap: 6px; margin-top: 5px; }
.pv-chips span { display: inline-flex; align-items: center; gap: 5px; padding: 1px 9px; border-radius: 999px; border: 1px solid var(--pv-line); background: rgba(255, 255, 255, 0.05); font-size: 12px; font-weight: 650; }
.pv-chips span.mine { border-color: #46c7ac; background: rgba(70, 199, 172, 0.2); }
.pv-chips em { font-style: normal; font-size: 14px; line-height: 1; }
.pv-typing { padding: 0 16px; color: var(--pv-muted); font-size: 12px; }
.pv-dots i { display: inline-block; width: 4px; height: 4px; margin-right: 3px; border-radius: 50%; background: currentColor; opacity: 0.6; }
.pv-composer { display: flex; align-items: center; justify-content: space-between; margin: 4px 14px 14px; padding: 9px 10px 9px 14px; border-radius: 12px; border: 1px solid var(--pv-line); background: var(--pv-bar); color: var(--pv-muted); }
.pv-composer i { width: 26px; height: 26px; border-radius: 50%; background: rgba(255, 255, 255, 0.12); }
@media (max-height: 830px) { .auth-art .preview { display: none; } }

/* ---------- Password eye ---------- */
.pass-wrap { position: relative; }
.pass-wrap .input { padding-right: 46px; }
.eye { position: absolute; top: 0; right: 0; bottom: 0; width: 44px; display: grid; place-items: center; border: 0; background: none; color: var(--muted); border-radius: 0 10px 10px 0; cursor: pointer; }
.eye:hover { color: var(--text); }
.eye .eye-shut { display: none; }
.eye[aria-pressed="true"] .eye-open { display: none; }
.eye[aria-pressed="true"] .eye-shut { display: grid; }
.eye[aria-pressed="true"] { color: var(--teal); }

/* ---------- Preview motion ---------- */
/* JS adds .live (only when motion is allowed) and then switches steps on with .in. Without .live everything simply shows. */
.preview.live .pv-body { transition: opacity 0.5s ease; }
.preview.live .pv-body.resetting { opacity: 0; }
.preview.live .pv-step { transition: opacity 0.45s ease, transform 0.55s cubic-bezier(0.2, 0.8, 0.2, 1), background 0.6s ease, box-shadow 0.6s ease; }
.preview.live .pv-step:not(.in) { opacity: 0; transform: translateY(14px); }
.preview.live .pv-msg.pv-mine:not(.in) { background: transparent; box-shadow: inset 3px 0 0 transparent; }
.preview.live .pv-typing:not(.in) { transform: translateY(4px); }
.preview.live .pv-chips span { transition: opacity 0.25s ease, transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1); }
.preview.live .pv-chips span:not(.in) { opacity: 0; transform: scale(0.5); }
.pv-chips .n.bump { animation: pv-bump 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes pv-bump { 0% { transform: scale(1); } 40% { transform: scale(1.45); } 100% { transform: scale(1); } }

/* ---- Attachments ---- */
.attach-btn { align-self: center; display: grid; place-items: center; width: 32px; height: 32px; flex-shrink: 0; margin-left: -8px; border: 0; border-radius: 8px; background: none; color: var(--muted); cursor: pointer; }
.attach-btn:hover { background: var(--mist); color: var(--text); }
.attach-bar { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px; border: 1px solid var(--line); border-bottom: 0; border-radius: 14px 14px 0 0; background: var(--mist); }
.attach-bar.hidden { display: none; }
.att-chip { display: flex; align-items: center; gap: 8px; max-width: 260px; padding: 4px 4px 4px 6px; border-radius: 10px; background: var(--paper-2); border: 1px solid var(--line); font-size: 13px; }
.att-chip img { width: 32px; height: 32px; object-fit: cover; border-radius: 6px; }
.att-chip.busy { opacity: 0.65; }
.att-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-size { flex-shrink: 0; color: var(--muted); font-size: 12px; }
.attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.att-img img { display: block; max-width: min(360px, 100%); max-height: 300px; border-radius: 10px; border: 1px solid var(--line); }
.att-file { display: flex; align-items: center; gap: 10px; max-width: 320px; padding: 8px 12px; border-radius: 10px; background: var(--mist); border: 1px solid var(--line); color: var(--text); text-decoration: none; font-size: 14px; }
.att-file:hover { background: var(--mist-2); }
.chat.dropping { outline: 2px dashed var(--teal); outline-offset: -8px; }

/* Composer previews: a tile per file, the image itself or a file icon with its extension */
.att-chip { position: relative; flex-direction: column; align-items: stretch; gap: 4px; width: 112px; max-width: none; padding: 6px; }
.att-prev { position: relative; display: grid; place-items: center; height: 80px; border-radius: 8px; overflow: hidden; background: var(--mist-2); color: var(--muted); }
.att-chip .att-prev img { width: 100%; height: 100%; border-radius: 0; object-fit: cover; }
.att-ext { position: absolute; bottom: 6px; font-size: 11px; font-weight: 700; letter-spacing: 0.04em; }
.att-prev:has(.icon) { padding-bottom: 14px; }
.att-chip .att-name { font-size: 12px; }
.att-x { position: absolute; top: 10px; right: 10px; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 999px; background: rgba(0, 0, 0, 0.6); color: #fff; }

/* Settings */
.settings-list { display: flex; flex-direction: column; gap: 8px; }
.settings-row { display: block; width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper-2); color: var(--text); text-align: left; cursor: pointer; font: inherit; }
.settings-row:hover { background: var(--mist); }
.settings-row b { display: block; font-weight: 650; }
.settings-row small { display: block; margin-top: 2px; color: var(--muted); font-size: 13px; }
.settings-row.danger b { color: #e5566a; }

/* Appearance: compact messages, theme picker, switches */
:root[data-compact] .msg { grid-template-columns: 28px minmax(0, 1fr); gap: 10px; padding: 1px 20px; font-size: 14px; }
:root[data-compact] .msg .avatar { --s: 28px !important; }
:root[data-compact] .msg-text { line-height: 1.4; }
:root[data-compact] .msg:not(.cont) { padding-top: 4px; }
.settings-h { margin: 14px 0 6px; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.settings-h:first-child { margin-top: 0; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; border-radius: 12px; background: var(--mist); }
.seg-btn { padding: 7px 10px; border: 0; border-radius: 9px; background: none; color: var(--muted); font: inherit; font-weight: 650; cursor: pointer; }
.seg-btn.on { background: var(--paper-2); color: var(--text); box-shadow: 0 1px 3px rgba(20, 20, 60, 0.15); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 2px; cursor: pointer; }
.toggle-row b { display: block; font-weight: 650; }
.toggle-row small { display: block; margin-top: 2px; color: var(--muted); font-size: 13px; }
.switch { appearance: none; flex-shrink: 0; position: relative; width: 40px; height: 24px; margin: 0; border-radius: 999px; background: var(--mist-2); cursor: pointer; transition: background 0.15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); transition: transform 0.15s; }
.switch:checked { background: var(--teal); }
.switch:checked::after { transform: translateX(16px); }
.switch:focus-visible, .seg-btn:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

/* Notifications, mute, profile text */
.head-mute { margin-left: auto; }
.head-mute.on { color: var(--rose); }
.seg-btn { white-space: nowrap; }
.session-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 4px; }
.session-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper-2); }
.session-row b { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-weight: 650; }
.session-row small { display: block; margin-top: 2px; color: var(--muted); font-size: 13px; }
.session-tag { padding: 1px 8px; border-radius: 10px; background: var(--mist-2); color: var(--text); font-size: 12px; font-weight: 600; }
.mod-list { max-height: min(60vh, 520px); overflow-y: auto; }
.mod-reason { overflow-wrap: anywhere; }
.report-row { align-items: flex-start; }
.report-main { min-width: 0; flex: 1; }
.report-where { display: inline; margin-left: 8px; font-weight: 400; }
.report-quote { margin: 6px 0; padding: 6px 10px; border-left: 3px solid var(--line); overflow-wrap: anywhere; white-space: pre-wrap; }
.report-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.report-head { margin: 14px 0 4px; color: var(--muted); font-size: 13px; font-weight: 650; }
.audit-list { display: flex; flex-direction: column; }
.audit-row { display: flex; justify-content: space-between; gap: 12px; padding: 9px 4px; border-bottom: 1px solid var(--line); font-size: 14px; }
.audit-row:last-child { border-bottom: 0; }
.audit-text { overflow-wrap: anywhere; }
.audit-row time { flex: none; color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.settings-list + .settings-h, .hint + .toggle-row { margin-top: 4px; }
.pc-custom { margin-top: 4px; color: var(--text); font-size: 14px; overflow-wrap: anywhere; }
.pc-bio { margin-top: 12px; padding: 10px 12px; border-radius: 12px; background: var(--mist); text-align: left; }
.pc-bio-h { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.pc-bio p { margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45; font-size: 14px; }
.bio-input { resize: vertical; min-height: 64px; font: inherit; }

.pc-handle { color: var(--muted); font-size: 14px; margin-top: 2px; }

/* ---------- Colour themes ----------
   A palette is a hue (--h), how colourful the surfaces are (--k) and an accent for light and dark. The default
   Concord look has no data-palette and keeps the tokens above. Keep ids in sync with theme.js. */
:root[data-palette] {
  --ink: hsl(var(--h) calc(36% * var(--k)) 24%);
  --paper: hsl(var(--h) calc(40% * var(--k)) 97%);
  --paper-2: #ffffff;
  --mist: hsl(var(--h) calc(38% * var(--k)) 94%);
  --mist-2: hsl(var(--h) calc(34% * var(--k)) 89%);
  --hover: hsl(var(--h) calc(40% * var(--k)) 25% / 0.055);
  --text: hsl(var(--h) calc(34% * var(--k)) 17%);
  --muted: hsl(var(--h) calc(16% * var(--k)) 39%);
  --faint: hsl(var(--h) calc(14% * var(--k)) 58%);
  --line: hsl(var(--h) calc(40% * var(--k)) 25% / 0.12);
  --shadow: 0 12px 44px hsl(var(--h) calc(40% * var(--k)) 20% / 0.22);
  --teal: var(--accent-l);
  --teal-ink: #ffffff;
  --teal-soft: color-mix(in srgb, var(--accent-l) 14%, transparent);
}
:root[data-palette][data-theme="dark"] {
    --ink: hsl(var(--h) calc(42% * var(--k)) 7%);
    --paper: hsl(var(--h) calc(34% * var(--k)) 13%);
    --paper-2: hsl(var(--h) calc(30% * var(--k)) 18%);
    --mist: hsl(var(--h) calc(32% * var(--k)) 15.5%);
    --mist-2: hsl(var(--h) calc(28% * var(--k)) 23%);
    --hover: rgba(255, 255, 255, 0.045);
    --text: hsl(var(--h) calc(40% * var(--k)) 93%);
    --muted: hsl(var(--h) calc(22% * var(--k)) 71%);
    --faint: hsl(var(--h) calc(18% * var(--k)) 55%);
    --line: rgba(255, 255, 255, 0.09);
    --shadow: 0 12px 44px rgba(0, 0, 0, 0.55);
    --teal: var(--accent-d);
    --teal-ink: #08121a;
    --teal-soft: color-mix(in srgb, var(--accent-d) 18%, transparent);
}
@media (prefers-color-scheme: dark) {
  :root[data-palette]:not([data-theme="light"]) {
    --ink: hsl(var(--h) calc(42% * var(--k)) 7%);
    --paper: hsl(var(--h) calc(34% * var(--k)) 13%);
    --paper-2: hsl(var(--h) calc(30% * var(--k)) 18%);
    --mist: hsl(var(--h) calc(32% * var(--k)) 15.5%);
    --mist-2: hsl(var(--h) calc(28% * var(--k)) 23%);
    --hover: rgba(255, 255, 255, 0.045);
    --text: hsl(var(--h) calc(40% * var(--k)) 93%);
    --muted: hsl(var(--h) calc(22% * var(--k)) 71%);
    --faint: hsl(var(--h) calc(18% * var(--k)) 55%);
    --line: rgba(255, 255, 255, 0.09);
    --shadow: 0 12px 44px rgba(0, 0, 0, 0.55);
    --teal: var(--accent-d);
    --teal-ink: #08121a;
    --teal-soft: color-mix(in srgb, var(--accent-d) 18%, transparent);
  }
}
:root[data-palette="forest"] { --h: 150; --k: 1; --accent-l: #2e7d4f; --accent-d: #5fd08a; }
:root[data-palette="ocean"] { --h: 205; --k: 1; --accent-l: #1b73b8; --accent-d: #5cb8ff; }
:root[data-palette="sunset"] { --h: 18; --k: 1; --accent-l: #c4512a; --accent-d: #ff9a6b; --gh: -30; }
:root[data-palette="berry"] { --h: 330; --k: 1; --accent-l: #b5306f; --accent-d: #ff7fb5; }
:root[data-palette="grape"] { --h: 272; --k: 1; --accent-l: #7a43c4; --accent-d: #b995ff; }
:root[data-palette="sand"] { --h: 38; --k: 0.8; --accent-l: #946410; --accent-d: #f2b84b; --gs: 0.8; --gh: -25; }
:root[data-palette="graphite"] { --h: 225; --k: 0.22; --accent-l: #566a8c; --accent-d: #9fb3d9; --gs: 0.2; --gh: 25; }

.swatches { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.swatch { position: relative; width: 32px; height: 32px; padding: 0; border: 2px solid transparent; border-radius: 50%; background: var(--sw); cursor: pointer; box-shadow: inset 0 0 0 2px var(--paper-2); }
.swatch:hover { transform: scale(1.08); }
.swatch.on { border-color: var(--text); }
.swatch:focus-visible { outline: 2px solid var(--teal); outline-offset: 3px; }
.swatch-name { margin-top: 6px; color: var(--muted); font-size: 13px; }

/* ---------- Gradient background ----------
   Painted on the body from the palette hue; the panels turn translucent so it shows through. Phone drawers stay solid. */
:root { --h: 243; --k: 1; --gs: 1; --gh: 55; } /* --gs: gradient colourfulness, --gh: hue distance between its two ends */
:root[data-gradient] {
  --g1: hsl(var(--h) calc(85% * var(--gs)) 76%);
  --g2: hsl(calc(var(--h) + var(--gh)) calc(85% * var(--gs)) 62%);
}
:root[data-gradient][data-theme="dark"] {
  --g1: hsl(var(--h) calc(62% * var(--gs)) 30%);
  --g2: hsl(calc(var(--h) + var(--gh)) calc(65% * var(--gs)) 14%);
}
@media (prefers-color-scheme: dark) {
  :root[data-gradient]:not([data-theme="light"]) {
    --g1: hsl(var(--h) calc(62% * var(--gs)) 30%);
    --g2: hsl(calc(var(--h) + var(--gh)) calc(65% * var(--gs)) 14%);
  }
}
:root[data-gradient] body { background: linear-gradient(135deg, var(--g1), var(--g2)) fixed; }
:root[data-gradient] .main, :root[data-gradient] .auth-panel { background: color-mix(in srgb, var(--paper) 68%, transparent); }
:root[data-gradient] .sidebar, :root[data-gradient] .members { background: color-mix(in srgb, var(--mist) 52%, transparent); backdrop-filter: blur(12px); }
@media (min-width: 721px) {
  :root[data-gradient] .rail { background: color-mix(in srgb, var(--ink) 55%, transparent); }
}

/* Voice channels */
.seg-2 { grid-template-columns: repeat(2, 1fr); }
.seg-2 button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.vc-row:disabled { opacity: 0.55; cursor: not-allowed; }
.vc-row.active { color: var(--teal); }
.vc-row.active .hash { color: var(--teal); }
.vc-count { font-size: 12px; font-weight: 600; color: var(--faint); font-variant-numeric: tabular-nums; }
.vc-users { margin: 0 0 4px 20px; padding-left: 8px; border-left: 1px solid var(--line); }
.vc-user { display: flex; align-items: center; gap: 8px; min-height: 30px; padding: 3px 8px; border-radius: 8px; color: var(--muted); font-size: 14px; }
.vc-user .avatar { transition: box-shadow 0.12s ease; }
.vc-user.speaking { color: var(--text); }
.vc-user.speaking .avatar { box-shadow: 0 0 0 2px var(--online), 0 0 0 4px color-mix(in srgb, var(--online) 28%, transparent); }
.vc-vol-btn { width: 24px; height: 24px; margin-left: 2px; opacity: 0; }
.vc-user:hover .vc-vol-btn, .vc-vol-btn:focus-visible, .vc-vol-btn[aria-expanded="true"] { opacity: 1; }
.vc-vol { font-size: 12px; font-weight: 650; color: var(--muted); }
.vc-volume { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 2px 8px 6px 38px; }
.vc-slider { flex: 1 1 80px; min-width: 80px; accent-color: var(--teal); }
.vc-vol-num { min-width: 2.6em; font-size: 12px; color: var(--muted); text-align: right; }
.vc-reset { height: 28px; padding: 0 10px; font-size: 12px; }
.vc-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vc-flag { display: inline-grid; color: var(--faint); flex-shrink: 0; }
.voice-panel { display: flex; align-items: center; gap: 2px; padding: 8px 8px 8px 14px; border-top: 1px solid var(--line); background: color-mix(in srgb, var(--teal) 7%, var(--mist)); }
.vp-info { flex: 1; min-width: 0; line-height: 1.25; }
.vp-status { font-size: 13px; font-weight: 700; color: var(--teal); }
.vp-status.pending { color: var(--muted); }
.vp-where { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.voice-panel .icon-btn.on { background: color-mix(in srgb, #d14343 16%, transparent); color: #d14343; }
.voice-panel .icon-btn:last-child:hover { color: #d14343; }
:root[data-reduce-motion] .vc-user .avatar { transition: none; }

/* Roles and permissions */
.row-wrap { display: flex; align-items: center; gap: 2px; }
.row-wrap .row { flex: 1; min-width: 0; }
.row-wrap .icon-btn { opacity: 0; }
.row-wrap:hover .icon-btn, .row-wrap .icon-btn:focus-visible { opacity: 1; }
@media (hover: none) { .row-wrap .icon-btn { opacity: 1; } }
.roles-ui { display: grid; gap: 2px; max-height: min(60vh, 520px); overflow-y: auto; }
.role-row { display: flex; align-items: center; gap: 4px; }
.role-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; text-align: left; font-weight: 600; }
.role-main:hover { background: var(--mist-2); }
.role-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; background: var(--faint); }
.icon-btn:disabled { opacity: 0.3; cursor: default; pointer-events: none; }
.cat-label { padding-top: 14px; }
.cat-toggle { display: flex; align-items: center; gap: 4px; flex: 1; min-width: 0; padding: 0; text-align: left; color: inherit; font: inherit; }
.cat-toggle:hover { color: var(--text); }
.cat-toggle .chev { display: inline-flex; transition: transform 0.15s; }
.cat-toggle[aria-expanded="false"] .chev { transform: rotate(-90deg); }
.cat-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-toggle .pip { margin-left: 4px; }
.cat-manage { display: flex; align-items: center; gap: 4px; padding: 14px 4px 4px; color: var(--text); }
.cat-manage .cat-name { font-weight: 700; }
.chan-editing { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; }
.chan-select { width: auto; max-width: 9.5em; height: 32px; padding: 0 6px; font-size: 13px; }
.cat-empty { margin: 0 4px 4px; }
.chan-name { cursor: default; }
.chan-name:hover { background: none; }
.chan-edit { flex: 1; min-width: 0; }
.roles-ui .hint { margin: 10px 4px 0; font-size: 12.5px; color: var(--muted); }
.roles-ui .group-label { padding: 12px 4px 4px; }
.role-new { margin-top: 10px; justify-self: start; display: inline-flex; align-items: center; gap: 6px; }
.role-back { justify-self: start; margin-bottom: 8px; }
.role-swatches { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.role-swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent; background: var(--mist-2); box-shadow: inset 0 0 0 1px var(--line); }
.role-swatch[aria-pressed="true"] { border-color: var(--text); }
.role-swatch.none { background: linear-gradient(135deg, transparent 46%, var(--faint) 46% 54%, transparent 54%), var(--mist-2); }
.role-custom { width: 30px; height: 30px; padding: 0; border: 0; background: none; cursor: pointer; }
.role-perms { display: grid; margin-top: 4px; }
.switch:disabled { opacity: 0.45; cursor: default; }
.role-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

/* Search */
.search-results { display: grid; gap: 2px; margin-top: 12px; max-height: min(52vh, 460px); overflow-y: auto; }
.search-hit { display: grid; gap: 3px; padding: 9px 10px; border-radius: 8px; text-align: left; }
.search-hit:hover { background: var(--mist-2); }
.search-meta { display: flex; gap: 8px; align-items: baseline; font-size: 13px; color: var(--muted); }
.search-meta b { color: var(--text); font-weight: 650; }
.search-meta time { margin-left: auto; }
.search-text { overflow-wrap: anywhere; }
.search-text mark { background: color-mix(in srgb, var(--teal) 28%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }
.search-more { justify-self: center; margin-top: 8px; }
.head-search { margin-left: 4px; }

/* Voice settings and push to talk */
.range-row { display: flex; align-items: center; gap: 12px; }
.range { flex: 1; accent-color: var(--teal); }
.range-val { min-width: 54px; text-align: right; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.mic-meter { height: 8px; border-radius: 999px; background: var(--mist-2); overflow: hidden; }
.mic-meter-wrap { position: relative; }
.gate-mark { position: absolute; top: -5px; bottom: -5px; left: var(--gate, 10%); width: 2px; margin-left: -1px; border-radius: 2px; background: var(--gold); }
.mic-bar { height: 100%; width: 0; background: var(--teal); transition: width 0.08s linear; }
select.input { appearance: auto; }
.vp-ptt { font-size: 12px; color: var(--muted); }
.voice-panel.talking { background: color-mix(in srgb, var(--teal) 22%, var(--mist)); }
.voice-panel.talking .vp-ptt { color: var(--teal); font-weight: 700; }
@media (hover: none) { .vc-vol-btn { opacity: 1; } }
