:root {
  --bg: #f4f4f2;
  --panel: #ffffff;
  --text: #1c1c1e;
  --muted: #6b6b70;
  --line: #e2e2df;
  --accent: #2d5bd7;
  --accent-soft: #e6ecfb;
  --ok: #1f8a4c;
  --img-bg: #e9e9e6;
  --radius: 10px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button { font: inherit; cursor: pointer; }
button:disabled { cursor: default; }
kbd { font: 12px ui-monospace, monospace; background: #fff; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; }
.loading { text-align: center; color: var(--muted); padding: 80px 16px; }

/* layout */
.wrap { max-width: 1480px; margin: 0 auto; padding: 0 16px 64px; }
.narrow { max-width: 720px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; margin-top: 32px; }
h1 { font-size: 26px; line-height: 1.25; margin: 0 0 12px; }
h2 { font-size: 20px; margin: 0; line-height: 1.3; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.err { color: #b3261e; }
.actions { display: flex; gap: 12px; justify-content: flex-end; align-items: center; margin-top: 24px; flex-wrap: wrap; }
.primary, .ghost { border-radius: 8px; padding: 10px 20px; border: 1px solid var(--accent); }
.primary { background: var(--accent); color: #fff; }
.primary:disabled { background: #b9c3dd; border-color: #b9c3dd; }
.ghost { background: transparent; color: var(--accent); }
label.check { display: flex; gap: 10px; align-items: flex-start; margin: 16px 0; }
label.check input { margin-top: 4px; }
textarea { width: 100%; font: inherit; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; min-height: 110px; resize: vertical; }
ul.steps, ol.steps { padding-left: 20px; margin: 0 0 12px; }
ul.steps li, ol.steps li { margin-bottom: 6px; }
.legend { display: inline-flex; align-items: center; gap: 6px; margin-right: 12px; white-space: nowrap; }
.sw { width: 18px; height: 3px; border-radius: 2px; display: inline-block; }
.sw.blue { background: #1428a0; }
.sw.red { background: #dc1414; }

/* sticky header */
.bar { position: sticky; top: 0; z-index: 5; background: rgba(244,244,242,.95); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
.bar-inner { max-width: 1440px; margin: 0 auto; padding: 10px 16px 12px; }
.head-row { display: flex; gap: 12px 24px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.edit-head { flex: 1 1 320px; min-width: 0; }
.edit-head .step { font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.edit-head .desc { margin: 2px 0 0; }
.tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.progress { height: 3px; background: var(--line); }
.progress > div { height: 100%; background: var(--accent); transition: width .2s; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: transparent; padding: 7px 12px; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.hold { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 7px 12px; user-select: none; -webkit-user-select: none; touch-action: none; }
.hold.on { background: var(--text); color: #fff; }

/* section nav */
.secnav { display: flex; align-items: center; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
.secnav .sep { flex: 0 0 14px; height: 1px; background: var(--line); }
.sec { display: flex; align-items: center; gap: 8px; padding: 4px 10px; border-radius: 999px; border: 1px solid transparent; white-space: nowrap; flex: 0 0 auto; }
.sec-name { font-size: 13px; color: var(--muted); }
.sec.active { background: #fff; border-color: var(--line); }
.sec.active .sec-name { color: var(--text); font-weight: 600; }
.sec.complete .sec-name { color: var(--ok); }
.dots { display: inline-flex; gap: 4px; }
.dot { width: 22px; height: 22px; border-radius: 50%; border: 1px solid #c9c9c4; background: #fff; color: var(--muted); font-size: 11px; line-height: 20px; padding: 0; }
.dot.done { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.dot.cur { border: 2px solid var(--accent); color: var(--accent); font-weight: 700; line-height: 18px; }
.dot:disabled { opacity: .45; }

/* page */
.context { font-size: 19px; line-height: 1.45; }
.subcontext { font-size: 14px; margin: 0; }
.intro-row { display: flex; gap: 16px; align-items: center; margin: 16px 0 12px; }
.intro-row .context { margin: 0 0 4px; }
.orig-thumb { flex: 0 0 auto; position: relative; padding: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--img-bg); line-height: 0; }
.orig-thumb img { height: 120px; width: auto; display: block; }
.orig-thumb span { position: absolute; left: 4px; bottom: 4px; font-size: 11px; font-weight: 600; line-height: 1.4; background: #fff; padding: 0 5px; border-radius: 4px; }
.redtxt { color: #c81414; font-weight: 600; }
.board { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.panelwrap { position: relative; max-width: 1400px; margin: 0 auto; }
#panel { display: block; width: 100%; height: auto; }
#panel.magnifying { cursor: none; }
#loupe { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.questions { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 16px; }
.q { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px 16px; }
.q.answered { border-color: #b9c7ef; }
.q-title { font-size: 12px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.q-text { font-size: 17px; font-weight: 600; margin: 4px 0 12px; }
.picks { display: flex; gap: 8px; }
.pick { flex: 1; padding: 10px 0; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--text); font-weight: 700; font-size: 16px; }
.pick:hover { border-color: #b9c7ef; background: #f6f8fe; }
.pick.sel { background: var(--accent); border-color: var(--accent); color: #fff; }
.page-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 18px; gap: 12px; flex-wrap: wrap; }
/* keep the questions in view while scrolling the figure */
@media (min-width: 701px) and (min-height: 640px) {
  .questions { position: sticky; bottom: 0; z-index: 4; margin-top: 0; padding: 12px 0; background: rgba(244,244,242,.96); backdrop-filter: blur(6px); }
  .q { padding: 10px 14px 12px; box-shadow: 0 -2px 10px rgba(0,0,0,.05); }
  .q-text { font-size: 16px; margin: 2px 0 8px; }
  .pick { padding: 8px 0; }
}

@media (max-width: 900px) {
  .card { padding: 20px; }
}
@media (max-width: 700px) {
  .questions { grid-template-columns: 1fr; }
  .tools { display: none; }
  .context { font-size: 17px; }
  .intro-row { align-items: flex-start; gap: 12px; }
  .orig-thumb img { height: 96px; }
  .wide-only { display: none; }
  .board { padding: 6px; }
}
@media (max-width: 520px) {
  .hold .long { display: none; }
  .sec-name { font-size: 12px; }
}
