:root {
  color-scheme: light;
  --bg: #f3f5f2;
  --panel: #ffffff;
  --panel-soft: #f0f4ef;
  --text: #111814;
  --muted: #657069;
  --line: #d8dfd8;
  --brand: #087f5b;
  --brand-strong: #066146;
  --warn: #b7791f;
  --blue: #1d4ed8;
  --rose: #b91c1c;
  --shadow: 0 10px 30px rgba(28, 41, 34, 0.08);
}

body.dark {
  color-scheme: dark;
  --bg: #101417;
  --panel: #171d21;
  --panel-soft: #20292e;
  --text: #edf2f4;
  --muted: #9aa8b1;
  --line: #2b363c;
  --brand: #2dd4bf;
  --brand-strong: #5eead4;
  --warn: #f59e0b;
  --blue: #60a5fa;
  --rose: #fb7185;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(8, 127, 91, 0.06), transparent 260px),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 94%, var(--panel-soft));
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--text);
  color: var(--panel);
  font-weight: 800;
}

.workspace-switcher {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 12px;
}

.workspace-switcher span,
.eyebrow {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
  font-weight: 700;
}

.workspace-switcher strong {
  display: block;
  margin-top: 5px;
  font-size: 14px;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
  margin-top: 2px;
}

.nav-group {
  display: grid;
  gap: 6px;
}

.nav-item {
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 12px;
  text-align: left;
}

.nav-item.is-active,
.nav-item:hover {
  background: var(--panel-soft);
  color: var(--text);
}

.icon {
  width: 22px;
  text-align: center;
  color: var(--brand);
  font-weight: 700;
}

.source-panel,
.mini-card,
.rail-section,
.stat-block {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
}

.source-panel {
  padding: 16px;
  display: grid;
  gap: 10px;
  max-height: 310px;
  overflow: auto;
}

.source-filter-list {
  display: grid;
  gap: 10px;
}

.panel-title {
  color: var(--muted);
  font-size: 13px;
}

.source-panel label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 14px;
}

.source-panel input {
  accent-color: var(--brand);
}

.mini-card {
  margin-top: auto;
  padding: 16px;
}

.metric-label,
.stat-block span,
.section-head p,
.article-meta,
.article-tags,
.article-signal span,
.health-row span,
.section-head.compact span {
  color: var(--muted);
}

.mini-card strong {
  display: block;
  font-size: 32px;
  margin: 6px 0;
}

.mini-card small {
  color: var(--muted);
  line-height: 1.5;
}

.disclaimer {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
  margin: 0;
}

.main {
  min-width: 0;
  padding: 24px 28px 32px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  margin-bottom: 18px;
}

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

h1 {
  font-size: 32px;
  line-height: 1.2;
  letter-spacing: 0;
  margin-top: 6px;
}

.topbar p {
  color: var(--muted);
  margin-top: 8px;
  max-width: 760px;
  line-height: 1.6;
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.refresh-status {
  display: grid;
  gap: 2px;
  min-width: 118px;
  color: var(--text);
  font-size: 13px;
}

.refresh-status small {
  color: var(--muted);
}

.search-box {
  width: min(420px, 34vw);
  height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 0 12px;
}

.search-box input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.icon-button,
.text-button {
  border: 1px solid var(--line);
  color: var(--text);
  background: var(--panel);
  border-radius: 8px;
}

.icon-button {
  width: 42px;
  height: 42px;
}

.text-button {
  min-height: 30px;
  padding: 0 10px;
}

.text-button:hover,
.icon-button:hover,
.focus-strip button:hover {
  border-color: var(--brand);
  color: var(--brand-strong);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.stat-block {
  padding: 16px;
  min-height: 108px;
}

.stat-block strong {
  display: block;
  font-size: 26px;
  line-height: 1.2;
  margin: 10px 0 6px;
}

.stat-block small {
  color: var(--muted);
}

.stat-block.accent {
  background: linear-gradient(135deg, rgba(15, 118, 110, 0.16), rgba(37, 99, 235, 0.1)), var(--panel);
}

.focus-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 16px;
}

.focus-strip button {
  min-height: 34px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 999px;
  padding: 0 12px;
}

.content-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: start;
}

.feed-section {
  min-width: 0;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.section-head h2 {
  font-size: 18px;
  letter-spacing: 0;
}

.section-head p {
  font-size: 14px;
  margin-top: 4px;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel);
}

.segmented button {
  border: 0;
  background: transparent;
  color: var(--muted);
  min-height: 36px;
  padding: 0 14px;
}

.segmented button.is-selected {
  background: var(--brand-strong);
  color: white;
}

.feed-list {
  display: grid;
  gap: 10px;
}

.source-board-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.cluster-list {
  display: grid;
  gap: 14px;
}

.cluster-card {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 16px;
}

.cluster-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.cluster-head h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

.cluster-head h3 a {
  color: var(--text);
  text-decoration: none;
}

.cluster-head h3 a:hover {
  color: var(--brand-strong);
  text-decoration: underline;
}

.cluster-summary {
  color: var(--muted);
  line-height: 1.58;
  font-size: 14px;
}

.cluster-metrics {
  display: grid;
  grid-template-columns: repeat(2, 72px);
  gap: 8px;
}

.cluster-metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  text-align: center;
}

.cluster-metric strong,
.cluster-metric span {
  display: block;
}

.cluster-metric strong {
  font-size: 20px;
}

.cluster-metric span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.cluster-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.cluster-meta span {
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--muted);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
}

.cluster-items {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.cluster-item {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  font-size: 14px;
}

.cluster-item b {
  color: var(--brand-strong);
  font-size: 12px;
}

.cluster-item a {
  color: var(--text);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cluster-item a:hover {
  color: var(--brand-strong);
  text-decoration: underline;
}

.cluster-item span {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.source-board {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-width: 0;
  overflow: hidden;
}

.source-board-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
}

.source-board-head h3 {
  margin: 0;
  font-size: 16px;
}

.source-board-head span {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.source-board-items {
  display: grid;
}

.source-board-item {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
}

.source-board-item:first-child {
  border-top: 0;
}

.source-board-rank {
  color: var(--brand-strong);
  font-weight: 800;
  font-size: 13px;
}

.source-board-title {
  min-width: 0;
}

.source-board-title a {
  color: var(--text);
  text-decoration: none;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-board-title a:hover {
  color: var(--brand-strong);
  text-decoration: underline;
}

.source-board-title small,
.source-board-score {
  color: var(--muted);
  font-size: 12px;
}

.source-board-score {
  white-space: nowrap;
}

.article-card {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 124px;
  gap: 14px;
  align-items: stretch;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 13px;
  box-shadow: none;
}

.article-card:hover,
.cluster-card:hover,
.source-board:hover {
  border-color: color-mix(in srgb, var(--brand) 45%, var(--line));
  box-shadow: var(--shadow);
}

.article-rank {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--brand-strong);
  font-weight: 800;
}

.article-body {
  min-width: 0;
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-size: 13px;
}

.source-pill {
  color: var(--panel);
  background: var(--brand-strong);
  border-radius: 999px;
  padding: 2px 8px;
}

h3 {
  margin: 8px 0 7px;
  font-size: 16px;
  line-height: 1.38;
  letter-spacing: 0;
}

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

h3 a:hover {
  color: var(--brand-strong);
  text-decoration: underline;
}

.article-body p {
  color: var(--muted);
  line-height: 1.52;
  font-size: 14px;
}

.article-original-title {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  margin: -2px 0 8px;
}

.article-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.article-tags span {
  border: 1px solid var(--line);
  background: var(--panel-soft);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
}

.article-signal {
  border-left: 1px solid var(--line);
  padding-left: 14px;
  display: grid;
  align-content: center;
  gap: 8px;
}

.article-signal strong {
  font-size: 20px;
}

.sparkline {
  height: 34px;
  display: flex;
  align-items: end;
  gap: 4px;
}

.sparkline i {
  display: block;
  width: 12px;
  border-radius: 3px 3px 0 0;
  background: var(--brand);
  opacity: 0.8;
}

.sparkline i:nth-child(1) { height: 30%; }
.sparkline i:nth-child(2) { height: 58%; }
.sparkline i:nth-child(3) { height: 48%; }
.sparkline i:nth-child(4) { height: 76%; }
.sparkline i:nth-child(5) { height: 100%; }

.right-rail {
  display: grid;
  gap: 14px;
  position: sticky;
  top: 18px;
}

.rail-section {
  padding: 16px;
}

.section-head.compact {
  margin-bottom: 12px;
}

.section-head.compact h2 {
  font-size: 16px;
}

.signal-list {
  display: grid;
  gap: 8px;
}

.signal-card {
  border: 1px solid var(--line);
  background: var(--panel-soft);
  border-radius: 8px;
  padding: 10px;
}

.signal-card button {
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0;
  text-align: left;
  width: 100%;
  font-weight: 700;
  line-height: 1.35;
}

.signal-card button:hover {
  color: var(--brand-strong);
}

.signal-card p {
  color: var(--muted);
  line-height: 1.45;
  margin-top: 6px;
  font-size: 12px;
}

.signal-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.signal-meta span {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 12px;
}

.watch-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.watch-tags button {
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--text);
  border-radius: 999px;
  min-height: 32px;
  padding: 0 10px;
}

.health-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  font-size: 14px;
}

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

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 34px;
  text-align: center;
  color: var(--muted);
  background: var(--panel);
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav-group {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .source-panel {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .panel-title {
    grid-column: 1 / -1;
  }

  .mini-card {
    margin-top: 0;
  }

  .content-layout {
    grid-template-columns: 1fr;
  }

  .right-rail {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    position: static;
  }
}

@media (max-width: 760px) {
  .main,
  .sidebar {
    padding: 18px;
  }

  .topbar {
    display: grid;
  }

  .toolbar,
  .search-box {
    width: 100%;
  }

  .toolbar {
    display: grid;
    grid-template-columns: 1fr;
  }

  .summary-grid,
  .right-rail,
  .source-board-list,
  .source-panel,
  .nav-group {
    grid-template-columns: 1fr;
  }

  .section-head {
    align-items: flex-start;
    display: grid;
  }

  .article-card {
    grid-template-columns: 36px minmax(0, 1fr);
  }

  .cluster-head,
  .cluster-item {
    grid-template-columns: 1fr;
  }

  .cluster-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .article-signal {
    grid-column: 2;
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 12px 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
}
