:root {
  --paper: #faf8f3;
  --panel: #ffffff;
  --ink: #1c1b19;
  --soft: #45413a;
  --muted: #6f6a61;
  --rule: #dcd7cb;
  --rule-strong: #1c1b19;
  --accent: #9a3412;
  --high: #1f6f43;
  --medium: #8a6100;
  --low: #a32a2a;
  --left: #2f5d9b;
  --center: #7a756c;
  --right: #b0413a;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #151412; --panel: #1e1c19; --ink: #ece8df; --soft: #cfc9bd; --muted: #9a9488;
    --rule: #35322c; --rule-strong: #ece8df; --accent: #e8935a;
    --high: #6fc497; --medium: #e0b454; --low: #ef8a84; --left: #7fa9e6; --center: #9a9488; --right: #ec8f88;
  }
}
:root[data-theme="dark"] {
  --paper: #151412; --panel: #1e1c19; --ink: #ece8df; --soft: #cfc9bd; --muted: #9a9488;
  --rule: #35322c; --rule-strong: #ece8df; --accent: #e8935a;
  --high: #6fc497; --medium: #e0b454; --low: #ef8a84; --left: #7fa9e6; --center: #9a9488; --right: #ec8f88;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 15px/1.5 var(--sans); padding: 0 16px 80px;
}
body > * { max-width: 1240px; margin-left: auto; margin-right: auto; }
button, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.masthead {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 12px;
  padding: 22px 0 12px; border-bottom: 3px double var(--rule-strong);
}
.masthead h1 { font: 700 clamp(28px, 5vw, 44px)/1 var(--serif); letter-spacing: -0.01em; margin: 0; text-align: center; }
.mast-side { font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.mast-actions { display: flex; gap: 16px; justify-content: flex-end; }

.link { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--rule); font-size: 13px; }
.link:hover { color: var(--ink); text-decoration-color: currentColor; }
.mast-actions .link { text-transform: uppercase; letter-spacing: 0.06em; font-size: 12px; text-decoration: none; }
.primary { background: var(--ink); color: var(--paper); border: 1px solid var(--ink); padding: 7px 16px; border-radius: 2px; font-size: 13px; letter-spacing: 0.04em; text-transform: uppercase; }
.primary:disabled { opacity: 0.5; cursor: default; }

.tabs { display: flex; gap: 4px 22px; flex-wrap: wrap; align-items: baseline; padding: 12px 0 0; border-bottom: 1px solid var(--rule); }
.tab { position: relative; background: none; border: 0; border-bottom: 2px solid transparent; padding: 6px 0 10px; font: 600 14px var(--sans); letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.tab .count { margin-left: 6px; font-weight: 600; font-size: 11px; color: var(--accent); letter-spacing: 0; }
.tab-add { color: var(--accent); }

.toolbar { display: flex; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; align-items: end; padding: 16px 0 14px; }
.toolbar[hidden], .status[hidden], .toast[hidden] { display: none; }
.definition { margin: 0; font: italic 16px/1.4 var(--serif); color: var(--soft); max-width: 60ch; }
.updated { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.controls { display: flex; gap: 14px 18px; align-items: center; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--rule); border-radius: 2px; overflow: hidden; }
.seg button { background: none; border: 0; padding: 5px 12px; font-size: 13px; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.sort { font-size: 13px; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; }
.sort select { background: var(--paper); border: 1px solid var(--rule); border-radius: 2px; padding: 4px 6px; font-size: 13px; }

.status { margin: 0 auto 12px; padding: 10px 14px; border-left: 3px solid var(--accent); background: var(--panel); font-size: 14px; color: var(--soft); }
.status.error { border-left-color: var(--low); }

.stories { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 0 36px; border-top: 1px solid var(--rule-strong); }
.card { padding: 20px 0 18px; border-bottom: 1px solid var(--rule); min-width: 0; scroll-margin: 90px; }
.card.focus { box-shadow: -12px 0 0 -9px var(--accent); }
@media (min-width: 760px) {
  .card.lead { grid-column: span 2; }
  .card.lead .headline { font-size: 30px; }
  .card.lead .summary { font-size: 17px; }
}
.flags { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; margin-bottom: 9px; }
.badge { font: 600 11px/1 var(--sans); letter-spacing: 0.06em; text-transform: uppercase; padding: 4px 7px; border: 1px solid currentColor; border-radius: 2px; background: none; }
.trust-high { color: var(--high); } .trust-medium { color: var(--medium); } .trust-low { color: var(--low); } .trust-unrated { color: var(--muted); }
.flag { font-size: 12px; color: var(--muted); }
.flag.warn { color: var(--accent); font-weight: 600; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-left: auto; }
.headline { font: 700 21px/1.22 var(--serif); margin: 0 0 8px; letter-spacing: -0.005em; text-wrap: balance; }
.headline a { text-decoration: none; }
.headline a:hover { text-decoration: underline; text-underline-offset: 3px; }
.summary { margin: 0 0 10px; font: 15.5px/1.5 var(--serif); color: var(--soft); }
.card.read .headline, .card.read .summary { opacity: 0.55; }
.disagree { margin: 0 0 10px; padding: 8px 10px; border-left: 3px solid var(--accent); background: var(--panel); font-size: 13.5px; }
.disagree b { color: var(--accent); }

.views { margin: 0 0 10px; display: grid; gap: 6px; }
.views-title, .meta-title { font: 600 11px var(--sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 0 0 2px; }
.view { font-size: 13.5px; margin: 0; padding-left: 10px; border-left: 2px solid var(--rule); }
.view b { font-weight: 600; }
.view span { color: var(--muted); }

.spectrum { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; font-size: 12px; color: var(--muted); }
.bar { display: flex; height: 6px; width: 110px; border-radius: 3px; overflow: hidden; background: var(--rule); }
.bar i { display: block; height: 100%; }
.bar .l { background: var(--left); } .bar .c { background: var(--center); } .bar .r { background: var(--right); }

.sources { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 3px; font-size: 13px; }
.sources li { display: flex; gap: 8px; align-items: baseline; min-width: 0; }
.sources a { font-weight: 600; text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sources a:hover { text-decoration-color: currentColor; }
.tag { font-size: 11px; color: var(--muted); white-space: nowrap; }
.tag.left { color: var(--left); } .tag.right { color: var(--right); }
.when { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 12px; }
.more-sources { font-size: 12px; }

.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; color: var(--muted); padding: 0 4px; border-radius: 2px; }
.menu summary::-webkit-details-marker { display: none; }
.menu summary:hover { color: var(--ink); background: var(--rule); }
.menu-items { position: absolute; right: 0; top: 100%; z-index: 5; background: var(--panel); border: 1px solid var(--rule); box-shadow: 0 6px 20px rgb(0 0 0 / 0.14); min-width: 190px; padding: 4px; display: grid; }
.menu-items button { text-align: left; background: none; border: 0; padding: 7px 10px; font-size: 13px; white-space: nowrap; }
.menu-items button:hover { background: var(--paper); }

.foot { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: baseline; font-size: 12px; color: var(--muted); }
.foot .stamp { flex-basis: 100%; font-variant-numeric: tabular-nums; }
.foot .link { font-size: 12px; }
.foot .link[disabled] { opacity: 0.5; cursor: default; }

.breakdown { margin: 0 0 12px; padding: 10px 12px; background: var(--panel); border: 1px solid var(--rule); font-size: 13px; }
.breakdown table { width: 100%; border-collapse: collapse; }
.breakdown td { padding: 3px 0; vertical-align: top; }
.breakdown td:first-child { font-weight: 600; padding-right: 10px; white-space: nowrap; }
.breakdown td:last-child { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; padding-left: 10px; }
.breakdown p { margin: 8px 0 0; color: var(--muted); font-size: 12px; }

.empty { grid-column: 1 / -1; padding: 64px 0; text-align: center; color: var(--muted); }
.empty h2 { font: 700 26px var(--serif); color: var(--ink); margin: 0 0 8px; }
.empty p { margin: 0 auto 18px; max-width: 46ch; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 3px; font-size: 14px; display: flex; gap: 14px; align-items: center; max-width: calc(100vw - 32px); z-index: 20; }
.toast button { background: none; border: 0; color: inherit; text-decoration: underline; padding: 0; font-size: 14px; }

dialog { border: 1px solid var(--rule); background: var(--paper); color: var(--ink); padding: 22px 24px; width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 48px); border-radius: 3px; }
dialog.wide { width: min(760px, calc(100vw - 32px)); }
dialog::backdrop { background: rgb(0 0 0 / 0.45); }
dialog h2 { font: 700 24px var(--serif); margin: 0 0 6px; }
dialog h3 { font: 600 12px var(--sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 22px 0 8px; padding-bottom: 6px; border-bottom: 1px solid var(--rule); }
.dialog-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 18px; align-items: center; margin-top: 16px; }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0; }
.error { color: var(--low); font-size: 13px; margin: 8px 0 0; }
textarea { width: 100%; background: var(--panel); border: 1px solid var(--rule); border-radius: 2px; padding: 10px; font: 16px/1.4 var(--serif); resize: vertical; }

.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: grid; grid-template-columns: 1fr auto; gap: 2px 16px; padding: 9px 0; border-bottom: 1px solid var(--rule); font-size: 14px; }
.rows .name { font-weight: 600; }
.rows .sub { grid-column: 1; color: var(--muted); font-size: 12.5px; }
.rows .act { grid-row: 1 / span 2; grid-column: 2; align-self: center; display: flex; gap: 12px; }
.choice { display: grid; gap: 8px; margin: 8px 0; }
.choice label { display: flex; gap: 8px; align-items: baseline; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 8px 18px; margin: 12px 0 0; }
.keys dt { font: 600 13px ui-monospace, SFMono-Regular, Menlo, monospace; }
.keys dd { margin: 0; color: var(--soft); }

@media (max-width: 640px) {
  .masthead { grid-template-columns: 1fr; text-align: center; gap: 6px; }
  .mast-actions { justify-content: center; }
  .stories { grid-template-columns: 1fr; }
  .controls { width: 100%; }
  .controls .primary { margin-left: auto; }
}
@media (prefers-reduced-motion: no-preference) {
  .card { transition: box-shadow 0.12s; }
}

/* Sign-in */
.signin { display: grid; gap: 12px; max-width: 340px; margin: 0 auto; text-align: left; }
.signin label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.signin input { width: 100%; background: var(--panel); border: 1px solid var(--rule); border-radius: 2px; padding: 10px; font: 16px/1.4 var(--serif); color: var(--ink); }
