:root {
  --ink: #172033;
  --muted: #657086;
  --paper: #f5f7fb;
  --surface: #ffffff;
  --line: #dfe5ef;
  --blue: #2457d6;
  --blue-dark: #173a91;
  --aqua: #12a7a1;
  --yellow: #ffd75e;
  --radius: 20px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

.training-hero { padding: clamp(4rem, 9vw, 8rem) 0; background: linear-gradient(135deg, #102a43, #173f5f 58%, #1f6f78); color: #fff; }
.training-hero h1 { max-width: 900px; margin: .2rem 0 1rem; font-size: clamp(3rem, 8vw, 6.5rem); line-height: .9; }
.training-hero p { max-width: 720px; font-size: 1.1rem; line-height: 1.7; }
.training-jumps { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 2rem; }
.training-jumps a { padding: .8rem 1.2rem; border: 1px solid rgba(255,255,255,.45); border-radius: 999px; color: #fff; text-decoration: none; font-weight: 700; }
.training-jumps a:hover { background: #fff; color: #173f5f; }
.training-group:nth-of-type(odd) { background: #f4f7f9; }
.training-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 1rem; }
.training-card { display: flex; min-height: 190px; flex-direction: column; padding: 1.5rem; border: 1px solid #d9e2ec; border-radius: 18px; background: #fff; color: inherit; text-decoration: none; box-shadow: 0 8px 24px rgba(16,42,67,.06); transition: transform .2s ease, box-shadow .2s ease; }
.training-card:hover { transform: translateY(-3px); box-shadow: 0 14px 32px rgba(16,42,67,.12); }
.training-card h3 { margin: .45rem 0 1.4rem; font-size: 1.2rem; line-height: 1.35; }
.training-card .card-link { margin-top: auto; }
.training-group { scroll-margin-top: 5rem; }
.reading-source { margin-bottom: 2rem; padding: clamp(1.25rem, 3vw, 2rem); overflow-x: auto; border: 1px solid #d9e2ec; border-radius: 18px; background: #fff; box-shadow: 0 8px 24px rgba(16,42,67,.06); line-height: 1.65; }
.reading-source > p:first-of-type { margin-top: 0; }
.reading-source table { width: 100%; min-width: 680px; border-collapse: collapse; }
.reading-source td { width: 50%; padding: 1rem; vertical-align: top; border: 1px solid #d9e2ec; }
.reading-source img { display: block; max-width: 100%; height: auto; margin: 1rem auto; }

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font-size: 1rem; line-height: 1.65; background: var(--paper); }
a { color: inherit; }
img { max-width: 100%; }

.skip-link { position: absolute; left: -999px; top: 0; z-index: 20; padding: .7rem 1rem; background: #fff; }
.skip-link:focus { left: 1rem; top: 1rem; }
.shell { width: min(1120px, calc(100% - 2rem)); margin-inline: auto; }

.site-header { position: sticky; top: 0; z-index: 10; border-bottom: 1px solid rgba(223,229,239,.9); background: rgba(255,255,255,.94); backdrop-filter: blur(14px); }
.header-inner { min-height: 74px; display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; }
.brand { display: inline-flex; align-items: center; gap: .75rem; color: var(--ink); font-weight: 850; text-decoration: none; letter-spacing: -.02em; }
.brand-mark { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 13px; color: #fff; background: linear-gradient(135deg, var(--blue), var(--aqua)); box-shadow: 0 8px 22px rgba(36,87,214,.2); }
.nav { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem; }
.nav a { padding: .55rem .75rem; border-radius: 10px; color: #3d485e; font-size: .92rem; font-weight: 700; text-decoration: none; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--blue-dark); background: #edf2ff; }

.hero { overflow: hidden; padding: clamp(4rem, 9vw, 7.5rem) 0 4.5rem; background: radial-gradient(circle at 86% 12%, rgba(18,167,161,.2), transparent 30rem), radial-gradient(circle at 12% 0%, rgba(36,87,214,.16), transparent 28rem), var(--surface); }
.eyebrow { margin: 0 0 1rem; color: var(--blue); font-size: .82rem; font-weight: 850; letter-spacing: .12em; text-transform: uppercase; }
h1, h2, h3 { line-height: 1.12; letter-spacing: -.035em; }
h1 { max-width: 820px; margin: 0; font-size: clamp(2.7rem, 7vw, 5.6rem); }
.hero-copy { max-width: 720px; margin: 1.4rem 0 0; color: var(--muted); font-size: clamp(1.05rem, 2vw, 1.3rem); }
.hero-actions { display: flex; flex-wrap: wrap; gap: .8rem; margin-top: 2rem; }
.button { display: inline-flex; min-height: 48px; align-items: center; justify-content: center; padding: .75rem 1.1rem; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); font-weight: 800; text-decoration: none; }
.button.primary { border-color: var(--blue); color: #fff; background: var(--blue); }
.button:hover { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(29,45,80,.12); }

.section { padding: 4.5rem 0; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 2rem; margin-bottom: 1.7rem; }
.section-head h2 { margin: 0; font-size: clamp(1.9rem, 4vw, 3rem); }
.section-head p { max-width: 560px; margin: 0; color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.card { min-height: 235px; display: flex; flex-direction: column; padding: 1.5rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 14px 40px rgba(35,51,84,.06); }
.card-kicker { color: var(--blue); font-size: .78rem; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.card h2, .card h3 { margin: .55rem 0 .5rem; font-size: 1.55rem; }
.card p { margin: 0 0 1.5rem; color: var(--muted); }
.card-link { margin-top: auto; color: var(--blue-dark); font-weight: 850; text-decoration: none; }
.card-link:hover { text-decoration: underline; }
.card.featured { color: #fff; border-color: transparent; background: linear-gradient(145deg, #111735, #25347c); }
.card.featured .card-kicker, .card.featured p, .card.featured .card-link { color: #e6ebff; }

.page-head { padding: 4rem 0 2.5rem; background: #fff; }
.page-head h1 { font-size: clamp(2.5rem, 6vw, 4.5rem); }
.page-head p { max-width: 720px; color: var(--muted); font-size: 1.15rem; }
.filters { display: flex; flex-wrap: wrap; gap: .65rem; margin: 1.5rem 0 2rem; }
.filter { padding: .55rem .8rem; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: #40506b; font: inherit; font-weight: 750; cursor: pointer; }
.filter[aria-pressed="true"] { color: #fff; border-color: var(--blue); background: var(--blue); }
.empty-note { padding: 2rem; border: 1px dashed #bbc5d6; border-radius: var(--radius); color: var(--muted); background: rgba(255,255,255,.55); }
.topic-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.topic { padding: 1.35rem; border: 1px solid var(--line); border-radius: 16px; background: #fff; }
.topic h2 { margin: 0 0 .4rem; font-size: 1.3rem; }
.topic p { margin: 0; color: var(--muted); }
.topic-label { margin-bottom: .35rem !important; color: #087d78 !important; font-size: .75rem; font-weight: 900; letter-spacing: .09em; text-transform: uppercase; }
.if-topic { border-color: #b8e7e3; background: linear-gradient(145deg, #fff, #effbf9); }
.site-footer { margin-top: 3rem; padding: 2.5rem 0; border-top: 1px solid var(--line); color: var(--muted); background: #fff; }
.footer-inner { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.footer-inner a { color: var(--ink); }

@media (max-width: 820px) {
  .header-inner { align-items: flex-start; flex-direction: column; padding: .8rem 0; }
  .nav { width: 100%; overflow-x: auto; flex-wrap: nowrap; padding-bottom: .2rem; }
  .nav a { white-space: nowrap; }
  .grid { grid-template-columns: 1fr; }
  .topic-list { grid-template-columns: 1fr; }
  .section-head { align-items: flex-start; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; }
}

/* If Clauses learning lab */
.if-page { --if-navy: #101c36; --if-ink: #15213b; --if-cyan: #50dfcf; --if-cyan-dark: #087d78; --if-orange: #ffad57; --if-lime: #c9ef62; --if-soft: #eef5f8; color: var(--if-ink); background: #f4f7f9; }
.if-hero { padding: clamp(2rem, 5vw, 4.5rem) 0; color: #fff; background: radial-gradient(circle at 78% 20%, rgba(80,223,207,.18), transparent 24rem), linear-gradient(135deg, #0c1730, #17294b); }
.if-hero-grid { display: grid; grid-template-columns: 1.4fr .6fr; gap: clamp(2rem, 6vw, 5rem); align-items: end; }
.if-hero .eyebrow { margin-bottom: .7rem; color: var(--if-cyan); }
.if-hero h1 { max-width: none; color: #fff; font-size: clamp(3.3rem, 9vw, 7.5rem); }
.if-hero p:last-child { max-width: 680px; margin: 1rem 0 0; color: #cbd8e9; font-size: 1.12rem; }
.if-back { display: inline-block; margin-bottom: 1.8rem; color: #dce8f6; font-weight: 800; text-decoration: none; }
.if-back::before { content: "← "; }
.lesson-jumps { display: grid; gap: .5rem; }
.lesson-jumps a { display: grid; grid-template-columns: 2.6rem 1fr; align-items: center; padding: .8rem 1rem; border: 1px solid rgba(255,255,255,.16); border-radius: 12px; color: #fff; font-weight: 800; text-decoration: none; background: rgba(255,255,255,.05); }
.lesson-jumps a:hover { border-color: var(--if-cyan); background: rgba(80,223,207,.09); }
.lesson-jumps span { color: var(--if-cyan); font-size: .78rem; letter-spacing: .08em; }
.if-section { padding: clamp(3.5rem, 7vw, 6rem) 0; scroll-margin-top: 70px; }
.if-section-head { display: flex; justify-content: space-between; align-items: end; gap: 2rem; margin-bottom: 2rem; }
.if-section-head h2 { margin: 0; font-size: clamp(2rem, 5vw, 3.6rem); }
.if-section-head > p { max-width: 510px; margin: 0; color: var(--muted); }
.section-number { margin: 0 0 .55rem; color: var(--if-cyan-dark); font-size: .78rem; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
.teacher-controls { display: grid; grid-template-columns: auto 1fr auto; gap: 1.2rem; align-items: end; margin-bottom: 1rem; }
.teacher-controls fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.teacher-controls legend { margin-bottom: .35rem; color: #526078; font-size: .78rem; font-weight: 850; text-transform: uppercase; letter-spacing: .06em; }
.segmented { display: flex; flex-wrap: wrap; gap: .35rem; }
.segmented button, .board-button, .generate-button, .exercise-tabs button, .check-button, .next-button { min-height: 44px; border: 0; border-radius: 10px; padding: .65rem .9rem; font: inherit; font-weight: 850; cursor: pointer; }
.segmented button { color: #46546c; background: #e6ebf0; }
.segmented button[aria-pressed="true"] { color: #fff; background: var(--if-navy); }
.generate-button { min-width: 150px; color: #092524; background: var(--if-cyan); box-shadow: 0 9px 22px rgba(25,157,149,.18); }
.generate-button span { display: inline-block; margin-right: .3rem; font-size: 1.3rem; line-height: 0; }
.sentence-board { position: relative; isolation: isolate; overflow: hidden; min-height: 370px; padding: clamp(1.5rem, 4vw, 3rem); border-radius: 24px; color: #fff; background: radial-gradient(circle at 90% 0, rgba(80,223,207,.14), transparent 23rem), var(--if-navy); box-shadow: 0 24px 70px rgba(15,28,53,.2); }
.board-top { display: flex; justify-content: space-between; color: #9db0c9; font-size: .73rem; font-weight: 900; letter-spacing: .12em; }
.sentence { position: relative; z-index: 1; max-width: 1050px; margin: clamp(2.3rem, 7vw, 5rem) 0 2.3rem; font-size: clamp(2rem, 5vw, 4.4rem); font-weight: 800; line-height: 1.16; letter-spacing: -.04em; }
.sentence-board.show-tenses .sentence .if-part { text-decoration: underline; text-decoration-color: var(--if-cyan); text-decoration-thickness: .12em; text-underline-offset: .13em; }
.sentence-board.show-tenses .sentence .main-part { text-decoration: underline; text-decoration-color: var(--if-orange); text-decoration-thickness: .12em; text-underline-offset: .13em; }
.reveal-grid { position: relative; z-index: 1; display: grid; grid-template-columns: 1.25fr .75fr; gap: .75rem; margin: 0 0 1.5rem; }
.reveal-card { padding: .85rem 1rem; border: 1px solid rgba(255,255,255,.15); border-radius: 12px; background: rgba(255,255,255,.07); }
.reveal-card span { display: block; color: #9db0c9; font-size: .7rem; font-weight: 900; letter-spacing: .09em; text-transform: uppercase; }
.reveal-card strong { display: block; margin-top: .15rem; color: #eef6ff; font-size: 1rem; }
.tense-card strong { display: flex; gap: .5rem; align-items: center; }
.tense-card i { width: 9px; height: 9px; border-radius: 50%; background: var(--if-cyan); }
.tense-card i:nth-of-type(2) { background: var(--if-orange); }
.tense-card em { color: #8393aa; font-style: normal; }
.board-actions { position: relative; z-index: 3; display: flex; flex-wrap: wrap; gap: .55rem; }
.board-button { color: #dce8f6; border: 1px solid #40516e; background: #22314c; }
.board-button:hover, .board-button[aria-pressed="true"] { color: #0f2930; border-color: var(--if-cyan); background: var(--if-cyan); }
.clear-button { color: #172239; background: #fff; }
#pen-canvas { position: absolute; inset: 0; z-index: 2; width: 100%; height: 100%; pointer-events: none; touch-action: none; }
.sentence-board.pen-active #pen-canvas { pointer-events: auto; cursor: crosshair; }
.board-hint { display: flex; flex-wrap: wrap; gap: .45rem .7rem; align-items: center; margin: 1rem .4rem 0; color: #68768a; font-size: .85rem; }
.board-hint > span:last-child { margin-left: auto; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; }
.if-dot { background: var(--if-cyan); } .main-dot { background: var(--if-orange); }
.overview-section { background: #fff; }
.type-table { overflow: hidden; border: 1px solid #dbe3e9; border-radius: 20px; }
.table-row { display: grid; grid-template-columns: 100px 1fr 1.1fr 1fr; width: 100%; text-align: left; }
.table-head { color: #6c7888; background: #edf2f5; font-size: .78rem; font-weight: 900; letter-spacing: .07em; text-transform: uppercase; }
.table-head > div { padding: .8rem 1rem; }
.type-row { align-items: stretch; padding: 0; border: 0; border-top: 1px solid #e1e7eb; color: inherit; background: #fff; cursor: pointer; }
.type-row > span { min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: .2rem; padding: 1.3rem 1rem; border-left: 1px solid #e1e7eb; }
.type-row > span:first-child { border-left: 0; }
.type-row:hover, .type-row.active { background: #f5fffd; }
.type-row.active { box-shadow: inset 5px 0 var(--if-cyan); }
.type-badge { align-items: center !important; font-size: 2.8rem; font-weight: 950; }
.type-row small { display: none; color: #708096; font-size: .7rem; font-weight: 900; text-transform: uppercase; }
.type-row strong { font-size: 1.08rem; line-height: 1.25; }
.type-row em { color: #536177; font-size: .9rem; font-style: normal; line-height: 1.4; }
.type-row mark { padding: .03rem .15rem; color: inherit; background: #d7f8f2; }
.type-1 { color: #087d78; }.type-2 { color: #d26928; }.type-3 { color: #6852a8; }
.memory-line { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; padding: 1rem 1.2rem; border-radius: 12px; background: var(--if-navy); color: #d9e5f3; }
.memory-line span { color: var(--if-cyan); font-weight: 900; }.memory-line strong { color: #fff; }
.practice-section { background: #eaf0f3; }
.practice-level { display: grid; gap: .3rem; }
.practice-level label { color: #647085; font-size: .75rem; font-weight: 850; text-transform: uppercase; }
.practice-level select { min-height: 44px; padding: .6rem 2.2rem .6rem .8rem; border: 1px solid #ccd7df; border-radius: 10px; color: var(--if-ink); background: #fff; font: inherit; font-weight: 800; }
.exercise-tabs { display: flex; gap: .5rem; margin-bottom: 1rem; }
.exercise-tabs button { color: #556278; background: #dbe4e9; }
.exercise-tabs button[aria-selected="true"] { color: #fff; background: var(--if-navy); }
.exercise-card { overflow: hidden; border-radius: 22px; background: #fff; box-shadow: 0 18px 50px rgba(31,48,71,.1); }
.exercise-top { display: flex; justify-content: space-between; padding: 1rem 1.4rem; border-bottom: 1px solid #e4e9ed; color: #6b778a; font-size: .75rem; font-weight: 900; letter-spacing: .07em; }
#exercise-content { min-height: 270px; display: grid; align-content: center; padding: clamp(1.5rem, 5vw, 3.5rem); }
.exercise-prompt { margin: 0 0 1.2rem; color: #576579; font-weight: 750; }
.word-bank, .answer-zone { display: flex; flex-wrap: wrap; gap: .55rem; min-height: 62px; padding: .7rem; border-radius: 12px; }
.word-bank { background: #f0f4f6; }
.answer-zone { margin-top: .8rem; border: 2px dashed #b9c8d2; background: #fafcfd; }
.word-chip { padding: .65rem .8rem; border: 1px solid #cbd5dc; border-radius: 9px; color: var(--if-ink); background: #fff; font: inherit; font-weight: 800; cursor: grab; box-shadow: 0 3px 8px rgba(30,47,68,.07); }
.word-chip:active { cursor: grabbing; }.word-chip.selected { outline: 3px solid var(--if-cyan); }.drag-over { border-color: var(--if-cyan-dark); background: #effbf9; }
.gap-sentence { font-size: clamp(1.35rem, 4vw, 2.3rem); font-weight: 800; line-height: 1.5; }
.gap-input { width: min(230px, 45vw); padding: .25rem .45rem; border: 0; border-bottom: 3px solid #90a1b1; color: var(--if-ink); background: #eef3f5; font: inherit; font-weight: 850; text-align: center; }
.gap-input:focus { outline: 3px solid rgba(80,223,207,.35); border-color: var(--if-cyan-dark); }
.sort-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: .7rem; margin-top: 1.5rem; }
.sort-option { padding: 1rem; border: 2px solid #d6dfe5; border-radius: 12px; color: #33425a; background: #fff; font: inherit; font-weight: 900; cursor: pointer; }
.sort-option[aria-pressed="true"] { border-color: var(--if-cyan-dark); background: #eafffb; }
.exercise-footer { display: flex; align-items: center; gap: .8rem; padding: 1rem 1.4rem; border-top: 1px solid #e4e9ed; background: #f8fafb; }
.exercise-footer p { flex: 1; margin: 0; color: #59677b; }
.exercise-footer p.correct { color: #087b56; font-weight: 850; }.exercise-footer p.incorrect { color: #a3402e; font-weight: 850; }
.exercise-footer p.revealed { color: #4c3e86; font-weight: 850; }
.solution-button { min-height: 44px; padding: .65rem .9rem; border: 1px solid #bfcbd5; border-radius: 10px; color: #33425a; background: #fff; font: inherit; font-weight: 850; cursor: pointer; }
.solution-button:hover { border-color: #6852a8; background: #f3f0ff; }
.check-button { color: #092524; background: var(--if-cyan); }.next-button { color: #fff; background: var(--if-navy); }
@media (max-width: 820px) {
  .if-hero-grid, .reveal-grid { grid-template-columns: 1fr; }
  .lesson-jumps { grid-template-columns: repeat(3, 1fr); }
  .lesson-jumps a { grid-template-columns: 1fr; gap: .15rem; }
  .teacher-controls { grid-template-columns: 1fr; }
  .generate-button { width: 100%; }
  .if-section-head { align-items: flex-start; flex-direction: column; }
  .table-head { display: none; }
  .type-table { display: grid; gap: .8rem; overflow: visible; border: 0; }
  .table-row.type-row { grid-template-columns: 64px 1fr; border: 1px solid #dbe3e9; border-radius: 15px; overflow: hidden; }
  .type-row > span { border: 0; border-top: 1px solid #e1e7eb; }
  .type-row > span:nth-child(n+2) { grid-column: 2; }
  .type-row > span:nth-child(2) { border-top: 0; }
  .type-badge { grid-row: 1 / 4; grid-column: 1 !important; padding: .7rem !important; border-right: 1px solid #e1e7eb !important; }
  .type-row small { display: block; }
}
@media (max-width: 560px) {
  .lesson-jumps { grid-template-columns: 1fr; }
  .if-hero p:last-child { font-size: 1rem; }
  .sentence-board { border-radius: 16px; }
  .sentence { margin-top: 2.5rem; }
  .board-hint > span:last-child { width: 100%; margin-left: 0; }
  .exercise-tabs { display: grid; grid-template-columns: 1fr; }
  .sort-options { grid-template-columns: 1fr; }
  .exercise-footer { align-items: stretch; flex-direction: column; }
  .exercise-footer button { width: 100%; }
}

/* If Clauses app shell */
.if-appbar { position: sticky; top: 0; z-index: 30; color: #fff; background: #101c36; box-shadow: 0 2px 16px rgba(10,20,40,.16); }
.if-appbar-inner { width: min(1480px, calc(100% - 2rem)); min-height: 68px; display: flex; align-items: center; gap: 2rem; margin-inline: auto; }
.if-app-brand { display: inline-flex; align-items: center; gap: .7rem; color: #fff; text-decoration: none; }
.if-app-brand span { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 11px; color: #10213a; background: var(--if-cyan); font-weight: 950; }
.if-app-brand strong { font-size: 1.08rem; }
.if-app-nav { display: flex; align-self: stretch; margin-left: auto; }
.if-app-nav a { display: flex; align-items: center; padding: 0 1rem; border-bottom: 3px solid transparent; color: #b9c8dc; font-weight: 800; text-decoration: none; }
.if-app-nav a:hover, .if-app-nav a[aria-current="page"] { color: #fff; border-color: var(--if-cyan); background: rgba(255,255,255,.05); }
.if-home-button { display: grid; width: 40px; height: 40px; place-items: center; border: 1px solid #40516e; border-radius: 10px; color: #fff; font-size: 1.25rem; text-decoration: none; }
.if-exit { margin-left: auto; color: #d3dfed; font-weight: 750; text-decoration: none; }
.if-exit::before { content: "← "; }
.if-app-home { min-height: 100vh; display: flex; flex-direction: column; background: radial-gradient(circle at 84% 16%, rgba(80,223,207,.13), transparent 28rem), #edf3f6; }
.app-home-main { width: min(1260px, calc(100% - 2rem)); flex: 1; margin: 0 auto; padding: clamp(3rem, 7vw, 6.5rem) 0 4rem; }
.app-welcome { display: grid; grid-template-columns: 1.25fr .75fr; align-items: end; gap: 3rem; margin-bottom: 3rem; }
.app-welcome h1 { margin: 0; color: var(--if-navy); font-size: clamp(3.8rem, 9vw, 7.5rem); }
.app-welcome p:last-child { max-width: 680px; margin: 1rem 0 0; color: #5d6d82; font-size: 1.15rem; }
.formula-strip { display: flex; align-items: center; justify-content: center; gap: 1rem; padding: 1.2rem; border: 1px solid #d8e2e8; border-radius: 16px; background: rgba(255,255,255,.78); box-shadow: 0 14px 36px rgba(32,49,72,.07); }
.formula-strip span { padding: .55rem .8rem; border-radius: 8px; font-weight: 900; background: #d9f8f3; }
.formula-strip span:last-child { background: #fff0df; }
.formula-strip b { color: #6d7b8e; font-size: 1.35rem; }
.app-menu { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 1.2rem; }
.app-menu-card { position: relative; min-height: 355px; display: flex; flex-direction: column; padding: 1.7rem; overflow: hidden; border: 1px solid #d9e2e8; border-radius: 22px; color: var(--if-ink); background: #fff; box-shadow: 0 18px 50px rgba(31,48,71,.08); text-decoration: none; transition: transform .18s ease, box-shadow .18s ease; }
.app-menu-card::after { content: ""; position: absolute; inset: auto -50px -70px auto; width: 180px; height: 180px; border-radius: 50%; opacity: .18; background: var(--card-accent); }
.app-menu-card:hover { transform: translateY(-6px); box-shadow: 0 26px 60px rgba(31,48,71,.14); }
.examples-card { --card-accent: var(--if-cyan); }.overview-card { --card-accent: var(--if-orange); }.practice-card { --card-accent: var(--if-lime); }
.app-card-number { color: #728095; font-size: .75rem; font-weight: 900; letter-spacing: .1em; }
.app-card-icon { width: 70px; height: 70px; display: grid; place-items: center; margin: 2rem 0 1.5rem; border-radius: 18px; color: #10213a; background: color-mix(in srgb, var(--card-accent) 35%, white); font-size: 1.25rem; font-weight: 950; }
.app-menu-card h2 { margin: 0 0 .7rem; font-size: 2rem; }
.app-menu-card p { margin: 0 0 1.5rem; color: #68768a; }
.app-menu-card > strong { margin-top: auto; color: #14223c; }
.app-home-footer { display: flex; justify-content: space-between; gap: 1rem; padding: 1.2rem max(1rem, calc((100% - 1260px)/2)); border-top: 1px solid #d9e2e8; color: #68768a; background: rgba(255,255,255,.55); font-size: .85rem; }
.if-workspace-page { min-height: 100vh; background: #eef3f6; }
.workspace-shell { width: min(1480px, calc(100% - 2rem)); display: grid; grid-template-columns: minmax(0,1fr) 290px; gap: 1.25rem; margin: 0 auto; padding: 1.4rem 0 2.5rem; }
.workspace-main { min-width: 0; }
.workspace-title { min-height: 90px; display: flex; align-items: end; justify-content: space-between; gap: 1.5rem; margin-bottom: 1rem; }
.workspace-title h1 { margin: 0; color: var(--if-navy); font-size: clamp(2rem,4vw,3.4rem); }
.workspace-title p:not(.section-number) { max-width: 420px; margin: 0 0 .5rem; color: #68768a; }
.teacher-toolbox { position: sticky; top: 86px; align-self: start; display: grid; gap: 1.15rem; padding: 1.2rem; border: 1px solid #d7e1e7; border-radius: 18px; background: #fff; box-shadow: 0 14px 40px rgba(31,48,71,.08); }
.toolbox-heading { display: grid; padding-bottom: .85rem; border-bottom: 1px solid #e4eaee; }
.toolbox-heading span, .tool-label, .teacher-toolbox legend { color: #788597; font-size: .7rem; font-weight: 900; letter-spacing: .09em; text-transform: uppercase; }
.toolbox-heading strong { font-size: 1.15rem; }
.teacher-toolbox fieldset { margin: 0; padding: 0; border: 0; }
.teacher-toolbox legend { margin-bottom: .45rem; }
.tool-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: .4rem; }.tool-grid.two { grid-template-columns: repeat(2,1fr); }
.tool-grid button, .tool-stack button, .tool-toggle, .clear-annotation, .reset-score { min-height: 41px; padding: .55rem .65rem; border: 1px solid #d8e1e7; border-radius: 9px; color: #48576d; background: #f4f7f9; font: inherit; font-size: .88rem; font-weight: 850; cursor: pointer; }
.tool-grid button[aria-pressed="true"], .tool-stack button[aria-pressed="true"], .tool-toggle[aria-pressed="true"] { color: #fff; border-color: var(--if-navy); background: var(--if-navy); }
.tool-stack { display: grid; gap: .4rem; }.tool-stack button { text-align: left; }
.toolbox-group { display: grid; gap: .45rem; }.tool-label { display: block; }
.pen-tools { padding-top: 1rem; border-top: 1px solid #e4eaee; }
.pen-colors { display: flex; gap: .5rem; }
.pen-colors button { width: 31px; height: 31px; border: 3px solid #fff; border-radius: 50%; background: var(--pen); box-shadow: 0 0 0 1px #ccd7df; cursor: pointer; }
.pen-colors button:nth-child(1){--pen:#c9ef62}.pen-colors button:nth-child(2){--pen:#ffad57}.pen-colors button:nth-child(3){--pen:#50dfcf}.pen-colors button.active{box-shadow:0 0 0 3px #24334d;}
.clear-annotation, .reset-score { color: #6a4550; background: #fff; }
.classroom-canvas { position: relative; isolation: isolate; }
.annotation-canvas { position: absolute; inset: 0; z-index: 10; width: 100%; height: 100%; pointer-events: none; touch-action: none; }
.classroom-canvas.pen-active .annotation-canvas { pointer-events: auto; cursor: crosshair; }
.if-workspace-page .sentence-board { min-height: calc(100vh - 200px); display: flex; flex-direction: column; justify-content: center; }
.if-workspace-page .sentence { margin: 3rem 0; }
.board-key { position: absolute; left: 2.5rem; bottom: 1.5rem; display: flex; gap: 1.2rem; color: #b7c5d8; font-size: .82rem; }
.board-key span { display: flex; align-items: center; gap: .4rem; }.board-key i { width: 9px; height: 9px; border-radius: 50%; }.if-key{background:var(--if-cyan)}.main-key{background:var(--if-orange)}
.overview-canvas { padding: 1rem; border-radius: 20px; background: #fff; box-shadow: 0 14px 40px rgba(31,48,71,.08); }
.type-row.dimmed { opacity: .25; }.overview-canvas.hide-examples .type-row em { visibility: hidden; }.overview-canvas.hide-rules .type-row > span:last-child { visibility: hidden; }
.overview-canvas [hidden] { display: none !important; }
.overview-empty { min-height: 430px; display: grid; place-content: center; gap: .35rem; padding: 2rem; text-align: center; color: #657489; }
.overview-empty strong { color: var(--if-navy); font-size: 1.45rem; }
.overview-canvas .tense-content, .overview-canvas .example-content, .overview-canvas .rule-content { visibility: hidden; }
.overview-canvas.show-tenses .tense-content, .overview-canvas.show-examples .example-content, .overview-canvas.show-rules .rule-content { visibility: visible; }
.overview-canvas.empty-overview .type-table { display: none; }
.score-pill { padding: .55rem .85rem; border-radius: 999px; color: #fff; background: var(--if-navy); font-size: .85rem; font-weight: 850; }
.if-workspace-page .exercise-card { min-height: calc(100vh - 200px); display: flex; flex-direction: column; }
.if-workspace-page #exercise-content { flex: 1; }
.exercise-empty { display: grid; place-items: center; gap: .35rem; color: #657489; text-align: center; }
.exercise-empty strong { color: var(--if-navy); font-size: 1.3rem; }
.gap-label { display: grid; gap: .5rem; width: min(420px,100%); margin-top: 1.4rem; color: #68768a; font-size: .8rem; font-weight: 850; text-transform: uppercase; }
.gap-label .gap-input { width: 100%; text-align: left; text-transform: none; }
.verb-hint { color: #6d7b8e; font-size: .72em; font-weight: 750; white-space: nowrap; }
@media (max-width: 980px) {
  .workspace-shell { grid-template-columns: 1fr; }
  .teacher-toolbox { position: static; grid-row: 1; grid-template-columns: repeat(3,minmax(0,1fr)); align-items: start; }
  .toolbox-heading { grid-column: 1/-1; }
  .pen-tools { padding-top: 0; border-top: 0; }
  .app-menu { grid-template-columns: 1fr; }
  .app-menu-card { min-height: 250px; }
  .app-card-icon { margin: 1.2rem 0 1rem; }
}
@media (max-width: 720px) {
  .if-appbar-inner { gap: .7rem; }
  .if-app-brand strong { display: none; }
  .if-app-nav { flex: 1; overflow-x: auto; }
  .if-app-nav a { padding: 0 .7rem; white-space: nowrap; font-size: .82rem; }
  .app-welcome { grid-template-columns: 1fr; gap: 1.5rem; }
  .formula-strip { justify-content: flex-start; }
  .teacher-toolbox { grid-template-columns: 1fr 1fr; }
  .toolbox-heading { grid-column: 1/-1; }
  .workspace-title { align-items: flex-start; flex-direction: column; }
  .workspace-title .generate-button { width: 100%; }
  .if-workspace-page .sentence-board, .if-workspace-page .exercise-card { min-height: 520px; }
}
@media (max-width: 500px) {
  .teacher-toolbox { grid-template-columns: 1fr; }
  .app-home-footer { flex-direction: column; }
  .if-exit { font-size: .8rem; }
}

/* Viewport-fitted classroom mode */
.if-workspace-page { height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; }
.if-workspace-page .if-appbar-inner { min-height: 58px; }
.if-workspace-page .if-app-brand span { width: 38px; height: 38px; }
.workspace-shell { height: calc(100vh - 58px); height: calc(100dvh - 58px); grid-template-columns: minmax(0,1fr) 238px; gap: .8rem; padding: .7rem 0; overflow: hidden; }
.workspace-main { min-height: 0; display: grid; grid-template-rows: auto minmax(0,1fr); }
.workspace-title { min-height: 62px; margin-bottom: .55rem; }
.workspace-title h1 { font-size: clamp(1.8rem, 3.2vw, 2.8rem); }
.workspace-title .section-number { margin-bottom: .2rem; }
.teacher-toolbox { top: 66px; max-height: calc(100dvh - 72px); gap: .7rem; padding: .85rem; border-radius: 14px; overflow-y: auto; }
.toolbox-heading { padding-bottom: .55rem; }
.toolbox-heading strong { font-size: 1rem; }
.tool-grid button, .tool-stack button, .tool-toggle, .clear-annotation, .reset-score { min-height: 34px; padding: .38rem .45rem; font-size: .78rem; }
.teacher-toolbox legend { margin-bottom: .25rem; }
.toolbox-group { gap: .3rem; }
.pen-tools { padding-top: .65rem; }
.pen-colors button { width: 25px; height: 25px; }
.if-workspace-page .sentence-board, .if-workspace-page .exercise-card, .if-workspace-page .overview-canvas { min-height: 0; height: 100%; overflow: hidden; }
.if-workspace-page .sentence-board { display: grid; grid-template-rows: auto 35% minmax(0,1fr); align-content: stretch; justify-content: stretch; padding: clamp(1.2rem, 3vh, 2.2rem); }
.if-workspace-page .board-top { grid-row: 1; }
.if-workspace-page .sentence { grid-row: 2; align-self: center; width: 100%; margin: 0; font-size: clamp(1.8rem, min(5vw, 7vh), 4rem); white-space: nowrap; }
.if-workspace-page .reveal-grid { grid-row: 3; align-self: start; min-height: 82px; margin: clamp(.25rem, 1.5vh, .8rem) 0 0; }
.if-workspace-page .board-key { left: 1.5rem; bottom: 1rem; }
.if-workspace-page .exercise-card { display: grid; grid-template-rows: auto minmax(0,1fr) auto; }
.if-workspace-page #exercise-content { min-height: 0; padding: clamp(1rem, 3vh, 2.2rem); overflow: hidden; }
.if-workspace-page .gap-sentence { font-size: clamp(1.15rem, min(3.2vw, 4.2vh), 2rem); }
.if-workspace-page .word-bank, .if-workspace-page .answer-zone { min-height: 50px; padding: .5rem; }
.if-workspace-page .word-chip { padding: .45rem .6rem; }
.if-workspace-page .exercise-footer { padding: .7rem 1rem; }
.if-workspace-page .overview-canvas { overflow: auto; }
.if-workspace-page .overview-empty { min-height: 100%; }
.if-workspace-page .type-row > span { padding: clamp(.55rem, 1.5vh, 1rem) .75rem; }

@media (max-width: 980px) {
  .workspace-shell { grid-template-columns: 1fr; grid-template-rows: auto minmax(0,1fr); gap: .55rem; }
  .workspace-main { grid-row: 2; min-height: 0; }
  .teacher-toolbox { position: static; grid-row: 1; display: flex; align-items: end; gap: .6rem; max-width: 100%; max-height: 112px; padding: .55rem .65rem; overflow-x: auto; overflow-y: hidden; }
  .toolbox-heading { display: none; }
  .teacher-toolbox fieldset, .teacher-toolbox > .toolbox-group { flex: 0 0 auto; min-width: 180px; }
  .teacher-toolbox > .reset-score { flex: 0 0 auto; }
  .teacher-toolbox .pen-tools { min-width: 310px; display: grid; grid-template-columns: auto auto auto; align-items: end; padding: 0 0 0 .65rem; border-top: 0; border-left: 1px solid #e4eaee; }
  .teacher-toolbox .pen-tools .tool-label { grid-column: 1/-1; }
  .workspace-title { min-height: 50px; }
  .workspace-title h1 { font-size: clamp(1.55rem, 4vw, 2.2rem); }
  .workspace-title p:not(.section-number) { font-size: .82rem; }
  .if-workspace-page .sentence-board, .if-workspace-page .exercise-card { min-height: 0; }
}

@media (max-height: 700px) {
  .if-workspace-page .if-appbar-inner { min-height: 50px; }
  .workspace-shell { height: calc(100vh - 50px); height: calc(100dvh - 50px); padding: .45rem 0; }
  .workspace-title { min-height: 44px; margin-bottom: .35rem; }
  .workspace-title h1 { font-size: 1.7rem; }
  .workspace-title .section-number, .workspace-title > p { display: none; }
  .teacher-toolbox { gap: .45rem; padding: .55rem; }
  .if-workspace-page .sentence { margin: 1rem 0; }
  .if-workspace-page .reveal-card { padding: .55rem .7rem; }
  .if-workspace-page .exercise-top, .if-workspace-page .exercise-footer { padding: .55rem .8rem; }
}

/* Hamilton learning project */
.hamilton-site { --gold: #c89b3c; --hamilton-dark: #12100d; }
.hamilton-hero { padding: clamp(3rem, 7vw, 6rem) 0; color: #fff; background: radial-gradient(circle at 75% 20%, rgba(200,155,60,.2), transparent 25rem), linear-gradient(135deg, #11100e, #272016); }
.hamilton-hero-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(240px, .5fr); align-items: center; gap: clamp(2rem, 6vw, 6rem); }
.hamilton-hero h1 { color: #fff; font-size: clamp(4rem, 10vw, 8rem); text-transform: uppercase; }
.hamilton-hero p:not(.eyebrow) { max-width: 680px; color: #e6dcc8; font-size: 1.18rem; }
.hamilton-hero img { width: min(330px, 100%); justify-self: end; border: 1px solid rgba(255,255,255,.18); box-shadow: 0 30px 70px rgba(0,0,0,.45); transform: rotate(2deg); }
.hamilton-site .eyebrow { color: var(--gold); }
.hamilton-tracks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
.hamilton-track { display: grid; grid-template-columns: 42px minmax(0,1fr) auto; align-items: center; gap: .8rem; min-height: 70px; padding: .8rem 1rem; border: 1px solid var(--line); border-radius: 14px; background: #fff; text-decoration: none; }
.hamilton-track:hover { border-color: var(--gold); transform: translateY(-1px); box-shadow: 0 9px 24px rgba(42,32,14,.1); }
.hamilton-track > span { color: var(--gold); font-size: .8rem; font-weight: 900; }
.hamilton-track strong { line-height: 1.25; }
.hamilton-track small { color: var(--muted); font-size: .76rem; white-space: nowrap; }
.hamilton-dark { color: #fff; background: var(--hamilton-dark); }
.hamilton-dark .section-head p { color: #b9ae9c; }
.hamilton-dark .hamilton-track { color: #fff; border-color: #40382c; background: #201c16; }
.hamilton-dark .hamilton-track small { color: #b9ae9c; }
.hamilton-head { padding: 3rem 0; color: #fff; background: linear-gradient(135deg, #12100d, #312719); }
.hamilton-head h1 { max-width: 850px; font-size: clamp(2.6rem, 7vw, 5rem); }
.hamilton-back { display: inline-block; margin-bottom: 2rem; color: #e9c978; font-weight: 800; }
.hamilton-intro { display: grid; grid-template-columns: minmax(0, 1fr) 220px; align-items: center; gap: 2rem; margin-top: 2rem; }
.hamilton-quote { margin: 0; padding: 1.5rem 0 1.5rem 1.5rem; border-left: 4px solid var(--gold); font-size: clamp(1.15rem, 3vw, 1.7rem); }
.hamilton-quote p { margin: 0 0 .7rem; }
.hamilton-quote cite { color: #d1c6b5; font-size: .9rem; }
.hamilton-portrait { max-height: 290px; justify-self: end; border-radius: 8px; object-fit: cover; box-shadow: 0 18px 45px rgba(0,0,0,.35); }
.hamilton-content { max-width: 900px; }
.hamilton-lyrics { margin-bottom: 2rem; border: 1px solid var(--line); border-radius: 16px; background: #fff; }
.hamilton-lyrics summary { padding: 1rem 1.2rem; color: var(--ink); font-size: 1.1rem; font-weight: 850; cursor: pointer; }
.lyrics-text { max-height: 560px; overflow-y: auto; padding: 0 1.25rem 1.5rem; color: #3e4655; line-height: 1.7; }
.h5p-stack { display: grid; gap: 1.25rem; }
.h5p-card { overflow: hidden; padding: 1.25rem; border: 1px solid var(--line); border-radius: 18px; background: #fff; }
.h5p-card h2 { margin: .35rem 0 1rem; font-size: 1.35rem; }
.h5p-card iframe { width: 100%; border: 0; border-radius: 10px; background: #f4f5f8; }
.h5p-local { min-height: 160px; }
.h5p-error { padding: 1rem; border-radius: 10px; background: #fff2f2; color: #8b1f1f; }
.h5p-note { margin: .8rem 0 0; color: var(--muted); font-size: .82rem; }
.h5p-download { margin-left: .35rem; color: var(--blue); font-weight: 800; }
.lesson-nav { display: flex; justify-content: space-between; gap: 1rem; margin-top: 2rem; }
.lesson-nav a { padding: .7rem 1rem; border: 1px solid var(--line); border-radius: 10px; background: #fff; font-weight: 800; text-decoration: none; }

@media (max-width: 760px) {
  .hamilton-hero-grid, .hamilton-intro { grid-template-columns: 1fr; }
  .hamilton-hero img, .hamilton-portrait { justify-self: start; }
  .hamilton-tracks { grid-template-columns: 1fr; }
  .hamilton-track { grid-template-columns: 34px minmax(0,1fr); }
  .hamilton-track small { grid-column: 2; }
}
