:root {
  /* Aliases onto the notebook.css system tokens — keeps every var(--old-name)
     reference below pointed at the shared "Refined Field Note" palette. */
  --cream: var(--paper);
  --navy: var(--ink);
  --navy-2: var(--ink);
  --copper-2: var(--copper);
  --shadow: 0 24px 80px rgba(16, 36, 59, .14);
  --reader-scale: 1;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
h1, h2, h3, h4, h5, h6 { font-family: var(--display); }
body {
  margin: 0;
  min-height: 100vh;
  /* color/font-family/background come from .nb-desk on <body> */
}
.progress { position: fixed; left: 0; top: 0; height: 4px; width: 0; background: repeating-linear-gradient(-45deg, var(--copper), var(--copper) 3px, rgba(184,115,56,.5) 3px, rgba(184,115,56,.5) 6px); z-index: 10; }
.reader-tabs-wrap {
  position: sticky;
  top: 0;
  z-index: 12;
  padding: 0 24px;
  background: rgba(239,233,218,.94);
  backdrop-filter: blur(12px);
}
.toc-tab {
  position: sticky;
  left: 0;
  z-index: 3;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-right: 8px;
  padding: 7px 11px;
  border: 1.5px solid var(--copper);
  border-bottom-color: var(--copper);
  border-radius: 10px 10px 0 0;
  background: var(--hl);
  color: var(--ink);
  box-shadow: 0 6px 18px rgba(16,36,59,.12);
  cursor: pointer;
  transition: background .18s ease, color .18s ease, transform .18s ease;
}
.toc-tab:hover { color: var(--ink); transform: translateY(-2px); }
.toc-tab:focus-visible { outline: 2px solid var(--copper); outline-offset: -2px; }
.toc-toggle-icon {
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font-size: 13px;
}
.toc-toggle-copy { display: grid; gap: 1px; text-align: left; }
.toc-toggle-copy strong { font: 800 12px var(--display); }
.toc-toggle-copy small { color: var(--muted); font: 600 9px var(--thai); }
.toc-toggle-arrow { color: var(--copper); font-size: 18px; line-height: 1; }
.toc-tab.is-collapsed { background: var(--copper); color: #fff; }
.toc-tab.is-collapsed .toc-toggle-icon { background: #fff; color: var(--ink); }
.toc-tab.is-collapsed .toc-toggle-copy small,
.toc-tab.is-collapsed .toc-toggle-arrow { color: #fff; }
.sidebar {
  position: fixed; top: var(--tabs-h, 57px); right: auto; bottom: 0; left: 0; width: 330px; z-index: 3;
  padding: 28px 22px;
  background: rgba(255,255,255,.45);
  border-right: 2px dashed rgba(16,36,59,.25);
  backdrop-filter: blur(18px);
  display: flex; flex-direction: column; gap: 18px;
}
.brand { border: 1px solid var(--line); border-radius: 26px; padding: 20px; background: rgba(255,255,255,.52); box-shadow: 0 14px 40px rgba(16,36,59,.08); }
.brand-kicker { font: 600 22px var(--hand); color: var(--copper); text-transform: none; letter-spacing: 0; }
.eyebrow, .section-meta, .handoff span { color: var(--copper); text-transform: uppercase; letter-spacing: .12em; font-size: 11px; font-weight: 700; }
.brand h1 { font: 750 38px/0.95 var(--display); margin: 8px 0 4px; color: var(--navy); }
.brand p { margin: 0; color: var(--muted); }
.reader-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.reader-stats div { border: 1px solid var(--line); border-radius: 18px; padding: 11px 12px; background: rgba(255,255,255,.48); }
.reader-stats span { display: block; color: var(--muted); font-size: 11px; font-weight: 700; margin-bottom: 3px; }
.reader-stats strong { display: block; color: var(--navy); font: 700 13px/1.25 var(--display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-label { font-size: 12px; color: var(--muted); font-weight: 700; }
.search { width: 100%; border: 1px solid var(--line); border-radius: 16px; padding: 13px 14px; background: rgba(255,255,255,.72); color: var(--navy); outline: none; }
.search:focus { border-color: var(--copper); box-shadow: 0 0 0 4px rgba(184,115,56,.12); }
.search-summary { min-height: 18px; color: var(--muted); font-size: 12px; margin-top: -10px; }
.toc { overflow: auto; padding-right: 6px; display: grid; gap: 7px; }
.toc button { width: 100%; border: 0; text-align: left; cursor: pointer; border-radius: 14px; padding: 11px 12px; background: transparent; color: var(--navy); font: 500 13px/1.35 var(--thai); display: grid; grid-template-columns: 42px 1fr; gap: 8px; align-items: start; }
.toc button .num { color: var(--copper); font-weight: 800; }
.toc button .part { display: block; color: var(--muted); font-size: 11px; font-weight: 500; margin-top: 2px; }
.toc button:hover { background: rgba(184,115,56,.12); }
.toc button.active { background: var(--hl); border: 1px solid var(--line); font-weight: 600; }
.sidebar-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 12px; }
.reader-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.ghost-btn, .nav-btn {
  display: inline-flex; align-items: center; gap: 8px;
  font: 700 15px var(--display);
  padding: 12px 22px;
  border-radius: 8px;
  border: 1.5px solid var(--ink);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
}
.ghost-btn.mini { padding: 8px 12px; font-size: 12px; }
.nav-btn.soft { background: rgba(255,255,255,.78); }
.nav-btn.primary { color: #fff; background: var(--ink); border-color: var(--ink); box-shadow: 0 2px 0 rgba(16,36,59,.7); }
.ghost-btn:hover, .nav-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(16,36,59,.15); }
.shell {
  position: relative; z-index: 1; margin-left: 330px; padding: 28px clamp(20px, 4vw, 60px) 70px;
  background: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 26px 26px;
  border: 1px solid rgba(16, 36, 59, .35);
  border-radius: 10px;
  box-shadow: 0 1px 0 rgba(16, 36, 59, .25), 0 18px 40px rgba(16, 36, 59, .12);
}
.shell::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--copper);
  border-radius: 10px 0 0 10px;
}
.topbar { display: flex; justify-content: space-between; gap: 20px; align-items: center; max-width: 1120px; margin: 0 auto 24px; }
.topbar h2 { margin: 3px 0 0; font: 700 24px/1.05 var(--display); }
.top-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.hero { max-width: 1120px; margin: 0 auto 28px; min-height: 360px; display: grid; grid-template-columns: 1fr minmax(280px, 430px); gap: 30px; align-items: stretch; padding: clamp(24px, 4vw, 46px); border: 1px solid var(--line); border-radius: 38px; background: rgba(255,253,247,.76); box-shadow: var(--shadow); overflow: hidden; position: relative; }
.hero::before { content: ""; position: absolute; width: 430px; height: 430px; border: 1px solid rgba(184,115,56,.2); border-radius: 50%; right: -120px; top: -160px; }
.hero-copy { display: flex; flex-direction: column; justify-content: center; position: relative; z-index: 1; }
.hero h3 { font: 750 clamp(42px, 7vw, 82px)/.94 var(--display); letter-spacing: -.04em; margin: 14px 0 18px; max-width: 720px; }
.hero p { color: var(--muted); font-size: 18px; line-height: 1.7; max-width: 680px; }
.hero-art { margin: 0; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: #f6eddf; align-self: center; box-shadow: 0 8px 22px rgba(16,36,59,.07); }
.hero-art img { display: block; width: 100%; height: 100%; min-height: 280px; object-fit: cover; }
.reader { max-width: 820px; margin: 0 auto; padding: clamp(24px, 4vw, 52px); background: rgba(255,253,247,.84); border: 1px solid var(--line); border-radius: 34px; box-shadow: 0 20px 70px rgba(16,36,59,.09); }
.reader h2 { font: 700 30px/1.25 var(--display); margin: 44px 0 16px; color: var(--navy); padding-left: 22px; position: relative; }
.reader h2::before { content: "✎"; position: absolute; left: 0; color: var(--copper); }
.reader h2:first-child { margin-top: 0; }
.reader h3 { font: 700 22px/1.35 var(--display); margin: 34px 0 12px; }
.reader p, .reader li, .reader blockquote { font-size: calc(17.5px * var(--reader-scale)); line-height: 2.05; }
.reader p { margin: 0 0 21px; }
.reader ul { margin: 0 0 24px; padding-left: 1.3em; }
.reader li { margin: 8px 0; }
.reader blockquote { margin: 28px 0; padding: 16px 20px; border: 1px solid var(--line); border-radius: 10px; background: #fff; box-shadow: 0 8px 22px rgba(16,36,59,.07); font-weight: 600; }
.reader blockquote strong { color: var(--copper); }
.reader code { background: rgba(16,36,59,.08); border-radius: 8px; padding: 1px 6px; }
.quote-mark { color: var(--navy-2); font-weight: 600; }
.handoff { max-width: 820px; margin: 24px auto 0; padding: 20px 24px; border: 1px dashed rgba(16,36,59,.25); border-radius: 10px; background: rgba(255,255,255,.5); font: 600 20px var(--hand); color: var(--muted); }
.handoff p { margin: 10px 0 0; line-height: 1.5; }
#handoffText b, #handoffText strong { color: var(--copper); }
.reader-footer { max-width: 820px; margin: 24px auto 0; display: flex; justify-content: space-between; gap: 12px; }
body.focus .sidebar { transform: translateX(-100%); }
body.focus .shell { margin-left: 0; }
body.focus .reader-tabs-wrap { display: none; }
.toc-collapsed .sidebar { transform: translateX(-100%); visibility: hidden; pointer-events: none; }
.toc-collapsed .shell { margin-left: 0; }
.sidebar, .shell, .progress { transition: .25s ease; }
@media (max-width: 980px) {
  .reader-tabs-wrap { padding: 0 16px; }
  .sidebar { position: relative; width: auto; inset: auto; max-height: none; border-right: 0; border-bottom: 1px solid var(--line); padding: 18px 16px; }
  .brand { padding: 16px 18px; border-radius: 22px; }
  .brand h1 { font-size: 32px; }
  .toc { max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: 18px; padding: 6px; background: rgba(255,255,255,.42); }
  .toc button { grid-template-columns: 42px 1fr; padding: 10px; }
  .sidebar-foot { margin-top: 0; }
  .shell, body.focus .shell { margin-left: 0; padding: 18px 16px 50px; }
  body.focus .sidebar { transform: none; }
  .toc-collapsed .sidebar { display: none; }
  .topbar, .hero { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; }
  .hero { min-height: auto; border-radius: 28px; padding: 22px; }
  .hero h3 { font-size: clamp(38px, 12vw, 58px); }
  .hero-art img { min-height: 220px; }
  .reader { padding: 24px 20px; border-radius: 24px; }
  .reader p, .reader li, .reader blockquote { font-size: calc(16px * var(--reader-scale)); line-height: 1.95; }
}

@media (max-width: 640px) {
  .toc-tab { gap: 7px; padding: 6px 9px; }
  .toc-toggle-copy small { display: none; }
  .toc-toggle-arrow { font-size: 15px; }
}

@media print {
  body { background: white; color: #111; }
  .progress, .reader-tabs-wrap, .sidebar, .topbar, .hero-art, .reader-footer { display: none !important; }
  .shell, body.focus .shell { margin: 0; padding: 0; }
  .hero, .reader, .handoff { max-width: none; box-shadow: none; border: 0; background: white; padding: 0; }
  .hero { display: block; min-height: auto; margin-bottom: 24px; }
  .hero h3 { font-size: 36px; line-height: 1.15; }
  .shell { background: none; border: 0; box-shadow: none; }
  .shell::before { display: none; }
}
