/* Power Plant Academy — locked theme. Additive changes only. */
:root {
  --ink: #1a2332;
  --ink-soft: #4a5568;
  --muted: #8895a7;
  --bg: #fafbfc;
  --card: #ffffff;
  --line: #e2e8f0;
  --brand: #0b4f8a;        /* deep engineering blue */
  --brand-soft: #e8f1f9;
  --accent: #d97706;       /* amber — highlights, warnings */
  --accent-soft: #fef3e2;
  --ok: #047857;
  --ok-soft: #ecfdf5;
  --code: #f1f5f9;
  --sidebar-w: 300px;
  font-size: 17px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Sukhumvit Set", "Thonburi", -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.75;
}
/* ---------- layout ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  border-right: 1px solid var(--line);
  background: var(--card);
  padding: 1.25rem 1rem 3rem;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  font-size: 0.85rem;
}
.sidebar h2 { font-size: 0.95rem; color: var(--brand); margin: 0 0 .75rem; }
.sidebar nav a {
  display: block; padding: .3rem .5rem; border-radius: 6px;
  color: var(--ink-soft); text-decoration: none;
}
.sidebar nav a:hover { background: var(--brand-soft); color: var(--brand); }
.sidebar nav a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.content { flex: 1; min-width: 0; padding: 2.5rem clamp(1.25rem, 5vw, 4rem) 5rem; }
.content-inner { max-width: 880px; margin: 0 auto; }
@media (max-width: 900px) { .sidebar { display: none; } }
/* ---------- typography ---------- */
h1 { font-size: 1.9rem; line-height: 1.3; color: var(--brand); margin: .25rem 0 .25rem; }
.subtitle { color: var(--muted); font-size: 1.05rem; margin: 0 0 2rem; }
h2 { font-size: 1.35rem; color: var(--ink); margin: 2.75rem 0 1rem; padding-bottom: .4rem; border-bottom: 2px solid var(--brand-soft); }
h3 { font-size: 1.1rem; margin: 2rem 0 .75rem; }
p { margin: .8rem 0; }
strong { color: var(--ink); }
a { color: var(--brand); }
code { background: var(--code); padding: .1em .35em; border-radius: 4px; font-size: .9em; }
/* ---------- breadcrumb + pager ---------- */
.crumb { font-size: .85rem; color: var(--muted); margin-bottom: 1rem; }
.crumb a { color: var(--muted); text-decoration: none; }
.crumb a:hover { color: var(--brand); }
.pager { display: flex; justify-content: space-between; gap: 1rem; margin: 3.5rem 0 0; }
.pager a {
  flex: 1; border: 1px solid var(--line); border-radius: 10px; padding: .8rem 1rem;
  text-decoration: none; background: var(--card); color: var(--ink-soft); font-size: .9rem;
}
.pager a:hover { border-color: var(--brand); color: var(--brand); }
.pager .next { text-align: right; }
.pager .spacer { flex: 1; }
/* ---------- boxes ---------- */
.box { border-radius: 12px; padding: 1.1rem 1.35rem; margin: 1.5rem 0; }
.box > :first-child { margin-top: 0; } .box > :last-child { margin-bottom: 0; }
.box-title { font-weight: 700; margin-bottom: .5rem; display: block; }
.why { background: var(--brand-soft); border-left: 4px solid var(--brand); }
.why .box-title { color: var(--brand); }
.objectives { background: var(--card); border: 1px solid var(--line); }
.field-note { background: var(--accent-soft); border-left: 4px solid var(--accent); }
.field-note .box-title { color: var(--accent); }
.example { background: var(--ok-soft); border-left: 4px solid var(--ok); }
.example .box-title { color: var(--ok); }
.summary-box { background: var(--card); border: 1px solid var(--line); }
/* ---------- figures ---------- */
figure { margin: 1.75rem 0; text-align: center; }
figure img {
  max-width: 100%; border-radius: 10px;
  box-shadow: 0 2px 12px rgba(26, 35, 50, .10);
}
figure svg { max-width: 100%; height: auto; }
figcaption { font-size: .85rem; color: var(--muted); margin-top: .6rem; line-height: 1.5; }
.fig-diagram { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 1rem; }
/* ---------- tables ---------- */
table { border-collapse: collapse; width: 100%; margin: 1.25rem 0; font-size: .92rem; }
th { background: var(--brand-soft); color: var(--brand); text-align: left; }
th, td { border: 1px solid var(--line); padding: .55rem .8rem; }
tr:nth-child(even) td { background: #f7fafc; }
/* ---------- quiz ---------- */
.quiz { counter-reset: q; }
.quiz details {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: .9rem 1.15rem; margin: .7rem 0;
}
.quiz summary { cursor: pointer; font-weight: 600; color: var(--ink); }
.quiz summary::before { counter-increment: q; content: "ข้อ " counter(q) " — "; color: var(--brand); }
.quiz .answer { margin-top: .7rem; padding-top: .7rem; border-top: 1px dashed var(--line); color: var(--ink-soft); }
/* ---------- equations ---------- */
.katex-display { overflow-x: auto; padding: .25rem 0; }
/* ---------- index page ---------- */
.hero { padding: 3rem 0 1rem; }
.hero h1 { font-size: 2.3rem; }
.part { margin: 2.5rem 0 1rem; }
.part h2 { border: none; color: var(--brand); font-size: 1.2rem; margin-bottom: .5rem; }
ol.toc { list-style: none; padding: 0; margin: 0; }
ol.toc li {
  display: flex; align-items: baseline; gap: .75rem;
  padding: .45rem .6rem; border-radius: 8px;
}
ol.toc li:hover { background: var(--brand-soft); }
.ch-num { font-weight: 700; color: var(--brand); min-width: 2rem; font-variant-numeric: tabular-nums; }
ol.toc a { text-decoration: none; color: var(--ink); }
ol.toc li.todo { opacity: .45; }
ol.toc li.todo a { pointer-events: none; }
ol.toc li.todo .ch-num::after { content: " ⏳"; font-size: .75em; }
/* ---------- annotated equipment figures (marker บนรูป + คำอธิบายไทยใต้รูป) ---------- */
.annot-wrap { position: relative; display: inline-block; max-width: 100%; line-height: 0; }
.marker {
  position: absolute; transform: translate(-50%, -50%);
  width: 1.7rem; height: 1.7rem; border-radius: 50%;
  background: var(--brand); color: #fff; font-weight: 700; font-size: .85rem;
  display: flex; align-items: center; justify-content: center; line-height: 1;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .4), 0 0 0 2px rgba(255, 255, 255, .9);
}
ol.annot-legend {
  list-style: none; counter-reset: annot; padding: 0;
  margin: 1rem auto 0; max-width: 720px; text-align: left; font-size: .92rem; line-height: 1.7;
}
ol.annot-legend li { counter-increment: annot; position: relative; margin: .6rem 0; padding-left: 2.3rem; }
ol.annot-legend li::before {
  content: counter(annot); position: absolute; left: 0; top: .15rem;
  width: 1.5rem; height: 1.5rem; border-radius: 50%;
  background: var(--brand); color: #fff; font-weight: 700; font-size: .8rem;
  display: flex; align-items: center; justify-content: center;
}
ol.annot-legend b { color: var(--brand); }
/* ==================== reader UX (2026-07-13, additive) ==================== */
/* ---- font scaling: content scales via root; chrome pinned in px below ---- */
:root { --font-scale: 1.5; font-size: calc(17px * var(--font-scale)); }
.sidebar { font-size: 14.5px; padding: 21px 17px 51px; }
.sidebar h2 { font-size: 16px; }
.sidebar nav a { padding: 5px 8.5px; }
.crumb { font-size: 14.5px; }
.pager a { font-size: 15.5px; padding: 14px 17px; }
/* ---- Thai-textbook paragraphs: first-line indent + blank-line gap ---- */
.content-inner p { text-indent: 2em; margin: 1.6em 0; }
.content-inner p.subtitle { text-indent: 0; margin: 0 0 2rem; }
/* ---- sidebar collapse (desktop) ---- */
.sidebar { transition: margin-left .25s ease; }
.layout.sidebar-off .sidebar { margin-left: calc(-1 * var(--sidebar-w)); }
.sidebar-toggle {
  position: fixed; z-index: 65;
  left: calc(var(--sidebar-w) - 12px); top: 50vh; transform: translateY(-50%);
  width: 24px; height: 48px; border-radius: 12px; padding: 0;
  border: 1px solid var(--line); background: var(--card); color: var(--ink-soft);
  font-size: 15px; line-height: 1; cursor: pointer;
  box-shadow: 0 1px 6px rgba(26, 35, 50, .15);
  transition: left .25s ease, background .15s;
}
.sidebar-toggle:hover { background: var(--brand-soft); color: var(--brand); }
.layout.sidebar-off .sidebar-toggle { left: 4px; }
.sidebar-backdrop {
  position: fixed; inset: 0; z-index: 55; background: rgba(26, 35, 50, .45);
  opacity: 0; pointer-events: none; transition: opacity .25s ease;
}
/* ---- sidebar drawer (mobile) ---- */
@media (max-width: 900px) {
  .sidebar {
    display: block; position: fixed; left: 0; top: 0; height: 100vh; z-index: 60;
    margin-left: 0; transform: translateX(-100%); transition: transform .25s ease;
  }
  .layout.sidebar-off .sidebar { margin-left: 0; }
  .layout.drawer-open .sidebar { transform: translateX(0); box-shadow: 0 0 30px rgba(0, 0, 0, .3); }
  .layout.drawer-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
  .sidebar-toggle { left: 4px; }
  .layout.drawer-open .sidebar-toggle { left: calc(var(--sidebar-w) - 12px); }
}
/* ---- floating reader bar (A− / A+ / resume code) ---- */
.reader-bar {
  position: fixed; right: 16px; bottom: 16px; z-index: 50;
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 12px; font-size: 14px; color: var(--ink-soft);
  box-shadow: 0 2px 10px rgba(26, 35, 50, .18);
}
.reader-bar button {
  width: 32px; height: 32px; border-radius: 50%; padding: 0;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
  font-size: 13px; font-weight: 700; line-height: 1; cursor: pointer;
}
.reader-bar button:hover:not(:disabled) { background: var(--brand-soft); color: var(--brand); }
.reader-bar button:disabled { opacity: .35; cursor: default; }
.reader-bar .resume-code { font-variant-numeric: tabular-nums; white-space: nowrap; }
/* ---- index page: continue banner + code entry ---- */
.resume-panel {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  background: var(--brand-soft); border-left: 4px solid var(--brand);
  border-radius: 12px; padding: 14px 20px; margin: 4px 0 8px; font-size: 16px;
}
.resume-panel a.continue { font-weight: 700; color: var(--brand); text-decoration: none; }
.resume-panel form { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.resume-panel label { color: var(--ink-soft); font-size: 14.5px; }
.resume-panel input {
  width: 100px; padding: 6px 10px; text-align: center;
  border: 1px solid var(--line); border-radius: 8px; font: inherit; background: var(--card);
}
.resume-panel form button {
  padding: 6px 14px; border-radius: 8px; border: 1px solid var(--brand);
  background: var(--brand); color: #fff; font: inherit; cursor: pointer;
}
.resume-panel .resume-err { color: #b91c1c; font-size: 14px; width: 100%; display: none; }
/* ---- book.tobulab gateway: back-to-library chip (injected by sync-books.sh) ---- */
.lib-home {
  position: fixed; left: 14px; bottom: 14px; z-index: 70;
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--card, #ffffff); border: 1px solid var(--line, #e2e8f0);
  border-radius: 999px; padding: 7px 15px; font-size: 13.5px; font-weight: 600;
  color: var(--ink-soft, #4a5568); text-decoration: none;
  box-shadow: 0 2px 10px rgba(26, 35, 50, .15);
}
.lib-home:hover { color: var(--brand, #0b4f8a); border-color: var(--brand, #0b4f8a); background: var(--brand-soft, #e8f1f9); }
