/* Site CSS on top of Bootstrap + the fixed Bootswatch theme (United), recoloured with the brand palette below. Everything here works with any theme: colors come
 * from the theme's own variables, plus the three ruling colors the worksheets print. No inline styles anywhere. */
:root {
  --rule-top: #3b70d9;   /* the same blue, dashed mid and red as the printed ruling (engine/paint.js COLORS) */
  --rule-mid: #9fb3e6;
  --rule-base: #d94a4a;
}

/* ---- Brand palette (coolors.co/273043-9197ae-eff6ee-f02d3a-dd0426) laid over the United theme ----
 * #F02D3A is the primary. #DD0426 is every button's hover and the text-link colour (white on #F02D3A is 4.1:1, on #DD0426 5.1:1; the
 * link colour on the #EFF6EE page is 4.6:1, where #F02D3A would only be 3.7:1). #273043 is the heading and body ink. #9197AE is for
 * borders and quiet decoration only: as text on the page it is too pale (2.7:1), so secondary text uses a darker mix of the ink. */
:root {
  --brand-red: #F02D3A;         /* signal / identity red: hero flashes, focused input ring, slider accent */
  --brand-red-deep: #DD0426;
  --brand-cta: #C20322;         /* primary CTA fill: white on it is 6.3:1 (passes AA at any size), weighted and confident */
  --brand-cta-press: #9A0320;   /* CTA pressed state */
  --brand-ink: #273043;
  --brand-slate: #9197AE;
  --brand-paper: #EFF6EE;
  --brand-link: #C20322;  /* text-link red; shares the hex with --brand-cta */
  --surface: #fff;

  --bs-primary: var(--brand-red);
  --bs-primary-rgb: 240, 45, 58;
  --bs-primary-bg-subtle: #fde4e6;
  --bs-primary-border-subtle: #f8a9af;
  --bs-primary-text-emphasis: #7a0214;
  --bs-body-bg: var(--brand-paper);
  --bs-body-bg-rgb: 239, 246, 238;
  --bs-body-color: var(--brand-ink);
  --bs-body-color-rgb: 39, 48, 67;
  --bs-heading-color: var(--brand-ink);
  --bs-secondary-color: color-mix(in srgb, var(--brand-ink) 80%, var(--brand-paper));
  --bs-border-color: color-mix(in srgb, var(--brand-slate) 55%, var(--brand-paper));
  --bs-link-color: var(--brand-link);
  --bs-link-color-rgb: 194, 3, 34;
  --bs-link-hover-color: var(--brand-ink);
  --bs-link-hover-color-rgb: 39, 48, 67;
  --bs-card-bg: var(--surface);
  --bs-focus-ring-color: rgba(240, 45, 58, .3);
}
h1, h2, h3, h4, .h1, .h2, .h3, .h4 { color: var(--brand-ink); }
.bg-primary h1, .bg-primary h2, .bg-primary h3, .bg-primary h4, .bg-dark h1, .bg-dark h2, .bg-dark h3, .bg-dark h4,
.text-bg-primary h1, .text-bg-primary h2, .text-bg-primary h3, .text-bg-primary h4 { color: #fff; }
.card, .list-group-item, .modal-content, .dropdown-menu, .accordion-item { background-color: var(--surface); }
.form-control, .form-select { background-color: var(--surface); border-color: var(--brand-slate); }
.form-control:focus, .form-select:focus { border-color: var(--brand-red); box-shadow: 0 0 0 .25rem rgba(240, 45, 58, .25); }
.form-check-input:checked { background-color: var(--brand-red); border-color: var(--brand-red); }
.form-check-input:focus { border-color: var(--brand-red); box-shadow: 0 0 0 .25rem rgba(240, 45, 58, .25); }
.form-range::-webkit-slider-thumb { background-color: var(--brand-red); }
.form-range::-moz-range-thumb { background-color: var(--brand-red); }
.navbar.bg-primary { background-color: var(--brand-red) !important; }
.text-primary { color: var(--brand-link) !important; }
.table { --bs-table-bg: transparent; }
.alert-primary { --bs-alert-color: #7a0214; --bs-alert-bg: #fde4e6; --bs-alert-border-color: #f8a9af; }

/* Buttons: the deeper --brand-cta is the resting fill (6.3:1 white) and --brand-cta-press is the pressed state.
   The brighter --brand-red stays as the identity accent (focused input ring, slider thumb, hero flashes). */
.btn-primary { --bs-btn-color: #fff; --bs-btn-bg: var(--brand-cta); --bs-btn-border-color: var(--brand-cta);
  --bs-btn-hover-color: #fff; --bs-btn-hover-bg: var(--brand-cta-press); --bs-btn-hover-border-color: var(--brand-cta-press);
  --bs-btn-active-color: #fff; --bs-btn-active-bg: var(--brand-cta-press); --bs-btn-active-border-color: var(--brand-cta-press);
  --bs-btn-disabled-color: #fff; --bs-btn-disabled-bg: var(--brand-cta); --bs-btn-disabled-border-color: var(--brand-cta); --bs-btn-focus-shadow-rgb: 194, 3, 34; }
.btn-outline-primary { --bs-btn-color: var(--brand-link); --bs-btn-border-color: var(--brand-link); }
.btn-outline-primary, .btn-outline-secondary, .btn-outline-dark, .btn-outline-light, .btn-secondary, .btn-light, .btn-ghost {
  --bs-btn-hover-color: #fff; --bs-btn-hover-bg: var(--brand-red-deep); --bs-btn-hover-border-color: var(--brand-red-deep);
  --bs-btn-active-color: #fff; --bs-btn-active-bg: var(--brand-red-deep); --bs-btn-active-border-color: var(--brand-red-deep); }
.btn-outline-secondary { --bs-btn-color: var(--brand-ink); --bs-btn-border-color: var(--brand-slate); }
.btn-outline-dark { --bs-btn-color: var(--brand-ink); --bs-btn-border-color: var(--brand-ink); }
.btn-ghost:hover, .btn-ghost:focus-visible { color: #fff; background: var(--brand-red-deep); border-color: var(--brand-red-deep); }
.btn-light { --bs-btn-color: var(--brand-ink); --bs-btn-bg: #fff; --bs-btn-border-color: #fff; }
.navbar .btn-light:hover, .navbar .btn-outline-light:hover { background-color: var(--brand-ink); border-color: var(--brand-ink); color: #fff; } /* on the red bar, #DD0426 would barely show */

/* ---- Type: 18px base, and nothing smaller than 16px ---- */
html { font-size: 112.5%; }
.small, small, .form-text, .figure-caption { font-size: .9rem; }
.form-label, .form-check-label { font-size: 1rem; }
.form-label { font-weight: 600; }
.btn { font-size: 1.0625rem; }
.btn-primary { font-weight: 700; }  /* white on --brand-cta #C20322 is 6.3:1: passes AA for text at any size */
.btn-primary:not(.btn-lg):not(.btn-sm) { --bs-btn-font-size: 1.04rem; }
.btn-sm { --bs-btn-font-size: .9rem; --bs-btn-padding-y: .35rem; --bs-btn-padding-x: .75rem; min-height: 2.5rem; display: inline-flex; align-items: center; justify-content: center; gap: .35rem; }
.btn-lg { --bs-btn-font-size: 1.25rem; min-height: 3.5rem; }
.form-select-sm, .form-control-sm { font-size: .95rem; min-height: 2.5rem; }
.form-control, .form-select { min-height: 3rem; }
.table { font-size: 1rem; }
.table > :not(caption) > * > * { padding: .65rem .6rem; }
.nav-link, .navbar-brand { font-size: 1.0625rem; }
.navbar .nav-link, .navbar .btn { white-space: nowrap; }

.visually-hidden-focusable:focus { z-index: 2000; top: .5rem; left: .5rem; }
img { max-width: 100%; height: auto; }

/* ---- Widths that used to be inline styles ---- */
.w-narrow { max-width: 28rem; margin-inline: auto; }
.w-form { max-width: 32rem; margin-inline: auto; }
.w-text { max-width: 36rem; margin-inline: auto; }
.w-account { max-width: 40rem; margin-inline: auto; }
.w-prose { max-width: 48rem; margin-inline: auto; }
.w-generator { max-width: 62rem; margin-inline: auto; }
.w-slider { max-width: 28rem; }

/* ---- Focus, hover and motion: every control shows where you are ---- */
:focus-visible { outline: 3px solid var(--bs-primary); outline-offset: 2px; }
.navbar :focus-visible, .btn-primary:focus-visible { outline-color: #fff; box-shadow: 0 0 0 5px var(--bs-primary); }
.btn, .form-control, .form-select, .choice, .example-card { transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s, transform .15s; }
.btn:active { transform: translateY(1px); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* ---- Helpers ---- */
.band { background-color: color-mix(in srgb, var(--bs-body-color) 6%, var(--bs-body-bg)); }
.btn-ghost { color: var(--bs-body-color); border: 1px solid currentColor; background: transparent; }
.btn-ghost:hover, .btn-ghost:focus-visible { color: var(--bs-body-color); background: color-mix(in srgb, var(--bs-body-color) 10%, transparent); }
.btn-go { min-height: 3.5rem; font-size: 1.25rem; padding-inline: 1.75rem; font-weight: 700; }

/* ---- Choice tiles (age group, capitalization, tracing marks): a radio you can see ---- */
.choice-group { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr)); }
.choice { position: relative; display: flex; flex-direction: column; justify-content: center; gap: .35rem; min-height: 3.5rem; padding: .6rem .8rem; border: 2px solid color-mix(in srgb, var(--bs-body-color) 22%, var(--bs-body-bg)); border-radius: .5rem; background: var(--surface); cursor: pointer; font-weight: 600; line-height: 1.2; }
.choice input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.choice-row { flex-direction: row; align-items: center; justify-content: space-between; gap: .75rem; } /* name and sample on one line, so these tiles are as tall as their neighbours */
.choice:hover { border-color: var(--bs-primary); }
.choice:has(input:checked) { border-color: var(--bs-primary); background: color-mix(in srgb, var(--bs-primary) 9%, var(--bs-body-bg)); box-shadow: inset 0 0 0 1px var(--bs-primary); }
.choice:has(input:focus-visible) { outline: 3px solid var(--bs-primary); outline-offset: 2px; }
.choice .choice-note { font-weight: 400; font-size: .9rem; color: var(--bs-secondary-color); }
.choice-sample { font-size: 1.35rem; letter-spacing: .02em; }
.choice-group.is-wide { grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); }

/* The three-line ruling, drawn at the real relative height of each age group */
.ruling { height: calc(var(--h, 1) * 3rem); min-height: 1.5rem; margin-block: .15rem;
  background:
    linear-gradient(var(--rule-top), var(--rule-top)) top / 100% 2px no-repeat,
    repeating-linear-gradient(90deg, var(--rule-mid) 0 6px, transparent 6px 10px) center / 100% 2px no-repeat,
    linear-gradient(var(--rule-base), var(--rule-base)) bottom / 100% 2px no-repeat; }
.ruling-prek { --h: 1; } .ruling-k { --h: .875; } .ruling-1 { --h: .625; } .ruling-2 { --h: .5; }
.choice-age { min-height: 6.25rem; justify-content: flex-end; }

/* ---- The word box is a practice line: type on the same ruling the worksheet prints ---- */
.ruled-input { position: relative; border: 2px solid color-mix(in srgb, var(--bs-body-color) 22%, var(--bs-body-bg)); border-radius: .5rem; background: #fff; transition: border-color .15s, box-shadow .15s; }
.ruled-input:focus-within { border-color: var(--bs-primary); box-shadow: 0 0 0 .25rem color-mix(in srgb, var(--bs-primary) 25%, transparent); }
.ruled-input input { display: block; width: 100%; height: 6rem; padding: 1.25rem 1rem 0 1rem; border: 0; background:
    linear-gradient(var(--rule-top), var(--rule-top)) 0 1.3rem / 100% 2px no-repeat,
    repeating-linear-gradient(90deg, var(--rule-mid) 0 6px, transparent 6px 10px) 0 3rem / 100% 2px no-repeat,
    linear-gradient(var(--rule-base), var(--rule-base)) 0 4.7rem / 100% 2px no-repeat;
  font-size: 2.4rem; line-height: 1; color: #1a1a1a; border-radius: .4rem; outline: none; }
.ruled-input input::placeholder { color: #9aa0ad; }
.fit-status { min-height: 1.75rem; font-size: 1rem; }
.fit-ok { color: var(--bs-success-text-emphasis, #0f5132); }
.char-count { font-variant-numeric: tabular-nums; }
.char-count.is-near { color: var(--bs-warning-text-emphasis, #664d03); font-weight: 600; }

/* ---- Slider: a thumb you can grab ---- */
.form-range { height: 2rem; }
.form-range::-webkit-slider-thumb { width: 1.75rem; height: 1.75rem; margin-top: -.55rem; }
.form-range::-moz-range-thumb { width: 1.75rem; height: 1.75rem; }
.form-range::-webkit-slider-runnable-track { height: .6rem; border-radius: .3rem; }
.form-range::-moz-range-track { height: .6rem; border-radius: .3rem; }

/* ---- Make button states, ready panel ---- */
.ready-panel { border: 2px solid var(--bs-success); border-radius: .5rem; background: color-mix(in srgb, var(--bs-success) 8%, var(--bs-body-bg)); padding: 1rem 1.25rem; }
.ready-panel .bi-check-circle-fill { color: var(--bs-success); font-size: 1.6rem; }

/* ---- Sample sheet previews drawn by the engine ---- */
.sheet-frame { background: #fff; border: 1px solid rgba(0, 0, 0, .15); border-radius: .5rem; box-shadow: 0 .25rem 1rem rgba(0, 0, 0, .12); overflow: hidden; max-width: 34rem; aspect-ratio: 8.5 / 5.6; }
.sheet-thumb { box-shadow: none; border: 0; border-bottom: 1px solid rgba(0, 0, 0, .15); border-radius: 0; aspect-ratio: 8.5 / 4.6; }
.sheet-frame svg { display: block; width: 100%; height: 100%; }

/* ---- Home hero: the copy and the sheet share one top edge and one bottom edge ----
 * On wide screens the two columns are the same height: the headline sits at the top of the copy column and the buttons at the
 * bottom. The sheet is inset by exactly the empty space above the headline's capitals and below the last line's baseline, so its
 * top edge meets the top of the capitals and its bottom edge meets that baseline. previews.js shows as much of the page as fits. */
.hero-row { --hero-fs: clamp(2.75rem, 7vw, 5rem); --cap-gap: calc(var(--hero-fs) * .169); --base-gap: .35rem; }
.hero-title { font-size: var(--hero-fs); line-height: 1.02; letter-spacing: -.01em; margin-bottom: 1.25rem; }
.hero-visual { container-type: inline-size; }  /* the sheet's minimum height is worked out from the column's width (cqw) */
.hero-visual .sheet-fill { aspect-ratio: 8.5 / 6.4; }  /* 6.4 in of page from 0.4 in down: through the third row and its descender band, nothing cut off */
.hero-tools-wrap { max-width: 34rem; margin-top: .75rem; }
.hero-try { font-size: 1rem; font-weight: 700; line-height: 1.2; color: var(--brand-ink); }
.hero-tools .form-range { display: block; height: 2.75rem; }  /* as tall as the buttons beside it, so the thumb sits on their centre line */
.btn-tool { --bs-btn-font-size: 1.1rem; --bs-btn-padding-x: .25rem; --bs-btn-padding-y: .2rem; min-height: 2.75rem; font-weight: 700; line-height: 1; white-space: nowrap; }
.btn-tool[aria-pressed="true"] { background-color: var(--brand-ink); border-color: var(--brand-ink); color: #fff; }
.btn-tool[aria-pressed="true"]:hover, .btn-tool[aria-pressed="true"]:focus-visible { background-color: var(--brand-red-deep); border-color: var(--brand-red-deep); }
@media (min-width: 992px) {
  .hero-row { align-items: stretch; }
  .hero-copy { display: flex; flex-direction: column; justify-content: space-between; }
  .hero-visual { display: flex; flex-direction: column; }
  .hero-visual .sheet-fill { position: relative; flex: 1 1 auto; width: 100%; max-width: none; aspect-ratio: auto; height: auto;
    min-height: calc(100cqw * 6.4 / 8.5); margin-top: var(--cap-gap); margin-bottom: 0; }
  .sheet-fill svg { position: absolute; inset: 0; } /* the picture never sets the row's height; the copy does */
  .hero-tools-wrap { max-width: none; width: 100%; margin-bottom: var(--base-gap); }
}
.sheet-preview-art { max-width: 24rem; margin: 0 auto; }
.sheet-preview-art svg { display: block; width: 100%; height: auto; box-shadow: 0 .25rem 1rem rgba(0, 0, 0, .18); border-radius: 2px; }
@media (min-width: 992px) { .sheet-preview { position: sticky; top: 1rem; } }

/* ---- Example cards: the whole card is a target ---- */
.example-card { position: relative; overflow: hidden; }
.example-card:hover, .example-card:focus-within { border-color: var(--bs-primary); box-shadow: 0 0 0 2px var(--bs-primary); }
.example-card .stretched-link::after { z-index: 1; }
.example-card .example-download { position: relative; z-index: 2; }

/* ---- Pricing / checkout ---- */
.pricing-lede { max-width: 40rem; }
.pricing-wrap { max-width: 56rem; }  /* two plans: a narrower column keeps the cards, table and questions in proportion */
.plan-card.is-featured { border: 2px solid var(--bs-primary); box-shadow: 0 .5rem 1.5rem color-mix(in srgb, var(--bs-primary) 22%, transparent); }
.interval-choice { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); }
.interval-choice .choice { min-height: 5rem; }
.price-big { font-size: 2.5rem; font-weight: 700; line-height: 1; }
.steps { display: flex; gap: .5rem; list-style: none; padding: 0; margin: 0 0 1.5rem; flex-wrap: wrap; }
.steps li { display: flex; align-items: center; gap: .5rem; font-size: 1rem; color: var(--bs-secondary-color); }
.steps .step-dot { width: 2rem; height: 2rem; border-radius: 50%; border: 2px solid currentColor; display: grid; place-items: center; font-weight: 700; font-size: 1.05rem; }
.steps li.is-current { color: var(--bs-body-color); font-weight: 700; }
.steps li.is-current .step-dot { background: var(--bs-primary); border-color: var(--bs-primary); color: #fff; }
.steps li.is-done .step-dot { background: var(--bs-success); border-color: var(--bs-success); color: #fff; }
@media (min-width: 640px) { .steps { flex-wrap: nowrap; } .steps li + li::before { content: ""; width: 1.5rem; border-top: 2px solid var(--bs-border-color); } }
@media (max-width: 639.98px) { .steps { flex-direction: column; gap: .4rem; } }

/* ---- Admin ---- */
.stat-number { font-size: 2.25rem; font-weight: 700; line-height: 1.1; }
.nowrap { white-space: nowrap; }
.popular-bar { width: 6rem; height: .6rem; accent-color: var(--bs-primary); vertical-align: middle; }
progress.popular-bar { appearance: none; border: 0; border-radius: .3rem; background: var(--bs-secondary-bg); overflow: hidden; }
progress.popular-bar::-webkit-progress-bar { background: var(--bs-secondary-bg); }
progress.popular-bar::-webkit-progress-value { background: var(--bs-primary); border-radius: .3rem; }
progress.popular-bar::-moz-progress-bar { background: var(--bs-primary); }
.url-line { font-family: var(--bs-font-monospace); font-size: .9rem; word-break: break-all; }

/* ---- 404: the paper ball drops in once, then rests ---- */
.paper-ball { display: block; width: min(15rem, 70vw); height: auto; margin: 0 auto; overflow: visible; }
.paper-ball .ball { transform-origin: 120px 190px; animation: ball-drop .9s cubic-bezier(.3, 0, .4, 1) both; }
.paper-ball .ball-shadow { transform-origin: 120px 196px; animation: shadow-grow .9s cubic-bezier(.3, 0, .4, 1) both; }
.paper-ball:hover .ball { animation: ball-wobble .6s ease-in-out; }
@keyframes ball-drop {
  0% { transform: translateY(-170px) rotate(-40deg); } 55% { transform: translateY(0) rotate(8deg) scale(1.06, .94); }
  72% { transform: translateY(-34px) rotate(-3deg); } 88% { transform: translateY(0) rotate(1deg) scale(1.03, .97); } 100% { transform: none; } }
@keyframes shadow-grow { 0% { transform: scale(.35); opacity: .2; } 55% { transform: scale(1); opacity: 1; } 72% { transform: scale(.75); } 88%, 100% { transform: scale(1); opacity: 1; } }
@keyframes ball-wobble { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(9deg); } 75% { transform: rotate(-7deg); } }

/* Dev-only theme dropdown in the header */
.theme-select { width: 8.5rem; }
legend.form-label { float: none; width: auto; padding: 0; margin-bottom: .5rem; }
.navbar[data-bs-theme="dark"] .nav-link { --bs-nav-link-color: rgba(255, 255, 255, .92); --bs-nav-link-hover-color: #fff; text-decoration: none; }
.navbar[data-bs-theme="dark"] .nav-link:hover { text-decoration: underline; text-underline-offset: .25em; }
.choice-age { padding: .5rem; gap: .15rem; }
.choice-age .ruling { margin-bottom: .35rem; }
.choice-name { white-space: nowrap; font-size: 1rem; }
.choice-age .choice-note { display: block; }
.choice-group:has(.choice-age) { grid-template-columns: repeat(auto-fit, minmax(6.75rem, 1fr)); }
.table th { white-space: nowrap; }
.price-big small { white-space: nowrap; }
.table-responsive { position: relative; } /* keeps screen-reader-only text inside the scrolling table instead of widening the page */

/* Emailed sign-in */
.or-divider { display: flex; align-items: center; gap: .75rem; color: var(--bs-secondary-color); font-size: .95rem; }
.or-divider::before, .or-divider::after { content: ""; flex: 1; border-top: 1px solid var(--bs-border-color); }
.code-input { letter-spacing: .4em; font-size: 1.75rem; text-align: center; font-variant-numeric: tabular-nums; }

/* ---- The page body (#main) sits on a pale tint of the brand slate, so text and red buttons keep their contrast: brand ink
 * is 10:1 on it, the red buttons and #DD0426 links stand out from it, and nothing is ever placed straight on #F02D3A. ---- */
:root { --brand-mist: #DDE0EA; }
#main { background-color: var(--brand-mist); }

/* ---- Mobile home (shown under 768px). The desktop hero + generator sections are hidden; this is the whole creator UI on
 * phones: sticky preview, four settings cards (age, case, tracing, spacing) and a floating dock with Print + Copy link. ---- */
.mhome { padding: 20px 16px calc(28px + 92px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; }
.mhome-hero { text-align: center; margin: 4px 0 2px; }
.mhome-hero-title { font-size: clamp(1.9rem, 7vw, 2.4rem); font-weight: 700; line-height: 1.08; letter-spacing: -0.01em; margin: 0 0 6px; color: var(--brand-ink); }
.mhome-hero-lede { font-size: 0.95rem; color: color-mix(in srgb, var(--brand-ink) 80%, var(--brand-paper)); margin: 0; line-height: 1.4; }
.mhome-section-heading { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.005em; margin: 14px 0 0; color: var(--brand-ink); }
.mhome-chips-row { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x proximity; padding: 2px 0; margin: 0 -4px; }
.mhome-chip { flex: 0 0 auto; appearance: none; border: 1.5px solid var(--bs-border-color); background: #fff; color: var(--brand-ink); font-weight: 600; font-size: 0.85rem; padding: 7px 14px; border-radius: 999px; line-height: 1; scroll-snap-align: start; transition: background 150ms, border-color 150ms, color 150ms, transform 150ms; }
.mhome-chip:active { transform: scale(0.96); }
.mhome-chip-recent { background: var(--brand-mist); border-color: transparent; }
/* Mobile ruled input: same three-line ruling (blue top, dashed mid, red base) as the desktop generator.
 * Everything scales with --age-scale so Pre-K (1.0) through 2nd (0.5) show a visible size delta. The
 * font is purely proportional (no additive), the ruling spacing matches cap-height (0.7 * font-size),
 * and padding keeps the baseline sitting on the red line (ascent ≈ 0.94 * font-size, line-height:1). */
.mhome .ruled-input { --age-scale: 0.88; border-radius: 16px; border-width: 2px; }
.mhome .ruled-input input { height: calc(5rem * var(--age-scale) + 1rem);
  padding: calc(1.2rem * var(--age-scale) + 0.8rem) 1rem 0 .2rem;
  font-size: calc(3.2rem * var(--age-scale)); line-height: 1; font-weight: 700; letter-spacing: -0.01em;
    /* No transition on font-size/height: Chromium does not interpolate calc() expressions that use a changing var(). */
  background:
    linear-gradient(var(--rule-top), var(--rule-top)) 0 calc(2.25rem * var(--age-scale) + 0.8rem) / 100% 2px no-repeat,
    repeating-linear-gradient(90deg, var(--rule-mid) 0 6px, transparent 6px 10px) 0 calc(3.38rem * var(--age-scale) + 0.8rem) / 100% 2px no-repeat,
    linear-gradient(var(--rule-base), var(--rule-base)) 0 calc(4.5rem * var(--age-scale) + 0.8rem) / 100% 2px no-repeat;
  border-radius: 14px; }
.mhome .ruled-input input::placeholder { color: #c2c7d0; font-weight: 700; }
.mhome-sheet { aspect-ratio: 8.5 / 11; background: var(--brand-paper); border: 1px solid var(--bs-border-color); border-radius: 10px; overflow: hidden; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18); transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1); }
.mhome-sheet svg { display: block; width: 100%; height: auto; }
/* In-flow preview bubble (top of the page crop) and the fixed strip that replaces it once it scrolls off. The strip only
 * moves with transform/opacity, so scrolling never re-lays out the page. Both crop the same page SVG from the top. */
.mhome-sheet-pin { padding: 8px 8px 8px; background: var(--brand-ink); border-radius: 22px; box-shadow: 0 8px 18px -8px rgba(39, 48, 67, 0.4), 0 2px 4px rgba(39, 48, 67, 0.12); }
.mhome-sheet-pin .mhome-sheet { aspect-ratio: 16 / 7; border-radius: 14px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.28), 0 1px 3px rgba(0, 0, 0, 0.18); }
.mhome-sheet-open { display: block; cursor: pointer; touch-action: manipulation; border-radius: 14px; }
.mhome-sheet-open:focus-visible { outline: 3px solid var(--brand-red); outline-offset: 2px; }
.mhome-strip { position: fixed; top: 0; left: 0; right: 0; z-index: 1020; padding: calc(6px + env(safe-area-inset-top)) 16px 10px; background: var(--brand-ink); border-radius: 0 0 22px 22px; box-shadow: 0 8px 18px -8px rgba(39, 48, 67, 0.4), 0 2px 4px rgba(39, 48, 67, 0.12);
  transform: translateY(-110%); opacity: 0; visibility: hidden; will-change: transform;
  transition: transform 200ms cubic-bezier(0.22, 1, 0.36, 1), opacity 200ms, visibility 0s linear 200ms; }
.mhome-strip.show { transform: none; opacity: 1; visibility: visible; transition-delay: 0s; }
.mhome-strip .mhome-sheet { aspect-ratio: 8.5 / 2.4; border-radius: 12px; box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25); }
@media (prefers-reduced-motion: reduce) { .mhome-strip { transition: none; } }
.mhome-meta-top { margin-top: 2px; }

/* Full-screen preview modal (mobile). Backdrop dims the page; dialog fills the viewport minus safe-area padding. */
.mhome-preview-modal { position: fixed; inset: 0; z-index: 1040; display: flex; align-items: stretch; justify-content: stretch; }
.mhome-preview-modal[hidden] { display: none; }
.mhome-preview-backdrop { position: absolute; inset: 0; background: rgba(39, 48, 67, 0.72); backdrop-filter: blur(2px); }
.mhome-preview-dialog { position: relative; z-index: 1; display: flex; flex-direction: column; width: 100%; background: var(--brand-ink); color: #fff; padding: calc(10px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom)); }
.mhome-preview-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 2px 4px 10px; }
.mhome-preview-title { font-size: 0.95rem; font-weight: 700; letter-spacing: 0.02em; margin: 0; color: #fff; }
.mhome-preview-close { appearance: none; border: 0; background: rgba(255, 255, 255, 0.12); color: #fff; height: 42px; padding: 0 14px; border-radius: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; font-weight: 700; font-size: 0.95rem; transition: none; touch-action: manipulation; }
.mhome-preview-close-label { line-height: 1; }
.mhome-preview-close:active { background: rgba(255, 255, 255, 0.24); }
.mhome-preview-body { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 6px; overflow: auto; }
.mhome-preview-body .mhome-sheet { width: 100%; max-width: min(100%, 72vh); margin: 0 auto; }
.mhome-meta-modal { color: rgba(255, 255, 255, 0.85); font-size: 0.78rem; margin: 2px 0 0; text-align: center; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.mhome-sheet.flash { animation: mhome-flash 400ms ease; }
.mhome-sheet.celebrate { animation: mhome-celebrate 900ms cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes mhome-flash { 0%, 100% { transform: scale(1); box-shadow: 0 4px 16px rgba(39, 48, 67, 0.1), 0 1px 3px rgba(39, 48, 67, 0.06); } 50% { transform: scale(1.015); box-shadow: 0 6px 24px rgba(240, 45, 58, 0.18); } }
@keyframes mhome-celebrate { 0% { transform: translateY(0) scale(1); } 30% { transform: translateY(-6px) scale(1.03); box-shadow: 0 14px 32px rgba(240, 45, 58, 0.24); } 60% { transform: translateY(2px) scale(0.995); } 100% { transform: translateY(0) scale(1); } }
.mhome-meta { font-size: 0.8rem; color: color-mix(in srgb, var(--brand-ink) 72%, var(--brand-mist)); text-align: center; margin: 0; font-variant-numeric: tabular-nums; }
.mhome-error { font-size: 0.9rem; margin: 0; }
.mhome-cards { display: flex; flex-direction: column; gap: 12px; margin-top: 4px; }
.mhome-card { background: #fff; border: 1.5px solid var(--bs-border-color); border-radius: 18px; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; transition: border-color 180ms, box-shadow 180ms; }
.mhome-card:focus-within { border-color: var(--brand-red); box-shadow: 0 6px 16px rgba(240, 45, 58, 0.14); }
.mhome-card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.mhome-card-title { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: color-mix(in srgb, var(--brand-ink) 72%, var(--brand-mist)); }
.mhome-card-value { flex: 1; text-align: right; font-size: 0.9rem; font-weight: 600; color: var(--brand-ink); font-variant-numeric: tabular-nums; }
.mhome-tooltip-btn { appearance: none; border: 1.5px solid var(--bs-border-color); background: #fff; color: var(--brand-ink-80, color-mix(in srgb, var(--brand-ink) 72%, var(--brand-mist))); width: 26px; height: 26px; border-radius: 50%; font-weight: 700; font-size: 0.85rem; line-height: 1; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.mhome-tooltip-btn[aria-expanded="true"] { background: var(--brand-ink); color: #fff; border-color: var(--brand-ink); }
.mhome-tooltip-pop { background: var(--brand-ink); color: #fff; border-radius: 14px; padding: 12px 14px; margin-top: 4px; font-size: 0.82rem; line-height: 1.4; }
.mhome-tooltip-pop .mhome-tooltip-title { font-weight: 700; margin: 0 0 6px; color: #fff; font-size: 0.78rem; letter-spacing: 0.03em; text-transform: uppercase; opacity: 0.85; }
.mhome-tooltip-pop ul { list-style: none; padding: 0; margin: 0; }
.mhome-tooltip-pop li { padding: 2px 0; }
.mhome-tooltip-pop b { color: #fff; font-weight: 700; }
.mhome-segment { display: flex; background: var(--brand-mist); border-radius: 12px; padding: 3px; gap: 2px; }
.mhome-segment button { flex: 1; appearance: none; background: transparent; border: 0; color: color-mix(in srgb, var(--brand-ink) 72%, var(--brand-mist)); font-weight: 600; font-size: 0.9rem; padding: 9px 2px; border-radius: 10px; line-height: 1; transition: background 180ms, color 180ms, box-shadow 180ms; }
.mhome-segment button[aria-pressed="true"] { background: #fff; color: var(--brand-ink); box-shadow: 0 1px 2px rgba(39, 48, 67, 0.08), 0 2px 6px rgba(39, 48, 67, 0.04); }
.mhome-ages-row { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 4px 0 2px; margin: -4px -4px 0;
  mask-image: linear-gradient(to right, #000 0, #000 88%, transparent 100%);
  -webkit-mask-image: linear-gradient(to right, #000 0, #000 88%, transparent 100%); }
.mhome-age-chip { flex: 0 0 auto; min-width: 76px; scroll-snap-align: start; appearance: none; background: var(--brand-mist); border: 0; color: var(--brand-ink); border-radius: 14px; padding: 10px 14px; text-align: left; transition: background 180ms, transform 180ms, color 180ms; }
.mhome-age-chip strong { display: block; font-size: 0.95rem; font-weight: 700; }
.mhome-age-chip small { display: block; font-size: 0.72rem; color: color-mix(in srgb, var(--brand-ink) 65%, var(--brand-mist)); margin-top: 2px; }
.mhome-age-chip[aria-pressed="true"] { background: var(--brand-ink); color: #fff; transform: scale(1.02); }
.mhome-age-chip[aria-pressed="true"] small { color: rgba(255, 255, 255, 0.72); }
.mhome-slider-track { display: flex; align-items: center; gap: 10px; }
.mhome-slider-track input[type="range"] { flex: 1; accent-color: var(--brand-red); height: 32px; }
.mhome-tick { font-size: 0.72rem; color: color-mix(in srgb, var(--brand-ink) 65%, var(--brand-mist)); font-variant-numeric: tabular-nums; min-width: 36px; text-align: center; }
.mhome-note { text-align: center; font-size: 0.78rem; color: color-mix(in srgb, var(--brand-ink) 70%, var(--brand-mist)); margin: 4px 0 0; }
.mhome-dock { position: fixed; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 1030; background: var(--brand-ink); border-radius: 22px; padding: 10px; display: flex; align-items: center; gap: 10px; box-shadow: 0 8px 24px rgba(39, 48, 67, 0.28), 0 2px 6px rgba(39, 48, 67, 0.18); }
.mhome-dock-icon { appearance: none; border: 0; background: rgba(255, 255, 255, 0.12); color: #fff; width: 42px; height: 42px; border-radius: 14px; display: inline-flex; align-items: center; justify-content: center; transition: background 150ms, transform 150ms; cursor: pointer; }
.mhome-dock-icon:active { background: rgba(255, 255, 255, 0.24); transform: scale(0.95); }
.mhome-dock-icon:disabled { opacity: 0.4; }
.mhome-dock-icon.mhome-dock-btn { flex: 1; width: auto; gap: 6px; padding: 0 8px; font-weight: 700; font-size: 0.9rem; }
.mhome-dock-print { flex: 1.2; justify-content: center; appearance: none; border: 0; background: var(--brand-cta); color: #fff; font-weight: 700; font-size: 0.95rem; padding: 12px 16px; border-radius: 14px; display: inline-flex; align-items: center; gap: 6px; transition: background 150ms, transform 150ms; min-height: 44px; }
.mhome-dock-print:active { background: var(--brand-cta-press); transform: scale(0.97); }
.mhome-dock-print:disabled { background: color-mix(in srgb, var(--brand-cta) 55%, var(--brand-ink)); opacity: 0.7; }
.mhome-dock-print .mhome-print-label { letter-spacing: 0.04em; }
/* Sign-up prompt for signed-out visitors (Save, and the second worksheet): a bottom sheet on phones, a centred card on larger screens. */
.signup-prompt { position: fixed; inset: 0; z-index: 1045; display: flex; align-items: flex-end; }
.signup-prompt[hidden] { display: none; }
.signup-prompt-backdrop { position: absolute; inset: 0; background: rgba(39, 48, 67, 0.6); }
.signup-prompt-card { position: relative; width: 100%; background: #fff; border-radius: 22px 22px 0 0; padding: 22px 20px calc(18px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; box-shadow: 0 -8px 24px rgba(39, 48, 67, 0.25); }
.signup-prompt-title { font-size: 1.25rem; font-weight: 700; margin: 0; color: var(--brand-ink); }
.signup-prompt-text { margin: 0 0 4px; font-size: 0.95rem; line-height: 1.4; color: color-mix(in srgb, var(--brand-ink) 80%, #fff); }
.signup-prompt-plans { text-align: center; font-weight: 600; color: var(--brand-link); padding: 6px 0; }
.signup-prompt-close { appearance: none; border: 0; background: transparent; color: color-mix(in srgb, var(--brand-ink) 72%, #fff); font-weight: 600; padding: 8px; }
@media (min-width: 768px) { .signup-prompt { align-items: center; justify-content: center; } .signup-prompt-card { width: min(26rem, calc(100% - 2rem)); border-radius: 22px; padding-bottom: 22px; } }
.mhome-install { display: flex; align-items: center; gap: 10px; background: color-mix(in srgb, var(--brand-ink) 92%, var(--brand-red)); color: #fff; padding: 12px 14px; border-radius: 16px; }
.mhome-install-body { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.mhome-install-body strong { font-size: 0.9rem; font-weight: 700; }
.mhome-install-body span { font-size: 0.76rem; opacity: 0.78; }
.mhome-install-btn { appearance: none; border: 0; background: var(--brand-cta); color: #fff; font-weight: 700; font-size: 0.82rem; padding: 10px 14px; border-radius: 12px; cursor: pointer; }
.mhome-install-btn:active { background: var(--brand-cta-press); }
.mhome-install-dismiss { appearance: none; border: 0; background: transparent; color: rgba(255, 255, 255, 0.6); font-size: 1.4rem; line-height: 1; cursor: pointer; padding: 4px 8px; }
.mhome-install-dismiss:active { color: #fff; }
.mhome-toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); background: var(--brand-ink); color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 0.85rem; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity 200ms, transform 220ms; z-index: 1040; }
.mhome-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* On phones (< 768px) the header's hero + generator form are hidden; let the mobile shell reach the viewport edges. */
@media (max-width: 767.98px) {
  .mhome ~ section.band { padding-top: 2rem; }
}

/* My worksheets (/app) on phones: the shared phone creator (`.mhome.mapp`) plus the saved list as cards. */
.app-account { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .6rem; }
.app-plan { font-size: .8rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; background: var(--brand-ink); color: #fff; border-radius: 999px; padding: .2rem .65rem; }
.mhome-stage { display: flex; flex-direction: column; gap: 12px; }
.mapp { padding-top: 4px; }
.mapp-saved { display: flex; flex-direction: column; gap: 12px; padding: 0; }
.mapp-saved-item { gap: 12px; }
.mapp-saved-name { flex: 1; min-width: 0; font-size: 1.2rem; font-weight: 700; letter-spacing: -0.01em; color: var(--brand-ink); }
.mapp-saved-age { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: color-mix(in srgb, var(--brand-ink) 72%, var(--brand-mist)); white-space: nowrap; }
.mapp-saved-actions { display: flex; gap: 8px; }
.mapp-saved-actions form { margin: 0; }
.mapp-print { flex: 1 1 auto; appearance: none; border: 0; background: var(--brand-cta); color: #fff; font-weight: 700; font-size: 1rem; letter-spacing: 0.04em; text-transform: uppercase; min-height: 48px; padding: 0 16px; border-radius: 14px; transition: background 150ms, transform 150ms; }
.mapp-print:active { background: var(--brand-cta-press); transform: scale(0.97); }
.mapp-print:disabled { opacity: 0.6; }
.mapp-delete { appearance: none; background: transparent; color: var(--brand-ink); border: 1.5px solid var(--bs-border-color); font-weight: 600; font-size: 0.9rem; min-height: 48px; padding: 0 16px; border-radius: 14px; }

/* ---- Classroom mode + /app multi-select (desktop) ---- */
.classroom-status { list-style: none; padding-left: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.classroom-status-row { display: flex; align-items: baseline; gap: 10px; padding: 6px 10px; border-radius: 8px; background: rgba(0,0,0,0.025); font-size: 0.95rem; }
.classroom-status-row.is-ok { color: var(--brand-ink); }
.classroom-status-row.is-skip { color: var(--brand-link); background: rgba(194, 3, 34, 0.06); }
.classroom-status-mark { font-weight: 700; width: 1.2em; }
.classroom-status-name { font-weight: 600; }
.classroom-status-why { font-size: 0.85rem; opacity: 0.9; }

.saved-actionbar { position: sticky; top: 0; z-index: 15; display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  background: var(--brand-ink); color: #fff; padding: 10px 14px; border-radius: 12px; margin-bottom: 10px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.08); }
.saved-actionbar .btn-link { color: #fff; text-decoration: underline; }
.saved-actionbar-count { font-size: 0.95rem; }
.saved-select { display: flex; align-items: center; gap: 10px; margin: 0; cursor: pointer; flex: 1; min-width: 0; }
.saved-check { margin: 0; }
