/* Wiki chrome, written from scratch.
 *
 * The layout conventions are the generic MediaWiki ones — a single reading column, an
 * infobox card at the top right, section headings with a rule under them. None of Fandom's
 * stylesheet, colours, logos or images are used or reproduced here; only the page *text* is
 * theirs, and that is credited in the footer and in snapshots/ATTRIBUTION.md.
 */

:root {
  --ink: #1e2328;
  --ink-soft: #5b656e;
  --ink-faint: #8b959e;
  --paper: #fbfaf8;
  --card: #ffffff;
  --rule: #e2ded7;
  --rule-soft: #efece7;
  --accent: #17605c;
  --accent-soft: #e6f0ef;
  --ok: #1f7a4d;
  --warn: #9a6212;
  --danger: #a33a2c;
  --violet: #5a4b9c;
  --shadow: 0 1px 2px rgba(30, 35, 40, .06), 0 4px 14px rgba(30, 35, 40, .05);
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

/* `.topbar` sets `display: flex`, which outranks the user agent's
   `[hidden] { display: none }` — so hiding it for the article view (app.js `route`) silently
   did nothing until this rule existed. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

/* -- top bar --------------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
  padding: 14px 28px;
  background: var(--card);
  border-bottom: 1px solid var(--rule);
}

.brand { display: flex; align-items: center; gap: 10px; }

.brand .mark {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.brand strong { display: block; font-size: 15px; letter-spacing: -.01em; }
.tagline { font-size: 12px; color: var(--ink-faint); }

/* -- shared bits ----------------------------------------------------------- */

main { max-width: 1120px; margin: 0 auto; padding: 28px; }

.empty, .muted { color: var(--ink-faint); }

.pill {
  /* Carries the `margin-left: auto` the wiki picker used to hold, so the pill stays hard
     right in the topbar now that nothing sits between it and the brand. */
  margin-left: auto;
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
  background: var(--rule-soft);
  color: var(--ink-soft);
}

.pill.ok { background: #e4f2ea; color: var(--ok); }
/* Two, because `ClaimStatus` has two. A claim either needs a reviewer or it does not;
   where a drafted edit sits is the queue's business, and age is next_check_at vs the clock. */

/* -- confidence ------------------------------------------------------------ */

.conf { display: flex; align-items: center; gap: 8px; }
.conf-track { width: 84px; height: 6px; border-radius: 3px; background: var(--rule-soft); }
.conf-fill { height: 100%; border-radius: 3px; }
.conf-fill.high { background: var(--ok); }
.conf-fill.mid { background: var(--warn); }
.conf-fill.low { background: var(--danger); }
.conf-num { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--ink-soft); }

/* -- queue cards ----------------------------------------------------------- */

.card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}

.card.decided { opacity: .68; }
.card.decided.approved { border-left: 3px solid var(--ok); }
.card.decided.rejected { border-left: 3px solid var(--danger); }

.card-head { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.card-head h2 { margin: 0; font-size: 17px; letter-spacing: -.01em; }
.card-head .conf { margin-left: auto; }

.where { margin: 3px 0 0; font-size: 12px; color: var(--ink-faint); }
.claim-id { font-family: var(--mono); margin-left: 6px; }

.summary { margin: 12px 0; color: var(--ink-soft); }

.diff {
  border: 1px solid var(--rule);
  border-radius: 7px;
  overflow: hidden;
  margin: 14px 0;
}

.diff-row { display: flex; gap: 10px; padding: 8px 12px; font-size: 12.5px; }
.diff-row + .diff-row { border-top: 1px solid var(--rule-soft); }
.diff-row code { font-family: var(--mono); white-space: pre-wrap; word-break: break-word; }
.diff-row .gutter { color: var(--ink-faint); user-select: none; }
.diff-row.del { background: #fdf1ef; }
.diff-row.ins { background: #eef7f1; }
.diff-row.ctx { background: transparent; color: var(--ink-soft); }
/* The words that actually moved, inside a line that was edited rather than replaced. */
.diff-row mark { background: none; padding: 0 1px; border-radius: 2px; font-weight: 600; }
.diff-row.del mark { background: #f7c9c0; color: var(--danger); }
.diff-row.ins mark { background: #b8e2c8; color: var(--ok); }

.rationale {
  margin: 12px 0;
  padding-left: 12px;
  border-left: 2px solid var(--rule);
  color: var(--ink-soft);
  font-size: 14px;
}

/* A conflicting card, above the diff it proposes: what the sources fell out over, and who.
   Violet is this stylesheet's conflict colour (see the ledger table's own `.conflict`); the
   left rule matches `.rationale`, because both are the agent explaining itself. */
.disagreement {
  margin: 12px 0;
  padding: 10px 12px;
  border-left: 2px solid var(--violet);
  background: #f4f2fa;
  border-radius: 0 4px 4px 0;
}

.disagreement-note { margin: 0; font-size: 13px; color: var(--ink); }
.disagreement-note strong { color: var(--violet); }

.disagreement-sources { list-style: none; margin: 8px 0 0; padding: 0; font-size: 12px; }
.disagreement-sources li { padding: 2px 0; }
.disagreement-sources a { color: var(--violet); }

.sources { list-style: none; margin: 14px 0 0; padding: 0; }

.sources li {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  padding: 7px 0;
  border-top: 1px solid var(--rule-soft);
  font-size: 13px;
}

.tier {
  font-family: var(--mono); font-size: 11px; font-weight: 700;
  padding: 1px 6px; border-radius: 4px;
  background: var(--rule-soft); color: var(--ink-soft);
}

.tier-1 { background: #e4f2ea; color: var(--ok); }
.tier-2 { background: var(--accent-soft); color: var(--accent); }
.tier-3 { background: #eef0f4; color: #46536b; }
.tier-5 { background: #fbf0dd; color: var(--warn); }
.tier-6 { background: #fae7e3; color: var(--danger); }

.src-note { color: var(--ink-faint); }
.src-date { color: var(--ink-faint); font-variant-numeric: tabular-nums; }

.actions { display: flex; align-items: center; gap: 8px; margin-top: 16px; flex-wrap: wrap; }

.btn {
  font: inherit; font-size: 13px; font-weight: 600;
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid var(--rule);
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
}

.btn.approve { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.reject { color: var(--danger); }
.btn.ghost { margin-left: auto; text-decoration: none; color: var(--ink-soft); }
.btn:hover { filter: brightness(.97); }

.decided-note { font-size: 13px; color: var(--ink-faint); }

/* -- the verify gate ------------------------------------------------------- */
/* Opened in a popup beside the article by wiki-config/continuity-launcher.js, so it drops the
   site chrome and narrows the column — 920px of window, one card at a time. */

.verify-head { margin-bottom: 20px; }
.verify-head h1 { margin: 2px 0 4px; font-size: 21px; letter-spacing: -.02em; }
.eyebrow {
  margin: 0; font-size: 11px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--accent);
}
.verify-sub { margin: 0; font-size: 13px; color: var(--ink-faint); }

/* The gate's one action. The popup opens idle now, so this is what the reader presses to
   start a run — it is the primary control on the view and reads like one, with what pressing
   it does said beside it rather than discovered afterwards. */
.run-action { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }

.runagain {
  padding: 8px 16px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.runagain:hover:not([disabled]) { filter: brightness(1.1); }
.runagain[disabled] {
  background: var(--card); color: var(--ink-faint); border-color: var(--rule);
  cursor: default;
}

.run-note { font-size: 11.5px; color: var(--ink-faint); }

/* Process and Changes: two views of one run, not two steps. The stepper used to sit above the
   cards and scroll away, so the thing worth watching while a run went was the thing you could
   not get back to. */
.gate-tabs {
  display: flex; gap: 4px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--rule);
}

.gate-tab {
  display: flex; align-items: center; gap: 6px;
  padding: 9px 14px;
  margin-bottom: -1px;
  border: 0; border-bottom: 2px solid transparent;
  background: none;
  font: inherit; font-size: 13px; font-weight: 600;
  color: var(--ink-faint);
  cursor: pointer;
}
.gate-tab:hover { color: var(--ink-soft); }
.gate-tab.on { color: var(--accent); border-bottom-color: var(--accent); }

.tab-count {
  padding: 1px 7px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 11px; font-weight: 700;
}

/* A card whose text the reviewer has changed. The agent's diff above it is now a proposal
   rather than a description of what will be written, and the card has to say so. */
.card.edited { border-left: 3px solid var(--violet); }

.verdicts { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.chip {
  font-size: 11px; font-weight: 600; letter-spacing: .02em;
  padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--rule); color: var(--ink-soft); background: var(--paper);
}
.chip.bucket { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.chip.shape { font-family: var(--mono); }
.chip.flag-chip { border-color: var(--danger); color: var(--danger); background: #fdf1ef; }

.draft-label {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  margin: 14px 0 5px; font-size: 12px; font-weight: 600; color: var(--ink-soft);
}
.edited-flag { font-weight: 400; color: var(--violet); }

textarea.draft {
  display: block; width: 100%; resize: vertical;
  padding: 10px 12px;
  border: 1px solid var(--rule); border-radius: 8px;
  background: var(--paper); color: var(--ink);
  font: 13px/1.65 var(--mono);
}
textarea.draft:focus { outline: 2px solid var(--accent); outline-offset: -1px; background: var(--card); }

/* -- the run rail ---------------------------------------------------------- */
/* The eight stages of summary.md §6 as a stepper. The stagger is a per-node animation-delay
   set in app.js, so the reveal is CSS and the *state* is data — nothing here animates a run
   that is not in the payload. */

.rail { display: flex; list-style: none; margin: 0 0 8px; padding: 0; }

.stage {
  position: relative; flex: 1 1 0; min-width: 84px; padding: 0 3px;
  display: flex; flex-direction: column; align-items: center; text-align: center;
  animation: stage-in .34s ease both;
}
.stage::before {
  content: ""; position: absolute; top: 11px; height: 2px;
  /* Between the circles, not under them: 12px of dot radius plus 8px of clearance, which also
     clears the 4px halo an active dot carries. Centre-to-centre drew the line through every
     dot and it read as skewered rather than connected. */
  right: calc(50% + 20px); width: calc(100% - 40px);
  background: var(--rule);
}
.stage:first-child::before { display: none; }
.stage.done::before, .stage.active::before { background: var(--accent); }

.dot {
  position: relative; z-index: 1;
  width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--rule); background: var(--card);
  color: #fff; font-size: 12px; font-weight: 700; line-height: 1;
}
.stage.done .dot { background: var(--accent); border-color: var(--accent); }
.stage.active .dot { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.stage.active .dot::after {
  content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
}

.stage-name { margin-top: 7px; font-size: 12px; font-weight: 600; }
.stage-note { font-size: 11px; color: var(--ink-faint); }
.stage.active .stage-name { color: var(--accent); }
.stage.pending .stage-name { color: var(--ink-faint); }

@keyframes stage-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) { .stage { animation: none; } }

.rail-note { margin: 0 0 24px; font-size: 11px; color: var(--ink-faint); text-align: center; }

/* -- the final gate -------------------------------------------------------- */
/* Accepting a card writes nothing; this bar is the only thing on the page that does. */

.publish-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 14px 18px; margin-top: 4px;
  border: 1px solid var(--rule); border-radius: 10px;
  background: var(--card); box-shadow: var(--shadow);
  font-size: 13px;
}
.publish-bar span { flex: 1 1 240px; color: var(--ink-soft); }
.publish-bar strong { color: var(--ink); }
.publish-bar.waiting { background: var(--paper); box-shadow: none; color: var(--ink-faint); }
.publish-bar.written { border-color: var(--ok); background: #f2f8f4; }

.btn.publish { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.publish[disabled] { opacity: .45; cursor: not-allowed; }
.btn.discard { color: var(--danger); }
.btn.undo { color: var(--ink-soft); }

/* What the publish route actually said. Shown verbatim rather than softened: the route
   answers 501 today, and a gate that hid that would be claiming a write it did not make. */
.publish-note {
  margin: 10px 0 0; padding: 8px 12px;
  border-radius: 6px; background: #fdf1ef;
  font-size: 12px; color: var(--danger);
}

/* -- article view ---------------------------------------------------------- */

.page-switch { max-width: 820px; display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }

.page-switch a {
  padding: 5px 11px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--card);
  font-size: 13px;
  text-decoration: none;
  color: var(--ink-soft);
}

.page-switch a.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.article-grid { max-width: 820px; }

.article {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 28px 32px;
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.7;
  min-width: 0;
}

.article h1 {
  margin: 0 0 18px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--rule);
  font-size: 30px;
  font-weight: 400;
  letter-spacing: -.01em;
}

.article h2, .article h3, .article h4, .article h5, .article h6 {
  font-weight: 600;
  letter-spacing: -.01em;
  margin: 26px 0 10px;
}

.article h2 { font-size: 21px; padding-bottom: 6px; border-bottom: 1px solid var(--rule-soft); }
.article h3 { font-size: 17px; }
.article h4, .article h5, .article h6 { font-size: 15px; }

.article p { margin: 0 0 14px; }
.article ul, .article ol { margin: 0 0 14px; padding-left: 24px; }
.article li { margin-bottom: 4px; }

.article blockquote {
  margin: 0 0 16px;
  padding: 10px 16px;
  border-left: 3px solid var(--rule);
  color: var(--ink-soft);
  font-style: italic;
}

.article blockquote cite { display: block; margin-top: 6px; font-size: 13px; font-style: normal; }

/* Wiki tables. The wrapper scrolls rather than the page: the soundtrack table is five
   columns of song titles and would otherwise push the whole article sideways. */
.article .wt-wrap { overflow-x: auto; margin: 0 0 14px; }
.article .wt { border-collapse: collapse; width: 100%; font-size: 14px; }
.article .wt th, .article .wt td {
  border: 1px solid var(--rule-soft);
  padding: 7px 10px;
  text-align: left;
  vertical-align: top;
}
.article .wt th { background: var(--rule-soft); font-weight: 600; }
.article .wt td > p:last-child, .article .wt td > ul:last-child { margin-bottom: 0; }
.article .wt ul, .article .wt ol { margin: 0; padding-left: 18px; }

.article .small { font-size: .85em; color: var(--ink-soft); }
.article a.wl { text-decoration: none; }
.article a.wl:hover { text-decoration: underline; }
.article a.ext::after { content: " ↗"; font-size: .8em; color: var(--ink-faint); }

mark.claim-hit {
  background: #fdf3d8;
  box-shadow: 0 0 0 2px #fdf3d8;
  border-bottom: 2px solid var(--warn);
  border-radius: 2px;
}

.attrib {
  margin-top: 28px; padding-top: 14px;
  border-top: 1px solid var(--rule);
  font-family: var(--sans); font-size: 12px; color: var(--ink-faint);
}

/* infobox: floated card, the one layout convention worth borrowing */
.infobox {
  float: right;
  width: 260px;
  margin: 0 0 18px 22px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--paper);
  font-family: var(--sans);
  font-size: 12.5px;
  overflow: hidden;
}

.infobox h3 {
  margin: 0;
  padding: 8px 12px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}

.infobox dl { margin: 0; }
.infobox dl > div { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 8px; padding: 6px 12px; }
.infobox dl > div + div { border-top: 1px solid var(--rule-soft); }
.infobox dt { color: var(--ink-faint); text-transform: capitalize; }
.infobox dd { margin: 0; word-break: break-word; }
/* -- footer ---------------------------------------------------------------- */

.foot {
  max-width: 1120px;
  margin: 10px auto 40px;
  padding: 18px 28px 0;
  border-top: 1px solid var(--rule);
  font-size: 12px;
  color: var(--ink-faint);
}

.foot p { margin: 0 0 6px; }
.foot code { font-family: var(--mono); }

/* -- narrow ---------------------------------------------------------------- */

@media (max-width: 900px) {
  .infobox { float: none; width: auto; margin: 0 0 18px; }
  .topbar { gap: 12px; }
  main { padding: 20px 16px; }
  .article { padding: 20px; }
}

/* -- the launcher ---------------------------------------------------------------------
   The button on an article that runs the agent against it. Fixed to the corner rather than
   placed in the nav: it stands in for the browser extension a real deployment would ship, so
   it should read as something watching the page rather than as part of the site's chrome. */
.continuity-launch {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  font: 600 13px/1 var(--sans);
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 999px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .22);
  cursor: pointer;
}
.continuity-launch:hover { filter: brightness(1.08); }
.continuity-launch:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

/* Reads as "watching", and it is the one piece of motion on the article. */
.launch-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
  animation: launch-pulse 2.4s ease-in-out infinite;
}
@keyframes launch-pulse { 0%, 100% { opacity: .45; } 50% { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .launch-dot { animation: none; opacity: .8; }
}

.rail-note.err { color: var(--bad, #b3261e); }
