/* MathSheetLab styles: "Premium Hybrid" design system.
 * Two universes share one set of components: dark immersive sections (.dark: hero, page heads, footer)
 * and light functional ones (generators, lists, text). The printable sheet and the print
 * stylesheet at the end follow the worksheet layout engine (src/layout.js). */

@font-face {
  font-family: "Inter";
  src: url("/assets/inter.3100e775e8.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
/* Metric-matched fallback so the swap to Inter does not shift the layout. */
@font-face {
  font-family: "Inter Fallback";
  src: local("Arial"), local("Helvetica Neue"), local("Helvetica");
  ascent-override: 90.44%;
  descent-override: 22.52%;
  line-gap-override: 0%;
  size-adjust: 107.12%;
}

:root {
  /* Colors */
  --bg-dark: #0B1020;
  --surface-dark: #111827;
  --elev-dark: #1E293B;
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --primary: #4F46E5;
  --primary-hover: #4338CA;
  --primary-soft: #EEF2FF;
  --primary-line: #C7D2FE;
  --primary-on-dark: #A5B4FC;
  --blue: #3B82F6;
  --violet: #8B5CF6;
  --text: #0F172A;
  --muted: #64748B;
  --muted-strong: #475569;
  --text-on-dark: #F8FAFC;
  --muted-on-dark: #94A3B8;
  --border: #E2E8F0;
  --border-strong: #CBD5E1;
  --border-dark: rgba(148, 163, 184, .16);
  --success: #059669;
  --error: #DC2626;
  --focus: #6366F1;

  /* Gradients (used sparingly) */
  --grad-primary: linear-gradient(135deg, #4F46E5, #8B5CF6);
  --grad-hero: linear-gradient(135deg, #0B1020, #111B35, #1A1740);
  --glow: radial-gradient(circle, rgba(79, 70, 229, .16), transparent 65%);

  /* Type */
  --font: "Inter", "Inter Fallback", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --sheet-font: "Inter", "Inter Fallback", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --fs-hero: clamp(2.5rem, 1.35rem + 4.2vw, 4.5rem);
  --fs-h1: clamp(2rem, 1.5rem + 1.9vw, 3rem);
  --fs-h2: clamp(1.625rem, 1.3rem + 1.2vw, 2.25rem);
  --fs-h3: clamp(1.25rem, 1.15rem + .4vw, 1.5rem);
  --fs-body: clamp(1rem, .97rem + .14vw, 1.0625rem);
  --fs-small: .875rem;

  /* Space: 4 8 12 16 24 32 48 64 96 */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px; --s9: 96px;

  /* Shape */
  --r-btn: 12px;
  --r-card: 18px;
  --r-panel: 24px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px -8px rgba(15, 23, 42, .10);
  --shadow-lg: 0 2px 4px rgba(15, 23, 42, .04), 0 24px 48px -16px rgba(15, 23, 42, .18);
  --ring: 0 0 0 4px rgba(79, 70, 229, .18);

  /* Layout & motion */
  --max: 1240px;
  --head-h: 64px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --t-micro: 160ms;
  --t-comp: 240ms;
  --t-section: 450ms;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--head-h) + 16px); }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body {
  margin: 0; font: 400 var(--fs-body)/1.6 var(--font); color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
img, svg { max-width: 100%; height: auto; }
a { color: var(--primary); text-underline-offset: 3px; text-decoration-thickness: 1px; transition: color var(--t-micro) ease; }
a:hover { color: var(--primary-hover); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 6px; }
h1, h2, h3 { line-height: 1.15; margin: 0 0 .5em; letter-spacing: -.022em; font-weight: 700; color: inherit; }
h1 { font-size: var(--fs-h1); letter-spacing: -.03em; }
h2 { font-size: var(--fs-h2); margin-top: 1.6em; }
h3 { font-size: var(--fs-h3); }
p { margin: 0 0 1em; }
.wrap { max-width: var(--max); margin: 0 auto; padding: 0 var(--s5); }
@media (max-width: 640px) { .wrap { padding: 0 var(--s4); } }
.skip { position: absolute; left: -9999px; top: 0; background: var(--surface); color: var(--text); padding: 8px 12px; z-index: 100; border-radius: 8px; }
.skip:focus { left: 8px; top: 8px; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Dark universe ---------- */
.dark { background: var(--bg-dark); color: var(--text-on-dark); color-scheme: dark; position: relative; isolation: isolate; }
.dark a:not(.btn) { color: var(--primary-on-dark); }
.dark a:not(.btn):hover { color: #fff; }
.dark :focus-visible { outline-color: var(--primary-on-dark); }
.dark .muted, .dark .lead { color: var(--muted-on-dark); }
.dark a.logo, .dark a.logo:hover { color: #fff; }
.glow { position: absolute; z-index: -1; pointer-events: none; width: 900px; height: 900px; background: var(--glow); border-radius: 50%; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 44px; padding: 10px 18px; border-radius: var(--r-btn); border: 1px solid transparent;
  font: 600 .9375rem/1.2 var(--font); letter-spacing: -.005em; text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background-color var(--t-micro) ease, border-color var(--t-micro) ease, color var(--t-micro) ease,
    box-shadow var(--t-comp) var(--ease), transform var(--t-micro) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.btn svg { width: 18px; height: 18px; flex: none; }
.btn:active { transform: translateY(1px) scale(.99); }
.btn-primary {
  color: #fff; background: var(--primary); background-image: var(--grad-primary);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .18) inset, 0 6px 16px -6px rgba(79, 70, 229, .6);
}
.btn-primary:hover { color: #fff; background-color: var(--primary-hover); background-image: linear-gradient(135deg, #4338CA, #7C3AED); box-shadow: 0 1px 0 rgba(255, 255, 255, .18) inset, 0 10px 24px -8px rgba(79, 70, 229, .7); }
.btn-secondary { color: var(--text); background: var(--surface); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { color: var(--primary-hover); border-color: var(--primary-line); background: var(--primary-soft); }
.btn-ghost { color: var(--text-on-dark); background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .14); }
.btn-ghost:hover { color: #fff; background: rgba(255, 255, 255, .11); border-color: rgba(255, 255, 255, .24); }
.btn-lg { min-height: 52px; padding: 14px 24px; font-size: 1rem; border-radius: var(--r-btn); }
.btn-sm { min-height: 38px; padding: 8px 14px; font-size: .875rem; }
svg.arrow { width: 16px; height: 16px; flex: none; }
.btn .arrow { transition: transform var(--t-micro) var(--ease); }
.btn:hover .arrow { transform: translateX(3px); }

/* ---------- Header ---------- */
.site-head {
  position: fixed; inset: 0 0 auto; z-index: 50; height: var(--head-h); color: var(--text-on-dark);
  background: rgba(11, 16, 32, .55); border-bottom: 1px solid transparent;
  -webkit-backdrop-filter: saturate(160%) blur(14px); backdrop-filter: saturate(160%) blur(14px);
  transition: background-color var(--t-comp) ease, border-color var(--t-comp) ease, box-shadow var(--t-comp) ease;
}
.site-head.is-scrolled { background: rgba(11, 16, 32, .86); border-bottom-color: var(--border-dark); box-shadow: 0 8px 24px -12px rgba(0, 0, 0, .5); }
.head-row { display: flex; align-items: center; gap: var(--s5); height: 100%; }
.site-head .wrap { max-width: 1440px; }
.logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.0625rem; letter-spacing: -.02em; color: #fff; text-decoration: none; flex: none; }
.logo:hover { color: #fff; }
.logo svg { width: 30px; height: 30px; filter: drop-shadow(0 4px 10px rgba(99, 102, 241, .45)); }
.logo b { font-weight: 700; color: var(--primary-on-dark); }
.nav { margin-left: auto; }
.nav ul { display: flex; gap: 2px; margin: 0; padding: 0; list-style: none; }
.nav a {
  display: block; position: relative; padding: 8px 7px; border-radius: 10px; font-size: .8125rem; font-weight: 500;
  color: var(--muted-on-dark); text-decoration: none; white-space: nowrap; transition: color var(--t-micro) ease, background-color var(--t-micro) ease;
}
.nav a:hover { color: #fff; background: rgba(255, 255, 255, .06); }
.nav a[aria-current="page"] { color: #fff; }
.nav a[aria-current="page"]::after { content: ""; position: absolute; left: 7px; right: 7px; bottom: 2px; height: 2px; border-radius: 2px; background: var(--grad-primary); }
.head-cta { flex: none; }
/* Championship link: gold accent, first item of the menu. */
.nav .nav-champ a { display: flex; align-items: center; gap: 6px; color: #FCD679; }
.nav .nav-champ a:hover { color: #FDE6A8; background: rgba(245, 184, 61, .10); }
.nav .nav-champ svg { width: 16px; height: 16px; flex: none; }
.nav .nav-champ a[aria-current="page"]::after { background: linear-gradient(90deg, #F5B83D, #FCD679); }
.nav-toggle {
  display: none; align-items: center; justify-content: center; width: 44px; height: 44px; margin-left: auto; padding: 0;
  border: 1px solid rgba(255, 255, 255, .14); border-radius: var(--r-btn); background: rgba(255, 255, 255, .06); color: #fff; cursor: pointer;
}
.nav-toggle svg { width: 22px; height: 22px; }
.nav-toggle .i-close { display: none; }
.nav-open .nav-toggle .i-open { display: none; }
.nav-open .nav-toggle .i-close { display: block; }

/* The full menu (championship + 9 topics + button) needs about 1,390 px: below that, the menu button is used. */
@media (max-width: 1399px) {
  .head-row { gap: var(--s3); }
  .nav-toggle { display: inline-flex; }
  .head-cta { order: 2; }
  .nav-toggle { order: 3; margin-left: 0; }
  .logo { margin-right: auto; }
  /* Without JavaScript the menu stays visible as a scrollable row under the bar. */
  html:not(.js) .site-head { height: auto; }
  html:not(.js) .head-row { flex-wrap: wrap; padding-top: 10px; padding-bottom: 6px; }
  html:not(.js) .nav-toggle { display: none; }
  html:not(.js) .nav { order: 4; flex-basis: 100%; overflow-x: auto; }
  .js .nav {
    position: absolute; top: var(--head-h); left: 0; right: 0; margin: 0; padding: var(--s3) var(--s4) var(--s5);
    background: rgba(11, 16, 32, .97); border-bottom: 1px solid var(--border-dark); box-shadow: 0 24px 48px -16px rgba(0, 0, 0, .6);
    visibility: hidden; opacity: 0; transform: translateY(-8px);
    transition: opacity var(--t-comp) var(--ease), transform var(--t-comp) var(--ease), visibility 0s linear var(--t-comp);
  }
  .js .nav-open .nav { visibility: visible; opacity: 1; transform: none; transition-delay: 0s; }
  .js .nav ul { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; max-width: var(--max); margin: 0 auto; }
  .js .nav a { padding: 12px 14px; font-size: 1rem; color: var(--text-on-dark); background: rgba(255, 255, 255, .03); }
  .js .nav a[aria-current="page"] { background: rgba(99, 102, 241, .18); }
  .js .nav a[aria-current="page"]::after { display: none; }
  .js .nav .nav-champ { grid-column: 1 / -1; }
  .js .nav .nav-champ a { color: #FCD679; background: rgba(245, 184, 61, .10); border: 1px solid rgba(245, 184, 61, .22); }
}
@media (max-width: 420px) { .head-cta { display: none; } }

/* ---------- Page heads (dark band on inner pages) ---------- */
.page-head { background: var(--grad-hero); overflow: hidden; padding: calc(var(--head-h) + var(--s7)) 0 var(--s7); }
.page-head .glow { top: -520px; right: -260px; }
.page-head h1 { margin: 0 0 var(--s3); max-width: 22em; }
.page-head .lead { font-size: 1.0625rem; max-width: 46em; margin: 0; color: var(--muted-on-dark); }
.page-head.has-panel { padding-bottom: calc(var(--s7) + var(--s6)); }
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); margin: 0 0 var(--s4); padding: 0; list-style: none; }
.chips li { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px; font-size: .8125rem; font-weight: 500; color: #E0E7FF; background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .12); }
.chips li:first-child { color: #fff; background: rgba(99, 102, 241, .22); border-color: rgba(129, 140, 248, .4); }
.chips svg { width: 14px; height: 14px; }

.crumbs { font-size: .8125rem; margin-bottom: var(--s4); }
.crumbs ol { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.crumbs li { color: var(--muted-on-dark); }
.crumbs li + li::before { content: "/"; margin-right: 6px; opacity: .45; }
.crumbs a { text-decoration: none; }
.crumbs li[aria-current] { color: #CBD5E1; }

/* ---------- Home: hero ---------- */
.hero { background: var(--grad-hero); overflow: hidden; padding: calc(var(--head-h) + var(--s8)) 0 var(--s9); }
.hero .glow { width: 1100px; height: 1100px; top: -460px; right: -300px; }
.hero .glow-2 { width: 700px; height: 700px; left: -320px; bottom: -420px; background: radial-gradient(circle, rgba(139, 92, 246, .12), transparent 65%); }
.hero::after { /* fine grid for depth, fading out */
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background-image: linear-gradient(rgba(148, 163, 184, .06) 1px, transparent 1px), linear-gradient(90deg, rgba(148, 163, 184, .06) 1px, transparent 1px);
  background-size: 48px 48px; -webkit-mask-image: radial-gradient(ellipse 70% 60% at 70% 30%, #000, transparent 75%); mask-image: radial-gradient(ellipse 70% 60% at 70% 30%, #000, transparent 75%);
}
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); gap: var(--s7); align-items: center; }
.eyebrow { display: inline-flex; align-items: center; gap: 10px; margin: 0 0 var(--s5); padding: 6px 14px 6px 8px; border-radius: 999px; font-size: .8125rem; font-weight: 500; color: #E0E7FF; background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .12); }
.eyebrow .pill { padding: 2px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; color: #fff; background: var(--grad-primary); }
.hero h1 { font-size: var(--fs-hero); line-height: 1.02; letter-spacing: -.04em; font-weight: 800; margin: 0 0 var(--s5); }
.grad-text { background: linear-gradient(100deg, #A5B4FC 0%, #C4B5FD 45%, #93C5FD 100%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero .lead { font-size: clamp(1.0625rem, 1rem + .35vw, 1.25rem); line-height: 1.55; max-width: 34em; margin: 0 0 var(--s6); }
.hero-actions { display: flex; flex-wrap: wrap; gap: var(--s3); margin-bottom: var(--s6); }
.hero-facts { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); margin: 0; padding: 0; list-style: none; font-size: .875rem; color: var(--muted-on-dark); }
.hero-facts li { display: inline-flex; align-items: center; gap: 8px; }
.hero-facts svg { width: 16px; height: 16px; color: #818CF8; }

/* Real worksheets, fanned out in depth */
.hero-visual { --k: .64; position: relative; height: 540px; perspective: 2000px; }
.stack { position: absolute; inset: 0; transform-style: preserve-3d; transform: rotateY(-16deg) rotateX(8deg) rotateZ(1deg); }
.stack-card {
  position: absolute; width: calc(640px * var(--k)); height: calc(560px * var(--k)); overflow: hidden;
  border-radius: 14px; background: #fff; box-shadow: 0 40px 80px -24px rgba(0, 0, 0, .65), 0 0 0 1px rgba(255, 255, 255, .08);
}
.stack-card::after { content: ""; position: absolute; inset: auto 0 0; height: 28%; background: linear-gradient(transparent, #fff); }
.stack-card .sheet { width: 640px; max-width: none; margin: 0; border: 0; border-radius: 0; box-shadow: none; transform: scale(var(--k)); transform-origin: 0 0; }
.stack-card.c1 { left: 2%; top: 150px; transform: translateZ(60px) rotate(-4deg); }
.stack-card.c2 { left: 17%; top: 80px; transform: translateZ(0) rotate(1.5deg); }
.stack-card.c3 { left: 32%; top: 10px; transform: translateZ(-60px) rotate(6deg); filter: brightness(.96); }
.stack-tag {
  position: absolute; z-index: 2; display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 12px;
  font-size: .8125rem; font-weight: 600; color: var(--text); background: rgba(255, 255, 255, .96); box-shadow: 0 12px 32px -8px rgba(0, 0, 0, .45);
}
.stack-tag .ok { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 6px; color: #fff; background: var(--success); }
.stack-tag .ok svg { width: 13px; height: 13px; }
.stack-tag.t1 { right: 6%; bottom: 40px; transform: translateZ(120px); }
.stack-tag.t2 { left: 0; top: 104px; transform: translateZ(120px); }

@media (max-width: 960px) {
  .hero { padding-top: calc(var(--head-h) + var(--s7)); padding-bottom: var(--s7); }
  .hero-grid { grid-template-columns: 1fr; gap: var(--s6); }
  .hero-visual { --k: .56; height: 470px; max-width: 600px; width: 100%; margin: 0 auto; }
}
@media (max-width: 560px) {
  .hero-visual { --k: .46; height: 330px; }
  .stack { transform: rotateY(-10deg) rotateX(6deg); }
  .stack-card.c1 { left: 0; top: 70px; }
  .stack-card.c2 { left: 14%; top: 34px; }
  .stack-card.c3 { display: none; }
  .stack-tag.t2 { top: 30px; }
  .stack-tag.t1 { right: 0; bottom: 20px; }
  .stack-tag { font-size: .75rem; padding: 6px 10px; }
  .stack-tag.t2 { left: 0; }
  .hero-actions .btn { flex: 1 1 100%; }
}

/* ---------- Sections ---------- */
.section { padding: var(--s9) 0; }
.section-head { max-width: 44em; margin-bottom: var(--s7); }
.section-head h2 { margin-top: 0; }
.section-head p:not(.kicker) { color: var(--muted); font-size: 1.0625rem; margin: 0; }
.dark .section-head p:not(.kicker) { color: var(--muted-on-dark); }
.kicker { margin: 0 0 var(--s3); font-size: .8125rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--primary); }
.dark .kicker { color: var(--primary-on-dark); }
@media (max-width: 640px) { .section { padding: var(--s8) 0; } .section-head { margin-bottom: var(--s6); } }

/* Category cards */
.cat-grid { display: grid; gap: var(--s4); grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0; padding: 0; list-style: none; }
@media (max-width: 1024px) { .cat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.cat-card {
  position: relative; display: flex; flex-direction: column; padding: var(--s5); border-radius: var(--r-card);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  transition: transform var(--t-comp) var(--ease), box-shadow var(--t-comp) var(--ease), border-color var(--t-comp) ease;
}
.cat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--primary-line); }
.cat-card:focus-within { border-color: var(--primary); box-shadow: var(--ring); }
.cat-icon {
  display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: var(--s5); border-radius: 14px;
  color: var(--primary); background: linear-gradient(135deg, #EEF2FF, #F5F3FF); border: 1px solid #E0E7FF;
  transition: color var(--t-comp) ease, background var(--t-comp) ease, transform var(--t-comp) var(--ease);
}
.cat-icon svg { width: 24px; height: 24px; }
.cat-card:hover .cat-icon { color: #fff; background: var(--grad-primary); border-color: transparent; transform: scale(1.04); }
.cat-card h3 { font-size: 1.125rem; letter-spacing: -.015em; margin: 0 0 var(--s2); }
.cat-card h3 a { color: var(--text); text-decoration: none; }
.cat-card h3 a:focus-visible { outline: none; }
.cat-card p { margin: 0 0 var(--s5); font-size: .9375rem; color: var(--muted); line-height: 1.55; }
.cat-count { margin-top: auto; display: inline-flex; align-items: center; gap: 6px; font-size: .875rem; font-weight: 600; color: var(--primary); }
.cat-count .arrow { transition: transform var(--t-micro) var(--ease); }
.cat-card:hover .cat-count .arrow { transform: translateX(4px); }
@media (max-width: 560px) {
  .cat-grid { grid-template-columns: 1fr; gap: var(--s3); }
  .cat-card { display: grid; grid-template-columns: 44px minmax(0, 1fr); column-gap: var(--s4); padding: var(--s4); }
  .cat-card > * { grid-column: 2; }
  .cat-card .cat-icon { grid-column: 1; grid-row: 1 / span 3; width: 44px; height: 44px; margin: 0; }
  .cat-card h3 { margin-bottom: 4px; }
  .cat-card p { margin-bottom: var(--s2); font-size: .875rem; }
}.stretch::before { content: ""; position: absolute; inset: 0; border-radius: inherit; z-index: 1; }

/* Demonstration (dark) */
.demo { background: var(--bg-dark); overflow: hidden; }
.demo .glow { left: -300px; top: -200px; }
.demo-grid { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: var(--s8); align-items: center; }
@media (max-width: 960px) { .demo-grid { grid-template-columns: 1fr; gap: var(--s7); } }
.steps { list-style: none; margin: 0 0 var(--s6); padding: 0; counter-reset: step; display: grid; gap: var(--s3); }
.steps li {
  counter-increment: step; position: relative; padding: var(--s5) var(--s5) var(--s5) 72px; border-radius: var(--r-card);
  background: rgba(255, 255, 255, .03); border: 1px solid var(--border-dark);
}
.steps li::before {
  content: counter(step); position: absolute; left: var(--s5); top: var(--s5); display: grid; place-items: center;
  width: 32px; height: 32px; border-radius: 10px; font-weight: 700; font-size: .9375rem; color: #fff; background: var(--grad-primary);
}
.steps h3 { font-size: 1.0625rem; margin: 0 0 4px; letter-spacing: -.01em; }
.steps p { margin: 0; font-size: .9375rem; color: var(--muted-on-dark); }
.demo-visual { position: relative; display: grid; grid-template-columns: repeat(2, max-content); justify-content: center; gap: var(--s5); }
.demo-paper { --k: .48; position: relative; margin: 0; min-width: 0; }
.demo-paper .frame { width: calc(600px * var(--k)); height: calc(620px * var(--k)); overflow: hidden; border-radius: 12px; background: #fff; box-shadow: 0 32px 64px -24px rgba(0, 0, 0, .7), 0 0 0 1px rgba(255, 255, 255, .08); }
.demo-paper .sheet { width: 600px; max-width: none; margin: 0; border: 0; border-radius: 0; box-shadow: none; transform: scale(var(--k)); transform-origin: 0 0; }
.demo-paper:nth-child(2) { margin-top: var(--s7); }
.demo-paper figcaption { margin-top: var(--s3); font-size: .8125rem; color: var(--muted-on-dark); display: flex; align-items: center; gap: 8px; }
.demo-paper figcaption b { color: var(--text-on-dark); font-weight: 600; }
@media (max-width: 560px) { .demo-visual { gap: var(--s3); } .demo-paper { --k: .27; } .demo-paper:nth-child(2) { margin-top: var(--s6); } }

/* Benefits */
.benefits { display: grid; gap: var(--s4); grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0; padding: 0; list-style: none; }
@media (max-width: 1024px) { .benefits { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .benefits { grid-template-columns: 1fr; } }
.benefit { padding: var(--s5); border-radius: var(--r-card); background: var(--surface); border: 1px solid var(--border); }
.benefit .b-icon { display: grid; place-items: center; width: 40px; height: 40px; margin-bottom: var(--s4); border-radius: 12px; color: var(--primary); background: var(--primary-soft); }
.benefit .b-icon svg { width: 20px; height: 20px; }
.benefit h3 { font-size: 1.0625rem; margin: 0 0 6px; letter-spacing: -.01em; }
.benefit p { margin: 0; font-size: .9375rem; color: var(--muted); }

/* All worksheets: search + list */
.all { padding-top: 0; }
.all-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s5); margin-bottom: var(--s6); }
.all-head .section-head { margin-bottom: 0; }
.search { position: relative; flex: 0 1 420px; width: 100%; }
.search input {
  width: 100%; height: 52px; padding: 0 16px 0 48px; font: inherit; font-size: 1rem; color: var(--text);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 16px 50% / 20px;
  border: 1px solid var(--border-strong); border-radius: 14px; box-shadow: var(--shadow-sm);
  transition: border-color var(--t-micro) ease, box-shadow var(--t-micro) ease;
}
.search input::placeholder { color: #94A3B8; }
.search input:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.search-meta { position: absolute; left: 4px; top: 100%; margin: 6px 0 0; min-height: 1.4em; color: var(--muted); font-size: .8125rem; }
#ws-search-empty { padding: var(--s5); border-radius: var(--r-card); background: var(--surface); border: 1px dashed var(--border-strong); color: var(--muted); }
.group { margin-top: var(--s7); }
.group:first-child { margin-top: 0; }
.cat-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; margin-bottom: var(--s4); padding-bottom: var(--s3); border-bottom: 1px solid var(--border); }
.cat-head h2 { margin: 0; font-size: 1.25rem; letter-spacing: -.015em; display: inline-flex; align-items: center; gap: 10px; }
.cat-head h2 svg { width: 20px; height: 20px; color: var(--primary); }
.cat-head a { font-size: .875rem; font-weight: 500; text-decoration: none; }
.cat-head a:hover { text-decoration: underline; }

/* Worksheet cards (home, category pages) */
.cards { display: grid; gap: var(--s3); grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); padding: 0; margin: 0; list-style: none; }
.card {
  position: relative; display: flex; flex-direction: column; gap: 6px; padding: var(--s4) var(--s5); border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  transition: transform var(--t-comp) var(--ease), box-shadow var(--t-comp) var(--ease), border-color var(--t-micro) ease;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--primary-line); }
.card:focus-within { border-color: var(--primary); box-shadow: var(--ring); }
.card a { font-weight: 600; color: var(--text); text-decoration: none; letter-spacing: -.01em; line-height: 1.35; }
.card a:focus-visible { outline: none; }
.card:hover a { color: var(--primary-hover); }
.card p { margin: 0; color: var(--muted); font-size: .875rem; line-height: 1.5; }
.grade { align-self: flex-start; margin-top: auto; padding: 2px 10px; border-radius: 999px; font-size: .75rem; font-weight: 600; color: #4338CA; background: var(--primary-soft); }
.card p + .grade { margin-top: 6px; }

/* ---------- Worksheet page ---------- */
.workspace { position: relative; margin-top: calc(-1 * var(--s6)); }
.ws-layout { display: grid; gap: var(--s5); grid-template-columns: 330px minmax(0, 1fr); align-items: start; }
@media (max-width: 960px) { .ws-layout { grid-template-columns: 1fr; } }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-panel); padding: var(--s5); box-shadow: var(--shadow-lg); }
.ws-controls { position: sticky; top: calc(var(--head-h) + var(--s4)); }
@media (max-width: 960px) { .ws-controls { position: static; } }
.ws-controls fieldset { border: 0; margin: 0 0 var(--s4); padding: 0 0 var(--s4); border-bottom: 1px solid var(--border); min-width: 0; }
.ws-controls legend { padding: 0; margin-bottom: var(--s3); font-size: .75rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.panel-title { display: flex; align-items: center; gap: 10px; margin: 0 0 var(--s4); font-size: 1rem; letter-spacing: -.01em; }
.panel-title svg { width: 20px; height: 20px; color: var(--primary); }
.field { margin-bottom: var(--s3); }
.field:last-child { margin-bottom: 0; }
.field label, .field .label { display: block; font-weight: 500; font-size: .875rem; margin-bottom: 6px; color: var(--muted-strong); }
.field select, .field input[type="text"] {
  width: 100%; height: 44px; padding: 0 14px; font: inherit; font-size: .9375rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-btn);
  transition: border-color var(--t-micro) ease, box-shadow var(--t-micro) ease;
}
.field select {
  -webkit-appearance: none; appearance: none; padding-right: 40px; cursor: pointer;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center / 18px;
}
.field input::placeholder { color: #94A3B8; }
.field select:hover, .field input[type="text"]:hover { border-color: #94A3B8; }
.field select:focus, .field input[type="text"]:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.check { display: flex; align-items: center; gap: 10px; min-height: 34px; font-size: .9375rem; cursor: pointer; }
.check + .check { margin-top: 2px; }
.check input { width: 20px; height: 20px; margin: 0; accent-color: var(--primary); cursor: pointer; flex: none; }
.ws-actions { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }
.ws-actions #ws-print { grid-column: 1 / -1; min-height: 50px; font-size: 1rem; }
.ws-actions .btn { width: 100%; padding-left: 10px; padding-right: 10px; }
.ws-actions #ws-pin { grid-column: 1 / -1; }
.seed { display: flex; gap: 8px; align-items: baseline; font-size: .8125rem; color: var(--muted); margin: var(--s4) 0 0; line-height: 1.5; }
.seed #ws-seed { font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.status { grid-column: 1 / -1; min-height: 1.4em; margin: 2px 0 0; font-size: .875rem; font-weight: 500; color: var(--success); }
.status:not(:empty)::before { content: "✓ "; }

.preview { min-width: 0; }
.preview-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); height: 44px; padding: 0 var(--s4); margin-bottom: var(--s3); border-radius: 14px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); font-size: .8125rem; color: var(--muted); }
.preview-bar .live { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; color: var(--text); }
.preview-bar .live i { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px rgba(5, 150, 105, .15); }
.desk {
  padding: var(--s6); border-radius: var(--r-panel); border: 1px solid var(--border);
  background: #EEF2F7 radial-gradient(rgba(100, 116, 139, .16) 1px, transparent 1px) 0 0 / 18px 18px;
}
.desk .sheet { box-shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 18px 40px -16px rgba(15, 23, 42, .22); border-color: #E5E7EB; }
.desk .sheet:last-child { margin-bottom: 0; }
.desk.is-updating .sheet { animation: sheet-in var(--t-comp) var(--ease); }
@keyframes sheet-in { from { opacity: .35; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (max-width: 640px) {
  .page-head { padding: calc(var(--head-h) + var(--s5)) 0 var(--s6); }
  .page-head.has-panel { padding-bottom: calc(var(--s6) + var(--s5)); }
  .page-head .lead { font-size: .9375rem; }
  .chips li { font-size: .75rem; padding: 3px 10px; }
  .hero { padding-top: calc(var(--head-h) + var(--s6)); }
  .eyebrow { margin-bottom: var(--s4); }
}
@media (max-width: 640px) { .desk { padding: var(--s3); border-radius: var(--r-card); } .preview-bar .hint { display: none; } }

.hide-sm { }
/* Phones: the three actions stay within thumb reach in a bar fixed to the bottom of the screen. */
@media (max-width: 760px) {
  .has-actionbar { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
  .ws-actions {
    position: fixed; z-index: 40; left: 0; right: 0; bottom: 0; grid-template-columns: 1.5fr 1fr 1fr; gap: var(--s2);
    padding: 12px var(--s4) calc(12px + env(safe-area-inset-bottom)); background: rgba(255, 255, 255, .92);
    -webkit-backdrop-filter: saturate(160%) blur(14px); backdrop-filter: saturate(160%) blur(14px);
    border-top: 1px solid var(--border); box-shadow: 0 -8px 24px -12px rgba(15, 23, 42, .18);
  }
  .ws-actions #ws-print { grid-column: auto; min-height: 48px; font-size: .9375rem; }
  .ws-actions #ws-pin { display: none; }
  .ws-actions .btn { min-height: 48px; font-size: .875rem; gap: 6px; }
  .hide-sm { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .status {
    position: absolute; left: var(--s4); right: var(--s4); bottom: calc(100% + 8px); margin: 0; padding: 10px 14px; border-radius: 12px;
    color: #fff; background: var(--text); box-shadow: var(--shadow-lg); font-size: .875rem;
    opacity: 0; transform: translateY(6px); pointer-events: none; transition: opacity var(--t-comp) ease, transform var(--t-comp) var(--ease);
  }
  .status.is-visible { opacity: 1; transform: none; }
  .status:not(:empty)::before { color: #6EE7B7; }
}

/* Category, legal and 404 page heads */
.title-row { display: flex; align-items: center; gap: var(--s4); margin-bottom: var(--s3); }
.title-row h1 { margin: 0; }
.head-icon { display: grid; place-items: center; flex: none; width: 56px; height: 56px; border-radius: 16px; color: #fff; background: var(--grad-primary); box-shadow: 0 12px 28px -10px rgba(99, 102, 241, .7), 0 1px 0 rgba(255, 255, 255, .2) inset; }
.head-icon svg { width: 28px; height: 28px; }
@media (max-width: 640px) { .head-icon { width: 44px; height: 44px; border-radius: 12px; } .head-icon svg { width: 22px; height: 22px; } }
.page-head .lead + .head-actions { margin: var(--s5) 0 0; }
.other-topics { padding-bottom: 0; }
.paper { max-width: 820px; padding: var(--s7) var(--s8); border-radius: var(--r-panel); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
.paper > :first-child { margin-top: 0; }
.paper > :last-child { margin-bottom: 0; }
@media (max-width: 640px) { .paper { padding: var(--s5) var(--s4); border-radius: var(--r-card); } }
.page-head.has-panel ~ * .paper, .page-head + .page-body .paper { margin-top: calc(-1 * var(--s6) - var(--s7)); position: relative; }
.page-head:has(+ .page-body .paper) { padding-bottom: calc(var(--s7) + var(--s6)); }

/* Text content under the tool, legal pages */
.more { padding-top: var(--s8); }
.content { max-width: 46em; }
.content h2 { font-size: clamp(1.375rem, 1.2rem + .6vw, 1.75rem); margin-top: 1.8em; }
.content > h2:first-child, .content > h1 + h2 { margin-top: 0; }
.content p, .content li { color: #334155; }
.content ul, .content ol { padding-left: 1.3em; }
.content li { margin-bottom: 6px; }
.content li::marker { color: var(--primary); }

/* Worked example: one problem explained step by step (screen only; hidden in print with .content) */
.worked { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 16px 28px; align-items: start; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 22px 24px; margin-top: 12px; }
.worked-problem { grid-row: span 2; background: #fff; color: #111; border: 1px solid var(--border); border-radius: 10px; padding: 16px 20px; font-size: 1.35rem; font-variant-numeric: tabular-nums; min-width: 7rem; display: flex; justify-content: center; }
.worked-problem .pld { padding-bottom: 0; }
.content .worked-steps { margin: 0; padding-left: 1.4em; }
.content .worked-steps li { margin-bottom: 8px; font-variant-numeric: tabular-nums; }
.worked-answer { margin: 0; padding-top: 12px; border-top: 1px dashed var(--border-strong); }
.worked-answer strong { color: var(--primary); font-size: 1.1em; }
@media (max-width: 640px) {
  .worked { grid-template-columns: 1fr; padding: 18px 16px; }
  .worked-problem { grid-row: auto; justify-self: start; }
}
.related { margin-top: var(--s7); }
.related h2 { font-size: 1.25rem; margin: 0 0 var(--s4); }
.related ul { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: var(--s2); }
.related a {
  display: inline-flex; align-items: center; min-height: 40px; padding: 8px 14px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--text); text-decoration: none; font-size: .875rem; font-weight: 500;
  transition: border-color var(--t-micro) ease, color var(--t-micro) ease, background-color var(--t-micro) ease;
}
.related a:hover { border-color: var(--primary-line); color: var(--primary-hover); background: var(--primary-soft); }
.page-body { padding-top: var(--s7); }
.error { background: #FEF2F2; color: #991B1B; border: 1px solid #FECACA; padding: 14px 16px; border-radius: var(--r-btn); }
.notice { background: var(--primary-soft); color: #3730A3; border-radius: var(--r-btn); padding: 12px 14px; font-size: .9375rem; }

/* Ad slots: only rendered when ads are enabled in site.config.js. Space is reserved to avoid layout shifts. */
.ad { margin: var(--s7) auto; text-align: center; min-height: 120px; padding: var(--s3); border-radius: var(--r-card); background: var(--surface); border: 1px solid var(--border); }
.ad-label { display: block; font-size: .6875rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }

/* ---------- Footer ---------- */
.site-foot { margin-top: var(--s9); padding: var(--s8) 0 var(--s6); background: var(--bg-dark); color: var(--muted-on-dark); font-size: .875rem; overflow: hidden; }
.site-foot .glow { left: 50%; top: -700px; transform: translateX(-50%); }
.foot-grid { display: grid; gap: var(--s6); grid-template-columns: 1.4fr repeat(4, minmax(0, 1fr)); }
@media (max-width: 860px) { .foot-grid { grid-template-columns: 1fr 1fr; } .foot-brand { grid-column: 1 / -1; } }
.foot-brand p { margin: var(--s4) 0 0; max-width: 26em; }
.site-foot h2 { font-size: .75rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; margin: 0 0 var(--s4); color: var(--text-on-dark); }
.site-foot ul { list-style: none; margin: 0; padding: 0; }
.site-foot li { margin: 0 0 10px; }
.site-foot a:not(.logo) { color: var(--muted-on-dark); text-decoration: none; }
.site-foot a:not(.logo):hover { color: #fff; }
.foot-note { grid-column: 1 / -1; margin: 0; padding-top: var(--s5); border-top: 1px solid var(--border-dark); font-size: .8125rem; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--muted-on-dark); text-decoration: underline; cursor: pointer; }

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: no-preference) {
  .hero-copy > * { animation: rise var(--t-section) var(--ease) both; }
  .hero-copy > :nth-child(2) { animation-delay: 60ms; }
  .hero-copy > :nth-child(3) { animation-delay: 120ms; }
  .hero-copy > :nth-child(4) { animation-delay: 180ms; }
  .hero-copy > :nth-child(5) { animation-delay: 240ms; }
  .hero-visual { animation: fade 700ms var(--ease) 120ms both; }
  .stack-card { transition: transform 500ms var(--ease); }
  .hero-visual:hover .c1 { transform: translateZ(80px) rotate(-5deg) translateX(-8px); }
  .hero-visual:hover .c3 { transform: translateZ(-60px) rotate(7deg) translateX(8px); }
  /* Scroll reveal: ui.js only hides elements that start below the fold, so nothing depends on JS to be visible. */
  .reveal.pre { opacity: 0; transform: translateY(16px); }
  .reveal.in { opacity: 1; transform: none; transition: opacity var(--t-section) var(--ease), transform var(--t-section) var(--ease); transition-delay: calc(var(--d, 0) * 60ms); }
  .reveal.in.cat-card, .reveal.in.card { transition: opacity var(--t-section) var(--ease), transform var(--t-comp) var(--ease), box-shadow var(--t-comp) var(--ease), border-color var(--t-comp) ease; }
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 1ms !important; animation-duration: 1ms !important; }
}

/* ---------- The printable sheet ----------
 * One design for every worksheet. src/layout.js computes, for each page, the columns (--cols),
 * rows (--rows), problem font size (--fs) and title size (--tfs), and the page size (--pw, --ph).
 * Fixed heights below (brand 12pt, title line 1.25, instruction 15pt, fields 26pt, rule 14pt,
 * footer 24pt) are the values layout.js counts on: change them together.
 * Black and white friendly: thin rules only, no filled areas. */
.sheet-wrap { overflow-x: auto; }
.sheet {
  --cols: 4; --fs: 1.15rem; --tfs: 1.3rem;
  background: #fff; color: #111; border: 1px solid var(--border); border-radius: 6px; box-shadow: var(--shadow);
  padding: 28px 32px; margin: 0 auto 24px; max-width: 820px; font-family: var(--sheet-font);
  font-variant-numeric: tabular-nums; line-height: 1.3; letter-spacing: normal; -webkit-font-smoothing: auto;
}
.sh-head { border-bottom: 1.25pt solid #111; padding-bottom: 6pt; margin-bottom: 8pt; }
.sh-brand { display: flex; justify-content: space-between; height: 12pt; font-size: 7.5pt; line-height: 9pt; color: #555; text-transform: uppercase; letter-spacing: .08em; }
.sh-logo { font-weight: 700; color: #111; }
.sh-logo::before { content: ""; display: inline-block; width: 7pt; height: 7pt; margin-right: 4pt; border: 1.25pt solid #111; border-radius: 2pt; vertical-align: -1pt; box-sizing: border-box;
  background: linear-gradient(#111, #111) center / 4pt 1pt no-repeat, linear-gradient(#111, #111) center / 1pt 4pt no-repeat; }
.sh-title { font-size: var(--tfs); line-height: 1.25; font-weight: 700; letter-spacing: -.01em; }
.sh-key { display: inline-block; margin-left: 8pt; padding: 0 5pt; border: 1pt solid #111; border-radius: 3pt; font-size: 8pt; line-height: 13pt; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; vertical-align: 3pt; }
.sh-more { font-size: 9pt; font-weight: 400; color: #555; }
.sh-ins { margin: 0; font-style: italic; font-size: 10.5pt; line-height: 15pt; }
.sh-fields { display: flex; gap: 0 18pt; height: 26pt; align-items: flex-end; font-size: 10pt; line-height: 14pt; }
.sh-fields span { display: inline-flex; align-items: flex-end; gap: 5pt; white-space: nowrap; }
.sh-fields .f-name { flex: 1 1 auto; }
.sh-fields .f-name i { flex: 1 1 auto; }
.sh-fields i { display: inline-block; width: 110pt; border-bottom: .75pt solid #111; height: 12pt; }
.sh-fields i.short { width: 32pt; }
.sh-cont .sh-title { font-size: 12pt; }
.sh-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: 1.1em 1.4em; font-size: var(--fs); }
.pr { display: flex; gap: .35em; align-items: flex-start; min-width: 0; break-inside: avoid; }
.pn { flex: 0 0 2.6em; font-size: .62em; line-height: 2.75; color: #555; text-align: right; font-weight: 600; }
.pb { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.sheet-lg .sh-grid { font-size: 1.45rem; }
.sh-foot { display: flex; justify-content: space-between; gap: 12pt; height: 24pt; box-sizing: border-box; padding-top: 6pt; margin-top: auto; border-top: .5pt solid #999; font-size: 7.5pt; line-height: 10pt; color: #555; }
.sh-foot span { flex: 1 1 0; }
.sh-foot span:nth-child(2) { text-align: center; }
.sh-foot span:last-child { text-align: right; }

/* Vertical (column) problems: room above for carried digits */
.pv { display: inline-grid; justify-items: end; align-self: flex-start; line-height: 1.35; min-width: 3.5ch; padding-top: .6em; }
.pv-b { display: flex; gap: .4em; }
.pv-op { margin-right: auto; }
.pv-line { width: 100%; border-top: 1.5pt solid #111; margin-top: 1pt; }
.pv-ans { min-height: 1.6em; padding-top: 2px; }
.sheet-key .pv-ans { color: #0b6b4f; font-weight: 700; }

/* Horizontal problems */
.ph { display: flex; flex-wrap: nowrap; white-space: nowrap; align-items: center; gap: .35em; line-height: 1.7; }
.blank { display: inline-block; flex: 0 0 auto; width: 2.8em; border-bottom: 1pt solid #111; height: 1.2em; }
.blank.sm { width: 2.4em; }
.blank.lg { width: 8em; }
.ans { color: #0b6b4f; font-weight: 700; }
.ans.fill { display: inline-block; min-width: 2em; text-align: center; border-bottom: 1pt solid #111; }
.ph sup { font-size: .65em; }

/* Fractions */
.pf { gap: .45em; line-height: 1.1; min-height: 2.6em; }
.fr { display: inline-flex; flex-direction: column; align-items: center; line-height: 1.1; vertical-align: middle; font-variant-numeric: tabular-nums; }
.fr-n { border-bottom: 1pt solid currentColor; padding: 0 .2em; }
.fr-d { padding: 0 .2em; }
.fr-w { margin-right: .15em; }
.pf .blank { height: 1.8em; }

/* Clocks and equations */
.pclk { display: flex; flex-direction: column; align-items: center; gap: .4em; width: 6.2em; }
.clk { width: 6.2em; height: 6.2em; display: block; }
.clk-ans { display: flex; align-items: flex-end; gap: .2em; white-space: nowrap; line-height: 1.6; }
.eq-gap { display: inline-block; width: 1.2em; }
.op { padding: 0 .1em; }
.cmp-box { display: inline-block; width: 1.6em; height: 1.6em; border: 1pt solid #111; border-radius: 3pt; margin: 0 .3em; }
.cmp { display: inline-block; min-width: 1.6em; text-align: center; margin: 0 .3em; }

/* Written working: faint ruled lines (equations, word problems); real borders so they print
 * even when the browser leaves out background graphics. */
.work { display: flex; flex-direction: column; margin-top: .2em; max-width: 16em; }
.work i { display: block; height: 1.6em; box-sizing: border-box; border-bottom: .6pt solid #aaa; }
.fam-E .work { max-width: none; }

/* Word problems */
.pwp { display: flex; flex-direction: column; white-space: normal; line-height: 1.45; }
.pwp-text { margin: 0; max-width: 70ch; }
.pwp-ans { order: 2; margin-top: .4em; white-space: nowrap; }
.pb > .pwp { display: contents; } /* text, then working lines, then the answer line */
.pb > .work { order: 1; }

/* Long division: the layout gives each problem room for its subtraction steps */
.pld { display: inline-flex; flex-direction: column; align-items: flex-end; align-self: flex-start; line-height: 1.4; }
.pld-q { min-height: 1.4em; padding-right: .2em; color: #0b6b4f; font-weight: 700; }
.pld-row { display: flex; }
.pld-dv { padding-right: .35em; }
.pld-dd { border-top: 1.5pt solid #111; border-left: 1.5pt solid #111; border-top-left-radius: 10px 70%; padding: 0 .3em 0 .45em; }
.sheet:not(.pg) .pld { padding-bottom: 3.5em; }
.sheet:not(.pg) .sh-foot { margin-top: 18px; }

/* Paged sheets (generator pages): each .sheet.pg is one sheet of paper, at its real size.
 * On narrow screens app.js scales the page down with `zoom`. */
.sheet.pg { box-sizing: border-box; width: var(--pw); max-width: none; height: var(--ph); padding: 12mm 14mm 10mm; display: flex; flex-direction: column; border-radius: 2px; }
.sheet.pg .sh-grid { flex: 1 1 0; min-height: 0; grid-template-rows: repeat(var(--rows), minmax(0, 1fr)); row-gap: 0; }
.sheet.pg .sh-foot { margin-top: 0; }
.sheet.pg .pr { min-height: 0; }
@media screen and (max-width: 640px) {
  .sheet:not(.pg) { padding: 18px 14px; }
  .sheet:not(.pg) .sh-grid { grid-template-columns: repeat(min(var(--cols), 2), minmax(0, 1fr)); gap: 18px 10px; font-size: 1.05rem; }
}

/* ---------- Print: only the worksheet(s) ---------- */
@page { margin: 0; }
@media print {
  :root { color-scheme: light; }
  html, body { background: #fff; color: #000; padding: 0 !important; margin: 0; }
  .site-head, .site-foot, .crumbs, .ws-controls, .ws-intro, .page-head, .preview-bar, .content, .related, .ad, .no-print, .skip { display: none !important; }
  main { padding: 0; }
  .wrap { max-width: none; padding: 0; }
  .ws-layout { display: block; }
  .workspace, .more { margin: 0; padding: 0; }
  .desk { padding: 0; border: 0; border-radius: 0; background: none; }
  .sheet { box-shadow: none !important; border: 0; border-radius: 0; margin: 0; animation: none !important; transform: none !important; zoom: 1 !important; }
  .sheet.pg { height: calc(var(--ph) - .4mm); break-after: page; break-inside: avoid; }
  .sheet.pg:last-child { break-after: auto; }
  .sheet-key .ans, .sheet-key .pv-ans, .pld-q { color: #000; }
  a { color: #000; text-decoration: none; }
}
