/* Base
   Design tokens, both themes, reset, typography, buttons, inputs, notices,
   pills, toast. Everything is served from this origin, so the fonts are the
   ones already on the reader's machine. */

:root {
  --navy: #012169;          /* Duke navy */
  --navy-deep: #00164a;
  --royal: #00539b;
  --royal-hover: #003f78;
  --ground: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #eef1f7;
  --ink: #141b2d;
  --muted: #5b6577;
  --line: #dce1ea;
  --line-strong: #c3cbd8;
  --focus: #2f7de1;
  --mast-ink: #ffffff;
  --mast-muted: #b9c6e4;
  --tab-idle: #d7def0;

  --ok: #1e7a4f;
  --ok-bg: #e3f3ea;
  --gold: #8a5a00;
  --gold-bg: #fbf0d9;
  --info: #00539b;
  --info-bg: #e2edf8;
  --slate: #566074;
  --slate-bg: #eceff4;
  --danger: #b3302a;
  --danger-bg: #fbe9e7;
  --bar: #00539b;

  --display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --r: 6px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --navy: #0b1f55;
    --navy-deep: #081640;
    --royal: #7fb2f0;
    --royal-hover: #a8cbf6;
    --ground: #0c1220;
    --surface: #131b2c;
    --surface-2: #1a2438;
    --ink: #e7ebf3;
    --muted: #9aa5b9;
    --line: #253049;
    --line-strong: #34415e;
    --focus: #7fb2f0;
    --mast-muted: #a4b3d6;
    --tab-idle: #b8c5e3;
    --ok: #6fd3a0;
    --ok-bg: #143427;
    --gold: #f0c36b;
    --gold-bg: #3a2c10;
    --info: #8fc0f5;
    --info-bg: #15304f;
    --slate: #b3bccd;
    --slate-bg: #232d42;
    --danger: #f3918a;
    --danger-bg: #3b1714;
    --bar: #7fb2f0;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --navy: #0b1f55;
  --navy-deep: #081640;
  --royal: #7fb2f0;
  --royal-hover: #a8cbf6;
  --ground: #0c1220;
  --surface: #131b2c;
  --surface-2: #1a2438;
  --ink: #e7ebf3;
  --muted: #9aa5b9;
  --line: #253049;
  --line-strong: #34415e;
  --focus: #7fb2f0;
  --mast-muted: #a4b3d6;
  --tab-idle: #b8c5e3;
  --ok: #6fd3a0;
  --ok-bg: #143427;
  --gold: #f0c36b;
  --gold-bg: #3a2c10;
  --info: #8fc0f5;
  --info-bg: #15304f;
  --slate: #b3bccd;
  --slate-bg: #232d42;
  --danger: #f3918a;
  --danger-bg: #3b1714;
  --bar: #7fb2f0;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 15px/1.55 var(--sans);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
[hidden] { display: none !important; }
a { color: var(--royal); text-underline-offset: 2px; }
a:hover { color: var(--royal-hover); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
h1, h2, h3 { text-wrap: balance; margin: 0; }
p { margin: 0; }
code { font-family: var(--mono); font-size: 0.9em; background: var(--surface-2); padding: 1px 4px; border-radius: 3px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); font-size: 0.86em; }
.wrap { max-width: 1240px; margin-inline: auto; padding-inline: 24px; }
@media (max-width: 640px) { .wrap { padding-inline: 16px; } }

.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Buttons & inputs ---------- */
.btn {
  appearance: none; cursor: pointer; font: 600 13.5px/1 var(--sans);
  display: inline-flex; align-items: center; gap: 7px; padding: 9px 14px;
  border-radius: var(--r); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--royal); color: var(--royal); }
.btn-primary { background: var(--royal); border-color: var(--royal); color: #fff; }
.btn-primary:hover { background: var(--royal-hover); border-color: var(--royal-hover); color: #fff; }
:root[data-theme="dark"] .btn-primary, :root[data-theme="dark"] .btn-primary:hover { color: #0c1220; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn-primary,
  :root:not([data-theme="light"]) .btn-primary:hover { color: #0c1220; }
}
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); background: var(--danger-bg); }
.btn-danger:hover { color: #fff; background: var(--danger); border-color: var(--danger); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--royal); padding-inline: 8px; }
.btn-icon { padding: 8px 10px; background: transparent; color: #fff; border-color: rgba(255,255,255,0.35); font-size: 15px; }
.btn-icon:hover { color: #fff; border-color: #fff; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.linkish { appearance: none; border: 0; background: none; padding: 0; font: inherit; color: var(--royal); cursor: pointer; text-align: left; }
.linkish:hover { text-decoration: underline; text-underline-offset: 2px; }

input[type="search"], input[type="text"], input[type="email"], input[type="password"], input[type="url"], select, textarea {
  font: 14px/1.4 var(--sans); color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--r); padding: 8px 10px; width: 100%;
}
textarea { min-height: 72px; resize: vertical; }
select { padding-right: 28px; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.8; }

/* ---------- Shared blocks ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 18px 20px; min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.panel-title { font: 600 19px/1.2 var(--display); }
.panel-note { font-size: 12.5px; color: var(--muted); }
.steps-inline { counter-reset: s; list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
/* The number is positioned rather than a grid cell, so links and bold text in
   a step stay on the same line as the rest of it. */
.steps-inline li { counter-increment: s; position: relative; padding-left: 34px; font-size: 14px; min-height: 24px; }
.steps-inline li::before { content: counter(s); position: absolute; left: 0; top: 0; font: 500 12px/24px var(--mono); text-align: center; width: 24px; height: 24px; border-radius: 50%; background: var(--surface-2); color: var(--ink); }
.bullets { margin: 0; padding-left: 18px; display: grid; gap: 7px; color: var(--muted); }
.notice { border: 1px solid var(--line-strong); background: var(--surface-2); border-radius: 8px; padding: 12px 14px; font-size: 13.5px; }
.notice-warn { border-color: color-mix(in srgb, var(--gold) 45%, transparent); background: var(--gold-bg); }
.notice-ok { border-color: color-mix(in srgb, var(--ok) 45%, transparent); background: var(--ok-bg); }
.notice-err { border-color: color-mix(in srgb, var(--danger) 55%, transparent); background: var(--danger-bg); }
.pill { display: inline-flex; align-items: center; gap: 6px; font: 600 12px/1 var(--sans); padding: 5px 9px 5px 8px; border-radius: 999px; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-ok { color: var(--ok); background: var(--ok-bg); }
.pill-gold { color: var(--gold); background: var(--gold-bg); }
.pill-info { color: var(--info); background: var(--info-bg); }
.pill-slate { color: var(--slate); background: var(--slate-bg); }
.pill-danger { color: var(--danger); background: var(--danger-bg); }
.tag { display: inline-block; font: 500 12px/1 var(--sans); padding: 4px 7px; border-radius: 4px; background: var(--surface-2); color: var(--ink); white-space: nowrap; }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }

/* ---------- Footer, toast, confirm ---------- */
.footer { padding-block: 28px 40px; font-size: 13px; color: var(--muted); display: grid; gap: 4px; border-top: 1px solid var(--line); margin-top: 28px; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(20px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: var(--ground); padding: 10px 16px; border-radius: 8px; font-size: 14px; z-index: 60; box-shadow: 0 8px 24px rgba(0,0,0,0.2); max-width: calc(100% - 32px); }
.confirm { border: 1px solid var(--line); border-radius: 10px; padding: 0; background: var(--surface); color: var(--ink); max-width: min(440px, calc(100% - 32px)); }
.confirm::backdrop { background: rgba(8, 16, 40, 0.45); }
.confirm-inner { padding: 22px; display: grid; gap: 12px; }
.confirm-inner h2 { font: 600 22px/1.2 var(--display); }
.confirm-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }

.spin { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; vertical-align: -2px; }
@media (prefers-reduced-motion: no-preference) { .spin { animation: spin 0.8s linear infinite; } }
@keyframes spin { to { transform: rotate(360deg); } }
