@font-face {
  font-family: "Teachers";
  src: url("../fonts/Teachers-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Playwrite US Trad";
  src: url("../fonts/playwrite-us-trad/PlaywriteUSTrad-wght.woff2") format("woff2");
  font-weight: 100 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Playwrite US Modern";
  src: url("../fonts/playwrite-us-modern/PlaywriteUSModern-wght.woff2") format("woff2");
  font-weight: 100 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --brand: #1f4e79;
  --brand-hover: #163b5c;
  --brand-soft: #eaf1f8;
  --bg: #f6f5f1;
  --surface: #ffffff;
  --canvas-bg: #e7e5df;
  --ink: #1e293b;
  --ink-muted: #526071;
  --border: #d8d5cd;
  --border-strong: #bdb9ae;
  --focus: #1f4e79;
  --radius-sm: 6px;
  --radius-md: 10px;
  --shadow-card: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sheet: 0 6px 20px rgba(15, 23, 42, 0.12), 0 1px 4px rgba(15, 23, 42, 0.08);
  --font-ui: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  color-scheme: light;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  accent-color: var(--brand);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  line-height: 1.25;
  letter-spacing: -0.015em;
  text-wrap: balance;
  color: #0f172a;
}

p,
li {
  text-wrap: pretty;
}

a {
  color: var(--brand);
}

a:hover {
  color: var(--brand-hover);
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* Skip link */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--brand);
  color: #ffffff;
  padding: 10px 16px;
  z-index: 1000;
  text-decoration: none;
  font-weight: 600;
}

.skip-link:focus {
  left: 12px;
  top: 12px;
  border-radius: var(--radius-sm);
}

/* Layout container */
.container {
  width: 100%;
  max-width: 1200px;
  margin-inline: auto;
  padding-inline: 20px;
}

.content-width {
  max-width: 820px;
}

/* Header */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 68px;
  padding-block: 10px;
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--ink);
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--brand);
  color: #ffffff;
  font-family: "Teachers", var(--font-ui);
  font-size: 20px;
  font-weight: 400;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: #0f172a;
}

.brand-tagline {
  font-size: 0.78rem;
  color: var(--ink-muted);
}

.nav-list {
  display: flex;
  align-items: center;
  gap: 6px;
  list-style: none;
  margin: 0;
  padding: 0;
  flex-wrap: wrap;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--ink-muted);
}

.nav-link:hover {
  background: var(--brand-soft);
  color: var(--brand);
}

.nav-link[aria-current="page"] {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
}

/* Hero */
.hero {
  padding: 32px 0 22px;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--brand);
}

.hero h1 {
  margin: 0 0 10px;
  font-size: clamp(1.7rem, 2.8vw, 2.35rem);
}

.hero-lead {
  margin: 0;
  max-width: 68ch;
  color: var(--ink-muted);
  font-size: 1.02rem;
}

/* Workspace */
.workspace {
  padding-bottom: 48px;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

/* Controls panel */
.controls-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-card);
  position: sticky;
  top: 20px;
}

.controls-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding: 0;
  border: 0;
}

.field-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 8px;
}

.field-group label,
.radio-fieldset legend {
  font-size: 0.9rem;
  font-weight: 600;
  color: #0f172a;
}

.radio-fieldset legend {
  padding: 0;
  margin-bottom: 6px;
}

.field-group output {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--brand);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.inline-actions {
  display: inline-flex;
  gap: 10px;
}

.text-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--brand);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 4px 2px;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: underline;
  text-underline-offset: 2px;
}

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

.controls-form textarea {
  width: 100%;
  min-height: 118px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--ink);
  background: #ffffff;
  resize: vertical;
}

.controls-form textarea:focus {
  border-color: var(--brand);
}

.field-hint {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--ink-muted);
}

/* Paper size radio options */
.paper-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.paper-choice {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #ffffff;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.88rem;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.paper-choice:has(input:checked) {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.paper-choice > span {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.nowrap {
  white-space: nowrap;
}

.paper-choice small {
  font-size: 0.74rem;
  color: var(--ink-muted);
  font-weight: 400;
}

.paper-choice input[type="radio"] {
  margin: 0;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Range controls */
input[type="range"] {
  width: 100%;
  margin: 4px 0 0;
  cursor: pointer;
  min-height: 28px;
}

.range-scale {
  display: flex;
  justify-content: space-between;
  font-size: 0.74rem;
  color: var(--ink-muted);
}

.two-col-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.checkbox-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
}

.checkbox-option input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  flex-shrink: 0;
  cursor: pointer;
}

.shade-readout {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.shade-swatch {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid #94a3b8;
  background: #c4c4c4;
}

/* Fallback for older browsers without accent-color support */
@supports not (accent-color: #1f4e79) {
  .checkbox-option {
    position: relative;
    padding-left: 26px;
  }

  .checkbox-option input[type="checkbox"] {
    position: absolute !important;
    clip-path: inset(50%) !important;
    overflow: hidden !important;
    width: 1px !important;
    height: 1px !important;
    margin: -1px !important;
    padding: 0 !important;
    border: 0 !important;
    white-space: nowrap !important;
  }

  .checkbox-option input[type="checkbox"] + span::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-strong);
    border-radius: 4px;
    background: #ffffff;
    box-sizing: border-box;
  }

  .checkbox-option input[type="checkbox"]:focus-visible + span::before {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
  }

  .checkbox-option input[type="checkbox"]:checked + span::before {
    background-color: var(--brand);
    border-color: var(--brand);
  }

  .checkbox-option input[type="checkbox"]:checked + span::after {
    content: "✓";
    position: absolute;
    left: 3px;
    top: 50%;
    transform: translateY(-50%);
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
  }

  input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
  }

  input[type="range"]::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px;
    background: linear-gradient(to right, var(--brand) var(--progress, 50%), #cbd5e1 var(--progress, 50%));
    border-radius: 3px;
  }

  input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    height: 18px;
    width: 18px;
    border-radius: 50%;
    background: var(--brand);
    border: 2px solid #ffffff;
    box-shadow: 0 0 0 1px var(--brand);
    margin-top: -6px;
  }

  input[type="range"]::-moz-range-track {
    width: 100%;
    height: 6px;
    background: #cbd5e1;
    border-radius: 3px;
  }

  input[type="range"]::-moz-range-progress {
    height: 6px;
    background: var(--brand);
    border-radius: 3px;
  }

  input[type="range"]::-moz-range-thumb {
    height: 18px;
    width: 18px;
    border-radius: 50%;
    background: var(--brand);
    border: 2px solid #ffffff;
  }
}

/* Buttons */
.panel-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 4px;
}

.btn-primary,
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 46px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: 0.96rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.btn-primary {
  background: var(--brand);
  color: #ffffff;
  border: 1px solid var(--brand);
}

.btn-primary:hover:not(:disabled) {
  background: var(--brand-hover);
  border-color: var(--brand-hover);
}

.btn-primary:disabled {
  background: #94a3b8;
  border-color: #94a3b8;
  cursor: not-allowed;
}

.btn-secondary {
  background: #ffffff;
  color: var(--ink);
  border: 1px solid var(--border-strong);
}

.btn-secondary:hover {
  background: #f1f5f9;
}

.privacy-note {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--ink-muted);
}

/* Preview column */
.preview-column {
  min-width: 0;
}

.preview-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 16px;
  margin-bottom: 12px;
}

.preview-summary {
  font-size: 0.94rem;
  font-weight: 700;
  color: #0f172a;
}

.print-tip {
  margin: 0;
  font-size: 0.82rem;
  color: var(--ink-muted);
}

.fit-notice {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: #fef9e7;
  border: 1px solid #e9d28a;
  color: #5c4608;
  font-size: 0.84rem;
}

.worksheets-output {
  background: var(--canvas-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.worksheet-page {
  width: 100%;
  max-width: 720px;
  background: #ffffff;
  box-shadow: var(--shadow-sheet);
  border-radius: 3px;
  padding: 5.8% 5.8%;
}

.worksheets-output.paper-a4 .worksheet-page {
  max-width: 698px;
}

.worksheet-svg {
  display: block;
  width: 100%;
  height: auto;
}

.empty-state {
  width: 100%;
  max-width: 560px;
  background: #ffffff;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 40px 24px;
  text-align: center;
  color: var(--ink-muted);
}

.empty-state p {
  margin: 0;
}

/* Info section */
.info-section {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 48px 0;
}

.info-section h2,
.faq-section h2 {
  margin: 0 0 14px;
  font-size: 1.5rem;
}

.steps-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  list-style: none;
  margin: 24px 0 28px;
  padding: 0;
}

.step-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
}

.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--brand);
  color: #ffffff;
  font-size: 0.86rem;
  font-weight: 700;
  margin-bottom: 10px;
}

.step-card h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.step-card p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--ink-muted);
}

.guide-note {
  padding: 18px 20px;
  border-left: 4px solid var(--brand);
  background: var(--brand-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.guide-note h3 {
  margin: 0 0 6px;
  font-size: 1.02rem;
}

.guide-note p {
  margin: 0;
  font-size: 0.93rem;
  color: var(--ink);
}

/* FAQ Accordion */
.faq-section {
  padding: 48px 0 56px;
  border-top: 1px solid var(--border);
}

.accordion {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 18px;
}

.accordion details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.accordion summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  font-weight: 600;
  color: #0f172a;
  cursor: pointer;
}

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

.accordion summary::before {
  content: "";
  inline-size: 0.65em;
  block-size: 0.65em;
  flex-shrink: 0;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  margin-top: -1px;
}

.accordion details[open] > summary::before {
  transform: rotate(45deg);
  margin-top: -4px;
}

.accordion details::details-content {
  interpolate-size: allow-keywords;
  overflow: clip;
  contain: layout;
}

.accordion details:not([open])::details-content {
  block-size: 0;
}

@media (prefers-reduced-motion: no-preference) {
  .accordion summary::before {
    transition: transform 0.2s ease;
  }

  .accordion details::details-content {
    transition: block-size 0.25s ease, content-visibility 0.25s ease;
    transition-behavior: allow-discrete;
  }
}

.faq-answer {
  padding: 0 16px 16px 36px;
  color: var(--ink-muted);
  font-size: 0.95rem;
}

.faq-answer p {
  margin: 0;
}

/* Related tools section */
.related-section {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 40px 0 48px;
}

.related-section h2 {
  margin: 0 0 16px;
  font-size: 1.35rem;
}

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

.related-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
  text-decoration: none;
  color: var(--ink);
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.related-card:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--ink);
}

.related-title {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--brand);
}

.related-desc {
  font-size: 0.86rem;
  line-height: 1.45;
  color: var(--ink-muted);
}

/* 404 page */
.not-found-section {
  padding: 48px 0 64px;
}

.not-found-section h1 {
  margin: 0 0 12px;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
}

.not-found-lead {
  margin: 0 0 28px;
  max-width: 60ch;
  color: var(--ink-muted);
}

.not-found-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.not-found-grid .related-card {
  background: var(--surface);
}

/* Reusable choice grids & custom inputs for tool controls */
.choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.choice-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.text-input,
.number-input {
  width: 100%;
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: 1rem;
  color: var(--ink);
  background: #ffffff;
}

.text-input:focus,
.number-input:focus {
  border-color: var(--brand);
}

.range-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* Footer */
.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 28px 0;
  font-size: 0.86rem;
  color: var(--ink-muted);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 16px 32px;
}

.footer-brand strong {
  display: block;
  color: #0f172a;
  margin-bottom: 4px;
}

.footer-brand p,
.footer-meta p {
  margin: 0 0 4px;
  max-width: 52ch;
}

/* Responsive */
@media (max-width: 900px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .controls-panel {
    position: static;
  }

  .worksheets-output {
    padding: 14px;
    gap: 16px;
  }

  .steps-grid,
  .related-grid,
  .not-found-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .container {
    padding-inline: 14px;
  }

  .paper-options,
  .two-col-controls {
    grid-template-columns: 1fr;
  }

  .hero {
    padding-top: 22px;
  }
}

/* Print styles: output worksheets only, one student name per page */
@media print {
  .no-print {
    display: none !important;
  }

  html,
  body {
    margin: 0 !important;
    padding: 0 !important;
    background: #ffffff !important;
    width: auto !important;
    height: auto !important;
  }

  .site-main,
  .workspace,
  .container,
  .workspace-grid,
  .preview-column,
  .worksheets-output {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    max-width: none !important;
    width: 100% !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: #ffffff !important;
    box-shadow: none !important;
  }

  .empty-state {
    display: none !important;
  }

  .worksheet-page {
    display: block !important;
    width: 100% !important;
    height: 99vh !important;
    max-width: 100% !important;
    max-height: 99vh !important;
    overflow: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: #ffffff !important;
    break-inside: avoid;
    page-break-inside: avoid;
    break-after: page;
    page-break-after: always;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .worksheet-page:last-child {
    break-after: auto;
    page-break-after: auto;
  }

  .worksheet-svg {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
