/* ============================================
   CyberWatch - Mobile-first White Sleek CSS
   ============================================ */

:root {
  --bg: var(--ws-color-bg, #ffffff);
  --bg-card: var(--ws-color-bg-subtle, #f5f4f9);
  --bg-input: var(--ws-color-bg-muted, #e6e4ee);
  --text: var(--ws-color-text, #16121f);
  --text-muted: var(--ws-color-text-muted, #6b6580);
  --primary: var(--ws-color-primary, #451dc7);
  --primary-hover: var(--ws-color-primary-hover, #36169b);
  --danger: var(--ws-danger, #d8412f);
  --success: var(--ws-success, #088a42);
  --border: var(--ws-color-border, #e6e4ee);
  --accent: var(--ws-color-primary, #451dc7);
  --nav-height: 56px;
  /* --bottom-nav-height removed: nav is now top-only */
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);

  /* Hard-coded color overrides for dark mode */
  --badge-success-bg: #f0fdf4;
  --badge-success-border: #bbf7d0;
  --badge-danger-bg: #fef2f2;
  --badge-danger-border: #fecaca;
  --badge-muted-bg: #f3f4f6;
  --badge-accent-bg: var(--ws-color-primary-subtle, #f1eefb);
  --badge-primary-bg: #f3f4f6;
  --table-even: #fafafa;
  --table-hover: #f3f4f6;
  --overlay-bg: rgba(0, 0, 0, 0.3);
  --shadow-color: rgba(0, 0, 0, 0.06);
  --focus-ring: rgba(90, 43, 224, 0.22);
  --active-bg: var(--ws-color-primary-subtle, #f1eefb);
  --active-bg-subtle: var(--ws-color-primary-subtle, #f1eefb);
  --score-bg: rgba(17, 17, 17, 0.05);
  --swipe-star: #f59e0b;
  --swipe-read: #3b82f6;
  --read-title-color: var(--text-muted);
  --read-excerpt-color: #a0a0a0;
  --theme-color: #ffffff;
}

/* ============================================
   Dynamic intelligence dashboard
   ============================================ */
.trend-intelligence-page { max-width: 1500px; }
.trend-page-title { align-items: flex-end; margin-bottom: 1.25rem; }
.eyebrow { color: var(--text-muted); font-size: .7rem; font-weight: 700; letter-spacing: .14em; margin-bottom: .35rem; }
.trend-command-bar { padding: 1rem; display: grid; gap: 1rem; }
.trend-periods, .trend-command-controls, .trend-custom-dates { display: flex; align-items: flex-end; flex-wrap: wrap; gap: .5rem; }
.trend-command-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.trend-command-controls .btn { align-self: end; min-height: 42px; }
.compact-field { display: flex; flex-direction: column; gap: .25rem; min-width: 0; }
.compact-field > span, .trend-filter-panel label > span { color: var(--text-muted); font-size: .72rem; font-weight: 600; }
.trend-filter-panel { margin-top: .75rem; padding: 1rem; }
.trend-filter-grid { display: grid; gap: .85rem; }
.trend-checkbox { display: flex; gap: .5rem; align-items: center; color: var(--text-muted); font-size: .8rem; }
.trend-checkbox input { accent-color: var(--accent); }
.active-filter-summary { min-height: 2.6rem; display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; padding: .65rem 0; }
.active-filter-summary span { background: var(--bg-input); border: 1px solid var(--border); color: var(--text-muted); font-size: .72rem; padding: .25rem .5rem; }
.analysis-progress { padding: .85rem 1rem; margin-bottom: 1rem; }
.analysis-progress > div:first-child { display: flex; justify-content: space-between; font-size: .78rem; }
.progress-track { height: 3px; background: var(--border); margin-top: .7rem; overflow: hidden; }
.progress-track > div { height: 100%; background: var(--accent); transition: width .3s ease; }
.trend-run-summary { display: grid; grid-template-columns: repeat(2, 1fr); border: 1px solid var(--border); border-bottom: none; background: var(--bg); }
.trend-run-summary > div { padding: .75rem 1rem; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.trend-run-summary strong, .trend-run-summary span { display: block; }
.trend-run-summary strong { font-size: 1.15rem; }
.trend-run-summary span { color: var(--text-muted); font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; }
.trend-snapshot-action { border: 1px solid var(--border); border-top: 0; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem 1rem; }
.trend-snapshot-action > div { display: flex; flex-direction: column; gap: .15rem; }
.trend-snapshot-action strong { font-size: .78rem; }
.trend-snapshot-action span { color: var(--text-muted); font-size: .7rem; }
.trend-section-heading { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: .75rem; margin: 1.35rem 0 .65rem; }
.trend-section-heading h2 { margin: 0; font-size: 1.15rem; }
.trend-section-heading p { color: var(--text-muted); font-size: .76rem; margin: 0; max-width: 520px; }
.trend-evidence-notice { border: 1px solid var(--border); border-bottom: 0; background: var(--badge-accent-bg); color: var(--text-muted); font-size: .75rem; padding: .6rem .8rem; }
.trend-no-consolidated { border: 1px solid var(--border); margin-bottom: 1rem; }
.trend-table-card { padding: 0; overflow: hidden; }
.trend-table { min-width: 1080px; }
.trend-table th { color: var(--text-muted); font-size: .68rem; letter-spacing: .05em; text-transform: uppercase; white-space: nowrap; }
.trend-table th, .trend-table td { padding: .8rem .7rem; vertical-align: top; }
.trend-row { cursor: pointer; }
.trend-theme-cell { min-width: 350px; max-width: 540px; }
.trend-theme-cell p { color: var(--text-muted); font-size: .78rem; line-height: 1.45; margin: .3rem 0 0; }
.trend-label-line { display: flex; align-items: center; flex-wrap: wrap; gap: .35rem; }
.trend-pin { color: var(--accent); font-size: .6rem; }
.trend-score-value { display: inline-grid; place-items: center; width: 2.15rem; height: 2.15rem; background: var(--score-bg); font-weight: 700; }
.trend-date-pair { color: var(--text-muted); font-size: .72rem; line-height: 1.55; white-space: nowrap; }
.trend-growth { color: var(--text-muted); font-weight: 600; }
.trend-growth.positive { color: var(--success); }
.trend-growth.negative { color: var(--danger); }
.trend-signals { margin-top: 1rem; padding: 0; overflow: hidden; }
.trend-signals summary { cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 1rem; list-style: none; padding: .9rem 1rem; }
.trend-signals summary::-webkit-details-marker { display: none; }
.trend-signals summary > span:first-child { display: flex; flex-direction: column; }
.trend-signals summary small { color: var(--text-muted); font-size: .72rem; font-weight: 400; }
.trend-signals summary > span:last-child { color: var(--accent); font-size: .72rem; font-weight: 700; text-transform: uppercase; }
.trend-signal-list { border-top: 1px solid var(--border); display: grid; }
.trend-signal-list button { appearance: none; background: transparent; border: 0; border-bottom: 1px solid var(--border); color: var(--text); cursor: pointer; display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: .75rem 1rem; text-align: left; }
.trend-signal-list button:last-child { border-bottom: 0; }
.trend-signal-list button:hover { background: var(--table-hover); }
.trend-signal-list button > span { display: flex; flex-direction: column; gap: .2rem; }
.trend-signal-list small { color: var(--text-muted); font-size: .74rem; line-height: 1.4; }
.trend-signal-list em { color: var(--text-muted); font-size: .68rem; font-style: normal; white-space: nowrap; }
.trend-detail-drawer { margin-top: 1.25rem; scroll-margin-top: calc(var(--nav-height) + 1rem); }
.trend-detail-shell { padding: 0; overflow: hidden; }
.trend-detail-header { display: flex; gap: 1rem; justify-content: space-between; padding: 1.15rem; border-bottom: 1px solid var(--border); }
.trend-detail-header h2 { margin-bottom: .35rem; }
.trend-detail-header p { color: var(--text-muted); max-width: 800px; }
.trend-detail-actions { display: flex; align-items: flex-start; gap: .4rem; white-space: nowrap; }
.trend-close { border: 0; background: transparent; color: var(--text-muted); font-size: 1.7rem; line-height: 1; cursor: pointer; padding: 0 .25rem; }
.trend-detail-tabs { display: flex; overflow-x: auto; border-bottom: 1px solid var(--border); }
.trend-detail-tabs button { appearance: none; border: 0; border-right: 1px solid var(--border); border-bottom: 2px solid transparent; background: transparent; color: var(--text-muted); cursor: pointer; font: inherit; font-size: .76rem; padding: .75rem .9rem; text-transform: capitalize; }
.trend-detail-tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
#trend-detail-body { padding: 1rem; }
.trend-metric-grid { display: grid; grid-template-columns: repeat(2, 1fr); border-top: 1px solid var(--border); border-left: 1px solid var(--border); }
.trend-metric { padding: .8rem; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.trend-metric span, .trend-metric strong { display: block; }
.trend-metric span { color: var(--text-muted); font-size: .68rem; text-transform: uppercase; letter-spacing: .07em; }
.trend-metric strong { font-size: 1.2rem; margin-top: .15rem; }
.trend-overview-grid { display: grid; gap: 1rem; margin-top: 1.25rem; }
.trend-overview-grid section { border-top: 1px solid var(--border); padding-top: .8rem; }
.mini-timeline { height: 120px; display: flex; align-items: flex-end; gap: 3px; padding-top: 1rem; }
.mini-timeline > div { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 3px; min-width: 8px; }
.mini-timeline i { width: 100%; max-width: 22px; background: var(--accent); opacity: .72; }
.mini-timeline span { color: var(--text-muted); font-size: .58rem; }
.comparison-block { background: var(--bg-input); padding: 1rem; font-size: .82rem; line-height: 1.8; }
.evidence-list, .formulation-list { display: grid; gap: .55rem; }
.evidence-list article, .formulation-list article { border: 1px solid var(--border); padding: .85rem; }
.evidence-list article { cursor: pointer; }
.evidence-list article:hover { background: var(--table-hover); }
.evidence-list article > div:first-child { display: flex; gap: .5rem; align-items: flex-start; justify-content: space-between; }
.evidence-list p, .formulation-list p { color: var(--text-muted); font-size: .78rem; margin: .35rem 0; }
.evidence-list small, .formulation-list small { color: var(--text-muted); }
.paragraph-evidence article { cursor: default; }
.paragraph-evidence blockquote { border-left: 2px solid var(--accent); margin: .55rem 0; padding-left: .75rem; font-size: .84rem; }
.paragraph-evidence article > div:last-child { display: flex; justify-content: space-between; gap: 1rem; font-size: .72rem; }
.entity-cloud { display: flex; flex-wrap: wrap; gap: .5rem; }
.entity-cloud > span { display: flex; flex-direction: column; border: 1px solid var(--border); padding: .55rem .7rem; }
.entity-cloud small { color: var(--text-muted); }
.analysis-metadata { display: grid; grid-template-columns: minmax(110px, .4fr) 1fr; border-top: 1px solid var(--border); border-left: 1px solid var(--border); }
.analysis-metadata dt, .analysis-metadata dd { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: .65rem; overflow-wrap: anywhere; }
.analysis-metadata dt { color: var(--text-muted); font-size: .72rem; }
.error-state { border-color: var(--danger); color: var(--danger); padding: 1rem; }
.trend-workflow-open { overflow: hidden; }
.trend-reader-workflow { display: none; position: fixed; inset: var(--nav-height) 0 0; z-index: 1200; pointer-events: none; }
.trend-reader-workflow.open { display: block; pointer-events: auto; }
.trend-reader-backdrop { appearance: none; position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: var(--overlay-bg); opacity: 0; transition: opacity .28s ease; cursor: default; }
.trend-reader-workflow.open .trend-reader-backdrop { opacity: 1; }
.trend-reader-pane { position: absolute; top: 0; right: 0; bottom: 0; width: min(100%, 620px); overflow-y: auto; overscroll-behavior: contain; background: var(--bg); border-left: 1px solid var(--border); box-shadow: -12px 0 32px rgba(0, 0, 0, .12); transform: translateX(100%); transition: transform .28s cubic-bezier(.22, .61, .36, 1); will-change: transform; -webkit-overflow-scrolling: touch; }
.trend-reader-pane.active { transform: translateX(0); }
.trend-articles-pane { z-index: 1; }
.trend-article-pane { z-index: 2; width: min(100%, 760px); }
.reader-detail { min-height: 100%; background: var(--bg); }
.rd-header { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: .5rem; padding: .6rem .75rem; border-bottom: 1px solid var(--border); background: var(--bg); }
.rd-back { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border: 0; background: transparent; color: var(--text-muted); cursor: pointer; }
.rd-back:hover, .rd-back:focus-visible { color: var(--primary); outline: none; }
.rd-header-title { color: var(--text); font-size: .9rem; font-weight: 600; }
.trend-reader-pane .rd-header { top: 0; }
.trend-article-pane .reader-detail { min-height: 100%; }
.trend-pane-content { padding-bottom: 2rem; }
.trend-reader-theme-header { border-bottom: 1px solid var(--border); padding: 1.15rem 1rem; }
.trend-reader-theme-header h1 { font-size: 1.25rem; line-height: 1.35; margin: 0 0 .45rem; overflow-wrap: anywhere; }
.trend-reader-theme-header p { color: var(--text-muted); font-size: .84rem; line-height: 1.55; margin: 0; }
.trend-reader-theme-meta { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .8rem; }
.trend-reader-theme-meta span { border: 1px solid var(--border); color: var(--text-muted); font-size: .68rem; padding: .2rem .4rem; }
.trend-reader-article-list { display: grid; }
.trend-reader-article { appearance: none; position: relative; display: flex; flex-direction: column; gap: .35rem; width: 100%; min-width: 0; padding: .9rem 2.5rem .9rem 1rem; border: 0; border-bottom: 1px solid var(--border); background: var(--bg); color: var(--text); cursor: pointer; font: inherit; text-align: left; }
.trend-reader-article:hover, .trend-reader-article:focus-visible { background: var(--table-hover); outline: none; }
.trend-reader-article-title { font-size: .95rem; font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; }
.trend-reader-article-summary { display: -webkit-box; overflow: hidden; color: var(--text-muted); font-size: .78rem; line-height: 1.45; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.trend-reader-article-meta { display: flex; align-items: center; flex-wrap: wrap; gap: .35rem .55rem; color: var(--text-muted); font-size: .68rem; }
.trend-reader-article-meta strong { color: var(--text-muted); font-size: inherit; letter-spacing: .03em; text-transform: uppercase; }
.trend-reader-article-chevron { position: absolute; right: .9rem; top: 50%; color: var(--text-muted); transform: translateY(-50%); }
.trend-pane-message { margin: 1rem; }
.rd-intelligence-summary { border-left: 2px solid var(--accent); padding-left: .9rem; }
.rd-analysis-meta { display: flex; flex-wrap: wrap; gap: .4rem; color: var(--text-muted); font-size: .72rem; margin-top: .5rem; }
.rd-analysis-meta span { border: 1px solid var(--border); padding: .2rem .4rem; }
.rd-chip.active { border-color: var(--accent); color: var(--accent); }
.rd-content-toolbar { display: flex; align-items: center; justify-content: space-between; gap: .75rem; border-bottom: 1px solid var(--border); padding-bottom: .5rem; }
.rd-content-toolbar label { color: var(--text-muted); font-size: .72rem; white-space: nowrap; }
.rd-content-block { padding: .7rem 0; border-bottom: 1px solid var(--border); }
.rd-content-block h3 { font-size: 1.05rem; margin-top: .6rem; }
.rd-content-block p, .rd-content-block blockquote, .rd-content-block pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.rd-content-block blockquote { border-left: 2px solid var(--border); padding-left: .75rem; color: var(--text-muted); }
.rd-content-block.supports-theme { background: var(--badge-accent-bg); border-left: 3px solid var(--accent); padding: .75rem; }
.rd-content-block footer { display: flex; justify-content: space-between; gap: .75rem; color: var(--text-muted); font-size: .68rem; margin-top: .45rem; }
.config-section-header { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; align-items: flex-start; margin-bottom: 1rem; }
.config-section-header > div { min-width: 0; max-width: 100%; }
.config-section-header h2, .config-section-header h3, .config-section-header p { overflow-wrap: anywhere; }
.intelligence-admin-summary { border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; }
.admin-intelligence-grid { display: grid; gap: 1.5rem; min-width: 0; }
.admin-intelligence-grid > *, .audit-viewer, .pipeline-status-list { min-width: 0; }
.admin-intelligence-grid section, .audit-viewer { border-top: 1px solid var(--border); padding-top: .85rem; }
.admin-category-list, .pipeline-status-list, .pipeline-failure-list { display: grid; gap: .4rem; }
.admin-category-list button { display: flex; justify-content: space-between; align-items: center; gap: .75rem; background: transparent; border: 1px solid var(--border); color: var(--text); padding: .65rem; text-align: left; cursor: pointer; }
.admin-category-list button:hover { background: var(--table-hover); }
.admin-category-list button span:first-child { display: flex; flex-direction: column; }
.admin-category-list small { color: var(--text-muted); }
.pipeline-status-list > div { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: .5rem; border-bottom: 1px solid var(--border); padding: .5rem 0; }
.pipeline-status-list > div > :first-child { min-width: 0; overflow-wrap: anywhere; }
.pipeline-failure-list article { border-left: 2px solid var(--danger); padding: .5rem .7rem; background: var(--bg-input); }
.pipeline-failure-list p { color: var(--text-muted); font-size: .75rem; margin: .2rem 0; overflow-wrap: anywhere; }
.audit-viewer { margin-top: 1.5rem; }
.queue-health-grid { display: grid; gap: .75rem; margin-bottom: 1rem; }
.queue-health-grid section { border: 1px solid var(--border); padding: .85rem; }
.queue-health-grid section > span { color: var(--text-muted); display: block; font-size: .68rem; font-weight: 700; letter-spacing: .08em; margin-bottom: .55rem; text-transform: uppercase; }
.queue-health-grid section > div { align-items: center; display: flex; flex-wrap: wrap; gap: .6rem; }
.queue-health-grid section strong { font-size: .85rem; }
.queue-health-grid section small { color: var(--text-muted); display: block; font-size: .72rem; margin-top: .45rem; }
.queue-stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 1.25rem; }
.queue-last-error { background: var(--badge-danger-bg); border-left: 3px solid var(--danger); display: grid; gap: .25rem; margin-bottom: 1rem; padding: .75rem; }
.queue-last-error span { color: var(--danger); font-size: .78rem; overflow-wrap: anywhere; }
.queue-last-error small, .queue-task-section > div small, .queue-telemetry-note { color: var(--text-muted); font-size: .7rem; }
.queue-task-section { border-top: 1px solid var(--border); padding-top: 1rem; }
.queue-task-section > div:first-child { align-items: baseline; display: flex; flex-wrap: wrap; justify-content: space-between; gap: .4rem 1rem; margin-bottom: .65rem; }
.queue-task-section h3 { margin: 0; }
.queue-task-section table { min-width: 720px; }
.queue-telemetry-note { line-height: 1.45; margin: .75rem 0 0; }
.search-paragraph-preview { border-left: 2px solid var(--accent); background: var(--bg-input); color: var(--text-muted); font-size: .8rem; margin: .65rem 0; padding: .65rem .8rem; }
@media (min-width: 900px) {
  .admin-intelligence-grid, .queue-health-grid { grid-template-columns: 1fr 1fr; }
  .queue-stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 767px) {
  .trend-page-title { align-items: flex-start; flex-direction: column; }
  .trend-page-title .btn { width: 100%; }
  .trend-command-bar { padding: .75rem; }
  .trend-periods { display: grid; grid-template-columns: repeat(4, 1fr); width: 100%; }
  .trend-periods button { min-width: 0; padding-left: .35rem; padding-right: .35rem; }
  .trend-command-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .trend-command-controls #trend-analyse-btn { grid-column: 1 / -1; width: 100%; }
  .trend-custom-dates { align-items: stretch; flex-direction: column; }
  .trend-custom-dates .compact-field { width: 100%; }
  .trend-run-summary > div { min-width: 0; }
  .trend-snapshot-action { align-items: stretch; flex-direction: column; }
  .trend-snapshot-action .btn { width: 100%; }
  .trend-section-heading { align-items: flex-start; flex-direction: column; }
  .trend-table-card { border: 0; overflow: visible; }
  .trend-table-card .table-responsive { overflow: visible; }
  .trend-table { display: block; min-width: 0; width: 100%; }
  .trend-table thead { display: none; }
  .trend-table tbody { display: grid; gap: .75rem; }
  .trend-table tr.trend-row { border: 1px solid var(--border); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: .8rem; }
  .trend-table tr.trend-row td { border: 0; display: flex; flex-direction: column; min-width: 0; padding: .4rem .25rem; }
  .trend-table tr.trend-row td:first-child { border-bottom: 1px solid var(--border); grid-column: 1 / -1; margin-bottom: .35rem; padding-bottom: .75rem; }
  .trend-table tr.trend-row td[data-label]::before { color: var(--text-muted); content: attr(data-label); font-size: .6rem; font-weight: 700; letter-spacing: .07em; margin-bottom: .15rem; text-transform: uppercase; }
  .trend-theme-cell { max-width: none; min-width: 0; }
  .trend-theme-cell p { font-size: .8rem; }
  .trend-date-pair { white-space: normal; }
  .trend-signals summary { align-items: flex-start; }
  .trend-signal-list button { align-items: flex-start; flex-direction: column; }
  .trend-reader-pane { border-left: 0; box-shadow: none; }
  .trend-reader-theme-header { padding: 1rem .75rem; }
  .trend-reader-article { padding-left: .75rem; }
}

@media (prefers-reduced-motion: reduce) {
  .trend-reader-backdrop, .trend-reader-pane { transition-duration: .01ms; }
}

@media (min-width: 768px) {
  .trend-command-bar { grid-template-columns: auto 1fr; align-items: end; }
  .trend-command-controls { display: flex; justify-content: flex-end; }
  .trend-command-controls .compact-field { min-width: 140px; }
  .trend-custom-dates { grid-column: 1 / -1; justify-content: flex-end; }
  .trend-filter-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .trend-run-summary { grid-template-columns: repeat(4, 1fr); }
  .trend-run-summary > div { border-bottom: 0; }
  .trend-metric-grid { grid-template-columns: repeat(6, 1fr); }
  .trend-overview-grid { grid-template-columns: 2fr 1fr; }
}

/* ============================================
   Dark theme variables
   ============================================ */
[data-theme="dark"] {
  --bg: #111113;
  --bg-card: #1a1a1e;
  --bg-input: #222228;
  --text: #e4e4e7;
  --text-muted: #8b8b95;
  --primary: #e4e4e7;
  --primary-hover: #c0c0c8;
  --danger: #ef4444;
  --success: #22c55e;
  --border: #2e2e35;
  --accent: #818cf8;
  --badge-success-bg: #0a2614;
  --badge-success-border: #14532d;
  --badge-danger-bg: #2a0a0a;
  --badge-danger-border: #7f1d1d;
  --badge-muted-bg: #1f1f24;
  --badge-accent-bg: #1a1a30;
  --badge-primary-bg: #1f1f24;
  --table-even: #16161a;
  --table-hover: #1e1e24;
  --overlay-bg: rgba(0, 0, 0, 0.6);
  --shadow-color: rgba(0, 0, 0, 0.3);
  --focus-ring: rgba(228, 228, 231, 0.15);
  --active-bg: rgba(228, 228, 231, 0.08);
  --active-bg-subtle: rgba(228, 228, 231, 0.04);
  --score-bg: rgba(228, 228, 231, 0.08);
  --swipe-star: #f59e0b;
  --swipe-read: #3b82f6;
  --read-title-color: #6b6b75;
  --read-excerpt-color: #55555e;
  --btn-primary-bg: #3a3a42;
  --btn-primary-text: #e4e4e7;
  --btn-primary-hover: #4a4a54;
  --theme-color: #111113;
  color-scheme: dark;
}

/* Auto dark mode (when theme preference is "auto" or not set) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --bg: #111113;
    --bg-card: #1a1a1e;
    --bg-input: #222228;
    --text: #e4e4e7;
    --text-muted: #8b8b95;
    --primary: #e4e4e7;
    --primary-hover: #c0c0c8;
    --danger: #ef4444;
    --success: #22c55e;
    --border: #2e2e35;
    --accent: #818cf8;
    --badge-success-bg: #0a2614;
    --badge-success-border: #14532d;
    --badge-danger-bg: #2a0a0a;
    --badge-danger-border: #7f1d1d;
    --badge-muted-bg: #1f1f24;
    --badge-accent-bg: #1a1a30;
    --badge-primary-bg: #1f1f24;
    --table-even: #16161a;
    --table-hover: #1e1e24;
    --overlay-bg: rgba(0, 0, 0, 0.6);
    --shadow-color: rgba(0, 0, 0, 0.3);
    --focus-ring: rgba(228, 228, 231, 0.15);
    --active-bg: rgba(228, 228, 231, 0.08);
    --active-bg-subtle: rgba(228, 228, 231, 0.04);
    --score-bg: rgba(228, 228, 231, 0.08);
    --swipe-star: #f59e0b;
    --swipe-read: #3b82f6;
    --read-title-color: #6b6b75;
    --read-excerpt-color: #55555e;
    --btn-primary-bg: #3a3a42;
    --btn-primary-text: #e4e4e7;
    --btn-primary-hover: #4a4a54;
    --theme-color: #111113;
    color-scheme: dark;
  }
}

/* Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Base - Mobile first */
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

a {
  color: var(--primary);
  text-decoration: none;
}

h1, h2, h3, h4 {
  font-weight: 600;
  margin-bottom: 0.5rem;
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.1rem; }

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

/* ============================================
   Navigation - Top bar with tabs
   ============================================ */

/* Top bar */
nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0;
  height: var(--nav-height);
}

.nav-container {
  display: flex;
  align-items: center;
  width: 100%;
  height: 100%;
}

.nav-brand {
  color: var(--text);
  flex-shrink: 0;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  padding-left: 0.65rem;
  text-decoration: none;
}

/* Mobile top tabs */
.top-tabs {
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  flex: 1;
  height: 100%;
}

.top-tabs a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  color: var(--text-muted);
  font-size: 0.6rem;
  font-weight: 500;
  text-decoration: none;
  padding: 0.25rem 0;
  gap: 0.15rem;
  transition: color 0.2s;
  min-width: 0;
}

.top-tabs a span:last-child,
.more-menu-btn span:last-child {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-tabs a .nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  line-height: 1;
}

.top-tabs a .nav-icon svg {
  display: block;
}

.top-tabs a.active {
  color: var(--primary);
}

.top-tabs a:active,
.top-tabs .more-menu-btn:active {
  background: var(--active-bg-subtle);
}

/* More menu button in top tabs */
.more-menu-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  color: var(--text-muted);
  font-size: 0.6rem;
  font-weight: 500;
  background: none;
  border: none;
  padding: 0.25rem 0;
  gap: 0.15rem;
  cursor: pointer;
  font-family: inherit;
  min-width: 0;
}

.more-menu-btn .nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  line-height: 1;
}

.more-menu-btn .nav-icon svg {
  display: block;
}

.more-menu-btn.active {
  color: var(--primary);
}

/* Desktop nav links: hidden on mobile */
.nav-links {
  display: none;
}

.nav-links a {
  color: var(--text-muted);
  padding: 0.5rem 1rem;
  border-radius: 0;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
}

.nav-link-disabled {
  color: var(--ws-color-text-subtle, #817c95);
  cursor: not-allowed;
  font-size: 0.875rem;
  font-weight: 500;
  opacity: 0.48;
  padding: 0.5rem 1rem;
  white-space: nowrap;
}

.nav-links a:hover {
  color: var(--text);
  background: var(--bg-input);
}

.nav-links a.active {
  color: var(--primary);
  background: var(--active-bg);
}

.nav-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

#user-display {
  display: none;
}

.nav-right #logout-btn,
.nav-right .ai-label {
  display: none;
}

/* More menu overlay */
.more-menu-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
}

.more-menu {
  position: fixed;
  top: var(--nav-height);
  right: 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  min-width: 200px;
  z-index: 1000;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}

.more-menu-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  color: var(--text);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  border-bottom: 1px solid var(--border);
  width: 100%;
  background: none;
  border-left: none;
  border-right: none;
  border-top: none;
  cursor: pointer;
  font-family: inherit;
}

.more-menu-item:last-child {
  border-bottom: none;
}

.more-menu-item:active {
  background: var(--active-bg-subtle);
}

.more-menu-item.active {
  color: var(--primary);
}

.menu-item-disabled {
  color: var(--ws-color-text-subtle, #817c95);
  cursor: not-allowed;
  opacity: 0.48;
}

.menu-item-disabled:active { background: none; }

.more-menu-item svg {
  flex-shrink: 0;
}

.more-menu-logout {
  color: var(--danger, #e53e3e);
}

/* Main content area */
#app {
  padding-top: calc(var(--nav-height) + 12px);
  padding-bottom: 16px;
}

/* AI status indicator */
.ai-indicator {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0 0.5rem;
  flex-shrink: 0;
}

.ai-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9ca3af;
  transition: background 0.3s;
}

.ai-indicator.connected .ai-dot {
  background: #22c55e;
}

.ai-label {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

/* Global refresh button */
.global-refresh-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 0 0.5rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.2s;
  min-width: 40px;
  min-height: 44px;
}

.global-refresh-btn span {
  display: none;
  font-size: 0.75rem;
  font-weight: 600;
}

.global-refresh-btn:hover {
  color: var(--text);
}

.global-refresh-btn.spinning svg {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* LLM activity panel */
.llm-activity-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 2000;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
}

.llm-activity-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  min-height: 32px;
}

.llm-activity-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.llm-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  display: none;
}

.llm-spinner.active {
  display: block;
  animation: spin 0.8s linear infinite;
}

.llm-activity-label {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.llm-activity-toggle {
  color: var(--text-muted);
  font-size: 0.7rem;
  transition: transform 0.2s;
}

.llm-activity-panel.expanded .llm-activity-toggle {
  transform: rotate(180deg);
}

.llm-activity-body {
  max-height: 200px;
  overflow-y: auto;
  border-top: 1px solid var(--border);
}

.llm-activity-log {
  padding: 0.5rem 0.75rem;
  font-family: monospace;
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-all;
}

.llm-log-entry {
  padding: 0.25rem 0;
  border-bottom: 1px solid var(--border);
}

.llm-log-entry:last-child {
  border-bottom: none;
}

.llm-log-time {
  color: var(--text-muted);
  margin-right: 0.5rem;
}

.llm-log-endpoint {
  color: var(--primary);
  font-weight: 500;
}

/* Container */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 0.75rem;
  min-width: 0;
}

/* ============================================
   Cards
   ============================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 1rem;
  margin-bottom: 0.75rem;
  box-shadow: none;
  min-width: 0;
  max-width: 100%;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

/* ============================================
   Tabs - horizontal scroll on mobile
   ============================================ */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  padding: 0.75rem 1rem;
  cursor: pointer;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.8125rem;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.2s, border-color 0.2s;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  white-space: nowrap;
  flex-shrink: 0;
  min-height: 44px;
}

.tab:hover { color: var(--text); }

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* Settings information architecture */
.settings-heading { margin-bottom: 1rem; }
.settings-heading h1 { margin-bottom: 0.25rem; }
.settings-heading p { color: var(--text-muted); margin: 0; max-width: 680px; }

.settings-layout { display: grid; gap: 1rem; min-width: 0; width: 100%; }
.settings-nav {
  display: flex;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}
.settings-nav::-webkit-scrollbar { display: none; }
.settings-nav-group { display: contents; }
.settings-nav-group > span { display: none; }
.settings-nav-item {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0.7rem 0.85rem;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
}
.settings-nav-item strong { display: block; font-size: 0.8125rem; font-weight: 600; }
.settings-nav-item small { display: none; }
.settings-nav-item:hover { color: var(--text); }
.settings-nav-item.active { color: var(--primary); border-bottom-color: var(--primary); }
.settings-panel { min-width: 0; max-width: 100%; margin: 0; }
.settings-panel .tab-content { min-width: 0; max-width: 100%; }
.settings-panel .tab-content > *, .settings-panel section { min-width: 0; max-width: 100%; }
.settings-panel .table-responsive { max-width: 100%; overflow-x: auto; }
.settings-panel .config-section-header h2 { margin: 0 0 0.25rem; }
.settings-panel .config-section-header p { max-width: 720px; margin: 0; }

/* ============================================
   Forms - Mobile first (single column)
   ============================================ */
label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"],
input[type="url"],
input[type="date"],
select,
textarea {
  width: 100%;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 0.75rem;
  font-size: 16px; /* prevents iOS zoom on focus */
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
  appearance: none;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

textarea {
  resize: vertical;
  min-height: 80px;
}

.form-group { margin-bottom: 1rem; }

.form-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
}

/* ============================================
   Buttons - 44px minimum touch target
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 1.1rem;
  border: none;
  border-radius: 0;
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  min-height: 44px;
  touch-action: manipulation;
  background: var(--bg-input);
  color: var(--text);
}

.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--btn-primary-bg, var(--primary)); color: var(--btn-primary-text, #fff); }
.btn-primary:hover { background: var(--btn-primary-hover, var(--primary-hover)); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c0392b; }

.btn-secondary {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

.btn-sm {
  padding: 0.45rem 0.75rem;
  font-size: 0.8125rem;
  min-height: 38px;
}

.btn-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn-block {
  width: 100%;
}

/* ============================================
   Tables - Hidden on mobile, replaced by cards
   ============================================ */
table {
  width: 100%;
  border-collapse: collapse;
  display: none;
}

thead th {
  text-align: left;
  padding: 0.65rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 0.65rem 0.75rem;
  font-size: 0.8125rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:nth-child(even) { background: var(--table-even); }
tbody tr:hover { background: var(--table-hover); }

/* Mobile card list (replaces tables) */
.mobile-card-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.mobile-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 0.875rem;
}

.mobile-card-title {
  font-weight: 600;
  font-size: 0.9375rem;
  margin-bottom: 0.35rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.mobile-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.mobile-card-meta-item {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.mobile-card-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.mobile-card-actions .btn {
  flex: 1;
}

/* ============================================
   Modal - Full screen on mobile
   ============================================ */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--overlay-bg);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 2500;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 1.25rem;
  width: 100%;
  max-height: 92vh;
  max-height: 92dvh;
  overflow-y: auto;
  box-shadow: 0 -4px 32px var(--shadow-color);
  -webkit-overflow-scrolling: touch;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 { margin-bottom: 0; }

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.5rem;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.modal-close:hover { color: var(--text); }

.modal-footer {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.modal-footer .btn {
  flex: 1;
}

/* ============================================
   Watch Query Preview Modal
   ============================================ */
.wq-preview-modal {
  max-width: 700px;
}

.wq-preview-stats {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.wq-preview-section {
  margin-bottom: 1rem;
}

.wq-preview-section h4 {
  margin: 0 0 0.5rem 0;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.wq-preview-items {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.wq-preview-item {
  border: 1px solid var(--border);
  padding: 0.75rem;
}

.wq-preview-item-header {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.wq-preview-check {
  flex-shrink: 0;
  margin-top: 0.15rem;
}

.wq-preview-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.wq-preview-item-title {
  flex: 1;
  line-height: 1.3;
}

.wq-preview-item-body {
  padding-left: 1.5rem;
}

.wq-preview-item-body p {
  margin: 0 0 0.25rem 0;
  line-height: 1.4;
}

.wq-preview-url {
  color: var(--primary);
  word-break: break-all;
  display: inline-block;
}

.wq-preview-item-meta {
  padding-left: 1.5rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.35rem;
}

.wq-preview-raw-toggle {
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 0.35rem 0;
  user-select: none;
}

.wq-preview-raw-toggle:hover {
  color: var(--text);
}

.wq-preview-raw {
  background: var(--bg-page);
  border: 1px solid var(--border);
  padding: 0.75rem;
  font-size: 0.75rem;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 300px;
  overflow-y: auto;
  margin-top: 0.5rem;
}

/* ============================================
   Badges
   ============================================ */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 0;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-success { background: var(--badge-success-bg); color: var(--success); }
.badge-danger { background: var(--badge-danger-bg); color: var(--danger); }
.badge-muted { background: var(--badge-muted-bg); color: var(--text-muted); }
.badge-primary { background: var(--badge-primary-bg); color: var(--primary); }

/* ============================================
   Toggle switch
   ============================================ */
.toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 26px;
  cursor: pointer;
  flex-shrink: 0;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 0;
  transition: background 0.2s;
}

.toggle-slider::before {
  content: 'O';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: var(--text-muted);
  border-radius: 0;
  transition: transform 0.2s, background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--bg-card, #fff);
  line-height: 1;
}

.toggle input:checked + .toggle-slider {
  background: var(--focus-ring);
  border-color: var(--primary);
}

.toggle input:checked + .toggle-slider::before {
  content: 'I';
  transform: translateX(18px);
  background: var(--primary);
}

/* ============================================
   Toast notifications
   ============================================ */
.toast-container {
  position: fixed;
  bottom: 0.75rem;
  left: 0.75rem;
  right: 0.75rem;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  padding: 0.75rem 1rem;
  border-radius: 0;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: 0 4px 12px var(--shadow-color);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
}

.toast-success {
  background: var(--badge-success-bg);
  color: var(--success);
  border: 1px solid var(--badge-success-border);
}

.toast-error {
  background: var(--badge-danger-bg);
  color: var(--danger);
  border: 1px solid var(--badge-danger-border);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(1rem); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(1rem); }
}

/* ============================================
   Utility
   ============================================ */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.text-sm { font-size: 0.8125rem; }
.text-right { text-align: right; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full { width: 100%; }

/* Masked value display */
.masked-value {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.8125rem;
  color: var(--text-muted);
  letter-spacing: 1px;
  word-break: break-all;
}

/* Config key row - stacked on mobile */
.config-key-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.875rem 0;
  border-bottom: 1px solid var(--border);
}

.config-key-row:last-child { border-bottom: none; }

.config-key-label {
  font-weight: 500;
  font-size: 0.875rem;
  min-width: 0;
  overflow-wrap: anywhere;
}

.config-key-value {
  flex: 1;
  min-width: 0;
}

.config-key-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  min-width: 0;
}

.llm-settings-card {
  border: 1px solid var(--border);
  max-width: 100%;
  min-width: 0;
  padding: 1rem;
  margin-bottom: 1rem;
  background: var(--bg-card);
}

.llm-settings-card h3 { margin: 0 0 0.25rem; }

.llm-routing-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--border);
  width: 100%;
}

.llm-routing-switch button {
  border: 0;
  border-right: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  padding: 0.625rem 0.75rem;
  cursor: pointer;
}

.llm-routing-switch button:last-child { border-right: 0; }
.llm-routing-switch button.active { background: var(--primary); color: #fff; }

.llm-route-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

.llm-route-grid label {
  display: grid;
  gap: 0.35rem;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.llm-route-grid select { width: 100%; }

.llm-activity-route {
  display: grid;
  gap: 0.75rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}

.llm-activity-route:last-child { border-bottom: 0; }
.llm-activity-copy { display: grid; gap: 0.2rem; min-width: 0; }
.llm-activity-copy strong, .llm-activity-copy span { overflow-wrap: anywhere; }
.llm-activity-copy span { color: var(--text-muted); font-size: 0.75rem; }

.llm-routing-footer {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: stretch;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.llm-key-status { display: inline-flex; align-items: center; gap: 0.45rem; }
.llm-key-status .ai-dot { position: static; display: inline-block; }

/* LLM Query result styles */
.llm-response-content {
  line-height: 1.6;
}

.llm-text-output p {
  margin: 0 0 0.5rem;
}

.llm-text-output h2,
.llm-text-output h3,
.llm-text-output h4 {
  color: var(--text);
}

.llm-text-output ul {
  list-style: disc;
}

.llm-text-output code {
  background: var(--bg-input);
  padding: 0.15rem 0.4rem;
  font-size: 0.85em;
  font-family: monospace;
}

.llm-json-output,
.llm-code-block {
  background: var(--bg-input);
  border: 1px solid var(--border);
  padding: 1rem;
  overflow-x: auto;
  font-size: 0.8rem;
  font-family: monospace;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
}

.empty-state p { margin-top: 0.5rem; }

/* ============================================
   Login page
   ============================================ */
.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 1.5rem;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 2rem 1.5rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 8px 32px var(--shadow-color);
}

.login-header {
  text-align: center;
  margin-bottom: 1.75rem;
}

.login-brand {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.25rem;
}

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

.password-wrapper input {
  flex: 1;
  padding-right: 2.75rem;
}

.password-toggle {
  position: absolute;
  right: 0.75rem;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  line-height: 1;
}

.password-toggle:hover {
  color: var(--text);
}

.remember-me {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  cursor: pointer;
}

.remember-me input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

.remember-me label {
  cursor: pointer;
}

.login-btn {
  width: 100%;
  padding: 0.875rem;
  font-size: 1rem;
  margin-top: 0.5rem;
}

.login-error {
  background: var(--badge-danger-bg);
  color: var(--danger);
  border: 1px solid var(--badge-danger-border);
  border-radius: 0;
  padding: 0.75rem;
  font-size: 0.875rem;
  margin-bottom: 0.75rem;
}

/* ============================================
   Stats grid
   ============================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.stat-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 1rem;
  text-align: center;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
}

.stat-label {
  font-size: 0.6875rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ============================================
   Prompt editor cards
   ============================================ */
.prompt-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 1rem;
  margin-bottom: 0.75rem;
}

.prompt-card textarea {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.8125rem;
}

/* ============================================
   DESKTOP BREAKPOINT (min-width: 768px)
   ============================================ */
@media (min-width: 768px) {
  body { font-size: 14px; }
  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.4rem; }
  h3 { font-size: 1.15rem; }

  /* Nav: show desktop links, hide mobile top tabs */
  .top-tabs { display: none; }

  .nav-links {
    display: flex;
    gap: 0.25rem;
    margin-left: 1.5rem;
  }

  .nav-brand {
    font-size: 1rem;
    padding-left: 0;
  }

  nav { padding: 0 1rem; }

  #user-display { display: inline; }

  .nav-right #logout-btn { display: inline-flex; }

  .nav-right .ai-label { display: inline; }

  .global-refresh-btn span { display: inline; }

  #app {
    padding-top: calc(var(--nav-height) + 16px);
    padding-bottom: 2rem;
  }

  .container { padding: 0 1.5rem; }

  .card { padding: 1.5rem; margin-bottom: 1rem; }

  .tabs { margin-bottom: 1.5rem; }

  .settings-layout { grid-template-columns: 240px minmax(0, 1fr); align-items: start; }
  .settings-nav {
    display: block;
    overflow: visible;
    border: 1px solid var(--border);
    background: var(--bg-card);
    padding: 0.5rem 0;
  }
  .settings-nav-group { display: block; padding: 0.5rem 0; }
  .settings-nav-group + .settings-nav-group { border-top: 1px solid var(--border); }
  .settings-nav-group > span {
    display: block;
    padding: 0.35rem 1rem;
    color: var(--text-muted);
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }
  .settings-nav-item {
    display: block;
    width: 100%;
    min-height: 0;
    padding: 0.65rem 1rem;
    border-bottom: 0;
    border-left: 3px solid transparent;
    white-space: normal;
  }
  .settings-nav-item small { display: block; margin-top: 0.15rem; color: var(--text-muted); line-height: 1.3; }
  .settings-nav-item.active { background: var(--badge-accent-bg); border-left-color: var(--primary); }

  /* Forms: 2-column on desktop */
  .form-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
  }

  input[type="text"],
  input[type="password"],
  input[type="number"],
  input[type="email"],
  input[type="url"],
  select,
  textarea {
    font-size: 0.875rem;
    padding: 0.6rem 0.75rem;
  }

  .btn {
    min-height: auto;
    padding: 0.55rem 1.1rem;
    font-size: 0.8125rem;
  }

  .btn-sm {
    padding: 0.35rem 0.7rem;
    font-size: 0.75rem;
    min-height: auto;
  }

  /* Tables: show on desktop */
  table { display: table; }

  /* Mobile cards: hide on desktop */
  .mobile-card-list { display: none; }

  /* Modal: centered dialog on desktop */
  .modal-overlay {
    align-items: center;
    background: var(--overlay-bg);
    backdrop-filter: blur(2px);
  }

  .modal {
    border-radius: 0;
    max-width: 600px;
    max-height: 85vh;
    width: 90%;
  }

  .modal-footer .btn { flex: initial; }

  .modal-close {
    min-width: auto;
    min-height: auto;
    padding: 0.25rem;
    font-size: 1.25rem;
  }

  .llm-routing-switch { width: auto; min-width: 230px; }
  .llm-route-grid { grid-template-columns: minmax(0, 0.65fr) minmax(0, 1.35fr); }
  .llm-route-unified { max-width: 760px; }
  .llm-routing-footer { flex-direction: row; justify-content: flex-end; align-items: center; }

  /* Stats: 3 columns */
  .stats-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
  }

  .stat-value { font-size: 1.75rem; }

  /* Toast: right corner on desktop */
  .toast-container {
    bottom: 1.5rem;
    left: auto;
    right: 1.5rem;
    max-width: 360px;
  }
}

@media (min-width: 1024px) {
  .llm-activity-route {
    align-items: end;
    grid-template-columns: minmax(190px, 0.75fr) minmax(0, 1.25fr);
  }

  .config-key-row {
    flex-direction: row;
    align-items: center;
    gap: 1rem;
  }

  .config-key-label {
    flex: 0 0 190px;
    font-size: 0.8125rem;
  }
}

@media (min-width: 768px) and (max-width: 1199px) {
  .nav-link-disabled,
  #user-display {
    display: none;
  }
}

@media (min-width: 768px) and (max-width: 899px) {
  .nav-right .ai-label,
  .global-refresh-btn span {
    display: none;
  }
}

/* The Wavestone system is intentionally white-only in CyberWatch. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --bg: var(--ws-color-bg, #ffffff);
    --bg-card: var(--ws-color-bg-subtle, #f5f4f9);
    --bg-input: var(--ws-color-bg-muted, #e6e4ee);
    --text: var(--ws-color-text, #16121f);
    --text-muted: var(--ws-color-text-muted, #6b6580);
    --primary: var(--ws-color-primary, #451dc7);
    --primary-hover: var(--ws-color-primary-hover, #36169b);
    --danger: var(--ws-danger, #d8412f);
    --success: var(--ws-success, #088a42);
    --border: var(--ws-color-border, #e6e4ee);
    --accent: var(--ws-color-primary, #451dc7);
    --badge-success-bg: #f0fdf4;
    --badge-success-border: #bbf7d0;
    --badge-danger-bg: #fef2f2;
    --badge-danger-border: #fecaca;
    --badge-muted-bg: #f3f4f6;
    --badge-accent-bg: var(--ws-color-primary-subtle, #f1eefb);
    --badge-primary-bg: #f3f4f6;
    --table-even: #fafafa;
    --table-hover: #f3f4f6;
    --overlay-bg: rgba(0, 0, 0, 0.3);
    --shadow-color: rgba(0, 0, 0, 0.06);
    --focus-ring: rgba(90, 43, 224, 0.22);
    --active-bg: var(--ws-color-primary-subtle, #f1eefb);
    --active-bg-subtle: var(--ws-color-primary-subtle, #f1eefb);
    --score-bg: rgba(17, 17, 17, 0.05);
    --read-title-color: var(--text-muted);
    --read-excerpt-color: #a0a0a0;
    --btn-primary-bg: var(--primary);
    --btn-primary-text: #fff;
    --btn-primary-hover: var(--primary-hover);
    --theme-color: #ffffff;
    color-scheme: light;
  }
}

/* ============================================
   Large desktop
   ============================================ */
@media (min-width: 1024px) {
  .tabs { overflow-x: visible; }
}

/* ============================================
   Scrollbar (desktop)
   ============================================ */
@media (min-width: 768px) {
  ::-webkit-scrollbar { width: 8px; }
  ::-webkit-scrollbar-track { background: var(--bg); }
  ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 0; }
  ::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
}

/* ============================================
   Home Page - Thematic Blocks
   ============================================ */

.home-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.home-header h1 {
  font-size: 1.3rem;
  margin: 0;
}

.home-actions {
  display: flex;
  gap: 0.5rem;
}

.home-events-header {
  margin-bottom: 0.5rem;
  min-width: 0;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.event-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 0.85rem;
  margin-bottom: 0.65rem;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  min-width: 0;
  max-width: 100%;
}

.event-card:active,
.event-card:hover {
  border-color: var(--primary);
}

.event-card-head {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  min-width: 0;
}

.event-importance {
  flex: 0 0 auto;
  min-width: 38px;
  padding: 0.15rem 0.35rem;
  background: var(--score-bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
}

.event-card-title {
  min-width: 0;
  color: var(--text);
  font-size: 0.98rem;
  font-weight: 650;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.event-card-summary {
  margin-top: 0.55rem;
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.event-card-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem 0.65rem;
  margin-top: 0.6rem;
  min-width: 0;
}

/* Dashboard */
.dashboard {
  margin-bottom: 1.25rem;
}

.dashboard-kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 0.75rem;
  text-align: center;
  min-width: 0;
}

.kpi-card.kpi-accent {
  border-color: var(--primary);
}

.kpi-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.kpi-accent .kpi-value {
  color: var(--primary);
}

.kpi-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0.15rem;
  overflow-wrap: anywhere;
}

.dashboard-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.dashboard-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 0.75rem;
}

.dashboard-themes {
  grid-column: 1 / -1;
}

.panel-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  font-weight: 600;
}

/* Method bar */
.method-bar {
  display: flex;
  height: 6px;
  background: var(--bg-input);
  overflow: hidden;
  margin-bottom: 0.4rem;
}

.method-bar-fill.method-rss {
  background: var(--primary);
}

.method-bar-fill.method-social {
  background: #1da1f2;
}

.method-bar-fill.method-watch {
  background: var(--text-muted);
}

.method-legend {
  display: flex;
  gap: 0.75rem;
  font-size: 0.7rem;
}

.method-legend-item {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--text-muted);
}

.method-dot {
  width: 8px;
  height: 8px;
  display: inline-block;
}

.method-dot.method-rss { background: var(--primary); }
.method-dot.method-social { background: #1da1f2; }
.method-dot.method-watch { background: var(--text-muted); }

/* Activity list */
.activity-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.activity-item {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
}

/* Theme distribution bars */
.theme-bar-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
  font-size: 0.75rem;
}

.theme-bar-label {
  width: 120px;
  flex-shrink: 0;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.theme-bar-track {
  flex: 1;
  height: 6px;
  background: var(--bg-input);
}

.theme-bar-fill {
  height: 100%;
  background: var(--primary);
  transition: width 0.3s;
}

.theme-bar-count {
  width: 30px;
  text-align: right;
  flex-shrink: 0;
  font-weight: 600;
  color: var(--text);
}

@media (min-width: 768px) {
  .dashboard-kpis {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .theme-bar-label {
    width: 160px;
  }
}

/* Clusters section (home) */
.home-clusters-section {
  margin-bottom: 1.25rem;
}

.home-clusters-section .section-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.cluster-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: background 0.15s;
}

.cluster-card:hover,
.cluster-card:active {
  background: var(--bg-input);
}

.cluster-card-header {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.cluster-card-title {
  font-weight: 600;
  font-size: 0.92rem;
  line-height: 1.3;
}

.cluster-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
}

.cluster-card-excerpt {
  margin-top: 0.35rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Theme blocks */
.home-blocks {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.theme-block {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0;
  overflow: hidden;
}

.collapse-toggle-row {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.5rem;
}

.theme-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  min-height: 44px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.theme-block-header:active {
  background: var(--bg-input);
}

.theme-block-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.95rem;
}

.theme-icon {
  font-size: 1.1rem;
}

.theme-block-chevron {
  font-size: 0.65rem;
  color: var(--text-muted);
  transition: transform 0.2s;
}

.theme-block.collapsed .theme-block-chevron {
  transform: rotate(-90deg);
}

.theme-block.collapsed .theme-block-body {
  display: none;
}

.theme-block-body {
  padding: 0 0.5rem 0.5rem;
}

.theme-block-more {
  padding: 0.5rem;
  text-align: center;
}

/* Article cards */
.article-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 0.65rem 0.75rem;
  margin-bottom: 0.4rem;
  cursor: pointer;
  transition: border-color 0.15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.article-card:active,
.article-card:hover {
  border-color: var(--primary);
}

.article-card-top {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.article-card-title {
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.article-card-meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.article-card-expand {
  display: none;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.article-card.expanded .article-card-expand {
  display: block;
}

.article-card.expanded .article-card-title {
  -webkit-line-clamp: unset;
}

.article-summary {
  font-size: 0.825rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 0.5rem;
}

.article-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.5rem;
}

.tag {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 0.1rem 0.4rem;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.article-link {
  font-size: 0.8rem;
  font-weight: 500;
}

.score-badge {
  background: var(--score-bg);
  color: var(--primary);
  border-radius: 0;
  padding: 0.1rem 0.35rem;
  font-size: 0.7rem;
  font-weight: 600;
}

/* Badge variants */
.badge-accent {
  background: var(--badge-accent-bg);
  color: var(--accent);
}

.badge-primary {
  background: var(--badge-primary-bg);
  color: var(--primary);
}

/* Loading/empty states */
.loading-state,
.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
}

/* ============================================
   Activity overlay (clustering progress)
   ============================================ */
.activity-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--overlay-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.activity-overlay.fade-out {
  opacity: 0;
  transition: opacity 0.3s ease;
}

.activity-modal {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 2rem 2.5rem;
  min-width: 320px;
  max-width: 420px;
  text-align: center;
}

.activity-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  margin: 0 auto 1rem;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.activity-title {
  font-weight: 600;
  font-size: 1.05rem;
  margin-bottom: 0.75rem;
  color: var(--text);
}

.activity-step {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.activity-progress-bar {
  height: 4px;
  background: var(--bg-input);
  overflow: hidden;
  margin-bottom: 0.75rem;
}

.activity-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--primary);
  transition: width 0.6s ease;
}

.activity-detail {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ============================================
   Interrogation page - Phase 3
   ============================================ */

/* Search filters */
.search-filters .form-group { margin-bottom: 0.75rem; }

.search-filters-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

@media (max-width: 767px) {
  .search-filters-row {
    grid-template-columns: 1fr;
  }
}

/* Search results */
.search-results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 1rem 0 0.5rem;
}

/* ============================================
   Intel Brief page
   ============================================ */
.intel-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  min-width: 0;
}

.intel-page-header h1,
.intel-page-header p {
  overflow-wrap: anywhere;
}

.intel-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
  min-width: 0;
}

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

.intel-sidebar {
  order: -1;
}

.intel-run-row {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
  padding: 0.75rem 0;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}

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

.intel-run-row.active .intel-run-title {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.intel-run-title {
  font-weight: 600;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.intel-run-meta {
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.intel-detail-header {
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.intel-detail-header h2,
.intel-synthesis h3 {
  overflow-wrap: anywhere;
}

.intel-synthesis-top,
.intel-source-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.intel-synthesis-top {
  margin-bottom: 0.75rem;
}

.intel-source-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-top: 1rem;
  border-top: 1px solid var(--border);
}

.intel-source-row {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.intel-source-main {
  min-width: 0;
}

.intel-source-main a {
  display: inline-block;
  max-width: 100%;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.intel-synthesis p {
  overflow-wrap: anywhere;
}

.intel-manual-add {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  margin-top: 1rem;
}

@media (max-width: 767px) {
  .intel-page-header {
    display: block;
  }

  .intel-main > .card .card-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.75rem;
  }

  .intel-main > .card .card-header .btn-group {
    width: 100%;
  }

  .intel-main > .card .card-header .btn {
    flex: 1;
  }

  .intel-synthesis-top,
  .intel-source-row {
    flex-direction: column;
  }

  .intel-synthesis-top .btn,
  .intel-source-row .btn,
  .intel-manual-add .btn {
    width: 100%;
  }
}

@media (min-width: 1024px) {
  .intel-layout {
    grid-template-columns: minmax(0, 1fr) 320px;
    align-items: start;
  }

  .intel-sidebar {
    order: initial;
    position: sticky;
    top: calc(var(--nav-height) + 1rem);
  }

  .intel-manual-add {
    grid-template-columns: minmax(120px, 160px) minmax(150px, 180px) auto;
    align-items: stretch;
  }
}

.search-result-card {
  cursor: pointer;
  transition: border-color 0.2s;
}

.search-result-card:hover {
  border-color: var(--primary);
}

.search-result-header h4 {
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.search-result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.25rem;
  min-width: 0;
}

.search-result-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.search-result-detail {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.key-points-list {
  margin: 0.5rem 0;
  padding-left: 1.25rem;
}

.key-points-list li {
  margin-bottom: 0.25rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* LLM Answer */
.ask-answer {
  background: var(--bg-input);
  border-radius: 0;
  padding: 1rem;
}

.ask-answer p {
  line-height: 1.7;
}

.ask-sources {
  list-style: none;
  padding: 0;
}

.ask-sources li {
  padding: 0.25rem 0;
  border-bottom: 1px solid var(--border);
}

.ask-sources li:last-child {
  border-bottom: none;
}

/* Cluster synthesis */
.cluster-synthesis {
  background: var(--bg-input);
  border-radius: 0;
  padding: 1rem;
  margin-bottom: 1rem;
}

.cluster-synthesis ul {
  padding-left: 1.25rem;
}

.cluster-synthesis li {
  margin-bottom: 0.25rem;
}

/* Pagination */
.search-pagination {
  margin: 1rem 0 2rem;
}

.pagination-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
}

/* Range input styling */
input[type="range"] {
  width: 100%;
  height: 6px;
  background: var(--bg-input);
  border-radius: 0;
  outline: none;
  -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 0;
  background: var(--primary);
  cursor: pointer;
}

/* Textarea */
textarea.form-control {
  resize: vertical;
  min-height: 60px;
  font-size: 16px;
}

/* Desktop: 2 columns for theme blocks */
@media (min-width: 768px) {
  .home-blocks {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
  }

  .home-blocks .uncategorized {
    grid-column: 1 / -1;
  }
}

/* ---- Market Watch ---- */

.market-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.market-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  background: var(--bg-input);
  font-size: 0.8125rem;
  font-family: inherit;
  color: var(--text-muted);
  cursor: pointer;
  min-height: 36px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.market-chip.selected {
  background: var(--btn-primary-bg, var(--primary));
  color: var(--btn-primary-text, #fff);
  border-color: var(--btn-primary-bg, var(--primary));
}

.market-chip:active {
  opacity: 0.8;
}

.market-report-content {
  line-height: 1.6;
}

.market-report-content h1 {
  font-size: 1.25rem;
  margin: 1.5rem 0 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border);
}

.market-report-content h2 {
  font-size: 1.125rem;
  margin: 1.25rem 0 0.5rem;
  padding-bottom: 0.375rem;
  border-bottom: 1px solid var(--border);
}

.market-report-content h3 {
  font-size: 1rem;
  margin: 1rem 0 0.375rem;
}

.market-report-content ul {
  padding-left: 1.25rem;
  margin: 0.5rem 0;
}

.market-report-content li {
  margin-bottom: 0.375rem;
}

.market-report-content p {
  margin: 0.5rem 0;
}

.market-report-content a {
  color: var(--accent);
  text-decoration: none;
}

.market-report-content a:hover {
  text-decoration: underline;
}

.market-report-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

.market-report-content .badge {
  vertical-align: middle;
  margin-left: 0.25rem;
}

.badge-warning {
  background: #f59e0b;
  color: #fff;
  display: inline-block;
  padding: 0.15rem 0.5rem;
  font-size: 0.675rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.market-generating {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  text-align: center;
  gap: 1rem;
}

.market-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: market-spin 0.8s linear infinite;
}

@keyframes market-spin {
  to { transform: rotate(360deg); }
}

/* ============================================
   Period selector (shared)
   ============================================ */
.period-selector {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1rem;
}

.period-selector-sm {
  display: flex;
  gap: 0.125rem;
  margin-bottom: 0;
}

.period-pill {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 0.375rem 0.875rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  line-height: 1;
}

.period-pill:first-child {
  border-radius: 0;
}

.period-pill:last-child {
  border-radius: 0;
}

.period-pill.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.period-pill:hover:not(.active) {
  background: var(--bg-input);
}

.period-selector-sm .period-pill {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

/* ============================================
   History page
   ============================================ */
.history-months-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.history-month-card {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 1rem;
  cursor: pointer;
  transition: background 0.15s;
}

.history-month-card:hover,
.history-month-card:active {
  background: var(--bg-input);
}

.history-month-label {
  font-weight: 600;
  font-size: 1rem;
  flex: 1;
  min-width: 0;
}

.history-month-stats {
  display: flex;
  gap: 0.5rem;
  margin-right: 0.5rem;
}

.history-month-arrow {
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ============================================
   Topic Intelligence Layer
   ============================================ */

/* Hot Topics section on Home */
.hot-topics-section {
  margin-bottom: 1.5rem;
}

.hot-topics-section .section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.hot-topic-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: background 0.15s;
}

.hot-topic-card:hover {
  background: var(--active-bg);
}

.hot-topic-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.hot-topic-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.hot-topic-title {
  font-weight: 600;
  font-size: 0.9rem;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hot-topic-heat {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--accent);
  flex-shrink: 0;
}

.hot-topic-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.35rem;
  flex-wrap: wrap;
}

/* Entity chips */
.entity-chip {
  display: inline-block;
  background: var(--badge-primary-bg);
  border: 1px solid var(--border);
  padding: 1px 6px;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.entity-chip-lg {
  padding: 2px 8px;
  font-size: 0.75rem;
}

.entity-type {
  color: var(--text-muted);
  font-size: 0.65rem;
  margin-left: 4px;
  opacity: 0.7;
}

.badge-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.7rem;
  padding: 1px 6px;
}

/* Topics page header */
.topics-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.topics-header h1 {
  margin: 0;
  font-size: 1.3rem;
}

.topics-header-actions {
  display: flex;
  gap: 0.5rem;
}

/* Topics filters */
.topics-filters {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.topics-filters .input-search {
  flex: 1;
  min-width: 150px;
}

.topics-filters .input-select {
  min-width: 120px;
}

/* Topics table/list */
.topics-table {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.topic-row {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: background 0.15s;
}

.topic-row:hover {
  background: var(--active-bg);
}

.topic-row-main {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.topic-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.topic-title {
  font-weight: 600;
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topic-row-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.35rem;
  flex-wrap: wrap;
}

.heat-bar {
  width: 60px;
  height: 6px;
  background: var(--score-bg);
  overflow: hidden;
}

.heat-bar-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.3s;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1rem 0;
}

/* Topic detail */
.topic-detail-header {
  margin-bottom: 1rem;
}

.topic-detail-info {
  margin-bottom: 1.5rem;
}

.topic-detail-title {
  font-size: 1.4rem;
  margin: 0 0 0.5rem;
}

.topic-detail-badges {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.topic-entities {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

/* Topic tabs */
.topic-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
  gap: 0;
}

.topic-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.topic-tab:hover {
  color: var(--text);
}

.topic-tab.active {
  color: var(--text);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

/* Synthesis content */
.topic-synthesis {
  padding: 0.5rem 0;
}

.synthesis-content h3 {
  font-size: 1.1rem;
  margin: 1.25rem 0 0.5rem;
}

.synthesis-content h4 {
  font-size: 0.95rem;
  margin: 1rem 0 0.35rem;
}

.synthesis-content p {
  margin: 0 0 0.75rem;
  line-height: 1.6;
}

.synthesis-content ul {
  margin: 0 0 0.75rem;
  padding-left: 1.5rem;
}

.synthesis-content a {
  color: var(--accent);
}

.synthesis-meta {
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  margin-top: 1rem;
}

/* Topic articles list */
.topic-articles {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.topic-article-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 0.75rem 1rem;
}

.topic-article-title a {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  text-decoration: none;
}

.topic-article-title a:hover {
  color: var(--accent);
}

.topic-article-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.35rem;
  flex-wrap: wrap;
}

.topic-article-summary {
  margin-top: 0.35rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Timeline chart */
.topic-timeline {
  padding: 1rem 0;
}

.timeline-chart {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 150px;
  padding-bottom: 1.5rem;
}

.timeline-bar-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
}

.timeline-bar {
  width: 100%;
  max-width: 20px;
  background: var(--accent);
  min-height: 2px;
  transition: height 0.3s;
}

.timeline-label {
  font-size: 0.6rem;
  color: var(--text-muted);
  margin-top: 4px;
  white-space: nowrap;
}

/* Topic actions */
.topic-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* Galaxy */
.galaxy-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.galaxy-header h1 {
  margin: 0;
  font-size: 1.3rem;
  flex: 1;
}

.galaxy-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

.galaxy-fullpage {
  min-height: calc(100vh - 200px);
}

.galaxy-embed {
  min-height: 400px;
}

.galaxy-container svg {
  width: 100%;
  height: 100%;
}

.galaxy-tooltip {
  position: fixed;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  z-index: 100;
  max-width: 250px;
  box-shadow: 0 2px 8px var(--shadow-color);
  pointer-events: none;
}

.galaxy-label {
  pointer-events: none;
  user-select: none;
}

/* Button extras */
.btn-xs {
  padding: 2px 6px;
  font-size: 0.7rem;
  min-height: auto;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border: none;
}

.btn-danger:hover {
  opacity: 0.85;
}

/* Period selector reusable */
.period-selector {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1rem;
}

/* Responsive */
@media (min-width: 768px) {
  .topics-filters {
    flex-wrap: nowrap;
  }

  .galaxy-embed {
    min-height: 500px;
  }

  .topic-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .topic-row-meta {
    margin-top: 0;
  }

  .timeline-chart {
    height: 200px;
  }
}

/* ============================================
   Trends dashboard
   ============================================ */
.trend-card-head {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  min-width: 0;
}

.trend-rank {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-muted);
  line-height: 1.4;
  flex-shrink: 0;
}

.trend-card h3 {
  overflow-wrap: anywhere;
}

.trend-articles {
  margin-top: 0.75rem;
}

.trend-articles summary {
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  user-select: none;
}

.trend-articles summary:hover {
  color: var(--text);
}

/* ---- Conso: consolidated story groups ---- */
.conso-page {
  --conso-surface: #ffffff;
  --conso-surface-soft: #f7f6fb;
  --conso-surface-tint: #efedfb;
  --conso-ink: #19152a;
  --conso-muted: #6d6880;
  --conso-border: #e2dfeb;
  --conso-accent: #5737d6;
  --conso-accent-strong: #3f22b8;
  color: var(--conso-ink);
  padding-bottom: 2rem;
}

.conso-page .trend-page-title {
  border-left: 3px solid var(--conso-accent);
  padding-left: 1rem;
}

.conso-page .trend-page-title h1 { color: var(--conso-ink); letter-spacing: -.025em; }
.conso-page .trend-page-title .eyebrow { color: var(--conso-accent); }
.conso-page .trend-page-title p { color: var(--conso-muted); max-width: 760px; }

.conso-page .trend-command-bar {
  background: var(--conso-surface);
  border-color: var(--conso-border);
  box-shadow: 0 10px 28px rgba(39, 28, 80, .06);
}

.conso-page .trend-periods {
  align-items: stretch;
  background: var(--conso-surface-soft);
  border: 1px solid var(--conso-border);
  gap: 0;
  padding: 3px;
}

.conso-page .period-pill {
  border: 0;
  color: var(--conso-muted);
  min-height: 36px;
}

.conso-page .period-pill.active {
  background: var(--conso-accent);
  color: #fff;
  box-shadow: 0 3px 9px rgba(87, 55, 214, .2);
}

.conso-page .period-pill:hover:not(.active) { background: var(--conso-surface-tint); color: var(--conso-ink); }

.conso-page .conso-command-controls { grid-template-columns: auto auto; }
.conso-page .conso-command-controls .conso-check {
  align-self: center;
  background: var(--conso-surface-soft);
  border: 1px solid var(--conso-border);
  color: var(--conso-muted);
  min-height: 38px;
  padding: .45rem .7rem;
}

.conso-page .conso-check input { accent-color: var(--conso-accent); }
.conso-page .btn-primary { background: var(--conso-accent); }
.conso-page .btn-primary:hover { background: var(--conso-accent-strong); }
.conso-page .btn-secondary { background: var(--conso-surface); border-color: var(--conso-border); color: var(--conso-ink); }
.conso-page .btn-secondary:hover { background: var(--conso-surface-soft); border-color: #c9c4da; }
.conso-page .conso-summary { color: var(--conso-muted); padding-left: .15rem; }

.conso-page .trend-run-summary {
  background: var(--conso-surface);
  border-color: var(--conso-border);
  box-shadow: 0 10px 28px rgba(39, 28, 80, .05);
}

.conso-page .trend-run-summary > div {
  border-color: var(--conso-border);
  min-height: 82px;
  padding: 1rem 1.1rem;
  position: relative;
}

.conso-page .trend-run-summary > div::before {
  background: var(--conso-accent);
  content: '';
  height: 2px;
  left: 1.1rem;
  position: absolute;
  top: 0;
  width: 30px;
}

.conso-page .trend-run-summary strong { color: var(--conso-ink); font-size: 1.45rem; letter-spacing: -.03em; }
.conso-page .trend-run-summary span { color: var(--conso-muted); line-height: 1.35; margin-top: .2rem; }
.conso-page .trend-section-heading { margin-top: 1.75rem; }
.conso-page .trend-section-heading h2 { color: var(--conso-ink); font-size: 1.35rem; letter-spacing: -.02em; }
.conso-page .trend-section-heading .eyebrow { color: var(--conso-accent); }
.conso-page .trend-section-heading p { color: var(--conso-muted); font-size: .8rem; }

.conso-page .trend-table-card { background: transparent; border: 0; overflow: visible; }
.conso-page .trend-table-card .table-responsive { overflow: visible; }
.conso-trend-table { border-collapse: separate; border-spacing: 0 .65rem; min-width: 760px; }
.conso-page .conso-trend-table thead th { border: 0; color: var(--conso-muted); padding: .1rem 1rem .35rem; }
.conso-page .conso-trend-table thead th:not(:first-child) { text-align: center; }
.conso-page .conso-trend-table tbody tr,
.conso-page .conso-trend-table tbody tr:nth-child(even) { background: transparent; }
.conso-page .conso-trend-table tbody td {
  background: var(--conso-surface);
  border-bottom: 1px solid var(--conso-border);
  border-top: 1px solid var(--conso-border);
  padding: 1.05rem 1rem;
  transition: background-color .18s ease, border-color .18s ease, transform .18s ease;
  vertical-align: middle;
}

.conso-page .conso-trend-table tbody td:first-child {
  border-left: 3px solid var(--conso-accent);
  box-shadow: -4px 8px 18px rgba(39, 28, 80, .045);
}

.conso-page .conso-trend-table tbody td:last-child {
  border-right: 1px solid var(--conso-border);
  box-shadow: 5px 8px 18px rgba(39, 28, 80, .045);
}

.conso-page .conso-trend-table tbody td:not(:first-child) { text-align: center; }
.conso-page .conso-trend-table tbody tr:hover td,
.conso-page .conso-trend-table tbody tr:focus-visible td { background: var(--conso-surface-soft); border-color: #cbc5df; }
.conso-page .conso-trend-table tbody tr:focus-visible { outline: 2px solid var(--conso-accent); outline-offset: 2px; }
.conso-page .trend-theme-cell { max-width: 720px; }
.conso-trend-heading { align-items: flex-start; display: flex; gap: .9rem; }
.conso-trend-index { color: var(--conso-accent); flex: 0 0 1.7rem; font-size: .68rem; font-weight: 800; letter-spacing: .08em; padding-top: .22rem; }
.conso-page .trend-label-line { gap: .5rem; }
.conso-page .trend-label-line strong { color: var(--conso-ink); font-size: .95rem; line-height: 1.35; }
.conso-page .trend-theme-cell p { color: var(--conso-muted); font-size: .8rem; line-height: 1.58; margin-top: .4rem; }
.conso-page .badge { border: 0; font-size: .62rem; letter-spacing: .06em; padding: .2rem .45rem; text-transform: uppercase; }
.conso-page .badge-accent { background: var(--conso-surface-tint); color: var(--conso-accent-strong); }
.conso-page .badge-muted { background: #f1f1f4; color: var(--conso-muted); }
.conso-table-metric { color: var(--conso-ink); font-size: 1rem; }
.conso-page .trend-date-pair { color: var(--conso-muted); font-size: .76rem; }
.conso-page .conso-reviewed-cell { cursor: default; white-space: nowrap; }
.conso-reviewed-check { accent-color: var(--conso-accent, #5737d6); cursor: pointer; height: 1.05rem; width: 1.05rem; vertical-align: middle; }
.conso-page .trend-row-reviewed .trend-theme-cell,
.conso-page .trend-row-reviewed .conso-table-metric,
.conso-page .trend-row-reviewed .trend-date-pair { opacity: .5; }
.conso-row-arrow { color: var(--conso-accent); margin-left: .65rem; vertical-align: middle; }
.conso-source-link { display: inline-flex; margin-top: 1rem; }
.conso-reader-content { padding: 1rem; }
.conso-reader-content .rd-content-block { background: transparent; border-left: 0; padding-left: 0; padding-right: 0; }

/* ---- Reader: raw RSS corpus ---- */
.rss-reader-page { padding-bottom: 2rem; }
.rss-reader-page .trend-page-title {
  border-left: 3px solid var(--accent);
  padding-left: 1rem;
}
.rss-reader-page .trend-page-title p { max-width: 760px; }
.rss-reader-toolbar { align-items: center; }
.rss-reader-summary { font-size: .78rem; margin: 0; }
.rss-reader-list { overflow: hidden; padding: 0; }
.rss-reader-item {
  align-items: center;
  appearance: none;
  background: var(--bg);
  border: 0;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  display: flex;
  font: inherit;
  gap: 1rem;
  justify-content: space-between;
  padding: 1rem;
  text-align: left;
  width: 100%;
}
.rss-reader-item:last-child { border-bottom: 0; }
.rss-reader-item:hover, .rss-reader-item:focus-visible { background: var(--table-hover); outline: none; }
.rss-reader-item:focus-visible { box-shadow: inset 3px 0 var(--accent); }
.rss-reader-item-main { display: flex; flex: 1; flex-direction: column; gap: .38rem; min-width: 0; }
.rss-reader-item-title { font-size: .96rem; font-weight: 650; line-height: 1.4; overflow-wrap: anywhere; }
.rss-reader-item-summary {
  color: var(--text-muted);
  display: -webkit-box;
  font-size: .8rem;
  line-height: 1.5;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.rss-reader-item-meta { align-items: center; color: var(--text-muted); display: flex; flex-wrap: wrap; font-size: .68rem; gap: .4rem .65rem; }
.rss-reader-item-meta strong { color: var(--accent); font-size: inherit; letter-spacing: .04em; text-transform: uppercase; }
.rss-reader-item-arrow { color: var(--text-muted); flex: 0 0 auto; }
.rss-reader-pagination { display: flex; justify-content: center; padding: .75rem 0; }
.rss-reader-empty { border: 1px solid var(--border); }
.rss-reader-detail-header .rd-intelligence-summary { margin-top: 1rem; }
.rss-reader-raw-content { padding: 1.15rem 1rem 2rem; }
.rss-reader-raw-content > .eyebrow { color: var(--accent); margin-bottom: .8rem; }
.reader-raw-paragraph {
  border-bottom: 1px solid var(--border);
  font-size: .9rem;
  line-height: 1.7;
  margin: 0;
  overflow-wrap: anywhere;
  padding: .75rem 0;
  white-space: pre-wrap;
}
.reader-raw-paragraph:last-child { border-bottom: 0; }

.custom-date-range {
  align-items: end;
  border-top: 1px solid var(--border);
  display: grid;
  gap: .65rem;
  grid-column: 1 / -1;
  grid-template-columns: minmax(190px, 1fr) minmax(140px, auto) minmax(140px, auto) auto;
  justify-content: stretch;
  padding-top: .85rem;
  width: 100%;
}
.custom-date-range-heading { align-self: center; display: flex; flex-direction: column; gap: .15rem; }
.custom-date-range-heading strong { font-size: .8rem; }
.custom-date-range-heading span { color: var(--text-muted); font-size: .7rem; line-height: 1.4; }
.custom-date-range .compact-field { min-width: 140px; }
.custom-date-range .btn { min-height: 42px; }
.date-range-warning {
  background: #fff8e6;
  border-left: 3px solid #d88900;
  color: #765000;
  display: none;
  font-size: .74rem;
  grid-column: 1 / -1;
  line-height: 1.5;
  margin: 0;
  padding: .65rem .75rem;
}
.date-range-warning.visible { display: block; }
.date-range-warning.invalid { background: var(--badge-danger-bg); border-left-color: var(--danger); color: var(--danger); }
.conso-page .custom-date-range { border-top-color: var(--conso-border); }
.conso-page .custom-date-range-heading span { color: var(--conso-muted); }

@media (max-width: 767px) {
  .rss-reader-item { padding: .85rem .75rem; }
  .rss-reader-toolbar .rss-reader-summary { line-height: 1.5; }
  .rss-reader-raw-content { padding-left: .75rem; padding-right: .75rem; }
  .custom-date-range { grid-template-columns: 1fr; }
  .custom-date-range .compact-field { min-width: 0; width: 100%; }
  .custom-date-range .btn { width: 100%; }
}

/* Personal tracking topics */
.interest-topic-chips { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .55rem; }
.interest-topic-chip { display: inline-flex; align-items: center; width: fit-content; border: 1px solid var(--border);
  background: var(--bg); color: var(--primary); font-size: .72rem; font-weight: 700; line-height: 1; padding: .34rem .48rem;
  text-decoration: none; }
.interest-topic-chip:hover { border-color: var(--primary); background: var(--table-hover); }
.reader-article-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.interest-topic-modal-overlay { position: fixed; inset: 0; z-index: 1800; display: grid; place-items: center;
  padding: 1rem; background: rgba(20, 17, 32, .5); }
.interest-topic-modal { width: min(100%, 620px); max-height: min(760px, calc(100vh - 2rem)); overflow: auto;
  border: 1px solid var(--border); background: var(--bg); box-shadow: 0 24px 64px rgba(20, 17, 32, .18); }
.interest-topic-modal > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem;
  padding: 1.25rem; border-bottom: 1px solid var(--border); }
.interest-topic-modal > header h2 { margin: .2rem 0 .35rem; font-size: 1.35rem; }
.interest-topic-modal > header p { margin: 0; color: var(--text-muted); font-size: .82rem; line-height: 1.45; }
.interest-topic-modal-close { flex: 0 0 auto; border: 0; background: transparent; color: var(--text);
  cursor: pointer; font-size: 1.75rem; line-height: 1; }
.stash-topic-options { display: grid; max-height: 310px; overflow-y: auto; border-bottom: 1px solid var(--border); }
.stash-topic-option { display: flex; align-items: center; gap: .75rem; padding: .85rem 1.25rem;
  border-bottom: 1px solid var(--border); cursor: pointer; }
.stash-topic-option:last-child { border-bottom: 0; }
.stash-topic-option:hover { background: var(--table-hover); }
.stash-topic-option input { width: 18px; height: 18px; accent-color: var(--primary); }
.stash-topic-option span { display: grid; gap: .15rem; }
.stash-topic-option small { color: var(--text-muted); }
.stash-topic-create { display: grid; gap: .7rem; padding: 1.1rem 1.25rem; border-bottom: 1px solid var(--border); }
.stash-topic-create-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(120px, .6fr) auto; gap: .5rem; }
.stash-topic-create .form-error { min-height: 1rem; margin: 0; color: var(--danger); font-size: .75rem; }
.interest-topic-modal > footer { display: flex; justify-content: flex-end; gap: .6rem; padding: 1rem 1.25rem; }
.interest-topic-settings-form { display: grid; grid-template-columns: minmax(150px, .8fr) minmax(120px, .5fr) minmax(220px, 1fr) auto;
  align-items: end; gap: .75rem; padding-bottom: 1.25rem; border-bottom: 1px solid var(--border); }
.interest-topic-settings-form .form-group { margin: 0; }
.email-ingestion-note { margin: 1.25rem 0; padding: 1rem; border-left: 3px solid var(--primary);
  background: var(--table-hover); }
.email-ingestion-note p { margin: .35rem 0 0; color: var(--text-muted); font-size: .82rem; line-height: 1.5; }
.interest-topic-settings-list { display: grid; }
.interest-topic-setting { display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1rem 0; border-bottom: 1px solid var(--border); }
.interest-topic-setting > div:first-child { display: grid; gap: .25rem; }
.interest-topic-setting a { color: var(--text); text-decoration: none; }
.interest-topic-setting span, .interest-topic-setting p { margin: 0; color: var(--text-muted); font-size: .78rem; }
.interest-topic-setting-actions { display: flex; gap: .4rem; }
.topic-workspace-page { padding-bottom: 4rem; }
.topic-index-header, .topic-workspace-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 1.5rem; }
.topic-index-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-top: 1.25rem; }
.topic-index-card { display: flex; flex-direction: column; min-height: 220px; padding: 1.25rem; color: var(--text); text-decoration: none; }
.topic-index-card-top { display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  color: var(--text-muted); font-size: .72rem; }
.topic-index-card h2 { margin: 1.15rem 0 .5rem; font-size: 1.3rem; }
.topic-index-card p { flex: 1; color: var(--text-muted); font-size: .85rem; line-height: 1.55; }
.topic-index-card > strong { color: var(--primary); font-size: .8rem; }
.topic-workspace-back { display: inline-block; margin: .9rem 0 1.4rem; color: var(--text-muted); text-decoration: none; font-size: .8rem; }
.topic-workspace-header { padding-bottom: 1.5rem; border-bottom: 1px solid var(--border); }
.topic-workspace-header h1 { margin: .25rem 0 .5rem; }
.topic-workspace-header p { margin: 0; color: var(--text-muted); }
.topic-workspace-count { display: grid; min-width: 130px; text-align: right; }
.topic-workspace-count strong { font-size: 2rem; }
.topic-workspace-count span { color: var(--text-muted); font-size: .75rem; }
.topic-workspace-command { display: flex; align-items: end; justify-content: space-between; gap: 1rem;
  margin: 1.25rem 0 2rem; padding: 1rem; }
.topic-period-control { display: grid; gap: .35rem; min-width: 150px; }
.topic-period-control label { color: var(--text-muted); font-size: .72rem; font-weight: 700; text-transform: uppercase; }
.topic-workspace-actions { display: flex; flex-wrap: wrap; gap: .6rem; }
.topic-workspace-analysis, .topic-workspace-corpus, .topic-workspace-briefings { margin-top: 2rem; }
.topic-section-heading { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: .9rem; }
.topic-section-heading h2 { margin: .15rem 0 0; font-size: 1.35rem; }
.topic-section-heading > span { color: var(--text-muted); font-size: .75rem; }
.topic-analysis-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .85rem; }
.topic-analysis-group { display: grid; grid-template-columns: 42px minmax(0, 1fr); gap: .85rem; padding: 1rem; }
.topic-analysis-rank { color: var(--primary); font-size: 1.15rem; font-weight: 800; }
.topic-analysis-group h3 { margin: 0; font-size: 1rem; line-height: 1.4; }
.topic-analysis-group p { margin: .25rem 0 .65rem; font-size: .72rem; }
.topic-analysis-group ul { display: grid; gap: .45rem; margin: 0; padding: 0; list-style: none; }
.topic-analysis-group li { display: grid; gap: .1rem; }
.topic-analysis-group li button { padding: 0; border: 0; background: transparent; color: var(--text);
  cursor: pointer; font: inherit; font-size: .78rem; font-weight: 600; line-height: 1.35; text-align: left; }
.topic-analysis-group li span { color: var(--text-muted); font-size: .66rem; }
.topic-article-item { display: flex; align-items: center; gap: 1rem; }
.topic-article-open { flex: 1; min-width: 0; display: flex; padding: 0; border: 0; background: transparent;
  color: inherit; cursor: pointer; font: inherit; text-align: left; }
.topic-article-item > .stash-topic-button { flex: 0 0 auto; margin-right: 1rem; }
#topic-workspace-pagination { display: flex; justify-content: center; margin-top: 1rem; }
.topic-briefing-table { display: grid; }
.topic-briefing-table article { display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1rem; border-bottom: 1px solid var(--border); }
.topic-briefing-table article:last-child { border-bottom: 0; }
.topic-briefing-table article > div:first-child { display: grid; gap: .25rem; }
.topic-briefing-table article span { color: var(--text-muted); font-size: .72rem; }
.topic-briefing-table article > div:last-child { display: flex; flex-wrap: wrap; gap: .45rem; }
.topic-article-overlay { z-index: 1750; }
.topic-article-modal { width: min(100%, 760px); }
.topic-article-modal-actions { display: flex; flex-wrap: wrap; gap: .5rem; padding: 1rem 1.25rem 0; }
.topic-article-modal > .interest-topic-chips { padding: 0 1.25rem; }
.topic-article-modal-content { padding: 1.25rem; color: var(--text); line-height: 1.7; white-space: pre-line; }

@media (max-width: 900px) {
  .topic-index-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .interest-topic-settings-form { grid-template-columns: 1fr 1fr; }
  .interest-topic-description-field { grid-column: 1 / -1; }
}

@media (max-width: 767px) {
  .stash-topic-create-fields, .interest-topic-settings-form { grid-template-columns: 1fr; }
  .topic-index-header, .topic-workspace-header, .topic-workspace-command, .topic-section-heading,
  .topic-briefing-table article { align-items: stretch; flex-direction: column; }
  .topic-index-grid, .topic-analysis-grid { grid-template-columns: 1fr; }
  .topic-index-card { min-height: 180px; }
  .topic-workspace-count { text-align: left; }
  .topic-workspace-actions { display: grid; }
  .topic-article-item { align-items: stretch; flex-direction: column; gap: 0; }
  .topic-article-item > .stash-topic-button { width: fit-content; margin: 0 0 .8rem 1rem; }
  .interest-topic-setting { align-items: flex-start; flex-direction: column; }
}

.conso-toolbar {
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.conso-title { font-size: 1.25rem; margin: 0; }

.conso-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.conso-select {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.35rem 0.5rem;
  font-size: 0.8rem;
}

.conso-check {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.conso-summary { font-size: 0.75rem; margin: 0 0 0.85rem; }

.conso-group {
  border: 1px solid var(--border);
  background: var(--bg-card);
  margin-bottom: 0.5rem;
}

.conso-group-multi { border-left: 3px solid var(--accent); }

.conso-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  color: var(--text);
  padding: 0.7rem 0.75rem;
  cursor: pointer;
  font: inherit;
}

.conso-group-head:hover { background: var(--table-hover); }

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

.conso-group-title {
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.35;
  margin-bottom: 0.3rem;
}

.conso-group-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.conso-badge {
  background: var(--badge-muted-bg);
  border: 1px solid var(--border);
  padding: 0.05rem 0.4rem;
  font-weight: 600;
}

.conso-badge-multi {
  background: var(--badge-accent-bg);
  color: var(--accent);
  border-color: transparent;
}

.conso-chevron {
  color: var(--text-muted);
  display: flex;
  transition: transform 0.15s;
  flex-shrink: 0;
}

.conso-chevron.open { transform: rotate(180deg); }

.conso-articles { border-top: 1px solid var(--border); }

.conso-article {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--bg);
  border: 0;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  padding: 0.6rem 0.75rem 0.6rem 1.1rem;
  cursor: pointer;
  font: inherit;
}

.conso-article:last-child { border-bottom: 0; }
.conso-article:hover { background: var(--table-hover); }
.conso-article.is-read .conso-article-title { color: var(--text-muted); font-weight: 400; }

.conso-article-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

.conso-article-source { font-weight: 700; letter-spacing: 0.06em; }

.conso-article-title {
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.35;
}

.conso-article-summary {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-top: 0.25rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.conso-paragraph {
  font-size: 0.9rem;
  line-height: 1.6;
  margin-bottom: 0.85rem;
}

@media (min-width: 768px) {
  .conso-toolbar { align-items: center; flex-direction: row; }
  .conso-controls { gap: 0.75rem; }
  .conso-title { font-size: 1.5rem; }
  .conso-group-title { font-size: 1rem; }
  .conso-page .conso-command-controls { display: flex; }
}

@media (max-width: 767px) {
  .conso-page .trend-page-title { padding-left: .75rem; }
  .conso-page .trend-periods { grid-template-columns: repeat(4, 1fr); }
  .conso-page .conso-command-controls { grid-template-columns: 1fr 1fr; }
  .conso-page .conso-command-controls .conso-check { grid-column: 1 / -1; justify-content: center; }
  .conso-page .conso-command-controls #fable-conso-generate { grid-column: 1 / -1; }
  .conso-page .trend-run-summary > div { min-height: 76px; padding: .85rem; }
  .conso-page .trend-run-summary > div::before { left: .85rem; }
  .conso-page .trend-run-summary strong { font-size: 1.25rem; }
  .conso-page .trend-section-heading { margin-top: 1.4rem; }
  .conso-trend-table { min-width: 0; }
  .conso-page .conso-trend-table { border-spacing: 0; }
  .conso-page .conso-trend-table tbody { gap: .8rem; }
  .conso-page .conso-trend-table tr.trend-row {
    background: var(--conso-surface);
    border: 0;
    border-left: 3px solid var(--conso-accent);
    box-shadow: 0 8px 22px rgba(39, 28, 80, .07);
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding: .85rem;
  }
  .conso-page .conso-trend-table tr.trend-row td,
  .conso-page .conso-trend-table tr.trend-row td:first-child,
  .conso-page .conso-trend-table tr.trend-row td:last-child {
    background: transparent;
    border: 0;
    box-shadow: none;
    padding: .45rem .35rem;
    text-align: left;
  }
  .conso-page .conso-trend-table tr.trend-row td:first-child {
    border-bottom: 1px solid var(--conso-border);
    padding-bottom: .9rem;
  }
  .conso-page .conso-trend-table tr.trend-row td:not(:first-child) { text-align: left; }
  .conso-trend-heading { gap: .55rem; }
  .conso-trend-index { flex-basis: 1.45rem; }
  .conso-page .trend-label-line strong { font-size: .9rem; }
  .conso-row-arrow { display: none; }
}
/* Daily briefing home */
.briefing-home { padding-bottom: 2rem; }
.briefing-home-header { display: flex; flex-direction: column; gap: 1rem; margin-bottom: 1rem; }
.briefing-home-header h1 { margin-bottom: .25rem; }
.briefing-browser { min-height: 70vh; border: 1px solid var(--border); background: #fff; }
.briefing-browser-bar { height: 44px; display: flex; align-items: center; gap: 7px; padding: 0 13px; border-bottom: 1px solid var(--border); background: #f2f4f7; }
.briefing-browser-bar > span { width: 10px; height: 10px; border-radius: 50%; background: #98a2b3; }
.briefing-browser-bar > span:first-child { background: #f97066; }
.briefing-browser-bar > span:nth-child(2) { background: #fdb022; }
.briefing-browser-bar > span:nth-child(3) { background: #32d583; }
#briefing-browser-address { min-width: 0; flex: 1; margin-left: 8px; padding: 6px 12px; background: #fff; border: 1px solid #d0d5dd; color: #667085; font-size: .75rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.briefing-frame-host { height: calc(100vh - 230px); min-height: 640px; }
.briefing-frame { display: block; width: 100%; height: 100%; border: 0; background: #fff; }
.briefing-browser > .loading-state, .briefing-browser > .empty-state { min-height: 60vh; display: grid; place-items: center; }

/* Briefing archive */
.briefings-page { padding-bottom: 3rem; }
.briefings-header { display: flex; flex-direction: column; gap: 1rem; margin-bottom: 1.25rem; }
.briefings-header h1 { margin: .2rem 0 .35rem; }
.briefing-format-key { display: grid; grid-template-columns: 1fr; border: 1px solid var(--border); background: #fff; margin-bottom: 1.25rem; }
.briefing-format-key > div { padding: 1rem 1.15rem; border-bottom: 1px solid var(--border); }
.briefing-format-key > div:last-child { border-bottom: 0; }
.briefing-format-key strong, .briefing-format-key span { display: block; }
.briefing-format-key strong { color: #2d1380; font-size: .86rem; }
.briefing-format-key span { color: var(--text-muted); font-size: .78rem; margin-top: .2rem; }
.briefing-filter-bar { display: grid; grid-template-columns: 1fr; gap: .8rem; padding: 1rem; border: 1px solid var(--border); background: #fff; margin-bottom: 1.25rem; }
.briefing-filter-bar label { display: block; margin-bottom: .3rem; color: var(--text-muted); font-size: .7rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.briefing-filter-actions { display: flex; align-items: flex-end; gap: .5rem; }
.briefing-filter-actions .btn { flex: 1; }
.briefing-results-summary { padding: .7rem 0; color: var(--text-muted); font-size: .8rem; }
.briefing-results-summary strong { color: #2d1380; font-size: 1rem; }
.briefing-archive-list { border: 1px solid var(--border); background: #fff; }
.briefing-archive-row { display: flex; flex-direction: column; gap: 1rem; padding: 1.2rem; border-bottom: 1px solid var(--border); }
.briefing-archive-row:last-child { border-bottom: 0; }
.briefing-archive-main { min-width: 0; flex: 1; }
.briefing-archive-topline { display: flex; align-items: center; gap: .45rem; margin-bottom: .55rem; }
.briefing-origin, .briefing-status { display: inline-flex; padding: .2rem .42rem; border: 1px solid var(--border); font-size: .68rem; line-height: 1; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.briefing-origin.automatic { color: #2d1380; border-color: #bdaef0; background: #f1eefb; }
.briefing-origin.manual { color: #08783d; border-color: #9ce4b9; background: #effbf4; }
.briefing-status.ready { color: #08783d; }
.briefing-status.uploading { color: #9a6700; }
.briefing-status.failed { color: var(--danger); }
.briefing-archive-row h2 { margin: 0; color: #16121f; font-size: 1.08rem; line-height: 1.35; }
.briefing-archive-row p { margin: .38rem 0 .2rem; color: #514b62; font-size: .86rem; }
.briefing-created { color: var(--text-muted); font-size: .75rem; }
.briefing-downloads { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.briefing-file-missing { color: var(--text-muted); font-size: .72rem; padding: .35rem 0; }
.briefing-error { margin-top: .55rem; color: var(--danger); font-size: .78rem; }
.briefing-preview-open { overflow: hidden; }
.briefing-preview-pane { width: min(100%, 980px); overflow: hidden; display: flex; flex-direction: column; background: #f5f4f9; }
.briefing-preview-header { flex: 0 0 auto; min-height: 58px; display: flex; align-items: center; gap: .65rem; padding: .55rem .75rem; border-bottom: 1px solid var(--border); background: #fff; }
.briefing-preview-heading { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: .08rem; }
.briefing-preview-heading span { color: var(--text-muted); font-size: .66rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.briefing-preview-heading strong { overflow: hidden; font-size: .88rem; text-overflow: ellipsis; white-space: nowrap; }
.briefing-preview-download { flex: 0 0 auto; }
.briefing-preview-tabs { flex: 0 0 auto; display: flex; border-bottom: 1px solid var(--border); background: #fff; }
.briefing-preview-tabs button { appearance: none; min-width: 112px; padding: .7rem 1rem; border: 0; border-right: 1px solid var(--border); border-bottom: 2px solid transparent; background: #fff; color: var(--text-muted); cursor: pointer; font: inherit; font-size: .76rem; font-weight: 700; }
.briefing-preview-tabs button.active { border-bottom-color: var(--primary); color: var(--primary); }
.briefing-preview-content { min-height: 0; flex: 1; background: #f5f4f9; }
.briefing-preview-content > .loading-state { height: 100%; display: grid; place-items: center; }
.briefing-corpus-content { min-height: 0; flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 1rem 1rem 2rem; background: var(--bg); -webkit-overflow-scrolling: touch; }
.briefing-preview-frame { display: block; width: 100%; height: 100%; border: 0; background: #fff; }

@media (min-width: 768px) {
  .briefing-home-header { flex-direction: row; align-items: center; justify-content: space-between; }
  .briefing-home-header .btn { flex: 0 0 auto; }
  .briefings-header { flex-direction: row; align-items: center; justify-content: space-between; }
  .briefing-format-key { grid-template-columns: repeat(3, 1fr); }
  .briefing-format-key > div { border-bottom: 0; border-right: 1px solid var(--border); }
  .briefing-format-key > div:last-child { border-right: 0; }
  .briefing-filter-bar { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; }
  .briefing-search-field { grid-column: span 2; }
  .briefing-filter-actions .btn { flex: 0 0 auto; }
  .briefing-archive-row { flex-direction: row; align-items: center; padding: 1.25rem 1.4rem; }
  .briefing-downloads { flex: 0 0 auto; justify-content: flex-end; max-width: 390px; }
}

@media (max-width: 767px) {
  .briefing-downloads { align-items: stretch; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .briefing-downloads .btn { min-width: 0; white-space: normal; }
  .briefing-downloads .btn:first-child { grid-column: 1 / -1; }
  .briefing-file-missing { display: none; }
  .briefing-preview-workflow { inset: var(--nav-height) 0 0; }
  .briefing-preview-pane { border-left: 0; box-shadow: none; }
  .briefing-preview-header { align-items: flex-start; flex-wrap: wrap; }
  .briefing-preview-heading { padding-top: .15rem; }
  .briefing-preview-download { flex-basis: calc(100% - 46px); margin-left: 46px; }
  .briefing-preview-tabs button { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .briefing-preview-workflow .trend-reader-backdrop, .briefing-preview-pane { transition-duration: .01ms; }
}

@media (min-width: 1200px) {
  .briefing-filter-bar { grid-template-columns: minmax(220px, 1.6fr) repeat(2, minmax(135px, .7fr)) minmax(165px, .85fr) minmax(150px, .8fr) auto; }
  .briefing-search-field { grid-column: auto; }
}

/* ============================================
   Company briefing tab
   ============================================ */
.company-briefing-header-actions { display: flex; gap: .5rem; }
.company-briefing-form { margin-bottom: 1.25rem; }
.company-briefing-form h2 { margin: 0 0 1rem; font-size: 1.05rem; }
.company-briefing-form-actions { display: flex; gap: .5rem; margin-top: 1rem; }

.company-briefing-group { margin-bottom: 1.5rem; }
.company-briefing-group-title { display: flex; align-items: center; gap: .5rem; font-size: 1rem; margin: 0 0 .6rem;
  padding-bottom: .4rem; border-bottom: 1px solid var(--border); }
.company-briefing-count { background: var(--bg-input); color: var(--text-muted); font-size: .72rem; font-weight: 700;
  padding: .1rem .45rem; }
.company-briefing-rows { display: flex; flex-direction: column; gap: .5rem; }
.company-briefing-row { display: flex; flex-direction: column; gap: .75rem; padding: .9rem 1rem;
  border: 1px solid var(--border); background: #fff; }
.company-briefing-row.active { border-color: var(--primary); box-shadow: inset 3px 0 0 var(--primary); }
.company-briefing-row-main h3 { margin: 0 0 .2rem; font-size: .95rem; }
.company-briefing-file { margin: 0 0 .25rem; color: var(--text-muted); font-size: .8rem; word-break: break-all; }
.company-briefing-meta { color: var(--text-muted); font-size: .75rem; }
.company-briefing-row-actions { display: flex; flex-wrap: wrap; gap: .4rem; }

.company-briefing-viewer { margin-top: 1.5rem; }
.company-briefing-viewer-empty { border: 1px dashed var(--border); background: var(--bg-card); padding: 2.5rem 1rem;
  text-align: center; color: var(--text-muted); }
.company-briefing-viewer-header { display: flex; flex-direction: column; gap: .6rem; padding: .9rem 1rem;
  border: 1px solid var(--border); border-bottom: none; background: var(--bg-card); }
.company-briefing-viewer-heading { display: flex; flex-direction: column; gap: .15rem; }
.company-briefing-viewer-heading span { color: var(--text-muted); font-size: .68rem; text-transform: uppercase;
  letter-spacing: .08em; }
.company-briefing-viewer-heading strong { font-size: .95rem; }
.company-briefing-viewer-actions { display: flex; gap: .5rem; }
.company-briefing-viewer-frame-wrap { position: relative; width: 100%; aspect-ratio: 16 / 9; min-height: 320px;
  border: 1px solid var(--border); background: var(--bg-card); }
.company-briefing-viewer-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.company-briefing-viewer-note { margin: .6rem 0 0; font-size: .75rem; }

@media (min-width: 768px) {
  .company-briefing-row { flex-direction: row; align-items: center; justify-content: space-between; }
  .company-briefing-row-actions { flex-wrap: nowrap; }
  .company-briefing-viewer-header { flex-direction: row; align-items: center; justify-content: space-between; }
}
