@font-face {
  font-family: Marelle;
  src: url("assets/MarelleBaton-Regular.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}
:root {
  color-scheme: light;
  --ink: #22223a;
  --muted: #59586d;
  --accent: #513cac;
  --accent-dark: #41308d;
  --edge: #dfddec;
  --surface: #fff;
  --canvas: #f5f4fa;
  --soft: #ede9fb;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--canvas);
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
button, input, select, textarea { font: inherit; }
[hidden] { display: none !important; }
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--edge);
}
.topbar-inner {
  min-height: 100px;
  max-width: 1490px;
  margin: auto;
  padding: 17px clamp(16px, 4vw, 55px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
}
.brand { display: flex; align-items: center; gap: 15px; }
.brand-icon {
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  background: var(--soft);
  border-radius: 13px;
  display: grid;
  justify-content: center;
  align-content: center;
  grid-template-columns: 11px 11px;
  gap: 3px;
  transform: rotate(-6deg);
}
.brand-icon i {
  height: 6px;
  border-radius: 2px;
  background: var(--accent);
}
.brand-icon i:last-child { grid-column: span 2; background: #9384d6; }
h1, h2, p { margin: 0; }
h1 {
  font-size: clamp(1.28rem, 2.15vw, 2rem);
  line-height: 1.14;
  letter-spacing: -.034em;
}
.brand p { color: var(--muted); margin-top: 5px; font-size: .94rem; }
h2 { font-size: 1.16rem; line-height: 1.25; letter-spacing: -.022em; }
.workspace {
  margin: 0 auto;
  padding: 26px clamp(16px, 4vw, 55px) 48px;
  max-width: 1490px;
  display: grid;
  grid-template-columns: minmax(325px, .72fr) minmax(0, 1.28fr);
  gap: clamp(18px, 2.6vw, 34px);
  align-items: start;
}
.controls { display: grid; gap: 15px; min-width: 0; }
.panel {
  background: var(--surface);
  border: 1px solid var(--edge);
  border-radius: 15px;
  padding: clamp(14px, 2vw, 21px);
}
.panel h2 { margin-bottom: 14px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.panel-heading h2 { margin: 0; }
.panel-heading select { width: auto; min-height: 35px; padding: 5px 31px 5px 11px; }
label, legend, summary { font-size: .91rem; font-weight: 650; }
label { display: block; }
.help {
  color: var(--muted);
  font-size: .84rem;
  line-height: 1.42;
  margin-top: 5px;
}
.help code {
  background: var(--soft);
  color: var(--accent-dark);
  padding: 1px 5px;
  border-radius: 4px;
}
textarea, input[type="text"], input[type="number"], select {
  display: block;
  min-width: 0;
  width: 100%;
  min-height: 40px;
  border: 1px solid #cfcddd;
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 7px 10px;
  font-size: .95rem;
  font-weight: 450;
}
textarea {
  margin-top: 6px;
  resize: vertical;
  line-height: 1.4;
}
select {
  appearance: none;
  padding-right: 28px;
  background:
    linear-gradient(45deg, transparent 50%, #69627e 50%) right 14px center / 5px 5px no-repeat,
    linear-gradient(135deg, #69627e 50%, transparent 50%) right 9px center / 5px 5px no-repeat,
    var(--surface);
}
input::placeholder { color: #77728a; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
button, select, summary, .file-button { cursor: pointer; }
button:disabled { cursor: default; opacity: .47; }
.primary, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  border-radius: 8px;
  font-weight: 650;
  line-height: 1.2;
}
.primary {
  color: #fff;
  background: var(--accent);
  padding: 12px 16px;
  min-height: 43px;
  border: 1px solid var(--accent);
  font-size: .92rem;
  flex: 0 0 auto;
}
.primary:hover:not(:disabled) { background: var(--accent-dark); }
.button {
  color: var(--accent-dark);
  background: var(--surface);
  border: 1px solid #d7cfee;
  min-height: 34px;
  padding: 7px 10px;
}
.button:hover:not(:disabled) { background: var(--soft); }
.text-button {
  border: 0;
  padding: 6px 0;
  background: transparent;
  color: var(--accent-dark);
  font-size: .84rem;
  font-weight: 650;
  text-align: left;
}
.text-button:hover { text-decoration: underline; text-underline-offset: 3px; }
.illustration-controls { margin-top: 15px; }
.illustration-controls > label { margin-bottom: 6px; }
.image-actions { display: flex; align-items: center; gap: 13px; }
.image-actions input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  opacity: 0;
  overflow: hidden;
}
.image-actions input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 3px; }
.image-name { overflow-wrap: anywhere; }
.level {
  margin: 0;
  padding: 11px 13px 12px;
  border: 1px solid var(--edge);
  border-radius: 10px;
  background: #faf9fd;
  min-width: 0;
}
.level + .level { margin-top: 10px; }
.level legend { color: var(--accent-dark); padding: 0 6px; }
.level label > input, .level label > select { margin-top: 4px; }
.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-bottom: 11px;
}
.level-footer {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  align-items: end;
  margin-top: 9px;
}
.copies input { width: 78px; min-height: 35px; }
summary { color: var(--ink); }
.option-fields { display: grid; gap: 10px; margin-top: 14px; }
.option-fields > select { margin-top: -5px; }
.range-field { display: grid; grid-template-columns: 1fr auto; gap: 4px 9px; align-items: center; }
.range-field output { color: var(--muted); font-size: .84rem; }
.range-field input { grid-column: 1 / -1; width: 100%; margin: 0; accent-color: var(--accent); }
.checkbox { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.checkbox input { accent-color: var(--accent); margin: 0; width: 16px; height: 16px; }
.criteria-controls {
  min-width: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--edge);
  border-radius: 8px;
  padding: 10px;
  gap: 8px;
}
.criteria-controls legend { padding: 0 4px; }
.preview {
  position: sticky;
  top: 16px;
  min-width: 0;
  border: 1px solid #ded9eb;
  border-radius: 15px;
  overflow: hidden;
  background: #eae7f4;
}
.preview-header {
  min-height: 65px;
  background: var(--surface);
  border-bottom: 1px solid var(--edge);
  padding: 12px clamp(12px, 2.4vw, 20px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 11px;
}
.preview-header p { color: var(--muted); font-size: .84rem; margin-top: 3px; }
.page-navigation { display: flex; align-items: center; gap: 7px; }
.page-navigation span { font-variant-numeric: tabular-nums; font-size: .84rem; min-width: 42px; text-align: center; }
.nav-button { min-width: 32px; padding: 1px 6px 4px; font-size: 1.45rem; }
.preview-stage { padding: clamp(9px, 2vw, 20px); }
.pages { --preview-scale: .7; }
.preview .sheet {
  margin: 0 auto;
  zoom: var(--preview-scale);
  box-shadow: 0 3px 13px #231b4725;
}
.preview .sheet:not([data-current]) { display: none; }
.notice {
  margin: 0 auto 12px;
  max-width: 580px;
  border-radius: 8px;
  background: #fff;
  color: #47346e;
  padding: 10px 13px;
  line-height: 1.4;
  font-size: .88rem;
}
.measure {
  position: absolute;
  left: -10000px;
  top: 0;
  visibility: hidden;
}

/* The preview and the printed document share physical A4 dimensions. */
.sheet {
  width: 210mm;
  height: 296.9mm;
  padding: 9mm 10mm;
  background: #fff;
  color: #111;
  font-family: Arial, "Liberation Sans", sans-serif;
}
.worksheet { display: grid; grid-template-rows: minmax(0, 1fr); }
.worksheet.duo { grid-template-rows: repeat(2, minmax(0, 1fr)); }
.exercise {
  display: flex;
  flex-direction: column;
  padding: 1mm 0 4mm;
}
.exercise + .exercise {
  border-top: .3mm dashed #858585;
  padding: 4mm 0 0;
}
.exercise-meta {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  min-height: 22mm;
  flex: none;
}
.level-mark {
  display: grid;
  align-content: center;
  justify-items: center;
  width: 20mm;
  height: 20mm;
  border-radius: 50%;
  border: .27mm solid #111;
  font-size: 10pt;
  line-height: 1.12;
}
.level-mark strong { font-size: 21pt; font-weight: 400; }
.criteria {
  display: grid;
  gap: 1.1mm;
  list-style: none;
  padding: 0;
  margin: 0;
  align-self: flex-start;
  font-size: 11pt;
}
.criteria li { display: flex; align-items: center; gap: 1.7mm; }
.tick-box { display: inline-block; width: 3.4mm; height: 3.4mm; border: .26mm solid #111; }
.phrase-model {
  display: flex;
  flex-direction: column;
  gap: 1mm;
  flex: none;
  margin: 7mm 0 4mm;
}
.worksheet:not(.duo) .phrase-model { margin-top: 14mm; }
.model-line, .box-line, .cut-line { display: flex; align-items: stretch; }
.model-line { gap: 4mm; justify-content: center; }
.model-word, .cut-cell { white-space: nowrap; line-height: 1.25; }
.handwriting { font-family: Marelle, sans-serif; }
.model-word { font-size: var(--word-size); }
.glue {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2mm;
  flex: none;
  min-height: var(--glue-height);
}
.glue.band { border: .36mm solid #111; }
.box-line { gap: 2mm; justify-content: center; }
.box, .cut-cell { flex: 0 0 var(--word-width); }
.box { height: 19.8mm; border: .3mm solid #111; }
.illustration {
  display: grid;
  justify-items: center;
  align-items: start;
  flex: 1;
  min-height: 0;
  margin: 3mm 0 0;
}
.illustration img {
  display: block;
  width: min(100%, calc(var(--image-height) * 2.25));
  height: 100%;
  min-height: 0;
  max-height: var(--image-height);
  object-fit: contain;
  object-position: center top;
}
.illustration img.gray { filter: grayscale(1); }
.cutting {
  display: flex;
  align-items: center;
  flex-direction: column;
}
.cutting h2 {
  align-self: flex-start;
  font: 400 13pt/1.2 Arial, "Liberation Sans", sans-serif;
  margin: 2mm 0 6mm;
}
.cut-set { margin: 0 auto; }
.cut-set.multi + .cut-set.multi { margin-top: 2mm; }
.cut-line {
  height: 19.8mm;
  border-top: .25mm solid #222;
  border-left: .25mm solid #222;
  width: max-content;
  max-width: 100%;
  margin: 0 auto;
}
.cut-cell {
  display: grid;
  place-items: center;
  border-right: .25mm solid #222;
  font-size: var(--word-size);
}
.cut-line:last-child { border-bottom: .25mm solid #222; }
.cut-set:not(.multi) + .cut-set:not(.multi) .cut-line { border-top: 0; }

@media (max-width: 850px) {
  .workspace { grid-template-columns: minmax(280px, .93fr) minmax(0, 1.07fr); }
  .field-grid { gap: 7px; }
}
@media (max-width: 650px) {
  .workspace { grid-template-columns: minmax(0, 1fr); padding-top: 14px; }
  .topbar-inner { align-items: flex-start; flex-direction: column; gap: 11px; }
  .brand { gap: 10px; }
  .preview { position: static; }
}

@page { size: A4 portrait; margin: 0; }
@media print {
  html, body { margin: 0; background: white; }
  .topbar, .controls, .preview-header, .notice, .measure { display: none !important; }
  .workspace, .preview, .preview-stage, .pages {
    display: block;
    position: static;
    padding: 0;
    margin: 0;
    border: 0;
    border-radius: 0;
    overflow: visible;
    background: white;
  }
  .preview .sheet {
    zoom: 1;
    box-shadow: none;
    margin: 0;
    break-after: page;
    break-inside: avoid;
  }
  .preview .sheet:last-child { break-after: auto; }
  .preview .sheet.worksheet:not([data-current]) { display: grid; }
  .preview .sheet.cutting:not([data-current]) { display: flex; }
}
