:root {
  --bg: #ffffff;
  --bg2: #f6f8fa;
  --bg3: #eaeef2;
  --border: #d0d7de;
  --text: #1f2328;
  --muted: #656d76;
  --accent: #0969da;
  --green: #1a7f37;
  --yellow: #9a6700;
  --red: #d1242f;
  --read-color: #1a7f37;
  --skim-color: #0969da;
  --save-color: #8250df;
  --skip-color: #656d76;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --bg2: #161b22;
    --bg3: #21262d;
    --border: #30363d;
    --text: #e6edf3;
    --muted: #8b949e;
    --accent: #58a6ff;
    --green: #3fb950;
    --yellow: #d29922;
    --red: #f85149;
    --read-color: #3fb950;
    --skim-color: #58a6ff;
    --save-color: #bc8cff;
    --skip-color: #6e7681;
  }
}

html { scroll-behavior: smooth; }

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Header */
.header {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header h1 { font-size: 16px; font-weight: 600; letter-spacing: 0.05em; color: var(--accent); }
.header nav { display: flex; gap: 4px; }
.header nav a {
  padding: 4px 12px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
}
.header nav a:hover, .header nav a.active {
  color: var(--text);
  background: var(--bg3);
  text-decoration: none;
}
.header .spacer { flex: 1; }
.period-select {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}
.refresh-indicator {
  font-size: 12px;
  color: var(--muted);
}

/* Focus styles — keyboard navigation */
input:focus-visible,
select:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* Page container */
.page { display: none; padding: 24px; max-width: 1400px; margin: 0 auto; }
.page.active { display: block; }

/* Entities page is a full-bleed split-pane — remove page padding */
#page-entities { padding: 0; max-width: none; margin: 0; }

/* Digest is a narrow newspaper column — sections handle their own horizontal padding */
#page-digest { max-width: 640px; padding-left: 0; padding-right: 0; }

/* Cards */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}
.card h2 {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}

/* Pipeline swimlanes */
.swimlanes {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.lane {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}
.lane-header {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.lane-title { flex: 1; }
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
}
.status-dot.warn { background: var(--yellow); }
.status-dot.error { background: var(--red); }

.kpi { margin-bottom: 10px; }
.kpi-label { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.kpi-value { font-size: 24px; font-weight: 600; }
.kpi-sub { font-size: 12px; color: var(--muted); }

/* Stacked bar */
.action-bar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; margin: 8px 0; }
.action-bar .seg-read { background: var(--read-color); }
.action-bar .seg-skim { background: var(--skim-color); }
.action-bar .seg-save { background: var(--save-color); }
.action-bar .seg-skip { background: var(--skip-color); }

.action-legend { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.legend-item { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; }

/* Resource gauges */
.gauges { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (max-width: 800px) { .gauges { grid-template-columns: 1fr; } }

.gauge {
  background: var(--bg3);
  border-radius: 6px;
  padding: 12px;
}
.gauge-header { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 6px; }
.gauge-name { color: var(--muted); }
.gauge-values { font-size: 11px; color: var(--muted); }
.gauge-bar {
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
}
.gauge-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s;
}
.gauge-fill.green { background: var(--green); }
.gauge-fill.yellow { background: var(--yellow); }
.gauge-fill.red { background: var(--red); }
.gauge-headroom { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* Alerts */
.alerts { margin-bottom: 16px; }
.alert {
  background: rgba(248, 81, 73, 0.1);
  border: 1px solid rgba(248, 81, 73, 0.3);
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--red);
}

/* Articles table */
.table-controls {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.table-controls input[type="search"] {
  flex: 1;
  min-width: 200px;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
}
.table-controls select {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}

.articles-table { width: 100%; border-collapse: collapse; }
.articles-table th, .articles-table td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.articles-table th { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.articles-table th[data-sort] { cursor: pointer; user-select: none; }
.articles-table th[data-sort]:hover { color: var(--text); }
.articles-table th .sort-arrow { font-size: 9px; }
.articles-table tr:hover td { background: var(--bg3); cursor: pointer; }
.article-title-cell { max-width: 400px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.score-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  min-width: 30px;
  text-align: center;
}
.action-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}
.badge-read { background: rgba(63,185,80,0.15); color: var(--read-color); }
.badge-skim { background: rgba(88,166,255,0.15); color: var(--skim-color); }
.badge-save { background: rgba(188,140,255,0.15); color: var(--save-color); }
.badge-skip { background: rgba(110,118,129,0.15); color: var(--skip-color); }

/* Article detail page */
.article-header { margin-bottom: 24px; }
.article-title { font-size: 20px; font-weight: 600; margin-bottom: 8px; }
.article-meta { display: flex; gap: 12px; color: var(--muted); font-size: 13px; flex-wrap: wrap; }
.article-meta a { color: var(--accent); }

.pipeline-journey {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  overflow-x: auto;
}
.journey-stage {
  flex: 1;
  min-width: 140px;
  padding: 12px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-right: none;
}
.journey-stage:first-child { border-radius: 8px 0 0 8px; }
.journey-stage:last-child { border-right: 1px solid var(--border); border-radius: 0 8px 8px 0; }
.journey-stage-name { font-size: 11px; color: var(--muted); text-transform: uppercase; margin-bottom: 6px; }
.journey-stage-value { font-weight: 600; }

.entities-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.entity-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
}
.entity-type {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
  padding: 2px 6px;
  border-radius: 4px;
  display: inline-block;
}
.type-company { background: rgba(88,166,255,0.15); color: var(--skim-color); }
.type-technology { background: rgba(63,185,80,0.15); color: var(--read-color); }
.type-person { background: rgba(210,153,34,0.15); color: var(--yellow); }
.type-product { background: rgba(188,140,255,0.15); color: var(--save-color); }
.type-theme { background: rgba(110,118,129,0.15); color: var(--muted); }

.insight-item {
  background: var(--bg3);
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 8px;
  font-size: 13px;
}
.insight-claim { margin-bottom: 6px; }
.confidence-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
}
.mini-bar {
  flex: 1;
  max-width: 80px;
  height: 4px;
  background: var(--bg);
  border-radius: 2px;
  overflow: hidden;
}
.mini-fill { height: 100%; background: var(--accent); border-radius: 2px; }

.rel-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: var(--bg3);
  border-radius: 6px;
  margin-bottom: 6px;
  font-size: 13px;
}
.rel-type-badge {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 11px;
  color: var(--muted);
}


/* Loading / error */
.loading { color: var(--muted); padding: 24px; text-align: center; }
.error { color: var(--red); padding: 12px; background: rgba(248,81,73,0.1); border-radius: 6px; }

/* Timeline */
.timeline { position: relative; padding-left: 24px; }
.timeline::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: var(--border);
}
.timeline-item {
  position: relative;
  padding-bottom: 16px;
}
.timeline-item::before {
  content: '';
  position: absolute;
  left: -21px;
  top: 5px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
}
.timeline-time { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.timeline-event { font-size: 13px; }

.back-btn {
  display: inline-block;
  padding: 6px 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  margin-bottom: 16px;
}
.back-btn:hover { background: var(--bg2); text-decoration: none; }

/* Entity Network Graph */

.graph-container {
  position: relative;
  width: 100%;
  height: 600px;
  background: var(--bg);
  border-radius: 6px;
  overflow: hidden;
}
.graph-svg {
  width: 100%;
  height: 100%;
  display: block;
}
.graph-empty {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--muted);
  font-size: 14px;
}
.graph-tooltip {
  position: absolute;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 12px;
  pointer-events: none;
  max-width: 200px;
  z-index: 10;
}
.graph-tooltip .tt-name  { font-weight: 600; margin-bottom: 4px; }
.graph-tooltip .tt-meta  { color: var(--muted); line-height: 1.6; }

/* D3 graph node/link styles */
.graph-link { stroke: var(--border); stroke-opacity: 0.7; fill: none; }
.graph-link.highlighted { stroke: var(--accent); stroke-opacity: 1; }
.graph-node { cursor: pointer; }
.graph-node:hover circle { filter: brightness(1.3); }
.graph-node.dimmed circle { opacity: 0.2; }
.graph-node.dimmed text  { opacity: 0.2; }
.graph-node text {
  font-size: 10px;
  fill: var(--text);
  pointer-events: none;
  text-anchor: middle;
  dominant-baseline: central;
}
.graph-link-label {
  font-size: 9px;
  fill: var(--muted);
  pointer-events: none;
  text-anchor: middle;
}

/* Funnel */
.funnel-body { padding: 4px 0; }
.funnel-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 3px 0;
}
.funnel-row-main {
  padding: 6px 0;
}
.funnel-row-sub {
  padding-left: 24px;
  font-size: 13px;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.1s;
}
.funnel-row-sub:hover { background: var(--bg3); }
.funnel-label {
  width: 100px;
  flex-shrink: 0;
  font-size: 13px;
  color: var(--muted);
}
.funnel-row-main .funnel-label {
  color: var(--text);
  font-weight: 600;
}
.funnel-bar-wrap {
  flex: 1;
  height: 16px;
  background: var(--bg3);
  border-radius: 3px;
  overflow: hidden;
}
.funnel-row-main .funnel-bar-wrap {
  height: 22px;
}
.funnel-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}
.funnel-count {
  width: 110px;
  flex-shrink: 0;
  font-size: 12px;
  color: var(--muted);
  text-align: right;
}
.funnel-row-main .funnel-count {
  font-size: 13px;
  color: var(--text);
  font-weight: 600;
}

/* Funnel bar colors */
.bar-ingest   { background: var(--accent); }
.bar-read     { background: var(--read-color); }
.bar-skim     { background: var(--skim-color); }
.bar-save     { background: var(--save-color); }
.bar-skip     { background: var(--skip-color); }
.bar-compiled { background: var(--accent); opacity: 0.65; }
.bar-entities { background: var(--green); }
.bar-insights { background: var(--yellow); }
.bar-vault    { background: var(--accent); opacity: 0.4; }
.bar-promoted { background: var(--yellow); }

/* Entity sidebar + graph split-pane layout */
.entity-graph-layout {
  display: flex;
  gap: 0;
  height: calc(100vh - 56px);
}
.entity-sidebar {
  width: 320px;
  min-width: 240px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg2);
}
.sidebar-controls {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sidebar-controls input[type="search"] {
  width: 100%;
  padding: 6px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 13px;
}
.sidebar-controls input[type="search"]::placeholder { color: var(--muted); }
.type-chips {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.chip {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2px 10px;
  font-size: 12px;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.15s;
}
.chip:hover { color: var(--text); border-color: var(--muted); }
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Colored dot per entity type — serves as graph legend */
.chip[data-type]::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
  opacity: 0.85;
}
.chip[data-type="all"]::before        { background: var(--muted); }
.chip[data-type="company"]::before    { background: var(--accent); }
.chip[data-type="technology"]::before { background: var(--green); }
.chip[data-type="person"]::before     { background: var(--yellow); }
.chip[data-type="product"]::before    { background: var(--save-color); }
.entity-list {
  flex: 1;
  overflow-y: auto;
}
.entity-list-item {
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.entity-list-item:hover { background: var(--bg3); }
.entity-list-item.selected {
  background: rgba(9, 105, 218, 0.08);
  border-left: 3px solid var(--accent);
  padding-left: 9px;
}
.entity-list-item .entity-name { font-size: 13px; font-weight: 500; }
.entity-list-item .entity-meta {
  display: flex;
  gap: 6px;
  align-items: center;
}
.entity-list-item .entity-type-badge {
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 10px;
  font-weight: 500;
}
.entity-type-badge[data-type="company"]    { background: rgba(9,105,218,0.1); color: var(--accent); }
.entity-type-badge[data-type="technology"] { background: rgba(26,127,55,0.1); color: var(--green); }
.entity-type-badge[data-type="person"]     { background: rgba(154,103,0,0.1); color: var(--yellow); }
.entity-type-badge[data-type="product"]    { background: rgba(130,80,223,0.1); color: var(--save-color); }
.entity-type-badge[data-type="theme"]      { background: rgba(101,109,118,0.1); color: var(--muted); }
.entity-list-item .entity-count { color: var(--muted); font-size: 12px; }
.entity-detail-link {
  color: var(--muted);
  font-size: 12px;
  text-decoration: none;
  padding: 0 2px;
  opacity: 0.6;
}
.entity-detail-link:hover { opacity: 1; color: var(--accent); }
.entity-link {
  color: var(--accent);
  text-decoration: none;
}
.entity-link:hover { text-decoration: underline; }
.entity-self { font-weight: 600; }
.entity-context-row td { background: var(--bg2); }
.entity-list-footer {
  padding: 8px 12px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
  border-top: 1px solid var(--border);
}
/* Entity Detail — clean, scannable, matches digest style */
#page-entity-detail { padding: 0; max-width: none; }
.ed-page { max-width: 640px; margin: 0 auto; padding: 32px 24px 60px; }
.ed-back { font-size: 13px; color: var(--muted); text-decoration: none; }
.ed-back:hover { color: var(--accent); }

.ed-header { margin: 20px 0 28px; padding-bottom: 16px; border-bottom: 2px solid var(--accent); }
.ed-name { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.ed-meta { font-size: 12px; color: var(--muted); }

.ed-summary { font-size: 14px; line-height: 1.7; margin-bottom: 28px; color: var(--text); }
.ed-summary-loading { color: var(--muted); font-style: italic; }

.ed-graph { width: 100%; height: 280px; background: var(--bg2); border: 1px solid var(--border); border-radius: 6px; overflow: hidden; margin-bottom: 8px; }
.ed-graph svg { display: block; }

.ed-section { margin-bottom: 32px; }
.ed-section-title { font-size: 11px; text-transform: uppercase; letter-spacing: 2px; color: var(--muted); padding-bottom: 8px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }

.ed-rel { display: flex; align-items: baseline; gap: 8px; padding: 6px 0; border-bottom: 1px dotted var(--border); font-size: 13px; }
.ed-rel:last-child { border-bottom: none; }
.ed-rel-name { font-weight: 600; color: var(--text); text-decoration: none; }
.ed-rel-name:hover { color: var(--accent); }
.ed-rel-type { font-size: 11px; color: var(--muted); }
.ed-rel-how { font-size: 11px; color: var(--muted); margin-left: auto; }

.ed-insight { padding: 8px 0; border-bottom: 1px dotted var(--border); }
.ed-insight:last-child { border-bottom: none; }
.ed-insight-claim { font-size: 13px; line-height: 1.6; }
.ed-insight-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }

.ed-article { padding: 8px 0; border-bottom: 1px dotted var(--border); cursor: pointer; }
.ed-article:last-child { border-bottom: none; }
.ed-article:hover { background: var(--bg2); margin: 0 -8px; padding-left: 8px; padding-right: 8px; border-radius: 4px; }
.ed-article-title { font-size: 13px; font-weight: 500; color: var(--text); text-decoration: none; }
.ed-article-title:hover { color: var(--accent); }
.ed-article-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }

@media (max-width: 600px) { .ed-page { padding: 20px 16px 40px; } }

.graph-panel {
  flex: 1;
  position: relative;
  overflow: hidden;
}
.graph-panel .graph-container {
  height: 100%;
}

@media (max-width: 600px) {
  .swimlanes { grid-template-columns: repeat(2, 1fr); }
  .header { flex-wrap: wrap; gap: 8px; }
  .graph-container { height: 400px; }
  .page { padding: 12px; }
  .card { overflow-x: auto; }
  .articles-table { min-width: 500px; }
  .entity-graph-layout { flex-direction: column; height: auto; }
  .entity-sidebar { width: 100%; min-width: 0; max-height: 300px; border-right: none; border-bottom: 1px solid var(--border); }
  .graph-panel .graph-container { height: 400px; }
}

/* ===================== Ask page ===================== */

/* Entities page has no padding; Ask page uses standard page padding */
#page-ask { padding: 24px; max-width: none; }

.ask-page {
  max-width: 800px;
  margin: 0 auto;
  padding: 24px 0;
}

.ask-input-wrap {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.ask-input {
  flex: 1;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 18px;
  padding: 12px 16px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.ask-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
}
.ask-input::placeholder { color: var(--muted); }

.ask-submit-btn {
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  padding: 12px 24px;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.ask-submit-btn:hover { opacity: 0.85; }
.ask-submit-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.ask-examples {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.ask-examples-label {
  color: var(--muted);
  font-size: 12px;
}
.ask-example {
  background: none;
  border: 1px solid var(--border);
  border-radius: 16px;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  padding: 4px 12px;
  transition: color 0.15s, border-color 0.15s;
}
.ask-example:hover { color: var(--text); border-color: var(--muted); }

.ask-history {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}
.ask-history-label {
  color: var(--muted);
  font-size: 12px;
}
.ask-history-item {
  background: none;
  border: 1px solid var(--border);
  border-radius: 16px;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  padding: 3px 10px;
  transition: color 0.15s, border-color 0.15s;
}
.ask-history-item:hover { color: var(--text); border-color: var(--muted); }

/* Skeleton loading */
@keyframes skeleton-pulse {
  0%   { opacity: 0.6; }
  50%  { opacity: 0.25; }
  100% { opacity: 0.6; }
}
.ask-skeleton { margin-top: 16px; }
.skeleton-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}
.skeleton-line {
  background: var(--bg3);
  border-radius: 4px;
  height: 12px;
  margin-bottom: 10px;
}
.skeleton-line:last-child { margin-bottom: 0; }
.skeleton-line.long   { width: 100%; }
.skeleton-line.medium { width: 68%; }
.skeleton-line.short  { width: 38%; }

/* Answer card */
.ask-answer { margin-top: 16px; }
.ask-answer-body {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
}
.ask-answer-body p { margin-bottom: 8px; }
.ask-answer-body p:last-child { margin-bottom: 0; }

/* Trends */
.ask-trends-list { display: flex; flex-direction: column; gap: 8px; }
.ask-trend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.ask-trend-item:last-child { border-bottom: none; }
.ask-trend-arrow { font-size: 14px; font-weight: 700; width: 16px; text-align: center; }
.ask-trend-rising  .ask-trend-arrow { color: var(--green); }
.ask-trend-falling .ask-trend-arrow { color: var(--red); }
.ask-trend-stable  .ask-trend-arrow { color: var(--muted); }
.ask-trend-entity { flex: 1; font-weight: 500; }
.ask-trend-nums { color: var(--muted); font-size: 12px; }
.ask-trend-pct {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 52px;
  text-align: center;
}
.ask-trend-rising  .ask-trend-pct { background: rgba(63,185,80,0.15); color: var(--green); }
.ask-trend-falling .ask-trend-pct { background: rgba(248,81,73,0.12); color: var(--red); }
.ask-trend-stable  .ask-trend-pct { background: var(--bg3); color: var(--muted); }
.ask-trend-sparkline { flex-shrink: 0; display: block; }

/* Sources */
.ask-source-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
}
.ask-source-item:last-child { border-bottom: none; }
.ask-source-score {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}
.ask-source-body { flex: 1; min-width: 0; }
.ask-source-title {
  display: block;
  font-weight: 500;
  font-size: 14px;
  margin-bottom: 3px;
  color: var(--accent);
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}
.ask-source-title:hover { text-decoration: underline; }
.ask-source-meta { color: var(--muted); font-size: 12px; margin-bottom: 3px; }
.ask-source-note { color: var(--muted); font-size: 12px; font-style: italic; }

/* Entities */
.ask-entities {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.ask-entity-chip {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 16px;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 5px 12px;
  transition: border-color 0.15s, background 0.15s;
}
.ask-entity-chip:hover { border-color: var(--accent); background: rgba(88,166,255,0.08); }
.ask-entity-chip-wrap { display: inline-flex; align-items: center; gap: 4px; }
.ask-entity-detail-link { font-size: 11px; color: var(--muted); text-decoration: none; }
.ask-entity-detail-link:hover { color: var(--accent); }
.ask-entity-count {
  background: var(--bg2);
  border-radius: 10px;
  color: var(--muted);
  font-size: 11px;
  padding: 1px 6px;
}

/* Query detail (collapsible) */
.ask-query summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
  user-select: none;
  padding: 2px 0;
}
.ask-query summary:hover { color: var(--text); }
.ask-query[open] summary { margin-bottom: 10px; }
.ask-sql {
  background: var(--bg3);
  border-radius: 6px;
  color: var(--text);
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 12px;
  overflow-x: auto;
  padding: 10px 12px;
  white-space: pre;
  margin-bottom: 8px;
}
.ask-query-explanation { color: var(--muted); font-size: 13px; }

/* Empty / error states */
.ask-empty {
  color: var(--muted);
  font-size: 14px;
  padding: 32px 0;
  text-align: center;
}
.ask-error {
  background: rgba(248, 81, 73, 0.08);
  border: 1px solid rgba(248, 81, 73, 0.25);
  border-radius: 8px;
  color: var(--red);
  font-size: 13px;
  margin-top: 16px;
  padding: 16px;
}
.ask-error p { margin-bottom: 10px; }
.ask-retry-btn {
  background: rgba(248, 81, 73, 0.12);
  border: 1px solid rgba(248, 81, 73, 0.3);
  border-radius: 6px;
  color: var(--red);
  cursor: pointer;
  font-size: 12px;
  padding: 6px 14px;
  transition: background 0.15s;
}
.ask-retry-btn:hover { background: rgba(248, 81, 73, 0.2); }

/* ===== Ask page context-dependent visualizations ===== */
.ask-viz { margin-top: 12px; }
.ask-viz h2 { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.05em; margin-bottom: 12px; }

/* Bar chart */
.ask-barchart-legend {
  display: flex;
  gap: 16px;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 8px;
}
.ask-barchart-legend-this::before {
  content: '';
  display: inline-block;
  width: 10px; height: 7px;
  background: var(--accent);
  border-radius: 2px;
  margin-right: 4px;
  vertical-align: middle;
  opacity: 0.85;
}
.ask-barchart-legend-prev::before {
  content: '';
  display: inline-block;
  width: 10px; height: 6px;
  background: var(--border);
  border-radius: 2px;
  margin-right: 4px;
  vertical-align: middle;
}
.ask-barchart-svg { display: block; max-width: 100%; overflow-x: auto; }

/* Timeline */
.ask-timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative;
}
.ask-timeline::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--border);
}
.ask-timeline-item {
  display: flex;
  gap: 16px;
  padding: 4px 0 16px;
  position: relative;
}
.ask-timeline-dot {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg2);
  margin-top: 2px;
  z-index: 1;
}
.ask-timeline-content { flex: 1; min-width: 0; }
.ask-timeline-date {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.ask-timeline-article {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 4px;
}
.ask-timeline-title {
  font-size: 13px;
  color: var(--accent);
  text-decoration: none;
  flex: 1;
}
.ask-timeline-title:hover { text-decoration: underline; }

/* Entity profile */
.ask-viz-entity-profile { padding: 20px 24px; }
.ask-entity-profile-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.ask-entity-profile-name {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}
.ask-entity-profile-stats {
  display: flex;
  gap: 32px;
  margin-bottom: 20px;
}
.ask-entity-profile-btn {
  background: var(--accent);
  border: none;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 16px;
  transition: opacity 0.15s;
}
.ask-entity-profile-btn:hover { opacity: 0.85; }

/* ===== Digest Page — newspaper-style daily brief ===== */
.digest-masthead {
  text-align: center;
  padding: 32px 24px 16px;
  max-width: 640px;
  margin: 0 auto;
}
.digest-masthead-title {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text);
  font-family: Georgia, 'Times New Roman', serif;
}
.digest-masthead-rule {
  height: 3px;
  background: var(--border);
  border-top: 1px solid var(--muted);
  border-bottom: 1px solid var(--muted);
  margin: 10px 0 8px;
}
.digest-masthead-meta {
  display: flex;
  justify-content: center;
  gap: 20px;
  font-size: 12px;
  color: var(--muted);
  flex-wrap: wrap;
}

.digest-editorial {
  max-width: 640px;
  margin: 0 auto 24px;
  padding: 0 24px;
  font-size: 15px;
  color: var(--muted);
  font-style: italic;
}

.digest-section {
  max-width: 640px;
  margin: 0 auto 32px;
  padding: 0 24px;
}
.digest-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}
.digest-section-rule {
  flex: 1;
  height: 1px;
  background: var(--border);
}
.digest-section-badge {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 4px;
}
.digest-badge-read   { background: rgba(63,185,80,0.15); color: var(--green); }
.digest-badge-skim   { background: rgba(88,166,255,0.15); color: var(--accent); }
.digest-badge-podcast { background: rgba(130,80,223,0.1); color: var(--save-color); }
.digest-section-count {
  font-size: 12px;
  color: var(--muted);
}

.digest-cluster { margin-bottom: 20px; }
.digest-cluster-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  border-left: 2px solid var(--accent);
  padding-left: 8px;
  margin-bottom: 10px;
}

.digest-article {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.digest-article:last-child { border-bottom: none; }
.digest-article-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.digest-score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg3);
  font-size: 11px;
  font-weight: 600;
  color: var(--green);
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.digest-source {
  font-size: 11px;
  color: var(--muted);
}
.digest-article-title {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
  margin-bottom: 6px;
  overflow-wrap: break-word;
}
.digest-article-title a { color: var(--text); }
.digest-article-title a:hover { color: var(--accent); text-decoration: none; }
.digest-summary {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.55;
  margin-bottom: 4px;
}
.digest-key-insight {
  font-size: 12px;
  color: var(--accent);
  line-height: 1.5;
  background: rgba(88,166,255,0.07);
  border-left: 2px solid var(--accent);
  padding: 4px 8px;
  border-radius: 0 4px 4px 0;
  margin-top: 4px;
  overflow-wrap: break-word;
}
.digest-insight-label {
  font-weight: 600;
  margin-right: 4px;
}

/* Quick Hits / Podcasts — compact inline list */
.digest-quickhits {
  list-style: none;
  padding: 0;
  margin: 0;
}
.digest-quickhit {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.digest-quickhit:last-child { border-bottom: none; }
.digest-quickhit a {
  color: var(--text);
  font-weight: 500;
  flex: 1;
  min-width: 0;
}
.digest-quickhit a:hover { color: var(--accent); text-decoration: none; }
.digest-quickhit-source {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.digest-quickhit-tldr { font-size: 12px; color: var(--muted); line-height: 1.5; margin-top: 2px; }

.digest-overflow summary { font-size: 12px; color: var(--muted); cursor: pointer; padding: 6px 0; }
.digest-overflow summary:hover { color: var(--accent); }

.digest-empty {
  max-width: 640px;
  margin: 40px auto;
  padding: 0 24px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}
