/* ---------------------------------------------------------------- tokens */
:root {
  --paper: #fffdf8;
  --surface: #ffffff;
  --page-bg: #f2ede4;
  --ink: #1b2430;
  --ink-soft: #5b6675;
  --ink-faint: #8b95a3;
  --line: #e4ded2;
  --accent: #e8683c;
  --accent-dark: #c9502a;
  --accent-soft: #fdeee7;
  --green: #0f9d58;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(27, 36, 48, .06), 0 8px 24px rgba(27, 36, 48, .07);
  --font: "Nunito", ui-rounded, "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--page-bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
}

h1, h2, h3 { line-height: 1.25; margin: 0 0 .4em; }

/* ---------------------------------------------------------------- topbar */
.topbar {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  background: var(--accent-soft);
  color: var(--accent-dark);
  border-radius: 12px;
  font-size: 20px;
}
.brand strong { display: block; font-size: 1.02rem; }
.brand small { display: block; color: var(--ink-faint); font-size: .8rem; }
.topbar-link { color: var(--ink-soft); font-size: .9rem; text-decoration: none; border-bottom: 1px dotted var(--ink-faint); }
.topbar-link:hover { color: var(--accent-dark); }

/* ---------------------------------------------------------------- layout */
.layout {
  max-width: 1320px;
  margin: 0 auto;
  padding: 22px 20px 40px;
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  position: sticky;
  top: 78px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}

.field-group { padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.field-group:last-of-type { border-bottom: 0; }
.field-group h2 { font-size: .76rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-faint); margin-bottom: 10px; }

.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: .88rem; font-weight: 600; margin-bottom: 5px; }
.field em, .check em { font-style: normal; font-weight: 400; color: var(--ink-faint); }

input[type="text"], select {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  font-size: .95rem;
  color: var(--ink);
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 10px;
}
input[type="text"]:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }

input[type="range"] { width: 100%; accent-color: var(--accent); }

.hint { font-size: .8rem; color: var(--ink-faint); margin: 6px 0 0; }

.segmented { display: flex; gap: 6px; }
.segmented label { flex: 1; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
  display: block;
  text-align: center;
  padding: 9px 4px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font-weight: 700;
  font-size: .95rem;
  cursor: pointer;
  background: #fff;
}
.segmented input:checked + span { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-dark); }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.check { display: flex; gap: 9px; align-items: flex-start; margin-bottom: 9px; font-size: .88rem; cursor: pointer; }
.check input { margin: 3px 0 0; accent-color: var(--accent); width: 17px; height: 17px; flex: none; }

.actions { margin-top: 16px; }
.actions-row { display: flex; gap: 8px; margin-top: 8px; }
.actions-row .btn { flex: 1; }

.btn {
  font: inherit;
  font-weight: 700;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1.5px solid transparent;
  cursor: pointer;
  background: #fff;
}
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); }
.btn-ghost { border-color: var(--line); color: var(--ink); }
.btn-ghost:hover:not(:disabled) { border-color: var(--ink-faint); }
.btn-block { width: 100%; font-size: 1.02rem; }

.warnings { font-size: .82rem; color: var(--accent-dark); margin: 12px 0 0; min-height: 1em; }

/* --------------------------------------------------------------- preview */
.preview-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.preview-head h2 { font-size: 1rem; margin: 0; }
.preview-meta { margin: 0; font-size: .85rem; color: var(--ink-faint); }

.sheets { display: flex; flex-direction: column; gap: 22px; align-items: center; }

.sheet {
  background: #fff;
  box-shadow: var(--shadow);
  border-radius: 4px;
  width: 100%;
  max-width: 816px;
  aspect-ratio: 816 / 1056;
  overflow: hidden;
}
.sheet-svg { display: block; width: 100%; height: 100%; }

.sheet-label {
  font-size: .78rem;
  color: var(--ink-faint);
  text-align: center;
  margin: 0 0 -12px;
}

.empty-state {
  background: #fff;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  color: var(--ink-faint);
  width: 100%;
}

/* ------------------------------------------------------------- explainer */
.explainer { background: var(--paper); border-top: 1px solid var(--line); padding: 36px 20px 44px; }
.explainer-inner { max-width: 940px; margin: 0 auto; }
.explainer h2 { font-size: 1.4rem; }
.explainer p { color: var(--ink-soft); max-width: 70ch; }

.ladder { list-style: none; counter-reset: rung; padding: 0; margin: 20px 0 26px; display: grid; gap: 6px; }
.ladder li {
  display: grid;
  grid-template-columns: 46px 140px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: .9rem;
}
.ladder .rung { font-weight: 800; color: var(--accent-dark); text-align: center; }
.ladder .name { font-weight: 700; }
.ladder .what { color: var(--ink-soft); }

.explainer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; margin-top: 8px; }
.explainer-grid h3 { font-size: .98rem; }
.explainer-grid p { font-size: .88rem; margin: 0; }
.fine-print { font-size: .84rem; color: var(--ink-faint); margin-top: 26px; border-top: 1px solid var(--line); padding-top: 16px; }

.site-foot { text-align: center; padding: 22px 20px 34px; color: var(--ink-faint); font-size: .82rem; }

/* -------------------------------------------------------------- practice */
.modal {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(27, 36, 48, .55);
  display: grid; place-items: center;
  padding: 16px;
}
.modal[hidden] { display: none; }
.modal-card {
  background: #fff; border-radius: var(--radius);
  width: min(980px, 100%); max-height: 94vh; overflow: auto;
  padding: 16px;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.modal-head h2 { margin: 0; font-size: 1.05rem; }

.practice-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.practice-progress { font-weight: 700; color: var(--ink-soft); }
.practice-actions { display: flex; gap: 8px; }
.practice-svg {
  display: block; width: 100%; height: auto;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 12px;
  touch-action: none;
  cursor: crosshair;
}
.practice-cheer { text-align: center; font-weight: 800; font-size: 1.3rem; color: var(--green); min-height: 1.6em; opacity: 0; transition: opacity .2s; }
.practice-cheer.is-on { opacity: 1; }
.pdot { transition: fill .12s ease; }

/* ----------------------------------------------------------- responsive */
@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .panel { position: static; max-height: none; }
  .ladder li { grid-template-columns: 44px 1fr; }
  .ladder .what { grid-column: 2; }
}

/* --------------------------------------------------------------- print */
@page { size: letter portrait; margin: 0; }

@media print {
  body { background: #fff; }
  .topbar, .panel, .preview-head, .explainer, .site-foot, .modal, .no-print, .sheet-label { display: none !important; }
  .layout { display: block; padding: 0; max-width: none; }
  .sheets { display: block; gap: 0; }
  .sheet {
    width: 8.5in; height: 11in;
    max-width: none; aspect-ratio: auto;
    box-shadow: none; border-radius: 0;
    break-after: page; page-break-after: always;
  }
  .sheet:last-child { break-after: auto; page-break-after: auto; }
}
