/* 美股期权课 · shared stylesheet
   Layout: a trading textbook printed on cool graph-paper stock. Top course bar, chapter masthead,
   sticky section index on the left, one 68ch reading column, interactive figures framed like lab plates. */
:root {
  --paper: #f4f7f6;
  --plate: #ffffff;
  --ink: #15202a;
  --muted: #5b6873;
  --rule: #d6dee1;
  --grid: #e7eded;
  --delta: #2a55c0;
  --gamma: #b0226a;
  --theta: #1f8a7a;
  --warn: #a35a00;
  --tint-delta: rgba(42, 85, 192, .08);
  --tint-gamma: rgba(176, 34, 106, .08);
  --tint-theta: rgba(31, 138, 122, .09);
  --tint-warn: rgba(163, 90, 0, .09);
  --font-display: "Noto Serif SC", "Songti SC", "STSong", serif;
  --font-body: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --font-math: "STIX Two Text", "Times New Roman", serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0f161c; --plate: #151f27; --ink: #e3e9ed; --muted: #93a2ad; --rule: #27343e; --grid: #1c2830;
    --delta: #86a6ff; --gamma: #f170b2; --theta: #4fc4b2; --warn: #f0a540;
    --tint-delta: rgba(134, 166, 255, .10); --tint-gamma: rgba(241, 112, 178, .10);
    --tint-theta: rgba(79, 196, 178, .10); --tint-warn: rgba(240, 165, 64, .10);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0f161c; --plate: #151f27; --ink: #e3e9ed; --muted: #93a2ad; --rule: #27343e; --grid: #1c2830;
  --delta: #86a6ff; --gamma: #f170b2; --theta: #4fc4b2; --warn: #f0a540;
  --tint-delta: rgba(134, 166, 255, .10); --tint-gamma: rgba(241, 112, 178, .10);
  --tint-theta: rgba(79, 196, 178, .10); --tint-warn: rgba(240, 165, 64, .10);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  background: var(--paper); color: var(--ink);
  font-family: var(--font-body); font-size: 16.5px; line-height: 1.85;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--delta); text-underline-offset: 3px; }
a:focus-visible, button:focus-visible, input:focus-visible, summary:focus-visible { outline: 2px solid var(--delta); outline-offset: 2px; }

/* ---------- masthead ---------- */
.mast {
  border-bottom: 1px solid var(--rule);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
  background-position: -1px -1px;
}
.mast-inner { max-width: 1160px; margin: 0 auto; padding-block: 44px 36px; padding-inline: 24px; display: grid; grid-template-columns: auto 1fr; gap: 8px 28px; align-items: end; }
.chapno { font-family: var(--font-mono); font-size: clamp(72px, 13vw, 132px); line-height: .82; font-weight: 500; color: var(--delta); letter-spacing: -.04em; grid-row: span 3; }
.eyebrow { font-size: 13px; color: var(--muted); letter-spacing: .08em; }
.mast h1 { font-family: var(--font-display); font-size: clamp(34px, 5.4vw, 54px); line-height: 1.15; margin: 0; font-weight: 700; text-wrap: balance; }
.mast h1 .g { color: var(--gamma); }
.deck { margin: 4px 0 0; color: var(--muted); max-width: 46em; font-size: 17px; }

/* ---------- layout ---------- */
.wrap { max-width: 1160px; margin: 0 auto; padding-inline: 24px; display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 56px; padding-block: 40px 80px; }
.toc { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 76px); align-self: start; font-size: 14px; line-height: 1.5; max-height: calc(100vh - 96px); overflow: auto; }
.toc-title { font-size: 12px; letter-spacing: .1em; color: var(--muted); margin: 0 0 12px; }
.toc ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.toc a { display: grid; grid-template-columns: 34px 1fr; padding: 6px 8px; border-radius: 4px; color: var(--muted); text-decoration: none; }
.toc a .n { font-family: var(--font-mono); font-size: 12px; padding-top: 1px; }
.toc a:hover { color: var(--ink); background: var(--grid); }
.toc a.active { color: var(--delta); background: var(--tint-delta); }
main { min-width: 0; max-width: 760px; }
.mobile-toc { display: none; }

@media (max-width: 900px) {
  .wrap { grid-template-columns: minmax(0, 1fr); gap: 0; padding-block: 24px 64px; padding-inline: 16px; }
  .toc { display: none; }
  .mobile-toc { display: block; margin-bottom: 28px; border: 1px solid var(--rule); border-radius: 6px; background: var(--plate); }
  .mobile-toc summary { padding: 12px 16px; cursor: pointer; font-weight: 500; }
  .mobile-toc ol { margin: 0; padding: 0 16px 14px 36px; font-size: 15px; }
  .mast-inner { padding-inline: 16px; padding-block: 32px 28px; grid-template-columns: 1fr; }
  .chapno { grid-row: auto; font-size: 64px; }
}

/* ---------- prose ---------- */
section { scroll-margin-top: 76px; }
section + section { margin-top: 64px; }
h2 { font-family: var(--font-display); font-size: 28px; line-height: 1.3; margin: 0 0 18px; display: flex; gap: 14px; align-items: baseline; text-wrap: balance; }
h2 .sn { font-family: var(--font-mono); font-size: 15px; font-weight: 500; color: var(--delta); flex: none; }
h3 { font-size: 18px; margin: 32px 0 8px; font-weight: 700; }
p { margin: 0 0 16px; max-width: 68ch; }
ul, ol { padding-left: 1.3em; margin: 0 0 16px; max-width: 68ch; }
li + li { margin-top: 4px; }
strong { font-weight: 700; }
.lead { font-size: 18px; color: var(--ink); }
.num { font-family: var(--font-mono); font-size: .92em; font-variant-numeric: tabular-nums; }
.v { font-family: var(--font-math); font-style: italic; font-size: 1.08em; }
.d { color: var(--delta); } .gm { color: var(--gamma); } .th { color: var(--theta); }
hr.sep { border: 0; border-top: 1px solid var(--rule); margin: 48px 0; }

/* objectives */
.objectives { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0; border: 1px solid var(--rule); border-radius: 6px; background: var(--plate); margin: 0 0 40px; }
.objectives div { padding: 18px 20px; min-width: 0; }
.objectives div + div { border-left: 1px solid var(--rule); }
@media (max-width: 560px) { .objectives div + div { border-left: 0; border-top: 1px solid var(--rule); } }
.objectives h4 { margin: 0 0 6px; font-size: 13px; letter-spacing: .08em; color: var(--muted); font-weight: 500; }
.objectives ul { margin: 0; padding-left: 1.1em; font-size: 15px; line-height: 1.7; }

/* formula */
.formula { margin: 20px 0 24px; padding: 18px 22px; background: var(--plate); border: 1px solid var(--rule); border-radius: 6px; overflow-x: auto; }
.formula .eq { font-family: var(--font-math); font-style: italic; font-size: 21px; line-height: 1.6; white-space: nowrap; }
.formula .eq .up { font-style: normal; font-family: var(--font-body); font-size: 17px; }
.formula .eq sub, .formula .eq sup { font-size: .62em; }
.formula .where { margin-top: 8px; font-size: 14px; color: var(--muted); line-height: 1.7; max-width: none; }
.frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; margin: 0 .15em; line-height: 1.15; }
.frac > span:first-child { border-bottom: 1px solid currentColor; padding: 0 .2em .05em; }
.frac > span:last-child { padding: .05em .2em 0; }

/* callouts */
.note { margin: 22px 0 24px; padding: 16px 20px 6px; border-radius: 6px; background: var(--tint-delta); }
.note .tag { display: inline-block; font-size: 12px; letter-spacing: .1em; font-weight: 700; color: var(--delta); margin-bottom: 4px; }
.note p, .note ul { font-size: 15.5px; }
.note.warn { background: var(--tint-warn); } .note.warn .tag { color: var(--warn); }
.note.field { background: var(--tint-theta); } .note.field .tag { color: var(--theta); }
.note.gam { background: var(--tint-gamma); } .note.gam .tag { color: var(--gamma); }

/* tables */
.tbl { overflow-x: auto; margin: 18px 0 26px; border: 1px solid var(--rule); border-radius: 6px; background: var(--plate); }
table { border-collapse: collapse; width: 100%; font-size: 14.5px; font-variant-numeric: tabular-nums; }
caption { caption-side: top; text-align: left; padding: 12px 16px 4px; font-size: 13px; color: var(--muted); }
th, td { padding: 9px 14px; text-align: right; border-bottom: 1px solid var(--rule); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
thead th { font-size: 12.5px; color: var(--muted); font-weight: 500; letter-spacing: .04em; }
tbody tr:last-child td { border-bottom: 0; }
td.mono, th.mono { font-family: var(--font-mono); }
tr.hl td { background: var(--tint-delta); }
.pos { color: var(--theta); } .neg { color: var(--gamma); }

/* figures */
figure.plate { margin: 26px 0 32px; background: var(--plate); border: 1px solid var(--rule); border-radius: 8px; padding: 18px 18px 14px; }
.fig-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; flex-wrap: wrap; margin-bottom: 6px; }
.fig-no { font-family: var(--font-mono); font-size: 12.5px; color: var(--muted); }
.fig-title { font-weight: 700; font-size: 15.5px; }
figure.plate svg.chart { width: 100%; height: auto; display: block; }
figcaption { font-size: 13.5px; color: var(--muted); line-height: 1.7; margin-top: 8px; }
.controls { display: flex; flex-wrap: wrap; gap: 10px 22px; margin: 6px 0 4px; align-items: center; }
.ctl { display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: var(--muted); }
.ctl input[type="range"] { width: 150px; accent-color: var(--delta); }
.ctl output { font-family: var(--font-mono); color: var(--ink); min-width: 4.5em; font-variant-numeric: tabular-nums; }
.seg { display: inline-flex; border: 1px solid var(--rule); border-radius: 6px; overflow: hidden; }
.seg button { font: inherit; font-size: 13.5px; background: transparent; color: var(--muted); border: 0; padding: 5px 12px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--rule); }
.seg button[aria-pressed="true"] { background: var(--tint-delta); color: var(--delta); font-weight: 500; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; color: var(--muted); margin-top: 4px; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 18px; height: 0; border-top: 2.5px solid; display: inline-block; }
.legend i.dash { border-top-style: dashed; }
.readout { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-top: 12px; }
.readout div { border-top: 1px solid var(--rule); padding-top: 8px; min-width: 0; }
.readout b { display: block; font-family: var(--font-mono); font-size: 19px; font-weight: 500; font-variant-numeric: tabular-nums; }
.readout small { font-size: 12.5px; color: var(--muted); }

/* svg text */
.ax { font-family: var(--font-mono); font-size: 11.5px; }
.scroll-x { overflow-x: auto; }
svg.chart.wide { min-width: 600px; }

/* calculator */
.calc table input { font: inherit; font-family: var(--font-mono); width: 6.5em; padding: 4px 6px; border: 1px solid var(--rule); border-radius: 4px; background: var(--paper); color: var(--ink); text-align: right; }
.calc table input.name { width: 7em; text-align: left; font-family: var(--font-body); }
.calc select { font: inherit; padding: 4px 6px; border: 1px solid var(--rule); border-radius: 4px; background: var(--paper); color: var(--ink); }
.calc .spy { display: flex; gap: 10px; align-items: center; font-size: 14px; color: var(--muted); margin: 0 0 10px; flex-wrap: wrap; }
.calc .spy input { font-family: var(--font-mono); width: 6em; padding: 4px 6px; border: 1px solid var(--rule); border-radius: 4px; background: var(--paper); color: var(--ink); }

/* cases */
.case { border-top: 2px solid var(--ink); padding-top: 14px; margin-top: 36px; }
.case .case-no { font-family: var(--font-mono); font-size: 12.5px; color: var(--muted); }
.case h3 { margin-top: 2px; }

/* checklists */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin: 20px 0 8px; }
.card { background: var(--plate); border: 1px solid var(--rule); border-radius: 8px; padding: 16px 18px; min-width: 0; }
.card h4 { margin: 0 0 8px; font-size: 15px; }
.card h4 .num { color: var(--muted); font-weight: 400; margin-right: 6px; }
.card ul { list-style: none; padding: 0; margin: 0; font-size: 14.5px; line-height: 1.65; }
.card li { display: grid; grid-template-columns: 22px 1fr; gap: 4px; align-items: start; }
.card input[type="checkbox"] { margin-top: 5px; accent-color: var(--theta); }

/* quiz */
details.q { border-bottom: 1px solid var(--rule); padding: 12px 0; max-width: 68ch; }
details.q summary { cursor: pointer; font-weight: 500; list-style: none; display: grid; grid-template-columns: 30px 1fr; }
details.q summary::-webkit-details-marker { display: none; }
details.q summary .num { color: var(--muted); }
details.q .ans { padding: 8px 0 0 30px; font-size: 15.5px; color: var(--ink); }
details.q .ans p { margin-bottom: 8px; }

footer.end { margin-top: 64px; padding-top: 18px; border-top: 1px solid var(--rule); font-size: 13.5px; color: var(--muted); }
footer.end p { max-width: none; }


/* ---------- course bar ---------- */
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: var(--paper); border-bottom: 1px solid var(--rule); }
.topbar-inner { max-width: 1160px; margin: 0 auto; padding-inline: 24px; padding-block: 10px; display: flex; gap: 16px; align-items: center; justify-content: space-between; }
.brand { font-family: var(--font-display); font-weight: 700; font-size: 16px; color: var(--ink); text-decoration: none; white-space: nowrap; }
.brand span { color: var(--delta); }
.topbar select { font: inherit; font-size: 14px; max-width: min(420px, 60vw); padding: 6px 10px; border: 1px solid var(--rule); border-radius: 6px; background: var(--plate); color: var(--ink); }
@media (max-width: 900px) { .topbar-inner { padding-inline: 16px; } }

/* ---------- pager ---------- */
.pager { display: flex; justify-content: space-between; gap: 16px; margin-top: 56px; padding-top: 18px; border-top: 1px solid var(--rule); flex-wrap: wrap; }
.pager a { display: block; text-decoration: none; color: var(--ink); border: 1px solid var(--rule); border-radius: 8px; padding: 10px 16px; max-width: 48%; min-width: 0; background: var(--plate); }
.pager a small { display: block; font-size: 12px; color: var(--muted); }
.pager a:hover { border-color: var(--delta); }
.pager a.next { margin-left: auto; text-align: right; }
@media (max-width: 560px) { .pager a { max-width: 100%; width: 100%; } .pager a.next { text-align: left; } }

/* ---------- extra components ---------- */
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 14px; margin: 18px 0 26px; }
.tile { background: var(--plate); border: 1px solid var(--rule); border-radius: 8px; padding: 16px 18px; min-width: 0; }
.tile h4 { margin: 0 0 6px; font-size: 16px; }
.tile p, .tile ul { font-size: 14.5px; margin-bottom: 8px; }
.tile .meta { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: 14.5px; margin: 0 0 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.figure-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 14px; }
pre.code { background: var(--plate); border: 1px solid var(--rule); border-radius: 6px; padding: 14px 16px; font-family: var(--font-mono); font-size: 13.5px; line-height: 1.7; overflow-x: auto; white-space: pre; margin: 12px 0 20px; }
.btn { font: inherit; font-size: 13.5px; padding: 6px 14px; border-radius: 6px; border: 1px solid var(--rule); background: var(--paper); color: var(--ink); cursor: pointer; }
.btn:hover { border-color: var(--delta); color: var(--delta); }
.ctl select, .ctl input[type="number"] { font: inherit; font-family: var(--font-mono); font-size: 13.5px; padding: 4px 8px; border: 1px solid var(--rule); border-radius: 4px; background: var(--paper); color: var(--ink); }
.ctl input[type="number"] { width: 6.5em; }
.scroll-x { overflow-x: auto; }
svg.chart.wide { min-width: 600px; }

/* ---------- course index ---------- */
.home-hero { max-width: 1160px; margin: 0 auto; padding-inline: 24px; padding-block: 48px 28px; }
.home-hero h1 { font-family: var(--font-display); font-size: clamp(38px, 6vw, 64px); margin: 6px 0 10px; line-height: 1.1; }
.home-hero p { max-width: 46em; color: var(--muted); font-size: 17px; }
.home-body { max-width: 1160px; margin: 0 auto; padding-inline: 24px; padding-block: 8px 80px; }
.part { margin-top: 40px; }
.part-head { display: flex; gap: 14px; align-items: baseline; border-bottom: 1px solid var(--rule); padding-bottom: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.part-head .pn { font-family: var(--font-mono); font-size: 13px; color: var(--delta); }
.part-head h2 { margin: 0; font-size: 24px; }
.part-head p { margin: 0; color: var(--muted); font-size: 14.5px; }
.ch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 14px; }
.ch-card { display: grid; grid-template-columns: 56px 1fr; gap: 4px 14px; text-decoration: none; color: var(--ink); background: var(--plate); border: 1px solid var(--rule); border-radius: 8px; padding: 16px 18px; min-width: 0; }
.ch-card:hover { border-color: var(--delta); }
.ch-card .cn { font-family: var(--font-mono); font-size: 30px; line-height: 1; color: var(--delta); grid-row: span 2; }
.ch-card h3 { margin: 0; font-size: 17px; line-height: 1.4; }
.ch-card p { margin: 0; font-size: 14px; color: var(--muted); line-height: 1.65; }
@media (max-width: 900px) { .home-hero, .home-body { padding-inline: 16px; } }

/* ---------- site bar (hanoptions.trade) ---------- */
.sitebar { border-bottom: 1px solid var(--rule); background: var(--paper); font-size: 13.5px; line-height: 1.4; }
.sitebar-inner { max-width: 1160px; margin: 0 auto; padding: 9px 24px; display: flex; gap: 18px; align-items: center; justify-content: space-between; }
.sitebar-home { font-family: var(--font-mono); color: var(--muted); text-decoration: none; letter-spacing: .02em; white-space: nowrap; }
.sitebar-home:hover { color: var(--ink); }
.sitebar-links { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.sitebar-links::-webkit-scrollbar { display: none; }
.sitebar-links a { color: var(--muted); text-decoration: none; padding: 3px 9px; border-radius: 4px; white-space: nowrap; }
.sitebar-links a:hover { color: var(--ink); background: var(--grid); }
.sitebar-links a[aria-current="page"] { color: var(--ink); background: var(--plate); box-shadow: inset 0 0 0 1px var(--rule); }
@media (max-width: 900px) { .sitebar-inner { padding-inline: 16px; } }
@media (max-width: 480px) { .sitebar-inner { gap: 10px; } .sitebar-links a { padding: 3px 7px; } }

.topbar-brand { display: flex; align-items: baseline; gap: 12px; min-width: 0; flex-wrap: wrap; }
.site-home { font-family: var(--font-mono); font-size: 12.5px; color: var(--muted); text-decoration: none; padding-right: 12px; border-right: 1px solid var(--rule); white-space: nowrap; }
.site-home:hover { color: var(--ink); }
