:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #233044;
  --muted: #657085;
  --brand: #1f7a8c;
  --brand-dark: #14596a;
  --accent: #d9573f;
  --soft: #e8eef6;
  --paper: #fffdf8;
  --line-blue: rgba(68, 111, 178, 0.32);
  --line-red: rgba(207, 80, 80, 0.48);
  --guide: rgba(101, 112, 133, 0.45);
  --shadow: 0 18px 60px rgba(35, 48, 68, 0.15);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(31, 122, 140, 0.08) 1px, transparent 1px),
    linear-gradient(180deg, rgba(31, 122, 140, 0.08) 1px, transparent 1px),
    var(--bg);
  background-size: 28px 28px;
  font-family:
    Inter, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(300px, 380px) 1fr;
  min-height: 100vh;
}

.controls {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 22px;
  background: rgba(255, 255, 255, 0.94);
  border-right: 1px solid rgba(35, 48, 68, 0.12);
  backdrop-filter: blur(10px);
}

.brand {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 14px;
  align-items: center;
  margin-bottom: 22px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  color: #ffffff;
  background: var(--brand);
  border-radius: 8px;
  font-family: "Segoe Print", "Comic Sans MS", cursive;
  font-size: 21px;
  font-weight: 700;
}

.brand h1,
.topbar h2,
.sheet-header h3 {
  margin: 0;
}

.brand h1 {
  font-size: 1.35rem;
  line-height: 1.1;
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.35;
}

.control-panel {
  display: grid;
  gap: 16px;
}

.panel-section {
  display: grid;
  gap: 13px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid rgba(35, 48, 68, 0.1);
  border-radius: 8px;
}

.section-title {
  color: var(--brand-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 5px;
  background: #edf3f8;
  border-radius: 8px;
}

.segment {
  min-height: 36px;
  padding: 7px 8px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 6px;
  font-size: 0.88rem;
  font-weight: 700;
}

.segment.is-active {
  color: #ffffff;
  background: var(--brand);
  box-shadow: 0 8px 16px rgba(31, 122, 140, 0.22);
}

.field,
.range-field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  color: var(--ink);
  background: #fbfcfe;
  border: 1px solid rgba(35, 48, 68, 0.18);
  border-radius: 8px;
  outline: 0;
}

.field input,
.field select {
  height: 42px;
  padding: 0 11px;
}

.field textarea {
  min-height: 94px;
  padding: 10px 11px;
  resize: vertical;
  line-height: 1.35;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(31, 122, 140, 0.12);
}

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

.range-field strong {
  color: var(--ink);
  font-weight: 800;
}

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

.toggle {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 10px;
  align-items: center;
  color: var(--ink);
  font-size: 0.94rem;
  font-weight: 650;
}

.toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
}

.layout-warning {
  flex-basis: 100%;
  padding: 10px 12px;
  color: #7a3b15;
  background: #fff4df;
  border: 1px solid rgba(217, 87, 63, 0.22);
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 750;
  line-height: 1.35;
}

[hidden] {
  display: none !important;
}

.actions,
.topbar-actions,
.mini-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.actions,
.mini-actions {
  flex-wrap: wrap;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 800;
}

.button span {
  font-size: 1.1rem;
  line-height: 1;
}

.button.primary {
  color: #ffffff;
  background: var(--accent);
  box-shadow: 0 10px 20px rgba(217, 87, 63, 0.23);
}

.button.secondary {
  color: var(--brand-dark);
  background: #ffffff;
  border-color: rgba(31, 122, 140, 0.2);
}

.button.compact {
  min-height: 38px;
  padding: 0 13px;
}

.mini-actions .button {
  flex: 1 1 0;
  min-width: 0;
}

.workspace {
  min-width: 0;
  padding: 26px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin: 0 auto 20px;
  max-width: 1050px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar h2 {
  font-size: clamp(1.35rem, 2vw, 2rem);
}

.preview-stage {
  display: grid;
  place-items: start center;
  overflow: auto;
  padding: 8px 0 34px;
}

.sheet-stack {
  display: grid;
  gap: 20px;
  justify-items: center;
  width: 100%;
}

.sheet {
  --row-font-size: 34px;
  --trace-opacity: 0.38;
  width: min(100%, 210mm);
  min-width: 620px;
  aspect-ratio: 210 / 297;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 18mm 16mm 12mm;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 253, 248, 0.95)),
    var(--paper);
  border: 1px solid rgba(35, 48, 68, 0.12);
  box-shadow: var(--shadow);
}

.sheet.theme-classic {
  --paper: #fffdf8;
}

.sheet.theme-color {
  --paper: #fffdf8;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 253, 248, 0.95)),
    linear-gradient(135deg, rgba(31, 122, 140, 0.08), transparent 42%),
    linear-gradient(315deg, rgba(217, 87, 63, 0.07), transparent 44%),
    var(--paper);
}

.sheet.theme-calm {
  --brand: #526f7d;
  --brand-dark: #314d5a;
  --accent: #7b8f62;
  --paper: #fffef9;
  --line-blue: rgba(72, 102, 130, 0.28);
  --line-red: rgba(154, 96, 78, 0.36);
}

.sheet.theme-ink {
  --brand: #4f545b;
  --brand-dark: #282d33;
  --accent: #5c6066;
  --paper: #ffffff;
  --line-blue: rgba(35, 48, 68, 0.28);
  --line-red: rgba(35, 48, 68, 0.24);
  background: #ffffff;
}

.sheet-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: start;
  padding-bottom: 9mm;
}

.sheet-kicker {
  margin: 0 0 2mm;
  color: var(--brand-dark);
  font-size: 10pt;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.sheet-header h3 {
  font-size: 24pt;
  line-height: 1.1;
}

.sheet-meta {
  display: grid;
  gap: 4mm;
  min-width: 50mm;
  margin: 0;
  font-size: 10pt;
}

.sheet-meta div {
  display: grid;
  grid-template-columns: 13mm 1fr;
  gap: 4mm;
  align-items: end;
}

.sheet-meta dt {
  color: var(--muted);
  font-weight: 800;
}

.sheet-meta dd {
  min-width: 34mm;
  margin: 0;
  padding-bottom: 1.5mm;
  border-bottom: 1px solid rgba(35, 48, 68, 0.35);
  color: var(--ink);
  font-weight: 700;
}

.writing-area {
  display: grid;
  grid-auto-rows: 1fr;
  gap: 2.3mm;
  min-height: 0;
}

.sentence-area {
  display: grid;
  gap: 3mm;
  min-height: 0;
}

.sentence-exercise {
  position: relative;
  display: grid;
  grid-template-columns: 12mm 1fr;
  gap: 3mm;
  min-height: 0;
  padding: 2.6mm 3.2mm;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(31, 122, 140, 0.08), transparent 16mm),
    rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(35, 48, 68, 0.14);
  border-radius: 6px;
  box-shadow: inset 1.6mm 0 0 rgba(31, 122, 140, 0.12);
}

.sentence-number {
  display: grid;
  place-items: center;
  align-self: start;
  width: 9mm;
  height: 9mm;
  color: #ffffff;
  background: var(--brand);
  border-radius: 50%;
  font-size: 8pt;
  font-weight: 900;
  box-shadow: 0 1mm 2mm rgba(35, 48, 68, 0.16);
}

.sentence-content {
  display: grid;
  gap: 1.3mm;
  min-width: 0;
  min-height: 0;
}

.sentence-title {
  color: var(--brand-dark);
  font-size: 8.5pt;
  font-weight: 900;
  text-transform: uppercase;
}

.sentence-prompt {
  margin: 0;
  color: var(--ink);
  font-size: 12.5pt;
  font-weight: 800;
  line-height: 1.22;
}

.word-bank {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  padding: 1.5mm 2.5mm;
  color: var(--muted);
  background: rgba(31, 122, 140, 0.08);
  border: 1px solid rgba(31, 122, 140, 0.14);
  border-radius: 6px;
  font-size: 9pt;
  font-weight: 850;
  line-height: 1.18;
}

.answer-zone {
  position: relative;
  display: grid;
  min-height: 10mm;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.34);
  border-radius: 2px;
}

.theme-calm .sentence-exercise {
  background:
    linear-gradient(90deg, rgba(82, 111, 125, 0.08), transparent 16mm),
    rgba(255, 255, 255, 0.82);
  box-shadow: inset 1.6mm 0 0 rgba(82, 111, 125, 0.11);
}

.theme-ink .sentence-exercise {
  background: #ffffff;
  box-shadow: inset 1.2mm 0 0 rgba(35, 48, 68, 0.08);
}

.answer-zone span {
  display: block;
  border-bottom: 1px solid var(--line-blue);
}

.answer-zone-single {
  align-items: end;
}

.answer-zone-three {
  min-height: 13mm;
  grid-template-rows: repeat(3, 1fr);
}

.answer-zone-three span:nth-child(2) {
  border-bottom-color: rgba(68, 111, 178, 0.18);
}

.answer-zone-grid {
  min-height: 13mm;
  background:
    repeating-linear-gradient(90deg, transparent 0 7mm, rgba(68, 111, 178, 0.18) 7mm 7.25mm),
    repeating-linear-gradient(180deg, transparent 0 7mm, rgba(68, 111, 178, 0.22) 7mm 7.25mm);
}

.answer-space-compact {
  gap: 2.2mm;
}

.answer-space-compact .sentence-exercise {
  padding-block: 2.2mm;
}

.answer-space-compact .answer-zone {
  min-height: 8mm;
}

.answer-space-compact .answer-zone-three,
.answer-space-compact .answer-zone-grid {
  min-height: 10mm;
}

.answer-space-roomy {
  gap: 4mm;
}

.answer-space-roomy .sentence-exercise {
  padding-block: 3.4mm;
}

.answer-space-roomy .answer-zone {
  min-height: 13mm;
}

.answer-space-roomy .answer-zone-three,
.answer-space-roomy .answer-zone-grid {
  min-height: 18mm;
}

.sentence-area.is-dense-sentence {
  gap: 2mm;
}

.sentence-area.is-dense-sentence .sentence-exercise {
  padding-block: 2mm;
}

.sentence-area.is-dense-sentence .sentence-content {
  gap: 1mm;
}

.sentence-area.is-dense-sentence .sentence-prompt {
  font-size: 11.3pt;
  line-height: 1.15;
}

.sentence-area.is-dense-sentence .word-bank {
  padding-block: 1mm;
  font-size: 8.2pt;
}

.sentence-area.is-dense-sentence .answer-zone-three {
  min-height: 10.5mm;
}

.flashcard-area {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5mm;
  min-height: 0;
}

.flashcard-area.cards-many {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.flashcard {
  --card-accent: var(--brand);
  --card-accent-rgb: 31, 122, 140;
  --card-soft: #e3f3f6;
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-rows: auto minmax(18mm, 0.8fr) auto auto;
  gap: 1.2mm;
  min-height: 0;
  padding: 3.6mm 3.4mm 3.8mm;
  overflow: hidden;
  background:
    linear-gradient(140deg, var(--card-soft) 0%, rgba(255, 255, 255, 0.96) 40%, #ffffff 100%),
    linear-gradient(90deg, rgba(var(--card-accent-rgb), 0.08) 1px, transparent 1px),
    linear-gradient(180deg, rgba(var(--card-accent-rgb), 0.08) 1px, transparent 1px),
    #ffffff;
  background-size: 8mm 8mm;
  border: 1px dashed rgba(35, 48, 68, 0.45);
  border-radius: 6px;
}

.flashcard::before {
  position: absolute;
  inset: 2mm;
  z-index: 0;
  content: "";
  border: 1px solid rgba(var(--card-accent-rgb), 0.2);
  border-radius: 4px;
  pointer-events: none;
}

.flashcard::after {
  position: absolute;
  right: 1mm;
  bottom: 1mm;
  z-index: 0;
  content: attr(data-letter);
  color: rgba(var(--card-accent-rgb), 0.12);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 36pt;
  font-weight: 900;
  line-height: 1;
  pointer-events: none;
}

.flashcard-label {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--card-accent);
  font-size: 7.5pt;
  font-weight: 900;
  text-transform: uppercase;
}

.flashcard-art {
  position: relative;
  z-index: 1;
  display: grid;
  min-height: 21mm;
  place-items: center;
}

.flashcard-art::before {
  position: absolute;
  width: min(44mm, 78%);
  height: 76%;
  content: "";
  background: rgba(var(--card-accent-rgb), 0.1);
  border: 1px solid rgba(var(--card-accent-rgb), 0.18);
  border-radius: 7px 14px 7px 14px;
  transform: rotate(-2deg);
}

.flashcard-shine {
  position: absolute;
  top: 18%;
  right: 22%;
  z-index: 1;
  width: 12mm;
  height: 1.4mm;
  background: rgba(var(--card-accent-rgb), 0.28);
  border-radius: 999px;
  transform: rotate(-12deg);
}

.flashcard-picture {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  width: var(--picture-size, 18mm);
  height: var(--picture-size, 18mm);
  justify-self: center;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.94);
  border: 1.5px solid rgba(var(--card-accent-rgb), 0.28);
  border-radius: 9px;
  box-shadow: 0 1.3mm 0 rgba(var(--card-accent-rgb), 0.2);
  font-size: 22pt;
  line-height: 1;
}

.flashcard-icon {
  width: 76%;
  height: 76%;
  fill: none;
  stroke: var(--card-accent);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3.5;
}

.flashcard-icon text {
  fill: var(--card-accent);
  stroke: none;
}

.flashcard-term {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-family: "Segoe Print", "Comic Sans MS", "Bradley Hand ITC", cursive;
  font-size: var(--card-font-size, 34pt);
  line-height: 1;
  text-align: center;
}

.flashcard-word {
  position: relative;
  z-index: 1;
  padding-top: 1.3mm;
  color: var(--card-accent);
  border-top: 1px solid rgba(var(--card-accent-rgb), 0.2);
  font-size: 10pt;
  font-weight: 900;
  text-align: center;
}

.theme-classic .flashcard {
  --card-accent: var(--brand);
  --card-accent-rgb: 31, 122, 140;
  --card-soft: #ffffff;
}

.theme-calm .flashcard {
  --card-accent: #526f7d !important;
  --card-accent-rgb: 82, 111, 125 !important;
  --card-soft: #f1f6f4 !important;
}

.theme-ink .flashcard {
  --card-accent: #4f545b !important;
  --card-accent-rgb: 79, 84, 91 !important;
  --card-soft: #ffffff !important;
  background:
    linear-gradient(90deg, rgba(35, 48, 68, 0.06) 1px, transparent 1px),
    linear-gradient(180deg, rgba(35, 48, 68, 0.06) 1px, transparent 1px),
    #ffffff;
}

.theme-ink .flashcard-picture {
  filter: grayscale(1);
}

.activity-area {
  display: grid;
  min-height: 0;
}

.activity-instruction {
  margin: 0;
  color: var(--ink);
  font-size: 11pt;
  font-weight: 750;
  line-height: 1.35;
}

.activity-wordsearch {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42mm;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 4mm;
  min-height: 0;
}

.activity-wordsearch .activity-instruction {
  grid-column: 1 / -1;
}

.wordsearch-grid {
  display: grid;
  grid-template-columns: repeat(var(--wordsearch-size), 1fr);
  align-self: start;
  aspect-ratio: 1;
  width: min(100%, 122mm);
  border: 1.2px solid rgba(35, 48, 68, 0.4);
  background: #ffffff;
}

.wordsearch-grid span {
  display: grid;
  place-items: center;
  min-width: 0;
  border-right: 1px solid rgba(68, 111, 178, 0.24);
  border-bottom: 1px solid rgba(68, 111, 178, 0.24);
  color: var(--ink);
  font-size: 9.5pt;
  font-weight: 850;
  line-height: 1;
}

.wordsearch-list {
  display: grid;
  align-self: start;
  gap: 1.5mm;
  padding: 3mm;
  background: rgba(31, 122, 140, 0.08);
  border: 1px solid rgba(31, 122, 140, 0.2);
  border-radius: 6px;
}

.wordsearch-list span {
  color: var(--brand-dark);
  font-size: 10pt;
  font-weight: 900;
}

.activity-lines {
  display: grid;
  gap: 3.4mm;
  min-height: 0;
}

.activity-wordsearch .activity-lines {
  grid-column: 1 / -1;
  grid-template-columns: repeat(2, 1fr);
  gap: 4mm 8mm;
}

.activity-lines span {
  min-height: 7mm;
  border-bottom: 1px solid var(--line-blue);
}

.activity-spelling {
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 4mm;
  min-height: 0;
}

.spelling-bank {
  justify-self: start;
  padding: 2mm 4mm;
  color: var(--brand-dark);
  background: rgba(31, 122, 140, 0.1);
  border: 1px solid rgba(31, 122, 140, 0.22);
  border-radius: 6px;
  font-size: 14pt;
  font-weight: 900;
}

.spelling-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4mm;
  min-height: 0;
}

.spelling-card {
  display: grid;
  grid-template-columns: 1fr 38mm;
  gap: 4mm;
  align-items: end;
  min-height: 16mm;
  padding: 3mm;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(35, 48, 68, 0.14);
  border-radius: 6px;
}

.spelling-card strong {
  color: var(--ink);
  font-size: 17pt;
  line-height: 1.1;
}

.spelling-word {
  display: inline-flex;
  align-items: baseline;
  min-width: 0;
  white-space: nowrap;
}

.spelling-gap {
  display: inline-block;
  width: 11mm;
  height: 5.2mm;
  margin: 0 0.6mm;
  transform: translateY(0.8mm);
  background: rgba(31, 122, 140, 0.08);
  border: 1.3px solid rgba(31, 122, 140, 0.35);
  border-radius: 3px;
}

.spelling-card > span {
  border-bottom: 1px solid var(--line-blue);
}

.activity-grammar {
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 4mm;
  min-height: 0;
}

.grammar-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 2mm;
  padding: 3mm;
  background: rgba(31, 122, 140, 0.08);
  border: 1px solid rgba(31, 122, 140, 0.18);
  border-radius: 6px;
}

.grammar-bank span {
  padding: 1.5mm 2.4mm;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid rgba(35, 48, 68, 0.16);
  border-radius: 5px;
  font-size: 11pt;
  font-weight: 850;
}

.grammar-columns {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4mm;
  min-height: 0;
}

.grammar-columns section {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 3mm;
  padding: 3mm;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(35, 48, 68, 0.14);
  border-radius: 6px;
}

.grammar-columns h4 {
  margin: 0;
  color: var(--brand-dark);
  font-size: 11pt;
  text-align: center;
}

.activity-maze {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 4mm;
  min-height: 0;
}

.maze-board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--maze-size), 1fr);
  justify-self: center;
  aspect-ratio: 1;
  width: min(100%, 136mm);
  background: #ffffff;
}

.maze-board span:not(.maze-label) {
  min-width: 0;
  min-height: 0;
}

.wall-top {
  border-top: 2px solid var(--ink);
}

.wall-right {
  border-right: 2px solid var(--ink);
}

.wall-bottom {
  border-bottom: 2px solid var(--ink);
}

.wall-left {
  border-left: 2px solid var(--ink);
}

.maze-label {
  position: absolute;
  color: var(--brand-dark);
  font-size: 8.5pt;
  font-weight: 900;
}

.maze-start {
  top: -5mm;
  left: 0;
}

.maze-end {
  right: 0;
  bottom: -5mm;
}

.flashcard-back {
  grid-template-rows: auto auto auto 1fr;
  background:
    linear-gradient(140deg, #ffffff 0%, var(--card-soft) 100%),
    #ffffff;
}

.flashcard-back-word {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  color: var(--ink);
  font-size: 18pt;
  font-weight: 900;
  line-height: 1.1;
  text-align: center;
}

.flashcard-back-prompt {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  color: rgba(35, 48, 68, 0.38);
  font-family: "Segoe Print", "Comic Sans MS", "Bradley Hand ITC", cursive;
  font-size: 28pt;
  line-height: 1;
}

.flashcard-back-lines {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: repeat(3, 1fr);
  min-height: 16mm;
  margin-top: 1mm;
}

.flashcard-back-lines span {
  border-bottom: 1px solid var(--line-blue);
}

.memory-area {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4mm;
  min-height: 0;
}

.memory-card {
  --card-accent: var(--brand);
  --card-accent-rgb: 31, 122, 140;
  --card-soft: #e3f3f6;
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 2mm;
  min-height: 0;
  padding: 3.4mm;
  overflow: hidden;
  background:
    linear-gradient(145deg, var(--card-soft), #ffffff 54%),
    #ffffff;
  border: 1px dashed rgba(35, 48, 68, 0.45);
  border-radius: 6px;
}

.memory-label {
  color: var(--card-accent);
  font-size: 7.5pt;
  font-weight: 900;
  text-transform: uppercase;
}

.memory-body {
  display: grid;
  place-items: center;
  min-width: 0;
  color: var(--ink);
  font-family: "Segoe Print", "Comic Sans MS", "Bradley Hand ITC", cursive;
  font-size: 24pt;
  font-weight: 800;
  line-height: 1.1;
  overflow-wrap: anywhere;
  text-align: center;
}

.memory-card.is-word .memory-body {
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  font-size: 15pt;
  font-weight: 900;
}

.memory-card .flashcard-icon {
  width: 23mm;
  height: 23mm;
}

.writing-row {
  position: relative;
  min-height: 13mm;
  overflow: hidden;
  border-radius: 2px;
}

.writing-row::before {
  position: absolute;
  inset: 0;
  content: "";
  pointer-events: none;
}

.line-three .writing-row::before {
  background:
    linear-gradient(90deg, transparent 0 11mm, var(--line-red) 11mm 11.4mm, transparent 11.4mm),
    linear-gradient(
      180deg,
      transparent 0 calc(20% - 0.5px),
      var(--line-blue) calc(20% - 0.5px) calc(20% + 0.5px),
      transparent calc(20% + 0.5px) calc(50% - 0.5px),
      rgba(68, 111, 178, 0.18) calc(50% - 0.5px) calc(50% + 0.5px),
      transparent calc(50% + 0.5px) calc(80% - 0.5px),
      var(--line-blue) calc(80% - 0.5px) calc(80% + 0.5px),
      transparent calc(80% + 0.5px) 100%
    );
}

.line-single .writing-row::before {
  background:
    linear-gradient(90deg, transparent 0 11mm, var(--line-red) 11mm 11.4mm, transparent 11.4mm),
    linear-gradient(
      180deg,
      transparent 0 calc(72% - 0.5px),
      var(--line-blue) calc(72% - 0.5px) calc(72% + 0.5px),
      transparent calc(72% + 0.5px) 100%
    );
}

.line-grid .writing-row::before {
  background:
    linear-gradient(90deg, transparent 0 11mm, var(--line-red) 11mm 11.4mm, transparent 11.4mm),
    repeating-linear-gradient(90deg, transparent 0 7mm, rgba(68, 111, 178, 0.18) 7mm 7.25mm),
    repeating-linear-gradient(180deg, transparent 0 7mm, rgba(68, 111, 178, 0.22) 7mm 7.25mm);
}

.line-text {
  position: absolute;
  right: 4mm;
  bottom: 7%;
  left: 16mm;
  overflow: hidden;
  color: rgba(35, 48, 68, var(--trace-opacity));
  font-family: "Segoe Print", "Comic Sans MS", "Bradley Hand ITC", cursive;
  font-size: var(--fit-font-size, var(--row-font-size));
  font-weight: 500;
  line-height: 1.1;
  white-space: nowrap;
}

.line-single .line-text {
  bottom: 16%;
}

.line-grid .line-text {
  bottom: 14%;
}

.writing-row.is-ghost .line-text {
  color: rgba(35, 48, 68, calc(var(--trace-opacity) * 0.64));
}

.writing-row.is-blank .line-text {
  color: transparent;
}

.prompt {
  position: absolute;
  top: 1.8mm;
  left: 16mm;
  max-width: calc(100% - 22mm);
  overflow: hidden;
  color: rgba(35, 48, 68, 0.5);
  font-size: 8.5pt;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.start-dot {
  position: absolute;
  left: 13mm;
  bottom: 28%;
  width: 2.4mm;
  height: 2.4mm;
  background: var(--accent);
  border-radius: 50%;
}

.line-single .start-dot,
.line-grid .start-dot {
  bottom: 25%;
}

.sheet-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: end;
  padding-top: 7mm;
  color: var(--muted);
  font-size: 9pt;
  font-weight: 700;
}

.calibration-mark {
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  width: 10mm;
  height: 10mm;
  color: rgba(35, 48, 68, 0.62);
  border: 1px solid rgba(35, 48, 68, 0.55);
  font-size: 5.5pt;
  line-height: 1;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .controls {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid rgba(35, 48, 68, 0.12);
  }

  .workspace {
    padding: 18px;
  }
}

@media (max-width: 680px) {
  .controls,
  .workspace {
    padding: 14px;
  }

  .brand {
    grid-template-columns: 44px 1fr;
  }

  .brand-mark {
    width: 44px;
    height: 44px;
    font-size: 18px;
  }

  .segmented {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid-two,
  .sheet-header {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions,
  .actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .actions .primary {
    grid-column: 1 / -1;
  }

  .sheet {
    min-width: 560px;
    padding: 16mm 12mm 10mm;
  }

  .flashcard-area.cards-many {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@page {
  size: A4;
  margin: 0;
}

@media print {
  * {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  html,
  body {
    width: 210mm;
    min-height: 297mm;
    background: #ffffff;
  }

  .controls,
  .topbar {
    display: none;
  }

  .app-shell,
  .workspace,
  .preview-stage {
    display: block;
    min-height: 0;
    padding: 0;
    overflow: visible;
  }

  .sheet {
    width: 209mm;
    height: 296mm;
    min-width: 0;
    margin: 0.5mm auto;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    overflow: hidden;
  }

  .sheet-stack {
    display: block;
  }

  .sheet-stack .sheet {
    break-after: page;
    page-break-after: always;
  }

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