:root {
  color-scheme: light;
  --ink: #16202a;
  --muted: #667386;
  --line: #d9e2ee;
  --paper: #ffffff;
  --panel: #f4f7fb;
  --soft: #eef5fb;
  --accent: #235f9f;
  --accent-dark: #174876;
  --brand-orange: #f49a21;
  --brand-green: #24856b;
  --shadow: 0 18px 50px rgba(23, 40, 64, 0.1);
}

@font-face {
  font-family: "Montserrat";
  src: url("assets/Montserrat-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Montserrat";
  src: url("assets/Montserrat-Bold.ttf") format("truetype");
  font-weight: 700 900;
  font-style: normal;
  font-display: swap;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(244, 154, 33, 0.14), transparent 28rem),
    radial-gradient(circle at top right, rgba(36, 133, 107, 0.1), transparent 30rem),
    linear-gradient(180deg, #fbfdff 0%, #eef3f8 100%),
    var(--panel);
  color: var(--ink);
  font-family: "Montserrat", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.app-shell {
  min-height: 100vh;
  padding: 24px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: 22px;
  max-width: 1380px;
  margin: 0 auto;
}

.control-panel {
  align-self: start;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 20px;
  position: sticky;
  top: 24px;
}

.library-link {
  width: max-content;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  padding: 0 12px;
  border: 1px solid #d8e4f1;
  border-radius: 999px;
  background: #ffffff;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 900;
  text-decoration: none;
  box-shadow: 0 8px 18px rgba(18, 32, 45, 0.06);
}

.library-link::before {
  content: "";
  width: 8px;
  height: 8px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
}

.brand-block {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 16px;
  margin: 0 0 20px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 10px 24px rgba(18, 32, 45, 0.05);
}

.brand-block > div {
  min-width: 0;
}

.brand-block > div::before {
  content: "SCOLATIO.COM";
  display: block;
  margin-bottom: 3px;
  color: var(--brand-green);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.brand-mark {
  width: 54px;
  height: 54px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid rgba(23, 33, 43, 0.08);
  box-shadow: 0 10px 22px rgba(18, 32, 45, 0.12);
  object-fit: contain;
  padding: 6px;
}

h1 {
  font-size: 1.12rem;
  line-height: 1.08;
  font-weight: 900;
}

.brand-block p {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.25;
  margin-top: 5px;
}

.controls {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: #334155;
  font-weight: 700;
  font-size: 0.86rem;
}

select,
input[type="text"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  color: var(--ink);
  min-height: 42px;
  padding: 0 12px;
  font-weight: 700;
}

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

.range-row {
  display: grid;
  grid-template-columns: 1fr 42px;
  gap: 10px;
  align-items: center;
}

output {
  display: grid;
  place-items: center;
  min-height: 34px;
  border-radius: 8px;
  background: var(--soft);
  color: var(--accent-dark);
  font-weight: 800;
}

.toggle-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

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

.button-stack {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
}

button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent-dark);
}

button:disabled {
  opacity: 0.66;
  cursor: wait;
}

.primary-btn {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 10px 18px rgba(35, 95, 159, 0.18);
}

.primary-btn:hover:not(:disabled) {
  background: #2d72b6;
  color: #fff;
}

.activity-panel {
  min-width: 0;
}

.account-widget {
  margin-bottom: 16px;
}

.worksheet {
  width: min(100%, 1020px);
  min-height: 720px;
  margin: 0 auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.worksheet-masthead {
  display: grid;
  grid-template-columns: 1fr 240px;
  align-items: center;
  gap: 24px;
  min-height: 126px;
  padding: 26px 34px;
  border-top: 8px solid var(--brand-orange);
  background:
    linear-gradient(90deg, rgba(244, 154, 33, 0.08), transparent 22%),
    linear-gradient(180deg, #fffdf8, #f8fbff);
}

.masthead-brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.worksheet-logo {
  width: 66px;
  height: 66px;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
  border: 1px solid rgba(23, 33, 43, 0.08);
  box-shadow: 0 8px 18px rgba(18, 32, 45, 0.14);
}

.worksheet-kicker {
  color: var(--brand-green);
  font-size: 0.8rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.worksheet h2 {
  color: #0f172a;
  font-size: clamp(2rem, 4.4vw, 3.05rem);
  line-height: 1;
  font-weight: 900;
  letter-spacing: 0;
}

.issue-card {
  min-height: 72px;
  display: grid;
  align-content: center;
  justify-items: end;
  gap: 5px;
  padding-left: 18px;
  border-left: 4px solid var(--accent);
}

.issue-card p:first-child {
  color: #0f172a;
  font-size: 0.86rem;
  font-weight: 800;
}

.issue-card p:last-child {
  color: #0f172a;
  font-size: 1.18rem;
  font-weight: 900;
}

.student-strip {
  display: grid;
  grid-template-columns: 1fr 0.62fr;
  gap: 26px;
  align-items: center;
  min-height: 48px;
  padding: 0 34px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fbfdff;
}

.student-strip p {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: end;
  color: #243244;
  font-weight: 900;
}

.student-strip p::after {
  content: "";
  border-bottom: 1.4px solid #1f2937;
  transform: translateY(-3px);
}

.activity-instructions {
  padding: 16px 34px 12px;
  text-align: center;
  color: #243244;
  font-size: 0.84rem;
  line-height: 1.45;
  font-weight: 500;
}

.activity-subtitle {
  margin: 0 0 5px;
  color: #0f172a;
  font-size: 0.94rem;
  line-height: 1.2;
  font-weight: 900;
}

.spelling-activity {
  --row-min: 92px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 14px 28px 22px;
}

.spelling-card {
  min-height: var(--row-min);
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  border: 1px solid var(--line);
  border-left: 6px solid var(--card-color);
  border-radius: 8px;
  background: linear-gradient(90deg, var(--card-soft), #fff 38%);
  padding: 14px 14px 12px 12px;
  break-inside: avoid;
}

.spelling-number {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--card-color);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 900;
}

.spelling-content {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 8px;
}

.spelling-label {
  color: var(--card-color);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.spelling-prompt {
  color: #101827;
  font-size: 0.93rem;
  line-height: 1.32;
  font-weight: 800;
}

.complete-word {
  display: flex;
  align-items: end;
  gap: 0;
  min-height: 24px;
  white-space: nowrap;
}

.complete-gap {
  min-width: calc(var(--gap-chars, 2) * 0.72em + 0.55em);
  height: 1.25em;
  display: inline-flex;
  align-items: end;
  justify-content: center;
  margin: 0 1px;
  padding: 0 0.08em;
  border-bottom: 2px solid #172235;
  color: var(--accent-dark);
  line-height: 1;
  font-weight: 900;
}

.option-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.option-pill {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  border: 1.5px solid #cad8e8;
  border-radius: 999px;
  background: #fff;
  color: #0f172a;
  padding: 0 13px;
  font-size: 0.82rem;
  font-weight: 900;
}

.option-pill.is-answer {
  border-color: var(--card-color);
  background: var(--card-soft);
  color: var(--card-color);
}

.answer-line {
  min-height: 28px;
  display: grid;
  align-items: end;
  color: var(--accent-dark);
  font-size: 0.9rem;
  font-weight: 900;
  border-bottom: 1.8px solid #172235;
}

.letter-choice {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #334155;
  font-size: 0.82rem;
  font-weight: 800;
}

.letter-choice span {
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  display: inline-grid;
  place-items: center;
  border: 1.4px solid #cad8e8;
  border-radius: 7px;
  background: #fff;
  color: var(--accent-dark);
  font-weight: 900;
}

.letter-choice.is-answer span {
  border-color: var(--card-color);
  background: var(--card-soft);
  color: var(--card-color);
}

.worksheet-footer {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 34px;
  border-top: 1px solid var(--line);
  background: #fbfdff;
  color: #536275;
  font-size: 0.74rem;
  font-weight: 800;
}

@media (max-width: 980px) {
  .app-shell {
    padding: 12px;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .control-panel {
    position: static;
  }
}

@media (max-width: 720px) {
  .worksheet-masthead,
  .student-strip,
  .spelling-activity {
    grid-template-columns: 1fr;
  }

  .issue-card {
    align-items: start;
    justify-items: start;
  }
}

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

@media print {
  html,
  body {
    width: 210mm;
    min-height: 297mm;
    background: #fff !important;
  }

  body * {
    visibility: hidden;
  }

  .worksheet,
  .worksheet * {
    visibility: visible;
  }

  .app-shell,
  .workspace,
  .activity-panel {
    display: block !important;
    width: 210mm !important;
    min-height: 297mm !important;
    padding: 0 !important;
    margin: 0 !important;
    background: #fff !important;
  }

  .control-panel,
  .account-widget,
  .generator-suggestions,
  .scolatio-global-footer {
    display: none !important;
  }

  .worksheet {
    position: absolute;
    inset: 0;
    width: 210mm !important;
    height: 297mm !important;
    min-height: 297mm !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    overflow: hidden !important;
  }

  .worksheet-masthead {
    min-height: 34mm;
    padding: 8mm 10mm;
  }

  .worksheet-logo {
    width: 17mm;
    height: 17mm;
  }

  .worksheet h2 {
    font-size: 26pt;
  }

  .student-strip {
    min-height: 13mm;
    padding: 0 10mm;
  }

  .activity-instructions {
    padding: 5mm 10mm 3mm;
    font-size: 9pt;
  }

  .spelling-activity {
    --row-min: var(--print-row-height, 27mm);
    gap: 3mm;
    padding: 3mm 8mm 5mm;
  }

  .spelling-card {
    min-height: var(--print-row-height, 27mm);
    padding: 3.5mm;
  }

  .worksheet-footer {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    min-height: 10mm;
    padding: 0 10mm;
  }
}
