/*
 * diysocial - dark theme.
 * Palette from the PacketViper dark-mode brand kit (GitHub-dimmed derived,
 * matching the Zero dashboard). Semantic colors are a dark tint background with
 * saturated text, never a light fill on dark.
 */

:root {
  --bg: #0d1117;
  --panel: #161b22;
  --header: #1c2129;
  --hover: #1c2129;
  --input: #0d1117;
  --border: #30363d;
  --border-lt: #21262d;
  --text: #c9d1d9;
  --text-hi: #e6edf3;
  --text-muted: #8b949e;
  --text-dim: #6e7681;
  --accent: #58a6ff;
  --accent-hover: #79c0ff;
  --primary: #1f6feb;

  --ok-bg: #12261a;
  --ok-fg: #56d364;
  --info-bg: #0d2436;
  --info-fg: #58a6ff;
  --warn-bg: #2b2410;
  --warn-fg: #e3b341;
  --danger-bg: #2a1416;
  --danger-fg: #f0857d;
  --purple-bg: #1e1830;
  --purple-fg: #b392f0;
  --neutral-bg: #1c2129;
  --neutral-fg: #8b949e;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

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

h1, h2, h3 { color: var(--text-hi); font-weight: 600; line-height: 1.25; }
h1 { font-size: 20px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 24px 0 10px; }

code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* --- layout --- */
.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  height: 52px;
}
.brand { color: var(--text-hi); font-weight: 600; font-size: 15px; letter-spacing: .2px;
  display: inline-flex; align-items: center; }
.brand span { color: var(--accent); }
/* The wordmark is an image now. height is set on the tag so the row does not jump before
   the PNG loads; width auto keeps the aspect ratio whatever the source dimensions are. */
.brand img { display: block; height: 26px; width: auto; }
.topbar nav { display: flex; gap: 4px; margin-left: 8px; }
.topbar nav a {
  color: var(--text-muted);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
}
.topbar nav a:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.topbar nav a.active { background: var(--bg); color: var(--accent); }
.topbar .spacer { flex: 1; }
.topbar .whoami { color: var(--text-muted); font-size: 12px; }

main { max-width: 1180px; margin: 0 auto; padding: 22px 20px 60px; }

/* --- panels --- */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 18px;
  margin-bottom: 16px;
}
.panel > h2:first-child { margin-top: 0; }
.panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  background: var(--header);
  margin: -16px -18px 14px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  border-radius: 8px 8px 0 0;
  color: var(--text-hi);
  font-weight: 600;
}

.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

.tile { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; }
.tile .label { color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: .6px; }
.tile .value { color: var(--text-hi); font-size: 26px; font-weight: 600; margin-top: 4px; }
.tile .sub { color: var(--text-dim); font-size: 12px; }

/* --- badges --- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--neutral-bg);
  color: var(--neutral-fg);
}
.badge.ok { background: var(--ok-bg); color: var(--ok-fg); }
.badge.info { background: var(--info-bg); color: var(--info-fg); }
.badge.warn { background: var(--warn-bg); color: var(--warn-fg); }
.badge.danger { background: var(--danger-bg); color: var(--danger-fg); }
.badge.purple { background: var(--purple-bg); color: var(--purple-fg); }

/* --- forms --- */
label { display: block; color: var(--text-muted); font-size: 12px; margin-bottom: 5px; }
input, select, textarea {
  width: 100%;
  background: var(--input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 14px;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(31, 111, 235, .3);
}
input::placeholder, textarea::placeholder { color: #5a626e; }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--primary); }
.field { margin-bottom: 14px; }

.btn {
  display: inline-block;
  background: #21262d;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
}
.btn:hover { background: var(--border); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: #388bfd; }
.btn-success { background: #3fb950; border-color: #3fb950; color: #06210c; }
.btn-danger { background: #d9534f; border-color: #d9534f; color: #fff; }
.btn:disabled, .btn[disabled] { opacity: .5; cursor: not-allowed; }
/* `.btn { display: inline-block }` above is an author-stylesheet rule, so it beats
   the browser's own `[hidden] { display: none }` rule regardless of selector
   specificity -- author-normal always outranks user-agent-normal in the cascade.
   That silently defeated `hidden` on any .btn, which is exactly the bug behind the
   "always-blue Open the draft" button in the writing-progress modal: it rendered
   visible and clickable, with whatever href it last held, for the entire pipeline
   run instead of only once the draft was actually finished. */
.btn[hidden] { display: none; }

/* --- tables: style CELLS, not just rows (bootstrap sets td bg) --- */
table { width: 100%; border-collapse: collapse; }
thead th {
  background: var(--header);
  color: var(--text-muted);
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
tbody td {
  background: transparent;
  color: var(--text);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-lt);
}
tbody tr:hover td { background: var(--hover); }

/* --- alerts --- */
.alert {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--neutral-fg);
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 12px;
  color: var(--text);
}
.alert-success { border-left-color: var(--ok-fg); }
.alert-info { border-left-color: var(--info-fg); }
.alert-warning { border-left-color: var(--warn-fg); }
.alert-danger { border-left-color: var(--danger-fg); }

/* --- login --- */
.login-wrap { max-width: 340px; margin: 12vh auto; }
.login-wrap .brand { display: block; text-align: center; font-size: 22px; margin-bottom: 20px; }
.login-wrap .brand img { display: inline-block; height: auto; max-width: 100%; }

.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }
.center { text-align: center; }

/* --- scrollbars --- */
* { scrollbar-width: thin; scrollbar-color: var(--border) var(--bg); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #484f58; }

/* ============================================================ left nav shell */

body.has-nav { padding-top: 52px; }
.topbar { position: fixed; top: 0; left: 0; right: 0; z-index: 20; }

.sidenav {
  position: fixed;
  top: 52px;
  bottom: 0;
  left: 0;
  width: 208px;
  overflow-y: auto;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 14px 0 40px;
}

.nav-group { margin-bottom: 20px; }

.nav-heading {
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .8px;
  padding: 0 18px 6px;
}

.sidenav a {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text-muted);
  padding: 7px 18px;
  font-size: 13.5px;
  border-left: 2px solid transparent;
}
.sidenav a:hover {
  background: var(--hover);
  color: var(--text);
  text-decoration: none;
}
.sidenav a.active {
  background: var(--bg);
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 600;
}

.nav-ico {
  width: 15px;
  text-align: center;
  font-size: 13px;
  opacity: .8;
}

.nav-count {
  margin-left: auto;
  background: var(--primary);
  color: #fff;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  padding: 1px 7px;
  min-width: 20px;
  text-align: center;
}
.nav-count.warn { background: var(--warn-bg); color: var(--warn-fg); }

/* Unconfigured-state marker: the Connectors dot when no account is linked. */
.nav-dot {
  margin-left: auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warn-fg);
}

main.with-nav {
  margin-left: 208px;
  max-width: 1080px;
  padding: 22px 26px 60px;
}

@media (max-width: 860px) {
  .sidenav {
    position: static;
    width: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
  }
  .sidenav a { border-left: 0; border-bottom: 2px solid transparent; }
  .sidenav a.active { border-left: 0; }
  main.with-nav { margin-left: 0; padding: 18px 16px 50px; }
  body.has-nav { padding-top: 52px; }
}

/* ------------------------------------------------------------- page headers */
.page-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.page-head h1 { margin: 0 0 3px; }
.page-head .lede { color: var(--text-muted); font-size: 13px; margin: 0; max-width: 640px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-shrink: 0; }

/* --------------------------------------------------------------- feed rows */
.feed-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border-lt);
}
.feed-row:last-child { border-bottom: 0; }
.feed-row .toggle { padding-top: 2px; }
.feed-row .meta { flex: 1; min-width: 0; }
.feed-row .name { color: var(--text-hi); font-weight: 600; font-size: 13.5px; }
.feed-row .url {
  color: var(--text-dim);
  font-size: 11.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  word-break: break-all;
}
.feed-row .row-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.feed-row.is-off .name, .feed-row.is-off .url { opacity: .45; }

.chips { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 4px; }

/* --------------------------------------------------------- role assignment */
.role-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  background: var(--bg);
  margin-bottom: 10px;
}
.role-card h3 { margin: 0 0 2px; font-size: 14px; }
.role-card .desc { color: var(--text-muted); font-size: 12px; margin: 0 0 10px; }
.role-card .assign { display: flex; gap: 8px; align-items: center; }
.role-card select { flex: 1; }

/* ------------------------------------------------------------- instructions */
.steps { counter-reset: step; list-style: none; padding: 0; margin: 0; }
.steps > li {
  counter-increment: step;
  position: relative;
  padding: 0 0 16px 34px;
  border-left: 1px solid var(--border);
  margin-left: 11px;
}
.steps > li:last-child { border-left-color: transparent; padding-bottom: 0; }
.steps > li::before {
  content: counter(step);
  position: absolute;
  left: -11px;
  top: -2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}
.steps strong { color: var(--text-hi); }
.steps code, .copyable {
  background: var(--input);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 12px;
  color: var(--accent);
}
.copy-field { display: flex; gap: 6px; align-items: center; margin: 6px 0; }
.copy-field input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

details.helper { margin-top: 10px; }
details.helper > summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 13px;
  padding: 6px 0;
}
details.helper > summary:hover { color: var(--accent-hover); }
details.helper[open] > summary { margin-bottom: 8px; }

.empty {
  text-align: center;
  padding: 34px 20px;
  color: var(--text-muted);
}
.empty .big { font-size: 15px; color: var(--text); margin-bottom: 6px; }

.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { margin-bottom: 0; flex: 1; min-width: 150px; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 760px) { .split { grid-template-columns: 1fr; } }

/* Post body: preserve the author's line breaks exactly, since paragraph shape
   is part of the voice and LinkedIn renders it verbatim. */
.post-body {
  white-space: pre-wrap;
  word-wrap: break-word;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px 16px;
  margin: 0 0 12px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
}

/* ================================================================ tab strip */
/* Tabs are real links with a ?tab= query param, not JS-only state, so a tab is
   linkable, survives a reload, and works if a form POST redirects back. */

.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}
.tabs a {
  color: var(--text-muted);
  padding: 9px 16px;
  font-size: 13.5px;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 7px 7px 0 0;
  margin-bottom: -1px;
  display: flex;
  align-items: center;
  gap: 7px;
}
.tabs a:hover {
  color: var(--text);
  background: var(--hover);
  text-decoration: none;
}
.tabs a.active {
  color: var(--accent);
  background: var(--panel);
  border-color: var(--border);
  border-bottom: 1px solid var(--panel);
  font-weight: 600;
}
.tabs .tab-count {
  background: var(--neutral-bg);
  color: var(--neutral-fg);
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  padding: 1px 6px;
}
.tabs a.active .tab-count { background: var(--info-bg); color: var(--info-fg); }
.tabs .tab-warn { color: var(--warn-fg); font-size: 15px; line-height: 1; }

@media (max-width: 700px) {
  .tabs { overflow-x: auto; }
  .tabs a { white-space: nowrap; }
}

/* ========================================================== news reader ==== */
/* The page itself does not scroll. The story list and the trending rail each
   scroll independently, so the filters and trending stay put while you read. */

.page-head.compact { margin-bottom: 12px; padding-bottom: 10px; }

.filter-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.filter-bar input[type="search"] { flex: 1 1 240px; min-width: 180px; }
.filter-bar select { flex: 0 1 190px; width: auto; }

.active-filters { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.chip-x {
  margin-left: 5px;
  color: inherit;
  opacity: .7;
  font-weight: 700;
  text-decoration: none;
}
.chip-x:hover { opacity: 1; text-decoration: none; }

.news-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 14px;
  /* Fill the viewport below the header and filters rather than growing the page.
     The two columns then own their own scrolling. */
  height: calc(100vh - 210px);
  min-height: 380px;
}

/* Left column: stories on top, recommendations beneath, each scrolling on its
   own so neither pushes the other off screen. */
.news-left {
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: 12px;
  min-height: 0;   /* lets a grid child actually shrink and scroll */
  overflow: hidden;
}

.news-main,
.news-recs {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin-bottom: 0;
  padding: 0;
  min-height: 0;
}

.news-recs .panel-header.sticky {
  margin: 0;
  border-radius: 8px 8px 0 0;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.news-main .panel-header.sticky {
  margin: 0;
  border-radius: 8px 8px 0 0;
  flex-shrink: 0;
}
.news-scroll {
  overflow-y: auto;
  flex: 1;
  padding: 4px 18px 10px;
}

.news-rail {
  overflow-y: auto;
  padding-right: 2px;
}
.news-rail .panel { margin-bottom: 12px; }
.news-rail .panel:last-child { margin-bottom: 0; }

/* ------------------------------------------------------------- story rows */
.story {
  padding: 11px 0;
  border-bottom: 1px solid var(--border-lt);
}
.story:last-child { border-bottom: 0; }
.story-title {
  color: var(--text-hi);
  font-weight: 600;
  font-size: 13.5px;
  line-height: 1.4;
}
.story-title:hover { color: var(--accent); }
.story-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 4px;
  font-size: 11.5px;
  flex-wrap: wrap;
}
.story-source { color: var(--text-muted); }
.story-source:hover { color: var(--accent); }
.story-summary {
  color: var(--text-muted);
  font-size: 12.5px;
  line-height: 1.5;
  margin-top: 5px;
}

/* ------------------------------------------------------------ trending rail */
.rail-label {
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .7px;
  margin: 12px 0 7px;
}
.rail-label:first-child { margin-top: 0; }

.topic-cloud { display: flex; flex-wrap: wrap; gap: 5px; }

.topic {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--neutral-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11.5px;
  line-height: 1.4;
}
.topic:hover {
  background: var(--hover);
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}
/* Rising against its own baseline, which is what makes it news rather than
   background. */
.topic.rising { border-color: #2d5f3a; background: var(--ok-bg); color: var(--ok-fg); }
.topic.is-new { border-color: #3a4a6b; background: var(--info-bg); color: var(--info-fg); }
.topic.vendor { background: var(--purple-bg); color: var(--purple-fg); border-color: #3d2f5c; }
.topic.cve {
  background: var(--danger-bg);
  color: var(--danger-fg);
  border-color: #5c2b2b;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
}
.topic-n { opacity: .65; font-size: 10.5px; }
.topic-arrow { font-size: 10px; opacity: .9; }

.rail-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-lt);
  font-size: 12.5px;
  color: var(--text-muted);
}
.rail-row:last-child { border-bottom: 0; }
.rail-row:hover { color: var(--accent); text-decoration: none; }
.rail-row-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------------------------------------------------------------- sparkline */
.spark {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 62px;
}
.spark-bar {
  flex: 1;
  background: var(--primary);
  border-radius: 2px 2px 0 0;
  min-height: 2px;
  cursor: pointer;
  transition: background .12s;
  position: relative;
}
.spark-bar:hover { background: var(--accent-hover); }
.spark-bar.is-today { background: var(--ok-fg); }
.spark-bar.is-active { background: var(--warn-fg); }

@media (max-width: 1000px) {
  .news-layout {
    grid-template-columns: 1fr;
    height: auto;
  }
  .news-main { max-height: 60vh; }
  .news-rail { overflow: visible; }
}

/* ------------------------------------------------------- recommendations */
.rec {
  padding: 11px 0;
  border-bottom: 1px solid var(--border-lt);
}
.rec:last-child { border-bottom: 0; }
.rec.is-going { opacity: .35; transition: opacity .2s; }

.rec-head { display: flex; align-items: flex-start; gap: 8px; }
.rec-score { flex-shrink: 0; margin-top: 1px; }
.rec-title {
  color: var(--text-hi);
  font-weight: 600;
  font-size: 13.5px;
  line-height: 1.4;
  flex: 1;
}
.rec-title:hover { color: var(--accent); }
.rec-x {
  background: none;
  border: 0;
  color: var(--text-dim);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  flex-shrink: 0;
}
.rec-x:hover { color: var(--danger-fg); }

.rec-angle, .rec-why, .rec-scope {
  font-size: 12.5px;
  line-height: 1.5;
  margin-top: 5px;
  padding-left: 2px;
}
.rec-angle { color: var(--text); }
.rec-why { color: var(--text-muted); }
.rec-scope { color: var(--warn-fg); }

.rec-label {
  display: inline-block;
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .6px;
  margin-right: 5px;
}
.rec-label.warn-label { color: var(--warn-fg); opacity: .8; }

.rec-meta {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 7px;
  font-size: 11.5px;
  flex-wrap: wrap;
}

@media (max-width: 1000px) {
  .news-left { grid-template-rows: auto auto; overflow: visible; }
  .news-main, .news-recs { max-height: 55vh; }
}

/* Search expansion explainer. Silent widening is confusing: the user typed two
   words and got eighty results, so show what was actually searched. */
.search-explain {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  padding: 7px 12px;
  margin-bottom: 10px;
  font-size: 12px;
}
.search-explain .rec-label { margin-right: 0; }
.inline-details { display: inline; }
.inline-details > summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 11.5px;
  display: inline;
  list-style: none;
}
.inline-details > summary::-webkit-details-marker { display: none; }
.inline-details > summary::before { content: '\2026 '; }
.inline-details > summary:hover { color: var(--accent-hover); }

/* ================================================================= modals == */
/* Uses the native <dialog> element: it gets focus trapping, Escape-to-close and
   the top layer for free, which a hand-rolled div overlay does not. */

dialog.modal {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0;
  max-width: 720px;
  width: calc(100% - 32px);
  max-height: 86vh;
  box-shadow: 0 16px 48px rgba(1, 4, 9, .75);
}
dialog.modal::backdrop { background: rgba(1, 4, 9, .72); }

.modal-head {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--header);
  border-bottom: 1px solid var(--border);
  border-radius: 10px 10px 0 0;
  padding: 12px 18px;
  position: sticky;
  top: 0;
}
.modal-head h2 { margin: 0; font-size: 15px; }
.modal-close {
  margin-left: auto;
  background: none;
  border: 0;
  color: var(--text-muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.modal-close:hover { color: var(--text-hi); }

.modal-body {
  padding: 16px 18px;
  overflow-y: auto;
  max-height: calc(86vh - 108px);
}
.modal-foot {
  display: flex;
  gap: 8px;
  align-items: center;
  border-top: 1px solid var(--border);
  padding: 12px 18px;
  background: var(--panel);
  border-radius: 0 0 10px 10px;
  position: sticky;
  bottom: 0;
}
.modal-foot .spacer { flex: 1; }

/* A row of related actions under a panel's content. */
.panel-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border-lt);
}

/* Write-a-post affordance. Hidden until hover on a story row, so 258 rows do not
   read as 258 buttons, but always visible on a recommendation, where writing is
   the whole point of the card. */
.story-actions {
  margin-top: 7px;
  opacity: 0;
  transition: opacity .12s;
}
.story:hover .story-actions,
.story-actions:focus-within { opacity: 1; }

.btn-write {
  padding: 3px 10px;
  font-size: 12px;
  background: var(--info-bg);
  color: var(--info-fg);
  border-color: #2c4a6b;
}
.btn-write:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Indeterminate progress. The work takes 30 to 60 seconds and a real percentage
   would be a lie, so this shows motion rather than a fake estimate. */
.writing-bar {
  height: 4px;
  background: var(--border-lt);
  border-radius: 2px;
  overflow: hidden;
  margin: 14px 0 10px;
}
.writing-fill {
  height: 100%;
  width: 35%;
  background: var(--primary);
  border-radius: 2px;
  animation: writing-slide 1.4s ease-in-out infinite;
}
@keyframes writing-slide {
  0%   { margin-left: -35%; }
  100% { margin-left: 100%; }
}
.writing-bar.is-done .writing-fill {
  animation: none;
  width: 100%;
  margin-left: 0;
  background: var(--ok-fg);
}
.writing-bar.is-error .writing-fill {
  animation: none;
  width: 100%;
  margin-left: 0;
  background: var(--danger-fg);
}

/* ============================================================== post cards == */
/* Compact by design: the previous layout gave every draft a full panel and three
   posts filled the screen. The body is clamped so the list stays scannable, with an
   expand for the whole thing. */

.post-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px 14px;
  margin-bottom: 10px;
}
.post-card.is-liked { border-left: 3px solid var(--ok-fg); }
.post-card.is-disliked { border-left: 3px solid var(--danger-fg); opacity: .72; }
.post-card.is-going { opacity: .3; transition: opacity .2s; }

/* Unmissable, not a corner badge -- see the 2026-08-28 incident note in posts.html.
   A full-width strip above everything else on the card, in the loudest color this
   theme has, so it reads before any button does. */
.post-card.is-test-draft { border: 2px solid var(--danger-fg); }
.test-draft-banner {
  background: var(--danger-bg);
  color: var(--danger-fg);
  font-weight: 700;
  font-size: 12.5px;
  letter-spacing: .02em;
  text-transform: uppercase;
  padding: 6px 10px;
  margin: -11px -14px 9px -14px;
  border-radius: 8px 8px 0 0;
  border-bottom: 2px solid var(--danger-fg);
}

.post-card-head {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  font-size: 11.5px;
  margin-bottom: 7px;
}

.post-origin { font-size: 12px; margin-bottom: 7px; }
.post-origin a { color: var(--text-muted); }
.post-origin a:hover { color: var(--accent); }

.post-preview {
  white-space: pre-wrap;
  word-wrap: break-word;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border-lt);
  border-radius: 6px;
  padding: 10px 12px;
  /* Four lines is enough to judge the opening, which is what matters most. */
  max-height: 84px;
  overflow: hidden;
  position: relative;
}
.post-preview.is-open { max-height: none; }
.post-preview:not(.is-open)::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 30px;
  background: linear-gradient(transparent, var(--bg));
}
.post-expand {
  background: none;
  border: 0;
  color: var(--accent);
  font-size: 11.5px;
  cursor: pointer;
  padding: 4px 0 0;
}
.post-expand:hover { color: var(--accent-hover); }

.post-card-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px solid var(--border-lt);
}
.post-card-foot .spacer { flex: 1; }
.post-card-foot .btn { padding: 4px 10px; font-size: 12px; }

.feedback-group { display: flex; gap: 4px; align-items: center; }
.btn-thumb { padding: 4px 10px; font-size: 12px; }
.btn-thumb.is-on {
  background: var(--ok-bg);
  color: var(--ok-fg);
  border-color: #2d5f3a;
}
.btn-thumb.is-on-bad {
  background: var(--danger-bg);
  color: var(--danger-fg);
  border-color: #5c2b2b;
}

.bulk-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--header);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 14px;
  margin-bottom: 10px;
  position: sticky;
  top: 52px;
  z-index: 5;
}
.bulk-bar .spacer { flex: 1; }
.bulk-pick { display: inline-flex; margin: 0; }

/* ---------------------------------------------------------- side by side ---- */
.compare-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 14px;
  align-items: start;
}
.compare-col .post-preview { max-height: none; }
.compare-col .post-preview::after { display: none; }

/* ------------------------------------------------------------ sources modal */
.src-group { margin-bottom: 16px; }
.src-group:last-child { margin-bottom: 0; }
.src-head {
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .7px;
  margin-bottom: 6px;
}
.src-item {
  padding: 7px 0;
  border-bottom: 1px solid var(--border-lt);
  font-size: 12.5px;
}
.src-item:last-child { border-bottom: 0; }
.src-item .src-url {
  font-size: 11px;
  color: var(--text-dim);
  word-break: break-all;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* Content repo paths: long, and the whole point is being able to read them. */
.repo-path {
  display: inline-block;
  background: var(--input);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 11.5px;
  color: var(--accent);
  word-break: break-all;
  max-width: 100%;
}

/* ---------------------------------------------------- content repos: tabs/items */
.tabstrip { display:flex; gap:2px; border-bottom:1px solid var(--border);
  margin:0 0 14px; flex-wrap:wrap; }
.tabstrip .tab { padding:9px 16px; color:var(--text-dim); text-decoration:none;
  border:1px solid transparent; border-bottom:none; border-radius:6px 6px 0 0;
  font-size:14px; margin-bottom:-1px; }
.tabstrip .tab:hover { color:var(--text); background:var(--panel-hi); }
.tabstrip .tab.active { color:var(--text); background:var(--panel);
  border-color:var(--border); border-bottom:1px solid var(--panel); font-weight:600; }
.tab-count { display:inline-block; margin-left:6px; padding:1px 7px; font-size:11px;
  border-radius:9px; background:var(--panel-hi); color:var(--text-dim); }
.tabstrip .tab.active .tab-count { background:var(--primary); color:#fff; }
.tab-blurb { max-width:74ch; margin:0 0 16px; }

.repo-panel { margin-bottom:16px; }
.repo-head { display:flex; align-items:flex-start; gap:12px; flex-wrap:wrap; }
.repo-head h2 { margin:0; font-size:16px; }
.repo-live { margin:10px 0 0; }
.repo-path { font-family:ui-monospace,SFMono-Regular,Menlo,monospace; font-size:12px;
  background:var(--bg); border:1px solid var(--border); border-radius:5px;
  padding:6px 9px; color:var(--text-dim); word-break:break-all; }
.repo-instructions { margin-top:14px; }
.repo-instructions textarea { width:100%; font-size:13px; }
.readonly-block { background:var(--bg); border:1px solid var(--border);
  border-radius:5px; padding:9px 11px; margin:0; font-size:13px;
  color:var(--text-dim); white-space:pre-wrap; }
.row-actions { display:flex; align-items:center; gap:9px; margin-top:8px;
  flex-wrap:wrap; }
.save-note.is-ok { color:var(--ok-fg); }
.save-note.is-bad, .dim.is-bad { color:var(--danger-fg); }
.dim.is-ok { color:var(--ok-fg); }

.switch { display:inline-flex; align-items:center; gap:7px; font-size:13px;
  color:var(--text-dim); cursor:pointer; white-space:nowrap; }
.switch input { cursor:pointer; }
.grant-row { display:flex; padding:7px 0; border-bottom:1px solid var(--border); }

.dropzone { margin-top:12px; border:2px dashed var(--border); border-radius:8px;
  padding:18px; text-align:center; background:var(--bg); }
.dropzone.is-over { border-color:var(--accent); background:var(--panel-hi); }
.dropzone p { margin:0; font-size:13px; }
.upload-log { margin-top:10px; text-align:left; }
.upload-line { font-size:12px; padding:4px 0; border-top:1px solid var(--border);
  color:var(--text-dim); }
.upload-line.is-ok strong { color:var(--ok-fg); }
.upload-line.is-bad strong { color:var(--danger-fg); }
/* A rejection has to READ as one. Styled the same as a success it was mistaken for the
   caption below the field, so an add that failed looked like nothing had happened. */
.upload-line.is-bad { border-top:0; border-left:3px solid var(--danger-fg);
  background:var(--danger-bg); color:var(--danger-fg); padding:8px 10px;
  border-radius:4px; margin-top:8px; }
.upload-line.is-bad span { color:var(--danger-fg); }

.add-row { display:flex; gap:8px; margin-top:12px; }
.add-row input { flex:1; }

.item-table { margin-top:14px; }
.item-table td { vertical-align:top; }
.item-name { color:var(--text); font-size:13px; }
.item-excerpt, .item-url { font-size:12px; display:block; margin-top:2px;
  word-break:break-all; }
.item-url { color:var(--accent); text-decoration:none; }
.item-error { font-size:12px; color:var(--danger-fg); margin-top:3px;
  max-width:62ch; }
.item-warn { font-size:12px; color:var(--warn-text); margin-top:3px; max-width:62ch; }
.item-actions { white-space:nowrap; text-align:right; }
.row-bad td { background:rgba(248,81,73,.05); }
.text-danger { color:var(--danger-fg); }
.btn-small { padding:3px 9px; font-size:12px; }

/* ------------------------------------------------- News: per-tab layouts (v2)
 * The analytics rail used to render on all three tabs. Recommended and Stories carried
 * panels they had no use for, and Analytics was that same narrow rail stacked vertically
 * with the rest of the page empty. Each tab now owns its own layout.
 */
.news-head { align-items:flex-start; }
.news-head-actions { display:flex; align-items:center; gap:10px; flex-shrink:0;
  padding-top:4px; }

/* Full-width single column that reaches the bottom of the viewport, so the list is the
 * page rather than a short box floating in it. The page itself does not scroll. */
.news-single { display:flex; flex-direction:column;
  height:calc(100vh - 260px); min-height:340px; }
.news-single > .panel { flex:1; display:flex; flex-direction:column; overflow:hidden;
  margin:0; }
.news-single .panel-header { flex-shrink:0; }
/* Only the list scrolls. */
.news-single .news-list, .news-single .rec-list,
.news-single .panel > div:last-child { overflow-y:auto; }

/* Recommended: posting stats, not feed volume. */
.stat-tile { background:var(--panel); border:1px solid var(--border);
  border-radius:8px; padding:12px 14px; }
.stat-label { font-size:11.5px; text-transform:uppercase; letter-spacing:.04em;
  color:var(--text-dim); }
.stat-value { font-size:30px; line-height:1.1; font-weight:600; color:var(--text);
  margin:4px 0 2px; font-variant-numeric:tabular-nums; }
.stat-note { font-size:12px; color:var(--text-dim); }
.stat-note a { color:var(--accent); text-decoration:none; }

/* Five-day outlook: a tiny column chart, not a number. */
.outlook { display:flex; align-items:flex-end; gap:6px; height:46px; margin:6px 0 4px; }
.outlook-day { flex:1; display:flex; flex-direction:column; align-items:center;
  justify-content:flex-end; height:100%; }
.outlook-bar { width:100%; background:var(--panel-hi); border-radius:3px 3px 0 0; }
.outlook-day.has-posts .outlook-bar { background:var(--primary); }
.outlook-dow { font-size:10px; color:var(--text-dim); margin-top:3px; }

/* Analytics and Recommended share one shape: a tall primary panel on the left, a stacked
 * rail on the right, and full-width tables below.
 *
 * auto-fit was wrong for this data. It gives every panel an equal column, but Trending
 * has 14 rows and wants the height while CVEs need four lines, so the result was a short
 * panel beside a tall one with dead space under it. The columns are explicit now.
 */
/* Analytics and Recommended: a tall primary panel on the left, a stacked rail on the
 * right, full-width tables below.
 *
 * Two grid columns of unequal content ALWAYS leave dead space under the shorter one, and
 * chasing it with row spans made it worse: a span made each rail panel share a row with
 * the tall left panel, so the rail stretched; wrapping the rail in a flex column fixed
 * that but left the whole rail short next to a 14-row Trending panel, so the gap simply
 * moved to the bottom of the rail.
 *
 * The fix is to stop asking two columns to be the same height. The rail sits in its own
 * column and its LAST panel absorbs the remaining space, so the column ends flush with
 * the left panel instead of stopping early.
 */
.analytics-layout, .rec-layout {
  display:grid; grid-template-columns:minmax(0,1fr) 360px; gap:14px;
  align-items:stretch;
}
.analytics-layout > .panel, .rec-layout > .panel { margin:0; }

.analytics-layout .a-main { grid-column:1; grid-row:1; }
.analytics-layout .a-side { grid-column:2; grid-row:1;
  display:flex; flex-direction:column; gap:14px; min-height:0; }
.analytics-layout .a-side > .panel { margin:0; flex:0 0 auto; }
/* The rail's last panel grows into whatever height is left, so its bottom lines up with
 * the left panel instead of stopping short.
 *
 * This only works because the rail now holds ONE panel of real content. It previously
 * held three, including a whole panel for the CVE list — which on a typical day is a
 * single chip. Stretching a one-chip panel to fill 300px of slack just moves the empty
 * space inside the box, so the CVEs folded into Vendors and Story volume moved to a
 * full-width row where 14 columns actually belong. Fixing the layout meant changing what
 * was in it, not the grid rules. */
.analytics-layout .a-side > .panel:last-child { flex:1 1 auto; }
/* Vendor bars sit at the top of a stretched panel rather than being spread down it. */
.analytics-layout .a-side .bar-list { align-content:flex-start; }
.analytics-layout .a-wide { grid-column:1 / -1; }

/* Recommended: same shape. The list is the left column, the tiles stack on the right, and
 * the last tile takes the slack. */
.rec-layout { margin-bottom:14px; }
.rec-layout > .news-single { grid-column:1; grid-row:1; }
.rec-rail { grid-column:2; grid-row:1; display:flex; flex-direction:column; gap:12px; }
.rec-rail .stat-tile { margin:0; flex:0 0 auto; }
.rec-rail .stat-tile:last-child { flex:1 1 auto; }

@media (max-width:1150px) {
  .analytics-layout, .rec-layout { grid-template-columns:minmax(0,1fr); }
  .analytics-layout .a-main, .analytics-layout .a-side,
  .analytics-layout .a-wide, .rec-layout > .news-single, .rec-rail {
    grid-column:1; grid-row:auto;
  }
  .rec-rail, .analytics-layout .a-side { flex-direction:row; flex-wrap:wrap; }
  .analytics-layout .a-side > .panel,
  .analytics-layout .a-side > .panel:last-child { flex:1 1 300px; }
  .rec-rail .stat-tile, .rec-rail .stat-tile:last-child { flex:1 1 190px; }
}

/* Horizontal bars. A bar encodes magnitude in LENGTH, which is the thing a cloud of
 * same-size chips cannot show — that was the point of the tag cloud being wrong here.
 * One hue for every bar: the terms are nominal, so colouring them individually would
 * spend the identity channel re-encoding what length already says. */
.bar-list { display:flex; flex-direction:column; gap:6px; }
/* Four columns by default: term, track, count, delta.
 *
 * A row WITHOUT a delta must not keep the delta column reserved, or the track is squeezed
 * for nothing — that is what made the vendor bars in a 340px rail render as stubs while
 * the same data filled the bar in the wide panel. Rows declare their own shape.
 *
 * The term column is also narrower in a rail than in a full-width panel, because 150px of
 * a 312px panel is half the row spent on a label that is usually one short word. */
.bar-row { display:grid; grid-template-columns:minmax(80px,132px) 1fr 34px 52px;
  align-items:center; gap:8px; text-decoration:none; padding:2px 0; }
/* No delta cell in the markup: three columns, and the track takes the slack. */
.bar-row.no-delta { grid-template-columns:minmax(72px,110px) 1fr 30px; }
/* Inside a narrow rail, give the track as much room as possible. */
.a-rail .bar-row { grid-template-columns:minmax(64px,96px) 1fr 28px; gap:7px; }
.a-rail .bar-term { font-size:12.5px; }
.bar-row:not(.static):hover .bar-fill { filter:brightness(1.25); }
.bar-row:not(.static):hover .bar-term { color:var(--accent); }
.bar-term { font-size:13px; color:var(--text); overflow:hidden;
  text-overflow:ellipsis; white-space:nowrap; }
.bar-track { height:14px; background:var(--bg); border-radius:3px; overflow:hidden; }
/* 4px rounded data-end, square at the baseline, per the mark spec. */
.bar-fill { display:block; height:100%; background:var(--primary);
  border-radius:0 4px 4px 0; min-width:2px; }
.bar-fill.vendor { background:#8957e5; }
.bar-fill.is-new { background:#3fb950; }
.bar-n { font-size:12px; color:var(--text-dim); text-align:right;
  font-variant-numeric:tabular-nums; }
.bar-delta { font-size:11.5px; color:var(--text-dim); text-align:right;
  font-variant-numeric:tabular-nums; }
.bar-delta.up { color:var(--ok-fg); }
.bar-delta.down { color:var(--text-dim); }

/* Rising rows carry 14 days of shape between the count and the delta, so they declare a
 * fifth column. A percentage tells you a subject moved; only the shape tells you whether
 * it is still climbing or already peaked, and those are opposite decisions about whether
 * to write today. */
.bar-row.with-spark { grid-template-columns:minmax(80px,132px) 1fr 30px 48px 50px; }
.spark { display:flex; align-items:flex-end; gap:1px; height:16px; }
/* min-height keeps empty days as a visible baseline: a gap in the line and a day with no
 * stories look identical otherwise. */
.spark i { flex:1; background:var(--text-dim); min-height:1px; border-radius:1px 1px 0 0; }
.bar-row:hover .spark i { background:var(--accent); }
/* Cooling bars are drawn at full length and dimmed: the bar is what the subject USED to
 * be, and the number beside it is how much of that is gone. Sizing them by what is left
 * would draw a dead subject as a stub, which reads as "small story" rather than "over". */
.bar-fill.cooling { background:var(--text-dim); opacity:.45; }

/* Volume columns. */
.col-chart { display:flex; align-items:flex-end; gap:4px; height:110px; }
.col { flex:1; display:flex; align-items:flex-end; height:100%; text-decoration:none; }
.col-fill { width:100%; background:var(--primary); border-radius:3px 3px 0 0;
  min-height:3px; }
.col:hover .col-fill { filter:brightness(1.3); }
.chip-row { display:flex; flex-wrap:wrap; gap:6px; }

/* -------------------------------------------- Posted / Disliked: log + rating
 * A published post is a record you scan by date, so the list is compact and the body
 * loads in a modal. Rendering forty full posts makes a page nobody scrolls.
 */
.post-log td { vertical-align:top; }
.post-log-title { background:none; border:0; padding:0; text-align:left; cursor:pointer;
  color:var(--text); font-size:13px; font-family:inherit; line-height:1.45; }
.post-log-title:hover { color:var(--accent); }

.modal-wide { max-width:860px; width:92vw; }
.post-full { white-space:pre-wrap; font-size:14px; line-height:1.6; color:var(--text);
  background:var(--bg); border:1px solid var(--border); border-radius:6px;
  padding:14px 16px; max-height:38vh; overflow-y:auto; }

.rate-block { margin-top:16px; border-top:1px solid var(--border); padding-top:14px; }
.rate-head { display:flex; flex-direction:column; gap:3px; margin-bottom:10px; }
.rate-thumbs { display:flex; gap:8px; margin-bottom:12px; }

/* Two columns of axes: seven dimensions in one column is a scroll, and in three the
 * labels stop lining up with their choices. */
.rate-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(320px,1fr));
  gap:10px 18px; }
.rate-dim { display:flex; flex-direction:column; gap:5px; }
.rate-label { font-size:11.5px; text-transform:uppercase; letter-spacing:.04em;
  color:var(--text-dim); }
.rate-choices { display:flex; flex-wrap:wrap; gap:5px; }
.rate-chip { background:var(--bg); border:1px solid var(--border); color:var(--text-dim);
  border-radius:12px; padding:3px 10px; font-size:12px; cursor:pointer;
  font-family:inherit; }
.rate-chip:hover { border-color:var(--accent); color:var(--text); }
.rate-chip.is-on { background:var(--primary); border-color:var(--primary); color:#fff; }

/* Day-of-week picker in the user edit form. Reuses .rate-chip so a selectable chip looks
 * the same everywhere in the app rather than being a second visual language. */
.day-picker { display:flex; gap:5px; flex-wrap:wrap; }
.day-picker .rate-chip { min-width:44px; text-align:center; }

/* Row action buttons line up as a set. Without a shared min-width the labels ("Edit",
 * "Disable", "Delete") set their own widths and the column reads as ragged rather than as
 * three controls. */
.item-actions .btn-small,
td .btn-small { min-width:66px; text-align:center; }

/* Feed Repo catalogue: one line per feed. */
.repo-table td { vertical-align:top; }
.repo-table .item-name { font-size:13px; }
.repo-table .item-actions { white-space:nowrap; text-align:right; }

/* ------------------------------------------------- LinkedIn-style post preview
 * The post was rendered in a <pre> in a monospace font, which tells you nothing about how
 * it will actually read or where the line breaks fall — the thing you are judging when you
 * approve it.
 */
.li-preview { background:var(--panel); border:1px solid var(--border); border-radius:10px;
  padding:14px 16px; max-width:620px; }
.li-head { display:flex; align-items:center; gap:10px; margin-bottom:10px; }
.li-avatar { width:40px; height:40px; border-radius:50%; background:var(--primary);
  color:#fff; display:flex; align-items:center; justify-content:center;
  font-weight:600; font-size:16px; flex-shrink:0; }
.li-name { font-size:14px; font-weight:600; color:var(--text); }
.li-sub { font-size:12px; color:var(--text-dim); }
/* Same wrapping behaviour as the real feed: proportional font, generous line height, and
 * blank lines preserved. */
.li-body { font-size:14px; line-height:1.55; color:var(--text); white-space:pre-wrap;
  word-wrap:break-word; }
.li-tags { margin-top:10px; font-size:14px; color:var(--accent); }
.li-card { display:block; margin-top:12px; border:1px solid var(--border);
  border-radius:8px; padding:10px 12px; text-decoration:none; background:var(--bg); }
.li-card:hover { border-color:var(--accent); }
.li-card-domain { font-size:12px; color:var(--text-dim); text-transform:uppercase;
  letter-spacing:.03em; }
.li-card-note { font-size:12.5px; color:var(--text); margin-top:2px; }
.li-foot { margin-top:12px; padding-top:10px; border-top:1px solid var(--border);
  font-size:12px; }

/* Writing rules: a disabled rule stays legible but visibly inactive, rather than
 * disappearing — the operator needs to see what they switched off. */
.rules-table td { vertical-align:top; }
.rules-table tr.row-off td { opacity:.45; }
.rules-table tr.rule-note td { border-top:0; }

/* ---------------------------------------------------------------- AI usage page
 * The two-hue pair is validated for colour-vision deficiency against the panel
 * surface (protan/tritan dE ~30, normal 35.8), so input and output stay tellable
 * apart; each segment is also directly labelled, so colour is never the only cue. */
.chart-legend { display:flex; gap:16px; align-items:center; margin:0 0 12px;
  font-size:12px; color:var(--text-muted); }
.chart-legend .swatch { display:inline-block; width:9px; height:9px; border-radius:2px;
  margin-right:5px; vertical-align:baseline; }
.split-track { display:flex; height:14px; background:var(--bg); border-radius:3px;
  overflow:hidden; min-width:120px; }
.split-in  { background:#1f6feb; border-radius:3px 0 0 3px; }
/* 2px surface-coloured gap rather than a border, so the two fills never touch. */
.split-out { background:#db6d28; border-radius:0 3px 3px 0;
  box-shadow:inset 2px 0 0 var(--panel); }
.split-label { font-size:11.5px; margin-top:4px; font-variant-numeric:tabular-nums; }
.usage-table td { vertical-align:top; }
.usage-table .num { text-align:right; font-variant-numeric:tabular-nums;
  white-space:nowrap; }
.usage-table th.num { text-align:right; }
.text-warn { color:var(--warn-fg); }

/* --- persona page --- */
.slider-field { display:flex; align-items:center; gap:12px; }
.slider-field label { margin:0; flex:0 0 140px; }
.slider-field input[type="range"] { flex:1; width:auto; accent-color:var(--primary); }
.slider-value { flex:0 0 130px; color:var(--text); font-size:13px; }
/* The exact text sent to the model. Monospace and scrollable because it is a prompt,
   not prose, and reading it is the point. */
.prompt-preview { margin:0; padding:12px 14px; background:var(--input);
  border:1px solid var(--border); border-radius:6px; color:var(--text-muted);
  font-size:12px; line-height:1.5; max-height:420px; overflow:auto;
  white-space:pre-wrap; word-break:break-word; }

/* Editable recommendation fields: they have to LOOK clickable or nobody finds them. */
.rec-editable { border-bottom:1px dashed var(--border); cursor:pointer; }
.rec-editable:hover { border-bottom-color:var(--accent); color:var(--text-hi); }
.rec-editable.just-saved { background:var(--ok-bg); color:var(--ok-fg);
  border-bottom-color:var(--ok-fg); }

/* Verified facts: the per-row form lives in one cell, so lay its fields out inline. */
.fact-row-form { display:flex; align-items:center; gap:12px; margin:0; }
.fact-row-form label { margin:0; white-space:nowrap; }

/* --- story rating --- */
.story-rate { display:inline-flex; align-items:center; gap:6px; margin-right:auto; }
.rate-btn { padding:3px 9px; font-size:12px; }
/* Dark tint plus saturated text, never a light fill on dark. */
.rate-btn.is-on-good { background:var(--ok-bg); border-color:var(--ok-fg); color:var(--ok-fg); }
.rate-btn.is-on-bad  { background:var(--danger-bg); border-color:var(--danger-fg); color:var(--danger-fg); }
.rate-note { font-size:11.5px; }
.story-actions { display:flex; align-items:center; gap:8px; }

/* --- user menu (top right) --- */
/* <details> based, so it needs no JS and stays keyboard reachable. */
.usermenu { position: relative; }
.usermenu > summary {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  padding: 6px 10px; border-radius: 6px; list-style: none;
}
.usermenu > summary::-webkit-details-marker { display: none; }
.usermenu > summary::marker { content: ''; }
.usermenu > summary:hover { background: var(--hover); }
.usermenu[open] > summary { background: var(--hover); }
.burger { display: inline-flex; flex-direction: column; gap: 3px; }
.burger i { display: block; width: 16px; height: 2px; background: var(--text-muted); border-radius: 1px; }
.usermenu[open] .burger i { background: var(--accent); }
.usermenu-panel {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 40;
  min-width: 210px; padding: 6px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.45);
}
.usermenu-panel a {
  display: block; padding: 8px 10px; border-radius: 6px;
  color: var(--text); font-size: 13px;
}
.usermenu-panel a:hover { background: var(--hover); color: var(--text-hi); text-decoration: none; }
.usermenu-sep { height: 1px; background: var(--border); margin: 6px 4px; }
.usermenu-panel form { margin: 4px 6px 2px; }

/* --- "write as" picker on the News page --- */
.write-as { display:flex; align-items:center; gap:8px; padding:8px 0 10px;
  border-bottom:1px solid var(--border-lt); margin-bottom:6px; flex-wrap:wrap; }
.write-as select { width:auto; min-width:150px; max-width:230px; padding:4px 8px;
  font-size:12.5px; }

/* --- help icons ------------------------------------------------------------ */
/* Hover for a mouse, :focus-within for keyboard and for touch, where hover does not
   exist at all. No JS, so it survives a script that failed to load. */
.help { position: relative; display: inline-flex; vertical-align: middle;
  margin-left: 6px; cursor: help; outline: none; }
.help-dot {
  display: inline-flex; align-items: center; justify-content: center;
  width: 15px; height: 15px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--input);
  color: var(--text-dim); font-size: 10px; font-weight: 700; line-height: 1;
}
.help:hover .help-dot, .help:focus .help-dot { border-color: var(--accent); color: var(--accent); }

.help-pop {
  position: absolute; left: 0; top: calc(100% + 7px); z-index: 60;
  /* Wide enough for three short paragraphs without becoming a wall of text. */
  width: 330px; max-width: 78vw;
  display: none; flex-direction: column; gap: 7px;
  padding: 11px 13px;
  background: var(--header); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 10px 28px rgba(0,0,0,.5);
  font-size: 12.5px; line-height: 1.5; font-weight: 400;
  color: var(--text); text-transform: none; letter-spacing: normal;
  white-space: normal; text-align: left;
}
.help:hover .help-pop, .help:focus .help-pop, .help:focus-within .help-pop { display: flex; }
.help-what { color: var(--text-hi); }
.help-effect { color: var(--text); }
.help-example { color: var(--text-muted); }
.help-pop b { color: var(--text-hi); font-weight: 600; }
/* Near the right edge the popover would be clipped by the panel, so flip it. */
.help.help-left .help-pop { left: auto; right: 0; }
/* Inside a table header the cell is uppercase and centred; the popover must not inherit
   either, which is why the resets above are explicit. */
thead th .help-dot { border-color: var(--border); }

/* --- brand gate findings --- */
/* One card per finding. The old layout reused .feed-row, which made a warning look like a
   list item and buried the remediation in dim 12px text nobody read. */
.finding { padding: 12px 0; border-top: 1px solid var(--border-lt); }
.finding:first-of-type { border-top: 0; padding-top: 0; }
.finding-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.finding-head strong { color: var(--text-hi); }
.finding-quote { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px; color: var(--warn-fg); background: var(--warn-bg);
  border-radius: 4px; padding: 4px 8px; display: inline-block; margin-bottom: 6px; }
.finding-msg { font-size: 13px; color: var(--text); margin-bottom: 4px; }
.finding-fix { font-size: 12.5px; color: var(--text-muted); margin-bottom: 4px; }
/* The route to the control, given its own tinted row so it reads as an action rather than
   more explanation. */
.finding-source { font-size: 12.5px; color: var(--text-muted);
  background: var(--info-bg); border-left: 2px solid var(--info-fg);
  border-radius: 4px; padding: 7px 10px; margin-top: 6px; }
.finding-fix b, .finding-source b { color: var(--text-hi); font-weight: 600; }
.finding-source a { margin-left: 6px; }

/* --- writing progress steps --- */
/* Named stages, not a percentage: the work is genuinely indeterminate because a blocked
   draft gets rewritten, so a bar claiming 60% would be lying. */
.writing-steps { list-style: none; margin: 0 0 14px; padding: 0;
  display: flex; flex-wrap: wrap; gap: 6px; }
.writing-steps li {
  font-size: 11.5px; color: var(--text-dim);
  padding: 4px 10px 4px 22px; border-radius: 999px;
  background: var(--input); border: 1px solid var(--border);
  position: relative;
}
.writing-steps li::before {
  content: ''; position: absolute; left: 8px; top: 50%;
  width: 7px; height: 7px; margin-top: -3.5px; border-radius: 50%;
  background: var(--border);
}
.writing-steps li.is-active { color: var(--accent); border-color: var(--accent); }
.writing-steps li.is-active::before { background: var(--accent);
  animation: step-pulse 1.2s ease-in-out infinite; }
.writing-steps li.is-done { color: var(--ok-fg); border-color: var(--ok-fg); }
/* A tick rather than a dot, so a finished stage is distinguishable at a glance and not
   only by colour. */
.writing-steps li.is-done::before { content: '\2713'; background: none;
  width: auto; height: auto; margin-top: 0; top: 3px; left: 7px;
  font-size: 11px; color: var(--ok-fg); }
@keyframes step-pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

/* The finished state has to look like the finished state. */
.btn-lg { padding: 10px 20px; font-size: 15px; font-weight: 600; }

/* --- bug reporting --- */
.topbar-bug { padding: 5px 10px; line-height: 1; font-size: 15px; }
.topbar-bug:hover { color: var(--warn-fg); border-color: var(--warn-fg); }

.bug .bug-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.bug .bug-head .spacer { flex: 1; }
.bug-title { color: var(--text-hi); }
.bug-meta { font-size: 12px; margin-bottom: 8px; }
.bug-page { font-size: 12px; margin-bottom: 8px; }
/* The report as written, newlines preserved: someone pasting an error message wants it to
   survive, and a wall of collapsed text is unreadable. */
.bug-details { font-size: 13px; color: var(--text); white-space: pre-wrap;
  background: var(--input); border: 1px solid var(--border);
  border-radius: 6px; padding: 10px 12px; margin-bottom: 10px; }

/* --- scheduled calendar ---------------------------------------------------
   A fixed seven-column week, so the same weekday always sits in the same
   column and 14 days reads as two stacked weeks. Auto-fitting the columns
   instead made a 14-day view put Tuesday in a different place than the 7-day
   view did, which defeats the point of a calendar. */
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
            gap: 6px; padding: 10px 12px 12px; }
.cal-day { border: 1px solid var(--line); border-radius: 6px; min-height: 88px;
           display: flex; flex-direction: column; overflow: hidden; }
/* The weekend is dimmed rather than hidden: nothing is scheduled there by
   design, and seeing the empty days is what makes the pattern legible. */
.cal-day.is-weekend { opacity: .55; }
.cal-day.is-today { border-color: var(--primary); }
.cal-day.has-posts { background: rgba(127, 127, 127, .06); }
.cal-day.is-zoomed { outline: 2px solid var(--primary); outline-offset: -2px; }
.cal-day-head { display: flex; align-items: baseline; gap: 5px; padding: 5px 6px;
                border-bottom: 1px solid var(--line); font-size: 11.5px; }
.cal-day-head a { display: flex; gap: 5px; align-items: baseline;
                  text-decoration: none; }
.cal-dow { font-weight: 600; }
.cal-date { color: var(--muted); font-size: 11px; }
.cal-count { margin-left: auto; background: var(--primary); color: #06210c;
             border-radius: 9px; padding: 0 5px; font-size: 10.5px;
             font-weight: 600; }
.cal-day-body { display: flex; flex-direction: column; gap: 3px; padding: 4px; }
.cal-post { display: block; width: 100%; text-align: left; cursor: pointer;
            border: 0; border-left: 3px solid var(--primary); border-radius: 3px;
            background: rgba(127, 127, 127, .14); color: inherit;
            padding: 3px 5px; font-size: 11px; line-height: 1.3; }
.cal-post:hover { background: rgba(127, 127, 127, .26); }
/* Morning and afternoon are coloured differently because the whole scheduling
   model is one of each per day -- at a glance you should see which half is
   still free. */
.cal-post.is-am { border-left-color: #58a6ff; }
.cal-post.is-pm { border-left-color: #d29922; }
.cal-time { display: block; font-weight: 600; font-size: 10.5px; }
.cal-title { display: block; overflow: hidden; text-overflow: ellipsis;
             white-space: nowrap; color: var(--muted); }
@media (max-width: 900px) {
  /* Below this the seven columns are unreadable, so it becomes a list of days.
     A calendar you cannot read the titles in is not a calendar. */
  .cal-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* --- MFA nudge in the top bar ---------------------------------------------
   Warm amber, not red: this is a "you should" not a "something is broken",
   and a red banner on every page for a setting that is merely off trains the
   eye to skip the bar entirely. */
.topbar-mfa { display: inline-flex; align-items: center; gap: 6px;
              margin-right: 10px; padding: 4px 10px; border-radius: 999px;
              font-size: 12.5px; font-weight: 600; text-decoration: none;
              color: #d29922; border: 1px solid rgba(210, 153, 34, .45);
              background: rgba(210, 153, 34, .12); }
.topbar-mfa:hover { background: rgba(210, 153, 34, .22); color: #f0b429; }

/* --- AI usage: two columns ------------------------------------------------
   Spend per day on the left, the five totals on the right. These panels used
   .rec-rail, which is the News SIDEBAR class (grid-column: 2, flex column) --
   standalone it gave each of five compact numbers a full-width row and turned
   a five-figure summary into several screens of scrolling.

   The day list is the growing side (90d = ninety rows), so it takes the wider
   column and owns the scrolling. The totals are fixed in number and stay put
   beside it. */
.usage-layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
                gap: 14px; align-items: start; margin-bottom: 14px; }
/* One window of days is not a trend, so the panel is not rendered at all and
   the totals take the full width rather than leaving a hole where it was. */
.usage-layout.is-single { grid-template-columns: minmax(0, 1fr); }

/* Capped and scrolled internally: at 90d an unbounded list pushes Cost by
   function off the bottom of the page, which is the problem this is fixing. */
.u-days-body { max-height: 420px; overflow-y: auto; padding: 10px 12px 12px; }

.u-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
           gap: 10px; }
.u-stats .stat-tile { margin: 0; }
/* Denser than a full-width tile: at half width the huge value size wraps the
   note underneath it and re-creates the tall stack in miniature. */
.u-stats .stat-value { font-size: 26px; line-height: 1.15; }
.u-stats .stat-label { font-size: 10.5px; }
.u-stats .stat-note { font-size: 11.5px; }
/* Cached input carries the longest note, so it spans both columns rather than
   being the one tile that is twice as tall as its neighbour. */
.u-stats .stat-tile:last-child { grid-column: 1 / -1; }

@media (max-width: 1150px) {
  .usage-layout { grid-template-columns: minmax(0, 1fr); }
  .u-days-body { max-height: none; }
}
@media (max-width: 620px) {
  .u-stats { grid-template-columns: minmax(0, 1fr); }
  .u-stats .stat-tile:last-child { grid-column: auto; }
}

/* --- setup markers and the Things to do toast -----------------------------
   Red ! means "you have not done this yet". Deliberately a different mark from
   the existing amber .nav-dot, which means "something you already set up has
   broken". Collapsing the two would make both less readable: one is work you
   have never started, the other is a regression. */
.nav-todo, .tab-todo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 15px; height: 15px; margin-left: 6px; border-radius: 50%;
  background: #d9534f; color: #fff; font-size: 10.5px; font-weight: 700;
  line-height: 1; flex: 0 0 auto;
}
.tab-todo { width: 14px; height: 14px; font-size: 10px; }

/* Bottom-right, above the content but out of the reading column. Not centred:
   a modal would have to be dismissed before the app could be used, and this is
   a nudge, not a gate. */
.todo-toast {
  position: fixed; right: 16px; bottom: 16px; z-index: 60; width: 340px;
  max-width: calc(100vw - 32px); max-height: 60vh; overflow-y: auto;
  background: var(--panel, #161b22); border: 1px solid var(--line, #30363d);
  border-left: 3px solid #d9534f; border-radius: 8px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .45); padding: 12px 14px;
  font-size: 13px;
}
.todo-head { display: flex; align-items: center; gap: 8px; }
.todo-bang { display: inline-flex; align-items: center; justify-content: center;
             width: 18px; height: 18px; border-radius: 50%; background: #d9534f;
             color: #fff; font-weight: 700; font-size: 12px; flex: 0 0 auto; }
.todo-x { margin-left: auto; background: none; border: 0; color: var(--muted, #8b949e);
          font-size: 19px; line-height: 1; cursor: pointer; padding: 0 2px; }
.todo-x:hover { color: inherit; }
.todo-list { list-style: none; margin: 10px 0 0; padding: 0; }
.todo-list li { padding: 7px 0; border-top: 1px solid var(--line, #30363d); }
.todo-list a { font-weight: 600; text-decoration: none; }
.todo-list a:hover { text-decoration: underline; }
/* The reason, not just the task. "Add an AI provider key" does not explain why
   nothing is happening; "no key means no agent can run" does. */
.todo-why { display: block; color: var(--muted, #8b949e); font-size: 11.5px;
            margin-top: 2px; line-height: 1.35; }
@media (max-width: 620px) {
  .todo-toast { right: 8px; left: 8px; bottom: 8px; width: auto; }
}

/* A checkbox that reads as a chip. Used for the "write for" network picker: the choice is
 * one of a small set shown side by side, and a column of bare checkboxes reads as a form to
 * fill in rather than a switch to flick. */
.pick-chip { display:inline-flex; align-items:center; gap:6px; padding:5px 10px;
  border:1px solid var(--border); border-radius:14px; background:var(--bg);
  font-size:12.5px; cursor:pointer; user-select:none; }
.pick-chip:hover { border-color:var(--accent); }
.pick-chip input { margin:0; cursor:pointer; }
.pick-chip:has(input:checked) { border-color:var(--primary); color:var(--text); }

/* The × that drops a "Do not claim" limit. Deliberately quiet until hovered: it sits inside
 * a line of text the operator is reading, not in a row of controls. */
.rec-clear { background:none; border:0; color:var(--text-dim); cursor:pointer;
  font-size:15px; line-height:1; padding:0 4px; border-radius:3px; }
.rec-clear:hover { color:var(--danger-fg, #f85149); background:var(--bg); }

/* Which network a post belongs to.
 *
 * Colour is the identity channel: with two platforms live, "which one is this" is the first
 * question on every row, and reading a word is slower than recognising a colour. Each keeps
 * the platform's own hue so the mapping needs no learning. The label is always present as
 * well -- colour alone fails for the colour-blind and in a screenshot pasted into chat. */
.badge.plat-linkedin { background:#0a66c2; color:#fff; border-color:#0a66c2; }
.badge.plat-x { background:#1a1d21; color:#e6edf3; border-color:#3d444d; }

/* The calendar's compact form. A full badge would be most of a day cell, so this is a
 * two-character mark at the same hues. */
.cal-plat { display:inline-block; min-width:16px; padding:0 3px; border-radius:3px;
  font-size:9.5px; font-weight:600; line-height:14px; text-align:center;
  vertical-align:middle; margin-right:3px; }
.cal-plat.plat-linkedin { background:#0a66c2; color:#fff; }
.cal-plat.plat-x { background:#1a1d21; color:#e6edf3; border:1px solid #3d444d; }

/* Review sets: one row per story, one mark per network.
 *
 * The tick is the only per-network state worth showing at this altitude -- read or not --
 * because the row exists to answer "what is left to do", and anything more turns a scannable
 * list back into a form. */
.set-table td { vertical-align:middle; }
.set-plat { display:inline-flex; align-items:center; gap:3px; min-width:26px; padding:2px 6px;
  border-radius:4px; font-size:11px; font-weight:600; text-decoration:none;
  margin-right:4px; opacity:.55; }
.set-plat.plat-linkedin { background:#0a66c2; color:#fff; }
.set-plat.plat-x { background:#1a1d21; color:#e6edf3; border:1px solid #3d444d; }
/* Full opacity once read: the unread ones recede, so a half-done row reads as half-done
 * without needing the percentage. */
.set-plat.is-read { opacity:1; }
.set-plat:hover { outline:1px solid var(--accent); }
.set-tick { font-size:10px; }
.set-pct { display:inline-block; min-width:38px; font-weight:600;
  font-variant-numeric:tabular-nums; color:var(--text-dim); }
.set-pct.is-ready { color:var(--ok-fg); }

/* Suggested posting slots. The first is the app's recommendation, the picked one is the
 * operator's decision -- two different states, so two different marks. */
.topic.is-best { border-color:var(--primary); }
.topic.is-picked { background:var(--primary); color:#fff; border-color:var(--primary); }

/* How many outlets ran a story. Sits above the claim limit because it is context for the
 * decision to write at all, not a constraint on what the post may say. */
.rec-outlets { display:flex; align-items:baseline; gap:8px; margin:4px 0 2px; flex-wrap:wrap; }
.rec-outlets a { color:var(--accent); }
