/* Ezra - StarzHive family assistant. First-party stylesheet (CSP: style-src 'self'; no inline styles).
   Design tokens -> layout (topbar, rail, workspace, context) -> conversation -> cards -> composer -> pages -> mobile. */

/* ------------------------------------------------------------------ tokens */
:root {
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --bg: #f6f5fc;
  --bg-tint: #efeefb;
  --surface: #ffffff;
  --surface-2: #f4f3fb;
  --surface-3: #ebe9f7;
  --line: #e8e6f3;
  --line-strong: #d8d5ea;
  --ink: #191a2e;
  --ink-2: #3c3f58;
  --muted: #696c85;
  --brand: #5850ec;
  --brand-ink: #4338ca;
  --brand-soft: #efeeff;
  --brand-grad: linear-gradient(135deg, #8b7cf6 0%, #5850ec 52%, #3a9bf0 100%);
  --user-bubble: #eceeff;
  --brand-word: #1f2a6b;
  --ezra-bubble: #ffffff;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --warn-soft: #fff7e8;
  --warn-line: #f6dfae;
  --focus: 0 0 0 3px rgba(88, 80, 236, .3);
  --shadow-sm: 0 1px 2px rgba(25, 24, 66, .05), 0 1px 3px rgba(25, 24, 66, .04);
  --shadow-md: 0 6px 20px -8px rgba(25, 24, 66, .14), 0 2px 5px rgba(25, 24, 66, .04);
  --shadow-lg: 0 24px 60px -16px rgba(25, 24, 66, .30);
  --t-green: #15803d;  --t-green-bg: #e7f6ec;
  --t-blue: #1d4ed8;   --t-blue-bg: #e7efff;
  --t-pink: #be185d;   --t-pink-bg: #fde9f2;
  --t-violet: #6d28d9; --t-violet-bg: #f0e9ff;
  --t-amber: #b45309;  --t-amber-bg: #fdf1df;
  --r-sm: 10px; --r-md: 14px; --r-lg: 18px; --r-xl: 24px;
  --topbar-h: 64px;
  --rail-w: 280px;
  --ctx-w: 320px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1021; --bg-tint: #14163a; --surface: #171a31; --surface-2: #1d2142; --surface-3: #262b52;
    --line: #262a4a; --line-strong: #353b66; --ink: #eceefb; --ink-2: #c8cbe6; --muted: #9a9ec0;
    --brand: #8d86ff; --brand-ink: #b8b4ff; --brand-soft: #23264f; --user-bubble: #2a2d5e; --ezra-bubble: #1a1e38; --brand-word: #eceefb;
    --danger: #f87171; --danger-soft: #3a1d26; --warn-soft: #2e2615; --warn-line: #5a4a22;
    --focus: 0 0 0 3px rgba(141, 134, 255, .38);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35); --shadow-md: 0 8px 24px -10px rgba(0, 0, 0, .6);
    --shadow-lg: 0 24px 60px -16px rgba(0, 0, 0, .7);
    --t-green: #4ade80;  --t-green-bg: rgba(34, 197, 94, .14);
    --t-blue: #7aa7ff;   --t-blue-bg: rgba(59, 130, 246, .16);
    --t-pink: #f472b6;   --t-pink-bg: rgba(236, 72, 153, .15);
    --t-violet: #b69bff; --t-violet-bg: rgba(139, 92, 246, .17);
    --t-amber: #fbbf24;  --t-amber-bg: rgba(245, 158, 11, .14);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1021; --surface: #171a31; --surface-2: #1d2142; --surface-3: #262b52; --line: #262a4a; --line-strong: #353b66;
  --ink: #eceefb; --ink-2: #c8cbe6; --muted: #9a9ec0; --brand: #8d86ff; --brand-ink: #b8b4ff; --brand-soft: #23264f;
  --user-bubble: #2a2d5e; --ezra-bubble: #1a1e38; --brand-word: #eceefb; color-scheme: dark;
}

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 400 16px/1.6 var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased;
       text-rendering: optimizeLegibility; }
a { color: var(--brand-ink); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--brand); }
img { max-width: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
h1, h2, h3, h4 { letter-spacing: -.012em; line-height: 1.25; margin: 0; }
h1 { font-size: 28px; font-weight: 700; }
h2 { font-size: 18px; font-weight: 650; }
h3 { font-size: 16px; font-weight: 650; }
p { margin: 0 0 .75em; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 8px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; margin: -1px; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--surface); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow-md); }
.skip:focus { top: 12px; }
.i { width: 20px; height: 20px; flex: none; display: inline-block; vertical-align: middle; }
.i-sm { width: 16px; height: 16px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.strong { font-weight: 600; }
.spaced { margin-top: 10px; }
.inline-form { display: inline; margin: 0; }
.stack { display: grid; gap: 10px; margin-top: 12px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

/* ------------------------------------------------------------------ buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 16px;
       border-radius: 12px; border: 1px solid transparent; background: var(--surface-2); color: var(--ink); font-weight: 600;
       font-size: 15px; text-decoration: none; cursor: pointer; transition: background .15s, box-shadow .15s, transform .05s, border-color .15s; }
.btn:hover { color: inherit; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand-grad); color: #fff; box-shadow: 0 6px 16px -6px rgba(88, 80, 236, .55); }
.btn-primary:hover { color: #fff; filter: brightness(1.05); }
.btn-soft { background: var(--brand-soft); color: var(--brand-ink); border-color: transparent; }
.btn-soft:hover { color: var(--brand-ink); background: color-mix(in srgb, var(--brand-soft) 70%, var(--brand) 12%); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { display: flex; width: 100%; }
.btn.small, .btn-ghost.small { min-height: 34px; padding: 6px 12px; font-size: 14px; }
.btn-ghost { display: inline-flex; align-items: center; gap: 8px; border: 0; background: transparent; color: var(--muted); cursor: pointer; border-radius: 10px; font-weight: 500; }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-link { border: 0; background: none; color: var(--brand-ink); padding: 0; cursor: pointer; font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; border: 0; background: transparent;
            color: var(--ink-2); cursor: pointer; text-decoration: none; transition: background .15s, color .15s; flex: none; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn.sm { width: 32px; height: 32px; border-radius: 10px; }
.icon-btn .i { width: 21px; height: 21px; }

/* ------------------------------------------------------------------ top bar (StarzHive) */
.topbar { position: sticky; top: 0; z-index: 30; height: var(--topbar-h); display: flex; align-items: center; gap: 18px;
          padding: 0 20px; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: saturate(1.4) blur(14px);
          -webkit-backdrop-filter: saturate(1.4) blur(14px); border-bottom: 1px solid var(--line); }
.topbar-menu { display: none; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); flex: none; }
.brand:hover { color: var(--ink); }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; background: var(--brand-grad); color: #fff;
              box-shadow: 0 6px 14px -6px rgba(88, 80, 236, .6); }
.brand-mark .i { width: 21px; height: 21px; fill: rgba(255, 255, 255, .22); }
.brand-text { display: grid; line-height: 1.1; }
.brand-name { font-size: 20px; font-weight: 800; letter-spacing: -.02em; color: var(--brand-word); }
.brand-name span { color: var(--brand); }
.brand-tag { font-size: 10.5px; color: var(--muted); letter-spacing: .01em; }
.topnav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.topnav a { display: grid; justify-items: center; gap: 2px; min-width: 76px; padding: 7px 10px; border-radius: 12px; color: var(--muted);
            text-decoration: none; font-size: 12.5px; font-weight: 500; }
.topnav a .i { width: 22px; height: 22px; }
.topnav a:hover { background: var(--surface-2); color: var(--ink); }
.topnav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand-ink); font-weight: 650; }
.topnav-ezra img { width: 24px; height: 24px; border-radius: 50%; }
.topbar-end { display: flex; align-items: center; gap: 8px; margin-left: 8px; }

/* ------------------------------------------------------------------ app grid */
.app { display: grid; min-height: calc(100dvh - var(--topbar-h)); }
.app-page { grid-template-columns: var(--rail-w) minmax(0, 1fr); }
.app-workspace { grid-template-columns: var(--rail-w) minmax(0, 1fr) var(--ctx-w); height: calc(100dvh - var(--topbar-h)); }
.main { min-width: 0; outline: none; }
.app-workspace .main { display: flex; min-height: 0; }

/* ------------------------------------------------------------------ rail */
.rail { position: sticky; top: var(--topbar-h); height: calc(100dvh - var(--topbar-h)); overflow-y: auto; overscroll-behavior: contain;
        display: flex; flex-direction: column; gap: 6px; padding: 18px 14px 14px; background: var(--surface); border-right: 1px solid var(--line);
        scrollbar-width: thin; }
.rail-mobile-head, .rail-starzhive { display: none; }
.btn-new { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 48px; border: 0; border-radius: 14px;
           background: var(--brand-grad); color: #fff; font-weight: 650; font-size: 15.5px; cursor: pointer; text-decoration: none;
           box-shadow: 0 10px 22px -10px rgba(88, 80, 236, .75); transition: filter .15s, transform .05s; }
.btn-new:hover { color: #fff; filter: brightness(1.06); }
.btn-new:active { transform: translateY(1px); }
.rail-new { margin: 0 0 6px; }
.rail-section { margin-top: 10px; }
.rail-label { font-size: 11.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); margin: 8px 10px 6px; }
.threads { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.thread { display: flex; gap: 10px; align-items: flex-start; padding: 9px 10px; border-radius: 12px; text-decoration: none; color: var(--ink); }
.thread:hover { background: var(--surface-2); color: var(--ink); }
.thread[aria-current="page"] { background: var(--brand-soft); }
.thread-icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 9px; background: var(--surface-2); color: var(--brand); flex: none; margin-top: 1px; }
.thread[aria-current="page"] .thread-icon { background: var(--surface); }
.thread-icon .i { width: 15px; height: 15px; }
.thread-text { display: grid; min-width: 0; }
.thread-title { font-size: 14.5px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread[aria-current="page"] .thread-title { color: var(--brand-ink); font-weight: 650; }
.thread-when { font-size: 12.5px; color: var(--muted); }
.threads-empty { font-size: 13.5px; color: var(--muted); padding: 6px 10px 2px; }
.rail-recent .threads { max-height: 38vh; overflow-y: auto; scrollbar-width: thin; }
.rail-messages { display: flex; align-items: center; gap: 10px; padding: 10px; margin-top: 4px; border-radius: 12px; color: var(--ink-2);
                 text-decoration: none; font-size: 14px; font-weight: 550; border: 1px dashed var(--line-strong); }
.rail-messages:hover { background: var(--surface-2); color: var(--ink); }
.rail-messages .i-sm { margin-left: auto; color: var(--muted); }
.tools { display: grid; gap: 2px; }
.tools a, .rail-foot a, .rail-signout { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 12px; color: var(--ink-2);
                                        text-decoration: none; font-size: 15px; font-weight: 500; border: 0; background: none; width: 100%; cursor: pointer; text-align: left; }
.tools a .i, .rail-foot .i { color: var(--muted); }
.tools a:hover, .rail-foot a:hover, .rail-signout:hover { background: var(--surface-2); color: var(--ink); }
.tools a[aria-current="page"], .rail-foot a[aria-current="page"] { background: var(--brand-soft); color: var(--brand-ink); font-weight: 650; }
.tools a[aria-current="page"] .i { color: var(--brand); }
.rail-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); display: grid; gap: 2px; }
.rail-foot a, .rail-signout { font-size: 14px; padding: 8px 10px; }

/* ------------------------------------------------------------------ conversation */
.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative;
        background: radial-gradient(1200px 380px at 50% -140px, color-mix(in srgb, var(--brand) 9%, transparent), transparent 70%), var(--bg); }
.chat-head { display: flex; align-items: center; gap: 10px; height: 68px; padding: 0 20px; border-bottom: 1px solid var(--line);
             background: color-mix(in srgb, var(--surface) 72%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); flex: none; }
.chat-id { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.avatar { width: 40px; height: 40px; border-radius: 50%; flex: none; box-shadow: 0 4px 12px -4px rgba(88, 80, 236, .5); }
.chat-id-text { min-width: 0; }
.chat-title { font-size: 17px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-sub { font-size: 13px; color: var(--muted); }
.chat-actions { display: flex; align-items: center; gap: 2px; }
.ctx-toggle { display: none; }
.only-compact { display: none; }
.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu-pop { position: absolute; right: 0; top: 46px; z-index: 20; width: 300px; background: var(--surface); border: 1px solid var(--line);
            border-radius: 16px; box-shadow: var(--shadow-lg); padding: 14px; }
.rename-form { display: grid; gap: 8px; }
.rename-form label { font-size: 13px; font-weight: 600; color: var(--muted); }
.rename-form input { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); }

.chat-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scroll-behavior: smooth; position: relative; }
.chat-inner { max-width: 820px; margin: 0 auto; padding: 28px 28px 24px; }
.stream { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }

.hero { text-align: center; padding: 28px 8px 26px; }
.hero-art { width: 104px; height: 104px; margin: 0 auto 16px; border-radius: 50%; display: grid; place-items: center;
            background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--brand) 22%, transparent), transparent 70%); }
.hero-art img { width: 88px; height: 88px; border-radius: 50%; box-shadow: 0 16px 36px -14px rgba(88, 80, 236, .7); animation: float 6s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-5px); } }
.hero-title { font-size: 30px; font-weight: 750; letter-spacing: -.02em; max-width: 560px; margin: 0 auto; }
.hero-sub { color: var(--muted); max-width: 520px; margin: 10px auto 0; font-size: 16px; }
.hero-values { display: inline-flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; margin-top: 16px; font-size: 13.5px; color: var(--muted); }
.hero-values span + span::before { content: "•"; margin-right: 14px; color: var(--line-strong); }
.starters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 8px; }
.starter { display: flex; gap: 14px; align-items: flex-start; padding: 16px; border-radius: var(--r-lg); background: var(--surface);
           border: 1px solid var(--line); box-shadow: var(--shadow-sm); text-decoration: none; color: var(--ink); transition: border-color .15s, box-shadow .15s, transform .15s; }
.starter:hover { color: var(--ink); border-color: color-mix(in srgb, var(--brand) 35%, var(--line)); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.starter-text { display: grid; gap: 2px; }
.starter-title { font-weight: 650; font-size: 15px; }
.starter-body { font-size: 13.5px; color: var(--muted); line-height: 1.45; }

.msg { display: flex; gap: 12px; animation: rise .22s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.msg-user { justify-content: flex-end; }
.msg-user .bubble { max-width: min(78%, 620px); background: var(--user-bubble); color: var(--ink); padding: 12px 16px; border-radius: 20px 20px 6px 20px;
                    display: grid; gap: 8px; }
.msg-user .text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-avatar { width: 36px; height: 36px; border-radius: 50%; flex: none; margin-top: 2px; }
.msg-body { min-width: 0; flex: 1; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.prose { background: var(--ezra-bubble); border: 1px solid var(--line); border-radius: 6px 20px 20px 20px; padding: 14px 18px; box-shadow: var(--shadow-sm);
         overflow-wrap: anywhere; justify-self: start; max-width: 100%; }
.prose > :last-child { margin-bottom: 0; }
.prose p { margin: 0 0 .7em; }
.prose h4 { font-size: 16px; margin: .9em 0 .35em; }
.prose h4:first-child { margin-top: 0; }
.prose ul, .prose ol { margin: .2em 0 .8em; padding-left: 1.3em; }
.prose li { margin: .25em 0; }
.prose li::marker { color: var(--brand); }
.prose code { font-size: .9em; background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }
.prose pre { background: var(--surface-2); padding: 12px; border-radius: 12px; overflow-x: auto; }
.prose strong { font-weight: 650; }
.msg-notice { align-items: flex-start; gap: 12px; background: var(--warn-soft); border: 1px solid var(--warn-line); border-radius: 16px; padding: 12px 14px; }
.msg-notice p { margin: 2px 0 0; font-size: 14.5px; color: var(--ink-2); }
.notice-icon { color: var(--t-amber); margin-top: 1px; }

.file-chip { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; min-width: 220px; }
.file-chip-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: var(--t-blue-bg); color: var(--t-blue); flex: none; }
.file-chip.voice .file-chip-icon { background: var(--t-violet-bg); color: var(--t-violet); }
.file-chip-text { display: grid; min-width: 0; flex: 1; }
.file-chip-name { font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-chip-meta { font-size: 12.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.photo-thumb img { display: block; max-height: 260px; border-radius: 14px; border: 1px solid var(--line); }
.is-uploading .bubble { opacity: .9; }

.pending { display: flex; gap: 12px; align-items: flex-start; margin-top: 18px; }
.pending[hidden] { display: none; }
.pending-bubble { display: inline-flex; align-items: center; gap: 12px; background: var(--ezra-bubble); border: 1px solid var(--line);
                  border-radius: 6px 20px 20px 20px; padding: 12px 16px; box-shadow: var(--shadow-sm); color: var(--ink-2); font-size: 15px; }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); opacity: .35; animation: blink 1.2s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .18s; } .dots i:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 40% { opacity: 1; transform: translateY(-2px); } }
.pending[data-phase="failed"] .dots { display: none; }
.pending[data-phase="failed"] .pending-bubble { border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); background: var(--danger-soft); }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid color-mix(in srgb, var(--brand) 25%, transparent); border-top-color: var(--brand);
           animation: spin .8s linear infinite; display: inline-block; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.jump { position: sticky; bottom: 12px; left: 50%; transform: translateX(-50%); display: inline-flex; align-items: center; gap: 6px; margin: 0 auto; z-index: 3;
        border: 0; border-radius: 999px; padding: 8px 14px; background: var(--ink); color: var(--surface); font-weight: 600; font-size: 13.5px; box-shadow: var(--shadow-md); cursor: pointer; }
.jump[hidden] { display: none; }

/* ------------------------------------------------------------------ cards */
.cards { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; min-width: 0; }
.card-icon { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; flex: none; }
.card-icon.sm { width: 32px; height: 32px; border-radius: 10px; }
.card-icon.sm .i { width: 17px; height: 17px; }
.tone-green { background: var(--t-green-bg); color: var(--t-green); }
.tone-blue { background: var(--t-blue-bg); color: var(--t-blue); }
.tone-pink { background: var(--t-pink-bg); color: var(--t-pink); }
.tone-violet { background: var(--t-violet-bg); color: var(--t-violet); }
.tone-amber { background: var(--t-amber-bg); color: var(--t-amber); }
.cards .card, .card-group { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px; box-shadow: var(--shadow-sm); margin: 0; }
.card-head { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.card-head-text { min-width: 0; }
.card-kicker { font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.card-title { font-size: 16px; font-weight: 650; overflow-wrap: anywhere; }
.card-body { color: var(--ink-2); font-size: 15px; margin: 0 0 10px; }
.card-note { color: var(--muted); font-size: 14px; margin: 6px 0 0; }
.card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 13.5px; color: var(--muted); margin: 8px 0 0; }
.card-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.card-actions .btn { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: var(--brand-soft); color: var(--brand-ink); }
.tag-plain { background: var(--surface-2); color: var(--muted); }
.visual-thumb { display: block; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); background: #fff; }
.visual-thumb img { display: block; width: 100%; max-height: 420px; object-fit: contain; background: #fff; }
.visual-skeleton { display: flex; align-items: center; justify-content: center; gap: 10px; height: 180px; border-radius: 14px; color: var(--muted); font-weight: 550;
                   background: linear-gradient(100deg, var(--surface-2) 30%, var(--surface-3) 50%, var(--surface-2) 70%); background-size: 300% 100%; animation: shimmer 1.6s infinite linear; }
@keyframes shimmer { to { background-position: -150% 0; } }

.group-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.group-head h3 { font-size: 16px; color: var(--brand-ink); }
.group-count { margin-left: auto; font-size: 13px; color: var(--muted); white-space: nowrap; }
.group-note { font-size: 13px; color: var(--muted); margin: 12px 0 0; }
.provider-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.provider { display: flex; flex-direction: column; gap: 8px; padding: 14px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface); }
.provider-top { display: flex; gap: 10px; align-items: center; }
.monogram { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; background: var(--brand-grad); color: #fff; font-weight: 700; font-size: 17px; flex: none; }
.monogram.lg { width: 48px; height: 48px; font-size: 20px; }
.provider-id { min-width: 0; }
.provider-id h4 { font-size: 15px; font-weight: 650; line-height: 1.3; }
.provider-cat { font-size: 13px; color: var(--muted); }
.provider-meta { font-size: 13px; color: var(--ink-2); line-height: 1.45; }
.provider-ok { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--t-green); font-weight: 600; }
.provider-found { font-size: 12.5px; color: var(--muted); }
.provider .btn { margin-top: auto; min-height: 40px; font-size: 14px; }

/* ------------------------------------------------------------------ composer dock */
.dock { flex: none; padding: 10px 24px max(12px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px;
        background: linear-gradient(to bottom, transparent, var(--bg) 22px); }
.dock > * { width: 100%; max-width: 772px; margin: 0 auto; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; scrollbar-width: none; order: 2; padding: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; padding: 7px 13px; border-radius: 999px; font-size: 13.5px; font-weight: 600;
        border: 1px solid transparent; text-decoration: none; cursor: pointer; transition: filter .15s, transform .05s; }
.chip:hover { filter: brightness(.97); }
.chip:active { transform: translateY(1px); }
.composer { order: 1; position: relative; background: var(--surface); border: 1.5px solid var(--line-strong); border-radius: 26px; padding: 6px;
            box-shadow: var(--shadow-md); transition: border-color .15s, box-shadow .15s; }
.composer:focus-within { border-color: color-mix(in srgb, var(--brand) 55%, var(--line-strong)); box-shadow: var(--shadow-md), var(--focus); }
.composer-row { display: flex; align-items: flex-end; gap: 4px; }
.composer textarea { flex: 1; min-width: 0; border: 0; outline: none; resize: none; background: transparent; font-size: 16px; line-height: 1.5;
                     padding: 9px 6px; max-height: 220px; min-height: 42px; }
.composer textarea::placeholder { color: var(--muted); }
.composer .icon-btn { border-radius: 50%; width: 42px; height: 42px; }
.send { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--brand-grad); color: #fff; cursor: pointer; flex: none;
        box-shadow: 0 8px 18px -8px rgba(88, 80, 236, .8); transition: opacity .15s, transform .1s; }
.send:disabled { opacity: .45; cursor: default; box-shadow: none; }
.send:not(:disabled):active { transform: scale(.95); }
.attach { position: relative; }
.attach-menu { position: absolute; bottom: 52px; left: 0; z-index: 25; min-width: 230px; background: var(--surface); border: 1px solid var(--line);
               border-radius: 16px; box-shadow: var(--shadow-lg); padding: 6px; display: grid; }
.attach-menu[hidden] { display: none; }
.attach-menu button { display: flex; align-items: center; gap: 12px; border: 0; background: none; padding: 10px 12px; border-radius: 10px; cursor: pointer; text-align: left; font-weight: 550; }
.attach-menu button:hover { background: var(--surface-2); }
.attach-menu small { display: block; font-weight: 400; color: var(--muted); font-size: 12.5px; }
.only-touch { display: none !important; }
@media (hover: none) and (pointer: coarse) { .attach-menu .only-touch { display: flex !important; } }
.composer-file { display: flex; align-items: center; gap: 10px; margin: 4px 4px 6px; padding: 8px 8px 8px 10px; background: var(--surface-2); border-radius: 16px; }
.composer-file[hidden] { display: none; }
.composer-file .file-chip-icon { width: 34px; height: 34px; }
.composer-file img.preview { width: 34px; height: 34px; border-radius: 8px; object-fit: cover; }
.recorder { display: flex; align-items: center; gap: 12px; padding: 4px 4px 4px 6px; }
.recorder[hidden] { display: none; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #ef4444; animation: blink 1.2s infinite; }
.rec-time { font-variant-numeric: tabular-nums; font-weight: 650; min-width: 42px; }
.rec-level { flex: 1; display: flex; align-items: center; gap: 3px; height: 28px; overflow: hidden; }
.rec-level i { width: 4px; height: 6px; border-radius: 2px; background: color-mix(in srgb, var(--brand) 70%, transparent); transition: height .08s; }
.rec-label { color: var(--muted); font-size: 14px; }
.upload-progress { height: 3px; margin: 2px 16px 0; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.upload-progress[hidden] { display: none; }
.upload-progress span { display: block; height: 100%; width: 0; background: var(--brand-grad); transition: width .2s; }
.consent-prompt form { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: space-between; background: var(--warn-soft); border: 1px solid var(--warn-line);
                       border-radius: 16px; padding: 10px 12px 10px 14px; font-size: 14px; color: var(--ink-2); }
.consent-prompt form span { display: inline-flex; align-items: center; gap: 8px; flex: 1; min-width: 200px; }
.consent-prompt[hidden] { display: none; }
.dock-note { order: 3; text-align: center; font-size: 12px; color: var(--muted); margin: 0 auto; }

/* ------------------------------------------------------------------ context panel */
.context { position: sticky; top: var(--topbar-h); height: calc(100dvh - var(--topbar-h)); overflow-y: auto; overscroll-behavior: contain; padding: 18px 16px 24px;
           display: flex; flex-direction: column; gap: 14px; border-left: 1px solid var(--line); background: var(--bg); scrollbar-width: thin; }
.context-head { display: none; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.panel-head a { font-size: 13px; font-weight: 600; text-decoration: none; }
.panel-title { font-size: 15px; font-weight: 700; margin: 0 0 10px; }
.panel-empty { font-size: 13.5px; color: var(--muted); margin: 0; line-height: 1.5; }
.glance-row { display: flex; align-items: center; gap: 12px; }
.panel-head .panel-title { margin-bottom: 10px; }
.glance-id { flex: 1; min-width: 0; }
.glance-name { font-weight: 700; font-size: 16px; overflow-wrap: anywhere; }
.glance-sub { font-size: 13px; color: var(--muted); }
.glance-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.glance-stats a { display: grid; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); text-decoration: none; color: var(--ink); }
.glance-stats strong { font-size: 20px; line-height: 1.1; }
.glance-stats span { font-size: 12.5px; color: var(--muted); }
.actions, .files, .today { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.actions a, .actions button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 7px 8px; border-radius: 10px; border: 0; background: none;
                              color: var(--ink-2); text-decoration: none; font-size: 14.5px; font-weight: 550; cursor: pointer; text-align: left; }
.actions a:hover, .actions button:hover { background: var(--surface-2); color: var(--ink); }
.files a { display: flex; align-items: center; gap: 12px; padding: 7px 8px; border-radius: 10px; text-decoration: none; color: var(--ink); }
.files a:hover { background: var(--surface-2); }
.files-text { display: grid; min-width: 0; }
.files-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.files-when { font-size: 12.5px; color: var(--muted); }
.today li { display: grid; grid-template-columns: 22px 70px 1fr; align-items: center; gap: 8px; padding: 7px 4px; font-size: 14px; border-radius: 10px; }
.today-check { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line-strong); color: #fff; }
.today .is-done .today-check { background: #22c55e; border-color: #22c55e; }
.today-time { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; }
.today .is-done .today-text { color: var(--muted); }

/* ------------------------------------------------------------------ pages (My Family tools) */
.page { max-width: 920px; margin: 0 auto; padding: 32px 32px 40px; }
.page > h2 { margin: 28px 0 12px; font-size: 18px; }
.page-head { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 22px; }
.page-icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 16px; flex: none; }
.page-icon .i { width: 26px; height: 26px; }
.page-head h1 { font-size: 28px; }
.lead { color: var(--muted); margin: 6px 0 0; max-width: 700px; }
.page > .btn { margin-bottom: 18px; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px; margin-bottom: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px 20px; margin: 0 0 12px; box-shadow: var(--shadow-sm); }
.card h3 { margin: 0 0 6px; }
.card.muted { color: var(--muted); }
.card-link { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); margin-bottom: 4px; }
.card-link:hover h3 { color: var(--brand-ink); }
.card-link h3 { margin: 0; }
.card-danger { border-color: color-mix(in srgb, var(--danger) 30%, var(--line)); }
.row-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.row-card .card-actions { margin-top: 0; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid .card { margin: 0; }
.pill { display: inline-block; font-size: 12.5px; font-weight: 600; padding: 2px 10px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-ink); }
.pill.soft { background: var(--surface-2); color: var(--ink-2); }
.quote { color: var(--ink-2); font-style: italic; }
.day { color: var(--muted); font-size: 13px; min-width: 62px; display: inline-block; font-variant-numeric: tabular-nums; }
ul.plain { list-style: none; padding: 0; margin: 8px 0 0; }
ul.plain li { padding: 9px 0; border-bottom: 1px solid var(--line); }
ul.plain li:last-child { border-bottom: 0; }
.body-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.banner { display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; background: var(--warn-soft); border: 1px solid var(--warn-line);
          border-radius: var(--r-lg); padding: 14px 18px; margin: 0 0 16px; }
.banner-actions { display: flex; align-items: center; gap: 14px; margin: 0; }
.empty { text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl); padding: 40px 24px; box-shadow: var(--shadow-sm); margin: 6px 0 16px; }
.empty-art { display: inline-grid; place-items: center; width: 72px; height: 72px; border-radius: 22px; margin-bottom: 14px; }
.empty-art .i { width: 32px; height: 32px; }
.empty-art img { border-radius: 50%; }
.empty h1, .empty h2 { font-size: 21px; margin-bottom: 8px; }
.empty p { color: var(--muted); max-width: 520px; margin: 0 auto 16px; }
.trust { display: flex; gap: 10px; align-items: flex-start; color: var(--muted); font-size: 13px; margin-top: 36px; border-top: 1px solid var(--line); padding-top: 16px; }
.trust .i-sm { margin-top: 2px; }
.page-grid { margin-top: 8px; }
.visual-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.visual-tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; }
.visual-tile .visual-thumb { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; aspect-ratio: 4 / 3; }
.visual-tile .visual-thumb img { height: 100%; max-height: none; }
.visual-tile-body { padding: 14px 16px 16px; }
.visual-tile-body h3 { font-size: 16px; }
.visual-full { margin: 18px 0 0; background: #fff; border: 1px solid var(--line); border-radius: var(--r-xl); padding: 12px; box-shadow: var(--shadow-sm); }
.visual-full img { display: block; width: 100%; height: auto; border-radius: 12px; }
.legacy-msg { margin: 10px 0; } .legacy-msg .who { font-size: 12px; color: var(--muted); }
.legacy-msg .bubble { display: inline-block; padding: 10px 14px; border-radius: 14px; background: var(--surface-2); white-space: pre-wrap; max-width: 100%; overflow-wrap: anywhere; }
.legacy-msg.you .bubble { background: var(--user-bubble); }
.working { color: var(--muted); font-style: italic; margin-top: 8px; }
.legacy-chat { display: flex; gap: 8px; margin-top: 14px; }
.legacy-chat input, .stack input { flex: 1; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface); }

/* ------------------------------------------------------------------ login + print */
.login-page { min-height: 100dvh; display: grid; place-items: center; padding: 20px;
              background: radial-gradient(800px 400px at 50% 0, color-mix(in srgb, var(--brand) 14%, transparent), transparent 70%), var(--bg); }
.login-box { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl); padding: 32px 28px; text-align: center; box-shadow: var(--shadow-lg); }
.login-avatar { border-radius: 50%; margin-bottom: 10px; }
.login-box h1 { font-size: 26px; }
.login-box .muted { margin: 8px 0 18px; }
.login-box .stack { text-align: left; }
.login-err { background: var(--danger-soft); color: var(--danger); padding: 9px 12px; border-radius: 10px; font-size: 14px; margin-bottom: 12px; }
.print-page { background: #fff; color: #111; }
.print-bar { position: sticky; top: 0; display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.print-title { flex: 1; font-weight: 650; }
.print-img { display: block; max-width: 100%; margin: 16px auto; }
@media print {
  .no-print, .topbar, .rail, .context, .dock, .chat-head { display: none !important; }
  .print-page { margin: 0; }
  .print-img { margin: 0 auto; max-height: 100vh; }
}

/* ------------------------------------------------------------------ toast + drawers */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; max-width: min(92vw, 460px); background: var(--ink); color: var(--surface);
         padding: 12px 16px; border-radius: 14px; box-shadow: var(--shadow-lg); font-size: 14.5px; }
.toast[hidden] { display: none; }
.scrim { position: fixed; inset: 0; z-index: 40; background: rgba(15, 16, 33, .45); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }
.scrim[hidden] { display: none; }

/* ---- 1200px and below: context panel becomes a side sheet */
@media (max-width: 1239px) {
  .app-workspace { grid-template-columns: var(--rail-w) minmax(0, 1fr); }
  .ctx-toggle { display: inline-grid; }
  .context { position: fixed; top: 0; right: 0; bottom: 0; height: 100dvh; width: min(380px, 92vw); z-index: 50; background: var(--bg); border-left: 1px solid var(--line);
             box-shadow: var(--shadow-lg); transform: translateX(105%); transition: transform .25s ease; visibility: hidden; }
  .context-head { display: flex; align-items: center; justify-content: space-between; }
  .context-head h2 { font-size: 17px; }
  body.ctx-open .context, .context:target { transform: none; visibility: visible; }
}

/* ---- 900px and below: rail becomes a drawer; conversation takes the screen */
@media (max-width: 899px) {
  :root { --topbar-h: 58px; }
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar-menu { display: inline-grid; }
  .topnav, .topbar-end { display: none; }
  .brand-tag { display: none; }
  .app-page, .app-workspace { grid-template-columns: minmax(0, 1fr); }
  .rail { position: fixed; top: 0; left: 0; bottom: 0; height: 100dvh; width: min(320px, 88vw); z-index: 50; transform: translateX(-105%); transition: transform .25s ease;
          visibility: hidden; box-shadow: var(--shadow-lg); padding-top: 12px; }
  body.rail-open .rail, .rail:target { transform: none; visibility: visible; }
  .rail-mobile-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
  .rail-starzhive { display: grid; gap: 2px; padding-bottom: 8px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
  .rail-starzhive a { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 12px; color: var(--ink-2); text-decoration: none; font-weight: 500; }
  .rail-starzhive a .i { color: var(--muted); }
  .rail-recent .threads { max-height: none; }
  .page { padding: 20px 16px 32px; }
  .page-head { gap: 12px; }
  .page-icon { width: 44px; height: 44px; border-radius: 14px; }
  .page-head h1 { font-size: 24px; }
  .grid { grid-template-columns: 1fr; }
  .row-card { align-items: flex-start; }

  /* workspace on phones: the StarzHive bar steps aside; the chat header is the app bar */
  body.is-workspace .topbar { display: none; }
  .app-workspace { height: 100dvh; }
  .only-compact { display: inline-grid; }
  .chat-head { height: 60px; padding: 0 6px 0 4px; gap: 4px; padding-top: env(safe-area-inset-top); height: calc(60px + env(safe-area-inset-top)); }
  .chat-id { gap: 10px; }
  .avatar { width: 34px; height: 34px; }
  .chat-title { font-size: 16px; }
  .chat-sub { font-size: 12px; }
  .chat-inner { padding: 18px 14px 12px; }
  .stream { gap: 14px; }
  .hero { padding: 14px 4px 18px; }
  .hero-art { width: 84px; height: 84px; margin-bottom: 12px; }
  .hero-art img { width: 72px; height: 72px; }
  .hero-title { font-size: 23px; }
  .hero-sub { font-size: 15px; }
  .starters { grid-template-columns: 1fr; gap: 10px; }
  .starter { padding: 14px; }
  .msg { gap: 8px; }
  .msg-avatar { width: 30px; height: 30px; }
  .msg-user .bubble { max-width: 86%; }
  .prose { padding: 12px 14px; font-size: 16px; }
  .dock { padding: 6px 10px max(10px, env(safe-area-inset-bottom)); gap: 8px; }
  .chips { order: 0; flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; margin: 0 -10px; padding: 2px 10px; width: auto; max-width: none; }
  .composer { border-radius: 24px; }
  .dock-note { display: none; }
  .provider-grid { grid-auto-flow: column; grid-auto-columns: 84%; grid-template-columns: none; overflow-x: auto; scroll-snap-type: x mandatory;
                   margin: 0 -16px; padding: 2px 16px 6px; scrollbar-width: none; }
  .provider-grid::-webkit-scrollbar { display: none; }
  .provider { scroll-snap-align: start; }
  .page .provider-grid { grid-auto-flow: row; grid-template-columns: 1fr; overflow: visible; margin: 0; padding: 0; }
  .file-chip { min-width: 0; }
  .card-actions .btn { min-height: 40px; }
  .attach-menu { position: fixed; left: 10px; right: 10px; bottom: calc(84px + env(safe-area-inset-bottom)); min-width: 0; padding: 8px; border-radius: 20px; }
  .attach-menu button { padding: 14px; font-size: 16px; }
  .context { width: 100vw; top: auto; height: auto; max-height: 86dvh; bottom: 0; border-radius: 24px 24px 0 0; border-left: 0;
             transform: translateY(105%); padding-bottom: max(24px, env(safe-area-inset-bottom)); }
  .context::before { content: ""; display: block; width: 42px; height: 5px; border-radius: 3px; background: var(--line-strong); margin: -6px auto 2px; flex: none; }
  body.ctx-open .context, .context:target { transform: none; }
  .menu-pop { position: fixed; left: 12px; right: 12px; top: 64px; width: auto; }
  .toast { bottom: calc(96px + env(safe-area-inset-bottom)); }
}
@media (min-width: 900px) {
  .jump { bottom: 16px; }
}
