/* ============================================================
   Brahcord styles
   Fonts: Bricolage Grotesque (display), Atkinson Hyperlegible Next
   (text), JetBrains Mono (code). All bundled, SIL Open Font License.
   ============================================================ */

@font-face { font-family: 'Bricolage'; src: url(../fonts/bricolage.woff2) format('woff2-variations'); font-weight: 200 800; font-stretch: 75% 100%; font-display: swap; }
@font-face { font-family: 'Atkinson'; src: url(../fonts/atkinson-400.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Atkinson'; src: url(../fonts/atkinson-400i.woff2) format('woff2'); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: 'Atkinson'; src: url(../fonts/atkinson-500.woff2) format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Atkinson'; src: url(../fonts/atkinson-600.woff2) format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Atkinson'; src: url(../fonts/atkinson-700.woff2) format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Atkinson'; src: url(../fonts/atkinson-700i.woff2) format('woff2'); font-weight: 700; font-style: italic; font-display: swap; }
@font-face { font-family: 'JetBrains Mono'; src: url(../fonts/jetbrains-mono.woff2) format('woff2-variations'); font-weight: 100 800; font-display: swap; }

/* ---------- themes ---------- */
:root {
  --accent: #ff9f40;
  --accent-ink: #1b1405;
  --font-text: 'Atkinson', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Bricolage', 'Atkinson', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  --ok: #3ddc84;
  --idle: #f5c542;
  --dnd: #f2545b;
  --off: #6c7488;
  --danger: #f2545b;
  --link: #74b9ff;
  --r-sm: 6px;
  --r: 8px;
  --r-lg: 12px;
  --bar-h: 52px;
  --rail-w: 72px;
  --side-w: 264px;
  --panel-w: 284px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

:root, [data-theme="dusk"] {
  --rail: #0c0f19;
  --side: #121624;
  --main: #171c2b;
  --raise: #1e2435;
  --field: #20263a;
  --sunk: #0f1220;
  --hover: rgba(185, 198, 240, .05);
  --active: rgba(185, 198, 240, .1);
  --line: rgba(185, 198, 240, .08);
  --line-2: rgba(185, 198, 240, .15);
  --text: #eceef5;
  --text-2: #a9afc4;
  --text-3: #717994;
  --shadow: 0 12px 32px -10px rgba(0, 0, 0, .6), 0 0 0 1px rgba(185, 198, 240, .1);
  --accent-text: color-mix(in oklab, var(--accent) 88%, white);
}
[data-theme="blackout"] {
  --rail: #000;
  --side: #09090c;
  --main: #0e0e12;
  --raise: #18181f;
  --field: #1b1b22;
  --sunk: #050507;
  --hover: rgba(255, 255, 255, .05);
  --active: rgba(255, 255, 255, .1);
  --line: rgba(255, 255, 255, .08);
  --line-2: rgba(255, 255, 255, .15);
  --text: #f1f1f4;
  --text-2: #a9a9b7;
  --text-3: #6c6c7b;
  --shadow: 0 12px 32px -10px rgba(0, 0, 0, .9), 0 0 0 1px rgba(255, 255, 255, .1);
  --accent-text: color-mix(in oklab, var(--accent) 88%, white);
}
[data-theme="harbor"] {
  --rail: #0a1a1d;
  --side: #0f2427;
  --main: #132c30;
  --raise: #1a3a3f;
  --field: #1c3e43;
  --sunk: #0c1f22;
  --hover: rgba(150, 240, 225, .06);
  --active: rgba(150, 240, 225, .12);
  --line: rgba(150, 240, 225, .1);
  --line-2: rgba(150, 240, 225, .18);
  --text: #e8f4f2;
  --text-2: #a5c4c0;
  --text-3: #6d928e;
  --shadow: 0 12px 32px -10px rgba(0, 10, 12, .65), 0 0 0 1px rgba(150, 240, 225, .1);
  --accent-text: color-mix(in oklab, var(--accent) 88%, white);
}
[data-theme="ember"] {
  --rail: #190e13;
  --side: #21131a;
  --main: #291820;
  --raise: #361f2a;
  --field: #3a222d;
  --sunk: #1c1016;
  --hover: rgba(255, 190, 210, .06);
  --active: rgba(255, 190, 210, .12);
  --line: rgba(255, 190, 210, .1);
  --line-2: rgba(255, 190, 210, .18);
  --text: #f7eaef;
  --text-2: #caabb7;
  --text-3: #93717e;
  --shadow: 0 12px 32px -10px rgba(12, 2, 6, .65), 0 0 0 1px rgba(255, 190, 210, .1);
  --accent-text: color-mix(in oklab, var(--accent) 88%, white);
}
[data-theme="daylight"] {
  --rail: #e2e5ef;
  --side: #eceff6;
  --main: #fafbfd;
  --raise: #ffffff;
  --field: #eaedf4;
  --sunk: #e6e9f1;
  --hover: rgba(30, 40, 90, .045);
  --active: rgba(30, 40, 90, .085);
  --line: rgba(30, 40, 90, .1);
  --line-2: rgba(30, 40, 90, .18);
  --text: #191d32;
  --text-2: #4c5373;
  --text-3: #80879f;
  --shadow: 0 12px 28px -12px rgba(25, 30, 70, .22), 0 0 0 1px rgba(25, 30, 70, .1);
  --accent-text: color-mix(in oklab, var(--accent) 62%, black);
  --link: #1764c0;
  --off: #9aa0b6;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  height: 100dvh;
  overflow: hidden;
  background: var(--main);
  color: var(--text);
  font: 400 .9375rem/1.45 var(--font-text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
input, textarea, select { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; }
code, kbd, pre { font-family: var(--font-mono); }
[hidden] { display: none !important; }
::selection { background: color-mix(in oklab, var(--accent) 38%, transparent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
kbd {
  font-size: .6875rem;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--sunk);
  color: var(--text-3);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.muted-text { color: var(--text-3); font-size: .875rem; }
.only-mobile { display: none !important; }

/* ---------- logo and boot ---------- */
.logo { width: 30px; height: 30px; color: var(--text); }
.boot { position: fixed; inset: 0; display: grid; place-items: center; background: var(--rail); z-index: 100; }
.boot-logo { width: 64px; height: 64px; animation: pulse 1.4s var(--ease) infinite; }
@keyframes pulse { 50% { transform: scale(.9); opacity: .6; } }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: var(--r);
  font-weight: 700; font-size: .875rem; white-space: nowrap;
  transition: background-color .12s, color .12s, box-shadow .12s, filter .12s;
}
.btn .ic { width: 17px; height: 17px; }
.btn.sm { height: 30px; padding: 0 11px; font-size: .8125rem; border-radius: var(--r-sm); }
.btn.full { width: 100%; }
.btn-big { height: 44px; font-size: 1rem; width: 100%; border-radius: var(--r); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-secondary { background: var(--active); color: var(--text); }
.btn-secondary:hover:not(:disabled) { background: color-mix(in oklab, var(--active) 70%, var(--line-2)); }
.btn-ghost { color: var(--text-2); box-shadow: inset 0 0 0 1px var(--line-2); }
.btn-ghost:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); }
.btn-danger-ghost { color: var(--danger); box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--danger) 45%, transparent); }
.btn-danger-ghost:hover { background: color-mix(in oklab, var(--danger) 12%, transparent); }
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; }

.icon-btn {
  position: relative; display: inline-grid; place-items: center; flex: none;
  width: 32px; height: 32px; border-radius: var(--r-sm); color: var(--text-2);
  transition: background-color .12s, color .12s;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.on { color: var(--text); background: var(--active); }
.icon-btn.sm { width: 28px; height: 28px; border-radius: var(--r-sm); }
.icon-btn.sm .ic { width: 17px; height: 17px; }
.mini-count {
  position: absolute; right: 1px; bottom: 2px; min-width: 15px; height: 15px; padding: 0 3px;
  border-radius: 8px; background: var(--raise); color: var(--text-2); box-shadow: 0 0 0 2px var(--main);
  font-size: .625rem; font-weight: 700; line-height: 15px;
}
.round-btn {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  background: var(--sunk); color: var(--text-2); transition: color .12s, background-color .12s;
}
.round-btn:hover { color: var(--text); background: var(--active); }
.round-btn.ok:hover { color: var(--ok); }
.round-btn.no:hover { color: var(--danger); }
.round-btn .ic { width: 18px; height: 18px; }
.link-btn { color: var(--accent-text); font-weight: 700; }
.link-btn:hover { text-decoration: underline; }
.sys-link { color: var(--link); font-weight: 600; }
.sys-link:hover { text-decoration: underline; }

/* ---------- fields ---------- */
input[type="text"], input[type="search"], input[type="password"], textarea {
  width: 100%; min-width: 0;
  background: var(--field); border: 1px solid transparent; border-radius: var(--r);
  height: 40px; padding: 0 12px; outline: none;
  transition: border-color .12s, box-shadow .12s;
}
textarea { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.4; }
input:focus, textarea:focus { border-color: color-mix(in oklab, var(--accent) 65%, transparent); box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 16%, transparent); }
input::placeholder, textarea::placeholder { color: var(--text-3); }
input[type="search"]::-webkit-search-cancel-button { filter: grayscale(1); opacity: .5; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; position: relative; }
.field > span, .field-label { font-size: .8125rem; font-weight: 700; color: var(--text-2); }
.field-hint { font-size: .8125rem; color: var(--text-3); margin: -6px 0 14px; }
.field-count { position: absolute; right: 10px; bottom: 8px; font-size: .75rem; color: var(--text-3); }
.form-msg { min-height: 1.2em; font-size: .875rem; margin: 2px 0 10px; color: var(--text-2); }
.form-msg.error { color: var(--danger); }
.form-msg.success { color: var(--ok); }

.search-field { position: relative; margin-bottom: 14px; }
.search-field .ic { position: absolute; left: 11px; top: 50%; translate: 0 -50%; width: 17px; height: 17px; color: var(--text-3); pointer-events: none; }
.search-field input { padding-left: 36px; height: 36px; background: var(--sunk); }

.switch {
  appearance: none; -webkit-appearance: none; flex: none;
  width: 42px; height: 24px; border-radius: 12px; background: var(--line-2);
  position: relative; cursor: pointer; transition: background-color .15s; margin: 0;
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; transition: transform .18s var(--ease); box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
}
.switch:checked { background: var(--ok); }
.switch:checked::after { transform: translateX(18px); }

.check {
  appearance: none; -webkit-appearance: none; flex: none; margin: 0;
  width: 20px; height: 20px; border-radius: 6px; border: 2px solid var(--line-2);
  position: relative; cursor: pointer; transition: background-color .12s, border-color .12s;
}
.check:checked { background: var(--accent); border-color: var(--accent); }
.check:checked::after {
  content: ''; position: absolute; left: 5px; top: 1px; width: 5px; height: 10px;
  border: solid var(--accent-ink); border-width: 0 2.5px 2.5px 0; transform: rotate(45deg);
}
.check-row { display: flex; align-items: center; gap: 10px; font-size: .875rem; color: var(--text-2); cursor: pointer; margin-top: 12px; }

.toggle-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 0; border-bottom: 1px solid var(--line); cursor: pointer;
}
.toggle-row:last-child { border-bottom: 0; }
.toggle-row b { display: block; font-weight: 700; }
.toggle-row small { display: block; color: var(--text-3); font-size: .8125rem; margin-top: 2px; }

.chip {
  height: 26px; padding: 0 10px; border-radius: var(--r-sm); font-size: .8125rem; font-weight: 600;
  color: var(--text-3); transition: background-color .12s, color .12s;
}
.chip:hover { color: var(--text); background: var(--hover); }
.chip.on { background: var(--active); color: var(--text); }

.badge {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; font-size: .6875rem; font-weight: 800; line-height: 1;
  background: var(--text-3); color: var(--main);
}
.badge.hot { background: var(--danger); color: #fff; }
.tag { font-size: .6875rem; font-weight: 700; padding: 2px 7px; border-radius: 5px; background: var(--active); color: var(--text-2); }
.spinner {
  width: 22px; height: 22px; border-radius: 50%; display: inline-block;
  border: 3px solid var(--line-2); border-top-color: var(--accent); animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- avatars and presence ---------- */
.avatar {
  --s: 40px;
  position: relative; flex: none; display: inline-grid; place-items: center;
  width: var(--s); height: var(--s); border-radius: 50%;
  background: color-mix(in oklab, var(--av, #5c6378) 30%, var(--ring, var(--main)));
  user-select: none;
}
.avatar.group-icon { border-radius: 32%; }
.av-img { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: inherit; object-fit: cover; }
.avatar.has-img { background: var(--sunk); }
.av-emoji { font-size: calc(var(--s) * .54); line-height: 1; }
.av-initials { font: 700 calc(var(--s) * .38)/1 var(--font-text); color: color-mix(in oklab, var(--av, #5c6378) 75%, var(--text)); }
.presence {
  position: absolute; right: -2px; bottom: -2px;
  width: max(11px, calc(var(--s) * .32)); height: max(11px, calc(var(--s) * .32));
  border-radius: 50%; border: max(2.5px, calc(var(--s) * .07)) solid var(--ring, var(--side));
  background: var(--off);
}
.presence.static { position: relative; right: auto; bottom: auto; width: 12px; height: 12px; border: 0; flex: none; }
.p-online { background: var(--ok); }
.p-idle { background: radial-gradient(circle at 22% 24%, var(--ring, var(--side)) 0 38%, var(--idle) 40%); }
.p-dnd { background: linear-gradient(var(--dnd), var(--dnd)) padding-box; }
.p-dnd::after { content: ''; position: absolute; left: 20%; right: 20%; top: 50%; height: 26%; translate: 0 -50%; border-radius: 2px; background: var(--ring, var(--side)); }
.p-offline, .p-invisible { background: var(--ring, var(--side)); box-shadow: inset 0 0 0 max(2.5px, calc(var(--s) * .07)) var(--off); }
.presence.static.p-offline { box-shadow: inset 0 0 0 3px var(--off); background: transparent; }
.presence.static.p-idle { background: radial-gradient(circle at 22% 24%, var(--raise) 0 38%, var(--idle) 40%); }
.presence.static.p-dnd::after { background: var(--raise); }
.bot-av { background: var(--accent); color: var(--accent-ink); }
.bot-av .ic { width: 22px; height: 22px; }

/* ============================================================
   Login screen
   ============================================================ */
.auth {
  position: fixed; inset: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(380px, 460px);
  background: var(--rail); overflow: auto;
}
.auth-stage { position: relative; padding: clamp(28px, 5vw, 64px); display: grid; align-content: center; min-width: 0; }
@media (min-width: 1400px) {
  .auth-stage { grid-template-columns: minmax(0, 1.15fr) minmax(320px, 420px); column-gap: clamp(32px, 4vw, 64px); align-items: center; }
  .auth-stage .demo-window { margin-top: 0; }
}
.auth-copy { container-type: inline-size; min-width: 0; }
.auth-brand .logo { width: 44px; height: 44px; }
.wordmark {
  font-family: var(--font-display); font-weight: 800; font-stretch: 84%;
  font-size: min(8rem, 28cqi); line-height: .9; letter-spacing: -.012em;
  margin: 18px 0 20px -.04em; color: var(--text);
}
.auth-tag { max-width: 34ch; font-size: clamp(1rem, 1.5vw, 1.1875rem); color: var(--text-2); line-height: 1.5; }
.demo-window {
  margin-top: clamp(24px, 4vw, 44px); width: min(460px, 100%);
  background: var(--main); border-radius: var(--r-lg); box-shadow: var(--shadow);
  overflow: hidden; --ring: var(--main);
}
.demo-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.demo-head b { font-family: var(--font-display); font-weight: 700; }
.demo-count { margin-left: auto; font-size: .75rem; color: var(--text-3); }
.demo-chat { height: 308px; padding: 10px 16px 14px; display: flex; flex-direction: column; justify-content: flex-end; gap: 10px; overflow: hidden; }
.demo-msg { display: flex; gap: 12px; align-items: flex-start; }
.demo-msg b { font-weight: 700; color: var(--text); font-size: .9375rem; }
.demo-msg .md { color: var(--text); }
.demo-msg .react { margin-top: 4px; }
.demo-roll { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-style: italic; }
.demo-roll .die { width: 28px; height: 28px; padding: 4px; border-radius: 7px; }
.demo-typing { display: flex; align-items: center; gap: 8px; font-size: .8125rem; color: var(--text-3); }
.auth-side { background: var(--side); display: flex; flex-direction: column; justify-content: center; padding: 40px clamp(24px, 4vw, 48px); border-left: 1px solid var(--line); }
.auth-card { width: 100%; max-width: 380px; margin: 0 auto; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--sunk); border-radius: var(--r); padding: 3px; margin-bottom: 26px; }
.auth-tab { height: 36px; border-radius: var(--r-sm); font-weight: 700; color: var(--text-3); transition: background-color .15s, color .15s; }
.auth-tab.on { background: var(--raise); color: var(--text); box-shadow: 0 0 0 1px var(--line); }
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 44px; }
.pw-wrap .icon-btn { position: absolute; right: 6px; top: 50%; translate: 0 -50%; }
.strength { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin: -8px 0 16px; }
.strength i { height: 4px; border-radius: 2px; background: var(--line-2); transition: background-color .2s; }
.strength span { grid-column: 1 / -1; font-size: .75rem; color: var(--text-3); }
.strength[data-score="0"] i:nth-child(-n+1), .strength[data-score="1"] i:nth-child(-n+1) { background: var(--danger); }
.strength[data-score="2"] i:nth-child(-n+2) { background: var(--idle); }
.strength[data-score="3"] i:nth-child(-n+3) { background: var(--ok); }
.strength[data-score="4"] i { background: var(--ok); }
.auth-switch { margin-top: 18px; text-align: center; color: var(--text-3); font-size: .875rem; }
.auth-foot { margin: 28px auto 0; max-width: 380px; text-align: center; font-size: .75rem; color: var(--text-3); }

/* ============================================================
   App layout
   ============================================================ */
.app {
  height: 100dvh; display: grid; overflow: hidden;
  grid-template-columns: var(--rail-w) var(--side-w) minmax(0, 1fr) 0;
  transition: grid-template-columns .2s var(--ease);
}
.app.panel-open { grid-template-columns: var(--rail-w) var(--side-w) minmax(0, 1fr) var(--panel-w); }
.app.shake { animation: shake .6s cubic-bezier(.36, .07, .19, .97) both; }
@keyframes shake {
  10%, 90% { transform: translate3d(-2px, 0, 0); }
  20%, 80% { transform: translate3d(4px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-8px, 1px, 0); }
  40%, 60% { transform: translate3d(8px, -1px, 0); }
}

/* ---------- rail ---------- */
.rail {
  --ring: var(--rail);
  background: var(--rail); display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 10px 0 12px; box-shadow: inset -1px 0 0 var(--line); overflow-y: auto; overflow-x: hidden; scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }
.rail-home, .rail-tile, .rail-btn { position: relative; width: 48px; height: 48px; display: grid; place-items: center; flex: none; }
.rail-home { border-radius: 50%; background: var(--side); transition: border-radius .18s var(--ease), background-color .18s; }
.rail-home .logo { width: 30px; height: 30px; }
.rail-home:hover, .rail-home.active { border-radius: 14px; background: var(--raise); }
.rail-tile .avatar { transition: border-radius .18s var(--ease); }
.rail-tile:hover .avatar.group-icon, .rail-tile.active .avatar.group-icon { border-radius: 14px; }
.rail-pill {
  position: absolute; left: -12px; top: 50%; width: 4px; height: 0; translate: 0 -50%;
  border-radius: 0 4px 4px 0; background: var(--text); transition: height .18s var(--ease);
}
.has-unread .rail-pill { height: 8px; }
.rail-home:hover .rail-pill, .rail-tile:hover .rail-pill { height: 20px; }
.rail-home.active .rail-pill, .rail-tile.active .rail-pill { height: 40px; }
.rail-badge { position: absolute; right: -4px; bottom: -3px; box-shadow: 0 0 0 3px var(--rail); background: var(--danger); color: #fff; }
.rail-sep { width: 28px; height: 1px; background: var(--line-2); margin: 2px 0; flex: none; }
.rail-pins { display: contents; }
.rail-btn { border-radius: 50%; background: var(--side); color: var(--text-2); transition: border-radius .18s var(--ease), background-color .18s, color .18s; }
.rail-btn:hover { border-radius: 14px; background: var(--raise); color: var(--text); }
.rail-btn .ic { width: 20px; height: 20px; }
.rail-spacer { flex: 1; }

/* ---------- sidebar ---------- */
.sidebar { --ring: var(--side); background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.sb-top { height: var(--bar-h); flex: none; padding: 0 10px; display: flex; align-items: center; border-bottom: 1px solid var(--line); }
.sb-find {
  width: 100%; height: 32px; display: flex; align-items: center; gap: 8px; padding: 0 6px 0 10px;
  background: var(--sunk); border-radius: var(--r-sm); color: var(--text-3); font-size: .875rem;
}
.sb-find .ic { width: 16px; height: 16px; }
.sb-find span { flex: 1; text-align: left; }
.sb-find:hover { color: var(--text-2); }
.sb-scroll { flex: 1; overflow-y: auto; padding: 8px; min-height: 0; }
.sb-nav { display: flex; flex-direction: column; gap: 2px; }
.sb-link {
  display: flex; align-items: center; gap: 12px; width: 100%; height: 38px; padding: 0 10px;
  border-radius: var(--r-sm); color: var(--text-2); font-weight: 600;
}
.sb-link span:first-of-type { flex: 1; text-align: left; }
.sb-link:hover { background: var(--hover); color: var(--text); }
.sb-link.active { background: var(--active); color: var(--text); }
.sb-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 2px 4px 10px; }
.sb-head h2 { font: 700 .8125rem/1 var(--font-text); color: var(--text-3); }
.chips { display: flex; gap: 2px; padding: 4px 4px 8px; flex-wrap: wrap; }
.conv-list { list-style: none; display: flex; flex-direction: column; gap: 1px; }
.conv-row { position: relative; }
.conv-item {
  display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; align-items: center; gap: 10px;
  width: 100%; padding: 6px 8px; border-radius: var(--r-sm); text-align: left;
}
.conv-item:hover { background: var(--hover); }
.conv-item.active { background: var(--active); }
.ci-text { display: flex; flex-direction: column; min-width: 0; }
.ci-top { display: flex; align-items: baseline; gap: 6px; }
.ci-name { flex: 1; min-width: 0; font-weight: 600; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci-top time { font-size: .6875rem; color: var(--text-3); flex: none; }
.ci-mute { width: 14px; height: 14px; color: var(--text-3); align-self: center; }
.ci-sub { font-size: .8125rem; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci-typing { color: var(--accent-text); font-weight: 600; }
.conv-item.unread .ci-name, .conv-item.active .ci-name { color: var(--text); }
.conv-item.unread .ci-name { font-weight: 700; }
.conv-item.unread .ci-sub { color: var(--text-2); }
.conv-item.muted { opacity: .55; }
.conv-item .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text); }
.ci-close {
  position: absolute; right: 6px; top: 6px; width: 22px; height: 22px; border-radius: 6px;
  display: grid; place-items: center; color: var(--text-3); opacity: 0; background: var(--side);
}
.ci-close .ic { width: 15px; height: 15px; }
.conv-row:hover .ci-close, .ci-close:focus-visible { opacity: 1; }
.conv-row:hover .ci-top time { visibility: hidden; }
.ci-close:hover { color: var(--text); background: var(--active); }
.sb-empty { padding: 18px 12px; color: var(--text-3); font-size: .875rem; display: grid; gap: 6px; }
.sb-empty p:first-child { color: var(--text-2); font-weight: 700; }

.me-bar {
  height: 58px; flex: none; display: flex; align-items: center; gap: 4px; padding: 0 8px;
  background: var(--side); border-top: 1px solid var(--line); --ring: var(--side);
}
.me-btn { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 5px 6px; border-radius: var(--r-sm); text-align: left; }
.me-btn:hover { background: var(--hover); }
.me-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.me-name { font-weight: 700; font-size: .875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-sub { font-size: .75rem; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- main column ---------- */
.main { --ring: var(--main); background: var(--main); display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.main.dropping::after {
  content: 'Drop to add pictures'; position: absolute; inset: 10px; z-index: 30; pointer-events: none;
  display: grid; place-items: center; border: 2px dashed var(--accent); border-radius: var(--r-lg);
  background: color-mix(in oklab, var(--main) 82%, transparent); font: 700 1.25rem/1 var(--font-display); color: var(--text);
}
.topbar {
  height: var(--bar-h); flex: none; display: flex; align-items: center; gap: 10px; padding: 0 10px 0 16px;
  border-bottom: 1px solid var(--line); min-width: 0;
}
.topbar-ic { color: var(--text-3); }
.topbar-title { font: 700 1rem/1 var(--font-display); white-space: nowrap; }
.topbar-sub { font-size: .8125rem; color: var(--text-3); padding-left: 12px; margin-left: 2px; border-left: 1px solid var(--line-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tabs { display: flex; gap: 4px; margin-left: 8px; padding-left: 14px; border-left: 1px solid var(--line-2); overflow-x: auto; scrollbar-width: none; }
.tab { height: 28px; padding: 0 11px; border-radius: var(--r-sm); color: var(--text-2); font-weight: 600; font-size: .875rem; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.tab:hover { background: var(--hover); color: var(--text); }
.tab.on { background: var(--active); color: var(--text); }
.tab-add { background: var(--accent); color: var(--accent-ink); margin-left: 4px; }
.tab-add:hover { background: var(--accent); color: var(--accent-ink); filter: brightness(1.08); }
.tab-add.on { background: transparent; color: var(--accent-text); }

/* friends page */
.friends-body { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 340px; min-height: 0; }
.friends-main { overflow-y: auto; padding: 18px 24px 30px; }
.list-title { font: 700 .8125rem/1 var(--font-text); color: var(--text-3); margin: 6px 0 8px 2px; }
.friend-list { list-style: none; }
.friend-row {
  display: flex; align-items: center; gap: 12px; padding: 9px 10px; margin: 0 -10px; border-radius: var(--r);
  border-top: 1px solid var(--line); cursor: pointer;
}
.friend-row:hover { background: var(--hover); border-top-color: transparent; }
.friend-row:hover + .friend-row { border-top-color: transparent; }
.fr-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.fr-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fr-user { font-weight: 400; color: var(--text-3); font-size: .875rem; margin-left: 4px; opacity: 0; transition: opacity .12s; }
.friend-row:hover .fr-user { opacity: 1; }
.fr-sub { font-size: .8125rem; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fr-actions { display: flex; gap: 8px; }
.friend-row:hover .round-btn { background: var(--rail); }
.empty-note { padding: 28px 4px; color: var(--text-3); max-width: 46ch; }
.active-now { border-left: 1px solid var(--line); padding: 18px 16px; overflow-y: auto; }
.active-now h2 { font: 700 1.0625rem/1.1 var(--font-display); margin-bottom: 12px; }
.active-card {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 10px 12px; border-radius: var(--r); background: var(--side); margin-bottom: 6px; --ring: var(--side);
  box-shadow: inset 0 0 0 1px var(--line);
}
.active-card:hover { background: color-mix(in oklab, var(--side) 80%, var(--line-2)); }
.active-card b { display: block; font-weight: 700; }
.active-card small { display: block; font-size: .8125rem; color: var(--text-2); }

.add-friend { max-width: 640px; padding-top: 6px; }
.big-title { font: 800 1.375rem/1.15 var(--font-display); margin-bottom: 6px; }
.big-title.second { margin-top: 40px; }
.inline-form {
  display: flex; align-items: center; gap: 8px; margin-top: 14px; padding: 6px 6px 6px 14px;
  background: var(--sunk); border-radius: var(--r); border: 1px solid var(--line);
}
.inline-form:focus-within { border-color: color-mix(in oklab, var(--accent) 70%, transparent); box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 20%, transparent); }
.inline-form input { background: transparent; border: 0; height: 40px; padding: 0; box-shadow: none !important; }
.inline-form .at { color: var(--text-3); font-weight: 700; display: grid; place-items: center; }
.inline-form .at .ic { width: 18px; height: 18px; }
.share-me { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; margin-top: 6px; border-radius: var(--r); background: var(--side); font-size: .875rem; color: var(--text-2); }
.share-me b { color: var(--text); }

/* saved page */
.saved-body { flex: 1; overflow-y: auto; padding: 18px 24px 30px; }
.saved-list { list-style: none; display: grid; gap: 12px; max-width: 760px; }
.saved-card { background: var(--side); border-radius: var(--r-lg); padding: 12px 16px 14px; --ring: var(--side); border: 1px solid var(--line); }
.saved-head { display: flex; align-items: center; gap: 8px; font-size: .8125rem; color: var(--text-2); margin-bottom: 10px; }
.saved-head time { color: var(--text-3); }
.saved-actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.saved-msg { display: flex; gap: 12px; }
.saved-author { font-weight: 700; }
.empty-state { max-width: 420px; margin: 8vh auto 0; text-align: center; color: var(--text-2); display: grid; justify-items: center; gap: 10px; }
.empty-state h2 { font: 800 1.5rem/1.1 var(--font-display); color: var(--text); }
.empty-ic { width: 52px; height: 52px; color: var(--text-3); }

/* ---------- chat header ---------- */
.chat-top { gap: 6px; }
.ct-id { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 4px 8px 4px 4px; margin-left: -4px; border-radius: var(--r-sm); text-align: left; flex: 0 1 auto; }
.ct-id:hover { background: var(--hover); }
.ct-titles { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.ct-name { font: 700 1rem/1.2 var(--font-display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ct-sub { font-size: .75rem; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ct-actions { margin-left: auto; display: flex; align-items: center; gap: 2px; flex: none; }
.ct-search { position: relative; margin: 0 4px; }
.ct-search input { width: 150px; height: 28px; font-size: .8125rem; padding: 0 30px 0 10px; background: var(--sunk); border-radius: var(--r-sm); transition: width .2s var(--ease), border-color .12s, box-shadow .12s; }
.ct-search input:focus { width: 230px; }
.ct-search .ic { position: absolute; right: 8px; top: 50%; translate: 0 -50%; width: 16px; height: 16px; color: var(--text-3); pointer-events: none; }

/* ---------- message list ---------- */
.chat-col { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
.scroller { flex: 1; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; outline: none; }
.msg-list { min-height: 100%; display: flex; flex-direction: column; justify-content: flex-end; padding: 0 0 10px; }
.msg-loading, .load-more { display: grid; place-items: center; padding: 30px 0; }

.chat-start { padding: 40px 16px 8px 18px; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.chat-start h2 { font: 800 2.125rem/1.05 var(--font-display); font-stretch: 88%; letter-spacing: -.02em; margin-top: 12px; }
.chat-start p { color: var(--text-2); max-width: 56ch; }
.chat-start .cs-user { color: var(--text-3); font-size: 1rem; margin-top: -2px; }
.cs-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

.day-sep { display: flex; align-items: center; gap: 10px; margin: 22px 16px 6px; color: var(--text-3); font-size: .75rem; font-weight: 700; }
.day-sep::before, .day-sep::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.new-sep { position: relative; height: 1px; margin: 14px 16px 2px; background: var(--danger); }
.new-sep span {
  position: absolute; right: 0; top: 50%; translate: 0 -50%; padding: 1px 7px 1px 8px;
  border-radius: 4px; background: var(--danger); color: #fff; font-size: .6875rem; font-weight: 800;
}

.msg { position: relative; display: grid; grid-template-columns: 72px minmax(0, 1fr); padding: 2px 48px 2px 0; }
.msg.first { margin-top: 16px; }
.msg:hover, .msg.tools-open { background: var(--hover); }
.msg-gutter { display: flex; justify-content: center; padding-top: 2px; }
.msg-av { border-radius: 50%; height: max-content; }
.msg-av:hover { filter: brightness(1.06); }
.msg-main { min-width: 0; }
.msg-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; line-height: 1.35; }
.msg-author { font-weight: 700; font-size: .96875rem; color: var(--text); }
.msg-author:hover { text-decoration: underline; }
.msg-head time { font-size: .75rem; color: var(--text-3); }
.msg-head { gap: 7px; }
.owner-crown { color: var(--idle); display: inline-grid; align-self: center; }
.owner-crown .ic { width: 14px; height: 14px; }
.pin-flag { color: var(--text-3); display: inline-grid; align-self: center; }
.pin-flag .ic { width: 13px; height: 13px; }
.hover-time { font-size: .6875rem; color: var(--text-3); opacity: 0; line-height: 1.5rem; white-space: nowrap; }
.msg:hover .hover-time, .msg.tools-open .hover-time { opacity: 1; }
.msg-content { overflow-wrap: anywhere; }
.msg.pending .msg-content { opacity: .55; }
.msg.failed .msg-content { color: var(--danger); }
.fail-row { font-size: .8125rem; color: var(--text-3); margin-top: 2px; }
.msg.mentioned { background: color-mix(in oklab, var(--accent) 7%, transparent); box-shadow: inset 2px 0 0 var(--accent); }
.msg.mentioned:hover { background: color-mix(in oklab, var(--accent) 11%, transparent); }
.msg.highlight { animation: flash 2s var(--ease); }
@keyframes flash { 0%, 30% { background: color-mix(in oklab, var(--accent) 22%, transparent); } }
.msg.arrive { animation: arrive .22s var(--ease); }
@keyframes arrive { from { opacity: 0; transform: translateY(6px); } }

.msg-reply {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 6px; min-width: 0;
  padding: 2px 0 2px 72px; margin-top: 14px; margin-bottom: -2px; position: relative;
  font-size: .8125rem; color: var(--text-2); text-align: left;
}
.msg-reply + .msg-gutter { margin-top: 0; }
.msg-reply:hover .reply-text { color: var(--text); }
.msg-reply b { font-weight: 700; flex: none; }
.msg-reply .avatar { --s: 16px; }
.msg-reply .av-emoji { font-size: 10px; }
.msg-reply.deleted { font-style: italic; color: var(--text-3); }
.reply-spine {
  position: absolute; left: 35px; top: 50%; width: 30px; height: 14px;
  border-left: 2px solid var(--line-2); border-top: 2px solid var(--line-2); border-top-left-radius: 7px;
}
.reply-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.msg-reply ~ .msg-gutter, .msg-reply ~ .msg-main { margin-top: 2px; }
.msg:has(.msg-reply) { margin-top: 0; }

/* system lines */
.msg.system { color: var(--text-2); font-size: .875rem; margin-top: 6px; }
.msg.system .msg-gutter { padding-top: 1px; }
.sys-ic { width: 17px; height: 17px; color: var(--text-3); }
.sys-joined .sys-ic, .sys-added .sys-ic { color: var(--ok); }
.sys-left .sys-ic, .sys-kicked .sys-ic { color: var(--danger); }
.sys-pinned .sys-ic, .sys-owner .sys-ic { color: var(--idle); }
.nudge-msg .sys-ic { color: var(--accent-text); }
.sys-ic.shake { animation: buzz 1s ease-in-out 1; }
@keyframes buzz { 0%, 100% { transform: none; } 20%, 60% { transform: rotate(-14deg); } 40%, 80% { transform: rotate(14deg); } }
.sys-name { font-weight: 700; color: var(--text); }
.sys-name:hover { text-decoration: underline; }
.msg.system time { font-size: .75rem; color: var(--text-3); margin-left: 4px; }
.blocked-msg { color: var(--text-3); font-size: .875rem; font-style: italic; margin-top: 6px; }
.msg.local .md { color: var(--text-2); }
.msg.local .md ul { margin: 6px 0; padding-left: 20px; }
.msg.local .md li { margin: 3px 0; }

/* hover toolbar */
.msg-tools {
  position: absolute; right: 16px; top: -18px; z-index: 2; display: none; align-items: center; gap: 1px; padding: 3px;
  background: var(--raise); border-radius: var(--r); box-shadow: 0 0 0 1px var(--line-2), 0 6px 16px -6px rgba(0, 0, 0, .45);
}
.msg:hover .msg-tools, .msg.tools-open .msg-tools, .msg-tools:focus-within { display: flex; }
.tool { width: 30px; height: 28px; border-radius: var(--r-sm); display: grid; place-items: center; color: var(--text-2); }
.tool:hover { background: var(--hover); color: var(--text); }
.tool .ic { width: 18px; height: 18px; }
.tool.quick { font-size: 1.05rem; }
.tool.quick:hover { transform: scale(1.12); background: var(--hover); }

/* message text */
.md { line-height: 1.42; font-size: 1rem; white-space: pre-wrap; }
.md.jumbo { font-size: 2.875rem; line-height: 1.15; }
.md .edited { font-size: .6875rem; color: var(--text-3); margin-left: 4px; white-space: nowrap; }
.md strong { font-weight: 700; }
.md blockquote { margin: 2px 0; padding: 0 0 0 12px; border-left: 4px solid var(--line-2); color: var(--text-2); }
.md ul, .md ol { padding-left: 22px; margin: 2px 0; white-space: normal; }
.md .md-h { font-family: var(--font-display); font-weight: 800; line-height: 1.2; margin: 6px 0 2px; white-space: normal; }
.md .md-h1 { font-size: 1.5rem; }
.md .md-h2 { font-size: 1.25rem; }
.md .md-h3 { font-size: 1.0625rem; }
.md .md-sub { font-size: .75rem; color: var(--text-3); }
.md code.inline { font-size: .84em; padding: .1em .38em; border-radius: 5px; background: var(--sunk); border: 1px solid var(--line); }
.codeblock { position: relative; margin: 4px 0; max-width: 760px; background: var(--sunk); border: 1px solid var(--line); border-radius: var(--r); white-space: normal; }
.codeblock pre { margin: 0; padding: 10px 14px; overflow-x: auto; font-size: .84rem; line-height: 1.5; white-space: pre; }
.code-lang { position: absolute; left: 10px; top: -9px; font-size: .6875rem; font-weight: 700; padding: 0 6px; border-radius: 4px; background: var(--raise); color: var(--text-3); }
.code-copy { position: absolute; right: 6px; top: 6px; font-size: .6875rem; font-weight: 700; padding: 3px 8px; border-radius: 6px; background: var(--raise); color: var(--text-2); opacity: 0; transition: opacity .12s; }
.codeblock:hover .code-copy, .code-copy:focus-visible { opacity: 1; }
.spoiler { background: repeating-linear-gradient(-45deg, var(--line-2) 0 5px, color-mix(in oklab, var(--line-2) 55%, transparent) 5px 10px); color: transparent; border-radius: 4px; padding: 0 2px; cursor: pointer; transition: background-color .15s, color .15s; }
.spoiler * { visibility: hidden; }
.spoiler.revealed { background: var(--active); color: inherit; cursor: auto; }
.spoiler.revealed * { visibility: visible; }
.mention { background: color-mix(in oklab, var(--accent) 16%, transparent); color: var(--accent-text); font-weight: 600; border-radius: 4px; padding: 0 3px; cursor: pointer; }
.mention:hover { background: var(--accent); color: var(--accent-ink); }
.mention.everyone { cursor: default; }
.mention.everyone:hover { background: color-mix(in oklab, var(--accent) 22%, transparent); color: var(--accent-text); }
.link { color: var(--link); text-decoration: none; }
.link:hover { text-decoration: underline; }
.me-action { color: var(--text-2); }

/* reactions */
.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin: 5px 0 2px; }
.react {
  height: 26px; padding: 0 7px; border-radius: var(--r-sm); display: inline-flex; align-items: center; gap: 5px;
  background: var(--hover); border: 1px solid var(--line); font-size: .875rem; transition: border-color .12s, background-color .12s;
}
.react:hover { border-color: var(--line-2); }
.react.mine { background: var(--hover); border-color: var(--accent); }
.react-e { font-size: 1rem; line-height: 1; }
.react-n { font-weight: 700; font-size: .8125rem; color: var(--text-2); }
.react.mine .react-n { color: var(--accent-text); }
.react-add { height: 26px; width: 30px; border-radius: var(--r-sm); display: inline-grid; place-items: center; color: var(--text-3); background: var(--hover); opacity: 0; transition: opacity .12s; }
.react-add .ic { width: 16px; height: 16px; }
.msg:hover .react-add, .react-add:focus-visible { opacity: 1; }
.react-add:hover { color: var(--text); }

/* pictures */
.attach-grid { display: grid; gap: 4px; margin: 5px 0 2px; max-width: 360px; }
.attach-grid.n1 { display: block; max-width: 100%; }
.attach-grid.n2, .attach-grid.n4 { grid-template-columns: 1fr 1fr; }
.attach-grid.n3 { grid-template-columns: 2fr 1fr; grid-template-rows: 1fr 1fr; }
.attach { display: block; position: relative; overflow: hidden; border-radius: var(--r); background: var(--sunk); }
.attach-grid:not(.n1) .attach { aspect-ratio: 1; }
.attach-grid.n3 .attach:first-child { grid-row: span 2; aspect-ratio: auto; }
.attach img { display: block; width: 100%; height: 100%; object-fit: cover; transition: filter .12s; }
.attach-grid.n1 .attach { display: inline-block; vertical-align: top; max-width: 100%; }
.attach-grid.n1 .attach img { max-width: 100%; height: auto; object-fit: contain; }
.attach:hover img { filter: brightness(1.07); }
.attach:focus-visible { outline-offset: 2px; }
.attach-gone { display: inline-flex; align-items: center; gap: 8px; margin: 5px 0 2px; padding: 10px 14px; border-radius: var(--r); background: var(--sunk); border: 1px dashed var(--line-2); color: var(--text-3); font-size: .875rem; }
.attach-gone .ic { width: 18px; height: 18px; }
.mini-msg .attach-grid, .saved-msg .attach-grid { max-width: 240px; }
.mini-msg .attach-grid.n1 .attach img, .saved-msg .attach-grid.n1 .attach img { max-height: 180px; width: auto !important; }

.attach-tray { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 10px 2px; }
.tray-item { position: relative; width: 76px; height: 76px; border-radius: var(--r); overflow: hidden; background: var(--sunk); display: grid; place-items: center; }
.tray-item img { width: 100%; height: 100%; object-fit: cover; }
.tray-item.processing img, .tray-item.uploading img { opacity: .45; }
.tray-item .spinner { position: absolute; width: 20px; height: 20px; border-width: 2.5px; }
.tray-x { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: rgba(0, 0, 0, .65); color: #fff; }
.tray-x .ic { width: 13px; height: 13px; stroke-width: 2.6; }
.tray-x:hover { background: var(--danger); }
.tray-add { width: 76px; height: 76px; border-radius: var(--r); display: grid; place-items: center; color: var(--text-3); border: 1px dashed var(--line-2); }
.tray-add:hover { color: var(--text); border-color: var(--text-3); }

.modal.lightbox { background: transparent; box-shadow: none; width: auto; max-width: none; }
.modal-wrap:has(.lightbox) .modal-backdrop { background: rgba(4, 5, 10, .88); }
.lightbox .modal-body { padding: 0; overflow: visible; display: grid; justify-items: center; gap: 12px; }
.lightbox img { display: block; max-width: min(94vw, 1600px); max-height: calc(100dvh - 110px); border-radius: var(--r); background: var(--sunk); }
.lb-bar { display: flex; gap: 8px; }
.lb-bar .btn { background: var(--raise); color: var(--text); }

/* polls */
.poll { margin: 6px 0 2px; max-width: 440px; padding: 12px 12px 10px; border-radius: var(--r-lg); background: var(--side); border: 1px solid var(--line); white-space: normal; }
.poll-q { display: flex; gap: 8px; align-items: flex-start; font: 700 1rem/1.3 var(--font-text); margin: 0 2px 10px; }
.poll-q .ic { color: var(--accent-text); margin-top: 2px; }
.poll-opts { display: grid; gap: 4px; }
.poll-opt {
  position: relative; overflow: hidden; display: flex; align-items: center; gap: 10px;
  min-height: 38px; padding: 7px 10px; border-radius: var(--r-sm); text-align: left;
  background: var(--hover); transition: background-color .12s;
}
.poll-opt:hover:not(:disabled) { background: var(--active); }
.poll-opt:disabled { opacity: 1; }
.po-fill { position: absolute; inset: 0 auto 0 0; background: var(--active); transition: width .4s var(--ease); }
.poll-opt.lead .po-fill { background: color-mix(in oklab, var(--text) 13%, transparent); }
.poll-opt.mine .po-text { color: var(--text); }
.po-check { position: relative; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line-2); display: grid; place-items: center; flex: none; }
.poll-opt.mine .po-check { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.po-check .ic { width: 12px; height: 12px; stroke-width: 3.2; }
.po-text { position: relative; flex: 1; font-weight: 600; }
.po-count { position: relative; font-weight: 700; font-size: .875rem; white-space: nowrap; }
.po-count small { color: var(--text-3); font-weight: 600; margin-left: 4px; }
.poll-foot { margin: 8px 2px 0; font-size: .8125rem; color: var(--text-3); display: flex; gap: 10px; flex-wrap: wrap; }

/* dice, coins, 8 ball */
.roll { display: flex; align-items: center; gap: 12px; margin: 4px 0; padding: 8px 14px 8px 10px; border-radius: var(--r-lg); background: var(--side); border: 1px solid var(--line); width: max-content; max-width: 100%; color: var(--text-2); }
.roll b { color: var(--text); }
.dice-faces { display: flex; gap: 4px; flex-wrap: wrap; }
.die {
  width: 34px; height: 34px; border-radius: 9px; flex: none; display: inline-grid;
  background: var(--text); color: var(--main); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .18);
}
.die.d6 { grid-template: repeat(3, 1fr) / repeat(3, 1fr); padding: 5px; }
.die.d6 i { border-radius: 50%; margin: 1.5px; }
.die.d6 i.on { background: var(--main); }
.die.dn { place-items: center; font: 800 1rem/1 var(--font-display); }
.dice .die { animation: roll .5s var(--ease); }
@keyframes roll { from { transform: rotate(-200deg) scale(.6); opacity: 0; } }
.roll-total { color: var(--accent-text) !important; font-size: 1.125rem; }
.coin-face {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; flex: none;
  font: 800 1.125rem/1 var(--font-display); color: #4a3200;
  background: radial-gradient(circle at 35% 30%, #ffe08a, #e7a91c 70%); box-shadow: inset 0 0 0 3px #c9890d;
}
.eight-ball { width: 40px; height: 40px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #4a4f63, #0d0e14 70%); display: grid; place-items: center; flex: none; color: #111; font: 800 .9rem/1 var(--font-display); }
.eight-ball::before { content: '8'; width: 18px; height: 18px; border-radius: 50%; background: #fff; display: grid; place-items: center; font: 800 .75rem/1 var(--font-display); color: #111; }
.eight-q { display: block; font-size: .8125rem; color: var(--text-3); }
.eight-a { display: block; font-size: 1rem; }

/* read receipts and bars */
.receipts { display: flex; justify-content: flex-end; padding: 2px 18px 0; min-height: 18px; }
.seen { font-size: .6875rem; font-weight: 700; color: var(--text-3); }
.seen-by { display: inline-flex; align-items: center; }
.seen-by .avatar { --s: 16px; margin-left: -4px; box-shadow: 0 0 0 2px var(--main); }
.seen-by .av-emoji { font-size: 10px; }
.seen-by .av-initials { font-size: 7px; }
.seen-by small { font-size: .6875rem; color: var(--text-3); margin-left: 4px; font-weight: 700; }
.jump-bar, .new-bar {
  position: absolute; left: 16px; right: 16px; z-index: 3; display: flex; justify-content: space-between; align-items: center;
  height: 32px; padding: 0 14px; border-radius: var(--r); font-size: .8125rem; font-weight: 700;
}
.jump-bar { bottom: calc(var(--composer-h, 80px) + 4px); background: var(--raise); color: var(--text-2); box-shadow: var(--shadow); }
.jump-bar span { display: inline-flex; align-items: center; gap: 4px; color: var(--accent-text); }
.jump-bar .ic { width: 15px; height: 15px; }
.new-bar { top: 8px; background: var(--danger); color: #fff; }

/* ---------- composer ---------- */
.composer-wrap { position: relative; flex: none; padding: 0 16px 18px; }
.typing-bar { height: 24px; display: flex; align-items: center; gap: 7px; padding-left: 4px; font-size: .8125rem; color: var(--text-2); opacity: 0; transition: opacity .15s; }
.typing-bar.on { opacity: 1; }
.typing-bar b { color: var(--text); }
.typing-dots { display: inline-flex; gap: 3px; }
.typing-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-2); animation: dot 1.2s infinite ease-in-out; }
.typing-dots i:nth-child(2) { animation-delay: .15s; }
.typing-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 60%, 100% { opacity: .35; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }
.composer { position: relative; background: var(--field); border-radius: var(--r-lg); box-shadow: inset 0 0 0 1px var(--line); transition: box-shadow .15s; }
.composer:focus-within { box-shadow: inset 0 0 0 1px var(--line-2); }
.reply-bar { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 14px; font-size: .8125rem; color: var(--text-2); border-bottom: 1px solid var(--line); }
.reply-bar .ic { width: 16px; height: 16px; color: var(--text-3); }
.reply-bar span { flex: 1; }
.reply-bar b { color: var(--text); }
.composer-row { display: flex; align-items: flex-end; gap: 2px; padding: 5px 6px; }
.composer-row .icon-btn { height: 34px; width: 34px; }
#input {
  flex: 1; min-width: 0; resize: none; overflow-y: auto; border: 0; outline: none; box-shadow: none !important;
  background: transparent; padding: 7px 6px; min-height: 34px; max-height: 40vh; line-height: 1.4; font-size: 1rem;
}
.send-btn { width: 34px; height: 34px; border-radius: var(--r); flex: none; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); transition: transform .12s, filter .12s; }
.send-btn:hover { filter: brightness(1.08); }
.send-btn:active { transform: scale(.92); }
.send-btn .ic { width: 18px; height: 18px; }
.char-count { position: absolute; right: 54px; bottom: -18px; font-size: .75rem; font-weight: 700; color: var(--text-3); }
.char-count.over { color: var(--danger); }
.composer-blocked { padding: 14px 16px; border-radius: var(--r); background: var(--side); color: var(--text-2); font-size: .875rem; text-align: center; }
.autocomplete {
  position: absolute; left: 16px; right: 16px; bottom: calc(100% - 20px); z-index: 5; max-height: 320px; overflow-y: auto;
  background: var(--raise); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 6px; --ring: var(--raise);
}
.ac-title { font: 700 .75rem/1 var(--font-display); color: var(--text-3); padding: 6px 8px 8px; }
.ac-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 8px; border-radius: var(--r-sm); text-align: left; }
.ac-item.on, .ac-item:hover { background: var(--active); }
.ac-cmd { font-weight: 700; white-space: nowrap; }
.ac-cmd small { color: var(--text-3); font-weight: 400; }
.ac-desc { color: var(--text-3); font-size: .8125rem; margin-left: auto; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ac-emoji { font-size: 1.25rem; width: 24px; text-align: center; }
.ac-at { width: 24px; display: grid; place-items: center; color: var(--text-2); }

/* ---------- right panel ---------- */
.panel { --ring: var(--side); background: var(--side); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }
.panel-head { height: var(--bar-h); flex: none; display: flex; align-items: center; justify-content: space-between; padding: 0 10px 0 16px; border-bottom: 1px solid var(--line); }
.panel-head h2 { font: 700 1rem/1 var(--font-display); }
.panel-scroll { flex: 1; overflow-y: auto; min-height: 0; }
.panel-empty { padding: 40px 20px; text-align: center; color: var(--text-2); display: grid; justify-items: center; gap: 8px; }
.group-card { padding: 22px 16px 16px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; border-bottom: 1px solid var(--line); }
.group-card h3 { font: 700 1.125rem/1.15 var(--font-display); margin-top: 6px; overflow-wrap: anywhere; }
.gc-icon { border-radius: 32%; }
.gc-icon:hover { filter: brightness(1.08); }
.gc-topic { font-size: .875rem; color: var(--text-2); }
.gc-actions { display: flex; gap: 6px; margin: 8px 0 4px; }
.invite-box { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 6px 6px 12px; margin-top: 6px; border-radius: var(--r); background: var(--sunk); }
.invite-label { font-size: .75rem; color: var(--text-3); font-weight: 700; }
.invite-box code { flex: 1; text-align: left; font-size: .875rem; font-weight: 700; color: var(--accent-text); letter-spacing: .04em; }
.mem-head { font: 700 .8125rem/1 var(--font-text); color: var(--text-3); padding: 18px 16px 6px; display: flex; gap: 6px; }
.mem-head span { color: var(--text-3); font-weight: 600; }
.member-list { list-style: none; padding: 0 8px; }
.member { display: flex; align-items: center; gap: 10px; width: 100%; padding: 5px 8px; border-radius: var(--r-sm); text-align: left; }
.member:hover { background: var(--hover); }
.member.off { opacity: .45; }
.member.off:hover { opacity: .9; }
.mem-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.mem-name { font-weight: 700; display: flex; align-items: center; gap: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mem-sub { font-size: .75rem; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-list { list-style: none; padding: 10px; display: grid; gap: 8px; }
.mini-msg { padding: 10px 12px; border-radius: var(--r); background: var(--main); --ring: var(--main); border: 1px solid var(--line); }
.mm-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; font-size: .875rem; }
.mm-head b { font-weight: 700; }
.mm-head time { margin-left: auto; font-size: .6875rem; color: var(--text-3); }
.mini-msg .md { font-size: .9375rem; }
.mini-msg .poll { padding: 10px; }
.mm-actions { display: flex; gap: 6px; margin-top: 8px; }

/* profile card */
.profile-card { position: relative; --ring: var(--raise); }
.panel .profile-card { --ring: var(--side); }
.pc-banner { height: 96px; background: var(--banner); }
.profile-card.full .pc-banner { height: 120px; }
.pc-av { position: absolute; left: 16px; top: 52px; padding: 5px; border-radius: 50%; background: var(--ring); }
.profile-card.full .pc-av { top: 72px; }
.pc-av .presence { right: 2px; bottom: 2px; }
.pc-bubble {
  position: absolute; left: 118px; top: 112px; right: 14px; padding: 7px 11px; border-radius: 12px 12px 12px 4px;
  background: var(--sunk); font-size: .8125rem; color: var(--text-2); box-shadow: 0 0 0 1px var(--line);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.profile-card.full .pc-bubble { top: 128px; }
.pc-body { padding: 56px 16px 16px; }
.pc-name { font: 800 1.375rem/1.15 var(--font-display); overflow-wrap: anywhere; }
.pc-user { color: var(--text-2); font-size: .875rem; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pc-pron { padding-left: 8px; border-left: 1px solid var(--line-2); color: var(--text-3); }
.pc-actions { display: flex; gap: 6px; margin-top: 12px; align-items: center; flex-wrap: wrap; }
.pc-sec { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.pc-sec h4 { font: 700 .75rem/1 var(--font-display); color: var(--text-3); margin-bottom: 6px; }
.pc-sec p, .pc-bio .md { font-size: .875rem; }
.pc-bio { font-size: .875rem; }
.pc-bio .md { font-size: .875rem; }
.pc-mutuals { display: flex; flex-wrap: wrap; gap: 6px; }
.pc-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px 3px 3px; border-radius: 14px; background: var(--sunk); font-size: .8125rem; max-width: 100%; }
.pc-chip span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pc-chip:hover { background: var(--active); }
.pc-chip .av-emoji { font-size: 11px; }
.pc-chip .av-initials { font-size: 8px; }
.pc-note { background: transparent; border-color: transparent; padding: 6px 8px; margin: 0 -8px; width: calc(100% + 16px); font-size: .8125rem; min-height: 0; resize: none; }
.pc-note:hover { background: var(--sunk); }
.pc-note:focus { background: var(--sunk); }

/* ============================================================
   Overlays: popovers, menus, modals, toasts, tooltips
   ============================================================ */
#layers { position: relative; z-index: 50; }
.popover { position: fixed; z-index: 60; --ring: var(--raise); background: var(--raise); border-radius: var(--r-lg); box-shadow: var(--shadow); max-height: calc(100dvh - 16px); overflow-y: auto; animation: pop .14s var(--ease); }
@keyframes pop { from { opacity: 0; transform: scale(.97) translateY(4px); } }
.profile-pop { width: 320px; overflow: hidden auto; }
.menu-pop { padding: 6px; min-width: 210px; }
.menu { display: flex; flex-direction: column; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 10px; border-radius: var(--r-sm); text-align: left; font-size: .875rem; font-weight: 600; color: var(--text-2); }
.menu-item .ic { width: 18px; height: 18px; color: var(--text-3); }
.menu-item:hover:not(:disabled), .menu-item:focus-visible { background: var(--active); color: var(--text); outline: none; }
.menu-item:hover .ic { color: var(--text); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger .ic { color: var(--danger); }
.menu-item.danger:hover { background: var(--danger); color: #fff; }
.menu-item.danger:hover .ic { color: #fff; }
.menu-item kbd { margin-left: auto; }
.menu-label { flex: 1; display: flex; flex-direction: column; }
.menu-label small { font-size: .75rem; color: var(--text-3); font-weight: 400; }
.menu-sep { height: 1px; background: var(--line); margin: 5px 6px; }
.status-pop { width: 270px; }
.sp-head { display: flex; align-items: center; gap: 10px; padding: 8px 10px 12px; }
.sp-head b { display: block; }
.sp-head small { color: var(--text-3); }
.status-item.on { color: var(--text); }

.emoji-picker { width: 352px; max-width: calc(100vw - 16px); display: flex; flex-direction: column; height: 400px; }
.ep-pop { overflow: hidden; }
.ep-search { position: relative; padding: 10px 10px 6px; }
.ep-search .ic { position: absolute; left: 21px; top: 50%; translate: 0 -30%; width: 16px; height: 16px; color: var(--text-3); }
.ep-search input { height: 34px; padding-left: 34px; background: var(--sunk); }
.ep-tabs { display: flex; padding: 0 6px; border-bottom: 1px solid var(--line); }
.ep-tab { flex: 1; height: 34px; font-size: 1.05rem; border-radius: 7px 7px 0 0; opacity: .6; filter: grayscale(.6); }
.ep-tab:hover { opacity: 1; filter: none; background: var(--hover); }
.ep-grid { flex: 1; overflow-y: auto; padding: 0 8px 8px; position: relative; }
.ep-section h4 { position: sticky; top: 0; background: var(--raise); font: 700 .75rem/1 var(--font-display); color: var(--text-3); padding: 10px 4px 6px; z-index: 1; }
.ep-cells { display: grid; grid-template-columns: repeat(8, 1fr); }
.ep-cell { aspect-ratio: 1; font-size: 1.45rem; border-radius: var(--r-sm); display: grid; place-items: center; line-height: 1; }
.ep-cell:hover { background: var(--active); }
.ep-empty { padding: 30px 10px; text-align: center; color: var(--text-3); font-size: .875rem; }
.ep-foot { height: 42px; flex: none; display: flex; align-items: center; gap: 8px; padding: 0 12px; border-top: 1px solid var(--line); background: var(--sunk); font-size: .8125rem; color: var(--text-2); font-weight: 700; }
.ep-preview-char { font-size: 1.4rem; }

.modal-wrap { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; z-index: 55; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(5, 7, 20, .62); opacity: 0; transition: opacity .16s; }
[data-theme="daylight"] .modal-backdrop { background: rgba(20, 24, 50, .38); }
.modal {
  position: relative; --ring: var(--raise); background: var(--raise); border-radius: var(--r-lg); box-shadow: var(--shadow);
  width: 100%; max-height: calc(100dvh - 32px); display: flex; flex-direction: column;
  opacity: 0; transform: scale(.97) translateY(6px); transition: opacity .16s, transform .2s var(--ease);
}
.modal-wrap.in .modal-backdrop { opacity: 1; }
.modal-wrap.in .modal { opacity: 1; transform: none; }
.modal-wrap.out .modal-backdrop, .modal-wrap.out .modal { opacity: 0; }
.modal-sm { max-width: 420px; }
.modal-md { max-width: 520px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 18px 16px 6px 22px; }
.modal-head h2 { font: 700 1.1875rem/1.2 var(--font-display); }
.modal-body { padding: 10px 22px 18px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--line); background: color-mix(in oklab, var(--raise) 70%, var(--sunk)); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.modal-text { color: var(--text-2); margin-bottom: 12px; }
.warn-text { color: var(--idle); display: flex; gap: 6px; align-items: flex-start; font-size: .875rem; }
.warn-text .ic { width: 17px; height: 17px; flex: none; margin-top: 2px; }
.quote-preview { display: block; padding: 10px 12px; margin-bottom: 12px; border-radius: var(--r); background: var(--sunk); color: var(--text); font-size: .875rem; overflow-wrap: anywhere; }
.url-box { display: block; padding: 10px 12px; border-radius: var(--r); background: var(--sunk); font-size: .8125rem; overflow-wrap: anywhere; color: var(--text); }

/* picker */
.picker .search-field { margin-bottom: 8px; }
.picked { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.picked:empty { display: none; }
.pick-chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 6px 3px 10px; border-radius: 14px; background: color-mix(in oklab, var(--accent) 20%, transparent); color: var(--accent-text); font-size: .8125rem; font-weight: 700; }
.pick-chip .ic { width: 14px; height: 14px; }
.pick-list { list-style: none; max-height: 300px; overflow-y: auto; margin: 0 -8px; }
.pick-row { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: var(--r-sm); cursor: pointer; }
.pick-row:hover { background: var(--hover); }
.pick-text { flex: 1; display: flex; flex-direction: column; line-height: 1.25; }
.pick-text small { color: var(--text-3); }

/* group settings */
.gs-top { display: flex; gap: 18px; align-items: flex-start; }
.gs-icon { position: relative; border-radius: 32%; margin-top: 4px; }
.gs-edit { position: absolute; right: -6px; bottom: -6px; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; box-shadow: 0 0 0 3px var(--raise); }
.gs-edit .ic { width: 15px; height: 15px; }
.gs-fields { flex: 1; min-width: 0; }
.gs-sec { padding-top: 16px; margin-top: 4px; border-top: 1px solid var(--line); }
.gs-sec h3 { font: 700 1rem/1.2 var(--font-display); margin-bottom: 4px; }
.gs-sec .field-hint { margin: 0 0 10px; }
.gs-invite { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.invite-code { padding: 6px 12px; border-radius: var(--r-sm); background: var(--sunk); font-weight: 700; letter-spacing: .05em; color: var(--accent-text); }
.danger-zone h3 { color: var(--danger); }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { width: 28px; height: 28px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15); position: relative; transition: transform .12s; }
.swatch:hover { transform: scale(1.1); }
.swatch.on { box-shadow: 0 0 0 2px var(--raise), 0 0 0 4px var(--text); }
.swatch-custom { display: grid; place-items: center; background: var(--sunk); color: var(--text-2); cursor: pointer; overflow: hidden; }
.swatch-custom .ic { width: 16px; height: 16px; pointer-events: none; }
.swatch-custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }

/* polls dialog */
.poll-rows { display: grid; gap: 6px; margin-bottom: 8px; }
.poll-row { display: flex; gap: 6px; align-items: center; }

/* join */
.join-preview:empty { display: none; }
.jp-card { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: var(--r); background: var(--sunk); }
.jp-card b { display: block; font-family: var(--font-display); font-size: 1.0625rem; }
.jp-card small { color: var(--text-3); }

/* custom status */
.cs-input { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; }
.cs-emoji-btn { width: 40px; height: 40px; flex: none; border-radius: var(--r); background: var(--field); font-size: 1.3rem; display: grid; place-items: center; color: var(--text-2); }
.cs-emoji-btn:hover { background: var(--active); }
.presets { display: flex; flex-wrap: wrap; gap: 6px; }
.presets .chip { height: 30px; font-weight: 600; color: var(--text-2); box-shadow: inset 0 0 0 1px var(--line-2); }

/* quick switcher */
.qs-modal { max-width: 560px; align-self: start; margin-top: 12vh; }
.qs-modal .modal-body { padding: 14px; }
.qs-input { position: relative; }
.qs-input .ic { position: absolute; left: 14px; top: 50%; translate: 0 -50%; color: var(--text-3); }
.qs-input input { height: 48px; font-size: 1.0625rem; padding-left: 44px; background: var(--sunk); border-radius: var(--r); }
.qs-list { list-style: none; margin-top: 10px; max-height: 50vh; overflow-y: auto; }
.qs-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 7px 10px; border-radius: var(--r-sm); text-align: left; }
.qs-item.on, .qs-item:hover { background: var(--active); }
.qs-name { flex: 1; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qs-kind { font-size: .75rem; color: var(--text-3); }
.qs-empty { padding: 20px 10px; color: var(--text-3); font-size: .875rem; }
.qs-tip { margin-top: 10px; font-size: .75rem; color: var(--text-3); }

/* shortcuts */
.shortcut-list { margin: 0; display: grid; gap: 2px; }
.shortcut-list div { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.shortcut-list dt { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; color: var(--text-3); font-size: .8125rem; }
.shortcut-list dd { margin: 0; color: var(--text-2); text-align: right; font-size: .875rem; }
.shortcut-list kbd { font-size: .75rem; padding: 3px 8px; color: var(--text); }
.shortcut-list.fmt dt code { font-size: .8125rem; color: var(--text); }

/* ---------- settings ---------- */
.modal-full { max-width: none; height: 100dvh; max-height: none; border-radius: 0; }
.modal-wrap:has(.modal-full) { padding: 0; }
.settings .modal-body { padding: 0; height: 100%; overflow: hidden; }
.set-layout { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(0, 760px) minmax(60px, 1fr); height: 100%; background: var(--main); }
.set-nav { background: var(--side); display: flex; flex-direction: column; align-items: flex-end; padding: 56px 12px 20px; overflow-y: auto; }
.set-nav > * { width: 210px; }
.set-nav-title { font: 800 1.5rem/1 var(--font-display); padding: 0 10px 16px; }
.set-link { display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 10px; border-radius: var(--r-sm); color: var(--text-2); font-weight: 700; font-size: .9375rem; margin-bottom: 2px; }
.set-link .ic { width: 18px; height: 18px; }
.set-link:hover { background: var(--hover); color: var(--text); }
.set-link.on { background: var(--active); color: var(--text); }
.set-link.danger { color: var(--danger); }
.set-sep { height: 1px; background: var(--line); margin: 10px 0; }
.set-version { font-size: .75rem; color: var(--text-3); padding: 10px; }
.set-body { padding: 56px 40px 60px; overflow-y: auto; --ring: var(--main); }
.set-body h1 { font: 800 1.75rem/1.1 var(--font-display); margin-bottom: 22px; }
.set-h2 { font: 700 1rem/1.2 var(--font-display); margin: 28px 0 12px; color: var(--text); }
.set-close { position: absolute; right: 24px; top: 48px; width: 44px; height: 44px; border-radius: 50%; box-shadow: inset 0 0 0 2px var(--line-2); display: grid; justify-items: center; gap: 2px; }
.set-close kbd { position: absolute; top: 50px; background: none; border: 0; font-weight: 700; }
.set-group { background: var(--side); border-radius: var(--r-lg); padding: 2px 18px; margin-bottom: 18px; border: 1px solid var(--line); }
.set-item { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.set-item:last-child { border-bottom: 0; }
.set-item h3 { font-weight: 700; font-size: .9375rem; }
.set-item p { color: var(--text-3); font-size: .8125rem; margin-top: 2px; }
.acct-card { border-radius: var(--r-lg); overflow: hidden; background: var(--side); margin-bottom: 18px; --ring: var(--side); box-shadow: inset 0 0 0 1px var(--line); }
.acct-banner { height: 90px; background: var(--banner); }
.acct-row { display: flex; align-items: flex-end; gap: 14px; padding: 0 18px 18px; margin-top: -30px; }
.acct-row .avatar { box-shadow: 0 0 0 6px var(--side); }
.acct-names { flex: 1; display: flex; flex-direction: column; padding-bottom: 4px; }
.acct-names b { font: 800 1.25rem/1.15 var(--font-display); }
.acct-names span { color: var(--text-2); font-size: .875rem; }
.profile-edit { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 28px; align-items: start; }
.pe-avatar { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.pe-sub { margin: -2px 0 4px; }
.pe-photo { display: flex; align-items: center; gap: 16px; }
.pe-photo-btn { position: relative; border-radius: 50%; --ring: var(--main); flex: none; }
.pe-photo-btn:hover .avatar { filter: brightness(.85); }
.pe-photo-btn.busy { pointer-events: none; opacity: .6; }
.pe-photo-badge { position: absolute; right: -2px; bottom: -2px; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); box-shadow: 0 0 0 3px var(--main); }
.pe-photo-badge .ic { width: 15px; height: 15px; }
.pe-photo-side { display: grid; gap: 6px; min-width: 0; }
.pe-emoji { width: 52px; height: 52px; border-radius: var(--r); background: var(--field); font-size: 1.75rem; display: grid; place-items: center; color: var(--text-2); }
.pe-emoji:hover { background: var(--active); }
.pe-actions { display: flex; justify-content: flex-end; gap: 8px; }
.pe-preview { position: sticky; top: 0; }
.pe-preview [data-preview] { margin-top: 8px; border-radius: var(--r-lg); overflow: hidden; background: var(--raise); box-shadow: var(--shadow); }
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(116px, 1fr)); gap: 10px; }
.theme-card { text-align: left; padding: 10px; border-radius: var(--r-lg); background: var(--side); box-shadow: inset 0 0 0 1px var(--line); display: flex; flex-direction: column; gap: 2px; }
.theme-card:hover { box-shadow: inset 0 0 0 1px var(--line-2); }
.theme-card.on { box-shadow: inset 0 0 0 2px var(--accent); }
.theme-card b { font-size: .875rem; margin-top: 8px; }
.theme-card small { font-size: .75rem; color: var(--text-3); }
.theme-swatch { display: grid; grid-template-columns: 1fr 2fr 4fr; height: 56px; border-radius: 8px; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(127, 127, 127, .2); }
.theme-swatch i:nth-child(1) { background: var(--rail); }
.theme-swatch i:nth-child(2) { background: var(--side); }
.theme-swatch i:nth-child(3) { background: var(--main); position: relative; }
.theme-swatch i:nth-child(3)::after { content: ''; position: absolute; left: 10%; right: 30%; bottom: 10px; height: 8px; border-radius: 4px; background: var(--accent); }
.accent-row { display: flex; flex-wrap: wrap; gap: 8px; }
.accent-pick { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px 0 6px; border-radius: 18px; background: var(--side); box-shadow: inset 0 0 0 1px var(--line); font-size: .8125rem; font-weight: 700; color: var(--text-2); position: relative; cursor: pointer; }
.accent-pick span { width: 24px; height: 24px; border-radius: 50%; background: var(--c, conic-gradient(#ff5f5f, #ffcc4d, #57d66b, #3fc9c1, #4db3ff, #9d7bff, #ff5fa2, #ff5f5f)); }
.accent-pick.on { box-shadow: inset 0 0 0 2px var(--c, var(--accent)); color: var(--text); }
.accent-pick.custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.range-row { display: flex; align-items: center; gap: 12px; max-width: 460px; }
.range-row input { flex: 1; accent-color: var(--accent); }
.range-row output { font-weight: 700; font-size: .875rem; width: 44px; text-align: right; }
.aa { font-family: var(--font-display); font-weight: 700; color: var(--text-3); }
.aa.small { font-size: .8rem; }
.aa.big { font-size: 1.3rem; }
.set-list { list-style: none; display: grid; gap: 6px; margin-bottom: 12px; }
.set-list li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--r); background: var(--side); }
.set-list li > span:nth-child(2) { flex: 1; display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.set-list small { color: var(--text-3); font-size: .8125rem; }
.device-ic { width: 36px; height: 36px; border-radius: 50%; background: var(--sunk); display: grid; place-items: center; color: var(--text-2); }

/* toasts and tooltips */
.toasts { position: fixed; left: 50%; top: 66px; translate: -50% 0; z-index: 90; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  pointer-events: auto; max-width: min(460px, calc(100vw - 32px)); padding: 10px 16px; border-radius: var(--r);
  background: var(--raise); color: var(--text); box-shadow: var(--shadow); font-weight: 600; font-size: .875rem;
  opacity: 0; transform: translateY(-10px); transition: opacity .2s, transform .25s var(--ease);
  border-left: 3px solid var(--text-3);
}
.toast.in { opacity: 1; transform: none; }
.toast-error { border-left-color: var(--danger); }
.toast-success { border-left-color: var(--ok); }
.toast-info { border-left-color: var(--accent); }
.tip {
  position: fixed; z-index: 95; pointer-events: none; padding: 6px 10px; border-radius: var(--r-sm);
  background: #0a0c18; color: #f1f2f8; font-size: .8125rem; font-weight: 700; white-space: nowrap;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .35); animation: pop .1s var(--ease);
}
[data-theme="daylight"] .tip { background: #1a1e33; }
.offline {
  position: fixed; top: 10px; left: 50%; translate: -50% 0; z-index: 80; display: flex; align-items: center; gap: 10px;
  padding: 8px 16px 8px 10px; border-radius: 20px; background: var(--danger); color: #fff; font-weight: 700; font-size: .875rem;
  box-shadow: var(--shadow);
}
.offline .spinner { width: 16px; height: 16px; border-width: 2px; border-color: rgba(255, 255, 255, .35); border-top-color: #fff; }

/* ============================================================
   Compact mode, motion and mobile
   ============================================================ */
[data-compact] .msg { grid-template-columns: 64px minmax(0, 1fr); }
[data-compact] .msg.first { margin-top: 6px; }
[data-compact] .msg-av { display: none; }
[data-compact] .msg.first .msg-gutter::before { content: ''; }
[data-compact] .msg-reply { padding-left: 64px; margin-top: 6px; }
[data-compact] .reply-spine { display: none; }
[data-compact] .md.jumbo { font-size: 2rem; }

[data-reduce-motion] *, [data-reduce-motion] *::before, [data-reduce-motion] *::after { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

@media (hover: none) {
  .msg { -webkit-touch-callout: none; }
  .msg:hover { background: transparent; }
  .msg:hover .msg-tools { display: none; }
  .react-add { opacity: 1; }
  .code-copy { opacity: 1; }
}

@media (max-width: 1180px) {
  .friends-body { grid-template-columns: minmax(0, 1fr); }
  .active-now { display: none; }
  .profile-edit { grid-template-columns: minmax(0, 1fr); }
  .pe-preview { position: static; max-width: 340px; }
}

@media (max-width: 1080px) {
  :root { --panel-w: 270px; }
  .ct-search { display: none; }
}

@media (max-width: 860px) {
  .only-mobile { display: inline-grid !important; }
  .app, .app.panel-open { grid-template-columns: minmax(0, 1fr); }
  .rail, .sidebar { position: fixed; top: 0; bottom: 0; z-index: 40; transition: transform .24s var(--ease); }
  .rail { left: 0; width: var(--rail-w); transform: translateX(-100%); }
  .sidebar { left: var(--rail-w); width: min(300px, calc(100vw - var(--rail-w) - 24px)); transform: translateX(calc(-100% - var(--rail-w))); box-shadow: var(--shadow); }
  .app.nav-open .rail, .app.nav-open .sidebar { transform: none; }
  .app::after { content: ''; position: fixed; inset: 0; z-index: 35; background: rgba(5, 7, 20, .55); opacity: 0; pointer-events: none; transition: opacity .2s; }
  .app.nav-open::after { opacity: 1; pointer-events: auto; }
  .main { grid-column: 1; }
  .panel { position: fixed; right: 0; top: 0; bottom: 0; z-index: 30; width: min(340px, 92vw); transform: translateX(100%); transition: transform .24s var(--ease); box-shadow: var(--shadow); }
  .app.panel-open .panel { transform: none; }
  .topbar { padding: 0 8px; gap: 6px; }
  .topbar-sub { display: none; }
  .tabs { margin-left: 0; padding-left: 6px; }
  .tab { padding: 0 9px; }
  .msg { grid-template-columns: 58px minmax(0, 1fr); padding-right: 10px; }
  .msg-reply { padding-left: 58px; }
  .reply-spine { left: 28px; width: 26px; }
  .msg-tools { right: 8px; }
  .friends-main, .saved-body { padding: 14px 14px 30px; }
  .composer-wrap { padding: 0 8px calc(10px + env(safe-area-inset-bottom)); }
  .ct-actions .icon-btn[data-action="nudge"], .ct-actions .icon-btn[data-action="add-members"] { display: none; }
  .sb-find kbd { display: none; }
  .auth { grid-template-columns: 1fr; }
  .auth-stage { padding-bottom: 8px; }
  .wordmark { font-size: min(6.5rem, 28cqi); margin-bottom: 10px; }
  .demo-window { display: none; }
  .auth-side { border-left: 0; padding-top: 18px; justify-content: flex-start; }
  .set-layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .set-nav { flex-direction: row; align-items: center; padding: 10px; overflow-x: auto; gap: 4px; }
  .set-nav > * { width: auto; flex: none; }
  .set-nav-title, .set-sep, .set-version { display: none; }
  .set-link span { display: none; }
  .set-link.on span { display: inline; }
  .set-body { padding: 22px 16px 60px; }
  .set-close { top: 8px; right: 8px; width: 38px; height: 38px; z-index: 2; background: var(--side); }
  .set-close kbd { display: none; }
  .profile-pop { width: min(320px, calc(100vw - 16px)); }
  .modal-wrap { padding: 8px; align-items: end; }
  .modal { max-height: calc(100dvh - 16px); }
  .qs-modal { margin-top: 0; align-self: auto; }
}
