/* =====================================================================
   Tellurium — "graphite & paper"
   Warm paper surfaces, graphite ink, and a teal accent borrowed from
   the blue-green flame tellurium burns with.
   ===================================================================== */

:root {
  --paper: #f4f2ec;
  --surface: #ffffff;
  --surface-2: #faf9f5;
  --sunken: #ecebe4;
  --line: #e2dfd6;
  --line-strong: #cfcbc0;
  --ink: #1a1b1e;
  --ink-2: #3c3e44;
  --muted: #74766f;
  --rail: #1f2023;
  --rail-ink: #b9bab4;
  --rail-hover: #2c2d31;
  --accent: #2f8a74;
  --accent-strong: #236d5b;
  --accent-soft: #dcefe8;
  --accent-ink: #ffffff;
  --danger: #c2453b;
  --danger-soft: #f8e3e0;
  --ok: #2f8a74;
  --online: #34a37a;
  --owner: #b5832a;
  --shadow: 0 1px 2px rgb(20 20 15 / 0.06), 0 8px 24px rgb(20 20 15 / 0.08);
  --shadow-lg: 0 24px 60px rgb(10 10 8 / 0.25);
  --r-s: 8px;
  --r: 12px;
  --r-l: 18px;
  --font: 'Manrope', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'Cascadia Code', Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --paper: #111214;
    --surface: #18191c;
    --surface-2: #1d1e22;
    --sunken: #0d0e10;
    --line: #2a2b30;
    --line-strong: #3a3c42;
    --ink: #ecebe6;
    --ink-2: #c8c8c2;
    --muted: #8f918a;
    --rail: #0b0c0d;
    --rail-ink: #8f918a;
    --rail-hover: #1d1e22;
    --accent: #58c2a6;
    --accent-strong: #79d4bb;
    --accent-soft: #173a31;
    --accent-ink: #0b1f1a;
    --danger: #ef7d72;
    --danger-soft: #3a1c19;
    --online: #4cc896;
    --owner: #e0b45c;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 8px 24px rgb(0 0 0 / 0.35);
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --paper: #111214;
  --surface: #18191c;
  --surface-2: #1d1e22;
  --sunken: #0d0e10;
  --line: #2a2b30;
  --line-strong: #3a3c42;
  --ink: #ecebe6;
  --ink-2: #c8c8c2;
  --muted: #8f918a;
  --rail: #0b0c0d;
  --rail-ink: #8f918a;
  --rail-hover: #1d1e22;
  --accent: #58c2a6;
  --accent-strong: #79d4bb;
  --accent-soft: #173a31;
  --accent-ink: #0b1f1a;
  --danger: #ef7d72;
  --danger-soft: #3a1c19;
  --online: #4cc896;
  --owner: #e0b45c;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 8px 24px rgb(0 0 0 / 0.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
.hidden { display: none !important; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
h3 { font-size: 0.95rem; }
p { margin: 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: 0.5rem 0; width: 100%; }
img { display: block; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.mono { font-family: var(--mono); }
.center { text-align: center; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row { display: flex; align-items: center; gap: 0.75rem; }
.row.gap-s, .gap-s { gap: 0.5rem; }
.row.gap { gap: 1rem; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.stack.gap-s { gap: 0.5rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.pad { padding: 1rem; }

/* ---------- Form controls ---------- */
input[type='text'], input[type='email'], input[type='password'], input[type='search'], select, textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  padding: 0.62rem 0.8rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { resize: vertical; }
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type='color'] { width: 44px; height: 34px; border: 1px solid var(--line); border-radius: var(--r-s); background: none; padding: 2px; cursor: pointer; }

.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field-label { font-size: 0.8rem; font-weight: 700; color: var(--ink-2); }
.field-hint { font-size: 0.78rem; color: var(--muted); }
.prefix-input { display: flex; align-items: stretch; }
.prefix-input > span {
  display: grid; place-items: center; padding: 0 0.65rem;
  background: var(--sunken); border: 1px solid var(--line); border-right: 0;
  border-radius: var(--r-s) 0 0 var(--r-s); color: var(--muted); font-weight: 700;
}
.prefix-input input { border-radius: 0 var(--r-s) var(--r-s) 0; }
.check, .radio { display: flex; gap: 0.65rem; align-items: flex-start; cursor: pointer; }
.check input, .radio input { margin-top: 0.3rem; accent-color: var(--accent); width: 16px; height: 16px; }
.form-error { color: var(--danger); font-size: 0.88rem; min-height: 1.2em; font-weight: 600; }
.form-error.ok, .form-note { color: var(--accent-strong); font-size: 0.88rem; font-weight: 600; }
.form-note:empty { display: none; }
.ink { color: var(--ink); }
.center-self { align-self: center; margin: 0.25rem auto 0; display: block; }
.auth-card > .link-btn, .auth-card > .btn { margin-top: 0.75rem; }
.auth-card > p { margin-top: 0.5rem; }
.auth-card > .auth-form { margin-top: 1rem; }
.auth-icon { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-strong); }
.auth-icon + h2 { margin-top: 1rem; }
.code-input { font-family: var(--mono); font-size: 1.6rem !important; letter-spacing: 0.5em; text-align: center; padding: 0.7rem !important; }

/* ---------- Buttons ---------- */
button { font: inherit; color: inherit; cursor: pointer; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  border: 1px solid transparent; border-radius: 999px;
  padding: 0.55rem 1.1rem; font-weight: 700; font-size: 0.9rem;
  background: transparent; color: var(--ink); transition: background 0.15s, border-color 0.15s, transform 0.05s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover:not(:disabled) { background: var(--accent-strong); }
.btn.ghost { border-color: var(--line-strong); background: var(--surface); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); border-color: var(--muted); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger-text { color: var(--danger); }
.btn.small { padding: 0.32rem 0.8rem; font-size: 0.82rem; }
.btn.block { width: 100%; padding: 0.75rem; }
.btn.icon-btn.round { padding: 0; width: 36px; height: 36px; border-radius: 50%; background: var(--sunken); }
.icon-btn {
  display: inline-grid; place-items: center; background: transparent; border: 0;
  width: 36px; height: 36px; border-radius: var(--r-s); color: var(--muted); flex: none;
}
.icon-btn:hover { background: var(--sunken); color: var(--ink); }
.icon-btn.small { width: 28px; height: 28px; }
.icon-btn.accent { color: var(--accent); }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 700; }
.icon { flex: none; }

/* ---------- Badges & bits ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 0.2rem; padding: 0.05rem 0.4rem;
  border-radius: 999px; font-size: 0.66rem; font-weight: 800; letter-spacing: 0.03em; text-transform: uppercase;
  vertical-align: middle;
}
.badge.admin { background: var(--accent-soft); color: var(--accent-strong); }
.badge.owner { background: color-mix(in srgb, var(--owner) 18%, transparent); color: var(--owner); }
.pronouns {
  font-size: 0.74rem; color: var(--muted); background: var(--sunken); border-radius: 999px;
  padding: 0.02rem 0.45rem; margin-left: 0.35rem; font-weight: 600;
}
.pill {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--danger); color: #fff;
  font-size: 0.72rem; font-weight: 800; display: inline-grid; place-items: center;
}
code.invite {
  font-family: var(--mono); background: var(--sunken); border: 1px dashed var(--line-strong);
  padding: 0.4rem 0.7rem; border-radius: var(--r-s); font-size: 0.95rem; user-select: all;
}

/* ---------- Avatars ---------- */
.avatar {
  position: relative; flex: none; display: inline-grid; place-items: center; border-radius: 50%;
  color: #fff; font-weight: 800; overflow: visible; background: var(--sunken); user-select: none;
}
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.presence {
  position: absolute; right: -1px; bottom: -1px; width: 32%; height: 32%; min-width: 10px; min-height: 10px;
  border-radius: 50%; background: var(--line-strong); border: 2.5px solid var(--surface);
}
.presence.on { background: var(--online); }
.avatar-btn { background: none; border: 0; padding: 0; border-radius: 50%; }

/* =====================================================================
   Sign-in screen
   ===================================================================== */
.auth {
  height: 100%; overflow-y: auto;
  display: grid; grid-template-columns: 1.1fr 1fr; align-items: center;
  gap: 2rem; padding: 2rem clamp(1rem, 5vw, 5rem);
  background:
    radial-gradient(1200px 600px at -10% -20%, var(--accent-soft), transparent 60%),
    var(--paper);
}
.auth-art { max-width: 460px; justify-self: end; }
.auth-logo { width: 180px; height: 180px; margin-left: -12px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .auth-logo { filter: invert(1); } }
:root[data-theme='dark'] .auth-logo { filter: invert(1); }
.auth-art h1 { font-size: clamp(2.4rem, 5vw, 3.6rem); font-weight: 800; letter-spacing: -0.04em; margin: 0.25rem 0 0.75rem; }
.auth-art p { font-size: 1.1rem; color: var(--ink-2); max-width: 30ch; }
.auth-card {
  width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-l); padding: 2rem; box-shadow: var(--shadow);
}
.auth-card h2 { font-size: 1.45rem; margin: 1.25rem 0 1rem; }
.auth-switch { display: grid; grid-template-columns: 1fr 1fr; background: var(--sunken); border-radius: 999px; padding: 4px; }
.auth-switch button { border: 0; background: none; padding: 0.5rem; border-radius: 999px; font-weight: 700; color: var(--muted); }
.auth-switch button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.auth-form { display: flex; flex-direction: column; gap: 0.9rem; }

/* =====================================================================
   App layout: rail | sidebar | main | members
   ===================================================================== */
.app {
  height: 100%;
  display: grid;
  grid-template-columns: 76px 264px minmax(0, 1fr);
}
.app.with-members { grid-template-columns: 76px 264px minmax(0, 1fr) 248px; }
.app:not(.with-members) .members { display: none; }

/* ----- Rail ----- */
.rail {
  background: var(--rail); display: flex; flex-direction: column; align-items: center;
  padding: 0.75rem 0; overflow-y: auto; overflow-x: hidden; scrollbar-width: none;
}
.rail-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; align-items: center; gap: 0.5rem; width: 100%; }
.rail-item { position: relative; width: 100%; display: flex; justify-content: center; }
.rail-item::before {
  content: ''; position: absolute; left: 0; top: 50%; width: 4px; height: 0; border-radius: 0 4px 4px 0;
  background: var(--accent); transform: translateY(-50%); transition: height 0.15s;
}
.rail-item.active::before { height: 32px; }
.rail-item:hover:not(.active)::before { height: 14px; }
.rail-btn {
  position: relative; width: 50px; height: 50px; border-radius: 16px; display: grid; place-items: center;
  background: var(--rail-hover); color: var(--rail-ink); border: 0; transition: border-radius 0.15s, background 0.15s, color 0.15s;
  text-decoration: none !important;
}
.rail-btn:hover, .rail-btn.active { border-radius: 14px; color: #fff; }
.rail-btn.tool { background: transparent; border: 1.5px dashed #3c3d42; }
.rail-btn.tool:hover { border-style: solid; border-color: var(--accent); color: var(--accent); background: transparent; }
.rail-btn.tool.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.rail-logo { width: 40px; height: 40px; filter: invert(1); opacity: 0.85; }
.rail-btn.active .rail-logo, .rail-btn:hover .rail-logo { opacity: 1; }
.room-icon {
  --hue: 160;
  display: grid; place-items: center; border-radius: inherit; overflow: hidden; flex: none;
  background: hsl(var(--hue) 25% 32%); color: #fff; font-weight: 800; font-size: 1rem; letter-spacing: 0.02em;
}
.rail-btn .room-icon { border-radius: inherit; }
.room-icon img { width: 100%; height: 100%; object-fit: cover; }
.rail-badge {
  position: absolute; right: -4px; bottom: -4px; min-width: 20px; height: 20px; padding: 0 5px;
  background: var(--danger); color: #fff; border-radius: 999px; font-size: 0.7rem; font-weight: 800;
  display: grid; place-items: center; border: 3px solid var(--rail);
}
.rail-sep { width: 32px; height: 2px; background: #333438; border-radius: 2px; margin: 0.15rem 0; }
.rail-bottom { margin-top: auto; padding-top: 0.75rem; }
.rail-me { background: none; border: 0; padding: 0; border-radius: 50%; }
.rail-me .presence { border-color: var(--rail); }

/* ----- Sidebar ----- */
.sidebar { background: var(--surface-2); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.side-head {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  height: 60px; padding: 0 1rem; border-bottom: 1px solid var(--line); flex: none;
}
.side-head h2 { font-size: 1.05rem; font-weight: 800; }
.room-head { width: 100%; background: none; border: 0; border-bottom: 1px solid var(--line); text-align: left; color: var(--ink); }
.room-head:hover { background: var(--sunken); }
.room-head .icon { color: var(--muted); }
.side-scroll { flex: 1; overflow-y: auto; padding: 0.6rem 0.5rem; display: flex; flex-direction: column; gap: 2px; }
.side-label {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 0.7rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
  padding: 0.9rem 0.5rem 0.35rem;
}
.side-link {
  display: flex; align-items: center; gap: 0.6rem; padding: 0.48rem 0.6rem; border-radius: var(--r-s);
  color: var(--ink-2); font-weight: 600; text-decoration: none !important; border: 0; background: none; width: 100%; text-align: left;
}
.side-link .icon { color: var(--muted); }
.side-link:hover { background: var(--sunken); color: var(--ink); }
.side-link.active { background: var(--accent-soft); color: var(--accent-strong); }
.side-link.active .icon { color: var(--accent-strong); }
.side-link.unread { color: var(--ink); font-weight: 800; }
.side-link.person { padding: 0.38rem 0.6rem; }
.side-empty { color: var(--muted); font-size: 0.84rem; padding: 0.5rem; }
.channel-row { position: relative; display: flex; align-items: center; border-radius: var(--r-s); }
.channel-row.active .side-link { background: var(--accent-soft); color: var(--accent-strong); }
.channel-row.active .side-link .icon { color: var(--accent-strong); }
.channel-tools { position: absolute; right: 4px; display: none; gap: 0; background: inherit; }
.channel-row:hover .channel-tools, .channel-row:focus-within .channel-tools { display: flex; }
.channel-row:hover .pill { visibility: hidden; }
.invite-link { margin-top: 0.75rem; color: var(--accent); }
.invite-link .icon { color: var(--accent); }

.me-bar {
  display: flex; align-items: center; gap: 0.25rem; padding: 0.55rem 0.6rem; border-top: 1px solid var(--line);
  background: var(--surface-2); flex: none;
}
.me-card { flex: 1; min-width: 0; display: flex; align-items: center; gap: 0.6rem; background: none; border: 0; padding: 0.3rem; border-radius: var(--r-s); text-align: left; }
.me-card:hover { background: var(--sunken); }
.me-card b, .me-card small { display: block; line-height: 1.25; }

/* ----- Main area ----- */
.main { min-width: 0; min-height: 0; background: var(--surface); display: flex; flex-direction: column; }
.main-head {
  height: 60px; flex: none; display: flex; align-items: center; gap: 0.6rem; padding: 0 1rem;
  border-bottom: 1px solid var(--line); background: var(--surface);
}
.main-head h1 { font-size: 1.05rem; font-weight: 800; display: flex; align-items: center; gap: 0.35rem; white-space: nowrap; }
.main-head h1 .icon { color: var(--muted); }
.head-sub { font-size: 0.86rem; border-left: 1px solid var(--line); padding-left: 0.6rem; }
.head-person { display: flex; align-items: center; gap: 0.6rem; background: none; border: 0; padding: 0.25rem 0.5rem 0.25rem 0.25rem; border-radius: var(--r); min-width: 0; }
.head-person:hover { background: var(--surface-2); }
.tabs { display: flex; gap: 0.25rem; margin-left: 0.75rem; overflow-x: auto; scrollbar-width: none; }
.tab {
  display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.35rem 0.8rem; border-radius: 999px;
  color: var(--ink-2); font-weight: 700; font-size: 0.88rem; text-decoration: none !important; white-space: nowrap;
}
.tab:hover { background: var(--sunken); }
.tab.active { background: var(--ink); color: var(--surface); }
.tab.accent { color: var(--accent); }
.tab.accent.active { background: var(--accent); color: var(--accent-ink); }
.mobile-only { display: none; }

.page { display: flex; flex-direction: column; min-height: 0; height: 100%; }
.page-body { flex: 1; overflow-y: auto; padding: 1.25rem; }
.page-body.narrow { padding: 1.25rem max(1.25rem, calc((100% - 640px) / 2)); }
.list-label { font-size: 0.72rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 0.25rem 0 0.6rem; }
.empty { display: grid; place-items: center; gap: 0.75rem; text-align: center; color: var(--muted); padding: 3rem 1rem; }
.empty .icon { opacity: 0.5; }

/* People rows */
.people-list { display: flex; flex-direction: column; }
.person-row { display: flex; align-items: center; gap: 0.75rem; padding: 0.6rem 0.65rem; border-radius: var(--r); border-top: 1px solid var(--line); }
.person-row:first-child { border-top-color: transparent; }
.person-row.clickable { cursor: pointer; }
.person-row.clickable:hover { background: var(--surface-2); border-top-color: transparent; }
.person-row.clickable:hover + .person-row { border-top-color: transparent; }
.add-friend { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-l); padding: 1.25rem; margin-bottom: 1rem; display: flex; flex-direction: column; gap: 0.6rem; }

/* =====================================================================
   Chat
   ===================================================================== */
.chat { display: flex; flex-direction: column; height: 100%; min-height: 0; position: relative; }
.chat.dropping::after {
  content: 'Drop to attach'; position: absolute; inset: 70px 12px 12px; border: 2px dashed var(--accent);
  border-radius: var(--r-l); background: color-mix(in srgb, var(--accent-soft) 85%, transparent);
  display: grid; place-items: center; font-weight: 800; color: var(--accent-strong); font-size: 1.1rem; z-index: 3;
}
.messages-wrap { flex: 1; min-height: 0; display: flex; }
.messages { flex: 1; list-style: none; margin: 0; padding: 0.75rem 0 0.5rem; overflow-y: auto; }
.history-top { text-align: center; padding: 1rem; color: var(--muted); font-size: 0.85rem; }
.history-top.start { text-align: left; padding: 2rem 1.25rem 1rem; font-size: 0.95rem; color: var(--ink-2); font-weight: 600; }
.day-divider { display: flex; align-items: center; gap: 0.75rem; margin: 1rem 1.25rem 0.35rem; font-size: 0.72rem; font-weight: 800; color: var(--muted); letter-spacing: 0.04em; }
.day-divider::before, .day-divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.system-line { text-align: center; font-size: 0.8rem; color: var(--muted); padding: 0.3rem 1rem; }

.msg { position: relative; display: flex; gap: 0.85rem; padding: 0.4rem 1.25rem 0.15rem; margin-top: 0.45rem; }
.msg.grouped { margin-top: 0; padding-top: 0.08rem; }
.msg:hover { background: var(--surface-2); }
.msg-gutter-time { width: 40px; flex: none; font-size: 0.66rem; color: var(--muted); text-align: right; padding-top: 0.25rem; visibility: hidden; }
.msg:hover .msg-gutter-time { visibility: visible; }
.msg-body { flex: 1; min-width: 0; }
.msg-meta { display: flex; align-items: baseline; gap: 0.4rem; flex-wrap: wrap; }
.msg-meta .pronouns { margin-left: 0; }
.msg-author { background: none; border: 0; padding: 0; font-weight: 800; color: var(--ink); }
.msg-author:hover { text-decoration: underline; }
.msg-meta time { font-size: 0.72rem; color: var(--muted); }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink-2); }
.msg.mine .msg-text { color: var(--ink); }
.msg-actions {
  position: absolute; right: 1rem; top: -12px; display: none; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-s); box-shadow: var(--shadow); padding: 2px;
}
.msg:hover .msg-actions, .msg:focus-within .msg-actions { display: flex; }
.blocked-msg { padding-left: calc(1.25rem + 40px + 0.85rem); }
.msg-media { display: grid; gap: 6px; margin-top: 0.4rem; max-width: 420px; }
.msg-media.n2, .msg-media.n4 { grid-template-columns: 1fr 1fr; }
.msg-media.n3 { grid-template-columns: 1fr 1fr 1fr; }
.media { display: block; padding: 0; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--sunken); width: 100%; }
.media img { width: 100%; max-height: 360px; object-fit: cover; }
.msg-media.n1 .media img { object-fit: contain; max-height: 380px; width: auto; max-width: 100%; }
.msg-media.n1 .media { width: fit-content; max-width: 100%; }
video.media { max-height: 380px; }

.typing { height: 1.4rem; padding: 0 1.25rem; font-size: 0.78rem; color: var(--muted); font-weight: 600; }
.composer { padding: 0 1rem 1rem; }
.composer-row {
  display: flex; align-items: flex-end; gap: 0.35rem; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-l); padding: 0.35rem; transition: border-color 0.15s, box-shadow 0.15s;
}
.composer-row:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer textarea { border: 0; background: transparent; resize: none; padding: 0.45rem 0.25rem; max-height: 200px; box-shadow: none !important; outline: none; }
.send-btn { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; flex: none; }
.send-btn:hover { background: var(--accent-strong); }
.attach-tray { display: flex; gap: 0.5rem; flex-wrap: wrap; padding: 0 0 0.5rem; }
.attach-chip {
  display: flex; align-items: center; gap: 0.5rem; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r); padding: 0.3rem 0.3rem 0.3rem 0.3rem; max-width: 240px;
}
.attach-chip img, .chip-icon { width: 40px; height: 40px; border-radius: var(--r-s); object-fit: cover; display: grid; place-items: center; background: var(--sunken); flex: none; }
.attach-chip.uploading { opacity: 0.7; }
.chip-name { font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ----- Members panel ----- */
.members { background: var(--surface-2); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.members-head { height: 60px; flex: none; display: flex; align-items: center; justify-content: space-between; padding: 0 1rem; border-bottom: 1px solid var(--line); }
.members-head h2 { font-size: 1rem; font-weight: 800; }
.member { display: flex; align-items: center; gap: 0.6rem; width: 100%; padding: 0.38rem 0.5rem; border-radius: var(--r-s); background: none; border: 0; text-align: left; }
.member:hover { background: var(--sunken); }
.member.offline { opacity: 0.55; }

/* =====================================================================
   Posts
   ===================================================================== */
.post-composer { display: flex; gap: 0.85rem; padding: 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); margin-bottom: 1rem; box-shadow: var(--shadow); }
.post-composer textarea { border: 0; background: transparent; padding: 0.5rem 0; font-size: 1.05rem; resize: none; box-shadow: none !important; outline: none; }
.post-composer:focus-within { border-color: var(--accent); }
.post-tray { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.5rem; margin: 0.25rem 0 0.5rem; }
.post-tray:empty { display: none; }
.tray-item { position: relative; aspect-ratio: 1; border-radius: var(--r); overflow: hidden; background: var(--sunken); }
.tray-item img, .tray-item video { width: 100%; height: 100%; object-fit: cover; }
.tray-loading { display: grid; place-items: center; height: 100%; font-size: 0.75rem; color: var(--muted); }
.tray-x { position: absolute; top: 4px; right: 4px; background: rgb(0 0 0 / 0.6); color: #fff; }
.tray-x:hover { background: rgb(0 0 0 / 0.8); color: #fff; }
.feed { display: flex; flex-direction: column; }
.post { display: flex; align-items: flex-start; gap: 0.85rem; padding: 1rem 0.25rem; border-bottom: 1px solid var(--line); }
.msg { align-items: flex-start; }
.post-composer { align-items: flex-start; }
.post-body { flex: 1; min-width: 0; }
.post-meta { display: flex; align-items: baseline; gap: 0.35rem; flex-wrap: wrap; font-size: 0.9rem; }
.post-meta .pronouns { margin-left: 0; }
.post-author { font-weight: 800; color: var(--ink); }
.post-text { margin-top: 0.2rem; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 1rem; }
.post-media { display: grid; gap: 4px; margin-top: 0.6rem; border-radius: var(--r-l); overflow: hidden; }
.post-media.n2, .post-media.n4 { grid-template-columns: 1fr 1fr; }
.post-media.n3 { grid-template-columns: 2fr 1fr; grid-template-rows: 1fr 1fr; }
.post-media.n3 > :first-child { grid-row: span 2; }
.post-media .media { border-radius: 0; border: 0; height: 100%; }
.post-media .media img { height: 100%; max-height: 480px; }
.post-media.n1 .media img { max-height: 520px; object-fit: cover; }
.post-media.n2 .media img, .post-media.n4 .media img { aspect-ratio: 1; }
.post-actions { display: flex; gap: 1.25rem; margin-top: 0.5rem; }
.post-act { display: inline-flex; align-items: center; gap: 0.35rem; background: none; border: 0; padding: 0.3rem 0.4rem; margin-left: -0.4rem; border-radius: 999px; color: var(--muted); font-weight: 700; font-size: 0.85rem; }
.post-act:hover { background: var(--sunken); color: var(--ink); }
.post-act.like:hover, .post-act.like.on { color: #d6456a; }
.post-act.like.on .icon { fill: currentColor; }
.feed-more { display: grid; place-items: center; padding: 1.25rem; }

/* Profile page */
.profile-hero { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); overflow: hidden; margin-bottom: 1.25rem; box-shadow: var(--shadow); }
.hero-banner { height: 170px; }
.hero-row { display: flex; align-items: flex-end; justify-content: space-between; padding: 0 1.25rem; margin-top: -56px; }
.hero-row .avatar { border: 5px solid var(--surface); box-sizing: content-box; }
.hero-row .presence { border-width: 4px; }
.hero-info { padding: 0.75rem 1.25rem 1.25rem; display: flex; flex-direction: column; gap: 0.35rem; }
.hero-info h2 { font-size: 1.5rem; font-weight: 800; display: flex; align-items: center; gap: 0.5rem; }

/* =====================================================================
   Modals
   ===================================================================== */
#modal-root { position: relative; z-index: 50; }
.overlay {
  position: fixed; inset: 0; background: rgb(15 15 12 / 0.55); display: grid; place-items: center; padding: 16px;
  animation: fade 0.15s ease-out; backdrop-filter: blur(2px);
}
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(8px) scale(0.98); opacity: 0; } }
.modal {
  width: 100%; max-width: 480px; max-height: calc(100dvh - 32px); display: flex; flex-direction: column;
  background: var(--surface); border-radius: var(--r-l); box-shadow: var(--shadow-lg); animation: pop 0.18s ease-out; overflow: hidden;
}
.modal.small { max-width: 400px; }
.modal.wide { max-width: 820px; }
.modal.profile { max-width: 400px; }
.modal.lightbox { max-width: min(1100px, 100%); background: transparent; box-shadow: none; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1rem 0.5rem 1.25rem; }
.modal-head h2 { font-size: 1.2rem; font-weight: 800; }
.modal-body { padding: 0.5rem 1.25rem 1.25rem; overflow-y: auto; }
.modal.profile .modal-body, .modal.lightbox .modal-body { padding: 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 0.5rem; padding: 0.85rem 1.25rem; background: var(--surface-2); border-top: 1px solid var(--line); flex-wrap: wrap; }

.lightbox { position: relative; display: grid; place-items: center; }
.lightbox img, .lightbox video { max-width: 100%; max-height: calc(100dvh - 48px); border-radius: var(--r); }
.lightbox-close { position: absolute; top: 8px; right: 8px; background: rgb(0 0 0 / 0.6); color: #fff; }

/* Profile card */
.card-banner { height: 120px; }
.card-top { padding: 0 1.25rem; margin-top: -48px; }
.card-top .avatar { border: 5px solid var(--surface); box-sizing: content-box; }
.card-top .presence { border-width: 4px; }
.card-info { padding: 0.6rem 1.25rem 1.25rem; display: flex; flex-direction: column; gap: 0.35rem; }
.card-name { font-size: 1.3rem; font-weight: 800; display: flex; align-items: center; gap: 0.5rem; }
.card-handle { color: var(--muted); }
.card-bio { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); padding: 0.65rem 0.8rem; white-space: pre-wrap; margin-top: 0.35rem; }
.card-meta { font-size: 0.82rem; color: var(--muted); }
.card-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.6rem; }

/* Settings */
.settings { display: grid; grid-template-columns: 190px 1fr; gap: 1.25rem; min-height: 420px; }
.settings-nav { display: flex; flex-direction: column; gap: 2px; border-right: 1px solid var(--line); padding-right: 0.75rem; }
.settings-tab { text-align: left; background: none; border: 0; padding: 0.55rem 0.7rem; border-radius: var(--r-s); font-weight: 700; color: var(--ink-2); }
.settings-tab:hover { background: var(--sunken); }
.settings-tab.active { background: var(--accent-soft); color: var(--accent-strong); }
.settings-pane { min-width: 0; }
.profile-editor { position: relative; padding-bottom: 46px; }
.edit-banner { width: 100%; height: 130px; border: 0; border-radius: var(--r-l); position: relative; overflow: hidden; }
.edit-avatar { position: absolute; left: 1.25rem; bottom: 0; border: 5px solid var(--surface); border-radius: 50%; padding: 0; background: var(--surface); }
.edit-hint {
  position: absolute; right: 10px; bottom: 10px; display: inline-flex; align-items: center; gap: 0.35rem;
  background: rgb(0 0 0 / 0.6); color: #fff; padding: 0.3rem 0.6rem; border-radius: 999px; font-size: 0.78rem; font-weight: 700;
}
.edit-hint.round { right: 0; bottom: 0; padding: 0.35rem; }
.theme-picks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; }
.theme-pick { display: flex; flex-direction: column; gap: 0.5rem; align-items: center; padding: 0.75rem; border: 2px solid var(--line); border-radius: var(--r); cursor: pointer; font-weight: 700; }
.theme-pick:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.theme-pick input { position: absolute; opacity: 0; pointer-events: none; }
.swatch { width: 100%; height: 56px; border-radius: var(--r-s); border: 1px solid var(--line); }
.theme-pick.light .swatch { background: linear-gradient(90deg, #1f2023 18%, #faf9f5 18% 45%, #fff 45%); }
.theme-pick.dark .swatch { background: linear-gradient(90deg, #0b0c0d 18%, #1d1e22 18% 45%, #18191c 45%); }
.theme-pick.system .swatch { background: linear-gradient(135deg, #faf9f5 50%, #18191c 50%); }

/* Rooms */
.icon-picker {
  width: 76px; height: 76px; border-radius: 20px; border: 2px dashed var(--line-strong); background: var(--surface-2);
  display: grid; place-items: center; overflow: hidden; color: var(--muted); flex: none; padding: 0;
}
.icon-picker span { display: grid; place-items: center; gap: 2px; }
.icon-picker img { width: 100%; height: 100%; object-fit: cover; }
.icon-picker:hover { border-color: var(--accent); color: var(--accent); }
.discover-list { display: flex; flex-direction: column; gap: 0.25rem; max-height: 300px; overflow-y: auto; }
.discover-row { display: flex; align-items: center; gap: 0.75rem; padding: 0.5rem; border-radius: var(--r); }
.discover-row:hover { background: var(--surface-2); }
.discover-row .room-icon { border-radius: 14px; }

/* Toasts */
#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 0.5rem; align-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast { background: var(--ink); color: var(--surface); padding: 0.65rem 1rem; border-radius: 999px; font-weight: 700; font-size: 0.9rem; box-shadow: var(--shadow-lg); animation: pop 0.2s ease-out; transition: opacity 0.3s, transform 0.3s; text-align: center; }
.toast.error { background: var(--danger); color: #fff; }
.toast.ok { background: var(--accent); color: var(--accent-ink); }
.toast.out { opacity: 0; transform: translateY(6px); }

.scrim { display: none; }

/* Offline page */
.offline-page { grid-template-columns: 1fr; justify-items: center; text-align: center; }
.offline-page .auth-art { justify-self: center; }
.offline-page .auth-logo { margin: 0 auto; }
.offline-page .auth-art p { margin: 0 auto; }
.offline-actions { margin-top: 1.5rem !important; }

/* "Get the app" */
.app-option { display: flex; align-items: center; gap: 1rem; padding: 1rem; border: 1px solid var(--line); border-radius: var(--r-l); background: var(--surface-2); }
.app-option .os { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--sunken); color: var(--ink-2); flex: none; font-weight: 800; }
.app-option.current { border-color: var(--accent); background: var(--accent-soft); }
.auth-get-app { margin-top: 1rem; text-align: center; font-size: 0.85rem; }
.suspend-note { background: color-mix(in srgb, var(--owner) 14%, transparent); border: 1px solid color-mix(in srgb, var(--owner) 40%, transparent); border-radius: var(--r); padding: 0.55rem 0.75rem; font-size: 0.88rem; margin-top: 0.4rem; }
.suspend-lengths { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.update-banner {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 90;
  display: flex; align-items: center; gap: 0.75rem; width: max-content; max-width: calc(100vw - 32px);
  background: var(--ink); color: var(--surface); padding: 0.6rem 0.7rem 0.6rem 1rem; border-radius: 999px; box-shadow: var(--shadow-lg); font-weight: 700; font-size: 0.9rem;
}

/* =====================================================================
   Tellurium Mail
   ===================================================================== */
.compose-btn { margin: 0.25rem 0 0.4rem; }
.mail-address { font-family: var(--mono); font-size: 0.78rem; color: var(--muted); padding: 0 0.5rem 0.6rem; overflow-wrap: anywhere; }
.mail-search { max-width: 260px; padding: 0.42rem 0.7rem !important; }
.page-body.mail-body { padding: 0; }
.mail-list { display: flex; flex-direction: column; }
.mail-row {
  display: grid; grid-template-columns: auto minmax(120px, 200px) minmax(0, 1fr) auto; align-items: center; gap: 0.75rem;
  padding: 0.55rem 1rem 0.55rem 0.6rem; border-bottom: 1px solid var(--line); color: var(--ink-2); text-decoration: none !important;
}
.mail-row:hover { background: var(--surface-2); }
.mail-row.unread { color: var(--ink); background: color-mix(in srgb, var(--accent-soft) 35%, var(--surface)); }
.mail-row.unread .mail-from, .mail-row.unread .mail-subj b { font-weight: 800; }
.mail-row .mail-subj b { font-weight: 600; }
.mail-meta { display: flex; align-items: center; gap: 0.5rem; color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.star { color: var(--line-strong); }
.star.on { color: var(--owner); }
.star.on .icon { fill: currentColor; }
.mail-read { max-width: 980px; display: flex; flex-direction: column; gap: 0.8rem; }
.mail-headers { display: flex; gap: 0.75rem; align-items: flex-start; }
.mail-tools { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.mail-frame-wrap { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: #fff; }
.mail-frame { display: block; width: 100%; height: min(58vh, 720px); min-height: 260px; border: 0; background: #fff; resize: vertical; }
.mail-frame-wrap.plain { background: var(--surface); }
.mail-plain { padding: 1rem 1.1rem; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; color: var(--ink); }
.mail-images-bar { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; padding: 0.55rem 0.8rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); font-size: 0.86rem; color: var(--ink-2); }
.mail-file-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0.5rem; }
.mail-file { display: flex; align-items: center; gap: 0.6rem; padding: 0.45rem; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); min-width: 0; }
.mail-file-thumb { width: 52px; height: 52px; flex: none; border-radius: var(--r-s); overflow: hidden; display: grid; place-items: center; background: var(--sunken); border: 0; padding: 0; color: var(--muted); }
.mail-file-thumb img { width: 100%; height: 100%; object-fit: cover; }
.modal.compose { max-width: 760px; }
.compose-from { padding-bottom: 0.25rem; }
.mail-compose-text { min-height: 240px; font-size: 0.95rem; }
.mail-apply, .feature-apply { max-width: 640px; display: flex; flex-direction: column; gap: 1.1rem; margin: 0 auto; }
.mail-hero, .feature-hero { display: flex; flex-direction: column; gap: 0.6rem; }
.mail-hero h2, .feature-hero h2 { font-size: 1.5rem; font-weight: 800; }
.feature-apply { padding: 1.5rem 1.25rem 2rem; }
.modal .feature-apply { padding: 0; }
.ad-like-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); padding: 1.1rem 1.2rem; display: flex; flex-direction: column; gap: 0.7rem; box-shadow: var(--shadow); }
.ad-like-card h3 { font-size: 1.05rem; font-weight: 800; }
.ad-like-card.warn { border-color: color-mix(in srgb, var(--owner) 50%, transparent); }
.prefix-input.suffix input { border-radius: var(--r-s) 0 0 var(--r-s); }
.prefix-input.suffix > span { border-radius: 0 var(--r-s) var(--r-s) 0; border: 1px solid var(--line); border-left: 0; }
@media (max-width: 800px) {
  .mail-row { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: 'star from meta' 'star subj subj'; row-gap: 0.1rem; }
  .mail-row .star { grid-area: star; }
  .mail-row .mail-from { grid-area: from; }
  .mail-row .mail-subj { grid-area: subj; }
  .mail-row .mail-meta { grid-area: meta; }
  .mail-search { max-width: 140px; }
}
.steps { margin: 0; padding-left: 1.1rem; display: flex; flex-direction: column; gap: 0.35rem; }

/* =====================================================================
   Smaller screens
   ===================================================================== */
@media (max-width: 1100px) {
  .app.with-members { grid-template-columns: 76px 248px minmax(0, 1fr); }
  .app.with-members .members {
    position: fixed; right: 0; top: 0; bottom: 0; width: 270px; z-index: 30;
    transform: translateX(100%); transition: transform 0.2s; box-shadow: var(--shadow-lg);
  }
  body.members-open .app.with-members .members { transform: none; }
  body.members-open .scrim { display: block; }
  .members .mobile-only { display: inline-grid; }
}
@media (max-width: 800px) {
  .app, .app.with-members { grid-template-columns: minmax(0, 1fr); }
  .rail, .sidebar { position: fixed; top: 0; bottom: 0; z-index: 30; transition: transform 0.2s; }
  .rail { left: 0; width: 76px; transform: translateX(-340px); }
  .sidebar { left: 76px; width: min(264px, calc(100vw - 76px - 24px)); transform: translateX(-340px); box-shadow: var(--shadow-lg); }
  body.drawer-open .rail, body.drawer-open .sidebar { transform: none; }
  body.drawer-open .scrim { display: block; }
  .mobile-only { display: inline-grid; }
  .main-head { padding: 0 0.5rem; gap: 0.35rem; }
  .head-sub { display: none; }
  .tabs { margin-left: 0.25rem; }
  .msg { padding-left: 0.75rem; padding-right: 0.75rem; }
  .composer { padding: 0 0.5rem 0.5rem; }
  .page-body, .page-body.narrow { padding: 1rem; }
  .auth { grid-template-columns: 1fr; justify-items: center; padding: 1.5rem 16px; gap: 1rem; }
  .auth-art { justify-self: center; text-align: center; }
  .auth-logo { width: 110px; height: 110px; margin: 0 auto; }
  .auth-art h1 { margin-top: 0; }
  .auth-art p { margin: 0 auto; }
  .auth-card { padding: 1.5rem; }
  .settings { grid-template-columns: 1fr; min-height: 0; }
  .settings-nav { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 0 0 0.5rem; }
  .settings-tab { white-space: nowrap; }
  .grid-2 { grid-template-columns: 1fr; }
  .hero-banner { height: 120px; }
}
.scrim { position: fixed; inset: 0; background: rgb(0 0 0 / 0.45); z-index: 20; }
@media (min-width: 1101px) { .scrim { display: none !important; } }

/* ---------- Settings > Security ---------- */
.security-status { display: flex; gap: 0.7rem; align-items: flex-start; padding: 0.8rem 0.9rem; border-radius: var(--r); border: 1px solid var(--line); }
.security-status.on { background: var(--accent-soft); border-color: transparent; color: var(--ink); }
.security-status.on > svg { color: var(--accent-strong); flex: none; margin-top: 2px; }
.security-status.off { background: var(--danger-soft); border-color: transparent; }
.security-status.off > svg { color: var(--danger); flex: none; margin-top: 2px; }
.here-tag { margin-left: 0.45rem; font-size: 0.7rem; font-weight: 800; background: var(--accent-soft); color: var(--accent-strong); padding: 0.05rem 0.45rem; border-radius: 999px; vertical-align: 1px; }
.device-icon { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--sunken); color: var(--ink-2); flex: none; }
.security-events { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.security-event { display: flex; justify-content: space-between; gap: 1rem; padding: 0.55rem 0.8rem; font-size: 0.88rem; border-top: 1px solid var(--line); }
.security-event:first-child { border-top: 0; }
.security-event.warn { box-shadow: inset 3px 0 0 var(--danger); }
.backup-codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.4rem; background: var(--sunken); border-radius: var(--r); padding: 0.8rem; }
.backup-codes code { font-family: var(--mono); font-size: 1rem; text-align: center; padding: 0.3rem; user-select: all; }
.qr-box { display: grid; place-items: center; }
.qr-box img { background: #fff; padding: 10px; border-radius: var(--r); width: 200px; height: 200px; }
.secret-key { display: block; margin-top: 0.4rem; font-family: var(--mono); font-size: 0.95rem; background: var(--sunken); padding: 0.5rem 0.7rem; border-radius: var(--r-s); user-select: all; word-break: break-all; }
.steps { margin: 0; padding-left: 1.3rem; display: flex; flex-direction: column; gap: 0.35rem; }
.row.wrap { flex-wrap: wrap; }

/* ---------- Report dialog ---------- */
.report-reasons { display: flex; flex-direction: column; gap: 0.15rem; }
.report-reason { padding: 0.45rem 0.6rem; border-radius: var(--r-s); align-items: flex-start; }
.report-reason:hover { background: var(--surface-2); }
.report-reason.urgent b { color: var(--danger); }
.msg-actions { gap: 0.15rem; }

/* ---------- Drive ---------- */
.drive-wrap, .clips-wrap { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.drive { flex: 1; overflow-y: auto; min-height: 0; }
.drive-body { padding: 1rem 1.25rem 2rem; min-height: 100%; border: 2px dashed transparent; border-radius: var(--r); transition: border-color 0.15s, background 0.15s; }
.drive-body.dragging { border-color: var(--accent); background: var(--accent-soft); }
.drive-search { max-width: 260px; }
.crumbs { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; font-weight: 700; margin-bottom: 0.75rem; }
.crumbs a { color: var(--ink-2); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.drive-tools { margin-bottom: 0.75rem; }
.drive-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.drive-item { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 0.75rem; padding: 0.35rem 0.6rem; border-top: 1px solid var(--line); }
.drive-item:first-child { border-top: 0; }
.drive-item:hover { background: var(--surface-2); }
.drive-open { display: flex; align-items: center; gap: 0.7rem; min-width: 0; background: none; border: 0; padding: 0.25rem; color: inherit; text-decoration: none; text-align: left; font: inherit; cursor: pointer; }
.drive-icon { width: 40px; height: 40px; border-radius: var(--r-s); display: grid; place-items: center; background: var(--sunken); color: var(--ink-2); flex: none; overflow: hidden; }
.drive-item.folder .drive-icon { background: var(--accent-soft); color: var(--accent-strong); }
.drive-icon.thumb img { width: 100%; height: 100%; object-fit: cover; }
.drive-name { font-weight: 600; }
.drive-shared, .drive-flag { color: var(--muted); display: inline-flex; flex: none; }
.drive-flag { color: var(--owner); }
.drive-actions { display: flex; gap: 0.1rem; opacity: 0.55; }
.drive-item:hover .drive-actions, .drive-item:focus-within .drive-actions { opacity: 1; }
.drive-empty { display: flex; flex-direction: column; align-items: center; gap: 0.4rem; padding: 3rem 1rem; color: var(--muted); text-align: center; }
.drive-empty p { margin: 0; }
.drive-uploads { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 0.75rem; }
.drive-upload { display: flex; align-items: center; gap: 0.6rem; padding: 0.45rem 0.7rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-s); font-size: 0.88rem; }
.drive-upload.failed { border-color: var(--danger); color: var(--danger); }
.drive-usage { display: flex; flex-direction: column; gap: 0.25rem; padding: 0.9rem 0.6rem 0.3rem; }
.meter { height: 8px; border-radius: 999px; background: var(--sunken); overflow: hidden; flex: none; }
.meter.small { width: 120px; height: 6px; }
.meter > span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width 0.2s; }
.meter > span.full { background: var(--danger); }
.pad-s { padding: 0.6rem 0.4rem; }
.btn.block { width: 100%; justify-content: center; }
@media (max-width: 640px) {
  .drive-item { grid-template-columns: minmax(0, 1fr) auto; }
  .drive-meta { display: none; }
  .drive-actions { opacity: 1; }
  .drive-search { max-width: 140px; }
}

/* ---------- Clips ---------- */
.clip-feed { flex: 1; min-height: 0; overflow-y: auto; scroll-snap-type: y mandatory; background: #0b0c0d; outline: none; scrollbar-width: none; }
.clip-feed::-webkit-scrollbar { display: none; }
.clip { height: 100%; scroll-snap-align: start; scroll-snap-stop: always; display: grid; place-items: center; padding: 0.75rem 0; }
.clip-stage { position: relative; height: 100%; aspect-ratio: 9 / 16; max-width: 100%; background: #000; border-radius: var(--r-l); overflow: hidden; }
.clip-stage video { width: 100%; height: 100%; object-fit: contain; display: block; cursor: pointer; }
.clip-play { position: absolute; inset: 0; display: grid; place-items: center; color: rgb(255 255 255 / 0.85); pointer-events: none; }
.clip-info { position: absolute; left: 0; right: 64px; bottom: 0; padding: 2.5rem 0.9rem 0.9rem; color: #fff; background: linear-gradient(transparent, rgb(0 0 0 / 0.7)); }
.clip-info .muted { color: rgb(255 255 255 / 0.7); }
.clip-author { display: flex; align-items: center; gap: 0.5rem; background: none; border: 0; color: #fff; padding: 0; font: inherit; cursor: pointer; }
.clip-caption { margin: 0.45rem 0 0.2rem; font-size: 0.92rem; word-break: break-word; max-height: 5.5em; overflow-y: auto; }
.clip-caption a { color: #9fe3cf; }
.clip-views { color: rgb(255 255 255 / 0.65); }
.clip-side { position: absolute; right: 8px; bottom: 1rem; display: flex; flex-direction: column; gap: 0.6rem; align-items: center; }
.clip-btn { width: 48px; display: flex; flex-direction: column; align-items: center; gap: 2px; background: none; border: 0; color: #fff; cursor: pointer; padding: 0; filter: drop-shadow(0 1px 3px rgb(0 0 0 / 0.6)); }
.clip-btn svg { width: 46px; height: 46px; padding: 11px; border-radius: 50%; background: rgb(255 255 255 / 0.14); }
.clip-btn:hover svg { background: rgb(255 255 255 / 0.25); }
.clip-btn.on svg { color: #ff5a6e; fill: currentColor; }
.clip-btn small { font-size: 0.75rem; font-weight: 700; min-height: 1em; }
.clip-comments { display: flex; flex-direction: column; gap: 0.65rem; max-height: 50vh; overflow-y: auto; }
.clip-comment { display: flex; gap: 0.6rem; align-items: flex-start; }
.clip-new { display: flex; gap: 1rem; align-items: flex-start; }
.clip-preview { width: 150px; aspect-ratio: 9 / 16; object-fit: cover; background: #000; border-radius: var(--r); flex: none; }
@media (max-width: 640px) {
  .clip { padding: 0; }
  .clip-stage { border-radius: 0; aspect-ratio: auto; width: 100%; }
  .clip-new { flex-direction: column; }
  .clip-preview { width: 100%; max-height: 40vh; }
}

/* ---------- Calls ---------- */
.call-panel { position: fixed; right: 20px; bottom: 20px; z-index: 900; width: 340px; background: #111214; color: #fff; border-radius: var(--r-l); box-shadow: var(--shadow-lg); overflow: hidden; display: flex; flex-direction: column; touch-action: none; user-select: none; }
.call-panel.video { width: 480px; }
.call-panel.full { inset: 0; width: auto; border-radius: 0; }
.call-stage { position: relative; height: 220px; background: radial-gradient(circle at 50% 35%, #24443c, #111214 70%); display: grid; place-items: center; cursor: grab; }
.call-panel.video .call-stage { height: 270px; }
.call-panel.full .call-stage { height: auto; flex: 1; cursor: default; }
.call-remote { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; display: none; }
.call-panel.video .call-remote { display: block; }
.call-face { display: flex; flex-direction: column; align-items: center; gap: 0.6rem; z-index: 1; }
.call-face .avatar { box-shadow: 0 0 0 6px rgb(255 255 255 / 0.08); }
.call-local { position: absolute; right: 10px; bottom: 10px; width: 108px; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--r-s); background: #000; border: 2px solid rgb(255 255 255 / 0.25); transform: scaleX(-1); z-index: 2; }
.call-panel.full .call-local { width: 200px; }
.call-status { position: absolute; left: 0; right: 0; top: 10px; text-align: center; font-size: 0.85rem; font-weight: 700; color: rgb(255 255 255 / 0.85); text-shadow: 0 1px 3px #000; z-index: 2; }
.call-controls { display: flex; justify-content: center; gap: 0.6rem; padding: 0.75rem; background: #18191c; }
.call-btn { width: 46px; height: 46px; border-radius: 50%; border: 0; display: grid; place-items: center; background: #2c2d31; color: #fff; cursor: pointer; }
.call-btn:hover { background: #3a3b40; }
.call-btn.off { background: #e8e8e3; color: #1a1b1e; }
.call-btn.on { background: var(--accent); color: var(--accent-ink); }
.call-btn.ok { background: #2f9a6a; }
.call-btn.danger { background: #d9463b; }
.call-btn.danger:hover { background: #c23a30; }
@media (max-width: 640px) {
  .call-panel, .call-panel.video { left: 8px; right: 8px; bottom: 8px; width: auto; }
}

/* ---------- Feature applications ---------- */
.feature-note { display: flex; align-items: center; gap: 0.6rem; padding: 0.6rem 0.8rem; margin-bottom: 0.75rem; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--line); font-size: 0.9rem; }
.feature-note > svg { color: var(--muted); flex: none; }
