/* Triage — no external fonts or assets: zero third-party requests. */

:root {
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --radius: 10px;
  --wrap: 1240px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0f14;
  --bg-elev: #11171f;
  --bg-hover: #161e28;
  --line: #222c38;
  --line-soft: #1a222c;
  --text: #e6edf3;
  --text-2: #a5b1be;
  --text-3: #6f7d8c;
  --accent: #3ddc97;
  --accent-ink: #06130d;
  --accent-soft: rgba(61, 220, 151, .12);
  --danger: #ff6b6b;
  --danger-soft: rgba(255, 107, 107, .13);
  --warn: #f5b942;
  --warn-soft: rgba(245, 185, 66, .14);
  --info: #6cb6ff;
  --info-soft: rgba(108, 182, 255, .13);
  --shadow: 0 10px 40px rgba(0, 0, 0, .5);
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f7f9;
  --bg-elev: #ffffff;
  --bg-hover: #f0f3f6;
  --line: #dde2e8;
  --line-soft: #e9edf1;
  --text: #121820;
  --text-2: #4a5563;
  --text-3: #7a8594;
  --accent: #0a8f5a;
  --accent-ink: #ffffff;
  --accent-soft: rgba(10, 143, 90, .10);
  --danger: #c92a2a;
  --danger-soft: rgba(201, 42, 42, .09);
  --warn: #a86600;
  --warn-soft: rgba(245, 159, 0, .13);
  --info: #1864ab;
  --info-soft: rgba(24, 100, 171, .09);
  --shadow: 0 10px 40px rgba(15, 23, 42, .14);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
svg { width: 18px; height: 18px; flex: none; }
button { font: inherit; color: inherit; }
kbd {
  font: 11px var(--mono); color: var(--text-3);
  border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px;
}
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 max(20px, env(safe-area-inset-right)) 0 max(20px, env(safe-area-inset-left)); }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.skip { position: absolute; left: -999px; top: 8px; z-index: 50; background: var(--accent); color: var(--accent-ink); padding: 8px 12px; border-radius: 6px; }
.skip:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.muted { color: var(--text-2); }

/* ---------- masthead ---------- */
.masthead {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top); /* clear the iPhone status bar / notch when launched from the home screen */
}
.masthead-row { display: flex; align-items: center; gap: 20px; padding-top: 14px; padding-bottom: 10px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; min-width: 0; }
.brand-mark { width: 30px; height: 30px; color: var(--accent); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-text strong { font-size: 18px; letter-spacing: -.01em; }
.tagline { font-size: 12.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.masthead-tools { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: 8px;
  padding: 0 10px; height: 36px; width: min(340px, 34vw); color: var(--text-3);
}
.search:focus-within { border-color: var(--accent); }
.search input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; color: var(--text); font: inherit; font-size: 14px; }
.search input::-webkit-search-cancel-button { filter: grayscale(1); }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 36px; padding: 0 12px; border-radius: 8px;
  background: var(--bg-elev); border: 1px solid var(--line); cursor: pointer;
  text-decoration: none; font-size: 14px; white-space: nowrap;
}
.btn:hover { background: var(--bg-hover); }
.btn.icon { width: 36px; padding: 0; justify-content: center; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.count { background: var(--accent); color: var(--accent-ink); font: 600 11px var(--mono); border-radius: 99px; padding: 1px 6px; }
[data-theme="dark"] .i-moon, [data-theme="light"] .i-sun { display: none; }

.tabs { display: flex; align-items: center; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 9px 12px 11px; text-decoration: none; color: var(--text-2); font-size: 14px; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.tab-count { font: 600 11px var(--mono); color: var(--danger); background: var(--danger-soft); border-radius: 99px; padding: 1px 6px; margin-left: 2px; }
.tab-count:empty { display: none; }
.updated { margin-left: auto; font: 12px var(--mono); color: var(--text-3); white-space: nowrap; padding-left: 12px; }
.updated::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-right: 7px; vertical-align: 1px; box-shadow: 0 0 0 3px var(--accent-soft); }
.updated.stale::before { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.updated:empty { display: none; }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 32px; padding-top: 22px; padding-bottom: 40px; }
.view-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }
.chip {
  border: 1px solid var(--line); background: var(--bg-elev); color: var(--text-2);
  border-radius: 99px; padding: 4px 11px; font-size: 13px; cursor: pointer;
}
.chip:hover { color: var(--text); border-color: var(--text-3); }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); cursor: pointer; padding-top: 4px; white-space: nowrap; }
.toggle input { accent-color: var(--accent); width: 15px; height: 15px; }

/* ---------- story list ---------- */
.day { margin: 22px 0 6px; font: 600 12px var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); display: flex; align-items: center; gap: 10px; }
.day::after { content: ""; flex: 1; height: 1px; background: var(--line-soft); }
.day:first-child { margin-top: 4px; }
.stories { list-style: none; margin: 0; padding: 0; }
.story {
  position: relative; display: grid; grid-template-columns: 66px minmax(0, 1fr); gap: 0 12px;
  padding: 13px 12px; margin: 0 -12px; border-radius: var(--radius);
}
.story:hover { background: var(--bg-hover); }
.story.mine::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 3px; background: var(--accent); }
.story time { font: 12px/1.9 var(--mono); color: var(--text-3); white-space: nowrap; }
.story h3 { margin: 0; font-size: 16px; line-height: 1.38; font-weight: 600; letter-spacing: -.005em; }
.story h3 a { text-decoration: none; }
.story h3 a:hover { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--text-3); }
.story h3 a::after { content: ""; position: absolute; inset: 0; } /* whole row clickable */
.story p { margin: 4px 0 0; color: var(--text-2); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 7px; font-size: 12.5px; color: var(--text-3); }
.meta .src { color: var(--text-2); font-weight: 500; }
.meta .sep { opacity: .5; }

.badge { display: inline-flex; align-items: center; gap: 4px; font: 600 11px/1 var(--mono); padding: 4px 7px; border-radius: 5px; white-space: nowrap; position: relative; z-index: 1; }
.badge.kev { background: var(--danger-soft); color: var(--danger); }
.badge.cve { background: var(--info-soft); color: var(--info); text-decoration: none; }
.badge.cve:hover { text-decoration: underline; }
.badge.hot { background: var(--warn-soft); color: var(--warn); }
.badge.topic { background: transparent; color: var(--text-3); border: 1px solid var(--line); font-weight: 500; }
.badge.sev-critical { background: var(--danger-soft); color: var(--danger); }
.badge.sev-high { background: var(--warn-soft); color: var(--warn); }
.badge.sev-medium { background: var(--info-soft); color: var(--info); }
.badge.sev-low, .badge.sev-unknown { background: var(--bg-hover); color: var(--text-3); }
.badge.ransom { background: var(--danger); color: #fff; }

.empty { padding: 40px 20px; text-align: center; color: var(--text-2); border: 1px dashed var(--line); border-radius: var(--radius); }
.loading { color: var(--text-3); font-family: var(--mono); font-size: 13px; }
.more { margin: 18px auto 0; display: flex; }

/* ---------- table-ish views ---------- */
.rows { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-elev); overflow: hidden; }
.row { position: relative; padding: 14px 16px; border-top: 1px solid var(--line-soft); }
.row:first-child { border-top: 0; }
.row:hover { background: var(--bg-hover); }
.row.mine { box-shadow: inset 3px 0 0 var(--accent); }
.row-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-id { font: 600 13px var(--mono); text-decoration: none; }
.row-id::after { content: ""; position: absolute; inset: 0; }
.row-id:hover { text-decoration: underline; }
.row-date { margin-left: auto; font: 12px var(--mono); color: var(--text-3); }
.row h3 { margin: 6px 0 2px; font-size: 15px; font-weight: 600; }
.row p { margin: 2px 0 0; color: var(--text-2); font-size: 14px; }
.row .meta { margin-top: 8px; }

.intro { margin: 0 0 16px; color: var(--text-2); font-size: 14px; max-width: 70ch; }
.intro strong { color: var(--text); }

.sources-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.source-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; background: var(--bg-elev); display: flex; flex-direction: column; gap: 3px; }
.source-card a { font-weight: 600; text-decoration: none; }
.source-card a:hover { text-decoration: underline; }
.source-card small { color: var(--text-3); font-size: 12.5px; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-right: 6px; }
.status-dot.bad { background: var(--danger); }
.feed-links { columns: 2 200px; padding-left: 18px; font-size: 14px; }
.feed-links li { margin: 3px 0; }
.view h2 { font-size: 15px; margin: 26px 0 10px; }

/* ---------- sidebar ---------- */
.secondary { display: flex; flex-direction: column; gap: 16px; }
.panel { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.panel > header { display: flex; align-items: baseline; justify-content: space-between; }
.panel h2 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-2); }
.panel > header a { font-size: 12.5px; color: var(--accent); text-decoration: none; }
.panel > header a:hover { text-decoration: underline; }
.panel-sub { margin: 4px 0 4px; font-size: 12.5px; color: var(--text-3); }
.panel-kev { border-top: 3px solid var(--danger); }
.panel-weekly p { margin: 6px 0 0; }
.panel-weekly .btn { margin-top: 4px; }
.mini { list-style: none; margin: 8px 0 0; padding: 0; }
.mini li { position: relative; padding: 9px 0; border-top: 1px solid var(--line-soft); font-size: 13.5px; line-height: 1.4; }
.mini li:first-child { border-top: 0; }
.mini a { text-decoration: none; font-weight: 500; }
.mini a::after { content: ""; position: absolute; inset: 0; }
.mini a:hover { text-decoration: underline; }
.mini .sub { display: flex; gap: 8px; align-items: center; margin-top: 3px; font-size: 12px; color: var(--text-3); }
.mini .mono { font-family: var(--mono); font-size: 12px; }
.mini li.mine a { color: var(--accent); }
.panel-about p { font-size: 13.5px; color: var(--text-2); margin: 8px 0 0; }
.panel-about h2 { margin-bottom: 2px; }
.feeds-line a { color: var(--accent); }

.footer { border-top: 1px solid var(--line); padding-top: 18px; padding-bottom: calc(40px + env(safe-area-inset-bottom)); font-size: 12.5px; color: var(--text-3); }
.footer a { color: var(--text-2); }

/* ---------- dialog ---------- */
dialog {
  border: 1px solid var(--line); border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 32px));
  background: var(--bg-elev); color: var(--text); box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(0, 0, 0, .55); backdrop-filter: blur(2px); }
.dialog-body { padding: 20px 22px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; }
.dialog-head h2 { margin: 0; font-size: 18px; }
.dialog-body > p { font-size: 14px; margin: 6px 0 16px; }
.stack-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; max-height: 50vh; overflow: auto; }
.stack-opt { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; cursor: pointer; font-size: 13.5px; }
.stack-opt:hover { background: var(--bg-hover); }
.stack-opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.stack-opt input { accent-color: var(--accent); }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* ---------- top stories + sorting ---------- */
.top-strip { margin-bottom: 26px; }
.top-strip .day { margin-top: 4px; }
.top-grid { list-style: none; margin: 10px 0 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.top-card { position: relative; background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); padding: 13px 15px; display: flex; flex-direction: column; gap: 6px; }
.top-card:hover { border-color: var(--text-3); }
.top-card.lead { grid-column: 1 / -1; border-left: 3px solid var(--accent); }
.top-card.lead h3 { font-size: 18px; }
.top-card.mine { box-shadow: inset 0 0 0 1px var(--accent); }
.top-card h3 { margin: 0; font-size: 15px; line-height: 1.38; font-weight: 600; }
.top-card h3 a { text-decoration: none; }
.top-card h3 a::after { content: ""; position: absolute; inset: 0; }
.top-card h3 a:hover { text-decoration: underline; text-underline-offset: 3px; }
.top-card p { margin: 0; color: var(--text-2); font-size: 14px; }
.top-card .meta { margin-top: auto; }
.top-flags { display: flex; gap: 6px; }
.top-flags:empty { display: none; }
.also { margin-top: 6px; font-size: 12.5px; color: var(--text-3); position: relative; z-index: 1; }
.also a { color: var(--text-2); }
.also a:hover { color: var(--accent); }
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 2px; flex-wrap: wrap; }
.list-label { font-size: 12.5px; color: var(--text-3); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--bg-elev); }
.seg button { border: 0; background: none; padding: 5px 12px; font-size: 13px; cursor: pointer; color: var(--text-2); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--text); font-weight: 600; }

/* ---------- digest pages ---------- */
.digest { max-width: 820px; padding-top: 26px; padding-bottom: 50px; }
.digest-kicker { font: 600 12px var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--accent); margin: 0; }
.digest h1 { font-size: 30px; letter-spacing: -.02em; line-height: 1.2; margin: 6px 0 8px; }
.digest-lede { color: var(--text-2); font-size: 16px; margin: 0 0 6px; }
.digest-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0 8px; }
.digest-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 22px 0 8px; }
.stat { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat strong { display: block; font: 600 24px/1.1 var(--mono); }
.stat span { font-size: 12.5px; color: var(--text-3); }
.digest h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-2); margin: 34px 0 10px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.digest ol.dlist { margin: 0; padding-left: 22px; }
.digest ol.dlist > li { margin: 0 0 14px; padding-left: 4px; }
.digest ol.dlist > li::marker { font: 600 13px var(--mono); color: var(--text-3); }
.digest .dtitle { font-weight: 600; text-decoration: none; }
.digest .dtitle:hover { text-decoration: underline; }
.digest .dmeta { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; font-size: 12.5px; color: var(--text-3); margin-top: 4px; }
.digest .dsum { color: var(--text-2); font-size: 14px; margin: 3px 0 0; }
.digest ul.compact { list-style: none; padding: 0; margin: 0; }
.digest ul.compact li { padding: 8px 0; border-top: 1px solid var(--line-soft); font-size: 14px; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.digest ul.compact li:first-child { border-top: 0; }
.digest .mono { font-family: var(--mono); font-size: 13px; }
.digest .weeks { list-style: none; padding: 0; margin: 18px 0 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-elev); }
.digest .weeks li { border-top: 1px solid var(--line-soft); }
.digest .weeks li:first-child { border-top: 0; }
.digest .weeks a { display: flex; justify-content: space-between; gap: 12px; padding: 13px 16px; text-decoration: none; }
.digest .weeks a:hover { background: var(--bg-hover); }
.digest .weeks small { color: var(--text-3); font-family: var(--mono); }
.digest-nav { display: flex; justify-content: space-between; margin-top: 40px; font-size: 14px; }
.digest-nav a { color: var(--accent); text-decoration: none; }
@media (max-width: 720px) {
  .top-grid { grid-template-columns: 1fr; }
  .digest-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .digest h1 { font-size: 24px; }
}

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .secondary { display: grid; grid-template-columns: 1fr 1fr; }
  .panel-about { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  .masthead-row { flex-wrap: wrap; gap: 10px; }
  .masthead-tools { width: 100%; }
  .search { flex: 1; width: auto; min-width: 0; }
  .search kbd { display: none; }
  #stack-btn span:not(.count) { display: none; }
  .tagline { display: none; }
  .updated { display: none; }
  .secondary { grid-template-columns: 1fr; }
  .story { grid-template-columns: 1fr; }
  .story time { line-height: 1.4; margin-bottom: 2px; }
}
@media (prefers-reduced-motion: no-preference) {
  .story, .row, .chip, .btn { transition: background-color .12s, border-color .12s, color .12s; }
}

/* Home-screen app on iPhone: the status bar text is always white with the
   black-translucent style, so keep a dark strip behind it in light theme too. */
@media (display-mode: standalone) {
  .masthead::before {
    content: ""; position: absolute; left: 0; right: 0; top: 0;
    height: env(safe-area-inset-top); background: #0b0f14;
  }
}
