/* PhishFactory user manual — standalone, no build step. */
:root {
  --brand: #e8562a;
  --brand-ink: #b23c14;
  --brand-tint: #fdeee8;
  --bg: #f6f6f4;
  --surface: #ffffff;
  --surface-2: #f0efec;
  --chrome: #0e0e0e;
  --chrome-fg: #d9d9d6;
  --chrome-muted: #8a8a86;
  --text: #191918;
  --muted: #5f5f5b;
  --subtle: #8b8b86;
  --border: #e3e2de;
  --border-strong: #cfcdc7;
  --info-bg: #eaf2fb; --info-fg: #164f86; --info-bd: #b9d3ef;
  --warn-bg: #fdf5e1; --warn-fg: #7a4f05; --warn-bd: #efd59a;
  --danger-bg: #fcecec; --danger-fg: #8f2424; --danger-bd: #f1c0c0;
  --ok-bg: #eaf5e4; --ok-fg: #2f5f12; --ok-bd: #c5e0b1;
  --radius: 10px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: "Inter", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --sidebar: 280px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #ff6a3d; --brand-ink: #ffb79e; --brand-tint: #3a1d12;
    --bg: #111110; --surface: #1a1a19; --surface-2: #242422;
    --text: #ececea; --muted: #a9a9a4; --subtle: #7d7d78;
    --border: #2e2e2c; --border-strong: #42423f;
    --info-bg: #13263a; --info-fg: #a9cdf2; --info-bd: #24476b;
    --warn-bg: #2f2410; --warn-fg: #f1cf86; --warn-bd: #5a4419;
    --danger-bg: #351616; --danger-fg: #f3aaaa; --danger-bd: #5f2626;
    --ok-bg: #18290f; --ok-fg: #b6dc9a; --ok-bd: #31501e;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --brand: #ff6a3d; --brand-ink: #ffb79e; --brand-tint: #3a1d12;
  --bg: #111110; --surface: #1a1a19; --surface-2: #242422;
  --text: #ececea; --muted: #a9a9a4; --subtle: #7d7d78;
  --border: #2e2e2c; --border-strong: #42423f;
  --info-bg: #13263a; --info-fg: #a9cdf2; --info-bd: #24476b;
  --warn-bg: #2f2410; --warn-fg: #f1cf86; --warn-bd: #5a4419;
  --danger-bg: #351616; --danger-fg: #f3aaaa; --danger-bd: #5f2626;
  --ok-bg: #18290f; --ok-fg: #b6dc9a; --ok-bd: #31501e;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 76px; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15.5px/1.65 var(--sans); -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-ink); text-underline-offset: 2px; }
code, kbd {
  font-family: var(--mono); font-size: .84em;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 5px; padding: .08em .38em; white-space: nowrap;
}
kbd { border-bottom-width: 2px; }
.ui { /* a control's label, as it appears in the portal */
  font-weight: 600; white-space: nowrap;
  background: var(--brand-tint); color: var(--brand-ink);
  border-radius: 5px; padding: .05em .4em;
}

/* ── top bar ─────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 30; height: 60px;
  display: flex; align-items: center; gap: 14px; padding: 0 20px;
  background: var(--chrome); color: var(--chrome-fg);
  border-bottom: 1px solid #000;
}
.topbar .brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 600; }
.topbar .brand img { height: 30px; width: auto; }
.topbar .brand small { font: 500 11px/1 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--chrome-muted); }
.topbar .spacer { flex: 1; }
.topbar .version { font: 12px var(--mono); color: var(--chrome-muted); }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 34px; min-width: 34px; padding: 0 10px; border-radius: 8px;
  background: #1d1d1c; color: var(--chrome-fg); border: 1px solid #2c2c2a; cursor: pointer; font: inherit; font-size: 13px;
}
.icon-btn:hover { background: #262624; }
.menu-btn { display: none; }

/* ── layout ──────────────────────────────────────────── */
.layout { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); }
.sidebar {
  position: sticky; top: 60px; height: calc(100vh - 60px); overflow-y: auto;
  background: var(--chrome); color: var(--chrome-fg); padding: 16px 12px 40px;
}
.sidebar input[type=search] {
  width: 100%; height: 36px; padding: 0 12px; margin-bottom: 8px;
  border-radius: 8px; border: 1px solid #2c2c2a; background: #1a1a19; color: #fff; font: inherit; font-size: 14px;
}
.sidebar input[type=search]::placeholder { color: var(--chrome-muted); }
.sidebar input[type=search]:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.toc-group { font: 500 11px/1 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--chrome-muted); margin: 20px 10px 8px; }
.toc a {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 7px;
  color: var(--chrome-fg); text-decoration: none; font-size: 14px; position: relative;
}
.toc a:hover { background: #1d1d1c; }
.toc a.active { background: #232321; color: #fff; }
.toc a.active::before { content: ""; position: absolute; left: -12px; top: 6px; bottom: 6px; width: 3px; border-radius: 0 3px 3px 0; background: var(--brand); }
.toc a .n { font: 11px var(--mono); color: var(--chrome-muted); width: 18px; }
.toc a.sub { padding-left: 38px; font-size: 13px; color: var(--chrome-muted); }
.toc a.sub:hover { color: var(--chrome-fg); }
.toc a.hidden { display: none; }
.toc .empty { color: var(--chrome-muted); font-size: 13px; padding: 8px 10px; display: none; }

main { min-width: 0; padding: 36px clamp(16px, 4vw, 56px) 120px; }
.content { max-width: 1040px; margin: 0 auto; }

/* ── chapter structure ───────────────────────────────── */
.chapter { padding-top: 24px; margin-top: 48px; border-top: 1px solid var(--border); }
.chapter:first-of-type { border-top: 0; margin-top: 0; }
.eyebrow { font: 500 11.5px/1 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--subtle); }
.eyebrow b { color: var(--brand); font-weight: 600; }
h1, h2, h3, h4 { line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 40px; margin: 8px 0 12px; }
h2 { font-size: 30px; margin: 8px 0 10px; }
h3 { font-size: 20px; margin: 36px 0 10px; }
h4 { font-size: 16px; margin: 24px 0 8px; }
.lede { font-size: 17.5px; color: var(--muted); max-width: 760px; margin: 0 0 20px; }
p, li { max-width: 780px; }
.anchor { color: var(--subtle); text-decoration: none; margin-left: 8px; opacity: 0; font-weight: 400; }
h3:hover .anchor, h2:hover .anchor { opacity: 1; }

/* hero */
.hero {
  background: var(--chrome); color: var(--chrome-fg); border-radius: 16px;
  padding: 40px clamp(20px, 4vw, 48px); margin-bottom: 32px; position: relative; overflow: hidden;
}
.hero h1 { color: #fff; }
.hero .lede { color: var(--chrome-fg); }
.hero::after {
  content: ""; position: absolute; right: -80px; top: -80px; width: 320px; height: 320px; border-radius: 50%;
  border: 48px solid var(--brand); opacity: .13;
}
.hero-meta { display: flex; flex-wrap: wrap; gap: 10px 24px; font: 12.5px var(--mono); color: var(--chrome-muted); margin-top: 18px; }

/* cards grid */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin: 20px 0; }
.card {
  display: block; padding: 16px 18px; border-radius: var(--radius); background: var(--surface);
  border: 1px solid var(--border); text-decoration: none; color: var(--text);
  transition: border-color .15s, transform .15s;
}
.card:hover { border-color: var(--brand); transform: translateY(-1px); }
.card .t { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card .d { color: var(--muted); font-size: 13.5px; margin-top: 4px; line-height: 1.5; }
.card .g { font: 10.5px var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--subtle); }

/* flow diagram */
.flow { display: flex; flex-wrap: wrap; align-items: stretch; gap: 0; margin: 20px 0 8px; }
.flow .step {
  flex: 1 1 140px; min-width: 130px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px; position: relative; margin: 0 22px 12px 0;
}
.flow .step:not(:last-child)::after {
  content: "→"; position: absolute; right: -20px; top: 50%; transform: translateY(-50%); color: var(--brand); font-weight: 700;
}
.flow .step .k { font: 11px var(--mono); color: var(--brand); letter-spacing: .1em; }
.flow .step .t { font-weight: 600; font-size: 14.5px; }
.flow .step .d { color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.flow .step a { color: inherit; text-decoration: none; }

/* ── figures ─────────────────────────────────────────── */
figure { margin: 22px 0 28px; }
.shot .frame, .anim .frame {
  position: relative; border-radius: 12px; overflow: hidden; background: #0e0e0e;
  border: 1px solid var(--border-strong); box-shadow: 0 1px 2px rgba(0,0,0,.05), 0 12px 32px -12px rgba(0,0,0,.18);
}
.frame .bar {
  height: 28px; display: flex; align-items: center; gap: 6px; padding: 0 12px; background: #1b1b1a; border-bottom: 1px solid #000;
}
.frame .bar i { width: 10px; height: 10px; border-radius: 50%; background: #3a3a38; display: block; }
.frame .bar span { margin-left: 10px; font: 11.5px var(--mono); color: #8a8a86; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.frame .stage { position: relative; line-height: 0; }
.frame .pic { position: relative; }
.frame img { width: 100%; height: auto; display: block; cursor: zoom-in; }
.shot.tall .stage { max-height: 760px; overflow: hidden; }
.shot.tall .stage::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 90px;
  background: linear-gradient(transparent, rgba(14,14,14,.75)); pointer-events: none;
}
.shot.tall.open .stage { max-height: none; }
.shot.tall.open .stage::after { display: none; }
.expand {
  margin: 8px 0 0; font: 600 13px var(--sans); color: var(--brand-ink); background: none; border: 0; cursor: pointer; padding: 4px 0;
}

.hot {
  position: absolute; border: 2px solid var(--brand); border-radius: 6px; pointer-events: none;
  box-shadow: 0 0 0 3px rgba(232,86,42,.18); transition: box-shadow .15s, background .15s;
}
.hot.on { background: rgba(232,86,42,.12); box-shadow: 0 0 0 6px rgba(232,86,42,.32); }
.pin {
  position: absolute; width: 24px; height: 24px; margin: -12px 0 0 -12px; border-radius: 50%;
  background: var(--brand); color: #fff; font: 700 12px/24px var(--sans); text-align: center;
  border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.35); cursor: pointer; z-index: 2;
}
.pin.on { transform: scale(1.2); }
figcaption { font-size: 13.5px; color: var(--muted); margin-top: 10px; }
.legend {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 6px 16px;
  list-style: none; padding: 12px 14px; margin: 10px 0 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.legend li { display: flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: default; border-radius: 6px; padding: 2px 4px; margin: -2px -4px; }
.legend li:hover, .legend li.on { background: var(--brand-tint); }
.legend .num {
  flex: none; width: 20px; height: 20px; border-radius: 50%; background: var(--brand); color: #fff;
  font: 700 11px/20px var(--sans); text-align: center;
}
.anim .badge {
  position: absolute; top: 10px; right: 10px; z-index: 2; font: 700 10.5px/1 var(--mono); letter-spacing: .1em;
  background: var(--brand); color: #fff; padding: 5px 7px; border-radius: 5px; pointer-events: none;
}
.anim .ctl {
  position: absolute; bottom: 10px; right: 10px; z-index: 2; height: 30px; padding: 0 12px; border-radius: 999px;
  border: 0; background: rgba(14,14,14,.82); color: #fff; font: 600 12px var(--sans); cursor: pointer; backdrop-filter: blur(4px);
}
.anim .poster { position: absolute; inset: 28px 0 0; display: none; }
.anim.paused .poster { display: block; }
.anim.paused .poster canvas { width: 100%; height: 100%; display: block; }

.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 28px; align-items: start; }
.two > figure { margin-top: 4px; }

/* ── steps ───────────────────────────────────────────── */
ol.steps { counter-reset: s; list-style: none; padding: 0; margin: 14px 0; }
ol.steps > li { counter-increment: s; position: relative; padding: 0 0 14px 44px; }
ol.steps > li::before {
  content: counter(s); position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 8px;
  background: var(--surface); border: 1px solid var(--border-strong); font: 700 13px/26px var(--mono); text-align: center; color: var(--brand-ink);
}
ol.steps > li:not(:last-child)::after { content: ""; position: absolute; left: 14px; top: 32px; bottom: 4px; width: 1px; background: var(--border-strong); }
ol.steps > li > b:first-child { display: block; }

/* ── callouts ────────────────────────────────────────── */
.note {
  display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 10px; padding: 12px 16px; margin: 18px 0;
  border-radius: var(--radius); border: 1px solid; font-size: 14.5px; max-width: 820px;
}
.note::before { font-weight: 700; font-size: 15px; line-height: 1.55; }
.note p { margin: 0; }
.note.tip { background: var(--ok-bg); color: var(--ok-fg); border-color: var(--ok-bd); }
.note.tip::before { content: "✓"; }
.note.info { background: var(--info-bg); color: var(--info-fg); border-color: var(--info-bd); }
.note.info::before { content: "i"; font-family: Georgia, serif; font-style: italic; }
.note.warn { background: var(--warn-bg); color: var(--warn-fg); border-color: var(--warn-bd); }
.note.warn::before { content: "!"; }
.note.danger { background: var(--danger-bg); color: var(--danger-fg); border-color: var(--danger-bd); }
.note.danger::before { content: "⚠"; }
.note code { background: transparent; border-color: currentColor; opacity: .9; }

/* ── tables ──────────────────────────────────────────── */
.table-wrap { overflow-x: auto; margin: 14px 0 22px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; vertical-align: top; padding: 10px 14px; border-bottom: 1px solid var(--border); }
th { font: 600 11px var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--subtle); background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
td:first-child { white-space: nowrap; }
.ico {
  display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 7px;
  border: 1px solid var(--border-strong); background: var(--surface-2); vertical-align: middle; margin-right: 6px; color: var(--muted);
}
.ico svg { width: 15px; height: 15px; }
.pill { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 600; border: 1px solid; }
.pill.draft { background: var(--surface-2); color: var(--muted); border-color: var(--border-strong); }
.pill.scheduled { background: var(--info-bg); color: var(--info-fg); border-color: var(--info-bd); }
.pill.sending { background: var(--warn-bg); color: var(--warn-fg); border-color: var(--warn-bd); }
.pill.sent { background: var(--ok-bg); color: var(--ok-fg); border-color: var(--ok-bd); }
.pill.cancelled { background: var(--danger-bg); color: var(--danger-fg); border-color: var(--danger-bd); }
.yes { color: var(--ok-fg); font-weight: 700; }
.no { color: var(--subtle); }

/* state diagram */
.states { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 14px 0 20px; font-size: 13.5px; }
.states .arr { color: var(--subtle); }

/* lightbox */
.lightbox {
  position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.86); display: none;
  align-items: center; justify-content: center; padding: 24px; cursor: zoom-out;
}
.lightbox.open { display: flex; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.lightbox .close { position: absolute; top: 14px; right: 18px; color: #fff; font-size: 28px; background: none; border: 0; cursor: pointer; }

.to-top {
  position: fixed; right: 20px; bottom: 20px; z-index: 20; width: 42px; height: 42px; border-radius: 50%;
  background: var(--chrome); color: #fff; border: 1px solid #333; cursor: pointer; font-size: 18px; opacity: 0; pointer-events: none; transition: opacity .2s;
}
.to-top.show { opacity: 1; pointer-events: auto; }
.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 28px; }
.pager a { font-size: 14px; text-decoration: none; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); }
.pager a:hover { border-color: var(--brand); }
.pager span { display: block; font: 11px var(--mono); color: var(--subtle); letter-spacing: .1em; text-transform: uppercase; }
footer.foot { margin-top: 80px; padding-top: 20px; border-top: 1px solid var(--border); color: var(--subtle); font-size: 13px; }

/* ── responsive ──────────────────────────────────────── */
@media (max-width: 980px) {
  .two { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .menu-btn { display: inline-flex; }
  .topbar .version { display: none; }
  .sidebar { position: fixed; left: 0; top: 60px; width: min(var(--sidebar), 86vw); z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.5); }
  h1 { font-size: 30px; } h2 { font-size: 25px; }
  .flow .step { flex-basis: 100%; margin-right: 0; margin-bottom: 22px; }
  .flow .step:not(:last-child)::after { content: "↓"; right: auto; left: 50%; top: auto; bottom: -21px; transform: none; }
  .pin { width: 20px; height: 20px; margin: -10px 0 0 -10px; font-size: 10.5px; line-height: 20px; }
}

/* ── print ───────────────────────────────────────────── */
@media print {
  .topbar, .sidebar, .to-top, .pager, .expand, .anim .ctl { display: none !important; }
  .layout { display: block; }
  main { padding: 0; }
  .chapter { break-before: page; border: 0; }
  .shot.tall .stage { max-height: none; }
  .shot.tall .stage::after { display: none; }
  figure { break-inside: avoid; }
}
