/* ───────── Design tokens ───────── */
:root {
  color-scheme: light dark;
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI Variable Display", "Segoe UI", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: "SFMono-Regular", Menlo, Consolas, "PT Mono", "Liberation Mono", Courier, monospace;

  --bg: #ffffff;
  --sidebar: #f7f7f5;
  --surface: #ffffff;
  --surface-2: #f7f7f5;
  --surface-3: #f1f1ef;
  --hover: rgba(55, 53, 47, 0.06);
  --ink: #37352f;
  --ink-2: rgba(55, 53, 47, 0.9);
  --muted: rgba(55, 53, 47, 0.65);
  --faint: rgba(55, 53, 47, 0.45);
  --line: rgba(55, 53, 47, 0.09);
  --line-strong: rgba(55, 53, 47, 0.16);

  --accent: #37352f;
  --accent-ink: #37352f;
  --accent-soft: rgba(55, 53, 47, 0.06);
  --accent-line: rgba(55, 53, 47, 0.16);
  --accent-ring: rgba(55, 53, 47, 0.08);
  --btn: #2f2e2a;
  --btn-hover: #0f0f0f;
  --btn-ink: #ffffff;

  --user-bg: #f1f1ef;
  --user-ink: #37352f;
  --danger: #eb5757;

  --shadow-sm: 0 0 0 1px rgba(15, 15, 15, 0.05), 0 1px 2px rgba(15, 15, 15, 0.08);
  --shadow-float: 0 0 0 1px rgba(15, 15, 15, 0.05), 0 3px 6px rgba(15, 15, 15, 0.1), 0 9px 24px rgba(15, 15, 15, 0.2);
  --shadow-input: 0 0 0 1px rgba(15, 15, 15, 0.04), 0 2px 4px rgba(15, 15, 15, 0.04), 0 8px 24px -8px rgba(15, 15, 15, 0.1);

  --header-h: 48px;
  --radius-lg: 10px;
  --radius-md: 8px;
  --radius-sm: 6px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #191919;
    --sidebar: #202020;
    --surface: #191919;
    --surface-2: #202020;
    --surface-3: #2a2a2a;
    --hover: rgba(255, 255, 255, 0.055);
    --ink: rgba(255, 255, 255, 0.87);
    --ink-2: rgba(255, 255, 255, 0.8);
    --muted: rgba(255, 255, 255, 0.52);
    --faint: rgba(255, 255, 255, 0.34);
    --line: rgba(255, 255, 255, 0.08);
    --line-strong: rgba(255, 255, 255, 0.14);

    --accent: rgba(255, 255, 255, 0.87);
    --accent-ink: rgba(255, 255, 255, 0.87);
    --accent-soft: rgba(255, 255, 255, 0.07);
    --accent-line: rgba(255, 255, 255, 0.16);
    --accent-ring: rgba(255, 255, 255, 0.08);
    --btn: #ebebea;
    --btn-hover: #ffffff;
    --btn-ink: #191919;

    --user-bg: #2a2a2a;
    --user-ink: rgba(255, 255, 255, 0.87);
    --danger: #ff7369;

    --shadow-sm: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-float: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 3px 6px rgba(0, 0, 0, 0.3), 0 9px 24px rgba(0, 0, 0, 0.5);
    --shadow-input: 0 0 0 1px rgba(255, 255, 255, 0.05), 0 8px 24px -8px rgba(0, 0, 0, 0.6);
  }
}

/* ───────── Base ───────── */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { display: block; flex: none; }
::selection { background: rgba(35, 131, 226, 0.28); }
button:focus-visible, a:focus-visible, textarea:focus-visible, .cite.is-live:focus-visible { outline: 2px solid rgba(35, 131, 226, 0.57); outline-offset: 1px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.conversation, .preview-panel, .rail { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }

.eyebrow { color: var(--muted); font-size: 12px; font-weight: 500; }
kbd { display: inline-grid; place-items: center; min-width: 20px; padding: 0 5px; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--surface); color: var(--muted); font: 500 10.5px/18px var(--font); }

/* ───────── Shell ───────── */
.app-shell { display: flex; height: 100vh; height: 100dvh; }

/* ───────── Left rail ───────── */
.rail { flex: 0 0 248px; display: flex; flex-direction: column; min-height: 0; padding: 10px 8px 8px; overflow-y: auto; background: var(--sidebar); box-shadow: inset -1px 0 0 var(--line); }
.brand { display: flex; align-items: center; gap: 8px; padding: 4px 6px; }
.brand-mark { display: block; width: 22px; height: 22px; object-fit: contain; }
@media (prefers-color-scheme: dark) { .brand-mark { filter: invert(1); } }
.brand-name { font-size: 14px; font-weight: 600; }

.rail-new {
  display: flex; align-items: center; gap: 8px; width: 100%; margin-top: 14px; padding: 6px 8px;
  border: 0; border-radius: var(--radius-sm); background: transparent;
  color: var(--muted); font-size: 14px; font-weight: 500; text-align: left;
  transition: background 0.12s;
}
.rail-new svg { width: 16px; height: 16px; }
.rail-new span { flex: 1; }
.rail-new kbd { border: 0; background: transparent; color: var(--faint); opacity: 0; transition: opacity 0.12s; }
.rail-new:hover { background: var(--hover); }
.rail-new:hover kbd { opacity: 1; }

.rail-section { margin-top: 20px; }
.history-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; margin: 0; padding: 0; list-style: none; }
.history-item {
  position: relative; display: block; width: 100%; padding: 5px 8px; border: 0; border-radius: var(--radius-sm); background: transparent;
  color: var(--muted); font-size: 14px; line-height: 1.45; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background 0.12s, color 0.12s;
}
.history-row { position: relative; min-width: 0; }
.history-row .history-item { padding-right: 28px; }
.history-delete {
  position: absolute; top: 50%; right: 4px; width: 22px; height: 22px; margin-top: -11px; border: 0; border-radius: 4px; background: transparent;
  color: var(--faint); font-size: 16px; line-height: 1; opacity: 0; cursor: pointer; transition: opacity 0.12s, background 0.12s;
}
.history-row:hover .history-delete, .history-delete:focus-visible { opacity: 1; }
.history-delete:hover { background: var(--line); color: var(--ink); }
.history-item:hover { background: var(--hover); color: var(--ink); }
.history-item.is-current { background: var(--hover); color: var(--ink); font-weight: 500; }

/* ───────── Workspace ───────── */
.workspace {
  --gutter: max(28px, calc((100% - 760px) / 2));
  position: relative; display: flex; flex: 1; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden;
  background: var(--surface);
}
.workspace-header {
  position: relative; z-index: 1; display: flex; flex: none; justify-content: space-between; align-items: center; gap: 16px; height: var(--header-h); padding: 0 14px 0 20px;
  border-bottom: 1px solid var(--line);
  transition: border-color 0.3s;
}
.workspace-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.workspace-title h2 { margin: 0; overflow: hidden; font-size: 14px; line-height: 1.3; font-weight: 500; white-space: nowrap; text-overflow: ellipsis; }
.ghost-button {
  display: none; align-items: center; gap: 6px; height: 28px; padding: 0 10px 0 8px; border: 0;
  border-radius: var(--radius-sm); background: transparent; color: var(--muted); font-size: 14px; font-weight: 500;
  transition: background 0.12s;
}
.ghost-button svg { width: 15px; height: 15px; }
.ghost-button:hover { background: var(--hover); }

.conversation { flex: 1; overflow: auto; padding: 34px var(--gutter) 28px; }

/* Empty (landing) mode: hero + composer centered as one group */
.workspace.is-empty .workspace-header { border-color: transparent; }
.workspace.is-empty .conversation { flex: 0 0 auto; margin-top: auto; padding-bottom: 30px; overflow: visible; }
.workspace.is-empty .composer-wrap { margin-bottom: auto; padding-bottom: 40px; }
.workspace.is-empty .composer-wrap::before, .workspace.is-empty .disclaimer { display: none; }
.workspace > * { position: relative; z-index: 1; }

/* ───────── Empty state ───────── */
.empty-state { max-width: 620px; margin: 0 auto; text-align: center; animation: rise 0.6s var(--ease) both; }
.empty-state h3 { margin: 0 0 10px; color: var(--ink); font-size: clamp(26px, 3vw, 34px); line-height: 1.25; font-weight: 700; letter-spacing: -0.02em; text-wrap: balance; }
.grad { color: var(--faint); }
.br-sm { display: none; }

/* Starter prompts (only in empty mode) */
.starters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 14px; animation: rise 0.6s 0.08s var(--ease) both; }
.workspace:not(.is-empty) .starters { display: none; }
.starter {
  display: flex; align-items: flex-start; gap: 10px; min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-md);
  background: var(--surface); text-align: left;
  transition: background 0.12s;
}
.starter-icon { display: grid; place-items: center; flex: none; width: 28px; height: 28px; border-radius: var(--radius-sm); background: var(--hover); color: var(--muted); }
.starter-icon svg { width: 16px; height: 16px; }
.starter-text { display: grid; gap: 2px; min-width: 0; }
.starter-text strong { color: var(--ink); font-size: 14px; font-weight: 500; }
.starter-text span { color: var(--muted); font-size: 12px; line-height: 1.5; }
.starter:hover { background: var(--hover); }

/* ───────── Messages ───────── */
.message { margin: 0 0 34px; scroll-margin-top: 24px; animation: rise 0.4s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.message--user { display: flex; justify-content: flex-end; }
.message--user .message-body {
  max-width: 80%; padding: 10px 16px; border-radius: 12px; background: var(--user-bg); color: var(--user-ink);
  font-size: 14.5px; line-height: 1.75;
}
.message-main { min-width: 0; }
.message-body { font-size: 14.5px; line-height: 1.9; overflow-wrap: anywhere; }

/* Answer typography */
.answer-content { color: var(--ink); }
.answer-content > :first-child { margin-top: 0; }
.answer-content p { margin: 0 0 14px; }
.answer-content h2, .answer-content h3 { position: relative; color: var(--ink); line-height: 1.5; letter-spacing: -0.015em; }
.answer-content h2 { margin: 28px 0 8px; font-size: 18px; font-weight: 600; }
.answer-content h3 { margin: 20px 0 6px; font-size: 16px; font-weight: 600; }
.answer-content ul, .answer-content ol { margin: 6px 0 18px; padding: 0; list-style: none; }
.answer-content ol { counter-reset: item; }
.answer-content li { position: relative; margin: 7px 0; padding-left: 22px; }
.answer-content ul > li::before { content: ""; position: absolute; left: 7px; top: 0.8em; width: 5px; height: 5px; border-radius: 50%; background: var(--ink); }
.answer-content ol > li { counter-increment: item; }
.answer-content ol > li::before { content: counter(item) "."; position: absolute; left: 0; top: 0.42em; display: grid; place-items: center; width: 17px; height: 17px; color: var(--ink); font-size: 14px; font-weight: 400; line-height: 1; }
.answer-content strong { color: var(--ink); font-weight: 600; }
.answer-content a { color: inherit; text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; transition: text-decoration-color 0.2s; }
.answer-content a:hover { text-decoration-color: var(--muted); }

/* Inline citation badges */
.cite {
  display: inline-grid; place-items: center; min-width: 19px; height: 19px; margin: 0 2px; padding: 0 5px; border-radius: 4px; vertical-align: 1.5px;
  background: var(--surface-3); color: var(--muted); font-size: 10.5px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; user-select: none;
  transition: background 0.15s, color 0.15s, transform 0.15s var(--ease);
}
.cite.is-live { background: var(--hover); color: var(--ink); cursor: pointer; }
.cite.is-live:hover { background: var(--btn); color: var(--btn-ink); }

/* Loading */
.loading { display: inline-flex; align-items: center; gap: 10px; padding: 6px 0; color: var(--muted); font-size: 13px; }
.loading::before { content: ""; width: 14px; height: 14px; border-radius: 50%; background: conic-gradient(from 0deg, transparent 10%, var(--muted)); -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2.2px), #000 calc(100% - 2px)); mask: radial-gradient(farthest-side, transparent calc(100% - 2.2px), #000 calc(100% - 2px)); animation: spin 0.8s linear infinite; }
.loading:not(:empty) { background: linear-gradient(100deg, var(--muted) 30%, var(--ink) 50%, var(--muted) 70%) 0 0 / 240% 100%; -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; animation: shimmer 2s linear infinite; }
.loading::before { -webkit-text-fill-color: initial; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { background-position: -240% 0; } }

/* Streaming status: visible for as long as the answer stream is open */
.stream-status { display: flex; align-items: center; gap: 8px; min-height: 22px; margin-top: 6px; color: var(--muted); font-size: 12.5px; }
.stream-dots { display: inline-flex; gap: 4px; }
.stream-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--muted); animation: pulse 1.2s ease-in-out infinite both; }
.stream-dots i:nth-child(2) { animation-delay: 0.15s; }
.stream-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes pulse { 0%, 80%, 100% { opacity: 0.25; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1); } }
.stream-error { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 10px; color: var(--danger); font-size: 12.5px; }
.stream-retry { padding: 2px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); font-size: 12.5px; font-weight: 500; transition: background 0.12s; }
.stream-retry:hover { background: var(--hover); }

/* Sources */
.source-title { display: flex; align-items: center; gap: 8px; margin: 28px 0 12px; padding-top: 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12.5px; font-weight: 500; }
.source-title::after { content: attr(data-count); display: grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 4px; background: var(--hover); color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.source-list { position: relative; display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; overscroll-behavior-x: contain; scrollbar-width: none; }
.source-list::-webkit-scrollbar { display: none; }
.source-list:focus-visible { outline: 2px solid rgba(35, 131, 226, 0.57); outline-offset: 2px; border-radius: var(--radius-md); }
.source-page { display: grid; flex: 0 0 100%; min-width: 0; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(96px, 1fr)); gap: 10px; scroll-snap-align: start; scroll-snap-stop: always; }
.source-row { display: flex; flex-direction: column; min-width: 0; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); overflow: hidden; }
.source-topic { display: flex; flex: 1; min-width: 0; align-items: flex-start; gap: 9px; padding: 10px 12px 8px; border: 0; background: transparent; text-align: left; transition: background 0.12s; }
.source-topic:focus-visible, .source-group:focus-visible { outline-offset: -2px; }
.source-topic:hover { background: var(--hover); }
.source-number { flex: none; display: grid; place-items: center; width: 18px; height: 18px; margin-top: 2px; border-radius: 4px; background: var(--hover); color: var(--muted); font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }
.source-number::before { content: attr(data-n); }
.source-heading { display: -webkit-box; min-width: 0; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; color: var(--ink); font-size: 13.5px; font-weight: 500; line-height: 1.55; }
.source-group { display: inline-flex; align-items: center; gap: 5px; align-self: flex-start; max-width: calc(100% - 43px); margin: 0 8px 8px 35px; padding: 2px 6px; border: 0; border-radius: 4px; background: transparent; color: var(--muted); font-size: 12px; transition: background 0.12s, color 0.12s; }
.source-group span { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.source-group-avatar { flex: none; width: 14px; height: 14px; border-radius: 4px; object-fit: cover; }
.source-group::after { content: " ›"; flex: none; }
.source-group:hover { background: var(--hover); color: var(--ink); }
.source-row:not(:has(.source-topic)) { flex-direction: row; align-items: center; gap: 9px; padding: 10px 12px; }
.source-unavailable { color: var(--danger); font-size: 12.5px; }
.source-navigation { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 10px; color: var(--muted); font-size: 12px; }
.source-controls { display: flex; align-items: center; gap: 6px; }
.source-page-button { display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--muted); font-size: 20px; line-height: 1; transition: background 0.12s, color 0.12s; }
.source-page-button:hover:not(:disabled) { background: var(--hover); color: var(--ink); }
.source-page-button:disabled { opacity: 0.35; cursor: default; }
.source-page-status { min-width: 40px; text-align: center; font-variant-numeric: tabular-nums; }

/* ───────── Composer ───────── */
.composer-wrap { position: relative; padding: 0 var(--gutter) 14px; background: var(--surface); }
.workspace.is-empty .composer-wrap { background: transparent; }
.composer-wrap::before { content: ""; position: absolute; left: 0; right: 0; top: -26px; height: 26px; background: linear-gradient(transparent, var(--surface)); pointer-events: none; }
.composer {
  padding: 12px 10px 10px 16px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-input);
  transition: border-color 0.2s, box-shadow 0.2s;
  animation: rise 0.6s 0.04s var(--ease) both;
}
.composer:focus-within { border-color: rgba(55, 53, 47, 0.28); }
@media (prefers-color-scheme: dark) { .composer:focus-within { border-color: rgba(255, 255, 255, 0.28); } }
.composer textarea { display: block; width: 100%; min-height: 50px; max-height: 190px; padding: 0; resize: none; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 15px; line-height: 1.7; }
.composer textarea::placeholder { color: var(--faint); opacity: 1; transition: opacity 0.3s, transform 0.3s; }
.composer textarea.ph-fade::placeholder { opacity: 0; transform: translateY(-4px); }
.composer-bottom { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin-top: 6px; }
#send {
  display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 50%; color: var(--btn-ink); background: var(--btn);
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}
#send svg { width: 16px; height: 16px; }
#send:hover:not(:disabled) { background: var(--btn-hover); }
.composer:has(textarea:placeholder-shown) #send { background: var(--surface-3); color: var(--faint); }
#send:disabled { opacity: 0.5; cursor: wait; }
.disclaimer { margin: 10px 0 0; color: var(--faint); text-align: center; font-size: 11.5px; }

/* ───────── Preview panel ───────── */
.preview-panel {
  display: flex; flex-direction: column; flex: 0 0 var(--preview-w, 400px); width: var(--preview-w, 400px); min-height: 0; overflow: auto;
  background: var(--surface); animation: slide-in 0.34s var(--ease) both;
}
@keyframes slide-in { from { opacity: 0; transform: translateX(18px); } }
.preview-header {
  position: sticky; top: 0; z-index: 1; display: flex; flex: none; justify-content: space-between; align-items: center; height: var(--header-h); padding: 0 12px 0 24px;
  background: color-mix(in srgb, var(--surface) 82%, transparent); -webkit-backdrop-filter: blur(14px) saturate(1.4); backdrop-filter: blur(14px) saturate(1.4);
}
.preview-header button { display: grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--muted); transition: background 0.12s, color 0.12s; }
.preview-header button svg { width: 16px; height: 16px; }
.preview-header button:hover { background: var(--hover); color: var(--ink); }
.preview-content { display: flex; flex: 1 0 auto; flex-direction: column; padding: 22px 24px 0; animation: rise 0.35s var(--ease) both; }
.preview-meta { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--muted); font-size: 12.5px; }
.preview-kind { flex: none; padding: 0 6px; border-radius: 4px; background: var(--hover); color: var(--muted); font-size: 11.5px; font-weight: 500; line-height: 20px; }
.preview-title { margin: 12px 0 16px; color: var(--ink); font-size: 19px; line-height: 1.45; font-weight: 650; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.preview-subtitle { margin: 0 0 4px; color: var(--muted); font-size: 12.5px; line-height: 1.7; }
.preview-excerpt { position: relative; margin: 0; color: var(--ink-2); white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.8; }
.preview-excerpt.is-truncated::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3.6em; background: linear-gradient(to bottom, transparent, var(--surface)); pointer-events: none; }
.preview-section { margin: 24px 0 0; color: var(--muted); font-size: 12px; font-weight: 500; }
.preview-footer {
  position: sticky; bottom: 0; margin: auto -24px 0; padding: 12px 24px 16px;
  border-top: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 88%, transparent); -webkit-backdrop-filter: blur(14px) saturate(1.4); backdrop-filter: blur(14px) saturate(1.4);
}
.preview-note { margin: 0 0 10px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.preview-content > .preview-note { margin: 0; }
.preview-link {
  display: flex; justify-content: center; align-items: center; gap: 6px; width: 100%; padding: 8px 12px; border-radius: var(--radius-sm);
  background: var(--btn); color: var(--btn-ink); font-size: 13.5px; font-weight: 500; text-decoration: none; transition: background 0.12s;
}
.preview-link svg { width: 14px; height: 14px; }
.preview-link:hover { background: var(--btn-hover); }
.preview-kind.is-digest { background: color-mix(in srgb, #d9730d 14%, transparent); color: #b35a06; }
@media (prefers-color-scheme: dark) { .preview-kind.is-digest { color: #f2a766; } }
.preview-author { display: flex; align-items: center; gap: 10px; margin: 0 0 18px; min-width: 0; }
.preview-author-avatar { flex: none; width: 32px; height: 32px; border-radius: 50%; object-fit: cover; background: var(--surface-3); }
.preview-author-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.45; }
.preview-author-name { color: var(--ink); font-size: 13.5px; font-weight: 500; }
.preview-author-detail { overflow: hidden; color: var(--muted); font-size: 12px; white-space: nowrap; text-overflow: ellipsis; }
.preview-images { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 14px; }
.preview-images.count-1 { grid-template-columns: minmax(0, 240px); }
.preview-images.count-2 { grid-template-columns: repeat(2, 1fr); }
.preview-images img { width: 100%; aspect-ratio: 1; border-radius: var(--radius-sm); object-fit: cover; background: var(--surface-3); }
.preview-images.count-1 img { aspect-ratio: auto; max-height: 240px; }
.preview-stats { margin: 14px 0 0; color: var(--muted); font-size: 12px; }
.preview-group-card {
  display: flex; align-items: center; gap: 12px; width: 100%; margin-top: 10px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-md);
  background: var(--surface); color: var(--ink); text-align: left; transition: background 0.12s;
}
.preview-group-card:hover { background: var(--hover); }
.preview-group-card::after { content: "›"; margin-left: auto; color: var(--faint); font-size: 18px; }
.preview-group-avatar { flex: none; width: 36px; height: 36px; border-radius: var(--radius-sm); object-fit: cover; }
.preview-group-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.preview-group-name { overflow: hidden; font-size: 14px; font-weight: 500; white-space: nowrap; text-overflow: ellipsis; }
.preview-group-facts { color: var(--muted); font-size: 12px; }
.preview-hero { position: relative; margin: -22px -24px 18px; height: 112px; background: var(--surface-3); }
.preview-cover { width: 100%; height: 100%; object-fit: cover; }
.preview-hero-avatar { position: absolute; left: 24px; bottom: -18px; width: 48px; height: 48px; border: 3px solid var(--surface); border-radius: var(--radius-md); object-fit: cover; background: var(--surface); }
.preview-hero:has(.preview-hero-avatar) + .preview-meta { margin-top: 28px; }
.preview-description { margin: 12px 0 0; color: var(--ink-2); font-size: 13.5px; line-height: 1.75; }
.preview-description { overflow-wrap: anywhere; }
.preview-description.is-clamped { display: -webkit-box; overflow: hidden; -webkit-line-clamp: 4; -webkit-box-orient: vertical; }
.preview-more { align-self: flex-start; margin-top: 4px; padding: 0; border: 0; background: none; color: var(--muted); font-size: 12.5px; font-weight: 500; }
.preview-more:hover { color: var(--ink); }
.group-topic-list { display: grid; gap: 6px; margin-top: 10px; }
.group-topic {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); color: var(--ink); text-align: left; font-size: 13.5px; line-height: 1.55;
  transition: background 0.12s;
}
.group-topic:hover { background: var(--hover); }
.group-topic-title { display: block; font-weight: 500; }
.group-topic small { display: -webkit-box; margin-top: 4px; overflow: hidden; color: var(--muted); font-size: 12px; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.preview-backdrop { display: none; }
.preview-resizer { position: relative; z-index: 2; flex: none; width: 0; cursor: col-resize; touch-action: none; }
.preview-resizer::before { content: ""; position: absolute; inset: 0 -4px; }
.preview-resizer::after { content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 1px; background: var(--line); transition: background 0.15s 0.1s, width 0.15s 0.1s, left 0.15s 0.1s; }
.preview-resizer:hover::after, .preview-resizer:focus-visible::after, .is-resizing .preview-resizer::after { left: -1px; width: 2px; background: var(--line-strong); }
.preview-resizer:focus-visible { outline: none; }
.is-resizing, .is-resizing * { cursor: col-resize !important; user-select: none; }

/* ───────── Responsive ───────── */
@media (max-width: 1180px) {
  .rail { flex-basis: 228px; }
  .preview-panel { flex-basis: var(--preview-w, 348px); width: var(--preview-w, 348px); }
}
@media (max-width: 920px) {
  .preview-resizer { display: none; }
  .preview-panel {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 10; width: min(430px, 100vw); box-shadow: var(--shadow-float);
  }
  .preview-backdrop:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 9; background: rgba(15, 15, 15, 0.4); animation: fade 0.25s ease both; }
  @keyframes fade { from { opacity: 0; } }
  .starters { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .app-shell { padding: 0; gap: 0; }
  .rail { display: none; }
  .ghost-button { display: inline-flex; }
  .workspace-header { padding: 0 16px; }
  .workspace { --gutter: 16px; }
  .conversation { padding-top: 24px; }
  .composer-wrap { padding: 0 12px 12px; }
  .workspace.is-empty .composer-wrap { padding-bottom: 24px; }
  .br-sm { display: inline; }
  .composer-bottom { justify-content: flex-end; }
  .message--user .message-body { max-width: 90%; }
  .source-page { gap: 6px; }
  .source-topic { gap: 5px; padding: 8px 6px; }
  .source-number { width: 16px; height: 16px; font-size: 10px; }
  .source-heading { font-size: 12px; }
  .source-group { max-width: calc(100% - 12px); margin: 0 6px 8px; padding: 2px 4px; font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
