/* Tuntisuunnitelma: a soft, playful look for early-years teachers. */
:root {
  --ink: #3d405b;
  --ink-soft: #6b6f8f;
  --paper: #fffdf7;
  --bg: #eaf7ff;
  --line: #e6e0d4;
  --yellow: #ffd166;
  --yellow-soft: #fff4d6;
  --green: #6cc070;
  --green-soft: #e7f8e3;
  --blue: #48a9d6;
  --blue-soft: #e3f4fb;
  --pink: #ef8fa8;
  --pink-soft: #fde8ee;
  --orange: #f4a261;
  --lilac: #b5a8f0;
  --lilac-soft: #efebff;
  --radius: 22px;
  --shadow: 0 6px 0 rgba(61, 64, 91, .08), 0 14px 32px rgba(61, 64, 91, .08);
  --font: "Baloo 2", "Nunito", "Quicksand", "Segoe UI Rounded", "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 12px 12px, rgba(255, 209, 102, .35) 3px, transparent 4px),
    radial-gradient(circle at 36px 30px, rgba(239, 143, 168, .25) 3px, transparent 4px),
    linear-gradient(180deg, #dff3ff 0%, #f3fbff 45%, #fffaf0 100%);
  background-size: 48px 48px, 48px 48px, 100% 100%;
  line-height: 1.5;
}
a { color: #2b7bb9; }
a:hover { color: #1d5a8a; }
.hidden { display: none !important; }

/* Decorative sky */
.sky { position: fixed; inset: 0 0 auto 0; height: 220px; pointer-events: none; z-index: 0; overflow: hidden; }
.sun {
  position: absolute; top: 22px; right: 6%; width: 74px; height: 74px; border-radius: 50%;
  background: radial-gradient(circle, #ffe08a 55%, #ffd166 56%);
  box-shadow: 0 0 0 10px rgba(255, 209, 102, .25), 0 0 0 22px rgba(255, 209, 102, .12);
  animation: sun-pulse 6s ease-in-out infinite;
}
.cloud { position: absolute; background: #fff; border-radius: 999px; opacity: .9; animation: drift 40s linear infinite; }
.cloud::before, .cloud::after { content: ""; position: absolute; background: #fff; border-radius: 50%; }
.cloud-a { width: 120px; height: 34px; top: 40px; left: -140px; }
.cloud-a::before { width: 52px; height: 52px; top: -26px; left: 18px; }
.cloud-a::after { width: 40px; height: 40px; top: -18px; left: 60px; }
.cloud-b { width: 90px; height: 26px; top: 120px; left: -100px; animation-duration: 55s; animation-delay: -20s; }
.cloud-b::before { width: 40px; height: 40px; top: -20px; left: 12px; }
.cloud-b::after { width: 30px; height: 30px; top: -12px; left: 46px; }
.cloud-c { width: 70px; height: 22px; top: 76px; left: -90px; animation-duration: 70s; animation-delay: -45s; }
.cloud-c::before { width: 32px; height: 32px; top: -16px; left: 10px; }
@keyframes drift { to { transform: translateX(calc(100vw + 260px)); } }
@keyframes sun-pulse { 50% { transform: scale(1.06); } }
@media (prefers-reduced-motion: reduce) {
  .cloud, .sun, .bouncers span { animation: none; }
}

/* Header */
.top { position: relative; z-index: 1; max-width: 1240px; margin: 0 auto; padding: 22px 20px 6px; }
.brand { display: flex; align-items: center; gap: 14px; }
.brand-pencil { width: 64px; height: 64px; flex: none; }
h1 { margin: 0; font-size: clamp(1.8rem, 3vw + 1rem, 2.6rem); letter-spacing: .5px; color: var(--ink); }
.tagline { margin: 0; color: var(--ink-soft); font-weight: 600; }
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.tab {
  font: inherit; font-weight: 700; color: var(--ink); background: #fff; border: 3px solid var(--line);
  border-radius: 999px; padding: 6px 16px; cursor: pointer; text-decoration: none; transition: transform .15s, border-color .15s;
}
.tab:hover { transform: translateY(-2px); border-color: var(--yellow); }
.tab.active { background: var(--yellow-soft); border-color: var(--yellow); }
@media (max-width: 620px) {
  .tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tab { padding: 8px 4px; font-size: .86rem; text-align: center; white-space: nowrap; }
  .tab:last-child:nth-child(odd) { grid-column: 1 / -1; }
}
@media (max-width: 370px) {
  .tab { white-space: normal; }
  .brand { gap: 8px; }
  .brand-pencil { width: 44px; height: 44px; }
  h1 { font-size: 1.6rem; }
}

main { position: relative; z-index: 1; max-width: 1240px; margin: 0 auto; padding: 12px 20px 30px; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 22px; max-width: 980px; margin: 0 auto; }

.card {
  background: var(--paper); border: 3px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px 22px;
}
.card h2 { margin: 0 0 12px; font-size: 1.35rem; display: flex; align-items: center; gap: 10px; }
.dot { width: 16px; height: 16px; border-radius: 50%; display: inline-block; flex: none; }
.dot-yellow { background: var(--yellow); }
.dot-green { background: var(--green); }
.dot-blue { background: var(--blue); }
.dot-pink { background: var(--pink); }
.dot-lilac { background: var(--lilac); }

/* Form */
/* The form is the page until there is a plan; then a bar above the plan
   brings it back. */
.form-card { padding: 28px 32px 24px; font-size: 1.06rem; }
.form-card > h2 { font-size: 1.7rem; margin-bottom: 4px; }
.form-intro { margin: 0 0 20px; color: var(--ink-soft); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 28px; }
.field-wide { grid-column: 1 / -1; }
.form-card select, .form-card input[type="text"] { padding: 12px 14px; }
.form-card .chip span { padding: 9px 18px; }
.wish-box { margin: 10px 0 18px; padding: 18px 20px; background: var(--blue-soft); border: 3px solid var(--blue); border-radius: var(--radius); }
.wish-title { display: block; font-size: 1.4rem; font-weight: 800; }
.wish-box textarea { min-height: 170px; font-size: 1.1rem; margin-top: 4px; }
.form-card .primary { font-size: 1.4rem; padding: 16px 18px; }
.form-card .disclaimer { margin: 16px 0 0; }
.slots-editor > textarea { margin-top: 6px; }
.request-bar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 12px 20px; }
.request-bar .grow { flex: 1; min-width: 220px; }
.request-bar .hint { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 620px) {
  .form-card { padding: 20px 16px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .wish-box { padding: 14px; }
}
.field { display: block; border: 0; padding: 0; margin: 0 0 14px; min-width: 0; }
.field legend, .label { display: block; font-weight: 800; margin-bottom: 6px; }
.hint { display: block; color: var(--ink-soft); font-size: .92rem; margin-bottom: 6px; }
select, input[type="text"], textarea {
  width: 100%; font: inherit; color: var(--ink); background: #fff; border: 3px solid var(--line);
  border-radius: 14px; padding: 9px 12px; outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 150px; }
select:focus, input[type="text"]:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(72, 169, 214, .2); }
.char-counter { display: block; text-align: right; font-size: .82rem; color: var(--ink-soft); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-block; padding: 6px 14px; border-radius: 999px; background: #fff; border: 3px solid var(--line);
  font-weight: 700; cursor: pointer; transition: all .15s; user-select: none;
}
.chip input:checked + span { background: var(--green-soft); border-color: var(--green); }
.chip input:focus-visible + span { box-shadow: 0 0 0 4px rgba(108, 192, 112, .3); }
.question-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.question-chip {
  font: inherit; font-size: .88rem; font-weight: 700; border: 2px dashed var(--lilac); background: var(--lilac-soft);
  color: var(--ink); border-radius: 999px; padding: 3px 10px; cursor: pointer;
}
.question-chip:hover { background: #fff; }
@media (max-width: 620px), (pointer: coarse) {
  .question-chips { gap: 8px; }
  .question-chip { min-height: 40px; padding: 6px 14px; }
  .link-button { min-height: 40px; }
}

.slots-editor { margin: 4px 0 16px; border: 3px dashed var(--line); border-radius: 16px; padding: 8px 12px; background: #fff; }
.slots-editor summary { cursor: pointer; font-weight: 800; }
.summary-hint { font-weight: 600; color: var(--ink-soft); font-size: .88rem; }
.slot-fields { display: grid; gap: 10px; margin: 10px 0; }
.slot-field { border-radius: 14px; padding: 10px; border: 3px solid transparent; }
.slot-field input, .slot-field textarea { margin-top: 4px; }
.slot-field textarea { min-height: 54px; }
.slot-aloitus { background: var(--yellow-soft); border-color: var(--yellow); }
.slot-ydin { background: var(--green-soft); border-color: var(--green); }
.slot-lopetus { background: var(--blue-soft); border-color: var(--blue); }
.link-button { font: inherit; background: none; border: 0; color: #2b7bb9; cursor: pointer; padding: 0; text-decoration: underline; }

.primary {
  width: 100%; font: inherit; font-size: 1.2rem; font-weight: 800; color: #3d2c00; cursor: pointer;
  background: linear-gradient(180deg, #ffe08a, #ffd166); border: 3px solid #e9b949; border-radius: 18px;
  padding: 12px 18px; box-shadow: 0 5px 0 #e0a92f; transition: transform .1s, box-shadow .1s;
}
.primary:hover { transform: translateY(-1px); }
.primary:active { transform: translateY(4px); box-shadow: 0 1px 0 #e0a92f; }
.primary:disabled { opacity: .6; cursor: wait; }
.ai-status { margin: 10px 0 0; font-size: .88rem; color: var(--ink-soft); text-align: center; }

/* Result */
.result-area { display: grid; gap: 18px; min-width: 0; }
.wish-note { margin: 12px 0 0; padding: 10px 14px; background: var(--blue-soft); border-radius: 14px; font-size: .95rem; }
.wish-note small { display: block; font-weight: 700; color: var(--ink-soft); font-size: .8rem; text-transform: uppercase; letter-spacing: .6px; }
.idea h3 { margin: 0 0 4px; font-size: 1.25rem; }
.idea-when { color: var(--ink-soft); font-size: .93rem; margin: 2px 0 6px; }
.idea ol { margin: 8px 0; padding-left: 22px; }
.idea-say { margin: 8px 0; padding: 8px 14px; background: var(--yellow-soft); border-radius: 14px; font-style: italic; }
.idea-say p { margin: 2px 0; }
.idea .secondary { margin-top: 10px; }
.mode-note { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 10px 0 0; font-size: .93rem; color: var(--ink-soft); }
.koonti-card { border-color: var(--green); }
.koonti-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 18px; margin: 10px 0 8px; }
.koonti-fields .field { margin-bottom: 8px; }
.koonti-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.koonti-status { font-weight: 700; color: var(--ink-soft); }
/* The preview looks like the printed form, not like this page; it scrolls
   sideways on a phone rather than squeezing six columns. */
.koonti-preview { margin-top: 14px; overflow-x: auto; border: 2px solid var(--line); border-radius: 12px; background: #fff; }
.koonti-sheet { min-width: 680px; padding: 18px; font-family: Arial, Helvetica, sans-serif; color: #000; font-size: 12px; line-height: 1.3; }
.k-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.k-table td, .k-table th { border: 1px solid #000; padding: 3px 5px; vertical-align: top; text-align: left; overflow-wrap: anywhere; }
.k-label { display: block; }
.k-green { background: #c5e0b3; }
.k-bullet, .k-sub, .k-indent { position: relative; margin: 3px 0; }
.k-bullet { padding-left: 14px; }
.k-sub { padding-left: 30px; }
.k-indent { padding-left: 24px; }
.k-bullet::before, .k-sub::before { position: absolute; }
.k-bullet::before { content: "•"; left: 3px; }
.k-sub::before { content: "◦"; left: 18px; }
.k-title { margin: 18px 0 6px; font-size: 16px; }
.k-model { margin: 8px 0; }
.k-flow { margin-top: 10px; font-size: 11px; }
.k-flow th { font-weight: 400; font-size: 9.5px; }
.k-flow th em { display: block; margin-top: 3px; font-size: 8.5px; }
.k-flow td em { display: block; margin-top: 3px; }
.k-flow th:nth-child(1) { width: 11%; }
.k-flow th:nth-child(2) { width: 25%; }
.k-flow th:nth-child(3) { width: 19%; }
.k-flow th:nth-child(4) { width: 16.5%; }
.k-flow th:nth-child(5) { width: 13%; }
.k-flow th:nth-child(6) { width: 15.5%; }
.k-phase { font-size: 9.5px; }
.k-row-0 { background: #fbe4d5; }
.k-row-1 { background: #ededed; }
.k-row-2 { background: #e2efd9; }
.k-row-3 { background: #d9e2f3; }
.k-references { margin-top: 14px; font-size: 10px; overflow-wrap: anywhere; }
@media (max-width: 620px) { .koonti-fields { grid-template-columns: minmax(0, 1fr); } }
.disclaimer { background: var(--pink-soft); border-radius: 14px; padding: 10px 14px; font-size: .92rem; }
.loading { text-align: center; }
.bouncers { display: flex; justify-content: center; gap: 10px; margin: 8px 0 4px; }
.bouncers span { width: 18px; height: 18px; border-radius: 50%; background: var(--yellow); animation: bounce 1s ease-in-out infinite; }
.bouncers span:nth-child(2) { background: var(--green); animation-delay: .15s; }
.bouncers span:nth-child(3) { background: var(--blue); animation-delay: .3s; }
@keyframes bounce { 50% { transform: translateY(-14px); } }
.error { border-color: var(--pink); background: var(--pink-soft); font-weight: 700; }

.plan { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; min-width: 0; }
.plan-head { position: relative; overflow: hidden; }
.plan-head::after {
  content: "★"; position: absolute; right: 18px; top: 8px; font-size: 3rem; color: var(--yellow); opacity: .5; transform: rotate(12deg);
}
.plan-title { margin: 0 0 4px; font-size: 1.6rem; }
.plan-meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px;
  font-size: .85rem; font-weight: 800; background: var(--lilac-soft); border: 2px solid var(--lilac);
}
.badge-warn { background: var(--pink-soft); border-color: var(--pink); }
.target {
  position: relative; margin: 12px 0 0; padding: 12px 16px 12px 52px; background: var(--yellow-soft);
  border: 3px solid var(--yellow); border-radius: 18px; font-weight: 800; font-size: 1.1rem;
}
.target::before { content: "🎯"; position: absolute; left: 14px; top: 10px; font-size: 1.4rem; }
.target small { display: block; font-weight: 700; color: var(--ink-soft); font-size: .8rem; text-transform: uppercase; letter-spacing: .6px; }

.ops-grid { display: grid; gap: 10px; }
.ops-item { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start; padding: 10px 12px; border-radius: 14px; background: #fff; border: 2px solid var(--line); }
.ops-code {
  min-width: 46px; text-align: center; font-weight: 900; border-radius: 12px; padding: 4px 8px; background: var(--blue-soft); border: 2px solid var(--blue);
}
.ops-code.code-l { background: var(--lilac-soft); border-color: var(--lilac); }
.ops-code.code-s { background: var(--green-soft); border-color: var(--green); }
.ops-why { color: var(--ink-soft); font-size: .93rem; margin-top: 2px; }

.phases { display: grid; gap: 16px; }
.phase { border-radius: var(--radius); padding: 0; overflow: hidden; border: 3px solid; box-shadow: var(--shadow); background: var(--paper); }
.phase-aloitus { border-color: var(--yellow); }
.phase-ydin { border-color: var(--green); }
.phase-lopetus { border-color: var(--blue); }
.phase-header { display: flex; align-items: center; gap: 12px; padding: 12px 18px; }
.phase-aloitus .phase-header { background: var(--yellow-soft); }
.phase-ydin .phase-header { background: var(--green-soft); }
.phase-lopetus .phase-header { background: var(--blue-soft); }
.phase-number {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 900; font-size: 1.2rem; flex: none; color: #fff;
}
.phase-aloitus .phase-number { background: var(--orange); }
.phase-ydin .phase-number { background: var(--green); }
.phase-lopetus .phase-number { background: var(--blue); }
.phase-name { margin: 0; font-size: 1.25rem; }
.phase-purpose { margin: 0; color: var(--ink-soft); font-size: .9rem; }
.phase-minutes { margin-left: auto; font-weight: 900; background: #fff; border-radius: 999px; padding: 4px 12px; white-space: nowrap; }
.phase-header > div { min-width: 0; }
.phase-name { overflow-wrap: anywhere; }
@media (max-width: 420px) {
  .phase-header { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; padding: 12px; }
  .phase-minutes { grid-column: 2; justify-self: start; margin-left: 0; }
}
.activity { padding: 14px 18px 16px; border-top: 2px dashed var(--line); }
.activity:first-of-type { border-top: 0; }
.activity h4 { margin: 0 0 4px; font-size: 1.1rem; }
.activity-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.swap-btn { flex: none; font: inherit; font-size: .82rem; font-weight: 800; color: var(--ink); background: var(--yellow-soft);
  border: 2px solid var(--yellow); border-radius: 999px; padding: 2px 10px; cursor: pointer; white-space: nowrap; }
.swap-btn:hover { background: var(--yellow); }
.swap-form { margin: 8px 0 10px; padding: 10px; border-radius: 14px; background: var(--yellow-soft); border: 2px dashed var(--yellow);
  display: flex; flex-direction: column; gap: 8px; font-family: var(--font); font-size: 1rem; line-height: 1.4; }
.swap-form textarea { font: inherit; width: 100%; min-height: 0; height: 4.6em; border: 2px solid var(--line); border-radius: 10px; padding: 8px 10px; resize: vertical; background: #fff; }
.swap-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.swap-send:disabled { opacity: .6; cursor: wait; }
.swap-status { font-weight: 700; color: var(--ink-soft); }
.flash { animation: flash 2.4s ease-out; }
@keyframes flash { 0%, 30% { background: var(--yellow-soft); } 100% { background: transparent; } }
.roles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
@media (max-width: 620px) { .roles { grid-template-columns: 1fr; } }
.role { border-radius: 14px; padding: 8px 12px; font-size: .93rem; border-left: 5px solid; }
.role-lo { background: var(--blue-soft); border-color: var(--blue); }
.role-eo { background: var(--green-soft); border-color: var(--green); }
.teaching-model { border-color: var(--lilac); }
.activity-element { font-size: .82rem; font-weight: 700; color: var(--ink-soft); }
.activity ol { margin: 8px 0; padding-left: 22px; }
.activity li { margin: 3px 0; }
.materials { font-size: .92rem; }
.diff { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
@media (max-width: 620px) { .diff { grid-template-columns: 1fr; } }
.diff-box { border-radius: 14px; padding: 10px 12px; font-size: .93rem; }
.diff-box strong { display: block; }
.diff-support { background: var(--pink-soft); }
.diff-challenge { background: var(--lilac-soft); }
.refs { margin-top: 8px; font-size: .85rem; color: var(--ink-soft); }
.ref-link {
  display: inline-block; min-width: 22px; padding: 0 6px; margin: 0 2px; border-radius: 8px; background: var(--blue-soft);
  border: 1px solid var(--blue); text-align: center; font-weight: 800; text-decoration: none; color: var(--ink);
}
.ref-link:hover { background: var(--blue); color: #fff; }

.support-list, .note-list { margin: 0; padding-left: 20px; }
.support-list li, .note-list li { margin: 6px 0; }
.support-basis { display: block; font-size: .85rem; color: var(--ink-soft); }

.references ol { margin: 0; padding-left: 26px; }
.references li { margin: 8px 0; scroll-margin-top: 16px; }
.references li:target { background: var(--yellow-soft); border-radius: 10px; }
.ref-kind { font-size: .75rem; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; padding: 1px 7px; border-radius: 999px; background: var(--green-soft); margin-left: 4px; }
.ref-meta { display: block; color: var(--ink-soft); font-size: .88rem; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.secondary {
  font: inherit; font-weight: 800; color: var(--ink); background: #fff; border: 3px solid var(--line);
  border-radius: 14px; padding: 8px 14px; cursor: pointer; box-shadow: 0 3px 0 var(--line);
}
.secondary:hover { border-color: var(--green); }
.secondary:active { transform: translateY(2px); box-shadow: none; }
.toast { color: #2d7a33; font-weight: 800; align-self: center; }
.toast.toast-warn { color: #b0571c; }

/* Saved plans */
.saved-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.saved-item { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 16px; background: #fff; border: 2px solid var(--line); }
.saved-item .grow { flex: 1; min-width: 0; }
.saved-title { font-weight: 800; }
.saved-meta { font-size: .85rem; color: var(--ink-soft); }

/* Library */
.library-filters { margin-bottom: 12px; }
.library { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.element-card { border-radius: 18px; padding: 14px; border: 3px solid; background: #fff; }
.element-card.slot-aloitus { border-color: var(--yellow); }
.element-card.slot-ydin { border-color: var(--green); }
.element-card.slot-lopetus { border-color: var(--blue); }
.element-card h3 { margin: 4px 0 6px; font-size: 1.05rem; }
.element-card p { margin: 0 0 8px; font-size: .93rem; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.tag { font-size: .75rem; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: var(--blue-soft); }
.element-sources { margin: 6px 0 0; padding-left: 18px; font-size: .82rem; }

.foot { position: relative; z-index: 1; max-width: 1240px; margin: 0 auto; padding: 0 20px 30px; color: var(--ink-soft); font-size: .88rem; text-align: center; }

/* Print: a clean, ink-friendly sheet */
/* Curriculum coverage */
.cov-select { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; margin-bottom: 10px; }
.cov-select select { font: inherit; border: 2px solid var(--line); border-radius: 12px; padding: 6px 10px; background: #fff; }
.cov-row { display: flex; align-items: center; gap: 12px; margin: 12px 0 6px; flex-wrap: wrap; }
.cov-bar { flex: 1; min-width: 120px; height: 12px; border-radius: 999px; background: var(--lilac-soft); overflow: hidden; }
.cov-fill { display: block; height: 100%; width: 0; background: var(--green); border-radius: 999px; }
.cov-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cov-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; border: 2px solid; font-weight: 800; cursor: help; }
.cov-done { background: var(--green-soft); border-color: var(--green); }
.cov-missing { background: #fff; border-color: var(--line); border-style: dashed; color: var(--ink-soft); }
.cov-count { font-weight: 600; font-size: .85rem; }
.cov-missing-list { margin: 10px 0 4px; padding-left: 18px; color: var(--ink-soft); font-size: .92rem; }
.cov-missing-list li { margin: 3px 0; }

/* Printables. The sheet styles are shared by the on-screen preview and the
   print; only page size and breaks live in the print block. */
.hyphen-toggle { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; margin: 4px 0 10px; cursor: pointer; }
.hyphen-toggle input { width: 20px; height: 20px; accent-color: var(--green); }
.printable { border-top: 2px dashed var(--line); padding: 12px 0; }
.printable-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.printable-head .grow { flex: 1; min-width: 180px; }
.printable-icon { font-size: 1.8rem; }
.printable-buttons { display: flex; flex-wrap: wrap; gap: 10px; }
.print-sheet { display: none; }
/* Measured off screen at the printed width (fitPages), natural height. */
.print-sheet.measuring { display: block !important; position: absolute; left: -10000px; top: 0; width: 186mm; }
.print-sheet.measuring .worksheet { min-height: 0; }
.print-sheet.measuring .no-print { display: none; }
/* The preview is the printed A4 page, margins included, scaled to fit. */
.preview { margin-top: 14px; padding: 14px; border-radius: 14px; background: #eef0f4; }
.preview-pages { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.preview .sheet-page { width: 210mm; flex: none; padding: 12mm; background: #fff; border-radius: 2px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .15); }
.preview .worksheet { min-height: 297mm; }
.preview .swap-btn { font-size: 10pt; margin-left: auto; }
.preview .swap-form { font-size: 11pt; }

.sheet-page { font-family: var(--font); color: #222; }
.sheet-page .num { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 1.6em; height: 1.6em;
  border-radius: 50%; border: 2px solid #333; color: #222; font-weight: 800; font-size: .85em; margin-right: .45em; }
.blank { display: inline-block; min-width: 26mm; border-bottom: 1.5px solid #555; height: 1.1em; vertical-align: baseline; margin: 0 1mm; }
.blank.wide { min-width: 60mm; }
.hw-line { height: 11mm; border-bottom: 1.5px solid #555; position: relative; }
.hw-line::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px dashed #bbb; }
.hw-line.grow { flex: 1; min-width: 50mm; }
.pic-box { display: inline-flex; align-items: flex-end; justify-content: center; flex: none; width: 30mm; height: 24mm;
  border: 1.5px dashed #999; border-radius: 3mm; padding: 1mm; background: #fcfcfc; }
.pic-label { font-size: 8pt; color: #888; text-align: center; line-height: 1.15; }
.pic-box.has-pic { align-items: center; border-color: transparent; background: none; padding: 0; }
.pic-img { width: 100%; height: 100%; object-fit: contain; display: block; }
.pic-many { display: grid; gap: .8mm; align-content: center; justify-content: center; }
.pic-many-sm { grid-template-columns: repeat(3, 1fr); }
.pic-many-lg { grid-template-columns: repeat(4, 1fr); }
.pic-many .pic-img { width: 100%; height: auto; max-height: 11mm; }
.pic-many-lg .pic-img { max-height: 7mm; }
.frame-box { padding: 1mm; }
.ten-frame { display: grid; grid-template-columns: repeat(5, 1fr); width: 100%; border: 1.5px solid #333; }
.ten-frame span { aspect-ratio: 1; border: 1px solid #333; display: flex; align-items: center; justify-content: center; }
.ten-frame span.full { font-size: 15pt; line-height: 1; color: #222; }
.pic-cycle { cursor: pointer; }
.pic-cycle:hover, .pic-cycle:focus-visible { outline: 3px solid var(--yellow); outline-offset: 1mm; border-radius: 3mm; }
.prompt-text { font-size: 1.05em; font-weight: 700; }
.task-prompt { display: flex; align-items: center; gap: 4mm; min-width: 0; }
.shape-box svg { width: 100%; height: 100%; }
.counter-groups { display: flex; flex-wrap: wrap; gap: 3mm; }
.counter-group { display: grid; grid-template-columns: repeat(5, 5mm); gap: 1mm; border: 1px solid #777; border-radius: 2mm; padding: 2mm; }
.counter { font-size: 17pt; line-height: 5mm; width: 5mm; height: 5mm; text-align: center; }
.answer-lines { width: 100%; min-width: 0; }
.write-item, .draw-item { display: flex; flex-direction: column; gap: 2mm; min-width: 0; break-inside: avoid; }

.self-check { display: flex; align-items: center; justify-content: space-between; gap: 4mm; }
.self-q { font-size: 11pt; font-weight: 700; }
.faces { display: flex; gap: 5mm; }
.face { display: flex; flex-direction: column; align-items: center; gap: 1mm; }
.face-icon { font-size: 18pt; line-height: 1; }
.face-word { font-size: 7.5pt; color: #555; white-space: nowrap; }

/* Four cards on a page of fixed height; fitCard shrinks the type of a card
   with a lot of text (all sizes are in em of the card). */
.sched { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 6mm; height: 266mm; }
.sched-card { border: 3px solid #333; border-radius: 8mm; padding: 7mm; display: flex; align-items: center; justify-content: center;
  overflow: hidden; min-height: 0; font-size: 14pt; break-inside: avoid; }
.sched-inner { display: flex; flex-direction: column; align-items: center; text-align: center; gap: .3em; width: 100%;
  overflow-wrap: anywhere; hyphens: manual; }
.sched-icon { font-size: 4.2em; line-height: 1; }
.sched-name { font-size: 1.7em; font-weight: 800; line-height: 1.15; }
.sched-sub { font-size: 1em; line-height: 1.3; }
.sched-min { font-size: 1em; font-weight: 700; }
.sched-target, .sched-aloitus { border-color: #e0a800; }
.sched-ydin { border-color: #3c9a40; }
.sched-lopetus { border-color: #2f86b6; }

.worksheet { display: flex; flex-direction: column; gap: 6mm; font-size: 14pt; line-height: 1.35; }
.ws-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 6mm; border-bottom: 2.5px solid #333; padding-bottom: 3mm; }
.ws-subject { font-size: 9.5pt; color: #666; text-transform: uppercase; letter-spacing: .05em; }
.ws-head h1 { margin: 1mm 0 0; font-size: 21pt; line-height: 1.15; }
.ws-page-number { flex: none; font-size: 9pt; color: #555; }
.ws-goal { margin: 2mm 0 0; font-size: 11pt; line-height: 1.4; font-weight: 600; }
.ws-level { display: flex; flex-direction: column; align-items: flex-end; font-size: 11pt; font-weight: 800; white-space: nowrap;
  border: 2px solid #333; border-radius: 4mm; padding: 1.5mm 3mm; }
.ws-level .stars { font-size: 15pt; letter-spacing: 1mm; }
.level-support .ws-level { border-color: #e0a800; }
.level-core .ws-level { border-color: #3c9a40; }
.level-challenge .ws-level { border-color: #2f86b6; }
.ws-name { display: flex; align-items: baseline; gap: 2mm; font-size: 11pt; }
.ws-task { break-inside: avoid; display: flex; flex-direction: column; gap: 3mm; }
.ws-instruction { display: flex; align-items: center; font-weight: 800; font-size: 14.5pt; }
.task-icon { margin-right: .4em; }
.ws-instruction-text { flex: 1; }
.ws-example { margin-left: 9mm; padding: 2mm 3mm; border-left: 3px solid #555; border-radius: 0 2mm 2mm 0; font-size: 12pt; line-height: 1.5; }
.ws-example:has(.shape-box) { display: flex; align-items: center; gap: 2mm; }
.ws-example .shape-box { width: 14mm; height: 12mm; }
.task-continued { margin-left: 3mm; font-size: 10pt; color: #555; }
.ws-foot { margin-top: auto; border-top: 1.5px dashed #aaa; padding-top: 3mm; }
.ws-cont { margin-top: auto; text-align: right; font-size: 22pt; font-weight: 800; }

.rows { display: flex; flex-direction: column; gap: 3mm; padding-left: 9mm; }
.row { display: flex; align-items: center; gap: 4mm; flex-wrap: wrap; }
.row.write { flex-wrap: nowrap; }
.options { display: flex; gap: 4mm; flex-wrap: wrap; }
.option { padding: 2mm 3mm; font-weight: 700; border: 0; }
.word-bank { border: 1px solid #777; border-radius: 2mm; padding: 1mm 2mm; gap: 3mm; }
.word-bank .option { padding: 0 1mm; font-weight: 600; }
.row.choose { padding-bottom: 3mm; border-bottom: 1px solid #ccc; flex-wrap: nowrap; }
.choose-body { display: flex; flex-direction: column; gap: 2mm; min-width: 0; }
.row.choose:last-child { border-bottom: 0; }
.fill-text { line-height: 2; }
.row.fill { flex-wrap: nowrap; }
.fill-body { display: flex; flex-direction: column; gap: 1.5mm; min-width: 0; }

.match { display: grid; grid-template-columns: 1fr 22mm 1fr; padding-left: 9mm; }
.match-col { display: flex; flex-direction: column; gap: 3mm; }
.match-cell { display: flex; align-items: center; justify-content: flex-end; gap: 3mm; min-height: 24mm; }
.match-right { justify-content: flex-start; }
.match-text { font-weight: 700; font-size: 15pt; }
.match .dot { width: 3.5mm; height: 3.5mm; border-radius: 50%; border: 2px solid #333; flex: none; }

.pic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(36mm, 1fr)); gap: 4mm; padding-left: 9mm; }
.pic-cell { display: flex; flex-direction: column; align-items: center; gap: 1.5mm; }
.pic-cell .pic-box { width: 34mm; height: 28mm; }
.pic-cell .hw-line { width: 100%; }
.pic-caption { font-size: 11pt; font-weight: 700; text-align: center; }
.preview .sheet-page { position: relative; }
.ws-preview-level { position: absolute; top: 3mm; right: 5mm; font-size: 10pt; font-weight: 700; color: #777; }
.ws-passage { margin: 0; padding-left: 9mm; line-height: 1.5; }
.work-line { display: flex; align-items: flex-end; gap: 2mm; margin-top: 3mm; }
.word-problem { padding-bottom: 2mm; }
.word-problem .prompt-text { font-weight: 400; }
/* Pictures to colour fill the sheet: the fewer, the bigger. */
.color-grid { padding-left: 0; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.color-grid .pic-caption { font-size: 1em; }
.color-grid .pic-cell .pic-box { width: 84mm; }
.color-one { grid-template-columns: minmax(0, 1fr); }
.color-one .pic-cell .pic-box { width: 150mm; height: 125mm; }
.color-two .pic-cell .pic-box { height: 76mm; }
.color-four .pic-cell .pic-box { height: 58mm; }
.color-many { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.color-many .pic-cell .pic-box { width: 54mm; height: 44mm; }

.calc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4mm 10mm; padding-left: 9mm; }
.calc-grid.illustrated { grid-template-columns: 1fr; }
.calc-word { display: flex; flex-direction: column; gap: 3mm; grid-column: 1 / -1; font-size: 14pt; }
.calc { display: flex; align-items: center; gap: 3mm; font-size: 17pt; font-weight: 700; }
.answer-box { width: 15mm; height: 12mm; border: 2px solid #555; border-radius: 2mm; flex: none; }
.calc-fill { grid-column: 1 / -1; }

.draw-grid { display: grid; gap: 5mm; padding-left: 9mm; }
.draw-grid.draw-2 { grid-template-columns: 1fr 1fr; }
.draw-frame { border: 2px solid #555; border-radius: 4mm; min-height: 60mm; padding: 2mm 3mm; }
.draw-caption { font-size: 11pt; color: #444; font-weight: 700; }
.teacher-answers { margin: 12px 0; border: 2px solid var(--line); border-radius: 12px; padding: 12px; }
.teacher-answers summary { cursor: pointer; font-weight: 800; }
.teacher-answers .answer-task { margin: 14px 0; gap: 6px; }
.worksheet.answer-sheet { font-size: 11pt; }
.answer-list { margin: 2mm 0 0; padding-left: 7mm; gap: 3mm; }
.answer-list li { padding-left: 1mm; }
.answer-list strong { display: block; }
.answer-prompt, .answer-note { color: #555; font-size: .9em; }
.answer-note { margin: 0; }
.worksheet-checks { margin: 12px 0; padding: 12px; border: 2px solid var(--orange); border-radius: 12px; background: var(--yellow-soft); }

/* The support level is read by children who need more room: bigger type,
   bigger pictures, more air. */
.level-support { font-size: 15.5pt; }
.level-support .pic-box { width: 36mm; height: 29mm; }
.level-support .match-cell { min-height: 29mm; }

@media print {
  /* A printable replaces the whole page. */
  body.printing-sheet > *:not(.print-sheet) { display: none !important; }
  body.printing-sheet { background: #fff; }
  body.printing-sheet .print-sheet { display: block !important; }
  .sheet-page { break-after: page; }
  .sheet-page:last-child { break-after: auto; }
  .no-print { display: none !important; }
  .worksheet { min-height: 270mm; }
}

@media print {
  body { background: #fff; }
  @page { size: A4; margin: 12mm; }
  .sky, .top .tabs, .form-card, .request-bar, .koonti-card, .actions, .printables, .foot, #view-saved, #view-library { display: none !important; }
  .layout { display: block; max-width: none; }
  .card, .phase { box-shadow: none; break-inside: avoid; }
  .plan-head::after { display: none; }
  a { color: var(--ink); }
  .references a::after { content: " (" attr(href) ")"; font-size: .8em; word-break: break-all; }
}
