/* Screen UI for the UK worksheet generator.
   Structure follows the reference generator: quick-start strip, year row,
   preset bar, then a split workspace (settings rail + live A4 preview). */

/* ------------------------------------------------------------------ header */

.site-head {
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  position: sticky;
  top: 0;
  z-index: 20;
}

.site-head .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 62px;
  flex-wrap: wrap;
  padding-top: 8px;
  padding-bottom: 8px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}

.brand:hover {
  color: var(--ink);
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 18px;
  font-weight: 600;
  line-height: 1;
}

.brand-sub {
  display: block;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  font-size: 14px;
}

.site-nav a {
  color: var(--ink-soft);
  text-decoration: none;
  padding: 5px 0;
  border-bottom: 2px solid transparent;
}

.site-nav a:hover {
  color: var(--accent);
}

.site-nav a[aria-current="page"] {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 650;
}

/* -------------------------------------------------------------- page intro */

.page-intro {
  max-width: 920px;
  margin: 0 auto;
  padding: 10px 0 8px;
  text-align: center;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 10px;
  padding: 5px 12px;
  border: 1px solid #d6e5da;
  border-radius: 999px;
  background: rgba(234, 242, 236, 0.78);
  color: var(--accent);
  font-size: 11px;
  font-weight: 650;
  line-height: 1;
  letter-spacing: 0.01em;
}

.eyebrow::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 107, 79, 0.12);
}

.page-intro h1 {
  max-width: 46rem;
  margin: 0 auto 8px;
  font-size: clamp(1.6rem, 1.25rem + 1.2vw, 2.1rem);
  line-height: 1.06;
  text-wrap: balance;
}

.ledes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 28px;
  max-width: 760px;
  margin: 0 auto;
  text-align: left;
}

.ledes p {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.5;
}

/* The teacher / parent note sits under the frame so the generator can start
   high on the page. */
.page-note {
  max-width: 920px;
  margin: 20px auto 0;
  padding: 14px 18px;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--paper);
}

.page-note .ledes {
  max-width: none;
}

.lede {
  max-width: 62ch;
  font-size: 0.95rem;
  color: var(--ink-soft);
}

.scene {
  margin: 0;
  padding-left: 11px;
  border-left: 3px solid var(--accent-soft);
  font-size: 0.95rem;
  line-height: 1.45;
}

.scene b {
  color: var(--ink);
  font-weight: 650;
}

/* --------------------------------------------------------- generator shell */

.generator {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--gen-radius);
  box-shadow: 0 18px 40px -30px rgba(61, 51, 41, 0.45);
  overflow: hidden;
  margin: 2px 0 26px;
}

.quick-guide {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 10px;
  padding: 8px 26px;
  border-bottom: 1px solid var(--rule);
  background: #fbf8f2;
  color: var(--muted);
  font-size: 10.5px;
}

.quick-guide-label {
  color: var(--accent);
  font-size: 9.5px;
  font-weight: 750;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.quick-guide-steps {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.quick-guide-step {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.quick-guide-step b {
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 9px;
  font-weight: 750;
}

.quick-guide-arrow {
  color: #c2b8aa;
  font-size: 10px;
}

.quick-guide-link {
  margin-left: auto;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  text-decoration: none;
  border-bottom: 1px solid rgba(47, 107, 79, 0.3);
  white-space: nowrap;
}

.quick-guide-link:hover {
  border-bottom-color: var(--accent);
}

/* Full screen sits at the right of the quick-start row: a filled pill so it is
   obvious, with the label acting as the reminder. */
.quick-guide-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.quick-guide-actions .quick-guide-link {
  margin-left: 0;
}

.quick-guide-expand {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: var(--chip-radius);
  background: var(--accent);
  color: #fff;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 4px 10px -6px rgba(47, 107, 79, 0.85);
}

.quick-guide-expand svg {
  width: 12px;
  height: 12px;
}

.quick-guide-expand:hover {
  background: #245741;
}

.quick-guide-expand[aria-pressed="true"] {
  background: var(--accent-ink);
}

/* ------------------------------------------------------------------ step 1 */

.year-bar {
  padding: 9px 20px 8px;
  border-bottom: 1px solid var(--rule);
}

.step-label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 4px;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.step-number {
  display: grid;
  place-items: center;
  width: 15px;
  height: 15px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 8.5px;
  font-weight: 750;
}

.year-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 5px;
}

.year-grid button {
  height: 39px;
  padding: 0 4px;
  background: var(--paper);
  border: 1px solid var(--rule-strong);
  border-radius: var(--control-radius);
  color: var(--ink-soft);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.year-grid button:hover {
  border-color: var(--accent);
  color: var(--accent-ink);
}

.year-grid button[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  border-width: 2px;
  color: var(--accent-ink);
  box-shadow: none;
}

.year-note {
  margin: 4px 0 0;
  font-size: 10.5px;
  color: var(--muted);
}

/* Practice style sits between the year row and the settings rail, as on the
   reference generator: presets on the left, the download shortcut on the
   right, both centred between the two rules. */
.preset-bar {
  display: grid;
  grid-template-columns: minmax(0, 1.32fr) minmax(320px, 1fr);
  align-items: center;
  gap: 6px 20px;
  padding: 13px 26px 11px;
  border-bottom: 1px solid var(--rule);
}

.preset-main {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.preset-bar .step-label {
  margin-bottom: 0;
}

.preset-bar .preset-summary {
  margin-top: 0;
}

.preset-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--control-gap);
  /* A nudge left of the column centre, so the pair sits closer to the summary. */
  padding-right: 56px;
}

/* The preset bar keeps its own Generate (same handler as the dock one) so a
   preset can be applied without scrolling to the bottom. */
.preset-generate {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: var(--control-h-md);
  padding: 0 16px;
  border: 0;
  border-radius: var(--cta-radius);
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 6px 14px -10px rgba(47, 107, 79, 0.9);
}

.preset-generate svg {
  width: 14px;
  height: 14px;
}

.preset-generate:hover {
  background: #245741;
}

.btn-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: var(--control-h-md);
  padding: 0 14px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--control-radius);
  background: var(--paper);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.btn-outline svg {
  width: 15px;
  height: 15px;
}

.btn-outline:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.btn-outline:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ------------------------------------------------------------------ step 2 */

.preset-chips {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  flex: 1 1 auto;
  min-width: 0;
}

/* What the current preset will print, echoed under the chips. */
.preset-summary {
  margin: 4px 0 0;
  padding: 4px 8px;
  border-left: 3px solid var(--accent);
  border-radius: 0 6px 6px 0;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.35;
}

.preset-chip {
  height: 27px;
  padding: 0 9px;
  border-radius: var(--chip-radius);
  border: 1px solid var(--rule-strong);
  background: var(--paper);
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.preset-chip:hover {
  border-color: var(--accent);
  color: var(--accent-ink);
}

.preset-chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Desktop keeps one action: Generate worksheet (the preview is always on
   screen, so an eye toggle adds nothing). Phones get a PDF download instead. */
/* ------------------------------------------------------------- workspace */

.workspace {
  display: grid;
  grid-template-columns: minmax(0, var(--gen-rail-width)) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  height: clamp(380px, calc(100vh - 414px), 700px);
}

.control-rail {
  border-right: 1px solid var(--rule);
  background: var(--paper);
  display: flex;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.generator-form {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  margin: 0;
}

.form-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 20px 8px;
  scrollbar-width: thin;
}

/* When the settings overflow, the bottom fades so the cut never reads as a
   broken component. */
.form-scroll.is-scrollable {
  mask-image: linear-gradient(to bottom, #000 calc(100% - 26px), transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 26px), transparent 100%);
}

.field-group {
  margin: 0 0 10px;
}

/* ------------------------------------------------------------ practice UI */

.category-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  margin: 0 0 7px;
}

.category-grid button {
  min-height: var(--control-h-sm);
  padding: 6px 10px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--control-radius);
  background: var(--paper);
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 650;
  line-height: 1.25;
  text-align: left;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.category-grid button:hover {
  border-color: var(--accent);
  color: var(--accent-ink);
}

.category-grid button[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-ink);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.type-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.type-chip {
  height: var(--control-h-sm);
  padding: 0 13px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--control-radius);
  background: var(--paper);
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.type-chip:hover {
  border-color: var(--accent);
  color: var(--accent-ink);
}

.type-chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.basic-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 5px;
}

.basic-row .option-label {
  flex: none;
  width: 74px;
  margin: 0;
}

.count-select {
  flex: none;
  width: 84px;
  height: var(--control-h-sm);
  padding: 0 6px;
  border: 1px solid var(--rule-strong);
  border-radius: 7px;
  background: var(--paper);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.basic-row .check {
  margin-left: auto;
}

.preset-chips--mini .preset-chip {
  height: 22px;
  padding: 0 8px;
  font-size: 10.5px;
}

/* Low-frequency settings stay folded away until someone asks for them. */
.more-options {
  margin-top: 2px;
  padding-top: 5px;
  border-top: 1px solid var(--rule);
}

.more-options > summary {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  color: var(--accent-ink);
  font-size: 11.5px;
  font-weight: 700;
  list-style: none;
  cursor: pointer;
}

.more-options > summary::-webkit-details-marker {
  display: none;
}

.more-options > summary::before {
  content: "+";
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 12px;
  line-height: 1;
}

.more-options[open] > summary::before {
  content: "−";
}

.more-summary {
  margin-left: auto;
  padding-right: 2px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
}

.more-body {
  display: grid;
  gap: 8px;
  padding: 4px 0 2px;
}

/* Opening the advanced panel gives the rail more room so the extra rows are a
   short scroll rather than a cramped one, while the frame still ends near the
   fold. */
html.more-open .workspace {
  height: clamp(430px, calc(100vh - 344px), 780px);
}

.dock-hint {
  margin: 0;
  font-size: 10.5px;
  line-height: 1.4;
  color: var(--muted);
}

/* Print / PDF / Answers sit under the call to action, as on the reference
   generator: 36 high, 13.5 px, equal columns. */
.dock-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.dock-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: var(--control-h-sm);
  border: 1px solid var(--rule-strong);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink-soft);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 140ms ease, color 140ms ease, background 140ms ease;
}

.dock-actions button svg {
  width: 15px;
  height: 15px;
  flex: none;
}

.dock-actions button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent-ink);
}

.dock-actions button[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.dock-actions button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* topic chips */

/* option rows */

.option-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.option-row--stack {
  display: block;
  margin-top: 9px;
}

.option-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.option-label {
  display: block;
  margin-bottom: 0;
  flex: none;
  font-size: 11px;
  font-weight: 650;
  color: var(--ink-soft);
}

.option-row--stack .option-label {
  margin-bottom: 5px;
}

.option-head .option-label {
  margin-bottom: 5px;
}

.segmented {
  display: inline-flex;
  flex: 0 1 auto;
  border: 1px solid var(--rule-strong);
  border-radius: 7px;
  overflow: hidden;
  background: var(--paper);
  max-width: 100%;
  flex-wrap: wrap;
}

.segmented button {
  height: var(--control-h-sm);
  padding: 0 12px;
  background: transparent;
  border: 0;
  border-right: 1px solid var(--rule);
  color: var(--ink-soft);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.segmented button:last-child {
  border-right: 0;
}

.segmented button:hover {
  background: var(--surface-soft);
}

.segmented button[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
}

.mini-toggle {
  display: inline-flex;
  margin-left: auto;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  overflow: hidden;
}

.mini-toggle button {
  height: 24px;
  padding: 0 10px;
  background: var(--paper);
  border: 0;
  color: var(--ink-soft);
  font-size: 10.5px;
  font-weight: 650;
  cursor: pointer;
}

.mini-toggle button[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.table-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 3px;
}

.table-chip {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 25px;
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink-soft);
  font-size: 10.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  user-select: none;
}

.table-chip input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.table-chip:has(input:checked) {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.table-chip:has(input:focus-visible) {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.option-note {
  margin: 9px 0 0;
  font-size: 10.5px;
  color: var(--muted);
}

.paper-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 9px;
  padding-top: 7px;
  border-top: 1px dashed var(--rule);
}

.paper-row .option-label {
  margin: 0;
}

.paper-value {
  margin-left: auto;
  padding: 2px 8px;
  border: 1px solid var(--rule);
  border-radius: 5px;
  background: var(--surface-soft);
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------------ dock */

.control-dock {
  flex: none;
  display: grid;
  gap: 6px;
  padding: 7px 20px 8px;
  border-top: 1px solid var(--rule);
  background: #fdfbf7;
  box-shadow: 0 -12px 20px -18px rgba(61, 51, 41, 0.75);
}

/* Difficulty and questions sit on one line each so the dock stays short. */
.field-help {
  margin: 4px 0 0;
  font-size: 10px;
  line-height: 1.3;
  color: var(--muted);
}

.count-select:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px rgba(47, 107, 79, 0.12);
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
}

.check input {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
}

.dock-primary {
  display: flex;
  gap: 7px;
  margin-top: 1px;
}

#difficulty {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
}

#difficulty button {
  height: 39.5px;
  padding: 0 4px;
  border-radius: var(--control-radius);
  font-size: 15.5px;
}

.btn-generate {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: var(--cta-h);
  padding: 0 18px;
  border: 0;
  border-radius: var(--cta-radius);
  background: var(--accent);
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 8px 18px -12px rgba(47, 107, 79, 0.9);
  transition: background 140ms ease, transform 140ms ease;
}

.btn-generate svg {
  width: 15px;
  height: 15px;
}

.btn-generate:hover {
  background: var(--accent-ink);
}

.btn-generate:active {
  transform: translateY(1px);
}

.dock-primary .btn-generate {
  flex: 1;
}

.btn-reset {
  width: var(--control-h-lg);
  height: var(--control-h-lg);
  border: 1px solid var(--rule-strong);
  border-radius: var(--control-radius);
  background: var(--paper);
  color: var(--ink-soft);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}

.btn-reset:hover {
  border-color: var(--accent);
  color: var(--accent-ink);
}

.status {
  min-height: 13px;
  margin: 0;
  font-size: 10.5px;
  color: var(--accent-ink);
}

.status[data-tone="error"] {
  color: #a4341f;
}

/* --------------------------------------------------------------- preview */

/* The rail's slot in the workspace: keeps the rail stretched to the grid row
   so the stage, not the page, is what scrolls. */
.preview-home {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

.preview-home .preview-rail {
  flex: 1 1 auto;
  min-height: 0;
}

.preview-rail {
  display: flex;
  flex-direction: column;
  min-width: 0;
  /* The rail is a grid item, so without this its content can push it taller
     than the workspace row and the page scrolls instead of the stage. */
  min-height: 0;
  overflow: hidden;
  background: #f2efe9;
}

.preview-toolbar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  /* One row always: the heading shrinks and truncates instead of pushing the
     buttons onto a second row, which used to jump the whole toolbar. */
  flex-wrap: nowrap;
  min-height: 44px;
  height: 49px;
  padding: 5px 14px;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
}

.preview-heading {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
}

.preview-eyebrow {
  color: var(--ink-soft);
  font-size: 9.5px;
  font-weight: 750;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.preview-meta {
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
  flex-wrap: nowrap;
  margin-left: auto;
}

/* The answer toggle keeps its width when the label changes, so nothing beside
   it shifts. */
#toggleAnswers {
  min-width: 124px;
}

/* Page selector: the same list the reference site uses — all pages, one page,
   or the answer key. */
.preview-pager select {
  height: var(--control-h-md);
  padding: 0 26px 0 10px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--control-radius);
  background: var(--paper)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%235b6660' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
    no-repeat right 9px center / 10px 7px;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 650;
  appearance: none;
  cursor: pointer;
}

.preview-pager select:hover {
  border-color: var(--accent);
}

.preview-pager select:disabled {
  opacity: 0.5;
  cursor: default;
}

/* ------------------------------------------------------- expanded frame */

/* Pure CSS state: the generator frame is laid out over the viewport. No
   Fullscreen API, so behaviour is identical in every browser and there is
   no permission prompt; Esc is handled by the app. */
html.is-fullscreen,
html.is-fullscreen body {
  overflow: hidden;
}

/* Phone preview modal: the real preview panel moves in here, so the same
   toolbar and the same sheet are used on both sizes. */
html.is-preview-modal,
html.is-preview-modal body {
  overflow: hidden;
}

.preview-modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: stretch;
  justify-content: center;
}

.preview-modal[hidden] {
  display: none;
}

.preview-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(16, 24, 32, 0.55);
}

.preview-modal-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 100%;
  height: 100vh;
  height: 100dvh;
  background: var(--paper);
}

.preview-modal-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--rule);
  background: #fbf8f2;
}

.preview-modal-title {
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.preview-modal-close {
  width: 36px;
  height: 36px;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink-soft);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}

.preview-modal-close:hover {
  border-color: var(--accent);
  color: var(--accent-ink);
}

.preview-modal-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
}

.preview-modal-body .preview-rail {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* The modal bar already says Preview, so the panel's own heading is dropped. */
.preview-modal-body .preview-heading {
  display: none;
}

.preview-modal-body .preview-toolbar {
  padding: 8px 10px;
}

/* One row that can be swiped sideways, like the reference toolbar. */
.preview-modal-body .preview-actions {
  flex: 1 1 auto;
  min-width: 0;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.preview-modal-body .preview-actions::-webkit-scrollbar {
  display: none;
}

.preview-modal-body .preview-stage {
  flex: 1 1 auto;
  min-height: 0;
}

/* ------------------------------------------------------- expanded frame */

/* Pure CSS state: the generator frame is laid out over the viewport. No
   Fullscreen API, so behaviour is identical in every browser and there is
   no permission prompt; Esc is handled by the app. */
html.is-fullscreen,
html.is-fullscreen body {
  overflow: hidden;
}

/* Phone PDF preview: the built document fills the screen over the page. */
html.is-pdf-preview,
html.is-pdf-preview body {
  overflow: hidden;
}

.pdf-preview {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  flex-direction: column;
  background: #1d211f;
  color: #f4f1ea;
}

.pdf-preview[hidden] {
  display: none;
}

.pdf-preview-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: #161917;
  border-bottom: 1px solid rgba(244, 241, 234, 0.14);
}

.pdf-preview-bar strong {
  font-size: 14px;
  font-weight: 650;
  letter-spacing: 0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pdf-preview-close {
  width: 36px;
  height: 36px;
  flex: none;
  border: 1px solid rgba(244, 241, 234, 0.28);
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}

.pdf-preview-close:hover {
  background: rgba(244, 241, 234, 0.12);
}

.pdf-preview-body {
  flex: 1 1 auto;
  min-height: 0;
  background: #33383a;
}

.pdf-preview-body object {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #33383a;
}

.pdf-preview-fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  height: 100%;
  padding: 24px;
  font-size: 14px;
  color: rgba(244, 241, 234, 0.8);
  text-align: center;
}

.pdf-preview .pdf-preview-open {
  padding: 10px 16px;
  border: 1px solid rgba(244, 241, 234, 0.4);
  border-radius: 999px;
  background: rgba(244, 241, 234, 0.08);
  color: #f4f1ea;
  font-weight: 650;
  text-decoration: none;
}

.pdf-preview .pdf-preview-open:hover {
  background: rgba(244, 241, 234, 0.18);
}

.pdf-preview-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: #161917;
  border-top: 1px solid rgba(244, 241, 234, 0.14);
}

.pdf-preview-note {
  margin: 0;
  font-size: 12px;
  color: rgba(244, 241, 234, 0.72);
}

.pdf-preview-download {
  flex: none;
  padding: 9px 14px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.pdf-preview-download:hover {
  background: #245741;
}

html.is-fullscreen .site-head,
html.is-fullscreen .site-foot,
html.is-fullscreen .page-intro,
html.is-fullscreen .page-note,
html.is-fullscreen .content,
html.is-fullscreen .section-block {
  display: none;
}

html.is-fullscreen #generator {
  position: fixed;
  inset: 0;
  z-index: 200;
  margin: 0;
  border: 0;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  background: var(--paper);
  box-shadow: none;
}

html.is-fullscreen #generator .workspace {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
  grid-template-columns: minmax(0, 540px) minmax(0, 1fr);
}

#expandTop .icon-collapse {
  display: none;
}

#expandTop[aria-pressed="true"] .icon-expand {
  display: none;
}

#expandTop[aria-pressed="true"] .icon-collapse {
  display: block;
}

@media (max-width: 900px) {
  #expandTop {
    display: none;
  }
}

.btn-answer {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: var(--control-h-md);
  padding: 0 12px;
  background: var(--paper);
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  color: var(--ink-soft);
  font-size: 10.5px;
  font-weight: 650;
  white-space: nowrap;
  cursor: pointer;
}

.btn-answer svg {
  width: 13px;
  height: 13px;
}

.btn-answer:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn-answer[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn-answer:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-icon {
  width: var(--control-h-md);
  padding: 0;
}

#fit {
  min-width: 51px;
  border-radius: var(--chip-radius);
}

.preview-stage {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.preview-canvas {
  position: relative;
  margin: 0 auto;
  flex: none;
}

.preview-content {
  transform-origin: top left;
  width: 210mm;
}

.preview-content .sheet {
  box-shadow: 0 10px 28px -18px rgba(61, 51, 41, 0.5);
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  background: #fff;
}

.preview-content .sheet + .sheet {
  margin-top: 10mm;
}

.preview-content .sheet[data-kind="answer"] {
  display: none;
}

/* Showing the key adds the answer sheets under the questions rather than
   replacing them, so "All pages" keeps every page and the view simply scrolls
   down to the answers. */
.preview-content.show-answers .sheet[data-kind="answer"] {
  display: grid;
}

/* A single page can be isolated from the page selector in the toolbar. */
.preview-content.view-page .sheet {
  display: none;
}

.preview-content.view-page .sheet.is-current {
  display: grid;
}

/* The selector's own "Answer key" mode hides the questions. */
.preview-content.view-answers .sheet[data-kind="questions"] {
  display: none;
}

.preview-content.view-answers .sheet[data-kind="answer"] {
  display: grid;
}

.preview-empty {
  margin: 0;
  max-width: 34ch;
  padding: 18px 20px;
  border: 1px dashed var(--rule-strong);
  border-radius: 10px;
  background: rgba(255, 253, 250, 0.7);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

/* -------------------------------------------------------- static PDF list */

.section-block {
  padding: 6px 0 4px;
}

.section-block > p {
  max-width: 74ch;
  color: var(--ink-soft);
}

.pdf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 8px;
  list-style: none;
  padding: 0;
  margin: 16px 0 8px;
}

/* A real sheet, shown at a readable size next to the copy. */
.preview-figure {
  margin: 20px 0 8px;
  padding: 16px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 12px;
  text-align: center;
}

.preview-figure img {
  width: 100%;
  max-width: 520px;
  height: auto;
  border: 1px solid var(--rule);
  border-radius: 4px;
  box-shadow: 0 10px 26px -18px rgba(16, 24, 32, 0.5);
}

.preview-figure figcaption {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}

.pdf-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 13px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 9px;
  text-decoration: none;
  color: var(--ink);
  font-size: 13.5px;
  line-height: 1.3;
}

.pdf-item:hover {
  border-color: var(--accent);
  color: var(--accent-ink);
}

.pdf-item small {
  display: block;
  color: var(--muted);
  font-size: 11.5px;
  margin-top: 2px;
}

.pdf-badge {
  flex: none;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #8a2f23;
  background: #fbeceb;
  border: 1px solid #f0cfcb;
  border-radius: 5px;
  padding: 2px 6px;
}

.pdf-item[aria-current="true"] {
  border-color: var(--accent);
  background: #f7fbf9;
}

.pdf-item[aria-current="true"] .pdf-badge {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

/* ---------------------------------------------------------------- content */

.content {
  max-width: 74ch;
  padding-bottom: 30px;
  margin: 0 auto;
}

/* Section rhythm from the reference site: a small green kicker, then a centred
   serif heading, with the prose itself left-aligned. */
.section-kicker {
  margin: 44px 0 8px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.14em;
  line-height: 1.2;
  text-align: center;
  text-transform: uppercase;
}

.content > .section-kicker:first-child,
.section-block > .section-kicker:first-child {
  margin-top: 0;
}

.content h2 {
  margin: 0 0 14px;
  text-align: center;
}

.section-block h2 {
  margin: 0 0 10px;
  text-align: center;
}

.section-lede {
  max-width: 66ch;
  margin: 0 auto 20px;
  color: var(--muted);
  text-align: center;
  line-height: 1.7;
}

.content p,
.content li {
  color: #4a4037;
  font-size: 1rem;
  line-height: 1.75;
}

.content p {
  margin: 0 0 1.05em;
}

[id] {
  scroll-margin-top: 84px;
}

.content ol,
.content ul {
  padding-left: 1.4em;
}

.content .note {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 13px 15px;
  font-size: 14.5px;
}

.faq {
  margin-top: 8px;
}

.faq-item {
  border-bottom: 1px solid var(--rule);
  padding: 13px 0;
}

.faq-item summary {
  cursor: pointer;
  font-weight: 650;
  font-size: 1rem;
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: baseline;
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary::after {
  content: "+";
  font-weight: 400;
  font-size: 1.3rem;
  line-height: 1;
  color: var(--accent);
  flex: none;
}

.faq-item[open] summary::after {
  content: "\2212";
}

.faq-item p {
  margin: 9px 0 0;
  color: var(--ink-soft);
  font-size: 15px;
}

.related {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  list-style: none;
  padding: 0;
  margin: 14px 0 0;
}

.related a {
  display: inline-flex;
  align-items: center;
  padding: 6px 11px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--paper);
  font-size: 13px;
  text-decoration: none;
  color: var(--ink-soft);
}

.related a:hover {
  border-color: var(--accent);
  color: var(--accent-ink);
}

.pager {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 24px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
  font-size: 14px;
}

/* -------------------------------------------------------------- hub cards */

.year-grid-links,
.hub-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  list-style: none;
  padding: 0;
  margin: 16px auto 0;
  max-width: 1060px;
}

/* Three cards per row, and any short last row stays centred. */
.hub-grid > li {
  display: flex;
  flex: 0 1 calc((100% - 24px) / 3);
  min-width: 240px;
  max-width: 340px;
}

.hub-block {
  max-width: 1120px;
  margin: 0 auto;
  padding-bottom: 8px;
}

.hub-block h2 {
  font-size: clamp(1.4rem, 1.2rem + 0.9vw, 1.9rem);
}

.hub-card {
  display: block;
  flex: 1 1 auto;
  padding: 14px 16px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 10px;
  text-decoration: none;
  color: var(--ink);
}

.hub-card:hover {
  border-color: var(--accent);
}

.hub-card strong {
  display: block;
  font-size: 0.98rem;
  margin-bottom: 3px;
}

.hub-card span {
  font-size: 12.5px;
  color: var(--muted);
}

/* ----------------------------------------------------------------- footer */

.site-foot {
  margin-top: 44px;
  background: #2b241d;
  color: #cfc6bb;
  padding: 34px 0 26px;
  font-size: 13.5px;
}

.site-foot .wrap {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 26px;
}

.site-foot h2,
.site-foot .footer-heading {
  color: #fff;
  font-size: 12px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  margin: 0 0 10px;
}

.site-foot a {
  color: #e4dcd2;
  text-decoration: none;
}

.site-foot a:hover {
  color: #fff;
  text-decoration: underline;
}

.site-foot ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.site-foot li {
  margin-bottom: 5px;
}

.foot-legal {
  grid-column: 1 / -1;
  border-top: 1px solid #3c342b;
  padding-top: 14px;
  color: #a2968a;
  font-size: 12.5px;
}

/* ------------------------------------------------------------- responsive */

@media (max-width: 1099px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr);
    height: auto;
    min-height: 0;
  }

  .control-rail {
    border-right: 0;
    border-bottom: 1px solid var(--rule);
  }

  .form-scroll {
    overflow: visible;
  }

  .preview-stage {
    max-height: 620px;
  }
}

@media (max-width: 720px) {
  /* The mobile entry point: Generate stays reachable without scrolling to the
     end of the form (F06). */
  .dock-primary {
    position: sticky;
    bottom: 8px;
    z-index: 5;
  }

  .dock-primary .btn-generate {
    box-shadow: 0 12px 26px -12px rgba(47, 107, 79, 0.9);
  }

  .ledes {
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
  }

  .year-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .topic-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .table-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .preset-bar {
    grid-template-columns: minmax(0, 1fr);
  }

  .preset-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    width: 100%;
  }

  .preset-actions .btn-generate {
    width: 100%;
    white-space: nowrap;
  }

  .preset-actions .preset-pdf {
    display: inline-flex;
  }

  .preset-hint {
    display: none;
  }

  .site-foot .wrap {
    grid-template-columns: 1fr;
  }

  .quick-guide {
    padding: 8px 16px;
  }

  .year-bar,
  .preset-bar,
  .form-scroll,
  .control-dock {
    padding-left: 16px;
    padding-right: 16px;
  }
}
