/* ═══════════════════════════════════════════════════════════════════════
   Community Brain — application styles

   One stylesheet, plain CSS, custom properties for theming. No build step and
   no framework: the whole UI is server-rendered Jinja, and a 20 KB stylesheet
   loads faster than any component library would.

   Light and dark both ship. `prefers-color-scheme` decides by default and the
   header toggle writes data-theme onto <html> to override it.
   ═══════════════════════════════════════════════════════════════════════ */

/* ───────────────────────────────────────────────────────────────── tokens */

:root {
  --bg: #0b0d10;
  --surface: #12151a;
  --surface-2: #171b21;
  --surface-3: #1d222a;
  --border: #232a33;
  --border-strong: #303945;
  --text: #e4e8ee;
  --text-2: #b9c2cf;
  --muted: #7f8b9a;
  --faint: #5b6674;

  --accent: #7aa2f7;
  --accent-soft: rgba(122, 162, 247, 0.14);
  --accent-line: rgba(122, 162, 247, 0.35);
  --green: #59c98a;
  --green-soft: rgba(89, 201, 138, 0.14);
  --amber: #e0b04c;
  --amber-soft: rgba(224, 176, 76, 0.14);
  --red: #f0736a;
  --red-soft: rgba(240, 115, 106, 0.14);
  --violet: #b48ce3;
  --violet-soft: rgba(180, 140, 227, 0.14);

  --mark: rgba(224, 176, 76, 0.28);

  --radius: 10px;
  --radius-sm: 7px;
  --radius-lg: 14px;
  --sidebar-w: 244px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.5);

  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Inter,
    Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-2: #fafbfc;
    --surface-3: #f0f2f5;
    --border: #e2e6eb;
    --border-strong: #cfd6de;
    --text: #14181d;
    --text-2: #38414d;
    --muted: #66717f;
    --faint: #8b95a2;

    --accent: #3b6fd4;
    --accent-soft: rgba(59, 111, 212, 0.09);
    --accent-line: rgba(59, 111, 212, 0.3);
    --green: #1f8a51;
    --green-soft: rgba(31, 138, 81, 0.1);
    --amber: #97690a;
    --amber-soft: rgba(151, 105, 10, 0.11);
    --red: #c93a30;
    --red-soft: rgba(201, 58, 48, 0.1);
    --violet: #7a4fb5;
    --violet-soft: rgba(122, 79, 181, 0.1);

    --mark: rgba(224, 176, 76, 0.42);
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 8px 24px -14px rgba(16, 24, 40, 0.22);
    color-scheme: light;
  }
}

/* Explicit override from the toggle beats the media query in both directions. */
:root[data-theme="light"] {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --surface-3: #f0f2f5;
  --border: #e2e6eb;
  --border-strong: #cfd6de;
  --text: #14181d;
  --text-2: #38414d;
  --muted: #66717f;
  --faint: #8b95a2;
  --accent: #3b6fd4;
  --accent-soft: rgba(59, 111, 212, 0.09);
  --accent-line: rgba(59, 111, 212, 0.3);
  --green: #1f8a51;
  --green-soft: rgba(31, 138, 81, 0.1);
  --amber: #97690a;
  --amber-soft: rgba(151, 105, 10, 0.11);
  --red: #c93a30;
  --red-soft: rgba(201, 58, 48, 0.1);
  --violet: #7a4fb5;
  --violet-soft: rgba(122, 79, 181, 0.1);
  --mark: rgba(224, 176, 76, 0.42);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 8px 24px -14px rgba(16, 24, 40, 0.22);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0b0d10;
  --surface: #12151a;
  --surface-2: #171b21;
  --surface-3: #1d222a;
  --border: #232a33;
  --border-strong: #303945;
  --text: #e4e8ee;
  --text-2: #b9c2cf;
  --muted: #7f8b9a;
  --faint: #5b6674;
  --accent: #7aa2f7;
  --accent-soft: rgba(122, 162, 247, 0.14);
  --accent-line: rgba(122, 162, 247, 0.35);
  --green: #59c98a;
  --green-soft: rgba(89, 201, 138, 0.14);
  --amber: #e0b04c;
  --amber-soft: rgba(224, 176, 76, 0.14);
  --red: #f0736a;
  --red-soft: rgba(240, 115, 106, 0.14);
  --violet: #b48ce3;
  --violet-soft: rgba(180, 140, 227, 0.14);
  --mark: rgba(224, 176, 76, 0.28);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

/* ────────────────────────────────────────────────────────────────── reset */

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

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  text-decoration: none;
}

h1,
h2,
h3,
h4,
p,
figure {
  margin: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

/* Inline icons carry no width/height attributes so they inherit colour and
   scale with text. Without this default an icon used somewhere with no
   explicit size rule renders at the SVG's natural size -- which is enormous.
   Every context-specific rule below overrides it on specificity. */
svg {
  width: 1em;
  height: 1em;
  flex: none;
  vertical-align: -0.14em;
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

::selection {
  background: var(--accent-soft);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ────────────────────────────────────────────────────────────────── shell */

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

/* The mobile nav backdrop. Hidden here rather than only inside the media
   query: as a grid child it would otherwise claim the first cell on desktop
   and push the sidebar and content out of their columns. */
.scrim {
  display: none;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem 0.75rem 0.75rem;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0.55rem 1.1rem;
}

.brand-mark {
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: 8px;
  background: linear-gradient(145deg, var(--accent), var(--violet));
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.brand-name {
  font-size: 14.5px;
  font-weight: 640;
  letter-spacing: -0.015em;
}

.brand-sub {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--faint);
  letter-spacing: 0.02em;
}

.nav-label {
  padding: 0.75rem 0.6rem 0.3rem;
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--faint);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.48rem 0.6rem;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.12s ease, color 0.12s ease;
}

.nav-item svg {
  width: 16px;
  height: 16px;
  flex: none;
  opacity: 0.75;
}

.nav-item:hover {
  background: var(--surface-3);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.nav-item.active svg {
  opacity: 1;
}

.nav-count {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--faint);
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.user-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.6rem;
  margin-top: 0.35rem;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.avatar {
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-3);
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 650;
  color: var(--text-2);
  text-transform: uppercase;
}

.user-email {
  font-size: 12px;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-btn {
  flex: none;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--muted);
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--surface-3);
  color: var(--text);
  border-color: var(--border);
}

.icon-btn svg {
  width: 15px;
  height: 15px;
}

/* ─────────────────────────────────────────────────────────────── content */

.content {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.page {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 2rem 2rem 5rem;
}

.page.narrow {
  max-width: 860px;
}

.page-head {
  margin-bottom: 1.5rem;
}

.page-head.row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
}

h1 {
  font-size: 22px;
  font-weight: 640;
  letter-spacing: -0.02em;
}

.page-sub {
  margin-top: 0.3rem;
  color: var(--muted);
  font-size: 13.5px;
  max-width: 68ch;
}

h2 {
  font-size: 15px;
  font-weight: 620;
  letter-spacing: -0.01em;
}

.section-label {
  font-size: 10.5px;
  font-weight: 680;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.7rem;
}

.eyebrow {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.mono {
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.muted {
  color: var(--muted);
}

.faint {
  color: var(--faint);
}

.link {
  color: var(--accent);
}

.link:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ───────────────────────────────────────────────────────────────── cards */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
}

.card + .card {
  margin-top: 1rem;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.85rem;
}

.grid {
  display: grid;
  gap: 1rem;
}

.grid.cols-2 {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.grid.cols-3 {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

/* Content plus a metadata rail. As a class rather than an inline style so it
   can collapse: at 320px fixed the rail was leaving the actual content about
   130px on a phone, which is unreadable. */
.detail-grid {
  grid-template-columns: minmax(0, 1fr) 320px;
  align-items: start;
}

@media (max-width: 900px) {
  .detail-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.grid.cols-4 {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

/* ───────────────────────────────────────────────────────────────── stats */

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat-value {
  margin-top: 0.35rem;
  font-size: 25px;
  font-weight: 620;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.stat-note {
  margin-top: 0.15rem;
  font-size: 12px;
  color: var(--faint);
}

/* ──────────────────────────────────────────────────────────────── badges */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.14rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 550;
  white-space: nowrap;
}

.badge.accent {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent);
}

.badge.green {
  background: var(--green-soft);
  border-color: transparent;
  color: var(--green);
}

.badge.amber {
  background: var(--amber-soft);
  border-color: transparent;
  color: var(--amber);
}

.badge.red {
  background: var(--red-soft);
  border-color: transparent;
  color: var(--red);
}

.badge.violet {
  background: var(--violet-soft);
  border-color: transparent;
  color: var(--violet);
}

.badge.plain {
  background: none;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: none;
  background: var(--muted);
}

.dot.ok {
  background: var(--green);
}

.dot.degraded {
  background: var(--amber);
}

.dot.error {
  background: var(--red);
}

.dot.idle {
  background: var(--muted);
}

.dot.off {
  background: var(--faint);
}

.source-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-2);
}

.source-chip svg {
  width: 13px;
  height: 13px;
  color: var(--accent);
}

/* ──────────────────────────────────────────────────────── demo notices */

.demo-note {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  padding: 0.7rem 0.9rem;
  border: 1px dashed var(--amber);
  background: var(--amber-soft);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: var(--text-2);
  line-height: 1.5;
}

.demo-note svg {
  width: 15px;
  height: 15px;
  flex: none;
  margin-top: 1px;
  color: var(--amber);
}

.demo-note strong {
  color: var(--amber);
  font-weight: 650;
}

.notice {
  padding: 0.75rem 0.95rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 13px;
  color: var(--text-2);
}

.notice.error {
  border-color: var(--red);
  background: var(--red-soft);
}

.notice.info {
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

/* ─────────────────────────────────────────────────────── forms & buttons */

.input,
select.input,
textarea.input {
  width: 100%;
  padding: 0.5rem 0.7rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13.5px;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.input::placeholder {
  color: var(--faint);
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
}

select.input {
  cursor: pointer;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 1.9rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
  white-space: nowrap;
}

.btn:hover {
  background: var(--surface-3);
  border-color: var(--muted);
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

:root[data-theme="dark"] .btn.primary,
:root:not([data-theme]) .btn.primary {
  color: #0b0d10;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .btn.primary {
    color: #fff;
  }
}

.btn.primary:hover {
  filter: brightness(1.08);
}

.btn.ghost {
  background: none;
  border-color: transparent;
  color: var(--muted);
}

.btn.ghost:hover {
  background: var(--surface-3);
  color: var(--text);
}

.btn.small {
  padding: 0.3rem 0.6rem;
  font-size: 12px;
}

.btn svg {
  width: 14px;
  height: 14px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: flex-end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  min-width: 0;
}

.field-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.field.grow {
  flex: 1 1 220px;
}

/* ────────────────────────────────────────────────────────────── search */

.searchbar {
  position: relative;
  display: flex;
  align-items: center;
}

.searchbar svg {
  position: absolute;
  left: 0.85rem;
  width: 16px;
  height: 16px;
  color: var(--faint);
  pointer-events: none;
}

.searchbar .input {
  padding-left: 2.4rem;
  padding-top: 0.7rem;
  padding-bottom: 0.7rem;
  font-size: 15px;
}

.searchbar.large .input {
  padding-top: 0.85rem;
  padding-bottom: 0.85rem;
  font-size: 16px;
  border-radius: var(--radius);
}

mark {
  background: var(--mark);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

/* ──────────────────────────────────────────────────────────── messages */

.msg-list {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}

.msg {
  display: block;
  padding: 0.85rem 1.05rem;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s ease;
}

.msg:last-child {
  border-bottom: 0;
}

a.msg:hover {
  background: var(--surface-2);
}

.msg-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.35rem;
  font-size: 12px;
  color: var(--muted);
}

.msg-author {
  font-weight: 620;
  font-size: 13px;
  color: var(--text);
}

.msg-handle {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--faint);
}

.msg-sep {
  color: var(--border-strong);
}

.msg-text {
  font-size: 14px;
  line-height: 1.62;
  color: var(--text-2);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg-text.full {
  font-size: 15px;
  color: var(--text);
}

.msg-foot {
  margin-top: 0.45rem;
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
  align-items: center;
  font-size: 11.5px;
  color: var(--faint);
}

.msg-foot span {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.msg-foot svg {
  width: 12px;
  height: 12px;
  opacity: 0.7;
}

.msg.is-anchor {
  background: var(--accent-soft);
  border-left: 2px solid var(--accent);
}

.msg.is-deleted .msg-text {
  opacity: 0.6;
  text-decoration: line-through;
}

.reply-quote {
  margin-bottom: 0.4rem;
  padding: 0.3rem 0.6rem;
  border-left: 2px solid var(--border-strong);
  background: var(--surface-2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 12px;
  color: var(--muted);
}

/* ── the message this one replies to ──────────────────────────────────────
   Shown as its own block rather than a run-on sentence, because the thing a
   reader needs first is "what was being answered", and that is the quoted
   text, not the words "Replying to". */

.quoted {
  display: block;
  margin-bottom: 0.9rem;
  padding: 0.6rem 0.8rem;
  border-left: 3px solid var(--accent-line);
  background: var(--surface-2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  text-decoration: none;
}

.quoted:hover {
  background: var(--surface-3);
}

.quoted-label {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--faint);
}

.quoted-label svg {
  width: 12px;
  height: 12px;
}

.quoted-name {
  margin-left: 0.35rem;
  font-size: 12px;
  font-weight: 620;
  color: var(--text-2);
}

.quoted-text {
  display: block;
  margin-top: 0.25rem;
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
}

/* ── transcript ──────────────────────────────────────────────────────────
   A conversation, not a feed: no source chip, no community, no topic on every
   line, because inside one transcript those never change. */

.transcript {
  display: flex;
  flex-direction: column;
}

.tr {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  padding: 0.6rem 0.7rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  border-left: 2px solid transparent;
}

.tr:hover {
  background: var(--surface-2);
}

.tr.is-anchor {
  background: var(--accent-soft);
  border-left-color: var(--accent);
}

.tr-avatar {
  flex: none;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-3);
  border: 1px solid var(--border);
  font-size: 9.5px;
  font-weight: 640;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.tr-body {
  min-width: 0;
  flex: 1;
}

.tr-head {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.15rem;
}

.tr-name {
  font-size: 12.5px;
  font-weight: 620;
  color: var(--text);
}

.tr-handle {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--faint);
}

.tr-time {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--faint);
}

.tr-flag svg {
  width: 12px;
  height: 12px;
  color: var(--faint);
  vertical-align: -2px;
}

.tr-text {
  display: block;
  font-size: 13.5px;
  line-height: 1.62;
  color: var(--text-2);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.tr.is-deleted .tr-text {
  text-decoration: line-through;
  color: var(--faint);
}

.tr-foot {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  margin-top: 0.3rem;
  font-size: 11px;
  color: var(--faint);
}

/* ──────────────────────────────────────────────────────────────── chat */

.chat-hero {
  padding: 2.5rem 0 1.75rem;
  text-align: center;
}

.chat-hero h1 {
  font-size: 30px;
  letter-spacing: -0.03em;
}

.chat-hero p {
  margin: 0.55rem auto 0;
  max-width: 54ch;
  color: var(--muted);
  font-size: 14.5px;
}

.chat-form {
  margin: 0 auto;
  max-width: 720px;
}

.prompt-grid {
  margin: 1.1rem auto 0;
  max-width: 720px;
  display: grid;
  gap: 0.55rem;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.prompt-chip {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  padding: 0.65rem 0.8rem;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.prompt-chip:hover {
  border-color: var(--accent-line);
  background: var(--surface-2);
  color: var(--text);
}

.prompt-chip svg {
  width: 14px;
  height: 14px;
  flex: none;
  color: var(--faint);
}

/* ── the composer ────────────────────────────────────────────────────────
   Sticky to the bottom of the viewport so the box you type in is in the same
   place whether you are starting a chat or twenty answers deep into one. */

.chat-page {
  padding-bottom: 1rem;
}

.composer {
  position: sticky;
  bottom: 0;
  z-index: 5;
  max-width: 760px;
  margin: 1.25rem auto 0;
  padding-bottom: 0.9rem;
  background: linear-gradient(to bottom, transparent, var(--bg) 22%);
}

.composer-box {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.55rem 0.55rem 0.55rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  transition: border-color 0.12s ease;
}

.composer-box:focus-within {
  border-color: var(--accent-line);
}

.composer-input {
  flex: 1;
  min-width: 0;
  min-height: 26px;
  max-height: 240px;
  padding: 0.3rem 0;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  line-height: 1.55;
  resize: none;
  outline: none;
}

.composer-input::placeholder {
  color: var(--faint);
}

.composer-send {
  flex: none;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  transition: opacity 0.12s ease;
}

:root[data-theme="dark"] .composer-send,
:root:not([data-theme]) .composer-send {
  color: var(--bg);
}

.composer-send svg {
  width: 17px;
  height: 17px;
}

.composer-send:hover {
  opacity: 0.88;
}

.composer-send:disabled {
  opacity: 0.5;
  cursor: default;
}

.composer-hint {
  margin: 0.5rem 0.3rem 0;
  font-size: 11.5px;
  color: var(--faint);
  text-align: center;
}

kbd {
  padding: 0.05em 0.35em;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: var(--surface-3);
  font-family: var(--mono);
  font-size: 0.9em;
  color: var(--muted);
}

/* ── a thread ──────────────────────────────────────────────────────────── */

.thread-head {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding-bottom: 0.9rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.thread-title h1 {
  font-size: 19px;
  letter-spacing: -0.015em;
  line-height: 1.35;
}

.thread-title p {
  margin-top: 0.25rem;
  font-size: 12px;
}

.thread-actions {
  margin-left: auto;
  display: flex;
  gap: 0.45rem;
  flex: none;
}

.thread {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.turn-user {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  max-width: 640px;
  margin-left: auto;
  padding: 0.75rem 1rem;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-lg) var(--radius-lg) var(--radius-sm) var(--radius-lg);
}

.turn-user .avatar {
  width: 22px;
  height: 22px;
  font-size: 9.5px;
  flex: none;
}

.turn-user p {
  font-size: 14.5px;
  line-height: 1.55;
  font-weight: 550;
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.turn-ai {
  padding: 1.25rem 1.35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.turn-head {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.9rem;
}

.ai-mark {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: none;
  border-radius: 7px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  color: var(--accent);
}

.ai-mark svg {
  width: 13px;
  height: 13px;
}

.ai-mark.spinning svg {
  animation: cb-pulse 1.4s ease-in-out infinite;
}

@keyframes cb-pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.9); }
  50%      { opacity: 1;    transform: scale(1.08); }
}

@media (prefers-reduced-motion: reduce) {
  .ai-mark.spinning svg {
    animation: none;
  }
}

.turn-title {
  font-size: 12.5px;
  font-weight: 620;
  letter-spacing: 0.01em;
  color: var(--text);
}

.turn-time,
.live-status {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--muted);
}

.live-status {
  color: var(--accent);
}

.turn-foot {
  margin-top: 1rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--faint);
  font-family: var(--mono);
}

/* Raw model output while it arrives. Deliberately plain: it has not been
   citation-checked yet, and dressing it up as a finished answer would invite
   trusting it before the check has run. */
.live-text {
  max-height: 22rem;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-2);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.live-text:empty {
  display: none;
}

.turn-ai.is-failed .live-status {
  color: var(--red);
}

/* ── drawers under an answer ───────────────────────────────────────────── */

.drawer {
  margin-top: 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.drawer > summary {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.65rem 0.85rem;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  list-style: none;
  border-radius: var(--radius);
}

.drawer > summary::-webkit-details-marker {
  display: none;
}

.drawer > summary::after {
  content: "▾";
  margin-left: auto;
  color: var(--faint);
  font-size: 11px;
  transition: transform 0.15s ease;
}

.drawer[open] > summary::after {
  transform: rotate(180deg);
}

.drawer > summary:hover {
  color: var(--text);
}

.drawer > summary svg {
  width: 14px;
  height: 14px;
  flex: none;
  color: var(--muted);
}

.drawer > summary strong {
  color: var(--text);
  font-weight: 620;
}

.drawer-body {
  padding: 0.2rem 0.85rem 0.85rem;
}

.drawer-note {
  margin-top: 0.8rem;
  font-size: 11.5px;
  line-height: 1.6;
}

/* ── people you could ask ──────────────────────────────────────────────── */

.who {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0;
  border-top: 1px solid var(--border);
}

.who:first-child {
  border-top: 0;
}

.who-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  flex: 1;
  text-decoration: none;
}

.who-link .avatar {
  width: 28px;
  height: 28px;
  font-size: 10.5px;
  flex: none;
}

.who-main {
  min-width: 0;
}

.who-name {
  display: block;
  font-size: 13.5px;
  font-weight: 570;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.who-sub {
  display: block;
  margin-top: 1px;
  font-size: 11.5px;
  color: var(--muted);
}

.who-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: none;
}

.reslink {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.5rem 0;
  border-top: 1px solid var(--border);
}

.reslink:first-child {
  border-top: 0;
}

.reslink-main {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
  flex: 1;
  text-decoration: none;
}

.reslink-main svg {
  width: 14px;
  height: 14px;
  flex: none;
  color: var(--faint);
}

.reslink-domain {
  display: block;
  font-size: 13px;
  font-weight: 560;
  color: var(--text);
}

.reslink-url {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── saved chats ───────────────────────────────────────────────────────── */

.history {
  max-width: 760px;
  margin: 2.25rem auto 0;
  padding: 1rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.history .section-label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.35rem;
}

.history .section-label svg {
  width: 13px;
  height: 13px;
}

.history-row {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 0.6rem 0;
  border-top: 1px solid var(--border);
  text-decoration: none;
}

.history-row:hover .history-title {
  color: var(--accent);
}

.history-title {
  font-size: 13.5px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-meta {
  margin-left: auto;
  flex: none;
  font-size: 11.5px;
  color: var(--faint);
}

.answer {
  margin-top: 1.5rem;
}

.answer-question {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.9rem 1.1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1.1rem;
}

.answer-question .avatar {
  width: 24px;
  height: 24px;
  font-size: 10px;
}

.answer-question p {
  font-size: 15px;
  font-weight: 550;
  padding-top: 1px;
}

.answer-block {
  padding: 1.15rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.answer-block + .answer-block {
  margin-top: 0.85rem;
}

.answer-block h3 {
  font-size: 11px;
  font-weight: 680;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.65rem;
}

.answer-block p {
  font-size: 14.5px;
  line-height: 1.68;
  color: var(--text-2);
}

/* ── AI answer ──────────────────────────────────────────────────────────
   The model writes markdown; brain.ai.render converts the narrow subset it is
   asked for into HTML. The prompt asks for up to eight named sections, so the
   headings do the scanning work: a rule above each one turns a long answer
   into something you can skim to "Recommendations" without reading the rest. */

.ai-answer > h3 {
  font-size: 11px;
  font-weight: 680;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.6rem;
}

.ai-answer > h3:not(:first-child) {
  margin-top: 1.6rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--border);
}

.ai-answer h4 {
  font-size: 13px;
  font-weight: 650;
  color: var(--text);
  margin: 0.95rem 0 0.4rem;
}

.ai-answer p {
  font-size: 14.5px;
  line-height: 1.72;
  color: var(--text-2);
}

.ai-answer p + p,
.ai-answer ul + p,
.ai-answer ol + p {
  margin-top: 0.75rem;
}

.ai-answer ul,
.ai-answer ol {
  margin: 0.55rem 0 0.2rem;
  padding-left: 1.15rem;
}

.ai-answer li {
  font-size: 14.5px;
  line-height: 1.68;
  color: var(--text-2);
  margin-bottom: 0.55rem;
  padding-left: 0.2rem;
}

.ai-answer li::marker {
  color: var(--faint);
}

.ai-answer strong {
  color: var(--text);
  font-weight: 620;
}

.ai-answer code {
  font-family: var(--mono);
  font-size: 12.5px;
  background: var(--surface-3);
  border-radius: 4px;
  padding: 0.1em 0.35em;
}

/* Citation marker. Quiet enough to read past, obvious enough to click: a
   reader must be able to verify any claim without the numbers shouting over
   the sentence they annotate. */
.cite {
  display: inline-block;
  min-width: 15px;
  margin: 0 1px;
  padding: 0 3px;
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 15px;
  text-align: center;
  vertical-align: 1px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: 4px;
  text-decoration: none;
}

.cite:hover {
  color: var(--bg);
  background: var(--accent);
}

.evidence-card {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  text-decoration: none;
}

.evidence-card + .evidence-card {
  margin-top: 0.5rem;
}

.evidence-card:hover {
  border-color: var(--border-strong);
}

.evidence-num {
  flex: none;
  width: 21px;
  height: 21px;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 21px;
  text-align: center;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: 5px;
}

.evidence-main {
  min-width: 0;
  flex: 1;
}

.evidence-head {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.evidence-text {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-2);
  white-space: pre-line;
}

.answer-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.answer-list li {
  position: relative;
  padding-left: 1.4rem;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-2);
}

.answer-list li::before {
  content: "";
  position: absolute;
  left: 0.35rem;
  top: 0.62em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.65;
}

.answer-list.outcomes li::before {
  border-radius: 1px;
  background: var(--green);
  opacity: 0.8;
}

.caveat {
  margin-top: 0.9rem;
  padding: 0.75rem 0.9rem;
  border-left: 2px solid var(--violet);
  background: var(--violet-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-2);
}

.person-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--border);
}

.person-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.person-row:first-child {
  padding-top: 0;
}

.person-main {
  min-width: 0;
  flex: 1;
}

.person-name {
  font-size: 14px;
  font-weight: 620;
}

.person-why {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 0.1rem;
}

.source-card {
  display: block;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  transition: border-color 0.12s ease;
}

.source-card:hover {
  border-color: var(--accent-line);
}

.source-card + .source-card {
  margin-top: 0.6rem;
}

.source-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.4rem;
  font-size: 11.5px;
  color: var(--muted);
}

.source-text {
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-2);
}

.source-foot {
  margin-top: 0.5rem;
  font-size: 12px;
  color: var(--accent);
  font-weight: 550;
}

/* ────────────────────────────────────────────────────────────── people */

.people-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
}

.person-card {
  display: block;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.12s ease, transform 0.12s ease;
}

.person-card:hover {
  border-color: var(--accent-line);
}

.person-card-head {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 0.7rem;
}

.person-card .avatar {
  width: 34px;
  height: 34px;
  font-size: 13px;
}

.topic-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.5rem;
}

.profile-head {
  display: flex;
  gap: 1.1rem;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.profile-head .avatar {
  width: 52px;
  height: 52px;
  font-size: 19px;
}

/* ─────────────────────────────────────────────────────────── daily brief */

.brief-head {
  padding: 1.5rem 1.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: linear-gradient(160deg, var(--surface-2), var(--surface));
  margin-bottom: 1.25rem;
}

.brief-date {
  font-size: 26px;
  font-weight: 640;
  letter-spacing: -0.025em;
  margin-top: 0.2rem;
}

.brief-stats {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
  margin-top: 1.1rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--border);
}

.brief-stat-value {
  font-size: 21px;
  font-weight: 620;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.brief-stat-label {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 0.1rem;
}

.brief-item {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}

.brief-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.brief-item:first-child {
  padding-top: 0;
}

.brief-item h3 {
  font-size: 14.5px;
  font-weight: 620;
  margin-bottom: 0.35rem;
}

.brief-item p {
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--text-2);
}

.conv-card {
  display: block;
  padding: 1rem 1.05rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.12s ease;
}

.conv-card:hover {
  border-color: var(--accent-line);
}

.conv-participants {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.7rem;
}

.conv-participants .avatar {
  width: 22px;
  height: 22px;
  font-size: 9.5px;
  margin-right: -0.45rem;
  box-shadow: 0 0 0 2px var(--surface);
}

/* ───────────────────────────────────────────────────────────── sources */

.source-tile {
  padding: 1.15rem 1.2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
}

.source-tile.planned {
  background: var(--surface-2);
  border-style: dashed;
}

.source-icon {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--surface-3);
  border: 1px solid var(--border);
  margin-bottom: 0.85rem;
}

.source-icon svg {
  width: 19px;
  height: 19px;
  color: var(--accent);
}

.source-tile.planned .source-icon svg {
  color: var(--faint);
}

.kv {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.4rem 0;
  font-size: 13px;
  border-top: 1px solid var(--border);
}

.kv:first-of-type {
  border-top: 0;
}

.kv .k {
  color: var(--muted);
}

.kv .v {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  text-align: right;
  overflow-wrap: anywhere;
}

/* ────────────────────────────────────────────────────────────── status */

.component-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.component-row:last-child {
  border-bottom: 0;
}

.component-name {
  font-size: 13.5px;
  font-weight: 570;
  min-width: 150px;
}

.component-detail {
  font-size: 12.5px;
  color: var(--muted);
  margin-left: auto;
  text-align: right;
}

details.advanced {
  margin-top: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

details.advanced > summary {
  padding: 0.75rem 1.1rem;
  cursor: pointer;
  font-size: 13px;
  font-weight: 560;
  color: var(--text-2);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

details.advanced > summary::-webkit-details-marker {
  display: none;
}

details.advanced > summary::before {
  content: "▸";
  color: var(--muted);
  font-size: 10px;
}

details.advanced[open] > summary::before {
  content: "▾";
}

details.advanced pre {
  margin: 0;
  padding: 0 1.1rem 1.1rem;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--muted);
  overflow-x: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ─────────────────────────────────────────────────────────── empty state */

.empty {
  padding: 3rem 1.5rem;
  text-align: center;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.empty svg {
  width: 26px;
  height: 26px;
  color: var(--faint);
  margin-bottom: 0.6rem;
}

.empty h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.empty p {
  font-size: 13px;
  color: var(--muted);
  max-width: 46ch;
  margin: 0 auto;
}

/* ─────────────────────────────────────────────────────────── pagination */

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.1rem;
  flex-wrap: wrap;
}

.result-count {
  font-size: 12.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ──────────────────────────────────────────────────────────────── login */

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1.25rem;
}

.login-card {
  width: 100%;
  max-width: 372px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 1.6rem;
}

.login-brand .brand-mark {
  width: 32px;
  height: 32px;
  font-size: 15px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

/* ─────────────────────────────────────────────────────────── responsive */

.menu-toggle {
  display: none;
}

.topbar {
  display: none;
}

@media (max-width: 900px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .topbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 30;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    width: 262px;
    transform: translateX(-100%);
    transition: transform 0.18s ease;
    box-shadow: var(--shadow);
  }

  .shell.nav-open .sidebar {
    transform: translateX(0);
  }

  .shell.nav-open .scrim {
    display: block;
  }

  .scrim {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(0, 0, 0, 0.45);
  }

  .menu-toggle {
    display: grid;
  }

  .page {
    padding: 1.25rem 1rem 4rem;
  }

  .chat-hero {
    padding: 1.5rem 0 1.25rem;
  }

  .chat-hero h1 {
    font-size: 24px;
  }

  .turn-user {
    max-width: 100%;
  }

  .turn-ai {
    padding: 1rem 0.9rem;
  }

  .thread-head {
    flex-wrap: wrap;
  }

  .thread-actions {
    margin-left: 0;
    width: 100%;
  }

  .who,
  .reslink {
    flex-wrap: wrap;
  }

  .who-actions {
    margin-left: auto;
  }

  .composer {
    padding-bottom: 0.6rem;
  }

  .brief-stats {
    gap: 1.25rem;
  }

  .component-row {
    flex-wrap: wrap;
  }

  .component-detail {
    margin-left: 0;
    text-align: left;
    width: 100%;
  }
}

@media print {
  .sidebar,
  .topbar,
  .pager {
    display: none;
  }
}
