/* Earshot — one stylesheet, no build step.
   Tokens first, then layout, then components. Light and dark share every rule.

   The signature is the paper edge: a thin tinted line under a surface, as if a
   sheet of coloured paper were tucked under it. Every place has a tint (--tint);
   it colours its dot and its edge.

   The rules, so it stays one design:
   - The edge (--edge) means "a thing": cards, the composer, attachments, link
     previews, rail cards, dialogs. Controls use the same geometry in their own
     colour (0 var(--edge-y) 0 -1px).
   - A shadow means "floating above the page": dialogs, menus, the palette, the
     message toolbar, toasts, slide-overs. Things in the flow have none.
   - A 3px bar on the left means "this line is marked": a mention of you, the
     picked or chosen message, the active row of a list. Never on an object.
   - Quotes keep their typographic rule; code is a quiet filled box.
   - Four corners: --r-xs inline bits, --r-s controls and rows, --r-m cards and
     content, --r-l overlays and large surfaces; pills 999px, circles 50%. */

:root {
  /* A colour is light-dark(light, dark): it follows color-scheme, which follows the
     system unless data-theme picks one. The few values that are not colours are below. */
  --bg: light-dark(#fbf7f0, #1b1815);
  --panel: light-dark(#fffdf9, #231f1b);
  --side: light-dark(#f3ece1, #151210);
  --side-hover: light-dark(#ebe2d4, #221d19);
  --side-active: light-dark(#fffdf9, #2c2621);
  --ink: light-dark(#2a2420, #f2ece4);
  --ink-2: light-dark(#5e554c, #c4baae);
  --ink-3: light-dark(#8f857a, #908679);
  --line: light-dark(#ebe2d5, #2f2924);
  --line-2: light-dark(#dccfbd, #40382f);
  --hover: light-dark(#f6f0e7, #28221e);
  --accent: light-dark(#f0573a, #ff7a5c);
  --accent-2: light-dark(#d4432a, #ff967c);
  --accent-ink: light-dark(#ffffff, #24110b);
  --accent-soft: light-dark(#fde6dd, #45291f);
  --accent-edge: light-dark(#c23d24, #b4472e);
  --ring: light-dark(#fde6dd, rgb(255 122 92 / 32%));
  --select: light-dark(#fde6dd, #352e28);
  --ok: light-dark(#2fa463, #4cc27f);
  --warn: #e0a800;
  --danger: light-dark(#d23f3f, #ff6b63);
  --danger-soft: light-dark(#fbe5e3, #3d201f);
  --mention-bg: light-dark(#fff5d9, #262119);
  --mention-line: light-dark(#e8b31c, #d9a520);
  --mark-bg: light-dark(#f6c945, rgb(240 190 60 / 20%));
  --mark-ink: light-dark(#3a2600, #f7d36b);
  --note-bg: light-dark(#fff6d6, #2f2b21);
  --note-line: light-dark(#f0d27a, #5c5130);
  --code-bg: light-dark(#f4ede2, #2b2520);
  --sticker: light-dark(#ffe27a, #f0cc55);
  --tip-bg: light-dark(#2a2420, #3d352e);
  --tip-ink: light-dark(#fbf7f0, #f2ece4);
  --scrim: light-dark(rgb(30 20 12 / 40%), rgb(0 0 0 / 55%));
  --lift: 82%;
  --lift-to: light-dark(#000000, #ffffff);
  --avatar-dim: 100%;
  --glow: 18%;
  --sticker-ink: #3d2f00;
  --shadow-1: 0 1px 2px rgb(60 40 20 / 6%), 0 1px 1px rgb(60 40 20 / 4%);
  --shadow-2: 0 12px 32px rgb(60 40 20 / 14%), 0 2px 6px rgb(60 40 20 / 8%);
  --edge-tint: var(--accent);
  --edge-y: 3px;
  --edge-mix: 32%;
  /* Four corners, by what a thing is: inline bits, controls and rows, cards and content,
     overlays and large surfaces. Pills and circles are 999px and 50%. */
  --r-xs: 5px;
  --r-s: 10px;
  --r-m: 14px;
  --r-l: 20px;
  --side-w: 264px;
  --panel-w: 392px;
  --rail-w: 292px;
  --font: "Figtree", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji";
  --display: "Bricolage Grotesque", "Figtree", ui-sans-serif, system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --hand: "Caveat", "Bradley Hand", "Segoe Print", cursive;
  color-scheme: light dark;
}

:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

/* Dark values that are not colours. The system's dark mode and a chosen dark theme
   need one selector each, so these few lines are written twice. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --lift: 70%;
    --avatar-dim: 86%;
    --glow: 7%;
    --shadow-1: 0 1px 2px rgb(0 0 0 / 30%);
    --shadow-2: 0 14px 36px rgb(0 0 0 / 50%), 0 2px 6px rgb(0 0 0 / 30%);
    --edge-y: 2px;
    --edge-mix: 34%;
  }
}

:root[data-theme="dark"] {
  --lift: 70%;
  --avatar-dim: 86%;
  --glow: 7%;
  --shadow-1: 0 1px 2px rgb(0 0 0 / 30%);
  --shadow-2: 0 14px 36px rgb(0 0 0 / 50%), 0 2px 6px rgb(0 0 0 / 30%);
  --edge-y: 2px;
  --edge-mix: 34%;
}

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

*, *::before, *::after {
  box-sizing: border-box;
  /* Worked out on each element, so the edge takes the tint of the place it belongs to. */
  --edge: 0 var(--edge-y) 0 -1px color-mix(in srgb, var(--tint, var(--edge-tint)) var(--edge-mix), var(--line-2));
}
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.5 var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img, video { max-width: 100%; }
h1, h2, h3 { margin: 0; line-height: 1.2; font-family: var(--display); font-weight: 700; letter-spacing: -.01em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
kbd { font: 500 11px var(--mono); padding: 1px 5px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: var(--r-xs); background: var(--panel); color: var(--ink-2); }
code { font-family: var(--mono); }
.icon { flex: none; display: block; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.lead { font-size: 16px; color: var(--ink-2); margin: 0; }
.center { text-align: center; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.k-pc { display: none; }
html.pc .k-pc { display: inline; }
html.pc .k-mac { display: none; }

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

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: var(--r-s);
  border: 1px solid var(--line-2); background: var(--panel); color: var(--ink);
  font-weight: 650; font-size: 14px; white-space: nowrap; text-decoration: none !important;
  box-shadow: 0 var(--edge-y) 0 -1px var(--line-2);
  transition: background .15s, border-color .15s, transform .06s, box-shadow .15s;
}
.btn:hover { background: var(--hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 var(--edge-y) 0 -1px var(--accent-edge); }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.primary:active { box-shadow: none; }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--hover); }
.btn.danger, .btn.ghost.danger { color: var(--danger); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: var(--r-s); }
.btn.big { height: 48px; padding: 0 26px; font-size: 16px; border-radius: var(--r-m); }
.btn.wide { width: 100%; }

.icon-btn {
  position: relative;
  display: inline-grid; place-items: center; gap: 5px; grid-auto-flow: column;
  min-width: 36px; height: 36px; padding: 0 8px; border-radius: var(--r-s);
  border: 0; background: transparent; color: var(--ink-2); text-decoration: none !important;
  font-size: 13px; font-weight: 600;
}
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn.sm { min-width: 28px; height: 28px; padding: 0 4px; border-radius: var(--r-s); }
.icon-btn.danger:hover { color: var(--danger); background: var(--danger-soft); }
.icon-btn.follow.on { color: var(--accent-2); background: var(--accent-soft); }

input[type="text"], input[type="email"], input[type="password"], input[type="search"], select, textarea {
  width: 100%; border: 1px solid var(--line-2); border-radius: var(--r-s); background: var(--panel);
  padding: 9px 12px; outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%); background-position: calc(100% - 16px) 55%, calc(100% - 11px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }

.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; font-weight: 700; color: var(--ink-2); }
.hint { color: var(--ink-3); font-size: 12px; }
.check { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent); }
.check span { display: grid; }
.check small { color: var(--ink-3); }
.input-prefix { display: flex; align-items: center; border: 1px solid var(--line-2); border-radius: var(--r-s); background: var(--panel); padding-left: 12px; }
.input-prefix:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.input-prefix > span { color: var(--ink-3); font-weight: 700; }
.input-prefix > span:last-child:not(:first-child) { padding-right: 12px; }
.input-prefix input { border: 0; box-shadow: none !important; padding-left: 4px; }
.input-prefix.grow { flex: 1; }
.form-error { color: var(--danger); font-size: 14px; margin: 0; }
.stack { display: grid; gap: 14px; }
.stack.tight { gap: 6px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line-2); background: var(--panel); border-radius: var(--r-s); padding: 4px 10px; font-size: 13px; }
.chip:hover { background: var(--hover); }
.segmented { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--r-s); overflow: hidden; width: fit-content; background: var(--panel); }
.segmented button { display: inline-flex; gap: 7px; align-items: center; border: 0; background: none; padding: 7px 14px; border-right: 1px solid var(--line-2); font-weight: 600; font-size: 14px; color: var(--ink-2); }
.segmented button:last-child { border-right: 0; }
.segmented button:hover:not(:disabled) { background: var(--hover); color: var(--ink); }
.segmented button[aria-pressed="true"] { background: var(--select); color: var(--ink); box-shadow: inset 0 -2px 0 var(--accent); }
.segmented button:disabled { cursor: default; }
.tag { font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: var(--r-s); background: var(--hover); color: var(--ink-2); white-space: nowrap; }
.tag.ok { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line-2); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- tints, locks, avatars ---------- */

.tint-dot { width: 10px; height: 10px; border-radius: 3px; background: var(--tint, var(--accent)); flex: none; display: inline-block; transform: rotate(8deg); }
.lock { display: inline-flex; flex: none; color: var(--ink-3); }

.avatar {
  --size: 36px; position: relative; flex: none;
  width: var(--size); height: var(--size); border-radius: 32%;
  background: color-mix(in srgb, var(--tint) var(--avatar-dim), #000);
  color: color-mix(in srgb, var(--tint) 28%, #1f140c); display: inline-grid; place-items: center;
  font-weight: 800; font-size: calc(var(--size) * .4); letter-spacing: .02em;
}
.avatar img { width: 100%; height: 100%; border-radius: inherit; object-fit: cover; }
.avatar .dot {
  position: absolute; right: -2px; bottom: -2px; width: 34%; height: 34%; min-width: 9px; min-height: 9px;
  border-radius: 50%; background: var(--ink-3); border: 2px solid var(--side);
}
.avatar .dot.on { background: var(--ok); }
.group-face { width: 22px; height: 22px; border-radius: 32%; background: var(--line-2); color: var(--ink-2); font-size: 11px; font-weight: 800; display: inline-grid; place-items: center; flex: none; }
.group-face.lg { width: 32px; height: 32px; font-size: 13px; }

/* ---------- tooltips and key stickers ---------- */

@media (hover: hover) and (pointer: fine) {
  [data-tip] { position: relative; }
  [data-tip]:hover::before, [data-tip]:focus-visible::before {
    content: attr(data-tip); white-space: pre;
    position: absolute; z-index: 60; left: 50%; top: calc(100% + 7px); transform: translateX(-50%);
    padding: 4px 9px; border-radius: var(--r-s); background: var(--tip-bg); color: var(--tip-ink);
    font: 600 12px/1.4 var(--font); letter-spacing: 0; pointer-events: none;
    box-shadow: var(--shadow-1); animation: tip .12s ease-out .45s both;
  }
  html.pc [data-tip]:hover::before, html.pc [data-tip]:focus-visible::before { content: attr(data-tip-pc); }
  .composer-bar [data-tip]:hover::before, .tools [data-tip]:hover::before, .pill[data-tip]:hover::before, .ear[data-tip]:hover::before { top: auto; bottom: calc(100% + 7px); }
  .nav-title [data-tip]:hover::before { left: auto; right: 0; transform: none; }
  html.show-keys [data-tip]::before { display: none; }
}
@keyframes tip { from { opacity: 0; translate: 0 -2px; } }

[data-kbd] { position: relative; }
html.show-keys [data-kbd]::after {
  content: attr(data-kbd);
  position: absolute; z-index: 61; right: -6px; top: -9px;
  padding: 1px 7px; border-radius: var(--r-xs);
  background: var(--sticker); color: var(--sticker-ink);
  font: 700 11px/1.5 var(--mono); white-space: nowrap;
  box-shadow: 0 1px 0 rgb(0 0 0 / 15%), var(--shadow-1);
  transform: rotate(-4deg); pointer-events: none;
  animation: stick .16s cubic-bezier(.3, 1.6, .5, 1);
}
html.pc.show-keys [data-kbd]::after { content: attr(data-kbd-pc); }
html.show-keys [data-kbd]:nth-of-type(even)::after { transform: rotate(3deg); }
@keyframes stick { from { transform: scale(.4) rotate(-14deg); opacity: 0; } }

/* ---------- auth ---------- */

.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(900px 500px at 12% -10%, var(--accent-soft), transparent 60%), radial-gradient(700px 500px at 100% 110%, color-mix(in srgb, var(--warn) var(--glow), transparent), transparent 60%), var(--bg); }
.auth-stack { width: min(420px, 100%); display: grid; justify-items: center; gap: 16px; }
.auth-card { width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-l); padding: 32px 28px; box-shadow: var(--edge); display: grid; gap: 18px; }
.auth-card h1 { font-size: 28px; text-align: center; }
.auth-card .lead { margin: -8px 0 4px; text-align: center; }
.auth-logo { width: 58px; height: 58px; margin: 0 auto; border-radius: var(--r-m); background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; transform: rotate(-6deg); box-shadow: 0 4px 0 var(--accent-edge); }

/* ---------- shell ---------- */

.shell {
  display: grid; height: 100dvh; overflow: hidden;
  grid-template-columns: var(--side-w) minmax(0, 1fr) auto auto;
  grid-template-areas: "side main panel rail";
}
.shell > .sidebar, .nav-live > .sidebar { grid-area: side; }
.shell > .chat, .shell > .page { grid-area: main; }
.shell > .panel { grid-area: panel; }
.shell > .rail { grid-area: rail; }
.nav-live { display: contents; }
.scrim { display: none; }

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

.sidebar { background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; padding-top: env(safe-area-inset-top); }
.side-head { padding: 10px 10px 4px; }
.ws-menu { position: relative; }
.ws-menu summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-s); cursor: pointer; font: 750 17px var(--display); }
.ws-menu summary::-webkit-details-marker { display: none; }
.ws-menu summary:hover { background: var(--side-hover); }
.ws-logo { width: 30px; height: 30px; border-radius: var(--r-s); background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; flex: none; font: 800 17px var(--display); transform: rotate(-6deg); box-shadow: 0 2px 0 var(--accent-edge); }
.ws-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px); background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-l); box-shadow: var(--edge), var(--shadow-2); padding: 6px; display: grid; }
.menu a, .menu button { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-s); border: 0; background: none; color: var(--ink); text-align: left; text-decoration: none; font-size: 14px; }
.menu a:hover, .menu button:hover { background: var(--hover); }
.menu .danger { color: var(--danger); }
.built-with { color: var(--ink-3); font-size: 12px; text-decoration: none !important; }
.built-with strong { font-weight: 700; color: var(--ink-2); }
.built-with:hover, .built-with:hover strong { color: var(--accent-2); }
.menu .built-with { justify-content: center; gap: 4px; padding: 6px 10px 4px; font-size: 12px; color: var(--ink-3); }
.find { display: flex; align-items: center; gap: 9px; margin: 4px 12px 10px; padding: 8px 11px; border-radius: var(--r-s); border: 1px solid var(--line-2); background: var(--panel); color: var(--ink-3); font-size: 14px; text-align: left; box-shadow: 0 var(--edge-y) 0 -1px var(--line-2); }
.find span { flex: 1; }
.find:hover { color: var(--ink-2); border-color: var(--ink-3); }
.side-scroll { flex: 1; overflow-y: auto; padding: 0 8px 12px; scrollbar-width: thin; }
.nav-section { margin-bottom: 16px; }
.nav-title { display: flex; justify-content: space-between; align-items: center; padding: 4px 6px 4px 10px; color: var(--ink-3); font: 700 12px var(--font); text-transform: uppercase; letter-spacing: .08em; }
.nav-item { position: relative; display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: var(--r-s); color: var(--ink-2); text-decoration: none !important; font-size: 15px; min-height: 34px; }
.nav-item:hover { background: var(--side-hover); color: var(--ink); }
.nav-item[aria-current="page"] { background: var(--side-active); color: var(--ink); font-weight: 650; box-shadow: var(--edge); }
.nav-item.unread { color: var(--ink); font-weight: 750; }
.nav-item.muted { opacity: .55; }
.nav-item.subtle { color: var(--ink-3); font-size: 14px; }
.nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .lock, .nav-item .tint-dot { margin: 0 6px 0 6px; }
.nav-item .avatar .dot { border-color: var(--side); }
.nav-item:hover .avatar .dot { border-color: var(--side-hover); }
.threads-link { margin-bottom: 10px; }
.threads-link .icon { margin: 0 3px 0 2px; color: var(--ink-3); }
.thread-card { align-items: flex-start; }
.thread-card.unread { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.thread-meta { display: flex; gap: 8px; align-items: baseline; }
.thread-text { color: var(--ink); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.cards.threads { grid-template-columns: 1fr; }
.unread-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); flex: none; margin-top: 6px; }
.nav-empty { margin: 2px 10px; color: var(--ink-3); font-size: 13px; }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-s); background: var(--ink-2); color: var(--side); font-size: 11px; font-weight: 800; display: inline-grid; place-items: center; }
.badge.mention { background: var(--accent); color: var(--accent-ink); }
.live-pill { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 800; color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, transparent); padding: 1px 6px; border-radius: var(--r-s); }
.hold-hint { display: flex; align-items: center; gap: 6px; padding: 2px 16px 6px; color: var(--ink-3); font: 600 17px/1.1 var(--hand); }
.hold-on { display: none; color: var(--accent-2); }
html.show-keys .hold-on { display: inline; }
html.show-keys .hold-off { display: none; }
.hold-arrow { width: 14px; height: 14px; border-left: 2px solid currentColor; border-bottom: 2px solid currentColor; border-radius: 0 0 0 8px; transform: translateY(-3px); opacity: .7; }
@media (hover: none) { .hold-hint { display: none; } }
.me-card { display: flex; align-items: center; gap: 10px; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); color: var(--ink); text-decoration: none !important; }
.me-card:hover { background: var(--side-hover); }
.me-text { flex: 1; min-width: 0; display: grid; line-height: 1.25; }
.me-text strong { font-size: 14px; }
.me-text small { color: var(--ink-3); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- the rail: keeping an ear on ---------- */

.rail { width: var(--rail-w); background: var(--side); border-left: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; min-height: 0; overflow-y: auto; padding: calc(12px + env(safe-area-inset-top)) 12px 14px; scrollbar-width: thin; }
html.rail-off .rail { display: none; }
.rail-head { display: flex; align-items: center; gap: 8px; color: var(--ink-2); padding: 4px 4px 2px; }
.rail-head h2 { font-size: 15px; font-weight: 700; }
.ear {
  display: grid; gap: 6px; padding: 10px 12px 11px; border-radius: var(--r-m);
  background: var(--panel); border: 1px solid var(--line); color: var(--ink); text-decoration: none !important;
  box-shadow: var(--edge); transition: transform .12s, box-shadow .12s;
}
.ear:hover { transform: translateY(-1px); box-shadow: var(--edge), var(--shadow-1); }
.ear.here { opacity: .6; }
.ear-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ear-title strong { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.lively { font: 700 17px/1 var(--hand); color: color-mix(in srgb, var(--tint, var(--accent)) var(--lift), var(--lift-to)); transform: rotate(-5deg); }
.ear-lines { display: grid; gap: 3px; }
.ear-line { font-size: 13px; color: var(--ink-2); line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; animation: murmur .5s ease-out; }
.ear-line:not(:last-child) { opacity: .62; }
.ear-line strong { color: var(--ink); font-weight: 700; }
.ear-line.quiet { color: var(--ink-3); font-style: italic; }
@keyframes murmur { from { opacity: 0; transform: translateY(6px); filter: blur(2px); } }
.rail-empty { display: grid; justify-items: center; text-align: center; gap: 6px; padding: 30px 12px; color: var(--ink-3); }
.rail-empty strong { color: var(--ink-2); font-family: var(--display); font-size: 16px; }
.rail-empty p { margin: 0; font-size: 13px; }
.rail-foot { margin: 2px 4px 0; font: 600 16px/1.2 var(--hand); color: var(--ink-3); }

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

.chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); position: relative; }
.chat-head { border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(8px); padding-top: env(safe-area-inset-top); z-index: 5; }
.head-row { display: flex; align-items: center; gap: 10px; padding: 10px 14px 10px 20px; min-height: 64px; }
.head-title { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.head-text { min-width: 0; display: grid; }
.head-text h1 { position: relative; font-size: 21px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-bottom: 5px; }
.squiggle {
  position: absolute; left: 0; bottom: 0; width: min(72px, 100%); height: 6px; background: var(--tint, var(--accent));
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='6' viewBox='0 0 16 6'%3E%3Cpath d='M0 3q4-3 8 0t8 0' fill='none' stroke='black' stroke-width='2'/%3E%3C/svg%3E") repeat-x;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='6' viewBox='0 0 16 6'%3E%3Cpath d='M0 3q4-3 8 0t8 0' fill='none' stroke='black' stroke-width='2'/%3E%3C/svg%3E") repeat-x;
}
.head-text small, .topic { color: var(--ink-3); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button.topic { border: 0; background: none; padding: 0; text-align: left; max-width: 60ch; }
button.topic:hover { color: var(--ink-2); text-decoration: underline dotted; text-underline-offset: 3px; }
.head-actions { display: flex; align-items: center; gap: 2px; }
.private-pill { display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 11px 0 10px; border-radius: var(--r-s); border: 1px solid var(--line-2); background: var(--panel); font-size: 13px; font-weight: 650; color: var(--ink-2); white-space: nowrap; }
.private-pill:hover { color: var(--ink); border-color: var(--ink-3); }
.nav-toggle-wrap { position: relative; display: none; }
.nav-dot { position: absolute; top: 6px; right: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); border: 2px solid var(--bg); }

.call-banner { display: flex; align-items: center; gap: 12px; margin: 0 14px 10px; padding: 8px 10px 8px 14px; border-radius: var(--r-m); background: color-mix(in srgb, var(--ok) 12%, var(--panel)); border: 1px solid color-mix(in srgb, var(--ok) 30%, transparent); }
.call-text { display: grid; flex: 1; line-height: 1.2; }
.call-text small { color: var(--ink-3); }
.faces { display: flex; }
.faces .avatar { margin-left: -6px; box-shadow: 0 0 0 2px var(--panel); }
.faces .avatar:first-child { margin-left: 0; }
.pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 60%, transparent); animation: pulse 1.6s infinite; flex: none; }
@keyframes pulse { 70% { box-shadow: 0 0 0 10px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }


.scroller { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column-reverse; overscroll-behavior: contain; scrollbar-width: thin; }
.scroll-inner { position: relative; padding: 12px 0 8px; }
.messages, .msg-list { display: flex; flex-direction: column; }
.msg-list > .msg:last-child, .msg-list > .sys:last-child { animation: arrive .22s ease-out; }
@keyframes arrive { from { opacity: 0; transform: translateY(4px); } }

.intro { padding: 36px 24px 18px; }
.intro-icon { width: 60px; height: 60px; border-radius: var(--r-m); background: color-mix(in srgb, var(--tint, var(--accent)) 18%, var(--panel)); color: color-mix(in srgb, var(--tint, var(--accent)) var(--lift), var(--lift-to)); display: grid; place-items: center; margin-bottom: 14px; transform: rotate(-4deg); }
.intro h2 { font-size: 24px; margin-bottom: 4px; }
.intro p { margin: 0; color: var(--ink-2); }
.older { display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--ink-3); font-size: 13px; padding: 16px; }

.divider { display: flex; align-items: center; gap: 10px; margin: 16px 20px 6px; color: var(--ink-3); font-size: 12px; font-weight: 700; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.divider span { padding: 2px 11px; border: 1px solid var(--line); border-radius: var(--r-s); background: var(--bg); }
.divider.unread { color: var(--accent); }
.divider.unread::before, .divider.unread::after { border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
.divider.unread span { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); font: 700 18px/1 var(--hand); padding: 1px 12px 3px; }

.msg { display: grid; grid-template-columns: 54px minmax(0, 1fr); padding: 6px 20px 6px 14px; position: relative; scroll-margin: 80px; transition: background .12s, padding .15s; }
.msg.grouped { padding-top: 1px; padding-bottom: 1px; }
.msg:focus { outline: none; }
.msg:focus-visible { background: var(--hover); box-shadow: inset 3px 0 0 var(--accent); }
.msg:hover { background: var(--hover); }
.msg.mentioned { background: var(--mention-bg); box-shadow: inset 3px 0 0 var(--mention-line); }
.msg.highlight { animation: flash 2.4s ease-out; }
@keyframes flash { 0%, 30% { background: var(--accent-soft); } 100% { background: transparent; } }
.gutter { display: flex; justify-content: center; padding-top: 2px; }
.hover-time { visibility: hidden; color: var(--ink-3); font-size: 11px; padding-top: 4px; }
.msg:hover .hover-time { visibility: visible; }
.body { min-width: 0; }
.body header { display: flex; align-items: baseline; gap: 8px; }
.author { font-weight: 750; }
.body header time { color: var(--ink-3); font-size: 12px; }
.pin-flag { color: var(--accent); align-self: center; }
.text { overflow-wrap: anywhere; }
.text p { margin: 0; }
.text p + p { margin-top: 4px; }
.text.deleted { color: var(--ink-3); font-style: italic; }
.text.jumbo { font-size: 40px; line-height: 1.2; }
.text.jumbo .emoji { width: 48px; height: 48px; }
.text a { word-break: break-all; }
.text code { background: var(--code-bg); padding: 1px 5px; border-radius: var(--r-xs); font-size: .86em; }
.text pre { background: var(--code-bg); border: 1px solid var(--line); border-radius: var(--r-m); padding: 10px 14px; overflow-x: auto; margin: 6px 0; font-size: 13px; line-height: 1.55; }
.text pre code { background: none; padding: 0; font-size: inherit; }
.text blockquote { margin: 4px 0; padding: 2px 0 2px 12px; border-left: 3px solid var(--line-2); color: var(--ink-2); }
.edited { color: var(--ink-3); font-size: 12px; }
.mention { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent-2); border-radius: var(--r-xs); padding: 0 3px; font-weight: 650; }
.mention.me, .mention.all { background: var(--mark-bg); color: var(--mark-ink); }
.chanref { font-weight: 650; }
.spoiler { background: var(--ink); color: transparent; border-radius: var(--r-xs); cursor: pointer; transition: color .2s, background .2s; }
.spoiler:hover, .spoiler:focus { background: var(--code-bg); color: inherit; }
.emoji { width: 22px; height: 22px; vertical-align: -5px; object-fit: contain; }
.emo { font-size: 1.15em; }

.sys { display: flex; align-items: center; gap: 8px; padding: 4px 20px 4px 32px; color: var(--ink-3); font-size: 13px; }
.sys strong { color: var(--ink-2); }
.sys time { margin-left: auto; font-size: 11px; }
.sys-text { min-width: 0; }
.sys-moved_out, .sys-moved_in {
  margin: 8px 20px 8px 68px; padding: 9px 12px; border-radius: var(--r-m);
  border: 1px dashed var(--line-2); background: var(--panel); color: var(--ink-2);
}
.sys-moved_out a, .sys-moved_in a { font-weight: 700; }
.undo { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line-2); background: var(--bg); border-radius: var(--r-s); padding: 2px 9px; font-size: 12px; font-weight: 700; color: var(--ink-2); }
.undo:hover { color: var(--ink); border-color: var(--ink-3); }

.media { display: grid; gap: 6px; margin-top: 6px; justify-items: start; }
.attachments { display: flex; flex-wrap: wrap; gap: 6px; }
.att-img { padding: 0; border: 1px solid var(--line); border-radius: var(--r-m); overflow: hidden; background: var(--code-bg); width: min(var(--w), 100%); aspect-ratio: var(--ar); display: block; cursor: zoom-in; }
.att-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.attachments.grid .att-img { width: min(220px, 46%); aspect-ratio: 1; }
.att-video { max-width: min(480px, 100%); max-height: 360px; border-radius: var(--r-m); background: #000; }
.att-file { display: inline-flex; align-items: center; gap: 12px; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--r-m); background: var(--panel); color: var(--ink); text-decoration: none !important; max-width: 100%; box-shadow: var(--edge); }
.att-file:hover { border-color: var(--line-2); background: var(--hover); }
.file-type { width: 40px; height: 40px; border-radius: var(--r-s); background: var(--accent-soft); color: var(--accent-2); display: grid; place-items: center; flex: none; font: 800 11px var(--mono); }
.file-meta { display: grid; min-width: 0; }
.file-meta strong { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta small { color: var(--ink-3); }
.gif { margin: 0; max-width: min(320px, 100%); }
.gif img { border-radius: var(--r-m); display: block; width: 100%; aspect-ratio: var(--ar); object-fit: cover; background: var(--code-bg); }
.gif figcaption { font-size: 11px; color: var(--ink-3); margin-top: 2px; }
.link-card { display: flex; gap: 12px; max-width: min(520px, 100%); padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-m); background: var(--panel); color: var(--ink); text-decoration: none !important; box-shadow: var(--edge); }
.link-card:hover { border-color: var(--line-2); }
.link-card img { width: 96px; height: 72px; object-fit: cover; border-radius: var(--r-m); flex: none; background: var(--code-bg); }
.link-text { display: grid; gap: 2px; min-width: 0; }
.link-text small { color: var(--ink-3); font-size: 12px; }
.link-text strong { font-size: 14px; line-height: 1.3; }
.link-text span { color: var(--ink-2); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.embed img { border-radius: var(--r-m); max-height: 320px; max-width: min(400px, 100%); display: block; border: 1px solid var(--line); }

.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.pill { display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 9px; border-radius: var(--r-s); border: 1px solid var(--line-2); background: var(--panel); font-size: 13px; transition: transform .1s; }
.pill:hover { border-color: var(--ink-3); }
.pill:active { transform: scale(.92); }
.pill.mine { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-2); }
.pill-emoji { font-size: 16px; line-height: 1; }
.pill-emoji .emoji { width: 18px; height: 18px; vertical-align: -4px; }
.pill-count { font-weight: 750; }
.pill.add { color: var(--ink-3); opacity: 0; }
.msg:hover .pill.add, .pill.add:focus { opacity: 1; }
.thread-link { display: inline-flex; align-items: center; gap: 8px; margin-top: 6px; padding: 4px 10px 4px 8px; border: 1px solid transparent; border-radius: var(--r-s); background: none; color: var(--accent-2); font-size: 13px; }
.thread-link span { color: var(--ink-3); }
.thread-link:hover { background: var(--panel); border-color: var(--line); box-shadow: var(--edge); }

.tools { position: absolute; right: 16px; z-index: 6; display: flex; gap: 2px; padding: 3px; border-radius: var(--r-l); background: var(--panel); border: 1px solid var(--line); box-shadow: var(--edge), var(--shadow-1); transform: translateY(-60%); }
.tools button { border: 0; background: none; width: 32px; height: 32px; border-radius: var(--r-s); display: grid; place-items: center; color: var(--ink-2); font-size: 17px; }
.tools button:hover { background: var(--hover); color: var(--ink); }
.tools button.danger:hover { color: var(--danger); background: var(--danger-soft); }

.jump-present { position: sticky; bottom: 8px; margin: 8px auto 0; display: flex; align-items: center; gap: 6px; border: 0; border-radius: var(--r-s); padding: 8px 14px; background: var(--accent); color: var(--accent-ink); font-weight: 700; box-shadow: var(--shadow-2); }
.seen { height: 1px; }

/* picking messages to take out */
.pick { display: none; position: absolute; left: 14px; top: 10px; width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line-2); background: var(--panel); color: transparent; place-items: center; }
.selecting .msg[data-root] { cursor: pointer; padding-left: 44px; user-select: none; }
.selecting .msg[data-root] .pick { display: grid; }
.selecting .msg.picked { background: var(--select); box-shadow: inset 3px 0 0 var(--accent); }
.selecting .msg.picked .pick { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.selecting .sys, .selecting .msg:not([data-root]) { opacity: .5; }
.selbar { display: none; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--r-m); background: var(--panel); border: 1px solid var(--line-2); box-shadow: var(--edge); }
.selecting .selbar { display: flex; }
.selecting .composer-wrap, .selecting .typing { display: none; }
.sel-count { font-weight: 750; }
.sel-hint { flex: 1; color: var(--ink-3); font-size: 13px; }

/* ---------- composer ---------- */

.footer { padding: 0 16px calc(12px + env(safe-area-inset-bottom)); }
.typing { height: 22px; font-size: 12px; color: var(--ink-3); display: flex; align-items: center; gap: 6px; padding-left: 6px; }
.dots { display: inline-flex; gap: 3px; }
.dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--ink-3); animation: bounce 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .15s; }
.dots i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }
.composer { position: relative; border: 1px solid var(--line-2); border-radius: var(--r-m); background: var(--panel); box-shadow: var(--edge); transition: border-color .15s, box-shadow .15s; }
.composer:focus-within { border-color: color-mix(in srgb, var(--accent) 55%, var(--line-2)); box-shadow: var(--edge), 0 0 0 3px var(--ring); }
.composer.drop { border-style: dashed; border-color: var(--accent); background: var(--accent-soft); }
.drop-note { display: none; position: absolute; inset: 0; z-index: 3; border-radius: inherit; place-items: center; align-content: center; gap: 4px; color: var(--accent-2); font: 700 18px var(--hand); background: color-mix(in srgb, var(--accent-soft) 85%, transparent); }
.composer.drop .drop-note { display: grid; }
.composer textarea:focus-visible { outline: none; }
.composer textarea { display: block; border: 0; background: none; resize: none; box-shadow: none !important; padding: 13px 15px 4px; max-height: 40vh; min-height: 46px; line-height: 1.45; font-size: 15px; }
.composer-bar { display: flex; align-items: center; gap: 2px; padding: 4px 6px 6px; }
.uploading { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-3); margin-left: 8px; }
.send { position: relative; margin-left: auto; height: 34px; padding: 0 14px; border-radius: var(--r-s); border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 750; font-size: 14px; box-shadow: 0 var(--edge-y) 0 -1px var(--accent-edge); }
.send:hover { background: var(--accent-2); }
.send:active { transform: translateY(1px); box-shadow: none; }
.send:disabled { opacity: .5; }
.tray { display: none; gap: 8px; padding: 10px 10px 0; overflow-x: auto; }
.tray.has { display: flex; }
.tray-item { position: relative; display: flex; align-items: center; gap: 8px; padding: 6px 28px 6px 6px; border: 1px solid var(--line); border-radius: var(--r-s); background: var(--bg); max-width: 220px; flex: none; }
.tray-item img { width: 44px; height: 44px; border-radius: var(--r-s); object-fit: cover; }
.tray-name { display: grid; min-width: 0; font-size: 12px; }
.tray-name strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tray-name small { color: var(--ink-3); }
.tray-x { position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; border-radius: 50%; border: 0; background: var(--ink-2); color: var(--bg); display: grid; place-items: center; }
.join-bar { display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; padding: 14px; border: 1px solid var(--line); border-radius: var(--r-m); background: var(--panel); color: var(--ink-2); box-shadow: var(--edge); }

.ac { position: absolute; left: 8px; right: 8px; bottom: calc(100% + 6px); z-index: 20; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-l); box-shadow: var(--edge), var(--shadow-2); padding: 6px; max-height: 300px; overflow-y: auto; }
.ac-item { width: 100%; display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 6px 10px; border-radius: var(--r-s); text-align: left; }
.ac-item:hover { background: var(--hover); }
.ac-item.active { background: var(--select); box-shadow: inset 3px 0 0 var(--accent); }
.ac-item small { margin-left: auto; color: var(--ink-3); }
.ac-label { font-weight: 650; }
.ac-icon { width: 22px; height: 22px; border-radius: var(--r-s); background: var(--hover); display: grid; place-items: center; font-weight: 800; color: var(--ink-3); }
.ac-emoji { font-size: 20px; width: 22px; text-align: center; }
.ac-empty { color: var(--ink-3); padding: 6px 10px; font-size: 13px; }

/* ---------- side panel ---------- */

.panel { display: none; width: var(--panel-w); border-left: 1px solid var(--line); background: var(--panel); flex-direction: column; min-height: 0; padding-top: env(safe-area-inset-top); }
.panel.open { display: flex; animation: slide .18s ease-out; }
@keyframes slide { from { opacity: 0; transform: translateX(12px); } }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 12px 18px; border-bottom: 1px solid var(--line); min-height: 64px; }
.panel-head h2 { font-size: 18px; }
.panel-head small { color: var(--ink-3); }
.panel-scroll { flex: 1; overflow-y: auto; padding: 8px 0; }
.panel .composer { margin: 0 12px calc(12px + env(safe-area-inset-bottom)); }
.panel .msg { padding-left: 8px; padding-right: 14px; }
.thread-msgs .divider { margin: 8px 14px; }
.panel .empty { margin-top: 30px; }
.panel h3 { font-size: 14px; margin-bottom: 8px; }
.rename { margin: 6px 14px 10px; }
.rename .row { flex-wrap: nowrap; }
.privacy-control { margin: 6px 14px 14px; padding: 14px; border-radius: var(--r-m); background: var(--bg); border: 1px solid var(--line); display: grid; gap: 8px; }
.privacy-control p { margin: 0; }
.outside { margin: 14px; padding: 14px; border-radius: var(--r-m); border: 1px dashed var(--line-2); display: grid; gap: 8px; justify-items: start; }
.outside p { margin: 0; }
.invite-row { display: flex; align-items: center; gap: 6px; width: 100%; }
.invite-row code { flex: 1; min-width: 0; font-size: 12px; background: var(--code-bg); padding: 5px 8px; border-radius: var(--r-s); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel-actions { display: flex; gap: 6px; flex-wrap: wrap; padding: 6px 14px 14px; }
.people { list-style: none; margin: 0; padding: 0 8px; display: grid; gap: 2px; }
.person { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: var(--r-s); }
.person:hover { background: var(--hover); }
.person-text { flex: 1; min-width: 0; display: grid; line-height: 1.3; }
.person-text strong { display: flex; align-items: center; gap: 6px; }
.person-text small { color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person.dim { opacity: .55; }
.person input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }
.role { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; padding: 1px 6px; border-radius: var(--r-xs); background: var(--accent-soft); color: var(--accent-2); }
.add-member { display: flex; gap: 8px; padding: 6px 14px 12px; }
.panel .btn.wide { margin: 14px; width: calc(100% - 28px); }
.pin-card { display: grid; gap: 4px; margin: 8px 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-m); color: var(--ink); text-decoration: none !important; background: var(--bg); box-shadow: var(--edge); transform: rotate(-.4deg); }
.pin-card:nth-child(even) { transform: rotate(.4deg); }
.pin-card:hover { border-color: var(--line-2); transform: none; }
.pin-card header { display: flex; align-items: center; gap: 8px; font-size: 13px; }

.empty { display: grid; justify-items: center; text-align: center; gap: 6px; padding: 30px 20px; color: var(--ink-2); }
.empty p { margin: 0; max-width: 34ch; color: var(--ink-3); font-size: 14px; }
.empty-icon { width: 56px; height: 56px; border-radius: var(--r-m); background: var(--hover); color: var(--ink-3); display: grid; place-items: center; margin-bottom: 4px; transform: rotate(-4deg); }

/* ---------- overlays ---------- */

dialog { border: 0; padding: 0; background: none; color: var(--ink); }
dialog::backdrop { background: var(--scrim); backdrop-filter: blur(2px); }
.modal { width: min(480px, calc(100% - 32px)); background: var(--panel); border-radius: var(--r-l); padding: 22px; border: 1px solid var(--line); box-shadow: var(--edge), var(--shadow-2); }
.modal[open] { animation: pop .16s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } }
.modal h2 { font-size: 21px; }
.modal.takeout { width: min(560px, calc(100% - 32px)); }
.guest-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.guest-chip { display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px 0 5px; border-radius: var(--r-s); border: 1px solid var(--line-2); background: var(--panel); font-size: 13px; font-weight: 650; color: var(--ink-2); }
.guest-chip:hover:not(:disabled) { border-color: var(--ink-3); color: var(--ink); }
.guest-chip.on { background: var(--select); border-color: var(--accent); color: var(--ink); }
.guest-chip:disabled { cursor: default; background: var(--select); border-color: var(--accent); color: var(--ink); }
.choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.choice { display: grid; gap: 4px; align-content: start; padding: 12px; border-radius: var(--r-m); border: 1px solid var(--line-2); background: var(--panel); cursor: pointer; position: relative; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice strong { font-size: 14px; }
.choice small { color: var(--ink-3); font-size: 12px; line-height: 1.35; }
.choice:has(input:checked) { border-color: var(--accent); background: var(--select); box-shadow: var(--edge); }
.choice:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.lightbox { max-width: 100vw; max-height: 100dvh; width: 100vw; height: 100dvh; }
.lightbox[open] { display: grid; place-items: center; grid-template-rows: 1fr auto; padding: 24px; }
.lightbox::backdrop { background: rgb(15 10 6 / 88%); }
.lightbox img { max-width: 100%; max-height: calc(100dvh - 110px); border-radius: var(--r-m); object-fit: contain; }
.lightbox-bar { display: flex; gap: 8px; padding-top: 12px; }
.sheet { margin: auto 0 0; width: 100%; max-width: 100%; }
.sheet[open] { animation: up .2s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet-body { max-width: 560px; margin: 0 auto; background: var(--panel); border-radius: var(--r-l) var(--r-l) 0 0; padding: 14px 10px calc(14px + env(safe-area-inset-bottom)); display: grid; gap: 2px; }
.sheet-reacts { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; padding: 4px 6px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.sheet-reacts button { width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--hover); font-size: 22px; display: grid; place-items: center; }
.sheet-item { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border: 0; background: none; border-radius: var(--r-s); text-align: left; font-size: 16px; }
.sheet-item:active { background: var(--hover); }
.sheet-item.danger { color: var(--danger); }

/* ⌘K */
.palette, .picker, .modal, .sheet, .ring { --tint: initial; }
.palette { width: min(640px, calc(100% - 24px)); margin: 11vh auto auto; }
.palette[open] { animation: pop .14s ease-out; }
.pal-box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-l); box-shadow: var(--edge), var(--shadow-2); overflow: hidden; display: flex; flex-direction: column; max-height: 74vh; }
.pal-input { display: flex; align-items: center; gap: 12px; padding: 4px 18px; border-bottom: 1px solid var(--line); color: var(--ink-3); }
.pal-input input { border: 0; background: none; box-shadow: none !important; padding: 16px 0; font-size: 18px; color: var(--ink); }
.pal-results { overflow-y: auto; padding: 6px 8px 10px; min-height: 60px; }
.pal-tokens { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 8px 2px; }
.token { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 9px 0 4px; border-radius: var(--r-s); border: 1px solid var(--accent); background: var(--select); font-weight: 700; font-size: 13px; }
.token-face { width: 22px; height: 22px; border-radius: 50%; background: color-mix(in srgb, var(--tint) var(--avatar-dim), #000); color: color-mix(in srgb, var(--tint) 28%, #1f140c); display: grid; place-items: center; font-size: 10px; font-weight: 800; }
.pal-section + .pal-section { margin-top: 6px; }
.pal-title { padding: 8px 10px 4px; color: var(--ink-3); font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.pal-item { width: 100%; display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: var(--r-s); border: 0; background: none; color: var(--ink); text-align: left; text-decoration: none !important; font-size: 15px; }
.pal-item.active { background: var(--select); box-shadow: inset 3px 0 0 var(--accent); }
.pal-item.static { padding: 7px 10px; }
.pal-glyph { width: 28px; height: 28px; border-radius: var(--r-s); background: color-mix(in srgb, var(--tint, var(--ink-3)) 16%, var(--panel)); color: color-mix(in srgb, var(--tint, var(--ink-2)) var(--lift), var(--lift-to)); display: grid; place-items: center; flex: none; font-weight: 800; font-size: 14px; }
.pal-glyph:has(.avatar) { background: none; }
.pal-label { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 8px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.pal-label small { color: var(--ink-3); font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.pal-keys { flex: none; }
html.pc .pal-keys[data-pc] { font-size: 0; }
html.pc .pal-keys[data-pc]::before { content: attr(data-pc); font-size: 11px; }
.pal-empty { padding: 18px 12px; margin: 0; color: var(--ink-3); text-align: center; }
.pal-foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 9px 16px; border-top: 1px solid var(--line); color: var(--ink-3); font-size: 12px; background: var(--bg); }

.picker { width: 360px; height: 420px; margin: 0; inset: auto 24px 96px auto; border: 1px solid var(--line); border-radius: var(--r-l); background: var(--panel); box-shadow: var(--edge), var(--shadow-2); padding: 0; overflow: hidden; flex-direction: column; color: var(--ink); }
.picker:popover-open { display: flex; }
.picker-tabs { display: flex; border-bottom: 1px solid var(--line); }
.picker-tabs button { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; border: 0; background: none; padding: 10px; color: var(--ink-3); font-weight: 700; border-bottom: 2px solid transparent; }
.picker-tabs button.on { color: var(--ink); border-bottom-color: var(--accent); }
.picker-pane { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 10px; gap: 8px; }
.cats { display: flex; gap: 2px; justify-content: space-between; }
.cats button { border: 0; background: none; font-size: 18px; width: 32px; height: 32px; border-radius: var(--r-s); }
.cats button:hover { background: var(--hover); }
.emoji-grid-wrap, .gif-wrap, .emoji-results { flex: 1; overflow-y: auto; min-height: 0; }
.emoji-title { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); padding: 6px 4px 4px; }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); }
.emoji-grid button { border: 0; background: none; font-size: 24px; height: 40px; border-radius: var(--r-s); display: grid; place-items: center; padding: 0; }
.emoji-grid button:hover { background: var(--hover); }
.emoji-grid img { width: 26px; height: 26px; object-fit: contain; }
.gif-grid { columns: 2; column-gap: 6px; }
.gif-item { display: block; width: 100%; border: 0; padding: 0; margin: 0 0 6px; background: var(--code-bg); border-radius: var(--r-s); overflow: hidden; break-inside: avoid; }
.gif-item img { display: block; width: 100%; }
.powered { display: block; text-align: center; color: var(--ink-3); font-size: 11px; column-span: all; padding: 6px; }

.ring { position: fixed; z-index: 50; right: 24px; top: 24px; width: 280px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-l); padding: 22px; box-shadow: var(--edge), var(--shadow-2); display: grid; justify-items: center; gap: 6px; animation: up .25s ease-out; }
.ring small { color: var(--ink-3); }
.ring-actions { display: flex; gap: 22px; margin-top: 10px; }
.round { width: 52px; height: 52px; border-radius: 50%; border: 0; display: grid; place-items: center; background: var(--hover); color: var(--ink); text-decoration: none !important; }
.round.ok { background: var(--ok); color: #fff; }
.round.danger { background: #e0453c; color: #fff; }
.round.danger.wide { width: 72px; border-radius: 999px; }

#toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 100; background: var(--tip-bg); color: var(--tip-ink); border: 1px solid color-mix(in srgb, var(--tip-ink) 12%, transparent); padding: 10px 18px; border-radius: var(--r-l); box-shadow: var(--shadow-2); font-weight: 650; font-size: 14px; max-width: calc(100% - 32px); animation: up .2s ease-out; }

/* ---------- pages ---------- */

.page { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow-y: auto; }
.page-head { display: flex; align-items: center; gap: 10px; padding: calc(12px + env(safe-area-inset-top)) 20px 12px; border-bottom: 1px solid var(--line); min-height: 64px; position: sticky; top: 0; background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(8px); z-index: 4; flex-wrap: wrap; }
.page-head h1 { font-size: 23px; flex: 1; }
.page-body { padding: 20px; width: 100%; max-width: 980px; }
.page-body.narrow { max-width: 760px; display: grid; gap: 18px; }
.browse-group { display: grid; gap: 8px; margin-bottom: 28px; }
.browse-group h2 { font-size: 19px; }
.browse-group > p { margin: 0 0 6px; }
.cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.card { display: flex; align-items: center; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: var(--r-m); background: var(--panel); color: var(--ink); text-decoration: none !important; height: 100%; box-shadow: var(--edge); transition: transform .12s; }
.card:hover { border-color: var(--line-2); transform: translateY(-1px); }
.card-icon { width: 40px; height: 40px; border-radius: var(--r-s); background: color-mix(in srgb, var(--tint, var(--ink-3)) 16%, var(--panel)); color: color-mix(in srgb, var(--tint, var(--ink-2)) var(--lift), var(--lift-to)); display: grid; place-items: center; flex: none; font: 800 19px var(--display); }
.card-text { flex: 1; display: grid; min-width: 0; }
.card-text small { color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-meta { display: inline-flex; align-items: center; gap: 4px; color: var(--ink-3); font-size: 13px; }
.gathering-form { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-l); padding: 22px; box-shadow: var(--edge); }
.filter { margin-bottom: 8px; }
.people.big .person { padding: 10px; border-bottom: 1px solid var(--line); border-radius: 0; }
.self-note { padding: 14px 0; }
.search-box { display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 14px; border: 1px solid var(--line-2); border-radius: var(--r-m); background: var(--panel); color: var(--ink-3); margin-bottom: 10px; box-shadow: var(--edge); }
.search-box input { border: 0; box-shadow: none !important; padding: 8px 0; }
.hits { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 6px; }
.hit { display: flex; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: var(--r-m); background: var(--panel); color: var(--ink); text-decoration: none !important; }
.hit:hover { border-color: var(--line-2); }
.hit-body { display: grid; gap: 2px; min-width: 0; }
.hit-meta { display: flex; gap: 8px; align-items: baseline; font-size: 13px; color: var(--ink-3); flex-wrap: wrap; }
.hit-meta strong { color: var(--ink); font-size: 14px; }
.hit-text mark { background: var(--mark-bg); color: var(--mark-ink); border-radius: var(--r-xs); padding: 0 2px; }
.settings-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-l); padding: 20px; display: grid; gap: 14px; box-shadow: var(--edge); }
.settings-card > h2 { font-size: 18px; }
.settings-card > p { margin: -8px 0 0; }
.avatar-edit { display: flex; align-items: center; gap: 18px; }
.status-input { display: flex; gap: 8px; }
.emoji-input { width: 64px !important; text-align: center; font-size: 18px; }
.rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.row-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-s); background: var(--bg); flex-wrap: wrap; }
.row-item small { color: var(--ink-3); margin-right: auto; }
.row-item.dim { opacity: .5; }
.invite-url { font-size: 12px; background: var(--code-bg); padding: 3px 8px; border-radius: var(--r-s); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.emoji-admin { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.emoji-tile { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--r-s); }
.emoji-tile img { width: 28px; height: 28px; object-fit: contain; }
.emoji-tile code { flex: 1; font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.people select { width: auto; height: 32px; padding-top: 4px; padding-bottom: 4px; font-size: 13px; }


/* ---------- call ---------- */

/* The call is always dark, in both themes: its own tokens. */
.call {
  --stage: #13110f; --stage-tile: #1f1c19; --stage-hover: #28241f;
  --stage-button: #2c2823; --stage-button-hover: #38332d;
  --stage-ink: #f3eee7; --stage-ink-2: #d3ccc2; --stage-ink-3: #a49c91;
  --stage-muted: #ff8a80; --stage-danger: #e0453c;
  height: 100dvh; display: grid; grid-template-rows: auto 1fr auto; background: var(--stage); color: var(--stage-ink); position: relative; overflow: hidden;
}
.call-head { display: flex; align-items: center; gap: 12px; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; }
.call-head .icon-btn { color: var(--stage-ink-2); }
.call-head .icon-btn:hover { background: var(--stage-hover); color: #fff; }
.call-title { display: grid; flex: 1; line-height: 1.2; }
.call-title small { color: var(--stage-ink-3); }
.call-timer { font: 600 13px var(--mono); color: var(--stage-ink-3); }
.call-live { display: contents; }
.stage { display: grid; gap: 10px; padding: 6px 16px; min-height: 0; grid-template-columns: repeat(var(--cols, 1), minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); }
.stage.n2 { --cols: 2; }
.stage.n3, .stage.n4 { --cols: 2; }
.stage.n5, .stage.n6 { --cols: 3; }
.stage.n7, .stage.n8, .stage.n9 { --cols: 3; }
.tile { position: relative; border-radius: var(--r-l); overflow: hidden; background: var(--stage-tile); min-height: 0; display: grid; }
.tile-media, .tile-media video { position: absolute; inset: 0; width: 100%; height: 100%; }
.tile-media video { object-fit: cover; background: var(--stage-tile); }
.tile.me .tile-media video { transform: scaleX(-1); }
.tile.screen .tile-media video { object-fit: contain; transform: none; }
.tile-face { position: absolute; inset: 0; display: none; place-items: center; }
.tile.no-video .tile-face { display: grid; }
.tile.no-video .tile-media { visibility: hidden; }
.tile-name { position: absolute; left: 10px; bottom: 10px; display: flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: var(--r-s); background: rgb(0 0 0 / 55%); font-size: 13px; font-weight: 650; }
.tile-icon.muted { color: var(--stage-muted); }
.speaking-ring { position: absolute; inset: 0; border-radius: inherit; pointer-events: none; box-shadow: inset 0 0 0 3px transparent; transition: box-shadow .15s; }
.tile.speaking .speaking-ring { box-shadow: inset 0 0 0 3px var(--ok); }
.waiting { grid-column: 1 / -1; display: grid; place-items: center; align-content: end; padding-bottom: 24px; gap: 10px; color: var(--stage-ink-3); }
.waiting .faces .avatar { box-shadow: 0 0 0 2px var(--stage); }
.prejoin { position: absolute; inset: 64px 0 120px; display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(280px, 1fr); gap: 28px; align-items: center; padding: 24px clamp(16px, 5vw, 64px); background: var(--stage); }
.preview { position: relative; aspect-ratio: 16 / 10; border-radius: var(--r-l); overflow: hidden; background: var(--stage-tile); }
.preview video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); display: block; }
.preview-off { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 8px; color: var(--stage-ink-3); background: var(--stage-tile); }
.prejoin-side { display: grid; gap: 14px; justify-items: start; }
.prejoin-side h1 { font-size: 30px; }
.prejoin-side .muted { color: var(--stage-ink-3); margin: 0; }
.call-toggles { display: flex; gap: 12px; }
.call .round { background: var(--stage-button); color: var(--stage-ink); width: 54px; height: 54px; }
.call .round:hover { background: var(--stage-button-hover); }
.call .round.off { background: var(--stage-ink); color: var(--stage); }
.call .round.on { background: var(--accent); color: var(--accent-ink); }
.call .round.danger { background: var(--stage-danger); color: #fff; }
.call-bar { display: flex; justify-content: center; gap: 14px; padding: 14px 16px calc(18px + env(safe-area-inset-bottom)); }
.call-error { position: absolute; left: 50%; bottom: 100px; transform: translateX(-50%); background: var(--danger); color: #fff; padding: 8px 14px; border-radius: var(--r-s); margin: 0; }

/* ---------- widths ---------- */

.only-mobile { display: none; }

.rail-toggle { display: none; }

/* With the panel open, the rail steps aside until there is room for both. */
@media (min-width: 1181px) and (max-width: 1520px) {
  .shell:has(.panel.open) .rail { display: none; }
  .shell:has(.panel.open) .rail-toggle { display: inline-grid; }
}

/* Where it does not fit, the rail slides in over the page from the right. */
@media (max-width: 1180px) {
  :root { --panel-w: 340px; }
  .rail-toggle { display: inline-grid; }
  .page-head .rail-toggle { order: 10; margin-left: auto; }
  .rail, html.rail-off .rail {
    display: flex; position: fixed; z-index: 45; inset: 0 0 0 auto; width: min(88vw, 340px);
    transform: translateX(102%); transition: transform .22s ease, visibility .22s; box-shadow: var(--shadow-2);
    visibility: hidden;
  }
  html.rail-open .rail { transform: none; visibility: visible; }
  html.rail-open .scrim { display: block; position: fixed; inset: 0; z-index: 44; background: var(--scrim); }
}

@media (max-width: 860px) {
  body { font-size: 16px; }
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-areas: "main"; }
  .only-mobile { display: inline-grid; }
  .nav-toggle-wrap { display: block; margin-left: -6px; }
  .hide-sm { display: none !important; }
  .sidebar, .nav-live > .sidebar {
    position: fixed; z-index: 40; inset: 0 auto 0 0; width: min(86vw, 320px);
    transform: translateX(-102%); transition: transform .22s ease; box-shadow: var(--shadow-2);
  }
  .nav-open .sidebar { transform: none; }
  .nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 35; background: var(--scrim); }
  .panel.open { position: fixed; inset: 0; z-index: 30; width: auto; border: 0; }
  .head-row { padding: 6px 8px; min-height: 56px; gap: 4px; }
  .head-text h1 { font-size: 18px; }
  .private-pill { padding: 0 9px; font-size: 0; gap: 0; }
  .msg { grid-template-columns: 46px minmax(0, 1fr); padding-left: 8px; padding-right: 12px; }
  .msg:hover { background: none; }
  .msg:active { background: var(--hover); }
  .selecting .msg[data-root] { padding-left: 38px; }
  .pick { left: 10px; }
  .sys-moved_out, .sys-moved_in { margin-left: 12px; margin-right: 12px; }
  .pill.add { opacity: 1; }
  .tools { display: none !important; }
  .footer { padding: 0 8px calc(8px + env(safe-area-inset-bottom)); }
  .picker { inset: auto 0 0 0; width: 100%; height: min(60dvh, 460px); border-radius: var(--r-l) var(--r-l) 0 0; }
  .palette { margin-top: 8px; }
  .pal-foot span:last-child { display: none; }
  .ring { left: 12px; right: 12px; top: 12px; width: auto; }
  .grid2, .choices { grid-template-columns: 1fr; }
  .page-body { padding: 14px; }
  .prejoin { grid-template-columns: 1fr; align-content: start; overflow-y: auto; gap: 18px; }
  .prejoin-side { justify-items: stretch; }
  .stage { padding: 6px 8px; gap: 6px; }
  .stage.n2 { --cols: 1; }
  .stage.n3, .stage.n4 { --cols: 2; }
  .stage.n5, .stage.n6, .stage.n7, .stage.n8, .stage.n9 { --cols: 2; }
  .call-bar { gap: 10px; }
  .call .round { width: 50px; height: 50px; }
}

@media (pointer: coarse) {
  .nav-item { min-height: 42px; }
  .icon-btn { min-width: 40px; height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@view-transition { navigation: auto; }

/* ---------- what notifies me in a place ---------- */
.level-menu { position: relative; }
.level-menu summary { list-style: none; cursor: pointer; }
.level-menu summary::-webkit-details-marker { display: none; }
.level-menu .menu { left: auto; right: 0; width: 220px; }
.level-menu .no-check { width: 15px; flex: none; }

/* ---------- saved searches, and the QR code of an invite ---------- */
.saved-search { position: relative; }
.saved-search .nav-item { padding-right: 30px; }
.saved-search .icon-btn { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); opacity: 0; }
.saved-search:hover .icon-btn, .saved-search .icon-btn:focus-visible { opacity: 1; }
.invite-qr summary { cursor: pointer; font-size: 13px; color: var(--ink-2); }
.invite-qr svg { display: block; margin-top: 8px; border-radius: var(--r-s); }

/* ---------- a bot's token, shown once ---------- */
.bot-token { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 8px 0; padding: 12px 14px; border-radius: var(--r-m); background: var(--note-bg); border: 1px solid var(--note-line); }
