:root {
  color-scheme: light;
  --ink: #1d2433;
  --muted: #687386;
  --line: #d8dee8;
  --paper: #ffffff;
  --panel: #f7f8fb;
  --accent: #24746d;
  --accent-strong: #18564f;
  --warm: #f2b84b;
  --blue: #3767a8;
  --danger: #a33b3b;
  --shadow: 0 18px 45px rgba(29, 36, 51, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(36, 116, 109, 0.08) 1px, transparent 1px),
    linear-gradient(0deg, rgba(55, 103, 168, 0.07) 1px, transparent 1px),
    #eef2f6;
  background-size: 32px 32px;
}

button,
input,
select {
  font: inherit;
}

.app-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 28px;
  align-items: center;
  max-width: 1180px;
  margin: 0 auto;
  padding: 32px 24px 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-strong);
  font-size: 0.85rem;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(2rem, 4vw, 3.8rem);
  line-height: 1.04;
  letter-spacing: 0;
}

.intro {
  max-width: 680px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.08rem;
}

.header-preview {
  position: relative;
  display: flex;
  justify-content: center;
  min-height: 160px;
}

.mini-sheet {
  width: 142px;
  height: 168px;
  padding: 20px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
  transform: rotate(-4deg);
}

.mini-sheet span {
  display: block;
  height: 12px;
  margin-bottom: 16px;
  border-bottom: 2px solid #aeb8c8;
}

.measure-ring {
  position: absolute;
  right: 20px;
  bottom: 8px;
  display: grid;
  width: 74px;
  height: 74px;
  place-items: center;
  border: 8px solid var(--warm);
  border-radius: 50%;
  background: #fff9eb;
  color: #5a3d04;
  font-weight: 850;
  box-shadow: 0 14px 28px rgba(90, 61, 4, 0.16);
}

.app-shell {
  display: grid;
  grid-template-columns: 390px minmax(0, 1fr);
  gap: 22px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px 36px;
}

.control-panel,
.preview-area {
  border: 1px solid rgba(216, 222, 232, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}

.control-panel {
  align-self: start;
  position: sticky;
  top: 18px;
  padding: 18px;
}

.panel-head,
.preview-toolbar,
.worksheet-head,
.actions,
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.panel-head h2 {
  margin-bottom: 0;
  font-size: 1.25rem;
}

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--accent-strong);
  cursor: pointer;
}

.field {
  display: grid;
  gap: 7px;
  margin-top: 16px;
}

.field span,
.toggle-row span {
  color: #394356;
  font-size: 0.92rem;
  font-weight: 700;
}

.field input,
.field select {
  width: 100%;
  min-height: 42px;
  border: 1px solid #cbd3df;
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.toggle-row {
  margin-top: 16px;
  align-items: flex-start;
  display: grid;
  grid-template-columns: 1fr;
}

.toggle-row label {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  min-width: 0;
}

.actions {
  margin-top: 20px;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 9px 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

button.secondary {
  border: 1px solid #bfc8d5;
  background: #fff;
  color: var(--ink);
}

button.secondary:hover {
  background: #eef3f7;
}

.preview-area {
  min-width: 0;
  padding: 18px;
}

.preview-toolbar {
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 0.94rem;
}

.preview-toolbar strong {
  display: block;
  color: var(--ink);
  font-size: 1rem;
}

.worksheet {
  width: min(100%, 820px);
  min-height: 980px;
  margin: 0 auto;
  padding: 42px;
  border: 1px solid var(--line);
  background: var(--paper);
  box-shadow: 0 12px 30px rgba(29, 36, 51, 0.11);
}

.worksheet-head {
  align-items: flex-start;
  padding-bottom: 18px;
  border-bottom: 2px solid var(--ink);
}

.worksheet h2 {
  margin-bottom: 8px;
  font-size: 1.8rem;
}

.worksheet p {
  margin-bottom: 0;
  color: var(--muted);
}

.score-box {
  min-width: 112px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
  font-size: 0.85rem;
}

.task-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 34px;
  margin: 28px 0 0;
  padding-left: 24px;
}

.task-list li {
  break-inside: avoid;
  min-height: 58px;
  padding-left: 6px;
  font-size: 1.08rem;
  line-height: 1.45;
}

.task-question {
  display: block;
}

.answer {
  display: inline-block;
  min-width: 90px;
  margin-top: 8px;
  border-bottom: 1px solid #697386;
  color: var(--blue);
  font-weight: 800;
}

.answer.hidden {
  color: transparent;
}

.solution-steps {
  display: block;
  margin-top: 8px;
  color: #48556a;
  font-size: 0.92rem;
  line-height: 1.35;
}

.solution-steps.hidden {
  display: none;
}

.word-task {
  grid-column: span 2;
  min-height: 84px;
}

@media screen and (max-width: 860px) {
  .app-header,
  .app-shell {
    grid-template-columns: 1fr;
  }

  .app-header {
    padding-top: 24px;
  }

  .header-preview {
    display: none;
  }

  .control-panel {
    position: static;
  }

  .task-list {
    grid-template-columns: 1fr;
  }

  .word-task {
    grid-column: auto;
  }

  .worksheet {
    min-height: auto;
    padding: 26px;
  }
}

@page {
  size: A4;
  margin: 8mm;
}

@media print {
  html,
  body {
    width: 194mm;
    min-height: 281mm;
    margin: 0;
    background: #fff;
  }

  .app-header,
  .control-panel,
  .preview-toolbar {
    display: none;
  }

  .app-shell,
  .preview-area {
    display: block;
    max-width: none;
    margin: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
    background: #fff;
  }

  .worksheet {
    display: flex;
    flex-direction: column;
    width: 194mm;
    height: 281mm;
    min-height: 281mm;
    margin: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
  }

  .worksheet-head {
    padding-bottom: 8mm;
  }

  .worksheet h2 {
    margin-bottom: 4mm;
    font-size: 18pt;
  }

  .worksheet p {
    font-size: 10pt;
  }

  .score-box {
    min-width: 30mm;
    padding: 3mm;
    font-size: 9pt;
  }

  .task-list {
    flex: 1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(var(--print-row-count, 9), minmax(0, 1fr));
    gap: 4mm 12mm;
    margin-top: 8mm;
    padding-left: 7mm;
  }

  .task-list li {
    min-height: 0;
    padding-left: 1mm;
    font-size: 11pt;
    line-height: 1.25;
  }

  .answer {
    min-width: 24mm;
    margin-top: 2mm;
  }

  .solution-steps {
    margin-top: 1.5mm;
    font-size: 8.5pt;
    line-height: 1.2;
  }

  .word-task {
    grid-column: span 2;
    min-height: 0;
  }

  .answer.hidden {
    color: transparent !important;
  }
}
