:root {
  --cream: #fdf8ec;
  --paper: #fffdf7;
  --navy: #10243b;
  --navy-2: #1d3857;
  --muted: #6f695e;
  --line: rgba(16,36,59,.14);
  --copper: #b87338;
  --copper-2: #d59a5b;
  --shadow: 0 24px 80px rgba(16, 36, 59, .14);
  --thai: "Sarabun", ui-sans-serif, system-ui, sans-serif;
  --display: "Kanit", "Sarabun", ui-sans-serif, system-ui, sans-serif;
  --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: var(--navy);
  font-family: var(--thai);
  background:
    radial-gradient(circle at 78% 8%, rgba(184,115,56,.18), transparent 28rem),
    radial-gradient(circle at 12% 18%, rgba(16,36,59,.10), transparent 22rem),
    linear-gradient(135deg, #fffaf0 0%, var(--cream) 46%, #f6ead7 100%);
}
.grain { position: fixed; inset: 0; pointer-events: none; opacity: .34; mix-blend-mode: multiply; background-image: radial-gradient(rgba(16,36,59,.12) .55px, transparent .55px); background-size: 7px 7px; z-index: 0; }
.progress { position: fixed; left: 0; top: 0; height: 4px; width: 0; background: linear-gradient(90deg, var(--copper), var(--navy)); z-index: 10; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: 330px; z-index: 3;
  padding: 28px 22px;
  background: rgba(255,253,247,.76);
  border-right: 1px solid var(--line);
  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, .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, .toc button.active { background: rgba(184,115,56,.12); }
.toc button.active { box-shadow: inset 3px 0 0 var(--copper); }
.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 { border: 1px solid var(--line); border-radius: 999px; padding: 10px 15px; color: var(--navy); background: rgba(255,255,255,.62); cursor: pointer; font-weight: 700; font-family: var(--thai); }
.ghost-btn.mini { padding: 8px 12px; font-size: 12px; }
.nav-btn.soft { background: rgba(255,255,255,.78); }
.nav-btn.primary { color: white; background: var(--navy); border-color: var(--navy); box-shadow: 0 12px 30px rgba(16,36,59,.2); }
.ghost-btn:hover, .nav-btn:hover { transform: translateY(-1px); }
.shell { position: relative; z-index: 1; margin-left: 330px; padding: 28px clamp(20px, 4vw, 60px) 70px; }
.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: 30px; overflow: hidden; border: 1px solid var(--line); background: #f6eddf; align-self: center; box-shadow: 0 20px 60px rgba(16,36,59,.16); }
.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); }
.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: 22px 24px; border-left: 5px solid var(--copper); background: rgba(184,115,56,.10); border-radius: 18px; font-weight: 600; }
.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: 24px 28px; border-radius: 28px; background: var(--navy); color: white; box-shadow: 0 24px 70px rgba(16,36,59,.22); }
.handoff p { margin: 10px 0 0; font-size: 16px; line-height: 1.85; color: rgba(255,255,255,.86); }
.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; }
.sidebar, .shell, .progress { transition: .25s ease; }
@media (max-width: 980px) {
  .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; }
  .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 print {
  body { background: white; color: #111; }
  .grain, .progress, .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; }
}
