:root {
  --bg: #f6f3ec;
  --paper: #ffffff;
  --ink: #1d2230;
  --muted: #5b6272;
  --line: #d9d3c6;
  --blue: #2f62d9;
  --blue-soft: #e3ebfd;
  --green: #0f9a76;
  --green-soft: #dcf4ec;
  --amber: #c9811a;
  --amber-soft: #fdf0d9;
  --purple: #7a52e0;
  --purple-soft: #ece5fd;
  --orange: #e0582c;
  --orange-soft: #fde6dc;
  --good: #1f9d55;
  --good-soft: #dcf3e5;
  --bad: #d23c3c;
  --bad-soft: #fbe1e1;
  --warn: #a87300;
  --warn-soft: #fdf1cf;
  --mark: #ffd84d;
  --shadow: 0 2px 0 var(--line), 0 10px 30px rgba(29, 34, 48, 0.07);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14171f;
    --paper: #1e222d;
    --ink: #eef0f5;
    --muted: #a3aab9;
    --line: #333949;
    --blue-soft: #1d2a4d;
    --green-soft: #133a30;
    --amber-soft: #3d2d12;
    --purple-soft: #2c2346;
    --orange-soft: #43241a;
    --good-soft: #15362a;
    --bad-soft: #432020;
    --warn-soft: #3d3112;
    --blue: #7ea2ff;
    --green: #3fd0a6;
    --amber: #f0ac45;
    --purple: #a98bff;
    --orange: #ff8a63;
    --good: #4fd18a;
    --bad: #ff7a7a;
    --warn: #f1c552;
    --shadow: 0 1px 0 #2a2f3c, 0 10px 30px rgba(0, 0, 0, 0.35);
  }
}
:root[data-theme="dark"] {
  --bg: #14171f;
  --paper: #1e222d;
  --ink: #eef0f5;
  --muted: #a3aab9;
  --line: #333949;
  --blue-soft: #1d2a4d;
  --green-soft: #133a30;
  --amber-soft: #3d2d12;
  --purple-soft: #2c2346;
  --orange-soft: #43241a;
  --good-soft: #15362a;
  --bad-soft: #432020;
  --warn-soft: #3d3112;
  --blue: #7ea2ff;
  --green: #3fd0a6;
  --amber: #f0ac45;
  --purple: #a98bff;
  --orange: #ff8a63;
  --good: #4fd18a;
  --bad: #ff7a7a;
  --warn: #f1c552;
  --shadow: 0 1px 0 #2a2f3c, 0 10px 30px rgba(0, 0, 0, 0.35);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 76px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Avenir Next", Avenir, -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: 18px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); }
img, video { max-width: 100%; display: block; }
.progress { position: fixed; top: 0; left: 0; height: 4px; background: var(--orange); z-index: 30; width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: 10px 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}
.topbar .home { font-weight: 700; color: var(--ink); text-decoration: none; white-space: nowrap; }
.topbar nav { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.topbar nav a { text-decoration: none; color: var(--muted); padding: 6px 12px; border-radius: 999px; white-space: nowrap; font-weight: 600; }
.topbar nav a.on { background: var(--ink); color: var(--bg); }
.topbar .where { margin-left: auto; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40%; }
main { max-width: 1060px; margin: 0 auto; padding: 0 16px 80px; }
.hero { padding: 48px 0 18px; }
.kicker { display: inline-flex; align-items: center; gap: 8px; background: var(--ink); color: var(--bg); border-radius: 999px; padding: 5px 14px; font-size: 14px; font-weight: 700; letter-spacing: .02em; }
h1 { font-size: clamp(34px, 6vw, 56px); line-height: 1.08; margin: 16px 0 12px; letter-spacing: -.015em; }
h2 { font-size: clamp(26px, 4vw, 36px); line-height: 1.15; margin: 56px 0 14px; letter-spacing: -.01em; }
h3 { font-size: 22px; line-height: 1.25; margin: 0 0 6px; }
h4 { font-size: 17px; margin: 0 0 8px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.lead { font-size: clamp(19px, 2.4vw, 23px); color: var(--muted); max-width: 760px; }
.muted { color: var(--muted); }
.small { font-size: 15px; }
.card { background: var(--paper); border-radius: 20px; padding: 20px 22px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.ic { font-size: 36px; line-height: 1; margin-bottom: 8px; }
.tag { display: inline-block; border-radius: 9px; padding: 2px 10px; font-size: 14px; font-weight: 700; margin: 2px 4px 2px 0; white-space: nowrap; }
.t-blue { background: var(--blue-soft); color: var(--blue); }
.t-green { background: var(--green-soft); color: var(--green); }
.t-amber { background: var(--amber-soft); color: var(--amber); }
.t-purple { background: var(--purple-soft); color: var(--purple); }
.t-orange { background: var(--orange-soft); color: var(--orange); }
.t-good { background: var(--good-soft); color: var(--good); }
.t-bad { background: var(--bad-soft); color: var(--bad); }
.t-warn { background: var(--warn-soft); color: var(--warn); }
.mark { background: linear-gradient(transparent 58%, color-mix(in srgb, var(--mark) 70%, transparent) 58%); padding: 0 2px; }
.mono { font-family: "SF Mono", Menlo, Consolas, monospace; font-size: .9em; }
code { font-family: "SF Mono", Menlo, Consolas, monospace; font-size: .88em; background: var(--paper); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; overflow-wrap: anywhere; }

/* Video */
.player { margin: 22px 0 10px; border-radius: 18px; overflow: hidden; background: #000; box-shadow: var(--shadow); aspect-ratio: 16 / 9; }
.player video { width: 100%; height: 100%; }
.chapters { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 0; padding: 0; list-style: none; }
.chapters button { font: inherit; font-size: 14px; font-weight: 600; border: 1px solid var(--line); background: var(--paper); color: var(--ink); border-radius: 999px; padding: 6px 12px; cursor: pointer; }
.chapters button span { color: var(--muted); font-weight: 500; margin-right: 6px; font-variant-numeric: tabular-nums; }
.chapters button:hover { border-color: var(--orange); }

/* Choose cards */
.choose { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); margin-top: 18px; }
.choose a { text-decoration: none; color: inherit; display: block; border: 2px solid transparent; transition: border-color .15s, transform .15s; }
.choose a:hover { border-color: var(--orange); transform: translateY(-2px); }
.big-num { font-size: 64px; font-weight: 800; line-height: 1; letter-spacing: -.03em; }

/* Flow strip: the whole pipeline at a glance */
.flow { display: flex; flex-wrap: wrap; gap: 8px; align-items: stretch; margin: 16px 0; }
.flow a { text-decoration: none; color: var(--ink); display: flex; align-items: center; gap: 8px; background: var(--paper); border-radius: 14px; padding: 8px 12px 8px 8px; box-shadow: var(--shadow); font-weight: 600; font-size: 15px; border: 2px solid transparent; }
.flow a:hover { border-color: var(--orange); }
.flow .n { width: 30px; height: 30px; flex: 0 0 30px; border-radius: 50%; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 800; }
.grp-research .n, .n.grp-research { background: var(--blue); }
.grp-write .n, .n.grp-write { background: var(--green); }
.grp-check .n, .n.grp-check { background: var(--purple); }
.grp-images .n, .n.grp-images { background: var(--amber); }
.grp-polish .n, .n.grp-polish { background: var(--orange); }
.grp-finish .n, .n.grp-finish { background: #1d2230; }
:root[data-theme="dark"] .grp-finish .n, :root[data-theme="dark"] .n.grp-finish { background: #5b6272; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .grp-finish .n, :root:not([data-theme="light"]) .n.grp-finish { background: #5b6272; } }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 14px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 14px; border-radius: 50%; display: inline-block; }

/* Stage sections */
.stage { margin-top: 64px; scroll-margin-top: 76px; }
.stage-head { display: flex; align-items: center; gap: 16px; }
.stage-head .n { width: 58px; height: 58px; flex: 0 0 58px; border-radius: 50%; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 800; }
.stage-head h2 { margin: 0; }
.stage-head .sub { color: var(--muted); font-size: 15px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.oneline { font-size: 21px; margin: 14px 0 18px; }
.ioflow { display: grid; grid-template-columns: 1fr auto 1.7fr auto 1fr; gap: 10px; align-items: stretch; }
.ioflow .arrow { display: flex; align-items: center; justify-content: center; font-size: 30px; color: var(--muted); font-weight: 800; }
.ioflow ul, .card ul { margin: 6px 0 0; padding-left: 20px; }
.ioflow li, .card li { margin: 4px 0; }
.steps { list-style: none; padding: 0; margin: 6px 0 0; counter-reset: s; }
.steps li { counter-increment: s; position: relative; padding: 8px 0 8px 42px; border-bottom: 1px dashed var(--line); }
.steps li:last-child { border-bottom: 0; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 8px; width: 28px; height: 28px; border-radius: 50%; background: var(--ink); color: var(--bg); font-size: 14px; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.in-card { border-top: 6px solid var(--blue); }
.do-card { border-top: 6px solid var(--ink); }
.out-card { border-top: 6px solid var(--good); }
.facts { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); margin-top: 14px; }
.facts .card { padding: 16px 18px; }
.like { display: flex; gap: 14px; align-items: flex-start; background: var(--amber-soft); border-radius: 18px; padding: 16px 18px; margin-top: 14px; }
.like .ic { margin: 0; font-size: 32px; }
.skip { background: var(--warn-soft); }
.warnbox { background: var(--bad-soft); }
.goodbox { background: var(--good-soft); }
.tools { margin-top: 10px; }
details { background: var(--paper); border-radius: 16px; padding: 12px 18px; box-shadow: var(--shadow); margin-top: 14px; }
details summary { cursor: pointer; font-weight: 700; }
details[open] summary { margin-bottom: 8px; }

/* Mapping diagram: 20 stages into 8 */
.map { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.map .col { display: flex; flex-direction: column; gap: 6px; }
.map .row20 { display: flex; align-items: center; gap: 10px; background: var(--paper); border-radius: 12px; padding: 6px 10px; box-shadow: var(--shadow); font-size: 15px; font-weight: 600; }
.map .row20 .n { width: 26px; height: 26px; flex: 0 0 26px; font-size: 12px; }
.map .box8 { border-radius: 16px; padding: 12px 14px; color: #fff; font-weight: 700; display: flex; flex-direction: column; justify-content: center; }
.map .box8 small { font-weight: 500; opacity: .85; font-size: 14px; }
.tablewrap { overflow-x: auto; border-radius: 16px; box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; background: var(--paper); font-size: 16px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 14px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
.gloss { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.gloss div { background: var(--paper); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow); }
.gloss b { display: block; }
.toc { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 0; }
.toc a { text-decoration: none; color: var(--ink); background: var(--paper); border-radius: 999px; padding: 6px 12px; font-size: 14px; font-weight: 600; box-shadow: var(--shadow); }
.toc a.on { background: var(--ink); color: var(--bg); }
footer { max-width: 1060px; margin: 0 auto; padding: 24px 16px 60px; color: var(--muted); font-size: 14px; border-top: 1px solid var(--line); }
.next { display: flex; justify-content: space-between; gap: 12px; margin-top: 50px; flex-wrap: wrap; }
.next a { text-decoration: none; }

@media (max-width: 760px) {
  body { font-size: 17px; }
  .ioflow { grid-template-columns: 1fr; }
  .ioflow .arrow { transform: rotate(90deg); padding: 2px 0; }
  .map { grid-template-columns: 1fr; }
  .topbar .where { display: none; }
  .stage-head .n { width: 48px; height: 48px; flex-basis: 48px; font-size: 22px; }
}
/* side cards sit at the top instead of stretching beside a long step list */
.ioflow { align-items: start; }
.ioflow .arrow { align-self: start; margin-top: 48px; }
.ioflow .in-card, .ioflow .out-card { position: sticky; top: 72px; }
@media (max-width: 760px) {
  .ioflow .arrow { margin-top: 0; align-self: center; }
  .ioflow .in-card, .ioflow .out-card { position: static; }
}
