@font-face {
    font-family: "Worksheet";
    src: url("../fonts/KBSticktoIt.ttf") format("truetype");
    font-display: swap;
}

:root {
    --ink: #25313c;
    --muted: #66727e;
    --paper: #fff;
    --canvas: #f4f1e9;
    --primary: #245f58;
    --primary-dark: #194740;
    --accent: #e9a23b;
    --accent-soft: #fff2d9;
    --line: #d9dedb;
    --danger: #a23d35;
    --shadow: 0 18px 50px rgba(37, 49, 60, 0.1);
}

* {
    box-sizing: border-box;
}

html {
    color: var(--ink);
    background: var(--canvas);
    font-family: Inter, ui-rounded, "Avenir Next", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}

body {
    min-width: 320px;
    margin: 0;
}

button,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

.site-header {
    background: var(--paper);
    border-bottom: 1px solid var(--line);
}

.header-inner {
    width: min(1180px, calc(100% - 40px));
    min-height: 70px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.brand {
    color: var(--ink);
    display: inline-flex;
    align-items: center;
    gap: 11px;
    font-size: 1.05rem;
    font-weight: 800;
    text-decoration: none;
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 13px;
    display: grid;
    place-items: center;
    color: var(--primary-dark);
    background: var(--accent-soft);
    font-family: "Worksheet", cursive;
    transform: rotate(-3deg);
}

.header-note,
.field-hint {
    color: var(--muted);
    font-size: 0.8rem;
}

main {
    width: min(1180px, calc(100% - 40px));
    margin: 0 auto;
}

.intro {
    max-width: 730px;
    padding: 68px 0 40px;
}

.eyebrow,
.step-label {
    margin: 0 0 7px;
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.intro h1 {
    margin: 0;
    font-size: clamp(2.3rem, 5vw, 4.3rem);
    line-height: 1.02;
    letter-spacing: -0.055em;
}

.intro > p:last-child {
    max-width: 610px;
    margin: 20px 0 0;
    color: var(--muted);
    font-size: 1.1rem;
}

.workspace {
    display: grid;
    grid-template-columns: minmax(330px, 0.8fr) minmax(480px, 1.2fr);
    gap: 28px;
    align-items: start;
    padding-bottom: 70px;
}

.builder,
.preview {
    background: var(--paper);
    border: 1px solid rgba(37, 49, 60, 0.08);
    border-radius: 22px;
    box-shadow: var(--shadow);
}

.builder {
    padding: 28px;
    position: sticky;
    top: 20px;
}

.panel-heading,
.preview-heading,
.picker-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.panel-heading {
    margin-bottom: 26px;
}

h2,
h3 {
    margin: 0;
    line-height: 1.2;
}

h2 {
    font-size: 1.35rem;
}

.field-grid {
    display: grid;
    grid-template-columns: 0.72fr 1.28fr;
    gap: 14px;
}

.field {
    min-width: 0;
}

.field label,
.picture-picker legend {
    display: block;
    margin-bottom: 7px;
    font-weight: 750;
}

.field input {
    width: 100%;
    min-height: 46px;
    padding: 10px 12px;
    color: var(--ink);
    background: #fbfcfa;
    border: 1px solid #cbd2ce;
    border-radius: 9px;
    outline: none;
}

.field select {
    width: 100%;
    min-height: 46px;
    padding: 10px 36px 10px 12px;
    color: var(--ink);
    background: #fbfcfa;
    border: 1px solid #cbd2ce;
    border-radius: 9px;
    outline: none;
}

.field select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(36, 95, 88, 0.14);
}

.field input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(36, 95, 88, 0.14);
}

.field-hint {
    display: block;
    margin-top: 6px;
}

.check-row {
    margin: 24px 0;
    padding: 14px;
    display: flex;
    align-items: flex-start;
    gap: 11px;
    background: #f7f8f5;
    border-radius: 11px;
    cursor: pointer;
}

.check-row input {
    width: 18px;
    height: 18px;
    margin: 3px 0 0;
    accent-color: var(--primary);
}

.check-row strong,
.check-row small {
    display: block;
}

.check-row small {
    margin-top: 2px;
    color: var(--muted);
}

.picture-picker {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.picture-picker legend {
    padding: 0;
}

.picker-heading {
    min-height: 28px;
    margin-bottom: 10px;
    align-items: start;
}

.picker-heading .field-hint {
    margin: 0;
}

.picker-actions {
    display: flex;
    gap: 10px;
    flex: 0 0 auto;
}

.text-button {
    padding: 0;
    color: var(--primary);
    background: none;
    border: 0;
    font-size: 0.78rem;
    font-weight: 750;
}

.text-button:hover,
.text-button:focus-visible {
    text-decoration: underline;
}

.thumb-list {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
}

.picture-option {
    position: relative;
    min-width: 0;
    padding: 6px 4px 5px;
    color: var(--muted);
    background: #fbfcfa;
    border: 2px solid transparent;
    border-radius: 10px;
}

.picture-option img {
    width: 100%;
    height: 45px;
    display: block;
    object-fit: contain;
    mix-blend-mode: multiply;
}

.picture-option span {
    display: block;
    overflow: hidden;
    margin-top: 4px;
    font-size: 0.66rem;
    text-overflow: ellipsis;
}

.picture-option:hover {
    background: #f1f4ef;
}

.picture-option.selected {
    color: var(--primary-dark);
    background: #e5f1ed;
    border-color: var(--primary);
}

.picture-option.selected::after {
    content: "✓";
    position: absolute;
    top: 4px;
    right: 4px;
    width: 17px;
    height: 17px;
    display: grid;
    place-items: center;
    color: #fff;
    background: var(--primary);
    border-radius: 50%;
    font-family: Arial, sans-serif;
    font-size: 0.68rem;
    font-weight: 800;
}

.picture-option:focus-visible,
.button:focus-visible,
.text-button:focus-visible {
    outline: 3px solid rgba(36, 95, 88, 0.25);
    outline-offset: 2px;
}

.form-message {
    min-height: 24px;
    margin-top: 14px;
    color: var(--danger);
    font-size: 0.85rem;
    font-weight: 700;
}

.form-actions {
    display: flex;
    gap: 10px;
}

.button {
    min-height: 46px;
    padding: 10px 16px;
    border: 1px solid transparent;
    border-radius: 9px;
    font-weight: 800;
}

.button-primary {
    flex: 1;
    color: #fff;
    background: var(--primary);
}

.button-primary:hover {
    background: var(--primary-dark);
}

.button-secondary {
    color: var(--primary-dark);
    background: #fff;
    border-color: #b8c6c1;
}

.button-secondary:hover:not(:disabled) {
    background: #f0f5f2;
}

.button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.preview {
    overflow: hidden;
}

.preview-heading {
    padding: 24px 28px;
    border-bottom: 1px solid var(--line);
}

.sheet-count {
    padding: 5px 10px;
    color: var(--primary-dark);
    background: #e5f1ed;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 800;
}

.preview-content {
    padding: 28px;
    background-color: #f1f1f1;
    background-image: radial-gradient(#d0d0d0 0.7px, transparent 0.7px);
    background-size: 12px 12px;
}

.empty-state {
    min-height: 460px;
    padding: 40px 20px;
    display: grid;
    place-content: center;
    justify-items: center;
    text-align: center;
}

.empty-state p {
    max-width: 350px;
    margin: 10px 0 0;
    color: var(--muted);
}

.empty-illustration {
    margin-bottom: 22px;
    display: flex;
    align-items: end;
    gap: 7px;
}

.empty-illustration span {
    width: 48px;
    height: 58px;
    display: grid;
    place-items: center;
    color: var(--primary-dark);
    background: var(--accent-soft);
    border: 2px solid var(--accent);
    border-radius: 12px;
    font-family: "Worksheet", cursive;
    font-size: 1.7rem;
    transform: rotate(-5deg);
}

.empty-illustration span:nth-child(2) {
    height: 70px;
    transform: rotate(3deg);
}

.empty-illustration span:nth-child(3) {
    height: 62px;
    transform: rotate(-1deg);
}

.worksheet-page {
    width: 100%;
    box-sizing: border-box;
    aspect-ratio: 8.5 / 11;
    min-height: 620px;
    margin: 0 auto 24px;
    padding: 7% 7% 6%;
    display: flex;
    flex-direction: column;
    color: #202020;
    background: #fff;
    box-shadow: 0 8px 25px rgba(37, 49, 60, 0.14);
    font-family: "Worksheet", "Comic Sans MS", cursive;
}

.worksheet-page img {
    filter: grayscale(1) contrast(1.15);
}

.worksheet-page:last-child {
    margin-bottom: 0;
}

.student-fields {
    display: grid;
    grid-template-columns: 1fr 0.55fr;
    gap: 8%;
    font-family: Arial, sans-serif;
    font-size: clamp(0.55rem, 1.1vw, 0.8rem);
}

.write-line {
    display: inline-block;
    width: calc(100% - 42px);
    border-bottom: 1px solid #555;
}

.worksheet-title {
    margin: 7% 0 1%;
    font-size: clamp(1.25rem, 3vw, 2.2rem);
    text-align: center;
}

.worksheet-directions {
    margin: 0;
    font-family: Arial, sans-serif;
    font-size: clamp(0.6rem, 1.2vw, 0.86rem);
    text-align: center;
}

.match-activity,
.more-activity,
.order-activity,
.equation-activity,
.tenframe-activity,
.missing-activity {
    min-height: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 5%;
    background: #fff;
    border: 2px solid #222;
    border-radius: 14px;
}

.activity-label {
    margin: 0 0 5%;
    font-family: Arial, sans-serif;
    font-size: clamp(0.65rem, 1.3vw, 0.95rem);
    font-weight: 700;
    text-align: center;
}

.writing-prompt {
    margin: 5% 0 2%;
    font-family: Arial, sans-serif;
    font-size: clamp(0.6rem, 1.2vw, 0.86rem);
    text-align: center;
}

.writing-line {
    width: 60%;
    height: 0.55in;
    margin: 0 auto;
    border-bottom: 2px solid #555;
}

.match-board,
.compare-groups {
    display: grid;
    align-items: center;
    gap: 8%;
}

.match-board {
    grid-template-columns: 1fr 0.75fr;
    padding: 5%;
    background: #fff;
    border: 1px solid #555;
    border-radius: 10px;
}

.picture-group {
    text-align: center;
}

.compact-countables {
    min-height: 1.4in;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4%;
}

.countables.compact-countables {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.compact-countables img {
    max-height: 0.8in;
}

.group-label {
    display: block;
    margin-top: 8px;
    font-family: Arial, sans-serif;
    font-size: clamp(0.75rem, 1.5vw, 1rem);
    font-weight: 700;
}

.match-choices {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.match-choice,
.order-box {
    display: grid;
    place-items: center;
    aspect-ratio: 1;
    border: 2px solid #6e6e6e;
    border-radius: 9px;
    font-size: clamp(1.3rem, 4vw, 2.5rem);
}

.match-choice {
    color: var(--primary-dark);
    background: #fff;
    border-color: #222;
    font-family: Arial, sans-serif;
    font-weight: 800;
}

.match-choice.answer-hint {
    color: var(--primary-dark);
    background: #eee;
    border: 4px dashed #333;
}

.compare-groups {
    grid-template-columns: 1fr 1fr;
    gap: 5%;
}

.compare-card {
    padding: 5% 5% 3%;
    background: #fff;
    border: 2px solid #444;
    border-radius: 14px;
}

.compare-card.answer-hint,
.hint-target.hint-visible {
    background: #eee;
    border-color: #222;
}

.number-bank {
    width: min(100%, 4.5in);
    margin: 0 auto;
    display: flex;
    justify-content: center;
    gap: 8%;
}

.bank-number {
    min-width: 0.55in;
    padding: 8px 13px;
    color: var(--primary-dark);
    background: #fff;
    border: 1px solid #444;
    border-radius: 7px;
    font-family: Arial, sans-serif;
    font-size: clamp(1.1rem, 3vw, 1.7rem);
    font-weight: 800;
    text-align: center;
}

.order-slots {
    width: min(100%, 6.3in);
    margin: 8% auto 0;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5%;
}

.order-slot {
    text-align: center;
}

.slot-label {
    display: block;
    margin-bottom: 10px;
    color: var(--muted);
    font-family: Arial, sans-serif;
    font-size: clamp(0.55rem, 1vw, 0.75rem);
    font-weight: 700;
    text-transform: uppercase;
}

.slot-line {
    display: block;
    height: 0.62in;
    border: 2px solid #444;
    border-radius: 9px;
    background: #fbfcfa;
}

.order-slot .hint-reveal {
    display: none;
    margin-top: 6px;
    color: var(--primary-dark);
    font-family: Arial, sans-serif;
    font-size: 1.25rem;
    font-weight: 800;
}

.order-slot.hint-visible .hint-reveal {
    display: block;
}

.equation {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2%;
}

.equation .picture-group {
    width: 28%;
}

.equation-card {
    padding: 4%;
    background: #fff;
    border: 2px solid #222;
    border-radius: 12px;
}

.operator,
.equation-answer {
    font-family: Arial, sans-serif;
    font-size: clamp(1.5rem, 4vw, 3rem);
    font-weight: 800;
}

.equation-answer {
    width: 0.75in;
    height: 0.75in;
    display: grid;
    place-items: center;
    border: 3px dashed #333;
    border-radius: 10px;
}

.subtraction-group {
    width: min(100%, 6in);
    margin: 0 auto;
}

.ten-frame {
    width: min(100%, 5.5in);
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    border: 3px solid var(--ink);
}

.ten-frame span {
    aspect-ratio: 1;
    border: 1px solid var(--ink);
}

.ten-frame span.filled {
    background: #d0d0d0;
}

.large-answer-line {
    margin: 7% auto 0;
    font-family: Arial, sans-serif;
    font-size: clamp(1rem, 2.5vw, 1.6rem);
    text-align: center;
}

.missing-sequence {
    width: min(100%, 4in);
    margin: 0 auto;
    display: flex;
    justify-content: center;
    gap: 5%;
}

.sequence-number,
.missing-box {
    width: 1in;
    height: 1in;
    display: grid;
    place-items: center;
    border: 2px solid #6e6e6e;
    border-radius: 10px;
    font-family: Arial, sans-serif;
    font-size: clamp(1.5rem, 4vw, 3rem);
    font-weight: 800;
}

.missing-box {
    color: var(--primary-dark);
    border: 3px dashed #333;
}

.countables {
    min-height: 0;
    padding: 5% 3%;
    flex: 1;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-auto-rows: 1fr;
    place-items: center;
    gap: 2%;
}

.countables.sparse {
    width: min(100%, 7in);
    margin: 0 auto;
    grid-template-columns: repeat(var(--image-count), minmax(0, 1fr));
    gap: 5%;
}

.countables.sparse img {
    max-height: 1.85in;
}

.countables.medium {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.countables img {
    width: 100%;
    height: 100%;
    max-height: 100px;
    object-fit: contain;
}

.number-line {
    display: grid;
    grid-template-columns: repeat(var(--number-count), minmax(0, 1fr));
    gap: 1.5%;
}

.number-choice {
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    color: var(--primary-dark);
    background: #fff;
    border: 2px solid #222;
    border-radius: 9px;
    font-size: clamp(1rem, 3.2vw, 2.3rem);
    font-family: Arial, sans-serif;
    font-weight: 800;
    line-height: 1;
}

.number-choice.answer-hint {
    background: #eee;
    border: 4px dashed #333;
    font-weight: 800;
}

footer {
    padding: 24px 20px 36px;
    color: var(--muted);
    text-align: center;
    font-size: 0.85rem;
}

@media (max-width: 900px) {
    .workspace {
        grid-template-columns: 1fr;
    }

    .builder {
        position: static;
    }

    .worksheet-page {
        max-width: 680px;
    }
}

@media (max-width: 560px) {
    .header-inner,
    main {
        width: min(100% - 24px, 1180px);
    }

    .header-note {
        display: none;
    }

    .intro {
        padding: 44px 4px 28px;
    }

    .workspace {
        gap: 16px;
    }

    .builder,
    .preview {
        border-radius: 16px;
    }

    .builder,
    .preview-heading,
    .preview-content {
        padding: 20px;
    }

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

    .thumb-list {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .picker-heading,
    .form-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .picker-actions {
        margin-top: 3px;
    }

    .worksheet-page {
        min-height: 430px;
    }
}

@page {
    size: letter portrait;
    margin: 0;
}

@media print {
    body {
        background: #fff;
    }

    .site-header,
    .intro,
    .builder,
    .preview-heading,
    footer,
    .empty-state {
        display: none !important;
    }

    main,
    .workspace,
    .preview,
    .preview-content {
        width: auto;
        max-width: none;
        margin: 0;
        padding: 0;
        display: block;
        background: none;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .worksheet-page {
        width: 100%;
        max-width: 8.5in;
        height: 11in;
        min-height: 0;
        margin: 0 auto;
        padding: 0.55in 0.6in 0.45in;
        box-shadow: none;
        break-after: page;
        page-break-after: always;
    }

    .countables.sparse {
        width: 100%;
        padding-left: 5%;
        padding-right: 5%;
    }

    .countables.sparse img {
        max-height: 2.1in;
    }

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

    .student-fields {
        font-size: 10pt;
    }

    .worksheet-title {
        font-size: 25pt;
    }

    .worksheet-directions {
        font-size: 11pt;
    }

    .number-choice {
        font-size: 26pt;
    }

    .writing-line {
        height: 0.55in;
    }
}