:root {
    --font-sans: system-ui, "Segoe UI", Roboto, Arial, sans-serif;
    --color-bg: #f4f6f9;
    --color-surface: #ffffff;
    --color-text: #1a1a2e;
    --color-muted: #5c6370;
    --color-primary: #0b5fff;
    --color-accent: #198754;
    --color-border: #e2e6ed;
    --color-primary-soft: #e8f0ff;
    --color-accent-soft: #e6f4ea;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.06);
}

* { box-sizing: border-box; }

body {
    font-family: var(--font-sans);
    margin: 0;
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-bg);
}

.app-shell { max-width: 960px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }

.app-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.app-header__brand { flex: 1 1 200px; }

.app-header__title {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.app-header__intro {
    margin: 0.35rem 0 0;
    color: var(--color-muted);
    font-size: 0.95rem;
    max-width: 36rem;
}

.app-header__lang { flex: 0 0 auto; }

.app-header__actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
    flex: 0 0 auto;
}

.app-header__library-link {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-primary, #0b5fff);
    text-decoration: none;
}

.app-header__library-link:hover { text-decoration: underline; }

.lang-form { margin: 0; }

.lang-form label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--color-muted);
}

.lang-form select {
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    font: inherit;
}

.app-main { display: flex; flex-direction: column; gap: 1rem; }

.panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
}

.panel__title {
    margin: 0 0 0.35rem;
    font-size: 1.25rem;
    font-weight: 700;
}

.panel__lead {
    margin: 0 0 1.25rem;
    color: var(--color-muted);
    font-size: 0.95rem;
}

.panel__section-title {
    margin: 0 0 0.75rem;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-muted);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.55rem 1.1rem;
    font: inherit;
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.2;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.btn:hover { background: var(--color-bg); }

.btn--primary {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}

.btn--primary:hover {
    background: #094bcc;
    border-color: #094bcc;
}

.btn--secondary {
    background: var(--color-surface);
    border-color: var(--color-border);
}

.tool-button {
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    padding: 0.45rem 0.75rem;
    cursor: pointer;
    border-radius: var(--radius);
    font: inherit;
    font-size: 0.875rem;
    font-weight: 600;
}

.tool-button:hover { background: var(--color-bg); }

.tool-button.active, .eraser-button.active {
    border-color: var(--color-primary);
    background: var(--color-primary-soft);
    color: var(--color-primary);
    font-weight: 700;
}

.wizard-stepper {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    counter-reset: wizard-step;
}

.wizard-stepper__item {
    flex: 1 1 0;
    min-width: 120px;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.75rem 1rem;
    position: relative;
    font-size: 0.875rem;
    color: var(--color-muted);
}

.wizard-stepper__item:not(:last-child)::after {
    content: "";
    position: absolute;
    right: 0;
    top: 50%;
    width: 1px;
    height: 1.5rem;
    background: var(--color-border);
    transform: translateY(-50%);
}

.wizard-stepper__marker {
    flex: 0 0 1.75rem;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    border: 2px solid var(--color-border);
    background: var(--color-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
}

.wizard-stepper__label { font-weight: 500; line-height: 1.25; }

.wizard-stepper__item--active { color: var(--color-text); }

.wizard-stepper__item--active .wizard-stepper__marker {
    border-color: var(--color-primary);
    background: var(--color-primary);
    color: #fff;
}

.wizard-stepper__item--active .wizard-stepper__label { font-weight: 700; }

.wizard-stepper__item--done { color: var(--color-muted); }

.wizard-stepper__item--done .wizard-stepper__marker {
    border-color: var(--color-accent);
    background: var(--color-accent);
    color: #fff;
}

.wizard-nav {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 1.5rem;
    justify-content: space-between;
    align-items: center;
}

.wizard-nav__link {
    font-size: 0.875rem;
    color: var(--color-muted);
    text-decoration: none;
}

.wizard-nav__link:hover { color: var(--color-primary); text-decoration: underline; }

.upload-zone {
    border: 2px dashed var(--color-border);
    border-radius: var(--radius);
    padding: 2rem 1.5rem;
    text-align: center;
    background: var(--color-bg);
    margin-bottom: 1.25rem;
    transition: border-color 0.15s, background 0.15s;
}

.upload-zone:hover { border-color: var(--color-primary); background: var(--color-primary-soft); }

.upload-zone__icon {
    display: block;
    width: 3rem;
    height: 3rem;
    margin: 0 auto 0.75rem;
    border-radius: 50%;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    line-height: 3rem;
    font-size: 1.5rem;
    color: var(--color-muted);
}

.upload-zone__label { display: block; font-weight: 600; margin-bottom: 0.5rem; }

.upload-zone input[type="file"] { font: inherit; max-width: 100%; }

.upload-blank-panel { margin-top: 1rem; }

.blank-palette-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.blank-palette-preview__swatch {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 4px;
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow);
}

.blank-canvas-form { margin: 0; }

.palette-picker {
    margin: 0 0 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-bg);
    overflow: hidden;
}

.palette-picker__summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1rem;
    padding: 0.85rem 1rem;
    cursor: pointer;
    list-style: none;
    font: inherit;
}

.palette-picker__summary::-webkit-details-marker { display: none; }

.palette-picker__summary::before {
    content: "▸";
    margin-right: 0.5rem;
    color: var(--color-muted);
    transition: transform 0.15s ease;
}

.palette-picker[open] .palette-picker__summary::before {
    transform: rotate(90deg);
}

.palette-picker__summary-text {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    flex: 1 1 12rem;
    min-width: 0;
}

.palette-picker__summary-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-muted);
}

.palette-picker__summary-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--color-text);
}

.palette-picker__summary-strip {
    flex: 0 1 10rem;
    min-width: 7rem;
    max-width: 100%;
}

.palette-picker__list {
    list-style: none;
    margin: 0;
    padding: 0 0.5rem 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    border-top: 1px solid var(--color-border);
}

.palette-picker__item { margin: 0; }

.palette-option {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1rem;
    width: 100%;
    padding: 0.65rem 0.75rem;
    border: 1px solid transparent;
    border-radius: calc(var(--radius) - 2px);
    background: var(--color-surface);
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.palette-option:hover {
    border-color: var(--color-border);
    background: #fff;
}

.palette-option--selected {
    border-color: var(--color-primary);
    box-shadow: inset 0 0 0 1px var(--color-primary);
    background: var(--color-primary-soft);
}

.palette-option__name {
    flex: 1 1 8rem;
    min-width: 0;
    font-size: 0.9375rem;
    font-weight: 600;
}

.palette-option__strip {
    flex: 0 1 11rem;
    min-width: 7rem;
    max-width: 100%;
}

.palette-strip {
    display: flex;
    height: 1.75rem;
    border-radius: 999px;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: var(--shadow);
}

.palette-strip__swatch { flex: 1 1 0; min-width: 0; }

.palette-picker__hint {
    margin: 0 0 1.25rem;
    font-size: 0.875rem;
    color: var(--color-muted);
}

.option-list {
    list-style: none;
    margin: 0 0 1.25rem;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.option-list label {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9375rem;
}

.form-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }

.editor-reprocess-panel { margin-bottom: 0; }

.editor-reprocess {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-bg);
    overflow: hidden;
}

.editor-reprocess__summary {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.85rem 1rem;
    cursor: pointer;
    list-style: none;
    font: inherit;
}

.editor-reprocess__summary::-webkit-details-marker { display: none; }

.editor-reprocess__summary::before {
    content: "▸";
    float: left;
    margin-right: 0.5rem;
    color: var(--color-muted);
    transition: transform 0.15s ease;
}

.editor-reprocess[open] .editor-reprocess__summary::before {
    transform: rotate(90deg);
}

.editor-reprocess__title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--color-text);
}

.editor-reprocess__lead {
    margin-left: 1.25rem;
    font-size: 0.875rem;
    color: var(--color-muted);
}

.editor-reprocess__hint {
    margin: 0 1rem 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--color-border);
    font-size: 0.875rem;
    color: var(--color-muted);
}

.editor-reprocess .panel__section-title,
.editor-reprocess .option-list,
.editor-reprocess .form-actions {
    margin-left: 1rem;
    margin-right: 1rem;
}

.editor-reprocess .form-actions { margin-bottom: 1rem; }

.editor-toolbar {
    display: flex;
    gap: 1.25rem;
    align-items: flex-start;
    flex-wrap: wrap;
    margin: 0 0 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--color-border);
}

.editor-toolbar__group { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }

.editor-canvas {
    display: flex;
    justify-content: center;
    padding: 1rem 0;
    margin-bottom: 1rem;
}

.editor-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
    justify-content: space-between;
    padding-top: 1.25rem;
    border-top: 1px solid var(--color-border);
}

.editor-footer__field label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-muted);
}

.editor-footer__field select {
    padding: 0.45rem 0.65rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font: inherit;
    min-width: 12rem;
}

.worksheet-ready {
    margin: 0 0 1rem;
    padding: 0.75rem 1rem;
    background: var(--color-accent-soft);
    border: 1px solid var(--color-accent);
    border-radius: var(--radius);
    color: #145a32;
    font-weight: 600;
    font-size: 0.9375rem;
}

.worksheet-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    align-items: stretch;
}

.worksheet-save-form {
    margin: 0;
    display: contents;
}

.worksheet-actions__secondary {
    display: contents;
}

.worksheet-actions .btn {
    flex: 1 1 10rem;
    justify-content: center;
    text-align: center;
}

form { margin-bottom: 0; }

.no-print { display: block; }

.pixel-grid { display: grid; grid-template-columns: repeat(10, 36px); gap: 3px; width: fit-content; user-select: none; touch-action: none; }

.pixel-cell-wrap { width: 36px; height: 36px; position: relative; }

.pixel-cell { width: 36px; height: 36px; border: 1px solid #888; cursor: crosshair; padding: 0; display: block; position: relative; z-index: 1; }

.background-indicator { display: inline-flex; align-items: center; gap: 0.5rem; font-size: 0.875rem; }

.background-indicator__swatch { width: 24px; height: 24px; border: 1px solid #888; background: #ffffff; display: inline-block; border-radius: 3px; }

.palette-row { --palette-control-size: 2.5rem; display: flex; gap: 1rem; margin: 0; flex-wrap: wrap; align-items: center; }

.palette-item { display: inline-flex; flex-direction: row; align-items: center; gap: 0.35rem; }

.palette-swatch-wrap { width: var(--palette-control-size); height: var(--palette-control-size); flex: 0 0 var(--palette-control-size); }

.palette-swatch { width: 100%; height: 100%; border: 2px solid #ccc; padding: 0; cursor: pointer; border-radius: 4px; box-sizing: border-box; display: block; }

.palette-swatch.active { border-color: #111; box-shadow: 0 0 0 2px #111; }

.palette-change-button { min-height: var(--palette-control-size); height: var(--palette-control-size); padding: 0 0.75rem; font-size: 0.75rem; line-height: 1; cursor: pointer; border-radius: 4px; box-sizing: border-box; white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--color-border); background: var(--color-bg); font: inherit; }

.palette-add-button:disabled { opacity: 0.45; cursor: not-allowed; }

.palette-color-inputs { display: none; }

.exercise-blue { color: #0b5fff; font-weight: 700; }

.exercise-green { color: #198754; font-weight: 700; }

.exercise-blank { display: inline-block; width: 36px; height: 36px; vertical-align: middle; box-sizing: border-box; border-radius: 3px; }

.exercise-blank--row { background: #e8f0ff; border: 2px solid #0b5fff; }

.exercise-blank--column { background: #e6f4ea; border: 2px solid #198754; }

.printable { background: white; padding: 1rem; }

.card { margin-top: 0; }

.print-page { page-break-after: always; }

.print-page:last-child { page-break-after: auto; }

.worksheet-visuals {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 1.25rem 2rem;
    margin-bottom: 0.25rem;
}

.print-grid { display: inline-block; padding: 0.5rem; }

.print-grid-row { display: flex; align-items: center; }

.print-grid-cell { width: 28px; height: 28px; border: 1px solid #ccc; box-sizing: border-box; }

.print-grid-label { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; box-sizing: border-box; }

.print-grid-header { display: flex; align-items: flex-end; }

.print-grid-label-blue { color: #0b5fff; }

.print-grid-label-green { color: #198754; }

.print-exercises { columns: 3; column-gap: 2rem; }

.print-exercise-item { break-inside: avoid; margin-bottom: 1rem; display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }

.print-only { display: none; }

.print-color-legend { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 0.75rem 0 1rem; }

.print-color-chip { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.15rem 0.35rem; border: 1px solid #ddd; border-radius: 999px; background: #fafafa; }

.print-color-swatch { width: 16px; height: 16px; border: 1px solid #444; display: inline-block; border-radius: 3px; }

.print-color-chip__number { font-weight: 700; min-width: 1rem; text-align: center; }

.exercise-color-chip { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.1rem 0.35rem; border: 1px solid #ddd; border-radius: 999px; background: #fafafa; margin-left: 0.25rem; }

.exercise-color-chip__swatch { width: 16px; height: 16px; border: 1px solid #444; border-radius: 3px; display: inline-block; }

.exercise-color-chip__number { font-weight: 700; min-width: 1rem; text-align: center; }

.print-header { margin-bottom: 0.75rem; }

.print-header__top {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem 1rem;
}

.print-header__title {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.print-header__intro {
    margin: 0.35rem 0 0;
    color: var(--color-muted);
    font-size: 0.95rem;
    max-width: 36rem;
}

.print-ref {
    margin: 0;
    font-size: 0.85rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.04em;
    color: var(--color-muted);
    white-space: nowrap;
}

.print-preview-image {
    display: block;
    max-width: 100%;
    width: 420px;
    height: auto;
}

.error-message {
    color: #b00020;
    font-weight: 600;
    margin: 0;
    padding: 0.75rem 1rem;
    background: #fff0f0;
    border: 1px solid #f5c2c7;
    border-radius: var(--radius);
}

.practice-body {
    min-height: 100vh;
    background:
        radial-gradient(ellipse 80% 50% at 10% -10%, rgba(11, 95, 255, 0.08), transparent 55%),
        radial-gradient(ellipse 60% 40% at 100% 0%, rgba(25, 135, 84, 0.07), transparent 50%),
        var(--color-bg);
}

.practice-shell {
    width: min(1120px, 100%);
    margin: 0 auto;
    padding: 1rem 0.85rem 2.5rem;
}

@media (min-width: 700px) {
    .practice-shell { padding: 1.5rem 1.25rem 3rem; }
}

.practice-page { width: 100%; }

.practice-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem 1.25rem;
    margin-bottom: 1rem;
}

.practice-header__title {
    margin: 0;
    font-size: clamp(1.35rem, 4vw, 1.75rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.practice-header__intro {
    margin: 0.4rem 0 0;
    color: var(--color-muted);
    font-size: 0.95rem;
    max-width: 36rem;
}

.practice-guide-link {
    flex: 0 0 auto;
    align-self: flex-start;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-primary);
    text-decoration: none;
    padding: 0.45rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    white-space: nowrap;
}

.practice-guide-link:hover { background: var(--color-primary-soft); }

.practice-progress {
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.practice-progress__meta {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.75rem;
    margin-bottom: 0.45rem;
    font-size: 0.9rem;
}

.practice-progress__label { color: var(--color-muted); font-weight: 600; }

.practice-progress__count { font-weight: 700; font-variant-numeric: tabular-nums; }

.practice-progress__track {
    height: 0.55rem;
    border-radius: 999px;
    background: var(--color-bg);
    overflow: hidden;
}

.practice-progress__fill {
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
    transition: width 0.25s ease;
}

.practice-page--unavailable {
    max-width: 28rem;
    margin: 2rem auto;
    padding: 1.5rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.practice-unavailable-actions { margin: 1rem 0 0; }

.guide-page { max-width: 42rem; margin: 1.5rem auto; padding: 1.5rem; }

.guide-content { line-height: 1.6; font-size: 0.95rem; }

.guide-content h1 { margin: 0 0 1rem; font-size: 1.75rem; line-height: 1.25; }

.guide-content h2 { margin: 1.75rem 0 0.75rem; font-size: 1.25rem; line-height: 1.3; }

.guide-content h3 { margin: 1.25rem 0 0.5rem; font-size: 1.05rem; }

.guide-content p { margin: 0 0 1rem; }

.guide-content ul,
.guide-content ol { margin: 0 0 1rem; padding-left: 1.5rem; }

.guide-content li { margin-bottom: 0.35rem; }

.guide-content li ul { margin-top: 0.35rem; margin-bottom: 0; }

.guide-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0 0 1rem;
    font-size: 0.9rem;
}

.guide-table th,
.guide-table td {
    border: 1px solid var(--color-border);
    padding: 0.5rem 0.65rem;
    text-align: left;
    vertical-align: top;
}

.guide-table th { background: var(--color-surface-muted, #f5f5f5); }

.guide-diagram {
    margin: 0 0 1rem;
    padding: 0.75rem 1rem;
    background: var(--color-surface-muted, #f5f5f5);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    overflow-x: auto;
    font-size: 0.85rem;
    line-height: 1.4;
}

.guide-diagram code { font-family: ui-monospace, Consolas, monospace; }

.guide-footer {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
    font-size: 0.9rem;
}

.practice-layout {
    display: grid;
    gap: 1rem;
    align-items: start;
}

@media (min-width: 900px) {
    .practice-layout {
        grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
        gap: 1.25rem 1.5rem;
    }
}

.practice-grid-section { min-width: 0; }

@media (min-width: 900px) {
    .practice-grid-section {
        position: sticky;
        top: 0.75rem;
    }
}

.practice-grid-card {
    container-type: inline-size;
    padding: 0.85rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.practice-grid {
    --practice-cell: clamp(1.25rem, calc((100cqi - 0.5rem) / 11), 2.25rem);
    display: block;
    width: fit-content;
    max-width: 100%;
    margin: 0 auto;
    padding: 0.25rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.practice-grid .print-grid-header,
.practice-grid .print-grid-row {
    flex-wrap: nowrap;
}

.practice-grid .print-grid-cell,
.practice-grid .print-grid-label {
    flex: 0 0 var(--practice-cell);
    width: var(--practice-cell);
    height: var(--practice-cell);
    max-width: var(--practice-cell);
    max-height: var(--practice-cell);
    aspect-ratio: 1 / 1;
    font-size: clamp(0.65rem, calc(var(--practice-cell) * 0.4), 0.8rem);
}

.practice-color-legend {
    justify-content: center;
    margin: 0.85rem 0 0;
}

.practice-exercises-section {
    min-width: 0;
    padding: 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.practice-exercises-heading {
    margin: 0 0 0.85rem;
    font-size: 1.05rem;
    font-weight: 700;
}

.practice-exercises {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.65rem;
}

@media (min-width: 700px) and (max-width: 899px) {
    .practice-exercises { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 1100px) {
    .practice-exercises { grid-template-columns: 1fr 1fr; }
}

.practice-exercise-item {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-areas:
        "index body"
        "feedback feedback";
    gap: 0.35rem 0.65rem;
    align-items: center;
    margin: 0;
    padding: 0.7rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-bg);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.practice-exercise-item--active {
    border-color: var(--color-primary);
    background: var(--color-primary-soft);
    box-shadow: 0 0 0 1px var(--color-primary);
}

.practice-exercise-item--solved {
    border-color: #b7dfc5;
    background: var(--color-accent-soft);
}

.practice-exercise-item__index {
    grid-area: index;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.75rem;
    height: 1.75rem;
    padding: 0 0.35rem;
    border-radius: 999px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--color-muted);
}

.practice-exercise-item--solved .practice-exercise-item__index {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: #fff;
}

.practice-exercise-item__body {
    grid-area: body;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.65rem;
    min-width: 0;
}

.practice-exercise-item .practice-feedback {
    grid-area: feedback;
    min-height: 1.1rem;
}

.practice-formula {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    font-size: 1.05rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.practice-formula__op {
    color: var(--color-muted);
    font-weight: 700;
}

.practice-grid-cell {
    transition: background-color 0.25s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.practice-grid-cell--target {
    background: #fafbfd;
}

.practice-grid-cell--filled { border-color: #888; }

.practice-answer {
    width: 2.75rem;
    height: 2.75rem;
    min-width: 2.75rem;
    min-height: 2.75rem;
    padding: 0;
    text-align: center;
    font-size: 1.05rem;
    font-weight: 700;
    box-sizing: border-box;
    border-radius: 6px;
    vertical-align: middle;
    -moz-appearance: textfield;
}

.practice-answer::-webkit-outer-spin-button,
.practice-answer::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.practice-answer:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: 1px;
}

.practice-answer--row { background: #e8f0ff; border: 2px solid #0b5fff; }

.practice-answer--column { background: #e6f4ea; border: 2px solid #198754; }

.practice-answer--correct { border-color: #198754; background: #e6f4ea; color: #146c43; }

.practice-answer--wrong { border-color: #b00020; background: #fff0f0; }

.practice-feedback { font-size: 0.85rem; font-weight: 700; }

.practice-feedback--correct { color: #198754; }

.practice-feedback--wrong { color: #b00020; }

.practice-complete {
    margin-top: 1.25rem;
    padding: 1rem 1.15rem;
    border: 2px solid #198754;
    background: #e6f4ea;
    border-radius: var(--radius);
    font-weight: 700;
    font-size: 1.1rem;
    text-align: center;
    box-shadow: var(--shadow);
}

.practice-exercise-item .exercise-color-chip {
    margin-left: 0;
}

.practice-fireworks {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
}

.library-panel__header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.library-empty {
    margin: 0;
    color: var(--color-text-muted, #666);
}

.library-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.75rem;
}

.library-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 0.75rem;
    background: var(--color-surface, #fff);
}

.library-item__link {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
    min-width: 0;
    color: inherit;
    text-decoration: none;
}

.library-item__link:hover { text-decoration: none; }

.library-item__thumb-wrap { flex: 0 0 auto; }

.library-item__thumb {
    display: block;
    width: 72px;
    height: 72px;
    object-fit: contain;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    background: #fff;
}

.library-item__thumb--empty {
    display: inline-block;
    background: #f5f5f5;
}

.library-item__meta {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.library-item__date { font-weight: 700; }

.library-item__count {
    font-size: 0.9rem;
    color: var(--color-text-muted, #666);
}

.library-item__delete { flex: 0 0 auto; }

.share-panel { margin-bottom: 1.5rem; }

.share-link-row { margin-bottom: 1rem; }

.share-link-row__label {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 700;
}

.share-url-input {
    width: 100%;
    font: inherit;
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    box-sizing: border-box;
}

.btn--small {
    padding: 0.35rem 0.65rem;
    font-size: 0.85rem;
}

.btn--danger {
    background: #fff0f0;
    border: 1px solid #b00020;
    color: #b00020;
}

.btn--danger:hover {
    background: #b00020;
    color: #fff;
}

@media (max-width: 540px) {
    .wizard-stepper { flex-direction: column; }

    .wizard-stepper__item:not(:last-child)::after { display: none; }

    .wizard-stepper__item { padding: 0.5rem 0; }
}

@page {
    size: A4;
    margin: 12mm 14mm;
}

@media print {
    body { margin: 0; background: #fff; color: #000; }

    .app-shell { max-width: none; padding: 0; }

    .app-header, .wizard-stepper, .wizard-nav, .worksheet-ready, .no-print { display: none !important; }

    .panel { border: none; box-shadow: none; padding: 0; background: #fff; }

    form:not(#pixel-editor-form) { display: none !important; }

    .card:not(.printable), #pixel-editor-form { display: none !important; }

    .print-only { display: block !important; }

    .printable {
        padding: 0;
        background: #fff;
        zoom: 0.8;
    }

    .print-header { margin-bottom: 0.5rem; }

    .print-header__title { font-size: 1.25rem; color: #000; }

    .print-header__intro {
        margin: 0.25rem 0 0;
        color: #333;
        font-size: 0.9rem;
    }

    .print-ref { color: #333; }

    .print-color-chip,
    .exercise-color-chip {
        background: transparent;
    }

    .print-grid-cell,
    .print-color-swatch,
    .exercise-color-chip__swatch,
    .exercise-blank,
    .exercise-blue,
    .exercise-green {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}
