/* ═══════════════════════════════════════════════════════════════════════════
   SyncEdge Clinic — /guide design system

   Single source of truth for the static Thai handbook bundle. Every page in
   frontend/public/guide/ links this file; nothing here is app-specific to one
   page. The token values MIRROR the React app's token layer
   (frontend/src/styles/globals.css) so the handbook and the product read as
   one system: dark-ink chrome, warm-paper content, clinical teal primary.

   Before 2026-08-20 each page carried its own byte-identical copy of ~85
   lines of "Warm Clinical Ledger" CSS (cream paper, pine green, honey amber,
   Bai Jamjuree) — a palette the app has never shipped. Restyling meant
   editing 14 files; now it means editing this one.

   When a token changes in globals.css, change it here too. The mapping is
   noted per line.
   ═════════════════════════════════════════════════════════════════════════ */

:root {
  /* ── Ground surfaces ─────────────────────────────────────────────────── */
  --paper: #faf8f4; /* --color-background / --color-paper */
  --paper-deep: #f5f0e8; /* --color-paper-deep */
  --card: #ffffff; /* --color-card */
  --line: #e2e8f0; /* --color-border */
  --line-warm: #e8e3d6; /* --color-border-warm / --color-input */
  --line-strong: #cbd5e1; /* slate-300 */

  /* ── Ink ─────────────────────────────────────────────────────────────── */
  --ink: #0f172a; /* --color-foreground */
  --ink-deep: #080e1b; /* --color-ink-deep (dark chrome floor) */
  --ink-soft: #475569; /* --color-muted-foreground (7:1 AAA) */
  --ink-faint: #64748b; /* --color-slate-500 */

  /* ── Brand — clinical teal ───────────────────────────────────────────── */
  --teal: #0f766e; /* --color-primary (AA on white, 5.47:1) */
  --teal-deep: #0d9488; /* --color-ring / --color-teal-dark */
  --teal-bright: #14b8a6; /* --color-teal / --color-success */
  --mint: #2dd4bf; /* --color-mint — the on-dark accent */
  --teal-wash: oklch(96% 0.02 195); /* --color-tone-teal-bg */
  --teal-ink: oklch(28% 0.1 195); /* --color-tone-teal-fg */
  --cyan: #0891b2; /* --color-info — eyebrow / micro-label accent */

  /* ── Semantic feedback ───────────────────────────────────────────────── */
  --amber: #f59e0b; /* --color-warning */
  --amber-ink: oklch(38% 0.14 75); /* --color-tone-ochre-fg */
  --amber-wash: oklch(97% 0.025 75); /* --color-tone-ochre-bg */
  --brick: oklch(60% 0.18 28); /* --color-tone-brick-border */
  --brick-ink: oklch(40% 0.16 28); /* --color-tone-brick-fg */
  --brick-wash: oklch(96% 0.035 28); /* --color-tone-brick-bg */
  --lilac: oklch(62% 0.08 290); /* --color-tone-lilac-border (specialty lens) */
  --lilac-ink: oklch(32% 0.08 290); /* --color-tone-lilac-fg */
  --lilac-wash: oklch(96% 0.02 290); /* --color-tone-lilac-bg */

  /* ── Shape & depth ───────────────────────────────────────────────────── */
  --r-sm: 6px; /* --radius-sm */
  --r-md: 10px; /* --radius */
  --r: 14px; /* --radius-lg — the card default */
  --r-lg: 16px; /* --radius-xl */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 12px 28px -20px rgba(15, 23, 42, 0.35);
  --shadow-lift: 0 1px 2px rgba(15, 23, 42, 0.05), 0 22px 44px -24px rgba(15, 23, 42, 0.4);
  --ease: cubic-bezier(0.32, 0.72, 0, 1); /* --ease-clinical */

  /* ── Type ────────────────────────────────────────────────────────────── */
  --font-sans: 'DM Sans', 'IBM Plex Sans Thai', system-ui, sans-serif;
  --font-display: 'Plus Jakarta Sans', 'IBM Plex Sans Thai', system-ui, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Content column. Detail pages read as prose (1080px); the atlas and the
     long-form handbooks override this to 1180px for their card grids. */
  --wrap: 1080px;

  /* ── Legacy aliases ──────────────────────────────────────────────────────
     The two long-form handbooks (stock-management, patient-order) still name
     colours in the old vocabulary inside their page-local CSS. Aliasing keeps
     one palette without rewriting those bespoke layouts. */
  --pine: var(--teal);
  --pine-deep: var(--ink-deep);
  --pine-glow: var(--teal-bright);
  --honey: var(--cyan);
  --honey-soft: var(--line-strong);
  --rust: var(--brick);
  --plum: var(--lilac);
}

/* ═══ Base ════════════════════════════════════════════════════════════════ */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html {
  scroll-behavior: smooth;
}
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  line-height: 1.7; /* --line-height-thai-body */
  -webkit-font-smoothing: antialiased;
  position: relative;
  overflow-x: hidden;
}
h1,
h2,
h3,
h4,
.display {
  font-family: var(--font-display);
  letter-spacing: -0.01em;
}
.mono {
  font-family: var(--font-mono);
}
.wrap {
  position: relative;
  z-index: 1;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 24px;
}
::selection {
  background: var(--teal-wash);
  color: var(--teal-ink);
}
a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--teal-deep); /* SC 2.4.13 */
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* ═══ Dark chrome header ══════════════════════════════════════════════════
   The app pairs an ink sidebar with warm-paper content. Every guide page's
   <header> is that same chrome: full-bleed ink with the faint teal grid the
   login split-screen uses. Content below stays on paper. */

header {
  position: relative;
  background: linear-gradient(165deg, var(--ink-deep), var(--ink));
  color: #f1f5f9;
  padding: 54px 0 30px;
  border-bottom: 1px solid rgba(45, 212, 191, 0.16);
  overflow: hidden;
}
header::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(45, 212, 191, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(45, 212, 191, 0.055) 1px, transparent 1px);
  background-size: 52px 52px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.9), transparent 92%);
  -webkit-mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.9), transparent 92%);
}
header h1 {
  color: #f8fafc;
  font-size: clamp(2.1rem, 5.2vw, 3.6rem);
  font-weight: 700;
  line-height: 1.06;
  margin: 22px 0 0;
  max-width: 22ch;
}
header .lede,
header .blurb {
  color: #cbd5e1;
}
/* Emphasised word in a hero headline — mint text over a thin fading rule,
   the treatment the login hero gives its logo lockup. (The old warm design
   put a skewed highlighter bar behind the word at z-index:-1; on the dark
   chrome that slab escapes the header gradient and reads as a smudge.) */
h1 .hl {
  position: relative;
  white-space: nowrap;
  color: var(--mint);
}
h1 .hl::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -0.04em;
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--mint), rgba(45, 212, 191, 0));
}

/* ═══ Links & nav chips ═══════════════════════════════════════════════════ */

.back {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.86rem;
  color: var(--teal);
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1.5px solid var(--line-strong);
  padding-bottom: 1px;
  transition: 0.18s var(--ease);
}
.back:hover {
  border-bottom-color: var(--teal-deep);
}
header .back {
  color: var(--mint);
  border-bottom-color: rgba(45, 212, 191, 0.4);
}
header .back:hover {
  border-bottom-color: var(--mint);
}

/* Cross-domain nav rail (detail pages) — sits on the dark header. */
.domnav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 14px;
}
.domnav a {
  font-size: 0.78rem;
  text-decoration: none;
  color: #cbd5e1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  padding: 4px 11px;
  transition: 0.15s var(--ease);
}
.domnav a:hover {
  border-color: var(--mint);
  color: #f8fafc;
}
.domnav a.cur {
  background: var(--teal);
  color: #ffffff;
  border-color: var(--teal-deep);
}
.domnav a.rg {
  background: rgba(8, 145, 178, 0.16);
  border-color: rgba(6, 182, 212, 0.45);
  color: #67e8f9;
  font-weight: 600;
}
.domnav a.sp {
  background: rgba(167, 139, 250, 0.14);
  border-color: rgba(167, 139, 250, 0.4);
  color: #ddd6fe;
  font-weight: 600;
}
.domnav a.sp.cur {
  background: var(--lilac);
  color: #ffffff;
  border-color: var(--lilac);
}

/* ═══ Detail-page masthead ════════════════════════════════════════════════ */

.dhead {
  display: flex;
  gap: 18px;
  align-items: center;
  margin-top: 22px;
}
.demoji {
  width: 62px;
  height: 62px;
  border-radius: var(--r-lg);
  background: var(--teal);
  display: grid;
  place-items: center;
  font-size: 1.9rem;
  box-shadow:
    0 0 0 1px rgba(45, 212, 191, 0.3),
    0 16px 32px -18px rgba(13, 148, 136, 0.9);
}
.dk {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mint);
}
.dhead h1 {
  font-size: clamp(2rem, 4.6vw, 3rem);
  font-weight: 700;
  line-height: 1.06;
  margin: 2px 0;
}
.blurb {
  color: var(--ink-soft);
  margin-top: 14px;
  max-width: 80ch;
}

/* ═══ Guide search (search.js) ════════════════════════════════════════════
   The index is fetched lazily on first focus (search.js), so this bar is
   just an input + a results host until then — no spinner, no skeleton. */

.searchbar {
  padding: 18px 24px 0;
}
.searchbar input {
  width: 100%;
  display: block;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line-warm);
  border-radius: var(--r-md);
  padding: 11px 16px;
  transition: 0.18s var(--ease);
}
.searchbar input::placeholder {
  color: var(--ink-faint);
}
.searchbar input:focus {
  border-color: var(--teal-deep);
}
#guide-results:not(:empty) {
  margin-top: 10px;
}
#guide-results h4 {
  font-family: var(--font-mono);
  font-size: 0.64rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 14px 0 6px;
}
#guide-results ul {
  list-style: none;
  display: grid;
  gap: 6px;
}
#guide-results li a {
  display: block;
  padding: 10px 14px;
  background: var(--card);
  border: 1px solid var(--line-warm);
  border-radius: var(--r-md);
  color: var(--ink);
  text-decoration: none;
  font-size: 0.9rem;
  transition: 0.15s var(--ease);
}
#guide-results li a:hover {
  border-color: var(--teal-deep);
  background: var(--teal-wash);
  color: var(--teal-ink);
}
#guide-results .gs-empty {
  text-align: center;
  color: var(--ink-faint);
  padding: 18px 0 10px;
}
/* Scoped to the search dead-end only — the footer's own .report .btn is
   unstyled pending a later task's pass over the report-exit CSS. */
#guide-results .btn {
  display: inline-flex;
  width: 100%;
  justify-content: center;
  align-items: center;
  gap: 6px;
  font-size: 0.86rem;
  font-weight: 600;
  color: #ffffff;
  background: var(--teal);
  border-radius: 999px;
  padding: 9px 18px;
  text-decoration: none;
  transition: 0.18s var(--ease);
}
#guide-results .btn:hover {
  background: var(--teal-deep);
}

/* ═══ Sticky section index ════════════════════════════════════════════════ */

.toc {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(250, 248, 244, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 11px 0;
}
.toc .wrap {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  align-items: center;
}
.toc .lbl {
  font-family: var(--font-mono);
  font-size: 0.64rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-right: 4px;
}
.tchip {
  font-size: 0.82rem;
  text-decoration: none;
  color: var(--ink-soft);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 11px;
  transition: 0.18s var(--ease);
}
.tchip:hover {
  border-color: var(--teal-deep);
  color: var(--teal);
  background: var(--teal-wash);
}

/* ═══ Feature section (detail pages) ══════════════════════════════════════ */

.fsec {
  background: var(--card);
  border: 1px solid var(--line-warm);
  border-radius: var(--r);
  padding: 28px;
  margin: 22px 0;
  scroll-margin-top: 74px;
  box-shadow: var(--shadow-sm);
}
.fsec.internal {
  opacity: 0.72;
}
.fsec-head h2 {
  font-size: clamp(1.3rem, 2.6vw, 1.7rem);
  font-weight: 600;
  line-height: 1.25;
}
.fsec-en {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-faint);
  margin-top: 3px;
}
.tier {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 600;
  background: var(--amber-wash);
  color: var(--amber-ink);
  padding: 2px 8px;
  border-radius: var(--r-sm);
  vertical-align: middle;
  margin-left: 6px;
}
.intbadge {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 600;
  background: var(--paper-deep);
  color: var(--ink-faint);
  padding: 2px 8px;
  border-radius: var(--r-sm);
  vertical-align: middle;
  margin-left: 6px;
}
.who {
  font-size: 0.84rem;
  color: var(--ink-soft);
  margin-top: 10px;
}
.who .wl,
.fc-who .wl {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--teal-ink);
  background: var(--teal-wash);
  padding: 2px 7px;
  border-radius: var(--r-sm);
  margin-right: 6px;
}
.ov {
  margin: 14px 0 4px;
  color: var(--ink-soft);
  font-size: 1.02rem;
}

/* App screenshot figure */
.shot {
  margin: 16px 0 4px;
  border: 1px solid var(--line-warm);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--paper-deep);
  box-shadow: var(--shadow);
}
.shot img {
  display: block;
  width: 100%;
  height: auto;
}
.shot figcaption {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding: 8px 12px;
  border-top: 1px solid var(--line-warm);
  background: var(--card);
}
.shot .emptynote {
  color: var(--amber-ink);
  text-transform: none;
  letter-spacing: 0;
}

/* The one-thing-that-bites callout */
.keycall {
  background: var(--brick-wash);
  border: 1px solid var(--brick);
  border-left: 4px solid var(--brick);
  border-radius: var(--r-md);
  padding: 12px 15px;
  margin: 14px 0 4px;
  font-size: 0.95rem;
  color: var(--ink);
}
.keycall b {
  color: var(--brick-ink);
}

/* ═══ Content blocks ══════════════════════════════════════════════════════ */

.blk {
  margin-top: 20px;
}
.blk h3 {
  font-size: 1.02rem;
  font-weight: 600;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
ul.kf,
ul.got,
ul.tips,
ul.perm {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
ul.kf li {
  padding-left: 22px;
  position: relative;
  font-size: 0.95rem;
}
ul.kf li::before {
  content: '◆';
  position: absolute;
  left: 0;
  color: var(--teal-bright);
  font-size: 0.7rem;
  top: 5px;
}
ol.steps {
  list-style: none;
  counter-reset: s;
  display: flex;
  flex-direction: column;
  gap: 11px;
}
ol.steps li {
  counter-increment: s;
  position: relative;
  padding-left: 42px;
  min-height: 30px;
}
ol.steps li::before {
  content: counter(s);
  position: absolute;
  left: 0;
  top: 0;
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm);
  background: var(--teal);
  color: #ffffff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9rem;
  display: grid;
  place-items: center;
}
ol.steps li b {
  display: block;
  font-weight: 600;
  font-size: 0.96rem;
}
ol.steps li span {
  color: var(--ink-soft);
  font-size: 0.9rem;
}
ul.got li,
ul.tips li {
  padding: 10px 13px;
  border-radius: var(--r-md);
  font-size: 0.9rem;
}
ul.got li {
  background: var(--amber-wash);
  border: 1px solid var(--amber);
  color: var(--ink-soft);
}
ul.tips li {
  background: var(--teal-wash);
  border: 1px solid var(--teal-deep);
  color: var(--ink-soft);
}
ul.perm li {
  font-size: 0.9rem;
  color: var(--ink-soft);
  padding-left: 20px;
  position: relative;
}
ul.perm li::before {
  content: '🔑';
  position: absolute;
  left: 0;
  font-size: 0.8rem;
}

/* Deep-handbook call-to-action — mirrors the app's primary button. */
.fbook {
  display: inline-block;
  margin-top: 16px;
  font-size: 0.86rem;
  font-weight: 600;
  color: #ffffff;
  text-decoration: none;
  background: var(--teal);
  border: 1px solid var(--teal);
  border-radius: var(--r-md);
  padding: 8px 14px;
  transition: 0.18s var(--ease);
}
.fbook:hover {
  background: var(--teal-deep);
  border-color: var(--teal-deep);
}
.totop {
  display: inline-block;
  margin-top: 14px;
  margin-left: 12px;
  font-size: 0.8rem;
  color: var(--ink-faint);
  text-decoration: none;
}

/* ═══ Atlas hero (index.html) ═════════════════════════════════════════════ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 7px 15px;
  border-radius: 999px;
  background: rgba(45, 212, 191, 0.1);
  border: 1px solid rgba(45, 212, 191, 0.35);
  color: #99f6e4;
  font-size: 0.78rem;
  font-weight: 500;
}
.badge .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--mint);
  animation: pulse 2.4s infinite;
}
@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(45, 212, 191, 0.6);
  }
  70% {
    box-shadow: 0 0 0 9px rgba(45, 212, 191, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(45, 212, 191, 0);
  }
}
.lede {
  font-size: clamp(1.02rem, 2vw, 1.25rem);
  color: var(--ink-soft);
  max-width: 60ch;
  margin-top: 20px;
}
.hstats {
  display: flex;
  gap: 26px;
  margin-top: 24px;
  flex-wrap: wrap;
}
.hstat .n {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 2.1rem;
  color: var(--mint);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.hstat .l {
  font-size: 0.82rem;
  color: #94a3b8;
}
.navchips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 26px;
}
.navchip {
  font-size: 0.84rem;
  text-decoration: none;
  color: #cbd5e1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  padding: 6px 13px;
  transition: 0.2s var(--ease);
}
.navchip:hover {
  border-color: var(--mint);
  color: #f8fafc;
  transform: translateY(-2px);
}
.navchip.sp {
  background: rgba(167, 139, 250, 0.14);
  border-color: rgba(167, 139, 250, 0.4);
  color: #ddd6fe;
  font-weight: 600;
}
.navchip.sp:hover {
  border-color: #c4b5fd;
  color: #ede9fe;
}
.quickstart {
  margin-top: 18px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(45, 212, 191, 0.3);
  border-radius: var(--r);
  padding: 13px 17px;
  font-size: 0.94rem;
  color: #cbd5e1;
  max-width: 80ch;
}
.quickstart b {
  color: #f8fafc;
}
.quickstart a {
  color: var(--mint);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1.5px solid rgba(45, 212, 191, 0.45);
}

/* ═══ Atlas filter bar + feature grid ═════════════════════════════════════ */

.filterbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(250, 248, 244, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
}
.filterbar .wrap {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
}
.pills {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}
.pill {
  font-family: var(--font-sans);
  font-size: 0.86rem;
  font-weight: 500;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 7px 13px;
  cursor: pointer;
  transition: 0.18s var(--ease);
}
.pill b {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--cyan);
  margin-left: 3px;
}
.pill:hover {
  border-color: var(--teal-deep);
}
.pill.active {
  background: var(--teal);
  color: #ffffff;
  border-color: var(--teal);
}
.pill.active b {
  color: #99f6e4;
}
.search {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--line-warm);
  border-radius: 999px;
  padding: 6px 14px;
}
.search input {
  border: none;
  background: none;
  outline: none;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: var(--ink);
  width: 170px;
}
.noresult {
  display: none;
  text-align: center;
  color: var(--ink-faint);
  padding: 50px 0;
}

.domsec {
  padding: 44px 0 6px;
}
.dom-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
  margin-bottom: 22px;
}
.dom-emoji {
  width: 58px;
  height: 58px;
  border-radius: var(--r);
  background: var(--teal);
  display: grid;
  place-items: center;
  font-size: 1.7rem;
  box-shadow: 0 16px 32px -18px rgba(13, 148, 136, 0.85);
}
.dom-emoji.sp {
  background: var(--lilac);
  box-shadow: 0 16px 32px -18px var(--lilac);
}
.dom-k {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--cyan);
}
.dom-head h2 {
  font-size: clamp(1.4rem, 3vw, 2rem);
  font-weight: 600;
  margin: 2px 0;
}
.dom-blurb {
  color: var(--ink-soft);
  font-size: 0.95rem;
  max-width: 80ch;
}
.dom-count {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 2rem;
  color: var(--teal);
  text-align: center;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.dom-count span {
  display: block;
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--ink-faint);
}

.fgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}
.fcard {
  background: var(--card);
  border: 1px solid var(--line-warm);
  border-radius: var(--r);
  padding: 20px;
  transition:
    transform 0.3s var(--ease),
    box-shadow 0.3s var(--ease),
    border-color 0.3s var(--ease);
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-sm);
}
.fcard:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lift);
  border-color: var(--line-strong);
}
.fcard.internal {
  opacity: 0.66;
}
.fc-head h3 {
  font-size: 1.08rem;
  font-weight: 600;
  line-height: 1.3;
}
.fc-en {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--ink-faint);
  letter-spacing: 0.02em;
  margin-top: 2px;
}
.fc-what {
  color: var(--ink-soft);
  font-size: 0.92rem;
}
.fc-who {
  font-size: 0.82rem;
  color: var(--ink-soft);
}
.fc-act {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.fc-act li {
  font-size: 0.86rem;
  color: var(--ink);
  padding-left: 16px;
  position: relative;
}
.fc-act li::before {
  content: '→';
  position: absolute;
  left: 0;
  color: var(--teal-deep);
  font-weight: 700;
}
.cgotcha {
  display: flex;
  gap: 8px;
  background: var(--amber-wash);
  border: 1px solid var(--amber);
  border-radius: var(--r-md);
  padding: 9px 11px;
  margin-top: auto;
}
.cgotcha span {
  flex: 0 0 auto;
}
.cgotcha p {
  font-size: 0.82rem;
  color: var(--ink-soft);
}
.clinks {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 2px;
}
.cbook {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--teal);
  text-decoration: none;
  border-bottom: 1.5px solid var(--line-strong);
}
.cbook:hover {
  border-bottom-color: var(--teal-deep);
}
.cbook.alt {
  color: var(--cyan);
}

/* ═══ Flow diagram — the app's dark chrome, inverted out of the paper ═════ */

.flowdiag {
  background: linear-gradient(165deg, var(--ink-deep), var(--ink));
  border-radius: var(--r-lg);
  padding: 24px 20px;
  color: #e2e8f0;
  position: relative;
  overflow: hidden;
  box-shadow: 0 28px 56px -34px rgba(15, 23, 42, 0.7);
  margin: 16px 0;
}
.flowdiag::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(45, 212, 191, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(45, 212, 191, 0.05) 1px, transparent 1px);
  background-size: 44px 44px;
}
.flowdiag > * {
  position: relative;
}
.flowdiag .fd-title {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--mint);
  margin-bottom: 14px;
}
.fstrip {
  display: flex;
  align-items: stretch;
  gap: 5px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.fnode {
  flex: 1 0 0;
  min-width: 94px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: var(--r-md);
  padding: 11px 8px;
  text-align: center;
  transition: 0.3s var(--ease);
}
.fnode:hover {
  background: rgba(255, 255, 255, 0.11);
  transform: translateY(-2px);
}
.fnode .e {
  font-size: 1.3rem;
  line-height: 1;
}
.fnode .t {
  font-size: 0.82rem;
  font-weight: 600;
  margin-top: 4px;
}
.fnode .s {
  font-size: 0.64rem;
  opacity: 0.62;
  margin-top: 1px;
}
.fnode.hot {
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 14px 30px -16px rgba(0, 0, 0, 0.7);
  border-color: rgba(45, 212, 191, 0.55);
}
.fnode.hot .t {
  color: var(--teal);
}
.fnode.hot .s {
  color: var(--cyan);
  opacity: 1;
  font-weight: 600;
}
.fconn {
  flex: 0 0 22px;
  align-self: center;
  position: relative;
  height: 3px;
  background: rgba(255, 255, 255, 0.16);
  border-radius: 2px;
  overflow: visible;
}
.fconn .fdot {
  position: absolute;
  top: 50%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 8px var(--mint);
  transform: translate(0, -50%);
  animation: flowtravel 2.4s linear infinite;
}
.fconn .fdot:nth-child(2) {
  animation-delay: 1.2s;
}
@keyframes flowtravel {
  0% {
    left: -3px;
    opacity: 0;
  }
  12% {
    opacity: 1;
  }
  88% {
    opacity: 1;
  }
  100% {
    left: calc(100% + 3px);
    opacity: 0;
  }
}
.flane {
  margin-top: 14px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 12px;
  align-items: center;
  font-size: 0.86rem;
}
.flane .lk {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.72;
  text-align: right;
  white-space: nowrap;
}
.flane .lv {
  opacity: 0.92;
}
.flane .lv b {
  color: var(--mint);
}
.dmap-base {
  margin-top: 14px;
  font-size: 0.85rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px dashed rgba(255, 255, 255, 0.22);
  border-radius: var(--r-md);
  padding: 11px 14px;
  line-height: 1.8;
}
.dmap-base .bl {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--mint);
  margin-right: 8px;
}

/* ═══ Role cheat-sheet (role-guide-th.html) ═══════════════════════════════ */

.rgrid {
  column-count: 2;
  column-gap: 20px;
  margin-top: 20px;
}
.rsec {
  break-inside: avoid;
  background: var(--card);
  border: 1px solid var(--line-warm);
  border-radius: var(--r);
  padding: 18px 20px;
  margin-bottom: 18px;
  display: inline-block;
  width: 100%;
  box-shadow: var(--shadow-sm);
}
.rsec h2 {
  font-size: 1.12rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--line);
}
.rc {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--cyan);
  margin-left: auto;
}
.day1 {
  background: linear-gradient(165deg, var(--ink-deep), var(--ink));
  color: #e2e8f0;
  border-radius: var(--r-md);
  padding: 13px 15px;
  margin-bottom: 12px;
}
.day1-h {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--mint);
  margin-bottom: 8px;
}
.day1-l {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.day1-l li {
  font-size: 0.86rem;
}
.rsub {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 8px;
}
.rlist .rcommon {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.56rem;
  background: var(--teal-wash);
  color: var(--teal-ink);
  padding: 1px 6px;
  border-radius: var(--r-sm);
  vertical-align: middle;
  margin-left: 4px;
}
.rlist {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.rlist li {
  font-size: 0.9rem;
}
.rlist a {
  color: var(--ink);
  text-decoration: none;
  display: block;
  font-weight: 600;
}
.rlist a:hover b {
  color: var(--teal);
}
.rlist span {
  display: block;
  color: var(--ink-soft);
  font-size: 0.82rem;
}

/* ═══ Footer ══════════════════════════════════════════════════════════════ */

footer {
  padding: 46px 0 70px;
  text-align: center;
  color: var(--ink-faint);
  font-size: 0.86rem;
}
footer .logo {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--ink);
}
footer .logo span {
  color: var(--teal);
}

/* ═══ Motion & media ══════════════════════════════════════════════════════ */

.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition:
    opacity 0.6s ease,
    transform 0.6s var(--ease);
}
.reveal.in {
  opacity: 1;
  transform: none;
}

@media (max-width: 760px) {
  .rgrid {
    column-count: 1;
  }
}
@media (max-width: 680px) {
  .dom-head {
    grid-template-columns: auto 1fr;
  }
  .dom-count {
    display: none;
  }
  .search {
    margin-left: 0;
    width: 100%;
  }
  .search input {
    width: 100%;
  }
}

@media print {
  body {
    background: #fff;
  }
  header {
    background: #fff;
    color: var(--ink);
    border-bottom: 2px solid var(--line);
  }
  header::before {
    display: none;
  }
  header h1 {
    color: var(--ink);
  }
  header .lede,
  header .blurb {
    color: var(--ink-soft);
  }
  header .back,
  .toc,
  .filterbar,
  .navchips,
  .domnav,
  .search {
    display: none;
  }
  .fsec,
  .fcard,
  .rsec {
    break-inside: avoid;
    box-shadow: none;
  }
  .flowdiag {
    box-shadow: none;
  }
  * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
  .reveal {
    opacity: 1;
    transform: none;
  }
  .fconn .fdot {
    display: none;
  }
}
