:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #6f6e69;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);
  --hover: rgba(11, 11, 11, 0.05);
  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --positive: #2a78d6;
  --neutral: #c3c2b7;
  --negative: #e34948;
  --delta-up: #006300;
  --delta-down: #b02f2f;
  --mark: #fff0b3;
  font-family: system-ui, -apple-system, "Segoe UI", "Nirmala UI", "Noto Sans Bengali", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #a09f97;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.1);
    --hover: rgba(255, 255, 255, 0.07);
    --accent: #3987e5;
    --accent-ink: #86b6ef;
    --positive: #3987e5;
    --neutral: #5a5a55;
    --negative: #e66767;
    --delta-up: #0ca30c;
    --delta-down: #e66767;
    --mark: #5c4a00;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--ink); font-size: 14px; line-height: 1.45; }
h1, h2, h3, p { margin: 0; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

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

.sidebar { display: flex; flex-direction: column; gap: 16px; padding: 16px 12px; border-right: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { font-weight: 650; font-size: 16px; padding: 0 8px; }
.folder { margin: 14px 8px 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.topic { display: flex; justify-content: space-between; gap: 8px; width: 100%; padding: 6px 8px; border: 0; border-radius: 6px; background: none; text-align: left; cursor: pointer; }
.topic:hover { background: var(--hover); }
.topic[aria-current="true"] { background: var(--hover); font-weight: 600; }
.topic .n { color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 400; }
.status { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--border); font-size: 12px; color: var(--ink-2); display: grid; gap: 8px; }
.status details summary { cursor: pointer; }
.status ul { margin: 6px 0 0; padding-left: 16px; }

.main { min-width: 0; padding: 20px 24px 48px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
h1 { font-size: 20px; font-weight: 650; }
.tabs { display: inline-flex; gap: 2px; padding: 2px; border-radius: 8px; background: var(--hover); }
.tabs button { padding: 5px 14px; border: 0; border-radius: 6px; background: none; cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--surface); font-weight: 600; box-shadow: 0 0 0 1px var(--border); }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 18px; }
.filters input[type="search"] { flex: 1 1 220px; min-width: 0; }
.filters input[type="search"], .filters select, .btn { height: 34px; padding: 0 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }
.btn { cursor: pointer; }
.btn:hover { background: var(--hover); }
.btn:disabled { cursor: default; opacity: 0.6; }
.check { display: inline-flex; gap: 6px; align-items: center; color: var(--ink-2); cursor: pointer; }

#view { outline: none; transition: opacity 0.12s; }
#view.loading { opacity: 0.55; }
.count { color: var(--ink-2); margin-bottom: 10px; }
.empty { padding: 48px 16px; text-align: center; color: var(--ink-2); }
.notice { padding: 10px 12px; margin-bottom: 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--ink-2); }

.mention { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 14px; padding: 14px 16px; margin-bottom: 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.mention h2 { font-size: 15px; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.mention h2 a { text-decoration: none; }
.mention h2 a:hover { text-decoration: underline; }
.mention .thumb { grid-column: 2; grid-row: 1 / span 3; width: 96px; height: 64px; object-fit: cover; border-radius: 6px; background: var(--hover); }
.meta { color: var(--ink-2); font-size: 13px; }
.snippet { color: var(--ink-2); overflow-wrap: anywhere; }
mark { background: var(--mark); color: inherit; border-radius: 2px; }
.mention footer { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-top: 6px; font-size: 13px; color: var(--ink-2); }
.tag { padding: 1px 7px; border-radius: 10px; background: var(--hover); font-size: 12px; }
.tag.search { box-shadow: inset 0 0 0 1px var(--axis); background: none; }
.linklike { padding: 0; border: 0; background: none; color: var(--accent-ink); cursor: pointer; text-decoration: underline; }
.sentiment { display: inline-flex; gap: 2px; margin-left: auto; align-items: center; }
.sentiment .label { margin-right: 6px; color: var(--muted); font-size: 12px; }
.sentiment button { padding: 2px 8px; border: 1px solid var(--border); border-radius: 6px; background: none; cursor: pointer; font-size: 12px; }
.sentiment button:hover { background: var(--hover); }
.sentiment button[aria-pressed="true"][data-s="positive"] { background: var(--positive); border-color: var(--positive); color: #fff; }
.sentiment button[aria-pressed="true"][data-s="neutral"] { background: var(--neutral); border-color: var(--neutral); color: var(--ink); }
.sentiment button[aria-pressed="true"][data-s="negative"] { background: var(--negative); border-color: var(--negative); color: #fff; }
.more-list { grid-column: 1 / -1; margin: 8px 0 0; padding: 8px 0 0 16px; border-top: 1px solid var(--border); font-size: 13px; }
.pager { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 16px; color: var(--ink-2); }

.mainnav { display: grid; gap: 1px; }
.navlink { padding: 7px 8px; border-radius: 6px; text-decoration: none; }
.navlink:hover { background: var(--hover); }
.navlink[aria-current="page"] { background: var(--hover); font-weight: 600; }
.filters[hidden] { display: none; }

.auth-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.auth-card { display: grid; gap: 12px; width: 100%; max-width: 380px; padding: 28px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.auth-card .brand { padding: 0; }
.auth-card form { display: grid; gap: 12px; }
.field { display: grid; gap: 4px; font-size: 13px; color: var(--ink-2); flex: 1 1 200px; min-width: 0; }
.field input, .field select, .field textarea, .link-box input, .row-actions select { width: 100%; min-height: 36px; padding: 6px 10px; border: 1px solid var(--axis); border-radius: 6px; background: var(--surface); color: var(--ink); font-size: 14px; }
.field textarea { resize: vertical; }
.row-actions select { width: auto; height: 34px; min-height: 0; padding: 0 8px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.form-error { margin: 0; color: var(--delta-down); font-size: 13px; }
.form-error[hidden] { display: none; }
.stack { display: grid; gap: 10px; min-width: 0; }
.narrow { max-width: 480px; }
.form-row { display: flex; flex-wrap: wrap; gap: 10px; }
.form-row.actions { align-items: center; }
.card-title { font-size: 15px; font-weight: 600; margin: 0; }
.intro { max-width: 70ch; }
.row-card { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px 16px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.row-main { min-width: 0; flex: 1 1 280px; display: grid; gap: 2px; overflow-wrap: anywhere; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-start; }
.muted-row { opacity: 0.65; }
.keywords { font-size: 12.5px; }
.spark { display: block; }
.spark polyline { fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-linejoin: round; }
.spark circle { fill: var(--accent); }
.topic-table { margin-top: 0; }
.topic-table .linklike { text-align: left; }
.tag.spike { margin-left: 6px; background: var(--mark); }
.stories li.latest { display: grid; gap: 1px; }
.stories a { overflow-wrap: anywhere; }
.sentiment button:disabled { cursor: default; opacity: 0.7; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-bottom: 12px; }
.tile, .card { border: 1px solid var(--border); border-radius: 8px; background: var(--surface); padding: 14px 16px; min-width: 0; }
.tile .label { color: var(--ink-2); font-size: 13px; }
.tile .value { font-size: 28px; font-weight: 600; line-height: 1.2; margin-top: 2px; }
.tile .sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.delta-up { color: var(--delta-up); }
.delta-down { color: var(--delta-down); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 10px; margin-bottom: 10px; }
.card.wide { margin-bottom: 10px; }
.card h2 { font-size: 14px; font-weight: 600; margin-bottom: 10px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }

.trend { width: 100%; height: auto; display: block; }
.trend text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.trend .grid { stroke: var(--grid); stroke-width: 1; }
.trend .base { stroke: var(--axis); stroke-width: 1; }
.trend .bar { fill: var(--accent); }
.trend .hit { fill: transparent; cursor: default; }
.trend .hit:hover, .trend .hit:focus { fill: var(--hover); outline: none; }
.tooltip { position: fixed; z-index: 10; pointer-events: none; padding: 6px 9px; border-radius: 6px; background: var(--ink); color: var(--surface); font-size: 12px; white-space: nowrap; }
table.data { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 13px; }
table.data th, table.data td { padding: 4px 6px; border-bottom: 1px solid var(--grid); text-align: left; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }

.split { display: flex; gap: 2px; height: 14px; margin-bottom: 10px; }
.split span { min-width: 2px; }
.split span:first-child { border-radius: 4px 0 0 4px; }
.split span:last-child { border-radius: 0 4px 4px 0; }
.split .positive, .swatch.positive { background: var(--positive); }
.split .neutral, .swatch.neutral { background: var(--neutral); }
.split .negative, .swatch.negative { background: var(--negative); }
.split .unscored, .swatch.unscored { background: var(--grid); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--ink-2); font-size: 13px; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }

.rank { display: grid; gap: 7px; margin: 0; padding: 0; list-style: none; }
.rank li { display: grid; grid-template-columns: minmax(90px, 38%) minmax(0, 1fr) 40px; gap: 8px; align-items: center; font-size: 13px; }
.rank .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank .track { display: block; height: 8px; }
.rank .fill { display: block; height: 8px; min-width: 2px; border-radius: 0 4px 4px 0; background: var(--accent); }
.rank .num { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.stories { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.stories li { display: flex; justify-content: space-between; gap: 12px; }
.stories .num { color: var(--ink-2); white-space: nowrap; font-size: 13px; }

@media (max-width: 800px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border); max-height: 45vh; }
  .main { padding: 16px; }
  .mention .thumb { display: none; }
  .mention { grid-template-columns: minmax(0, 1fr); }
  .sentiment { margin-left: 0; }
  .cards { grid-template-columns: minmax(0, 1fr); }
}
