/* ============================================================
   StreamCampus — Design System
   Dark-first, warm campus palette (amber × crimson × violet)
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

:root {
  --font: "Plus Jakarta Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Code", "SF Mono", Consolas, monospace;

  /* Shape — a single scale keeps every corner in the product harmonised. */
  --r-xs: 8px; --r-sm: 10px; --r-md: 14px; --r-lg: 20px; --r-xl: 28px; --r-full: 999px;

  /* Brand */
  --accent: #F59E0B;
  --accent-2: #E5484D;
  --violet: #7C3AED;
  --teal: #14B8A6;

  /* Semantic */
  --ok: #30A46C; --warn: #F59E0B; --danger: #E5484D;
  --ok-soft: rgba(48,164,108,.14);
  --warn-soft: rgba(245,158,11,.14);
  --danger-soft: rgba(229,72,77,.14);
  --info-soft: rgba(124,58,237,.14);

  --grad-brand: linear-gradient(135deg, #F59E0B 0%, #E5484D 100%);
  --grad-brand-soft: linear-gradient(135deg, rgba(245,158,11,.16), rgba(229,72,77,.16));
  --grad-violet: linear-gradient(135deg, #7C3AED, #DB2777);
  --grad-teal: linear-gradient(135deg, #0E7490, #14B8A6);
  --grad-sheen: linear-gradient(180deg, rgba(255,255,255,.06), transparent);

  --shadow-1: 0 1px 2px rgba(0,0,0,.25);
  --shadow-2: 0 8px 28px -6px rgba(0,0,0,.35);
  --shadow-3: 0 24px 70px -12px rgba(0,0,0,.5);
  --glow-brand: 0 8px 32px -10px rgba(245,158,11,.55);
  --ring: 0 0 0 3px rgba(245,158,11,.42);
  --ring-danger: 0 0 0 3px rgba(229,72,77,.42);

  /* Fluid type — scales with the viewport instead of stepping at breakpoints. */
  --fs-xs: clamp(11px, 0.68rem + 0.1vw, 12px);
  --fs-sm: clamp(12.5px, 0.76rem + 0.12vw, 13.5px);
  --fs-base: clamp(14px, 0.85rem + 0.16vw, 15px);
  --fs-md: clamp(15.5px, 0.93rem + 0.2vw, 17px);
  --fs-lg: clamp(18px, 1.05rem + 0.35vw, 21px);
  --fs-xl: clamp(22px, 1.2rem + 0.7vw, 28px);
  --fs-2xl: clamp(28px, 1.4rem + 1.6vw, 44px);

  /* Spacing scale */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 22px; --s-6: 30px; --s-7: 44px;

  /* Minimum comfortable touch target (WCAG 2.5.5 / Apple HIG). */
  --tap: 44px;

  --nav-w: 256px; --rail-w: 336px; --main-w: 620px;
  --header-h: 60px;

  --ease: cubic-bezier(.22,.61,.36,1);
  --dur-fast: 120ms; --dur: 200ms; --dur-slow: 340ms;
}

html[data-theme="dark"] {
  --bg: #0A0C11;
  --bg-soft: #0F1218;
  --surface: #131720;
  --surface-2: #1A1F2A;
  --surface-3: #232936;
  --line: rgba(255,255,255,.08);
  --line-strong: rgba(255,255,255,.16);
  --text: #F4F6FA;
  --text-2: #A9B2C1;
  --text-3: #7F899B;
  --shadow-1: 0 1px 2px rgba(0,0,0,.3);
  --shadow-2: 0 10px 30px -8px rgba(0,0,0,.55);
  --shadow-3: 0 30px 80px -12px rgba(0,0,0,.65);
  --hover: rgba(255,255,255,.045);
  --scrim: rgba(6,8,12,.72);
  --glass: rgba(19,23,32,.78);
  color-scheme: dark;
}

html[data-theme="light"] {
  --bg: #F6F7F9;
  --bg-soft: #EFF1F4;
  --surface: #FFFFFF;
  --surface-2: #F1F3F7;
  --surface-3: #E6EAF1;
  --line: rgba(15,23,42,.10);
  --line-strong: rgba(15,23,42,.18);
  --text: #0E1626;
  --text-2: #566072;
  --text-3: #8B95A6;
  --shadow-1: 0 1px 2px rgba(16,24,40,.06);
  --shadow-2: 0 10px 30px -8px rgba(16,24,40,.14);
  --shadow-3: 0 30px 80px -12px rgba(16,24,40,.22);
  --hover: rgba(15,23,42,.04);
  --scrim: rgba(15,23,42,.42);
  --glass: rgba(255,255,255,.82);
  color-scheme: light;
}

html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background .25s ease, color .25s ease;
}

img, video { max-width: 100%; display: block; }

/* The `hidden` attribute must always win. Several components below set an explicit
   `display`, which otherwise overrides the user-agent `[hidden] { display: none }`
   at equal specificity — leaving "hidden" overlays visible on screen. */
[hidden] { display: none !important; }

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
::selection { background: rgba(245,158,11,.35); }

h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -0.015em; }
p { margin: 0; }

:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 8px; }
*::-webkit-scrollbar-track { background: transparent; }

/* ───────────────────────── boot screen ───────────────────── */
.boot-screen {
  min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px;
  background: radial-gradient(1200px 600px at 50% -10%, rgba(245,158,11,.14), transparent 60%), var(--bg);
}
.boot-logo { text-align: center; display: grid; gap: 8px; justify-items: center; }
.boot-logo h1 { font-size: 30px; font-weight: 800; letter-spacing: -0.03em; }
.boot-logo p { color: var(--text-2); }
.boot-dots { display: flex; gap: 8px; }
.boot-dots span { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); animation: bootpulse 1.2s infinite ease-in-out; }
.boot-dots span:nth-child(2) { animation-delay: .15s; background: var(--accent-2); }
.boot-dots span:nth-child(3) { animation-delay: .3s; background: var(--violet); }
@keyframes bootpulse { 0%, 80%, 100% { transform: scale(.6); opacity: .4; } 40% { transform: scale(1); opacity: 1; } }

/* ───────────────────────── layout shell ──────────────────── */
.app-root { min-height: 100dvh; }

.app-shell {
  display: grid;
  grid-template-columns: var(--nav-w) minmax(0, var(--main-w)) var(--rail-w);
  justify-content: center;
  gap: 28px;
  padding: 0 20px;
  max-width: 1440px;
  margin: 0 auto;
}

.app-shell.wide { grid-template-columns: var(--nav-w) minmax(0, 1fr); }
.app-shell.wide .main-col { max-width: none; }

/* Messaging routes get the leftover width instead of being capped at --main-w, so the
   conversation pane is readable rather than wrapping every few words. */
.app-shell.chat-wide {
  grid-template-columns: var(--nav-w) minmax(0, 1fr) minmax(0, var(--rail-w));
  max-width: 1680px;
}
.app-shell.chat-wide .main-col { max-width: none; }
.app-shell.chat-wide .rail { max-width: var(--rail-w); }

.main-col { padding: 24px 0 90px; min-height: 100dvh; min-width: 0; }
.rail-col { padding: 24px 0 90px; min-width: 0; }

/* top header (mobile) */
.mobile-header {
  display: none;
  position: sticky; top: 0; z-index: 60;
  height: var(--header-h);
  align-items: center; gap: 12px; padding: 0 16px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

/* ───────────────────────── sidebar nav ───────────────────── */
.side-nav {
  position: sticky; top: 0; height: 100dvh;
  display: flex; flex-direction: column; gap: 6px;
  padding: 20px 8px 16px;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 6px 12px 18px; }
.brand-badge { width: 38px; height: 38px; border-radius: 12px; background: var(--grad-brand); display: grid; place-items: center; flex: none; box-shadow: var(--shadow-2); }
.brand-badge svg { width: 20px; height: 20px; fill: #fff; }
.brand-name { font-size: 19px; font-weight: 800; letter-spacing: -0.03em; }
.brand-name em { font-style: normal; color: var(--accent); }

.nav-item {
  display: flex; align-items: center; gap: 14px;
  padding: 11px 14px; border-radius: var(--r-md);
  color: var(--text-2); font-weight: 600; font-size: 15px;
  transition: background .15s ease, color .15s ease, transform .05s ease;
  position: relative;
}
.nav-item svg { width: 22px; height: 22px; flex: none; }
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item:active { transform: scale(.98); }
.nav-item.active { color: var(--text); background: var(--surface-2); }
.nav-item.active::before {
  content: ""; position: absolute; left: -8px; top: 50%; translate: 0 -50%;
  width: 4px; height: 22px; border-radius: 4px; background: var(--grad-brand);
}
.nav-item .badge {
  margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-full);
  background: var(--accent-2); color: #fff; font-size: 11px; font-weight: 800;
  display: grid; place-items: center;
}
.nav-create {
  margin: 8px 12px 4px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 13px; border-radius: var(--r-md);
  background: var(--grad-brand); color: #fff; font-weight: 800; font-size: 15px;
  box-shadow: var(--shadow-2); transition: transform .12s ease, filter .15s ease;
}
.nav-create:hover { filter: brightness(1.08); }
.nav-create:active { transform: scale(.98); }
.nav-create svg { width: 20px; height: 20px; }

.nav-spacer { flex: 1; }
.nav-user {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  border-radius: var(--r-md); transition: background .15s ease;
}
.nav-user:hover { background: var(--hover); }
.nav-user .nu-name { font-weight: 700; font-size: 14px; }
.nav-user .nu-handle { font-size: 12px; color: var(--text-3); }
.nav-user .nu-more { margin-left: auto; color: var(--text-3); }

/* icon rail (tablet) */
.app-shell.rail { grid-template-columns: 84px minmax(0, var(--main-w)) var(--rail-w); }
.app-shell.rail .side-nav { padding: 20px 10px 16px; align-items: center; }
.app-shell.rail .brand-name, .app-shell.rail .nav-item span, .app-shell.rail .nav-create span, .app-shell.rail .nav-user .nu-meta { display: none; }
.app-shell.rail .nav-item { justify-content: center; padding: 13px; }
.app-shell.rail .nav-create { padding: 13px; margin: 8px 0 4px; }
.app-shell.rail .brand { padding: 6px 0 18px; justify-content: center; }
.app-shell.rail .nav-user { justify-content: center; padding: 10px 6px; }

/* ───────────────────────── right rail ────────────────────── */
.rail { display: grid; gap: 16px; align-content: start; position: sticky; top: 0; max-height: 100dvh; overflow-y: auto; padding-bottom: 90px; }
.rail-card {
  background: color-mix(in srgb, var(--surface) 80%, transparent); backdrop-filter: blur(12px);
  border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 18px; box-shadow: var(--shadow-1);
}
.rail-card h3 { font-size: 16px; font-weight: 800; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.rail-card h3 svg { width: 18px; height: 18px; color: var(--accent); }

.trend-row { display: flex; align-items: baseline; gap: 8px; padding: 7px 10px; margin: 0 -10px; border-radius: 10px; cursor: pointer; transition: background .12s; }
.trend-row:hover { background: var(--hover); }
.trend-row .tr-tag { font-weight: 700; color: var(--accent); }
.trend-row .tr-count { margin-left: auto; font-size: 12px; color: var(--text-3); }

.sugg-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.sugg-row .sr-name { font-weight: 700; font-size: 14px; }
.sugg-row .sr-reason { font-size: 12px; color: var(--text-3); }
.sugg-row .btn-follow { margin-left: auto; }

.ad-card { padding: 0; overflow: hidden; cursor: pointer; }
.ad-card img { width: 100%; aspect-ratio: 3/2; object-fit: cover; }
.ad-meta { display: flex; align-items: center; gap: 8px; padding: 12px 14px 14px; }
.ad-sponsor { font-size: 12px; font-weight: 700; color: var(--text-2); }
.ad-flag { margin-left: auto; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); border: 1px solid var(--line); padding: 2px 8px; border-radius: var(--r-full); }

.usage-card .usage-bar { height: 8px; border-radius: 8px; background: var(--surface-3); overflow: hidden; margin: 10px 0 8px; }
.usage-card .usage-bar i { display: block; height: 100%; border-radius: 8px; background: var(--grad-brand); transition: width .6s ease; }
.usage-note { font-size: 12px; color: var(--text-3); }

.live-mini { display: flex; gap: 12px; align-items: center; padding: 8px 0; cursor: pointer; }
.live-mini img { width: 92px; aspect-ratio: 16/10; object-fit: cover; border-radius: 10px; background: var(--surface-3); }
.live-mini .lm-title { font-weight: 700; font-size: 13.5px; }
.live-mini .lm-host { font-size: 12px; color: var(--text-3); }

/* ───────────────────────── avatars ───────────────────────── */
.avatar {
  border-radius: 50%; background: var(--grad-violet); color: #fff;
  display: grid; place-items: center; font-weight: 800; flex: none;
  overflow: hidden; position: relative; user-select: none;
}
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar[data-size="32"] { width: 32px; height: 32px; font-size: 12px; }
.avatar[data-size="40"] { width: 40px; height: 40px; font-size: 14px; }
.avatar[data-size="44"] { width: 44px; height: 44px; font-size: 15px; }
.avatar[data-size="52"] { width: 52px; height: 52px; font-size: 18px; }
.avatar[data-size="88"] { width: 88px; height: 88px; font-size: 30px; }

/* ───────────────────────── buttons ───────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 18px; border-radius: var(--r-full);
  font-weight: 700; font-size: 14px; line-height: 1.2;
  border: 1px solid transparent;
  transition: filter .15s ease, background .15s ease, transform .08s ease, opacity .15s;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg { width: 17px; height: 17px; }

.btn-primary { background: var(--grad-brand); color: #fff; box-shadow: var(--shadow-2); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-violet { background: var(--grad-violet); color: #fff; }
.btn-ghost { background: var(--surface-2); color: var(--text); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-soft { background: rgba(229,72,77,.14); color: var(--danger); }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-follow.is-following { background: var(--surface-2); color: var(--text-2); border-color: var(--line-strong); box-shadow: none; }

.icon-btn {
  display: grid; place-items: center; width: 38px; height: 38px;
  border-radius: 50%; color: var(--text-2); transition: background .15s, color .15s, transform .08s;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn:active { transform: scale(.92); }
.icon-btn svg { width: 20px; height: 20px; }

/* ───────────────────────── composer + post card ──────────── */
.card {
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-1);
  transition: box-shadow .25s ease, border-color .25s ease;
}

.composer { padding: 16px 18px; display: grid; gap: 12px; }
.composer-row { display: flex; gap: 12px; min-width: 0; }
.composer-row > * { min-width: 0; }
.composer-input {
  flex: 1; background: none; border: 0; resize: none; outline: none;
  font-size: 16px; padding: 9px 4px; min-height: 26px; max-height: 200px;
  color: var(--text); min-width: 0;
}
.composer-input::placeholder { color: var(--text-3); }
.composer-tools { display: flex; align-items: center; gap: 4px; padding-left: 56px; }
.composer-tools .icon-btn { width: 36px; height: 36px; }
.composer-tools .icon-btn.active { color: var(--accent); background: rgba(245,158,11,.12); }
.composer-tools .grow { flex: 1; }
.composer-preview { position: relative; border-radius: var(--r-md); overflow: hidden; background: var(--surface-3); }
.composer-preview img, .composer-preview video { width: 100%; max-height: 320px; object-fit: cover; }
.composer-preview .pv-x { position: absolute; top: 10px; right: 10px; background: rgba(0,0,0,.6); color: #fff; border-radius: 50%; width: 32px; height: 32px; display: grid; place-items: center; }
.composer-course { display: flex; align-items: center; gap: 8px; padding: 0 4px; color: var(--text-2); font-size: 13px; flex-wrap: wrap; min-width: 0; }
.composer-course select { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-full); padding: 5px 10px; color: var(--text); outline: none; max-width: 100%; min-width: 0; flex: 1; }

.post-card { overflow: hidden; transition: transform .25s cubic-bezier(.2,1.2,.3,1), box-shadow .25s ease, border-color .15s; }
.post-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); border-color: var(--line-strong); }
.post-card + .post-card { margin-top: 16px; }
.post-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px 0; }
.post-head .ph-meta { min-width: 0; flex: 1; }
.post-head .ph-name { font-weight: 800; font-size: 14.5px; display: flex; align-items: center; gap: 6px; cursor: pointer; }
.post-head .ph-name:hover { text-decoration: underline; }
.post-head .ph-sub { font-size: 12.5px; color: var(--text-3); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.verified { color: var(--accent); width: 15px; height: 15px; flex: none; }

.post-body { padding: 10px 18px 0; font-size: 15px; white-space: pre-wrap; word-break: break-word; }
.post-body .hashtag { color: var(--accent); font-weight: 700; cursor: pointer; }
.post-body .hashtag:hover { text-decoration: underline; }

.post-media { margin-top: 12px; background: var(--bg-soft); }
.post-media img { width: 100%; max-height: 560px; object-fit: cover; cursor: zoom-in; }
.post-media video { width: 100%; max-height: 560px; background: #000; }

.post-actions { display: flex; align-items: center; gap: 6px; padding: 8px 10px 10px; }
.action-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 12px; border-radius: var(--r-full);
  color: var(--text-3); font-weight: 700; font-size: 13.5px;
  transition: background .15s, color .15s, transform .08s;
}
.action-chip svg { width: 19px; height: 19px; }
.action-chip:hover { background: var(--hover); }
.action-chip:active { transform: scale(.94); }
.action-chip.liked { color: var(--accent-2); }
.action-chip.liked svg { fill: var(--accent-2); }
.action-chip.bookmarked.on { color: var(--accent); }
.action-chip.bookmarked.on svg { fill: var(--accent); }
.action-chip.share:hover { color: var(--teal); }

.course-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 800; letter-spacing: .02em;
  color: var(--violet); background: rgba(124,58,237,.12);
  padding: 3px 10px; border-radius: var(--r-full);
}
html[data-theme="dark"] .course-chip { color: #C4B5FD; }

/* comments */
.comments-box { border-top: 1px solid var(--line); margin-top: 2px; }
.comment-row { display: flex; gap: 10px; padding: 10px 18px 0; }
.comment-bubble { background: var(--surface-2); border-radius: 4px 16px 16px 16px; padding: 9px 13px; max-width: 85%; }
.comment-bubble .cb-name { font-size: 12.5px; font-weight: 800; }
.comment-bubble .cb-text { font-size: 14px; word-break: break-word; }
.comment-bubble .cb-time { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.comment-input-row { display: flex; gap: 10px; align-items: center; padding: 12px 18px 14px; }
.comment-input-row input {
  flex: 1; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-full); padding: 10px 16px; outline: none;
}
.comment-input-row input:focus { border-color: var(--accent); }

/* ───────────────────────── forms ─────────────────────────── */
.field { display: grid; gap: 6px; }
.field label { font-size: 13px; font-weight: 700; color: var(--text-2); }
.input, textarea.input {
  width: 100%; background: var(--surface-2); border: 1.5px solid var(--line);
  border-radius: var(--r-md); padding: 11px 14px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--accent); box-shadow: var(--ring); }
.input::placeholder { color: var(--text-3); }
.field .hint { font-size: 12px; color: var(--text-3); }
.field .error { font-size: 12.5px; color: var(--danger); font-weight: 600; }

.switch { position: relative; width: 44px; height: 26px; border-radius: 999px; background: var(--surface-3); transition: background .2s; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: translate .2s ease; box-shadow: var(--shadow-1); }
.switch.on { background: var(--accent); }
.switch.on::after { translate: 18px 0; }

/* segmented control */
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-full); padding: 4px; gap: 4px; }
.seg button { padding: 7px 16px; border-radius: var(--r-full); font-weight: 700; font-size: 13.5px; color: var(--text-2); transition: all .15s; }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }

/* ───────────────────────── auth screens ──────────────────── */
.auth-wrap { min-height: 100dvh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero {
  position: relative; overflow: hidden;
  background: radial-gradient(900px 500px at 20% 0%, rgba(245,158,11,.25), transparent 55%),
              radial-gradient(700px 500px at 90% 100%, rgba(124,58,237,.28), transparent 55%),
              #0B0D12;
  color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between;
}
.auth-hero::after {
  content: ""; position: absolute; inset: 0; opacity: .35; pointer-events: none;
  background-image: radial-gradient(rgba(255,255,255,.12) 1px, transparent 1px);
  background-size: 26px 26px;
}
.auth-brand { display: flex; align-items: center; gap: 12px; font-size: 22px; font-weight: 800; z-index: 1; }
.auth-brand .brand-badge { width: 44px; height: 44px; border-radius: 14px; }
.auth-brand em { font-style: normal; color: var(--accent); }
.auth-hero-copy { z-index: 1; display: grid; gap: 18px; max-width: 520px; }
.auth-hero-copy h1 { font-size: clamp(30px, 3.4vw, 44px); font-weight: 800; letter-spacing: -0.035em; }
.auth-hero-copy h1 em { font-style: normal; background: var(--grad-brand); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth-hero-copy p { color: rgba(255,255,255,.72); font-size: 16.5px; max-width: 46ch; }
.auth-points { display: grid; gap: 12px; margin-top: 8px; }
.auth-point { display: flex; gap: 12px; align-items: center; font-weight: 600; color: rgba(255,255,255,.85); }
.auth-point i {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none;
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.14);
}
.auth-point i svg { width: 17px; height: 17px; color: var(--accent); }

.auth-panel { display: flex; align-items: center; justify-content: center; padding: 40px 28px; background: var(--bg); }
.auth-card { width: 100%; max-width: 420px; display: grid; gap: 20px; }
.auth-card h2 { font-size: 26px; font-weight: 800; letter-spacing: -0.03em; }
.auth-card .sub { color: var(--text-2); margin-top: 4px; }
.auth-tabs { display: flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-full); padding: 4px; }
.auth-tabs button { flex: 1; padding: 10px; border-radius: var(--r-full); font-weight: 800; color: var(--text-2); transition: all .18s; }
.auth-tabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
.auth-form { display: grid; gap: 14px; }
.demo-hint {
  border: 1px dashed var(--line-strong); border-radius: var(--r-md);
  padding: 12px 14px; font-size: 13px; color: var(--text-2); display: grid; gap: 6px;
}
.demo-hint b { color: var(--text); }
.demo-hint .demo-fill { color: var(--accent); font-weight: 800; cursor: pointer; }
.demo-hint .demo-fill:hover { text-decoration: underline; }
.auth-foot { text-align: center; font-size: 13px; color: var(--text-3); }
.auth-foot button { color: var(--accent); font-weight: 700; }

/* ───────────────────────── page headers ──────────────────── */
.page-head { margin-bottom: 18px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; font-weight: 800; letter-spacing: -0.03em; }
.page-head .ph-sub { color: var(--text-2); font-size: 14px; }
.page-head .grow { flex: 1; }

.feed-tabs { display: flex; gap: 8px; margin-bottom: 16px; overflow-x: auto; padding-bottom: 2px; }
.feed-tab {
  padding: 8px 18px; border-radius: var(--r-full); font-weight: 700; font-size: 14px;
  color: var(--text-2); background: var(--surface-2); border: 1px solid var(--line);
  transition: all .15s; white-space: nowrap;
}
.feed-tab.active { background: var(--grad-brand); color: #fff; border-color: transparent; box-shadow: var(--shadow-2); }
.feed-tab:not(.active):hover { color: var(--text); }

/* ───────────────────────── chat ──────────────────────────── */
.chat-page-head { align-items: center; margin-bottom: var(--s-3); flex-wrap: wrap; gap: var(--s-3); }
.chat-tabs { display: inline-flex; background: var(--surface-2); border-radius: var(--r-full); padding: 3px; gap: 2px; }
.ctab { padding: 8px 18px; border-radius: var(--r-full); font-weight: 700; font-size: var(--fs-sm); color: var(--text-2); transition: all var(--dur) var(--ease); min-height: 36px; }
.ctab:hover { color: var(--text); }
.ctab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }

.chat-layout { display: grid; grid-template-columns: minmax(280px, 330px) minmax(0, 1fr); gap: 0; border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; background: var(--surface); height: calc(100dvh - 150px); min-height: 440px; }
.chat-layout.embedded { height: 440px; }
.chat-calls { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); padding: var(--s-2) var(--s-4) var(--s-4); min-height: 300px; }

/* ── conversation list ── */
.chat-list { border-right: 1px solid var(--line); overflow-y: auto; background: var(--bg-soft); display: flex; flex-direction: column; }
.chat-list-head { padding: var(--s-3); position: sticky; top: 0; background: var(--bg-soft); z-index: 2; border-bottom: 1px solid var(--line); }
.chat-search { display: flex; align-items: center; gap: var(--s-2); background: var(--surface-2); border: 1.5px solid transparent; border-radius: var(--r-md); padding: 0 var(--s-3); transition: border-color var(--dur) var(--ease); }
.chat-search:focus-within { border-color: var(--accent); }
.chat-search .cs-icon { display: flex; color: var(--text-3); }
.chat-search input { flex: 1; background: none; border: 0; outline: none; padding: 11px 0; font-size: var(--fs-base); min-height: var(--tap); }
.chat-list-body { flex: 1; overflow-y: auto; }
.cl-empty { padding: var(--s-4); color: var(--text-3); font-size: var(--fs-sm); line-height: 1.6; }
.unread-summary { padding: 10px var(--s-4); font-size: var(--fs-xs); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--accent); background: var(--grad-brand-soft); position: sticky; top: 0; z-index: 1; }

.convo-item { display: flex; gap: var(--s-3); align-items: center; padding: 12px var(--s-4); cursor: pointer; transition: background var(--dur-fast) var(--ease); border-left: 3px solid transparent; min-height: 68px; }
.convo-item:hover { background: var(--hover); }
.convo-item:focus-visible { outline: none; background: var(--hover); box-shadow: inset var(--ring); }
.convo-item.active { background: var(--surface); border-left-color: var(--accent); }
.convo-item.unread .ci-name { font-weight: 800; }
.convo-item.unread .ci-last { color: var(--text-2); font-weight: 600; }
.ci-avatar-wrap { position: relative; flex: none; }
.ci-body { min-width: 0; flex: 1; display: grid; gap: 3px; }
.ci-top, .ci-bottom { display: flex; align-items: center; gap: var(--s-2); min-width: 0; }
.ci-name { font-weight: 700; font-size: var(--fs-base); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci-last { font-size: var(--fs-sm); color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.ci-time { margin-left: auto; font-size: var(--fs-xs); color: var(--text-3); flex: none; }
.ci-badge { flex: none; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-full); background: var(--accent-2); color: #fff; font-size: 11px; font-weight: 800; display: grid; place-items: center; }
.convo-icon { width: 46px; height: 46px; border-radius: 50%; background: var(--grad-violet); color: #fff; display: grid; place-items: center; flex: none; }
.convo-icon svg { width: 18px; height: 18px; }
.presence-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--text-3); border: 2.5px solid var(--bg-soft); display: inline-block; flex: none; }
.presence-dot.on { background: var(--ok); box-shadow: 0 0 0 2px var(--ok-soft); }
.ci-avatar-wrap .presence-dot { position: absolute; right: -1px; bottom: -1px; width: 13px; height: 13px; }
.typing-inline { color: var(--accent); font-style: normal; font-weight: 600; }

/* ── thread pane ── */
.chat-pane { display: flex; flex-direction: column; min-width: 0; background: var(--surface); position: relative; }
.chat-welcome { display: grid; place-items: center; flex: 1; padding: var(--s-6); }
.chat-head { display: flex; align-items: center; gap: var(--s-3); padding: 10px var(--s-4); border-bottom: 1px solid var(--line); background: var(--surface); min-height: 62px; }
.chat-head .ch-title { flex: 1; min-width: 0; }
.chat-head .ch-name { font-weight: 800; font-size: var(--fs-md); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head .ch-sub { font-size: var(--fs-xs); color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.chat-head .ch-sub .presence-dot { width: 9px; height: 9px; border-width: 2px; border-color: var(--surface); }
.ch-actions { display: flex; gap: 2px; }
.ch-actions .icon-btn { width: 38px; height: 38px; }
.ch-actions .icon-btn:disabled { opacity: .35; cursor: not-allowed; }

.thread-search { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-2) var(--s-4); border-bottom: 1px solid var(--line); background: var(--surface-2); }
.thread-search input { flex: 1; background: none; border: 0; outline: none; font-size: var(--fs-sm); min-height: 36px; }

.chat-msgs { flex: 1; overflow-y: auto; padding: var(--s-4) var(--s-4) var(--s-2); display: flex; flex-direction: column; gap: 3px; scroll-behavior: smooth; }
.chat-msgs.dragging { outline: 2px dashed var(--accent); outline-offset: -8px; border-radius: var(--r-md); background: var(--warn-soft); }
.msg-row.dim { opacity: .28; }
.msg-row.flash .msg-bubble { animation: flashHi 2s var(--ease); }
@keyframes flashHi { 0%, 40% { box-shadow: 0 0 0 3px var(--ring); } 100% { box-shadow: var(--shadow-1); } }

.thread-empty { margin: auto; text-align: center; color: var(--text-3); display: grid; gap: var(--s-2); justify-items: center; }
.te-art { width: 60px; height: 60px; border-radius: var(--r-lg); background: var(--surface-2); display: grid; place-items: center; color: var(--text-3); }
.te-art svg { width: 26px; height: 26px; }

.day-sep { display: flex; align-items: center; justify-content: center; margin: var(--s-4) 0 var(--s-2); }
.day-sep span { font-size: var(--fs-xs); font-weight: 700; color: var(--text-3); background: var(--surface-2); padding: 4px 12px; border-radius: var(--r-full); }

.msg-row { display: flex; gap: var(--s-2); max-width: min(78%, 620px); align-items: flex-end; position: relative; }
.msg-row.mine { align-self: flex-end; flex-direction: row-reverse; }
.msg-row.grouped { margin-top: -1px; }
.mr-av { width: 30px; flex: none; }
.mr-body { min-width: 0; display: grid; gap: 3px; }
.msg-bubble { background: var(--surface-2); border-radius: 16px 16px 16px 5px; padding: 9px 13px 6px; box-shadow: var(--shadow-1); position: relative; min-width: 0; }
.msg-row.mine .msg-bubble { background: var(--grad-brand); color: #fff; border-radius: 16px 16px 5px 16px; }
.msg-row.grouped:not(.mine) .msg-bubble { border-top-left-radius: 8px; }
.msg-sender { font-size: var(--fs-xs); font-weight: 800; color: var(--accent); margin-bottom: 2px; }
.msg-text { font-size: var(--fs-base); word-break: break-word; white-space: pre-wrap; }
.msg-foot { display: flex; align-items: center; justify-content: flex-end; gap: 6px; margin-top: 3px; }
.msg-time { font-size: 10.5px; opacity: .72; }
.msg-edited { font-size: 10.5px; opacity: .6; font-style: italic; }
.msg-tick { display: inline-flex; opacity: .8; }
.msg-tick svg { width: 14px; height: 14px; }
.msg-tick.read { color: #7DD3FC; opacity: 1; }
.msg-tick.pending { opacity: .55; animation: tickPulse 1.2s infinite; }
@keyframes tickPulse { 0%,100% { opacity: .35; } 50% { opacity: .8; } }
.msg-row.failed .msg-bubble { box-shadow: var(--ring-danger); }
.msg-row.failed .msg-tick { color: var(--danger); opacity: 1; }

.msg-reply { border-left: 3px solid currentColor; opacity: .82; padding: 3px 0 3px 8px; margin-bottom: 5px; border-radius: 3px; font-size: var(--fs-xs); max-width: 100%; }
.mrp-sender { display: block; font-weight: 800; }
.mrp-text { display: block; opacity: .82; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-row:not(.mine) .msg-reply { color: var(--accent); }
.msg-row.mine .msg-reply { color: rgba(255,255,255,.94); }

.deleted-text { display: flex; align-items: center; gap: 6px; opacity: .7; font-size: var(--fs-sm); }
.deleted-text svg { width: 14px; height: 14px; }

/* reactions */
.reaction-row { display: flex; gap: 4px; flex-wrap: wrap; min-height: 0; }
.reaction { display: inline-flex; align-items: center; gap: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-full); padding: 2px 9px; font-size: 13px; line-height: 1.7; transition: all var(--dur-fast) var(--ease); }
.reaction:hover { transform: translateY(-1px); border-color: var(--line-strong); }
.reaction.mine { background: var(--grad-brand-soft); border-color: rgba(245,158,11,.5); }
.reaction b { font-size: 11px; font-weight: 800; color: var(--text-2); }

.msg-menu-btn { opacity: 0; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; color: var(--text-3); background: var(--surface-2); align-self: center; transition: opacity var(--dur-fast) var(--ease); flex: none; }
.msg-menu-btn svg { width: 16px; height: 16px; }
.msg-row:hover .msg-menu-btn, .msg-row:focus-within .msg-menu-btn { opacity: 1; }

.msg-menu { z-index: 400; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-3); padding: 6px; width: 232px; animation: popIn var(--dur-fast) var(--ease); }
@keyframes popIn { from { opacity: 0; transform: scale(.96) translateY(-4px); } }
.mm-reactions { display: flex; justify-content: space-between; padding: 4px 2px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.mm-reactions button { width: 34px; height: 34px; border-radius: 50%; font-size: 18px; display: grid; place-items: center; transition: background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease); }
.mm-reactions button:hover { background: var(--surface-2); transform: scale(1.15); }
.mm-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border-radius: var(--r-sm); font-size: var(--fs-sm); font-weight: 600; text-align: left; min-height: 40px; }
.mm-item:hover { background: var(--hover); }
.mm-item svg { width: 17px; height: 17px; color: var(--text-2); }
.mm-item.danger { color: var(--danger); }
.mm-item.danger svg { color: var(--danger); }

.edit-box { width: 100%; min-width: 220px; background: rgba(0,0,0,.16); border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: 8px 10px; font-size: var(--fs-base); resize: none; outline: none; color: inherit; }
.edit-actions { display: flex; gap: 6px; justify-content: flex-end; margin-top: 8px; }
.edit-actions .btn { padding: 6px 14px; font-size: var(--fs-sm); min-height: 34px; }

.typing-row { font-size: var(--fs-sm); color: var(--text-3); padding: 0 var(--s-5) 6px; min-height: 20px; }
.typing-row .tdots span { display: inline-block; width: 4px; height: 4px; margin-right: 2px; background: var(--text-3); border-radius: 50%; animation: tyblink 1.2s infinite; }
.typing-row .tdots span:nth-child(2) { animation-delay: .15s; }
.typing-row .tdots span:nth-child(3) { animation-delay: .3s; }
@keyframes tyblink { 0%,80%,100% { opacity: .3; } 40% { opacity: 1; } }

/* ── attachments in bubbles ── */
.msg-bubble.image { padding: 5px; overflow: hidden; }
.msg-image { border-radius: 12px; max-height: 340px; width: 100%; object-fit: cover; cursor: zoom-in; }
.msg-bubble.image .msg-foot { padding: 0 6px 2px; }
.msg-bubble.image .msg-text { padding: 4px 6px 0; }
.msg-file { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-radius: var(--r-sm); text-decoration: none; color: inherit; }
.mf-icon { width: 38px; height: 38px; border-radius: var(--r-sm); background: rgba(127,127,127,.18); display: grid; place-items: center; flex: none; }
.mf-icon svg { width: 18px; height: 18px; }
.mf-meta { display: grid; min-width: 0; }
.mf-name { font-size: var(--fs-sm); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 190px; }
.mf-size { font-size: var(--fs-xs); opacity: .7; }
.mf-dl { margin-left: auto; opacity: .7; }
.mf-dl svg { width: 18px; height: 18px; }

/* voice notes */
.voice-note { display: flex; align-items: center; gap: 10px; min-width: 210px; padding: 3px 0; --vn-progress: 0%; }
.vn-play { width: 38px; height: 38px; border-radius: 50%; background: rgba(255,255,255,.22); display: grid; place-items: center; flex: none; transition: transform var(--dur-fast) var(--ease); }
.vn-play:hover { transform: scale(1.06); }
.vn-play svg { width: 17px; height: 17px; }
.msg-row:not(.mine) .vn-play { background: var(--surface-3); }
.vn-wave { flex: 1; display: flex; align-items: center; gap: 2px; height: 30px; cursor: pointer; position: relative; }
.vn-wave::before { content: ""; position: absolute; inset: 0; width: var(--vn-progress); background: rgba(255,255,255,.16); border-radius: 4px; pointer-events: none; }
.vn-wave i { flex: 1; min-width: 2px; border-radius: 2px; background: currentColor; opacity: .5; }
.voice-note.playing .vn-wave i { animation: vnBar .9s ease-in-out infinite alternate; }
@keyframes vnBar { from { transform: scaleY(.5); } to { transform: scaleY(1); } }
.vn-time { font-size: var(--fs-xs); opacity: .8; min-width: 34px; text-align: right; }

/* ── composer ── */
.chat-input-row { display: flex; gap: var(--s-2); padding: var(--s-3) var(--s-4); border-top: 1px solid var(--line); background: var(--surface); align-items: flex-end; }
.input-wrap { flex: 1; display: flex; align-items: flex-end; gap: var(--s-1); background: var(--surface-2); border: 1.5px solid transparent; border-radius: var(--r-lg); padding: 2px 4px 2px 12px; transition: border-color var(--dur) var(--ease); }
.input-wrap:focus-within { border-color: var(--accent); }
.input-wrap textarea { flex: 1; background: none; border: 0; outline: none; resize: none; padding: 11px 0; font-size: var(--fs-base); line-height: 1.5; max-height: 148px; font-family: inherit; }
.ci-btn { width: var(--tap); height: var(--tap); border-radius: 50%; display: grid; place-items: center; color: var(--text-2); flex: none; transition: all var(--dur-fast) var(--ease); }
.ci-btn:hover { background: var(--hover); color: var(--text); }
.ci-btn svg { width: 20px; height: 20px; }
.ci-btn.send { background: var(--grad-brand); color: #fff; box-shadow: var(--glow-brand); width: 42px; height: 42px; }
.ci-btn.send:hover { filter: brightness(1.1); }
.ci-btn.rec.recording { background: var(--danger); color: #fff; animation: recPulse 1.4s infinite; }
@keyframes recPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(229,72,77,.55); } 50% { box-shadow: 0 0 0 8px rgba(229,72,77,0); } }

.reply-bar { display: flex; align-items: center; gap: var(--s-3); padding: 8px var(--s-4); background: var(--surface-2); border-top: 1px solid var(--line); }
.rb-line { width: 3px; align-self: stretch; border-radius: 3px; background: var(--grad-brand); flex: none; }
.rb-body { flex: 1; min-width: 0; }
.rb-sender { font-size: var(--fs-xs); font-weight: 800; color: var(--accent); }
.rb-text { font-size: var(--fs-sm); color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* emoji picker */
.emoji-pop { z-index: 400; width: min(320px, 92vw); max-height: 280px; overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-3); padding: 8px; display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; animation: popIn var(--dur-fast) var(--ease); }
.emoji-pop button { aspect-ratio: 1; border-radius: var(--r-sm); font-size: 19px; display: grid; place-items: center; transition: background var(--dur-fast) var(--ease); }
.emoji-pop button:hover { background: var(--surface-2); }

/* voice recorder overlay */
.rec-overlay { position: fixed; inset: 0; z-index: 500; background: var(--scrim); backdrop-filter: blur(8px); display: grid; place-items: center; padding: var(--s-4); animation: fadeIn var(--dur) var(--ease); }
@keyframes fadeIn { from { opacity: 0; } }
.rec-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl); padding: var(--s-5); width: min(420px, 100%); display: grid; gap: var(--s-4); justify-items: center; box-shadow: var(--shadow-3); }
.rec-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--danger); animation: recPulse 1.4s infinite; }
.rec-time { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.rec-wave { display: flex; align-items: center; gap: 3px; height: 56px; width: 100%; }
.rec-wave i { flex: 1; min-width: 2px; height: 12%; border-radius: 2px; background: var(--grad-brand); transition: height 80ms linear; }
.rec-actions { display: flex; gap: var(--s-3); width: 100%; }
.rec-actions .btn { flex: 1; justify-content: center; }

/* ── call history ── */
.call-day { font-size: var(--fs-xs); font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); padding: var(--s-4) 0 var(--s-2); }
.call-row { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) 6px; border-bottom: 1px solid var(--line); }
.call-row:last-child { border-bottom: 0; }
.cr-main { flex: 1; min-width: 0; }
.cr-name { font-weight: 700; font-size: var(--fs-base); }
.cr-name.missed { color: var(--danger); }
.cr-sub { display: flex; align-items: center; gap: 5px; font-size: var(--fs-sm); color: var(--text-3); }
.cr-dir { display: inline-flex; }
.cr-dir svg { width: 14px; height: 14px; }
.cr-call { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); flex: none; transition: all var(--dur) var(--ease); }
.cr-call:hover { background: var(--grad-brand); color: #fff; box-shadow: var(--glow-brand); }
.cr-call svg { width: 19px; height: 19px; }

/* ───────────────────────── shorts ────────────────────────── */
.shorts-stage { position: fixed; inset: 0; z-index: 120; background: #000; display: flex; justify-content: center; }
.short-item { position: absolute; inset: 0; display: grid; place-items: center; }
.short-frame { position: relative; height: 100dvh; aspect-ratio: 9/16; max-width: 100vw; background: #000; overflow: hidden; }
.short-frame video, .short-frame img { width: 100%; height: 100%; object-fit: contain; }
.short-overlay {
  position: absolute; inset: 0; z-index: 5;
  background: linear-gradient(180deg, rgba(0,0,0,.55) 0%, transparent 18%, transparent 62%, rgba(0,0,0,.65) 100%);
  display: flex; flex-direction: column; justify-content: space-between; padding: 18px;
}
.short-top { display: flex; align-items: center; gap: 10px; color: #fff; }
.short-top h3 { font-size: 17px; font-weight: 800; text-shadow: 0 2px 10px rgba(0,0,0,.5); }
.short-bottom { display: flex; align-items: flex-end; gap: 12px; color: #fff; }
.short-meta { flex: 1; min-width: 0; text-shadow: 0 2px 10px rgba(0,0,0,.6); }
.short-meta .sm-author { font-weight: 800; font-size: 15px; margin-bottom: 4px; }
.short-meta .sm-text { font-size: 14px; opacity: .95; word-break: break-word; }
.short-rail { display: grid; gap: 16px; justify-items: center; align-items: end; }
.short-rail .sr-btn { display: grid; gap: 4px; justify-items: center; font-size: 12px; font-weight: 700; color: #fff; }
.short-rail .sr-btn .icon-btn { width: 48px; height: 48px; background: rgba(255,255,255,.14); backdrop-filter: blur(6px); color: #fff; }
.short-rail .sr-btn .icon-btn svg { width: 24px; height: 24px; }
.short-rail .sr-btn.liked .icon-btn { background: rgba(229,72,77,.9); }
.short-rail .sr-btn.liked .icon-btn svg { fill: #fff; }
.short-nav-hint { position: absolute; right: 14px; top: 50%; translate: 0 -50%; z-index: 6; display: grid; gap: 10px; }
.short-nav-hint button { width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,.14); color: #fff; display: grid; place-items: center; backdrop-filter: blur(6px); }
.short-empty { color: #cbd5e1; text-align: center; display: grid; gap: 14px; justify-items: center; }

/* ───────────────────────── live ──────────────────────────── */
.live-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.live-card { overflow: hidden; cursor: pointer; transition: transform .15s ease, box-shadow .15s ease; }
.live-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); }
.live-thumb { position: relative; aspect-ratio: 16/9; background: var(--grad-violet); display: grid; place-items: center; }
.live-thumb .lt-emoji { font-size: 52px; filter: drop-shadow(0 6px 16px rgba(0,0,0,.4)); }
.live-badge { position: absolute; top: 10px; left: 10px; display: inline-flex; align-items: center; gap: 6px; background: var(--accent-2); color: #fff; font-size: 11px; font-weight: 800; letter-spacing: .06em; padding: 4px 10px; border-radius: var(--r-full); }
.live-badge i { width: 7px; height: 7px; border-radius: 50%; background: #fff; animation: livepulse 1.4s infinite; }
@keyframes livepulse { 0%,100% { opacity: 1; transform: scale(1);} 50% { opacity: .5; transform: scale(.8);} }
.live-viewers { position: absolute; bottom: 10px; right: 10px; background: rgba(0,0,0,.65); color: #fff; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: var(--r-full); display: flex; align-items: center; gap: 5px; }
.live-card-body { padding: 12px 14px; display: flex; gap: 10px; align-items: center; }
.live-card-body .lcb-title { font-weight: 800; font-size: 14px; }
.live-card-body .lcb-host { font-size: 12.5px; color: var(--text-3); }

.live-stage { position: fixed; inset: 0; z-index: 120; background: #07080c; display: flex; flex-direction: column; }
.live-video-wrap { flex: 1; position: relative; display: grid; place-items: center; overflow: hidden; }
.live-video-wrap video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.live-top-bar { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 12px; padding: 14px 18px; z-index: 10; background: linear-gradient(180deg, rgba(0,0,0,.6), transparent); color: #fff; }
.live-side {
  width: 340px; background: var(--surface); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; height: 100dvh;
}
@media (max-width: 900px) { .live-side { position: absolute; right: 0; top: 0; bottom: 0; z-index: 20; width: min(340px, 86vw); box-shadow: var(--shadow-3); } }
.live-side .chat-msgs { flex: 1; }
.live-controls { position: absolute; bottom: 22px; left: 0; right: 0; display: flex; justify-content: center; gap: 12px; z-index: 10; }
.live-controls .icon-btn { width: 52px; height: 52px; background: rgba(255,255,255,.12); color: #fff; backdrop-filter: blur(8px); border: 1px solid rgba(255,255,255,.15); }
.live-controls .icon-btn svg { width: 24px; height: 24px; }
.live-controls .icon-btn.danger { background: var(--accent-2); border-color: transparent; }
.live-controls .icon-btn.off { background: var(--danger); }

/* ───────────────────────── courses ───────────────────────── */
.course-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.course-card { padding: 18px; display: grid; gap: 10px; cursor: pointer; transition: transform .15s, box-shadow .15s, border-color .15s; position: relative; overflow: hidden; }
.course-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); border-color: var(--line-strong); }
.course-code { font-family: var(--mono); font-size: 12px; font-weight: 700; color: var(--accent); letter-spacing: .06em; }
.course-name { font-weight: 800; font-size: 16px; letter-spacing: -0.02em; }
.course-desc { font-size: 13px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.course-meta { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-3); margin-top: 4px; }
.course-card .cc-grad { position: absolute; top: -40px; right: -40px; width: 130px; height: 130px; border-radius: 50%; opacity: .12; background: var(--grad-brand); }

/* ───────────────────────── profile ───────────────────────── */
.profile-banner { height: 200px; border-radius: var(--r-lg); overflow: hidden; background: var(--grad-violet); position: relative; }
.profile-banner img { width: 100%; height: 100%; object-fit: cover; }
.profile-head { padding: 0 20px; margin-top: -44px; position: relative; display: flex; gap: 16px; align-items: flex-end; }
.profile-head .avatar { border: 4px solid var(--surface); box-shadow: var(--shadow-2); }
.profile-head .ph-btns { margin-left: auto; display: flex; gap: 8px; padding-bottom: 6px; }
.profile-info { padding: 12px 20px 4px; }
.profile-info .pi-name { font-size: 22px; font-weight: 800; letter-spacing: -0.03em; display: flex; align-items: center; gap: 8px; }
.profile-info .pi-mail { color: var(--text-2); font-size: 13.5px; }
.profile-info .pi-bio { margin-top: 8px; white-space: pre-wrap; }
.profile-stats { display: flex; gap: 26px; padding: 14px 20px; }
.pstat b { font-size: 17px; font-weight: 800; display: block; }
.pstat span { color: var(--text-3); font-size: 13px; }
.crown { color: var(--accent); display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 800; background: rgba(245,158,11,.13); border: 1px solid rgba(245,158,11,.35); padding: 3px 10px; border-radius: var(--r-full); }
.crown svg { width: 13px; height: 13px; }

/* ───────────────────────── misc views ────────────────────── */
.settings-group { padding: 20px; display: grid; gap: 16px; }
.settings-row { display: flex; align-items: center; gap: 14px; }
.settings-row .sr-icon { width: 42px; height: 42px; border-radius: 12px; background: var(--surface-2); display: grid; place-items: center; color: var(--accent); flex: none; }
.settings-row .sr-icon svg { width: 20px; height: 20px; }
.settings-row .sr-label { font-weight: 700; }
.settings-row .sr-sub { font-size: 12.5px; color: var(--text-3); }
.settings-row .grow { flex: 1; }

.notif-row { display: flex; gap: 12px; padding: 14px 18px; align-items: flex-start; transition: background .12s; cursor: pointer; position: relative; }
.notif-row:hover { background: var(--hover); }
.notif-row.unread { background: rgba(245,158,11,.06); }
.notif-row.unread::before { content: ""; position: absolute; left: 6px; top: 50%; translate: 0 -50%; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.notif-icon { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.notif-icon svg { width: 18px; height: 18px; }
.notif-icon.like { background: rgba(229,72,77,.14); color: var(--accent-2); }
.notif-icon.comment { background: rgba(124,58,237,.14); color: #A78BFA; }
.notif-icon.follow { background: rgba(20,184,166,.14); color: var(--teal); }
.notif-icon.livestream { background: rgba(245,158,11,.14); color: var(--accent); }
.notif-icon.system { background: var(--surface-3); color: var(--text-2); }
.notif-body .nb-title { font-weight: 700; font-size: 14px; }
.notif-body .nb-text { font-size: 13.5px; color: var(--text-2); }
.notif-body .nb-time { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }

.search-hero { display: grid; gap: 16px; margin-bottom: 20px; }
.search-hero .search-box { position: relative; }
.search-hero .search-box svg { position: absolute; left: 16px; top: 50%; translate: 0 -50%; width: 20px; height: 20px; color: var(--text-3); }
.search-hero .search-box input { width: 100%; padding: 14px 18px 14px 46px; border-radius: var(--r-full); border: 1.5px solid var(--line); background: color-mix(in srgb, var(--surface) 70%, transparent); backdrop-filter: blur(12px); outline: none; font-size: 15px; transition: all .2s; }
.search-hero .search-box input:focus { border-color: var(--accent); box-shadow: var(--ring); background: var(--surface); }

.user-card { display: flex; align-items: center; gap: 12px; padding: 12px 16px; }
.user-card .uc-meta { min-width: 0; flex: 1; cursor: pointer; }
.user-card .uc-name { font-weight: 800; font-size: 14.5px; }
.user-card .uc-sub { font-size: 12.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* AI buddy */
.ai-layout { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; height: calc(100dvh - 140px); min-height: 480px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; }
.ai-head { padding: 14px 20px; border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: center; }
.ai-head .ai-orb { width: 40px; height: 40px; border-radius: 14px; background: var(--grad-violet); display: grid; place-items: center; color: #fff; box-shadow: var(--shadow-2); }
.ai-head .ai-orb svg { width: 20px; height: 20px; }
.ai-msgs { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.ai-msg { max-width: 82%; padding: 12px 16px; border-radius: 18px 18px 18px 6px; background: var(--surface-2); font-size: 14.5px; white-space: pre-wrap; word-break: break-word; }
.ai-msg.mine { align-self: flex-end; border-radius: 18px 18px 6px 18px; background: var(--grad-brand); color: #fff; }
.ai-chips { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 20px 12px; }
.ai-chip { font-size: 12.5px; font-weight: 700; color: var(--text-2); border: 1px solid var(--line); padding: 6px 12px; border-radius: var(--r-full); background: var(--surface-2); transition: all .15s; }
.ai-chip:hover { color: var(--accent); border-color: rgba(245,158,11,.4); }

/* ───────────────────────── modal / toast / lightbox ──────── */
#modal-root:empty, #lightbox-root:empty { display: none; }
.modal-backdrop {
  position: fixed; inset: 0; z-index: 200; background: rgba(4,6,12,.66); backdrop-filter: blur(6px);
  display: grid; place-items: center; padding: 20px; animation: fadein .18s ease;
}
.modal {
  width: 100%; max-width: 480px; max-height: 88dvh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl);
  box-shadow: var(--shadow-3); animation: popin .22s cubic-bezier(.2,1.2,.3,1);
}
.modal.modal-lg { max-width: 640px; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 18px 22px 0; }
.modal-head h3 { font-size: 19px; font-weight: 800; }
.modal-head .icon-btn { margin-left: auto; }
.modal-body { padding: 16px 22px 22px; display: grid; gap: 14px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 0 22px 20px; }

@keyframes fadein { from { opacity: 0; } }
@keyframes popin { from { opacity: 0; transform: translateY(14px) scale(.97); } }

.toasts { position: fixed; bottom: 22px; left: 50%; translate: -50% 0; z-index: 300; display: grid; gap: 10px; justify-items: center; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-3); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: var(--r-full);
  padding: 11px 20px; font-weight: 600; font-size: 14px;
  box-shadow: var(--shadow-3); animation: toastin .25s cubic-bezier(.2,1.2,.3,1);
  pointer-events: auto; max-width: 90vw;
}
.toast svg { width: 18px; height: 18px; flex: none; }
.toast.ok svg { color: var(--ok); }
.toast.err svg { color: var(--danger); }
.toast.info svg { color: var(--accent); }
@keyframes toastin { from { opacity: 0; transform: translateY(12px) scale(.95); } }

.lightbox-backdrop { position: fixed; inset: 0; z-index: 250; background: rgba(0,0,0,.92); display: grid; place-items: center; animation: fadein .15s; cursor: zoom-out; }
.lightbox-backdrop img, .lightbox-backdrop video { max-width: 94vw; max-height: 94dvh; border-radius: var(--r-md); }
.lightbox-backdrop .lb-x { position: absolute; top: 18px; right: 18px; width: 44px; height: 44px; border-radius: 50%; background: rgba(255,255,255,.12); color: #fff; display: grid; place-items: center; }

/* notifications popover */
.popover {
  position: fixed; z-index: 150; width: 380px; max-width: 94vw; max-height: 70dvh; overflow: hidden auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-3); animation: popin .18s cubic-bezier(.2,1.2,.3,1);
}
.popover-head { position: sticky; top: 0; background: var(--surface); display: flex; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); z-index: 2; }
.popover-head h3 { font-size: 16px; font-weight: 800; }
.popover-head button { margin-left: auto; font-size: 12.5px; font-weight: 700; color: var(--accent); }

/* skeletons + empty + spinner */
.skeleton { border-radius: var(--r-lg); background: linear-gradient(100deg, var(--surface) 40%, var(--surface-2) 50%, var(--surface) 60%); background-size: 200% 100%; animation: shimmer 1.4s infinite linear; min-height: 120px; border: 1px solid var(--line); }
@keyframes shimmer { to { background-position: -200% 0; } }

.empty-state { display: grid; justify-items: center; gap: 10px; text-align: center; padding: 54px 24px; color: var(--text-2); }
.empty-state .es-art { width: 84px; height: 84px; border-radius: 26px; background: var(--surface-2); display: grid; place-items: center; color: var(--text-3); }
.empty-state .es-art svg { width: 38px; height: 38px; }
.empty-state h3 { color: var(--text); font-size: 18px; font-weight: 800; }
.empty-state p { font-size: 14px; max-width: 38ch; }

.spinner { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--surface-3); border-top-color: var(--accent); animation: spin .7s linear infinite; margin: 20px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

.load-more { display: grid; place-items: center; padding: 18px; }

/* mobile bottom tabs */
.mobile-tabs {
  display: none;
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  /* minmax(0,1fr) — a bare 1fr takes its min from content, which let the tab labels
     push this bar wider than a 320px phone and scroll the entire page. */
  grid-template-columns: repeat(6, minmax(0, 1fr));
}
.mobile-tabs .tab { display: grid; justify-items: center; gap: 3px; padding: 7px 2px; color: var(--text-3); font-size: 10px; font-weight: 700; border-radius: 12px; position: relative; min-width: 0; }
.mobile-tabs .tab span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mobile-tabs .tab .tab-badge {
  position: absolute; top: 1px; right: 0; min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: var(--r-full); background: var(--accent-2); color: #fff;
  font-size: 9.5px; font-weight: 800; display: grid; place-items: center;
}
.mobile-tabs .tab svg { width: 22px; height: 22px; }
.mobile-tabs .tab.active { color: var(--accent); }
.mobile-tabs .tab .badge { position: absolute; top: 2px; right: 14px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--accent-2); color: #fff; font-size: 9.5px; font-weight: 800; display: grid; place-items: center; }
.mobile-tabs .tab-create svg { background: var(--grad-brand); border-radius: 10px; padding: 4px; width: 30px !important; height: 30px; fill: #fff; color: #fff; }

/* ───────────────────────── responsive ────────────────────── */
@media (max-width: 1380px) {
  .app-shell { grid-template-columns: var(--nav-w) minmax(0, var(--main-w)); }
  /* The rail is hidden here, so messaging must reclaim its track rather than leaving
     an empty 336px column beside the thread. */
  .app-shell.chat-wide { grid-template-columns: var(--nav-w) minmax(0, 1fr); }
  .rail-col { display: none; }
}
@media (max-width: 980px) {
  .app-shell, .app-shell.rail { grid-template-columns: 84px minmax(0,1fr); }
  .app-shell:not(.rail) .side-nav { align-items: center; padding: 20px 10px; }
  .app-shell:not(.rail) .brand-name, .app-shell:not(.rail) .nav-item span, .app-shell:not(.rail) .nav-create span, .app-shell:not(.rail) .nav-user .nu-meta { display: none; }
  .app-shell:not(.rail) .nav-item { justify-content: center; padding: 13px; }
  .app-shell:not(.rail) .nav-create { padding: 13px; margin: 8px 0; }
  .app-shell:not(.rail) .brand { justify-content: center; padding: 6px 0 18px; }
  .app-shell:not(.rail) .nav-user { justify-content: center; padding: 10px 6px; }
}
@media (max-width: 760px) {
  .app-shell, .app-shell.rail, .app-shell.wide { display: block; padding: 0; }
  .side-nav { display: none; }
  .mobile-header { display: flex; }
  .main-col { padding: 16px 14px 90px; }
  .chat-layout { grid-template-columns: 1fr; height: calc(100dvh - 150px); }
  .chat-list { display: none; }
  .chat-layout.show-list .chat-list { display: block; }
  .chat-layout.show-list .chat-pane { display: none; }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .mobile-tabs { display: grid; }
  .profile-banner { height: 150px; }
  .ai-layout { height: calc(100dvh - 150px); }
}

/* ============================================================
   CALLING — ring overlay + full-screen call stage
   ============================================================ */
.call-layer { position: fixed; inset: 0; z-index: 600; display: none; }
.call-layer.open { display: block; }
.call-layer.incoming { display: grid; place-items: center; }

/* ── incoming ring ── */
.ring-backdrop { position: absolute; inset: 0; background: radial-gradient(900px 600px at 50% 30%, rgba(245,158,11,.2), transparent 65%), var(--scrim); backdrop-filter: blur(16px); animation: fadeIn var(--dur) var(--ease); }
.incoming-card {
  position: relative; z-index: 1; width: min(400px, 90vw);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl);
  padding: var(--s-6) var(--s-5) var(--s-5); display: grid; gap: var(--s-3); justify-items: center;
  box-shadow: var(--shadow-3); animation: ringIn var(--dur-slow) var(--ease);
}
@keyframes ringIn { from { opacity: 0; transform: translateY(22px) scale(.94); } }
.ic-avatar { position: relative; }
.ic-avatar::after { content: ""; position: absolute; inset: -14px; border-radius: 50%; border: 2px solid var(--accent); opacity: 0; animation: ringPulse 1.8s infinite; }
@keyframes ringPulse { 0% { transform: scale(.92); opacity: .0; } 40% { opacity: .55; } 100% { transform: scale(1.18); opacity: 0; } }
.ic-name { font-size: var(--fs-xl); font-weight: 800; letter-spacing: -.02em; text-align: center; }
.ic-sub { color: var(--text-2); font-size: var(--fs-sm); }
.ic-actions { display: flex; gap: var(--s-7); margin-top: var(--s-3); }
.call-btn { width: 62px; height: 62px; border-radius: 50%; display: grid; place-items: center; color: #fff; transition: transform var(--dur-fast) var(--ease), filter var(--dur-fast) var(--ease); }
.call-btn svg { width: 26px; height: 26px; }
.call-btn:hover { transform: scale(1.07); }
.call-btn:active { transform: scale(.96); }
.call-btn.reject { background: linear-gradient(135deg, #E5484D, #B4232A); box-shadow: 0 10px 30px -8px rgba(229,72,77,.6); }
.call-btn.accept { background: linear-gradient(135deg, #30A46C, #157F4B); box-shadow: 0 10px 30px -8px rgba(48,164,108,.6); animation: acceptBob 1.8s infinite var(--ease); }
@keyframes acceptBob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
.ic-message { color: var(--text-2); font-size: var(--fs-sm); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; padding: 10px; min-height: var(--tap); }
.ic-message:hover { color: var(--text); }

/* ── active stage ── */
.call-stage {
  position: absolute; inset: 0; background: #05070B; color: #F4F6FA;
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto; overflow: hidden;
}
.cs-head { display: flex; align-items: center; gap: var(--s-3); padding: 14px clamp(14px, 3vw, 28px); background: linear-gradient(180deg, rgba(0,0,0,.55), transparent); z-index: 3; }
.cs-peer { min-width: 0; }
.cs-name { font-weight: 800; font-size: var(--fs-md); letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-meta { display: flex; align-items: center; gap: 10px; font-size: var(--fs-sm); color: rgba(244,246,250,.7); font-variant-numeric: tabular-nums; }
.cs-quality { padding: 2px 9px; border-radius: var(--r-full); font-size: var(--fs-xs); font-weight: 700; }
.cs-quality.good { background: rgba(48,164,108,.2); color: #7EE2AF; }
.cs-quality.fair { background: rgba(245,158,11,.2); color: #FCD34D; }
.cs-quality.poor { background: rgba(229,72,77,.22); color: #FDA4A6; }
.cs-quality.unknown { background: rgba(255,255,255,.12); color: rgba(255,255,255,.7); }
.cs-head-actions { margin-left: auto; display: flex; gap: 6px; }
.cs-icon { width: var(--tap); height: var(--tap); border-radius: 50%; display: grid; place-items: center; color: #fff; background: rgba(255,255,255,.1); transition: background var(--dur-fast) var(--ease); }
.cs-icon:hover { background: rgba(255,255,255,.2); }
.cs-icon svg { width: 19px; height: 19px; }

.cs-grid {
  display: grid; gap: 10px; padding: 0 clamp(10px, 2vw, 20px); min-height: 0; overflow-y: auto;
  grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
  align-content: center;
}
/* A lone remote peer should read as a video frame, not a stretched letterbox band. */
.cs-grid[data-count="1"] { grid-template-columns: minmax(0, 1fr); }
.cs-grid[data-count="1"] .call-tile {
  width: min(100%, 1120px); margin: 0 auto; aspect-ratio: 16 / 9;
  max-height: 100%; min-height: 0;
}
.call-tile {
  position: relative; background: linear-gradient(160deg, #1A1F2A, #0C1017);
  border-radius: var(--r-lg); overflow: hidden; min-height: 180px;
  display: grid; place-items: center; box-shadow: var(--shadow-2);
}
.ct-video { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.ct-camoff { display: grid; place-items: center; gap: var(--s-2); width: 100%; height: 100%; }
.ct-avatar { border-radius: 50%; }
.ct-wait { position: absolute; inset: 0; display: grid; place-items: center; }
.ct-bar { position: absolute; bottom: 0; left: 0; right: 0; padding: 20px 12px 8px; display: flex; align-items: center; gap: 6px; background: linear-gradient(0deg, rgba(0,0,0,.68), transparent); }
.ct-name { font-size: var(--fs-sm); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ct-mute, .ct-share { display: inline-flex; padding: 3px; border-radius: 50%; background: rgba(229,72,77,.85); }
.ct-share { background: rgba(20,184,166,.9); }
.ct-mute svg, .ct-share svg { width: 13px; height: 13px; }
.call-tile.audio { display: grid; place-items: center; }
.call-tile.audio .ct-camoff { display: grid; }

.cs-self {
  position: absolute; right: clamp(12px, 2.5vw, 26px); bottom: 118px; z-index: 4;
  width: clamp(112px, 15vw, 190px); aspect-ratio: 3/4; border-radius: var(--r-md); overflow: hidden;
  background: #12161F; box-shadow: var(--shadow-3); border: 1.5px solid rgba(255,255,255,.12);
}
.cs-self video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.cs-self.audio-only { display: none; }
.cs-self-off { position: absolute; inset: 0; display: grid; place-items: center; gap: 6px; color: rgba(255,255,255,.65); font-size: var(--fs-xs); background: #12161F; }
.cs-self-off svg { width: 22px; height: 22px; }
.cs-self-label { position: absolute; bottom: 5px; left: 7px; font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: var(--r-full); background: rgba(0,0,0,.5); }

.cs-dock {
  display: flex; justify-content: center; align-items: center; gap: clamp(8px, 1.6vw, 16px);
  padding: 18px clamp(14px, 3vw, 28px) max(18px, env(safe-area-inset-bottom));
  background: linear-gradient(0deg, rgba(0,0,0,.72), transparent); z-index: 5; flex-wrap: wrap;
}
.cd-btn { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.14); color: #fff; transition: all var(--dur-fast) var(--ease); }
.cd-btn svg { width: 23px; height: 23px; }
.cd-btn:hover:not(:disabled) { background: rgba(255,255,255,.24); transform: translateY(-2px); }
.cd-btn:disabled { opacity: .35; cursor: not-allowed; }
.cd-btn.off { background: #fff; color: #05070B; }
.cd-btn.on { background: var(--teal); color: #04211E; }
.cd-btn.end { background: linear-gradient(135deg, #E5484D, #B4232A); width: 66px; height: 66px; box-shadow: 0 10px 34px -8px rgba(229,72,77,.65); }
.cd-btn.end svg { width: 27px; height: 27px; transform: rotate(135deg); }

.device-sheet { position: absolute; left: 50%; bottom: 104px; transform: translateX(-50%); z-index: 6; width: min(400px, 92vw); background: rgba(19,23,32,.96); backdrop-filter: blur(20px); border: 1px solid rgba(255,255,255,.12); border-radius: var(--r-lg); padding: var(--s-4); display: grid; gap: var(--s-3); box-shadow: var(--shadow-3); animation: popIn var(--dur) var(--ease); }
.ds-head { font-weight: 800; font-size: var(--fs-sm); }
.ds-row { display: grid; gap: 5px; font-size: var(--fs-xs); color: rgba(255,255,255,.7); }
.ds-row select { background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.14); border-radius: var(--r-sm); padding: 9px 10px; color: #fff; outline: none; min-height: 40px; }
.ds-note { font-size: var(--fs-xs); color: rgba(255,255,255,.5); line-height: 1.5; }

/* ── call buttons in headers ── */
.profile-actions .btn-sm svg, .chat-head .icon-btn svg { width: 18px; height: 18px; }

/* ── adaptive: tablet + phone ── */
@media (max-width: 1024px) {
  .chat-layout { grid-template-columns: minmax(240px, 290px) minmax(0, 1fr); }
}

@media (max-width: 860px) {
  .chat-layout { grid-template-columns: 1fr; }
  .chat-list { display: none; border-right: 0; }
  .chat-layout.show-list .chat-list { display: flex; }
  .chat-layout.show-list .chat-pane { display: none; }
  .chat-calls { padding: var(--s-2) var(--s-3) var(--s-4); }
  .msg-row { max-width: 88%; }
}

@media (max-width: 640px) {
  .call-layer.incoming .incoming-card { padding: var(--s-5) var(--s-4) var(--s-4); }
  .ic-actions { gap: var(--s-6); }
  .cs-self { bottom: 128px; width: 104px; aspect-ratio: 3/4; }
  .cs-grid { grid-template-columns: 1fr; }
  .call-tile { min-height: 30vh; }
  .cd-btn { width: 48px; height: 48px; }
  .cd-btn svg { width: 20px; height: 20px; }
  .cd-btn.end { width: 58px; height: 58px; }
  .cs-dock { gap: 8px; padding-bottom: max(14px, env(safe-area-inset-bottom)); }
  .chat-input-row { padding: 10px var(--s-3); gap: 6px; }
  .emoji-pop { grid-template-columns: repeat(7, 1fr); }
  .msg-menu { width: min(232px, 88vw); }
  .call-row { padding: 10px 2px; }
}

/* Short viewports (landscape phones) — keep the dock reachable. */
@media (max-height: 520px) and (orientation: landscape) {
  .cs-self { width: 96px; bottom: 78px; }
  .cs-dock { padding: 8px 14px; }
  .cd-btn { width: 42px; height: 42px; }
  .cd-btn.end { width: 50px; height: 50px; }
  .cs-head { padding: 8px 14px; }
  .call-tile { min-height: 42vh; }
}

/* Respect the OS "reduce motion" setting across every animated surface. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* Keyboard users get a visible ring everywhere; mouse users do not. */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; box-shadow: none; }
.icon-btn:focus-visible, .ci-btn:focus-visible, .call-btn:focus-visible, .cd-btn:focus-visible, .cs-icon:focus-visible { outline-offset: 3px; }

/* Print: nobody needs a call stage on paper. */
@media print {
  .call-layer, .mobile-tabs, .side-nav, .rail-col, .toasts { display: none !important; }
}

/* ============================================================
   CONTAINMENT
   Flex and grid items default to `min-width: auto`, so a single long
   word, <select>, or nowrap button can stretch a column past the
   viewport and make the whole page scroll sideways. These rules make
   every container able to shrink below its content's min-content size.
   ============================================================ */
.explore-grid,
.settings-stack,
.profile-grid {
  grid-template-columns: minmax(0, 1fr);
}

.main-col, .rail-col, .main-col > *, .rail > *,
.card, .rail-card, .settings-group, .settings-row, .settings-row > *,
.sugg-row, .sugg-row > *, .sr-meta, .sr-names,
.convo-item, .ci-body, .chat-pane, .chat-head, .mr-body, .msg-row,
.composer-row, .composer-course, .composer-tools,
.post-head, .post-body, .post-actions {
  min-width: 0;
}

.rail-card { overflow-wrap: anywhere; }

/* The bleed-out hover pill needed a negative margin that made these rows wider
   than their card; flush padding keeps the same look without the overflow. */
.trend-row { margin: 0; padding: 7px 8px; }

/* Long unbroken strings (URLs, course codes, pasted text) must wrap, not push. */
.msg-text, .sr-name, .sr-reason, .ci-last, .ci-name, .ch-name, .cr-name,
.notif-body, .post-text, .card p, .rail-card p {
  overflow-wrap: anywhere;
}

/* Media can never be wider than its container. */
img, video, canvas, svg, iframe { max-width: 100%; }


/* StreamCampus Premium Visual Layer */
html[data-theme="dark"] body {
  background:
    radial-gradient(900px 520px at 18% -8%, rgba(245,158,11,.065), transparent 62%),
    radial-gradient(850px 560px at 92% 18%, rgba(124,58,237,.055), transparent 65%),
    var(--bg);
}
html[data-theme="light"] body {
  background:
    radial-gradient(900px 520px at 18% -8%, rgba(245,158,11,.08), transparent 62%),
    radial-gradient(850px 560px at 92% 18%, rgba(124,58,237,.055), transparent 65%),
    var(--bg);
}
.app-shell { gap: clamp(18px,2.2vw,32px); padding-inline: clamp(12px,2vw,28px); }
.main-col { padding-top: clamp(18px,2.2vw,30px); }
.brand-badge { position:relative; box-shadow:0 12px 34px -12px rgba(245,158,11,.62); }
.brand-badge::after { content:""; position:absolute; inset:-5px; border-radius:inherit; border:1px solid rgba(245,158,11,.18); pointer-events:none; }
.nav-item { min-height:46px; transition:background var(--dur) var(--ease),color var(--dur) var(--ease),transform var(--dur-fast) var(--ease); }
.nav-item:hover { transform:translateX(2px); }
.nav-item.active { background:linear-gradient(90deg,rgba(245,158,11,.11),rgba(245,158,11,.035) 72%,transparent),var(--surface-2); box-shadow:inset 0 0 0 1px rgba(245,158,11,.07); }
.nav-item.active::before { box-shadow:0 0 18px rgba(245,158,11,.42); }
.card,.rail-card,.chat-layout,.chat-calls { box-shadow:0 20px 60px -28px rgba(0,0,0,.72); }
.card { background:linear-gradient(180deg,rgba(255,255,255,.026),transparent 34%),color-mix(in srgb,var(--surface) 90%,transparent); border-color:rgba(255,255,255,.105); }
.card:hover { border-color:color-mix(in srgb,var(--line-strong) 80%,rgba(245,158,11,.22)); }
.composer { padding:18px 20px; background:radial-gradient(500px 180px at 0 0,rgba(245,158,11,.055),transparent 65%),linear-gradient(180deg,rgba(255,255,255,.022),transparent 55%),color-mix(in srgb,var(--surface) 92%,transparent); }
.composer:focus-within { border-color:rgba(245,158,11,.22); box-shadow:0 18px 60px -30px rgba(245,158,11,.22); }
.post-card { overflow:clip; transform:translateZ(0); transition:transform var(--dur-slow) var(--ease),box-shadow var(--dur-slow) var(--ease),border-color var(--dur) var(--ease); }
.post-card:hover { transform:translateY(-2px); box-shadow:0 28px 80px -28px rgba(0,0,0,.82); }
.post-head { padding-top:17px; }
.post-body { line-height:1.65; }
.post-media { margin-top:16px; position:relative; }
.post-media::after { content:""; position:absolute; inset:0; pointer-events:none; background:linear-gradient(180deg,transparent 70%,rgba(0,0,0,.13)); }
.btn { min-height:42px; letter-spacing:-.01em; }
.btn-primary { box-shadow:0 12px 26px -16px rgba(245,158,11,.78),inset 0 1px 0 rgba(255,255,255,.16); }
.btn-primary:hover { filter:brightness(1.06) saturate(1.04); box-shadow:0 16px 34px -16px rgba(245,158,11,.82),inset 0 1px 0 rgba(255,255,255,.18); }
.btn-ghost { background:color-mix(in srgb,var(--surface-2) 84%,transparent); }
.feed-tabs { gap:6px; padding:4px; width:fit-content; max-width:100%; border:1px solid var(--line); border-radius:var(--r-full); background:color-mix(in srgb,var(--surface-2) 72%,transparent); box-shadow:var(--shadow-1); }
.feed-tab { border-color:transparent; background:transparent; min-height:40px; }
.feed-tab.active { box-shadow:0 8px 22px -12px rgba(245,158,11,.75); }
.page-head { margin-bottom:22px; }
.page-head h1 { font-size:clamp(25px,1.2rem + 1vw,34px); letter-spacing:-.04em; }
.rail { gap:18px; }
.rail-card { padding:19px; border-color:rgba(255,255,255,.105); background:linear-gradient(180deg,rgba(255,255,255,.025),transparent 45%),color-mix(in srgb,var(--surface) 88%,transparent); }
.input,textarea.input,.chat-search { transition:border-color var(--dur) var(--ease),box-shadow var(--dur) var(--ease),background var(--dur) var(--ease); }
.input:focus,textarea.input:focus { box-shadow:0 0 0 3px rgba(245,158,11,.11),0 12px 30px -20px rgba(245,158,11,.45); }
.avatar { box-shadow:0 7px 20px -13px rgba(0,0,0,.75); }
.avatar img { transition:transform .35s var(--ease); }
.avatar:hover img { transform:scale(1.045); }
.chat-layout { box-shadow:0 20px 60px -28px rgba(0,0,0,.72); }
.chat-head { background:linear-gradient(180deg,rgba(255,255,255,.025),transparent),var(--surface); }
.chat-list { background:linear-gradient(180deg,rgba(255,255,255,.018),transparent 35%),var(--bg-soft); }
.convo-item { transition:background var(--dur) var(--ease),border-color var(--dur) var(--ease),transform var(--dur-fast) var(--ease); }
.convo-item:hover { transform:translateX(1px); }
.convo-item.active { background:linear-gradient(90deg,rgba(245,158,11,.075),transparent 78%),var(--surface); }
.msg-bubble { box-shadow:0 6px 18px -14px rgba(0,0,0,.72); }
.msg-row.mine .msg-bubble { box-shadow:0 10px 24px -16px rgba(245,158,11,.6); }
.auth-wrap { background:radial-gradient(900px 600px at 8% 0,rgba(245,158,11,.07),transparent 60%),var(--bg); }
.auth-hero { isolation:isolate; }
.auth-hero::before { content:""; position:absolute; width:520px; height:520px; right:-180px; top:12%; border-radius:50%; background:radial-gradient(circle,rgba(245,158,11,.18),transparent 68%); filter:blur(4px); animation:authFloat 12s ease-in-out infinite alternate; }
@keyframes authFloat { from{transform:translate3d(0,0,0) scale(1)} to{transform:translate3d(-30px,24px,0) scale(1.08)} }
.auth-card { max-width:440px; }
.auth-card h2 { font-size:clamp(27px,2vw,32px); }
.demo-hint { background:color-mix(in srgb,var(--surface-2) 55%,transparent); }
@media (max-width:900px) {
  .app-shell { display:block; padding-inline:12px; }
  .side-nav { display:none; }
  .mobile-header { display:flex; }
  .main-col { padding:16px 0 88px; }
  .rail-col { display:none; }
  .post-card + .post-card { margin-top:12px; }
  .auth-wrap { grid-template-columns:1fr; }
  .auth-hero { min-height:42dvh; padding:34px 24px; }
}
@media (max-width:560px) {
  .app-shell { padding-inline:8px; }
  .main-col { padding-top:12px; }
  .card { border-radius:17px; }
  .post-head,.post-body { padding-inline:14px; }
  .composer { padding:14px; }
  .feed-tabs { width:100%; overflow-x:auto; }
  .feed-tab { flex:0 0 auto; }
  .auth-hero { min-height:34dvh; padding:26px 20px; }
  .auth-hero-copy h1 { font-size:30px; }
}
@media (prefers-reduced-motion:reduce) {
  *,*::before,*::after { animation-duration:.01ms !important; animation-iteration-count:1 !important; scroll-behavior:auto !important; transition-duration:.01ms !important; }
}
@media (hover:none) {
  .post-card:hover,.nav-item:hover,.convo-item:hover { transform:none; }
}


/* Network status: quiet by default, unmistakable only when connectivity changes. */
.network-status {
  position: fixed;
  z-index: 1200;
  left: 50%;
  top: 14px;
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: min(92vw, 520px);
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  color: var(--text);
  box-shadow: 0 18px 48px -24px rgba(0,0,0,.7), 0 0 0 1px rgba(255,255,255,.035);
  backdrop-filter: blur(18px) saturate(1.15);
  -webkit-backdrop-filter: blur(18px) saturate(1.15);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -12px) scale(.98);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.network-status.is-offline,
.network-status.is-online {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}
.network-status.is-offline {
  border-color: color-mix(in srgb, var(--accent-2) 32%, var(--line-strong));
}
.network-status.is-online {
  border-color: color-mix(in srgb, #22c55e 34%, var(--line-strong));
}
.network-status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 4px rgba(34,197,94,.10), 0 0 14px rgba(34,197,94,.38);
}
.network-status.is-offline .network-status-dot {
  background: var(--accent-2);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent-2) 12%, transparent), 0 0 14px color-mix(in srgb, var(--accent-2) 36%, transparent);
}
.network-status-copy {
  min-width: 0;
  font-size: 12.5px;
  line-height: 1.35;
  font-weight: 700;
  letter-spacing: -.01em;
}
@media (max-width:560px) {
  .network-status { top: 9px; padding: 9px 12px; }
  .network-status-copy { font-size: 12px; }
}

/* ───────────────────────── cartoons (public-domain shelf) ───────────────────────── */
.toon-rails { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; scrollbar-width: none; }
.toon-rails::-webkit-scrollbar { display: none; }
.toon-chip {
  flex: 0 0 auto; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text-2); font: inherit; font-size: 13px; font-weight: 700;
  cursor: pointer; transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.toon-chip:hover { background: var(--surface-2); color: var(--text); }
.toon-chip.active { background: var(--grad-brand); border-color: transparent; color: #fff; }

.toon-search {
  display: flex; align-items: center; gap: 9px; padding: 10px 14px; margin-bottom: 14px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--surface);
}
.toon-search .icn { color: var(--text-3); display: inline-flex; }
.toon-search .icn svg { width: 17px; height: 17px; }
.toon-search input { flex: 1; border: 0; background: transparent; color: var(--text); font: inherit; font-size: 14.5px; outline: none; }

.toon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; margin-bottom: 16px; }
.toon-card { display: flex; flex-direction: column; gap: 9px; padding: 0; border: 0; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.toon-thumb { position: relative; display: block; aspect-ratio: 4 / 3; border-radius: 14px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); }
.toon-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform var(--dur-slow) var(--ease); }
.toon-card:hover .toon-thumb img { transform: scale(1.05); }
.toon-play { position: absolute; right: 10px; bottom: 10px; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--grad-brand); color: #fff; box-shadow: var(--shadow-2); }
.toon-play svg { width: 15px; height: 15px; }
.toon-meta { display: flex; flex-direction: column; gap: 2px; padding: 0 2px; }
.toon-title { font-weight: 700; font-size: 14px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.toon-sub { font-size: 12.5px; color: var(--text-3); }

.toon-player .page-head { gap: 10px; }
.toon-stage { border-radius: 18px; overflow: hidden; background: #000; border: 1px solid var(--line); margin-bottom: 14px; }
.toon-stage video { width: 100%; max-height: 70vh; background: #000; }
.toon-about { padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.toon-line { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; font-weight: 700; color: var(--text-2); }
.toon-license { color: var(--accent); }
.toon-credits { margin: 0; font-size: 13px; color: var(--text-3); }
.toon-desc { margin: 0; font-size: 14px; color: var(--text-2); }
@media (max-width: 520px) { .toon-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 11px; } }
