/* =========================================================
   PASSAGE STUDIO — Paper Classroom theme
   (Mirrors the Weekly Planner aesthetic: paper-cut, crayon
   primaries, thick ink outlines, 3D drop shadows.)
   ========================================================= */

:root {
  /* Palette */
  --paper:        #fbf3df;
  --paper-warm:   #fae9c8;
  --paper-dark:   #2a2438;
  --ink:          #2a2438;
  --ink-soft:     #5a4f6a;
  --line:         #2a2438;

  /* Tool category colors (crayon primaries) */
  --c-decodable:  #ff7aa9;  /* decodable passages — pink */
  --c-reading:    #ffc24c;  /* reading passages — yellow */
  --c-phonics:    #5cd6b1;  /* phonics worksheets — teal */
  --c-worksheet:  #5ea7ff;  /* reading worksheets — blue */
  --c-assess:     #b07cff;  /* assessments — purple */
  --c-parents:    #ff945c;  /* parent letters — orange */
  --c-extras:     #c79fff;  /* extras — lavender */
  --c-fluency:    #a7e34f;  /* fluency drills — lime */

  /* Sky */
  --sky-1: #ffeec5;
  --sky-2: #ffd6e0;
  --sky-3: #cfe8ff;

  /* 3D shadows */
  --shadow-card:  6px 8px 0 var(--ink);
  --shadow-pop:   10px 14px 0 var(--ink);
  --shadow-soft:  0 18px 36px rgba(42, 36, 56, .18);

  --radius:       18px;
  --radius-lg:    28px;
  --radius-pill:  999px;
}

[data-theme="plasticine"] {
  --paper:      #f6efe0;
  --paper-warm: #f1e3c5;
  --ink:        #3a2c4a;
  --line:       #3a2c4a;
  --c-decodable: #ff8fa6; --c-reading: #ffd06b; --c-phonics: #82e0c2;
  --c-worksheet: #8fb9ff; --c-assess: #c79fff;
}

[data-theme="chalkboard"] {
  --paper:      #1f3a36;
  --paper-warm: #2c4842;
  --ink:        #fff7e0;
  --ink-soft:   #d6cca8;
  --line:       #fff7e0;
  --sky-1: #1a322f; --sky-2: #25433d; --sky-3: #18302c;
  --shadow-card: 4px 6px 0 rgba(0,0,0,.5);
  --shadow-pop:  8px 10px 0 rgba(0,0,0,.6);
}

[data-theme="blocks"] {
  --paper:      #fff3d6;
  --paper-warm: #ffe3a3;
  --c-decodable: #e3433f; --c-reading: #f5b316; --c-phonics: #3aa86b;
  --c-worksheet: #2f7adc; --c-assess: #8b50d6;
}

/* =========================================================
   Base
   ========================================================= */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: "Baloo 2", "Fredoka", ui-rounded, system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overscroll-behavior-x: none;
}

body {
  background:
    radial-gradient(1200px 800px at 12% 0%, var(--sky-1) 0%, transparent 55%),
    radial-gradient(900px 700px at 92% 8%, var(--sky-2) 0%, transparent 50%),
    radial-gradient(900px 700px at 60% 100%, var(--sky-3) 0%, transparent 55%),
    var(--paper);
}

button, input, select, textarea {
  font-family: inherit;
  color: inherit;
}

button {
  border: 0;
  background: none;
  cursor: pointer;
  font-weight: 600;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3 { font-family: "Fredoka", sans-serif; font-weight: 600; margin: 0; }

[data-motion="low"] *,
[data-motion="low"] *::before,
[data-motion="low"] *::after {
  animation-duration: 0.001s !important;
  transition-duration: 100ms !important;
}

/* =========================================================
   App layout
   ========================================================= */

#root {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  z-index: 1;
}

.app {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 22px 28px 100px;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 18px;
  max-width: 1620px;
  margin: 0 auto;
}

/* =========================================================
   Top bar
   ========================================================= */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  position: relative;
  background: var(--paper-warm);
  border: 3px solid var(--ink);
  border-radius: 18px;
  box-shadow: var(--shadow-card);
  transform: rotate(-4deg);
}
.brand-mark svg { width: 36px; height: 36px; }

.brand h1 {
  font-size: 36px;
  line-height: 1;
  letter-spacing: -0.5px;
  font-family: "Fredoka", sans-serif;
  font-weight: 700;
}
.brand .subline {
  font-size: 15px;
  color: var(--ink-soft);
  font-weight: 600;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand .subline .pin {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--c-reading);
  border: 2px solid var(--ink);
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-card);
  font-weight: 700;
  font-size: 15px;
  transition: transform .15s ease, box-shadow .15s ease;
}
.tool-btn:hover {
  transform: translate(-2px, -2px);
  box-shadow: 8px 10px 0 var(--ink);
}
.tool-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 3px 0 var(--ink);
}
.tool-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: var(--shadow-card); }
.tool-btn.icon-only { padding: 10px; }
.tool-btn svg { width: 18px; height: 18px; }

.tool-btn.tb-primary  { background: var(--c-phonics); }
.tool-btn.tb-back     { background: var(--paper-warm); }
.tool-btn.tb-danger   { background: var(--c-decodable); color: #fff; }
.tool-btn.tb-danger svg { stroke: #fff; }
.tool-btn.account-chip {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: #fff;
}

.sync-line {
  margin-top: -8px;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 800;
}

/* =========================================================
   Account gate
   ========================================================= */

.auth-page {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(22px, env(safe-area-inset-top)) max(22px, env(safe-area-inset-right)) max(22px, env(safe-area-inset-bottom)) max(22px, env(safe-area-inset-left));
  overflow: hidden;
}

.auth-card {
  position: relative;
  z-index: 3;
  width: min(520px, 100%);
  padding: 28px;
  border: 3px solid var(--ink);
  border-radius: var(--radius-lg);
  background: rgba(255, 250, 240, 0.94);
  box-shadow: var(--shadow-pop);
}

.auth-brand { align-items: flex-start; margin-bottom: 22px; }
.auth-brand h1 { font-size: 34px; }

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}
.auth-tabs button {
  padding: 10px 12px;
  border: 3px solid var(--ink);
  border-radius: var(--radius-pill);
  background: #fff;
  box-shadow: 4px 5px 0 var(--ink);
}
.auth-tabs button.active { background: var(--c-reading); }

.auth-field { display: grid; gap: 6px; margin-bottom: 13px; }
.auth-field span {
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.auth-field input {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 3px solid rgba(42, 36, 56, 0.5);
  border-radius: 16px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
}

.auth-error {
  margin: 8px 0 12px;
  padding: 10px 12px;
  border: 3px solid var(--ink);
  border-radius: 16px;
  background: #ffe0e8;
  color: var(--ink);
  font-weight: 700;
  font-size: 14px;
  line-height: 1.4;
  overflow-wrap: break-word;
  word-break: break-word;
  min-width: 0;
}

.auth-submit {
  width: 100%;
  justify-content: center;
  margin-top: 4px;
  background: var(--c-phonics);
}

.auth-note {
  margin-top: 14px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

/* =========================================================
   Tools gallery (landing grid)
   ========================================================= */

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 22px;
  padding: 8px 0 24px;
}

.tool-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 22px 22px 24px;
  background: var(--card-color, #fff);
  border: 3px solid var(--ink);
  border-radius: 22px;
  box-shadow: var(--shadow-card);
  cursor: pointer;
  transform: rotate(var(--rot, -0.6deg));
  transition: transform .2s cubic-bezier(.34,1.56,.64,1), box-shadow .2s ease;
  text-align: left;
  font: inherit;
  color: inherit;
  overflow: hidden;
}
.tool-card:hover {
  transform: rotate(0deg) translate(-3px, -4px);
  box-shadow: 10px 12px 0 var(--ink);
}
.tool-card:active {
  transform: rotate(0deg) translate(2px, 3px);
  box-shadow: 3px 4px 0 var(--ink);
}
.tool-card.coming-soon {
  cursor: not-allowed;
  opacity: 0.78;
}
.tool-card.coming-soon:hover {
  transform: rotate(var(--rot, -0.6deg));
  box-shadow: var(--shadow-card);
}

.tool-card .tape {
  position: absolute;
  width: 64px;
  height: 18px;
  background: rgba(255, 220, 120, .8);
  border: 1px dashed rgba(42,36,56,.4);
  border-left: 1px solid rgba(42,36,56,.2);
  border-right: 1px solid rgba(42,36,56,.2);
  top: -8px;
  left: 50%;
  transform: translateX(-50%) rotate(-3deg);
  z-index: 2;
  pointer-events: none;
}

.tool-card .tc-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: rgba(255,255,255,.92);
  border: 3px solid var(--ink);
  display: grid;
  place-items: center;
  box-shadow: 3px 4px 0 var(--ink);
}
.tool-card .tc-icon svg { width: 30px; height: 30px; }

.tool-card .tc-title {
  font-family: "Fredoka", sans-serif;
  font-weight: 700;
  font-size: 22px;
  line-height: 1.1;
}
.tool-card .tc-desc {
  font-size: 14px;
  font-weight: 600;
  color: rgba(42,36,56,.78);
  line-height: 1.35;
}
.tool-card .tc-tag {
  position: absolute;
  top: 18px;
  right: 18px;
  background: rgba(255,255,255,.85);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
}
.tool-card .tc-tag.live  { background: var(--c-phonics); }
.tool-card .tc-tag.soon  { background: var(--paper-warm); }

.gallery-intro {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 18px 22px;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  margin-bottom: 6px;
}
.gallery-intro .gi-mark {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  border-radius: 14px;
  background: var(--c-reading);
  border: 3px solid var(--ink);
  display: grid;
  place-items: center;
  box-shadow: 3px 4px 0 var(--ink);
}
.gallery-intro .gi-mark svg { width: 30px; height: 30px; }
.gallery-intro p {
  margin: 0;
  font-weight: 600;
  font-size: 15px;
  color: var(--ink);
  line-height: 1.45;
}
.gallery-intro p strong { color: var(--ink); }

/* =========================================================
   Workspace layout (tool detail page)
   ========================================================= */

.workspace {
  display: grid;
  /* minmax(0, 1fr) is critical — without the 0 lower bound, the right
     column's content can push the column wider than the grid intends,
     causing it to bleed into / overlap the controls column. */
  grid-template-columns: minmax(340px, 400px) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}
@media (max-width: 980px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
}

.ws-controls {
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 20px;
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

/* ===== Week hero — the primary control ===== */

.ws-week-hero {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  background: var(--paper-warm);
  border: 2.5px solid var(--ink);
  border-radius: 18px;
  padding: 12px 14px;
  box-shadow: 3px 4px 0 var(--ink);
}
.ws-week-badge {
  flex-shrink: 0;
  min-width: 60px; height: 56px;
  padding: 0 10px;
  display: grid;
  place-items: center;
  background: var(--c-decodable);
  color: #fff;
  border: 2.5px solid var(--ink);
  border-radius: 14px;
  font-family: "Fredoka", sans-serif;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: 2px 3px 0 var(--ink);
  white-space: nowrap;
}
.ws-week-info {
  min-width: 0;
  display: grid;
  gap: 2px;
  overflow: hidden;
}
.ws-week-title {
  font-size: 15px;
  font-weight: 800;
  font-family: "Fredoka", sans-serif;
  color: var(--ink);
}
.ws-week-unit {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.ws-scope-btn {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  gap: 0;
  background: #fff;
  border: 2.5px solid var(--ink);
  border-radius: 14px;
  padding: 8px 10px;
  cursor: pointer;
  font-family: "Fredoka", sans-serif;
  color: var(--ink);
  box-shadow: 2px 3px 0 var(--ink);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
  min-width: 64px;
}
.ws-scope-btn:hover {
  transform: translate(-1px, -1px);
  box-shadow: 3px 4px 0 var(--ink);
  background: #fffbe6;
}
.ws-scope-btn:active {
  transform: translate(1px, 1px);
  box-shadow: 1px 2px 0 var(--ink);
}
.ws-scope-count {
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
}
.ws-scope-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 2px;
}

/* ===== Grouped sections (Scope / Content / Output) ===== */

.ws-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}
.ws-group:first-child { margin-top: 0; }

.ws-group-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  padding: 0 2px;
}
.ws-group-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  display: inline-block;
  flex-shrink: 0;
}

.ws-row-tight { gap: 8px; margin-bottom: 0; }
.ws-scope-row {
  grid-template-columns: minmax(0, 1fr) minmax(104px, 128px);
}
.ws-field-compact label { font-size: 11px; }

.ws-mini-label {
  display: block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 4px;
}
.ws-mode-wrap {
  display: flex;
  flex-direction: column;
}

.ws-adv-toggle {
  margin-top: 2px;
  background: transparent;
  border: 2px dashed rgba(42,36,56,0.2);
  border-radius: 12px;
  padding: 8px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: "Fredoka", sans-serif;
  font-weight: 800;
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
}
.ws-adv-toggle:hover { border-color: var(--ink); color: var(--ink); }

/* ===== History trigger button + drawer ===== */

.ws-history-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  margin-top: 12px;
  background: #fff;
  border: 2.5px solid var(--ink);
  border-radius: 14px;
  box-shadow: 2px 3px 0 var(--ink);
  font-family: "Fredoka", sans-serif;
  font-size: 14px;
  font-weight: 800;
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.ws-history-btn:hover {
  transform: translate(-1px, -1px);
  box-shadow: 3px 4px 0 var(--ink);
  background: #fffbe6;
}
.ws-history-btn:active {
  transform: translate(1px, 1px);
  box-shadow: 1px 2px 0 var(--ink);
}
.ws-history-icon {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  font-size: 18px;
  color: var(--c-phonics);
}
.ws-history-count {
  margin-left: auto;
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  padding: 2px 8px;
  background: var(--ink);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  border-radius: 999px;
}

.history-drawer-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 18px 32px;
}
.history-card {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  width: 100%;
  padding: 12px 14px;
  background: #fff;
  border: 2.5px solid var(--ink);
  border-radius: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.08s ease, box-shadow 0.08s ease, background 0.08s ease;
  box-shadow: 2px 2px 0 var(--ink);
}
.history-card:hover {
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 var(--ink);
  background: #fffbe6;
}
.history-card.is-current {
  background: #e8f7ee;
  box-shadow: 2px 2px 0 var(--ink), 0 0 0 3px rgba(46,207,145,0.3);
}
.history-card-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.history-card-title {
  font-weight: 800;
  font-size: 14px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-card-meta {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-soft);
}

/* ===== Scope drawer ===== */

.scope-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(42, 36, 56, 0.45);
  z-index: 9000;
  display: flex;
  justify-content: flex-end;
  animation: scope-drawer-fade 0.18s ease;
}
@keyframes scope-drawer-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.scope-drawer {
  width: min(420px, 100vw);
  height: 100vh;
  background: var(--paper-warm);
  border-left: 3px solid var(--ink);
  box-shadow: -6px 0 0 rgba(42,36,56,0.2);
  display: flex;
  flex-direction: column;
  animation: scope-drawer-slide 0.22s cubic-bezier(.2,.8,.2,1);
}
@keyframes scope-drawer-slide {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}
.scope-drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 20px 14px;
  border-bottom: 2.5px solid var(--ink);
  background: #fffaeb;
}
.scope-drawer-eyebrow {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--c-decodable);
}
.scope-drawer-title {
  font-family: "Fredoka", sans-serif;
  font-size: 22px;
  margin: 2px 0 4px;
  font-weight: 800;
  color: var(--ink);
}
.scope-drawer-sub {
  font-size: 12px;
  color: var(--ink-soft);
  font-weight: 700;
}
.scope-drawer-close {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 2.5px solid var(--ink);
  background: #fff;
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--ink);
  flex-shrink: 0;
}
.scope-drawer-close:hover { background: #ffe0e8; }
.scope-drawer-close:active { transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--ink); }
.scope-drawer-body {
  overflow-y: auto;
  padding: 16px 20px 32px;
  flex: 1;
}
.scope-group {
  margin-bottom: 22px;
}
.scope-group h3 {
  font-family: "Fredoka", sans-serif;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.scope-group-count {
  background: var(--ink);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: 0;
}
.scope-group:first-of-type h3 {
  color: var(--c-decodable);
}

@media (max-width: 640px) {
  .ws-week-hero {
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
  }
  .ws-scope-btn {
    grid-column: 1 / -1;
    flex-direction: row;
    justify-content: center;
    gap: 8px;
  }
  .ws-scope-btn .ws-scope-count { font-size: 14px; }
  .ws-scope-btn .ws-scope-label { margin-top: 0; }
}

/* ===== Sections with colored left bar ===== */

.ws-section {
  display: flex;
  gap: 0;
  min-width: 0;
}
.ws-section-bar {
  flex-shrink: 0;
  width: 5px;
  border-radius: 5px;
  background: var(--accent, var(--c-reading));
  margin-right: 14px;
}
.ws-section-body {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 10px;
}
.ws-adv-fields {
  display: grid;
  gap: 10px;
}

.ws-group-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 4px 0;
  background: transparent;
  border: 0;
  text-align: left;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  cursor: pointer;
}
.ws-group-toggle:hover { color: var(--c-assess); }
.ws-chev {
  display: inline-grid;
  place-items: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--paper-warm);
  border: 2px solid var(--ink);
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: none;
  line-height: 1;
}

/* Field label hints */
.ws-field label .ws-hint,
.ws-hint {
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  color: rgba(90, 79, 106, 0.7);
  font-size: 11px;
}

/* ===== Generate CTA ===== */

.ws-cta {
  display: grid;
  gap: 8px;
  padding-top: 12px;
  border-top: 2px dashed rgba(42,36,56,.12);
}
.ws-mode {
  display: inline-flex;
  gap: 0;
  margin-top: 10px;
  padding: 3px;
  background: #fef6e5;
  border: 2px solid var(--ink);
  border-radius: 999px;
  align-self: stretch;
  width: 100%;
  box-sizing: border-box;
}
.ws-mode-opt {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  transition: background 0.15s ease, color 0.15s ease;
  white-space: nowrap;
  min-width: 0;
}
.ws-mode-opt:hover:not(:disabled):not(.active) {
  color: var(--ink);
  background: rgba(42,36,56,0.06);
}
.ws-mode-opt:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.ws-mode-opt.active {
  background: var(--ink);
  color: #fff;
  box-shadow: 1px 2px 0 rgba(42,36,56,0.2);
}
.ws-mode-opt .ws-mode-label {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.02em;
}
.ws-mode-opt .ws-mode-sub {
  font-size: 10px;
  font-weight: 700;
  color: inherit;
  opacity: 0.7;
  letter-spacing: 0.02em;
  text-transform: lowercase;
  display: none;
}
.ws-mode-opt.active .ws-mode-sub { display: inline; }
@media (min-width: 480px) {
  .ws-mode-opt .ws-mode-sub { display: inline; }
}
.ws-model-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 11px;
  font-weight: 800;
}
.ws-model-name {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--ink);
  background: var(--paper-warm);
  border: 1.5px solid var(--ink);
  padding: 1px 7px;
  border-radius: 999px;
}
.ws-model-tag {
  font-size: 10px;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1.5px solid var(--ink);
  letter-spacing: 0.06em;
}
.ws-model-tag.ok   { background: var(--c-phonics); color: var(--ink); }
.ws-model-tag.warn { background: var(--c-decodable); color: #fff; }
.ws-model-fallback {
  font-weight: 700;
  color: var(--ink-soft);
  text-transform: lowercase;
  letter-spacing: 0;
}

/* Recent section */
.ws-section-recent .history-list {
  max-height: 240px;
  overflow-y: auto;
}

.ws-field { display: grid; gap: 5px; }
.ws-field label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.ws-field input,
.ws-field select,
.ws-field textarea {
  border: 2.5px solid var(--ink);
  border-radius: 10px;
  background: #fff;
  padding: 8px 10px;
  font-size: 14px;
  font-weight: 600;
  outline: none;
  box-shadow: inset 0 -2px 0 rgba(42,36,56,.05);
}
.ws-field textarea { resize: vertical; min-height: 68px; line-height: 1.4; }
.ws-field input:focus,
.ws-field select:focus,
.ws-field textarea:focus {
  box-shadow: 3px 4px 0 var(--ink);
  transform: translate(-1px,-1px);
}

.ws-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.ws-generate {
  width: 100%;
  justify-content: center;
  background: var(--c-decodable);
  color: #fff;
  font-size: 16px;
  padding: 14px 18px;
}
.ws-generate svg { stroke: #fff; }
.ws-generate:disabled { background: var(--paper-warm); color: var(--ink); }
.ws-generate:disabled svg { stroke: var(--ink); }

/* Scope chips — show graphemes in-scope */
.scope-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-height: 110px;
  overflow-y: auto;
  overflow-x: hidden;     /* never escape the column */
  padding: 6px;
  border: 2px dashed rgba(42,36,56,.35);
  border-radius: 10px;
  background: rgba(255,255,255,.6);
  width: 100%;
  box-sizing: border-box;
  min-width: 0;
}
.scope-chip {
  font-size: 12px;
  font-weight: 800;
  padding: 2px 9px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  background: var(--paper-warm);
  letter-spacing: 0.04em;
  font-family: "Fredoka", sans-serif;
}
.scope-chip.new { background: var(--c-phonics); }

/* =========================================================
   Output panel: passage preview + agent trace
   ========================================================= */

.ws-output {
  display: grid;
  gap: 18px;
  /* Don't let the right column's contents push the column wider than its
     grid track. Required when the parent grid uses minmax(0, 1fr). */
  min-width: 0;
}

.ws-output > * {
  /* Same defensive constraint for every direct child card. */
  min-width: 0;
  max-width: 100%;
}

.passage-card {
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  padding: 26px 28px;
  position: relative;
  overflow: hidden;
  min-width: 0;
}
.passage-card .pc-title {
  font-family: "Fredoka", sans-serif;
  font-weight: 700;
  font-size: 26px;
  line-height: 1.1;
  margin-bottom: 14px;
  padding-right: 80px;
}
.passage-card .pc-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.passage-card .pc-meta .meta-pill {
  font-size: 11px;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  background: var(--paper-warm);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.passage-card .pc-meta .meta-pill.ok { background: var(--c-phonics); }
.passage-card .pc-meta .meta-pill.warn { background: var(--c-reading); }
.passage-card .pc-meta .meta-pill.fail { background: var(--c-decodable); color: #fff; }
.passage-card .pc-meta .meta-pill.ccss {
  background: #fff;
  border-color: var(--ink);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
  letter-spacing: 0.3px;
}

.passage-body {
  font-family: "Baloo 2", sans-serif;
  font-size: 19px;
  line-height: 1.7;
  font-weight: 500;
  color: var(--ink);
  white-space: pre-wrap;
  word-wrap: break-word;
}
.passage-body .target { background: rgba(92, 214, 177, 0.42); border-radius: 4px; padding: 0 2px; font-weight: 700; }
.passage-body .sight  { background: rgba(255, 194, 76, 0.42); border-radius: 4px; padding: 0 2px; }
.passage-body .untaught { background: rgba(255, 122, 169, 0.45); border-radius: 4px; padding: 0 2px; text-decoration: underline wavy var(--ink); }

/* =========================================================
   Word-building / pre-decodable artifact card (early weeks)
   ========================================================= */
.passage-card .pc-meta .meta-pill.wordbuilding { background: var(--c-phonics); }
.scope-artifact-card .sa-body { display: grid; gap: 16px; }
.sa-section { display: grid; gap: 7px; }
.sa-label {
  font-family: "Fredoka", sans-serif;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.04em;
  opacity: 0.7;
  text-transform: uppercase;
}
.sa-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.sa-chip {
  font-family: "Fredoka", sans-serif;
  font-weight: 800;
  font-size: 16px;
  padding: 4px 12px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  background: var(--paper-warm);
}
.sa-chip em { font-style: normal; font-weight: 600; opacity: 0.55; font-size: 13px; }
.sa-chip.grapheme-chip { background: var(--c-phonics); font-size: 18px; }
.sa-chip.heart-chip { background: rgba(255, 194, 76, 0.55); }
.sa-chip.word-chip { background: #fff; }
.sa-chain { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; margin-bottom: 4px; }
.sa-arrow { font-weight: 800; opacity: 0.5; }
.sa-sentences { display: grid; gap: 6px; }
.sa-sentence {
  font-family: "Baloo 2", sans-serif;
  font-size: 19px;
  line-height: 1.5;
  padding: 6px 12px;
  background: var(--paper-warm);
  border-radius: 10px;
  border: 2px dashed rgba(42,36,56,.25);
}
.sa-note {
  font-family: "Baloo 2", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  opacity: 0.85;
  padding: 10px 12px;
  background: rgba(255,255,255,.6);
  border-left: 4px solid var(--c-reading);
  border-radius: 6px;
}
.ws-empty.ws-error h3 { color: var(--c-decodable); }
.ws-empty.ws-error .tool-btn { margin-top: 6px; }

/* ── Letter & Sound Lesson card ── */
.sa-intro {
  font-family: "Baloo 2", sans-serif; font-size: 15px; line-height: 1.5;
  padding: 10px 14px; background: rgba(130,224,194,.18);
  border-left: 4px solid var(--c-phonics); border-radius: 8px;
}
.sa-sounds { display: grid; gap: 12px; }
.sa-sound {
  border: 2px solid var(--ink); border-radius: 14px; padding: 14px 16px;
  background: #fff; box-shadow: 3px 3px 0 var(--ink);
}
.sa-sound-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 8px; }
.sa-letter { font-family: "Fredoka", sans-serif; font-weight: 800; font-size: 26px; letter-spacing: 1px; }
.sa-phoneme { font-family: ui-monospace, Menlo, monospace; font-size: 17px; font-weight: 700; background: var(--c-phonics); border: 2px solid var(--ink); border-radius: 999px; padding: 1px 10px; }
.sa-type { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; padding: 2px 9px; border-radius: 999px; border: 2px solid var(--ink); }
.sa-type-continuous { background: #d6f5e8; }
.sa-type-stop { background: #ffe0e9; }
.sa-type-vowel { background: #fff0c2; }
.sa-keyword { font-family: "Baloo 2", sans-serif; font-size: 15px; opacity: .8; }
.sa-keyword strong { opacity: 1; }
.sa-diff { margin-left: auto; font-size: 11px; font-weight: 800; padding: 2px 9px; border-radius: 999px; border: 2px solid var(--ink); }
.sa-diff-easy { background: var(--c-phonics); }
.sa-diff-watch { background: var(--c-reading); }
.sa-sound-row { display: flex; gap: 8px; align-items: baseline; font-family: "Baloo 2", sans-serif; font-size: 15px; line-height: 1.45; margin-top: 5px; }
.sa-ic { flex: 0 0 auto; }
.sa-blend { opacity: .85; font-size: 14px; }
.sa-l1 {
  display: flex; gap: 8px; align-items: baseline; margin-top: 8px;
  font-family: "Baloo 2", sans-serif; font-size: 15px; line-height: 1.45;
  padding: 8px 11px; border-radius: 10px; border: 2px solid var(--ink);
}
.sa-l1-easy { background: rgba(130,224,194,.30); }
.sa-l1-watch { background: rgba(255,194,76,.32); }
.sa-wordbank { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.sa-alphabet { display: flex; flex-wrap: wrap; gap: 6px; }
.sa-alpha {
  display: inline-flex; gap: 2px; align-items: baseline;
  font-family: "Fredoka", sans-serif; font-size: 15px; font-weight: 600;
  border: 2px solid var(--ink); border-radius: 8px; padding: 4px 8px; background: var(--paper-warm);
}
.sa-alpha b { font-weight: 800; }
.sa-activity {
  font-family: "Baloo 2", sans-serif; font-size: 15px; line-height: 1.5;
  padding: 9px 12px; background: var(--paper-warm); border-radius: 10px; border: 2px dashed rgba(42,36,56,.25);
}
.sa-heart { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; margin-bottom: 6px; }
.sa-heart-tip { font-family: "Baloo 2", sans-serif; font-size: 14.5px; opacity: .85; }
.sa-list { margin: 0; padding-left: 20px; font-family: "Baloo 2", sans-serif; font-size: 15px; line-height: 1.6; }
.sa-list li { margin-bottom: 2px; }
.sa-chip.review-chip { background: rgba(130,224,194,.4); font-size: 15px; }
.sa-parent .sa-activity { background: rgba(255,122,169,.14); border-color: rgba(255,122,169,.45); border-style: solid; }
.ws-mode-hint {
  font-family: "Baloo 2", sans-serif; font-size: 14px; line-height: 1.5; opacity: .8;
  padding: 12px 14px; background: rgba(255,255,255,.55);
  border: 2px dashed rgba(42,36,56,.3); border-radius: 12px;
}
.sa-stack { display: grid; gap: 6px; }

/* ── Student / Teacher view toggle (keeps the two outputs separate) ── */
.sa-view-toggle {
  display: inline-flex; gap: 4px; margin: 0 0 16px; padding: 4px;
  background: rgba(255,255,255,.7); border: 2px solid var(--ink); border-radius: 999px;
  box-shadow: 3px 3px 0 var(--ink);
}
.sa-vt {
  font-family: "Fredoka", sans-serif; font-weight: 700; font-size: 14px; color: var(--ink);
  border: none; background: transparent; cursor: pointer; padding: 8px 18px; border-radius: 999px; line-height: 1;
}
.sa-vt.active { background: var(--c-phonics); box-shadow: 2px 2px 0 var(--ink); }

/* Only one view shows at a time; the student resource is the printable default */
.sa-student { display: grid; gap: 22px; }
.sa-views .sa-teacher { display: none; }
.sa-views.view-teacher .sa-teacher { display: grid; gap: 16px; }
.sa-views.view-teacher .sa-student { display: none; }

/* ── Student materials: big, bold, picture-forward for 5-year-olds ── */
.sa-student .sa-label {
  font-family: "Fredoka", sans-serif; font-size: 19px; font-weight: 800; opacity: 1;
  letter-spacing: .2px; margin-bottom: 10px;
}
.sa-cards { display: flex; flex-wrap: wrap; gap: 16px; }
.sa-card {
  width: 158px; text-align: center; border: 3px solid var(--ink); border-radius: 18px;
  background: #fff; box-shadow: 5px 5px 0 var(--ink); padding: 16px 10px;
}
.sa-card-letter { font-family: "Fredoka", sans-serif; font-weight: 800; font-size: 58px; line-height: 1; letter-spacing: 3px; }
.sa-card-pic { font-size: 56px; line-height: 1.25; }
/* Card art is a Twemoji SVG — sized to match the old emoji glyph, never distorts. */
.sa-card-pic img { width: 52px; height: 52px; display: block; margin: 0 auto; }
.sa-heart-card .sa-card-pic img { width: 42px; height: 42px; }
.sa-card-word { font-family: "Baloo 2", sans-serif; font-size: 21px; font-weight: 600; margin-top: 2px; }
.sa-heart-card { background: rgba(255,194,76,.18); }
.sa-heart-card .sa-card-pic { font-size: 44px; }
.sa-heart-word { font-family: "Fredoka", sans-serif; font-weight: 800; font-size: 36px; line-height: 1.05; letter-spacing: 1px; margin-top: 4px; }
.sa-blend-lines { display: grid; gap: 12px; }
.sa-blend-line {
  display: flex; flex-wrap: wrap; gap: 26px; padding: 14px 20px; align-items: center;
  background: var(--paper-warm); border: 2px solid var(--ink); border-radius: 14px;
}
.sa-blend-line:nth-child(even) { background: rgba(130,224,194,.16); }
.sa-blend-word { font-family: "Fredoka", sans-serif; font-weight: 700; font-size: 30px; letter-spacing: 1.5px; }
.sa-boxes { display: flex; flex-wrap: wrap; gap: 26px; }
.sa-box-word { text-align: center; }
.sa-box-row { display: flex; }
.sa-box { width: 46px; height: 46px; border: 3px solid var(--ink); background: #fff; margin-right: -3px; }
.sa-box:first-child { border-top-left-radius: 8px; border-bottom-left-radius: 8px; }
.sa-box:last-child { border-top-right-radius: 8px; border-bottom-right-radius: 8px; margin-right: 0; }
.sa-box-key { font-family: "Fredoka", sans-serif; font-size: 18px; font-weight: 700; opacity: .55; margin-top: 5px; letter-spacing: 1.5px; }
.sa-student .sa-alphabet { gap: 9px; }
.sa-student .sa-alpha { font-size: 20px; padding: 7px 11px; border-radius: 10px; }
.sa-student .sa-sentence { font-size: 24px; line-height: 1.6; padding: 12px 18px; }
.sa-student .sa-chain { gap: 14px; margin-bottom: 12px; }
.sa-student .sa-arrow { font-size: 28px; opacity: .4; }

/* =========================================================
   Student worksheet sheet — the printable, hand-to-a-kid page.
   Always white paper with near-black ink regardless of app theme,
   so what you see on screen is exactly what prints.
   ========================================================= */

.sheet {
  --sheet-ink:  #1d1d28;
  --sheet-soft: #6b6b78;
  --sheet-rule: #b9b9c6;
  background: #fff;
  color: var(--sheet-ink);
  border: 2.5px solid #1d1d28;
  border-radius: 16px;
  box-shadow: 5px 5px 0 rgba(29, 29, 40, .14);
  padding: 26px 32px 18px;
  max-width: 740px;
  margin: 0 auto;
}

/* Name / Date header */
.sheet-top { display: flex; align-items: flex-end; gap: 10px; margin-bottom: 16px; }
.sheet-id-label {
  font-family: "Fredoka", sans-serif; font-weight: 700; font-size: 13px;
  text-transform: uppercase; letter-spacing: .08em; color: var(--sheet-soft);
}
.sheet-id-line { flex: 1 1 auto; border-bottom: 2px solid var(--sheet-ink); height: 24px; }
.sheet-id-line-sm { flex: 0 0 132px; }

/* Footer strip */
.sheet-foot {
  display: flex; justify-content: space-between; gap: 12px;
  border-top: 1.5px solid var(--sheet-rule); margin-top: 8px; padding-top: 8px;
  font-family: "Fredoka", sans-serif; font-weight: 600; font-size: 11px;
  letter-spacing: .06em; text-transform: uppercase; color: var(--sheet-soft);
}

/* Worksheet title */
.wks-title {
  font-family: "Fredoka", sans-serif; font-weight: 700; font-size: 30px;
  line-height: 1.15; text-align: center; margin: 2px 0 18px; color: var(--sheet-ink);
}

/* Warm-up row: focus sounds + words to read first */
.wks-warmup { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 18px; }
.wks-block { border: 2px solid var(--sheet-ink); border-radius: 14px; padding: 12px 14px; }
.wks-block-sounds { flex: 0 1 auto; min-width: 168px; background: rgba(92, 214, 177, .18); }
.wks-block-words { flex: 1 1 240px; background: rgba(255, 194, 76, .15); }
.wks-sec-label {
  font-family: "Fredoka", sans-serif; font-weight: 700; font-size: 12.5px;
  text-transform: uppercase; letter-spacing: .09em; color: var(--sheet-soft);
  margin-bottom: 8px;
}
.wks-chips { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; }
.wks-sound {
  font-family: "Fredoka", sans-serif; font-weight: 700; font-size: 24px; line-height: 1;
  padding: 9px 14px; background: #fff; border: 2.5px solid var(--sheet-ink);
  border-radius: 12px; letter-spacing: 1px;
}
.wks-word {
  font-family: "Andika", "Baloo 2", sans-serif; font-weight: 700; font-size: 19px;
  line-height: 1; padding: 8px 13px; background: #fff;
  border: 2px solid var(--sheet-ink); border-radius: 10px;
}

/* The passage itself — Andika is designed for beginning readers.
   Type scale steps down as readers mature. */
.wks-passage {
  font-family: "Andika", "Baloo 2", sans-serif;
  white-space: pre-wrap; word-wrap: break-word;
  margin: 4px 2px 18px; color: var(--sheet-ink);
}
.wks-kg .wks-passage { font-size: 26px; line-height: 2.05; word-spacing: .12em; }
.wks-g1 .wks-passage { font-size: 22px; line-height: 1.92; word-spacing: .06em; }
.wks-g2 .wks-passage { font-size: 18px; line-height: 1.8; }

/* Fluency re-read tracker */
.wks-reread {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 14px; border: 2px dashed var(--sheet-rule); border-radius: 12px;
  margin-bottom: 18px;
}
.wks-reread .wks-sec-label { margin: 0 6px 0 0; }
.wks-star { display: inline-flex; color: var(--sheet-ink); }
.wks-reread-hint {
  font-family: "Baloo 2", sans-serif; font-size: 13.5px; font-weight: 600;
  color: var(--sheet-soft); margin-left: auto;
}

/* Comprehension questions with writing lines */
.wks-questions { margin-bottom: 16px; }
.wks-q-list {
  margin: 0; padding-left: 24px; display: grid; gap: 16px;
  font-family: "Fredoka", sans-serif;
}
.wks-q-list li::marker { font-weight: 700; }
.wks-q {
  font-family: "Andika", "Baloo 2", sans-serif; font-weight: 700;
  font-size: 17px; line-height: 1.5; margin-bottom: 4px;
}
.wks-kg .wks-q { font-size: 19px; }
.wks-write-line { height: 34px; border-bottom: 2px solid var(--sheet-rule); }
.wks-kg .wks-write-line { height: 44px; }

/* KG draw-the-story box */
.wks-draw { margin-bottom: 16px; }
.wks-draw-box { height: 230px; border: 2.5px dashed var(--sheet-rule); border-radius: 14px; background: #fff; }

/* Passage card: student worksheet ⇄ teacher annotated view */
.pc-views .pc-teacher { display: none; }
.pc-views.view-teacher .pc-teacher { display: block; }
.pc-views.view-teacher .pc-student { display: none; }
.pc-legend {
  display: flex; flex-wrap: wrap; gap: 14px; margin-top: 14px;
  font-family: "Baloo 2", sans-serif; font-size: 13.5px; font-weight: 600;
  color: var(--ink-soft);
}
.pc-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.pc-swatch { width: 14px; height: 14px; border-radius: 4px; border: 1.5px solid var(--ink); display: inline-block; }
.pc-swatch.target { background: rgba(92, 214, 177, .42); }
.pc-swatch.sight { background: rgba(255, 194, 76, .42); }
.pc-swatch.untaught { background: rgba(255, 122, 169, .45); }

/* Letter/word-card sheet: cut-out hints + sheet-aware spacing */
.sa-cut-hint {
  font-family: "Baloo 2", sans-serif; font-size: 13px; font-weight: 600;
  color: var(--sheet-soft); text-transform: none; letter-spacing: 0; margin-left: 8px;
}
.sa-student.sheet { display: grid; gap: 20px; }
.sa-student.sheet .wks-title { margin: -4px 0 0; }
.sa-student.sheet .sa-label { color: var(--sheet-ink); }
.sa-student.sheet .sa-card { box-shadow: 3px 3px 0 rgba(29, 29, 40, .16); }

.passage-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 2px dashed rgba(42,36,56,.2);
}

/* Validator report */
.validator-report {
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 18px 22px;
  min-width: 0;
  overflow-wrap: anywhere;
}
.validator-report h3 {
  font-size: 18px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.validator-report h3 .badge-pill {
  font-size: 11px;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.validator-report h3 .badge-pill.pass { background: var(--c-phonics); }
.validator-report h3 .badge-pill.fail { background: var(--c-decodable); color: #fff; }
.validator-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 6px;
}
.validator-list li {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 8px;
  align-items: start;
  padding: 7px 10px;
  border-radius: 10px;
  background: rgba(255,255,255,.6);
  border: 2px solid rgba(42,36,56,.15);
  font-size: 14px;
  font-weight: 600;
}
.validator-list li.ok { background: #e9faf2; border-color: rgba(60, 170, 130, 0.35); }
.validator-list li.fail { background: #ffe6ee; border-color: rgba(220, 80, 120, 0.35); }
.validator-list .v-mark {
  font-weight: 900;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  background: var(--ink);
  color: var(--paper);
}
.validator-list .fail .v-mark { background: var(--c-decodable); }
.validator-list .ok .v-mark   { background: var(--c-phonics); }
.validator-list .v-detail { color: var(--ink-soft); font-size: 13px; margin-top: 2px; }

/* Comprehension questions card uses a numbered list, not the validator grid. */
.questions-list {
  list-style: decimal;
  padding-left: 24px;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.questions-list li {
  padding: 8px 12px;
  border-radius: 10px;
  background: #e9faf2;
  border: 2px solid rgba(60, 170, 130, 0.35);
  font-size: 14px;
}
.questions-list .q-text { font-weight: 700; }
.questions-list .q-answer { color: var(--ink-soft); font-size: 13px; margin-top: 4px; }
.questions-list .q-meta { color: var(--ink-soft); font-size: 11px; opacity: 0.7; margin-top: 2px; text-transform: uppercase; letter-spacing: 0.5px; }

/* Agent trace */
.agent-trace {
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 18px 22px;
  min-width: 0;
}
.agent-trace h3 {
  font-size: 18px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.trace-steps {
  display: grid;
  gap: 8px;
}
.trace-step {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 12px;
  border: 2px solid rgba(42,36,56,.18);
  background: rgba(255,255,255,.6);
  transition: background .2s ease;
  min-width: 0;
}
.trace-step.active {
  background: var(--paper-warm);
  border-color: var(--ink);
  animation: trace-pulse 1.4s ease-in-out infinite;
}
.trace-step.done   { background: #eaf8f1; border-color: rgba(60, 170, 130, 0.35); }
.trace-step.failed { background: #ffe6ee; border-color: rgba(220, 80, 120, 0.35); }

@keyframes trace-pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(176, 124, 255, .35); }
  50%     { box-shadow: 0 0 0 8px rgba(176, 124, 255, 0); }
}

.trace-step .ts-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--c-assess);
  border: 2px solid var(--ink);
  display: grid;
  place-items: center;
}
.trace-step .ts-icon svg { width: 18px; height: 18px; }
.trace-step.done   .ts-icon { background: var(--c-phonics); }
.trace-step.failed .ts-icon { background: var(--c-decodable); }
.trace-step.failed .ts-icon svg { stroke: #fff; }

.trace-step .ts-body {
  min-width: 0;
  overflow: hidden;
}
.trace-step .ts-name {
  font-family: "Fredoka", sans-serif;
  font-weight: 700;
  font-size: 15px;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.trace-step .ts-sub {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-soft);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.trace-step .ts-time {
  font-size: 11px;
  font-weight: 800;
  color: var(--ink-soft);
  white-space: nowrap;
  padding-left: 8px;
}

/* Empty workspace state */
.ws-empty {
  display: grid;
  place-items: center;
  text-align: center;
  padding: 64px 24px;
  border: 3px dashed rgba(42,36,56,.3);
  border-radius: var(--radius-lg);
  background: rgba(255,255,255,.5);
  color: var(--ink-soft);
  font-weight: 700;
}
.ws-empty .we-mark {
  width: 80px; height: 80px;
  border-radius: 22px;
  background: var(--c-reading);
  border: 3px solid var(--ink);
  box-shadow: var(--shadow-card);
  display: grid;
  place-items: center;
  margin-bottom: 18px;
  transform: rotate(-3deg);
}
.ws-empty .we-mark svg { width: 44px; height: 44px; }
.ws-empty h3 { font-size: 22px; margin-bottom: 6px; color: var(--ink); }
.ws-empty p { max-width: 380px; line-height: 1.45; font-size: 15px; font-weight: 600; }

/* =========================================================
   History list (sidebar / inline)
   ========================================================= */

.history-list {
  display: grid;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
}
.history-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 12px;
  cursor: pointer;
  transition: transform .15s ease;
}
.history-item:hover {
  transform: translate(-1px,-1px);
  box-shadow: 3px 4px 0 var(--ink);
}
.history-item.selected {
  background: var(--c-reading);
}
.history-title {
  font-family: "Fredoka", sans-serif;
  font-weight: 600;
  font-size: 15px;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-meta {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
  margin-top: 2px;
}
.history-badge {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.history-badge.pass { background: var(--c-phonics); }
.history-badge.fail { background: var(--c-decodable); color: #fff; }
.history-badge.draft { background: var(--paper-warm); }

/* =========================================================
   Background scene (clouds, sun, stars)
   ========================================================= */

.scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.scene .cloud,
.scene .sun-bg,
.scene .star-bg,
.scene .planet-bg {
  position: absolute;
}

.scene .cloud { width: 160px; }
.scene .cloud svg { width: 100%; }

.scene .sun-bg {
  top: 80px; right: 8%;
  width: 220px; height: 220px;
  animation: spin-slow 60s linear infinite;
}

@keyframes spin-slow { to { transform: rotate(360deg); } }
@keyframes float-1 {
  0%,100% { transform: translateY(0) translateX(0); }
  50%     { transform: translateY(-18px) translateX(10px); }
}
@keyframes float-2 {
  0%,100% { transform: translateY(0); }
  50%     { transform: translateY(-12px); }
}
@keyframes drift {
  from { transform: translateX(-200px); }
  to   { transform: translateX(calc(100vw + 200px)); }
}

.scene .cloud-1 { top: 18%; left: -200px; animation: drift 80s linear infinite; }
.scene .cloud-2 { top: 6%;  left: -200px; animation: drift 110s linear infinite 20s; opacity: .7; }
.scene .cloud-3 { top: 38%; left: -200px; animation: drift 95s linear infinite 40s; opacity: .85; }

.scene .planet-bg {
  bottom: 8%;
  right: 4%;
  width: 90px; height: 90px;
  animation: float-1 8s ease-in-out infinite;
}

.scene .star-bg {
  animation: float-2 4s ease-in-out infinite;
}

/* =========================================================
   Toast
   ========================================================= */

.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translate(-50%, -80px);
  background: var(--ink);
  color: var(--paper);
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 700;
  z-index: 200;
  transition: transform .35s cubic-bezier(.4,1.4,.5,1);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.toast.show { transform: translate(-50%, 0); }
.toast svg { stroke: var(--paper); width: 16px; height: 16px; }

/* =========================================================
   Disclaimer banner (the SoR-honesty note)
   ========================================================= */

.disclaimer {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  background: #fff6d1;
  border: 2px dashed var(--ink);
  border-radius: 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.5;
}
.disclaimer svg {
  flex-shrink: 0;
  width: 20px; height: 20px;
  margin-top: 1px;
}

/* =========================================================
   Loading shimmer / spinner
   ========================================================= */

.shimmer {
  position: relative;
  overflow: hidden;
  background: rgba(255,255,255,.6);
  border: 2px dashed rgba(42,36,56,.2);
  border-radius: 16px;
  min-height: 80px;
}
.shimmer::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.7), transparent);
  animation: shimmer-sweep 1.4s linear infinite;
}
@keyframes shimmer-sweep {
  from { transform: translateX(-100%); }
  to   { transform: translateX(100%); }
}

.spinner {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 3px solid rgba(42,36,56,.25);
  border-top-color: var(--ink);
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =========================================================
   Result tabs (Validator · Questions · Provenance · Trace)
   ========================================================= */

.result-tabs {
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: 100%;
}

.result-tab-strip {
  display: flex;
  gap: 4px;
  padding: 6px;
  background: #fef6e5;
  border: 2.5px solid var(--ink);
  border-radius: 18px 18px 0 0;
  border-bottom: 0;
  overflow-x: auto;
  scrollbar-width: thin;
}
.result-tab-strip::-webkit-scrollbar { height: 4px; }
.result-tab-strip::-webkit-scrollbar-thumb { background: rgba(42,36,56,0.2); border-radius: 4px; }

.result-tab {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: transparent;
  border: 0;
  border-radius: 12px;
  font-family: "Fredoka", sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
  white-space: nowrap;
}
.result-tab:hover { background: rgba(42,36,56,0.06); color: var(--ink); }
.result-tab.is-active {
  background: #fff;
  color: var(--ink);
  border: 2px solid var(--ink);
  box-shadow: 1px 2px 0 var(--ink);
}

.result-tab-badge {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.02em;
}
.result-tab-badge.pass { background: #2ecf91; }
.result-tab-badge.fail { background: #ff6b6b; }
.result-tab-badge.warn { background: #f7b955; color: var(--ink); }
.result-tab-badge.info { background: #b07cff; }

.result-tab-panel {
  background: #fffbf2;
  border: 2.5px solid var(--ink);
  border-radius: 0 0 18px 18px;
  box-shadow: 3px 4px 0 var(--ink);
  padding: 16px 20px 20px;
  min-width: 0;
}

/* The cards inside the tab panel already have their own h3 and styling.
   When rendered inside a tab, shed the outer container chrome so we don't
   double-up borders and shadows. */
.result-tab-panel > .validator-report,
.result-tab-panel > .questions-card,
.result-tab-panel > .agent-trace {
  background: transparent;
  border: 0;
  box-shadow: none;
  border-radius: 0;
  padding: 0;
  margin: 0;
}

/* The inner h3 is redundant with the tab label — keep it but make it
   visually subordinate. */
.result-tab-panel > .validator-report > h3,
.result-tab-panel > .questions-card > h3,
.result-tab-panel > .agent-trace > h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  margin: 0 0 12px;
}

/* =========================================================
   Generating Animation
   ========================================================= */

.gen-anim {
  position: relative;
  border-radius: 24px;
  overflow: hidden;
  min-height: 340px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fef9f0;
  border: 3px solid var(--ink);
}

.gen-anim-rainbow {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    rgba(255,107,107,.15),
    rgba(255,183,77,.15),
    rgba(255,213,79,.15),
    rgba(129,199,132,.15),
    rgba(100,181,246,.15),
    rgba(186,147,214,.15),
    rgba(255,107,107,.15)
  );
  background-size: 400% 400%;
  animation: gen-rainbow 6s ease infinite;
}

@keyframes gen-rainbow {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.gen-anim-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 40px 24px;
  text-align: center;
}

.gen-anim-pencil svg {
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.1));
}

.gen-pencil-bob {
  animation: gen-bob 1.2s ease-in-out infinite;
  transform-origin: 32px 36px;
}

@keyframes gen-bob {
  0%, 100% { transform: translateY(0) rotate(-5deg); }
  50%      { transform: translateY(-8px) rotate(5deg); }
}

.gen-anim-letters {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 2px;
  font-family: var(--f-head);
  font-size: 28px;
  font-weight: 700;
  color: var(--ink);
}

.gen-letter {
  display: inline-block;
  animation: gen-wave 1.8s ease-in-out infinite;
}

@keyframes gen-wave {
  0%, 100% { transform: translateY(0); color: var(--ink); }
  25%      { transform: translateY(-6px); color: #EF5350; }
  50%      { transform: translateY(0); color: #AB47BC; }
  75%      { transform: translateY(-3px); color: #42A5F5; }
}

.gen-anim-msg {
  font-family: var(--f-head);
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  opacity: .75;
  animation: gen-fade 3s ease-in-out infinite;
  min-height: 1.4em;
}

@keyframes gen-fade {
  0%, 100% { opacity: .5; }
  30%, 70% { opacity: 1; }
}

.gen-anim-dots {
  display: flex;
  gap: 8px;
}

.gen-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ink);
  opacity: .3;
  animation: gen-bounce 1.4s ease-in-out infinite;
}

.gen-dot:nth-child(2) { animation-delay: .2s; }
.gen-dot:nth-child(3) { animation-delay: .4s; }

@keyframes gen-bounce {
  0%, 80%, 100% { transform: scale(1); opacity: .3; }
  40%           { transform: scale(1.5); opacity: .8; }
}

/* =========================================================
   Three products — switcher, decorated passage, word-building,
   per-product download, OpenDyslexic toggle.
   ========================================================= */

/* OpenDyslexic (SIL OFL — free for commercial output) from fontsource via
   jsDelivr. If blocked, the toggle falls back through the stack below. */
@font-face {
  font-family: "OpenDyslexic"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("https://cdn.jsdelivr.net/npm/@fontsource/opendyslexic@5/files/opendyslexic-latin-400-normal.woff2") format("woff2");
}
@font-face {
  font-family: "OpenDyslexic"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("https://cdn.jsdelivr.net/npm/@fontsource/opendyslexic@5/files/opendyslexic-latin-700-normal.woff2") format("woff2");
}
.font-dyslexic,
.font-dyslexic .psheet-passage,
.font-dyslexic .wks-passage,
.font-dyslexic .wks-q,
.font-dyslexic .wks-word,
.font-dyslexic .wb-writeword-cue,
.psheet-passage.font-dyslexic {
  font-family: "OpenDyslexic", "Andika", "Baloo 2", sans-serif !important;
  letter-spacing: .01em;
}
/* OpenDyslexic runs wide — ease the scale a notch so A4 still fits. */
.font-dyslexic.passage-sheet.wks-kg .psheet-passage { font-size: 23px; }
.font-dyslexic.passage-sheet.wks-g1 .psheet-passage { font-size: 20px; }
.font-dyslexic.passage-sheet.wks-g2 .psheet-passage { font-size: 17px; }

/* ── Product switcher ── */
.result-workspace .product-switch {
  display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 12px;
}
.product-tab {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  font-family: "Fredoka", sans-serif; font-weight: 600; font-size: 14px;
  padding: 9px 15px; border: 2.5px solid var(--ink); border-radius: 12px;
  background: #fff; color: var(--ink); box-shadow: 2px 2px 0 var(--ink);
  transition: transform .08s ease, box-shadow .08s ease, background .12s ease;
}
.product-tab:hover { transform: translateY(-1px); }
.product-tab .product-tab-ico { font-size: 18px; line-height: 1; }
.product-tab.is-active {
  background: var(--c-reading); box-shadow: 3px 3px 0 var(--ink);
  transform: translateY(-1px);
}

/* ── Reading-font toggle ── */
.product-toolbar { display: flex; justify-content: flex-end; margin-bottom: 10px; }
.font-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  border: 2px solid var(--ink); border-radius: 999px; padding: 4px 6px 4px 12px; background: #fff;
}
.font-toggle-label {
  font-family: "Fredoka", sans-serif; font-weight: 700; font-size: 11px;
  text-transform: uppercase; letter-spacing: .07em; color: var(--ink-soft); margin-right: 2px;
}
.ft-opt {
  font-family: "Fredoka", sans-serif; font-weight: 600; font-size: 13px; cursor: pointer;
  padding: 5px 12px; border: none; border-radius: 999px; background: transparent; color: var(--ink);
}
.ft-opt:nth-of-type(2) { font-family: "OpenDyslexic", "Fredoka", sans-serif; }
.ft-opt.active { background: var(--ink); color: #fff; }

/* ── Product stage (only the active product mounts) ── */
.product-stage { margin-bottom: 14px; }
.product-sheet { position: relative; }

/* ════ PASSAGE product — the decorated reading page ════ */
.passage-sheet { padding: 22px 24px 16px; }
.psheet-frame {
  position: absolute; inset: 10px; border: 3px solid var(--c-reading);
  border-radius: 16px; pointer-events: none;
  box-shadow: inset 0 0 0 2px #fff, inset 0 0 0 4px rgba(108, 160, 255, .25);
}
.psheet-corner {
  position: absolute; width: 34px; height: 34px; color: var(--c-reading);
  background: #fff; border-radius: 50%; display: grid; place-items: center;
}
.psheet-corner.tl { top: -17px; left: -17px; }
.psheet-corner.tr { top: -17px; right: -17px; color: var(--c-assess); }
.psheet-corner.bl { bottom: -17px; left: -17px; color: var(--c-phonics); }
.psheet-corner.br { bottom: -17px; right: -17px; color: var(--c-decodable); }
.psheet-inner { position: relative; z-index: 1; padding: 8px 16px 4px; }
.psheet-banner { text-align: center; margin: 6px 0 14px; }
.psheet-title {
  display: inline-block; font-family: "Fredoka", sans-serif; font-weight: 700;
  font-size: 30px; line-height: 1.1; color: var(--sheet-ink);
  padding: 6px 22px; background: rgba(108, 160, 255, .16);
  border: 2.5px solid var(--sheet-ink); border-radius: 14px;
}
.psheet-passage {
  font-family: "Andika", "Baloo 2", sans-serif; white-space: pre-wrap; word-wrap: break-word;
  color: var(--sheet-ink); margin: 6px 4px 16px;
}
.passage-sheet.wks-kg .psheet-passage { font-size: 26px; line-height: 2.05; word-spacing: .12em; }
.passage-sheet.wks-g1 .psheet-passage { font-size: 22px; line-height: 1.95; word-spacing: .05em; }
.passage-sheet.wks-g2 .psheet-passage { font-size: 18px; line-height: 1.82; }
.passage-sheet .sheet-foot { margin-top: 6px; }

/* Focus-sound banner (target graphemes for the week) */
.sound-banner {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 10px;
  border: 2.5px solid var(--sheet-ink); border-radius: 12px;
  padding: 8px 12px; margin: 0 auto 14px; max-width: 80%;
  background: rgba(255, 194, 76, .16);
}
.sound-banner-chip {
  font-family: "Fredoka", sans-serif; font-weight: 700; font-size: 21px; line-height: 1;
  letter-spacing: .5px; color: var(--sheet-ink);
}
.sound-banner-chip + .sound-banner-chip { border-left: 2px solid var(--sheet-rule); padding-left: 10px; }

/* Hero + spot illustrations on the passage. Sizes use min() so they scale down
   on narrow screens (and wrap as a final safety net) — square SVGs with
   height:auto never distort. Print/A4 keeps the full size (large viewport). */
.psheet-hero {
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 14px;
  margin: 4px 0 14px;
}
.psheet-hero-img { width: min(132px, 30vw); height: auto; }
.psheet-spot-img { width: min(64px, 15vw); height: auto; opacity: .92; }
.wks-kg .psheet-hero-img { width: min(150px, 34vw); height: auto; }

/* Word-building lesson: spot art beside the sound cards */
.wb-hero { display: flex; justify-content: center; margin: 2px 0 12px; }
.wb-hero-img { width: 96px; height: 96px; }

/* Tiny open-licence credit (CC-BY attribution for the spot art) */
.psheet-credit {
  text-align: right; font-family: "Fredoka", sans-serif; font-size: 9px;
  letter-spacing: .04em; color: var(--sheet-rule); margin-top: 3px;
}

/* ════ WORD-BUILDING product — the lesson page ════ */
.wb-howto {
  border: 2.5px solid var(--sheet-ink); border-radius: 14px; padding: 12px 16px;
  background: rgba(92, 214, 177, .14); margin-bottom: 18px;
}
.wb-howto-label {
  font-family: "Fredoka", sans-serif; font-weight: 700; font-size: 13px;
  text-transform: uppercase; letter-spacing: .08em; color: var(--sheet-soft); margin-bottom: 6px;
}
.wb-steps {
  margin: 0; padding-left: 22px; display: grid; gap: 4px;
  font-family: "Baloo 2", sans-serif; font-size: 15.5px; font-weight: 600; color: var(--sheet-ink);
}
.wb-wordrow { display: flex; flex-wrap: wrap; gap: 10px 14px; }

/* Syllable + suffix spelling-change rule blocks (SoR structural skills) */
.wb-rule {
  border: 2.5px solid var(--sheet-ink); border-radius: 14px; padding: 12px 16px;
  background: rgba(255, 122, 169, .08);
}
.wb-rule-item + .wb-rule-item { margin-top: 12px; border-top: 1.5px dashed var(--sheet-rule); padding-top: 12px; }
.wb-rule-title {
  font-family: "Fredoka", sans-serif; font-weight: 700; font-size: 15px; color: var(--sheet-ink); margin-bottom: 2px;
}
.wb-rule-explain {
  font-family: "Baloo 2", sans-serif; font-size: 15px; line-height: 1.5; color: var(--sheet-ink); margin-bottom: 8px;
}
.wb-rule-egs { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.wb-eg {
  font-family: "Andika", "Baloo 2", sans-serif; font-size: 16px; color: var(--sheet-ink);
  display: inline-flex; align-items: baseline; gap: 5px;
}
.wb-eg b { font-weight: 700; }
.wb-eg-note {
  font-family: "Baloo 2", sans-serif; font-size: 12.5px; font-weight: 600; color: var(--sheet-soft);
}
.wb-card-phon {
  font-family: ui-monospace, Menlo, monospace; font-size: 14px; font-weight: 700;
  margin-top: 4px; color: var(--sheet-soft);
}

/* ════ WORKSHEET product — practice extras ════ */
.wks-usehint {
  font-family: "Baloo 2", sans-serif; font-weight: 600; font-size: 14px;
  color: var(--sheet-soft); text-align: center; margin: -8px 0 16px;
}
.wb-write-list { display: grid; gap: 14px; }
.wb-writeword { display: flex; align-items: baseline; gap: 14px; }
.wb-writeword-cue {
  flex: 0 0 116px; font-family: "Andika", "Baloo 2", sans-serif; font-weight: 700;
  font-size: 20px; color: var(--sheet-ink);
}
.wb-writeword-cue.heart {
  background: rgba(255, 122, 169, .18); border: 2px solid var(--sheet-ink);
  border-radius: 9px; padding: 2px 12px; flex: 0 0 auto;
}
.wb-writeword .wks-write-line { flex: 1 1 auto; }
.sa-box-row + .wks-box-write { margin-top: 6px; }

/* Mixed comprehension question formats on the worksheet */
.wks-qi { margin-bottom: 4px; }
.wks-mc { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 8px 0 2px; }
.wks-mc-opt {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: "Andika", "Baloo 2", sans-serif; font-size: 16px; font-weight: 700; color: var(--sheet-ink);
}
.wks-mc-bub {
  width: 24px; height: 24px; display: inline-grid; place-items: center;
  border: 2.5px solid var(--sheet-ink); border-radius: 50%;
  font-family: "Fredoka", sans-serif; font-size: 13px; font-weight: 700;
}
.wks-wordbank {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin: 7px 0 4px;
}
.wks-bank-label {
  font-family: "Fredoka", sans-serif; font-weight: 700; font-size: 11px;
  text-transform: uppercase; letter-spacing: .07em; color: var(--sheet-soft);
}
.wks-bank-word {
  font-family: "Andika", "Baloo 2", sans-serif; font-weight: 700; font-size: 15px;
  padding: 3px 11px; background: rgba(108, 160, 255, .14);
  border: 2px solid var(--sheet-ink); border-radius: 9px;
}

/* Teacher answer-key options */
.q-options { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 4px 0; }
.q-opt {
  font-family: "Baloo 2", sans-serif; font-size: 13.5px; font-weight: 600; color: var(--ink-soft);
}
.q-opt.correct { color: var(--ink); font-weight: 800; }

/* ════ ROLL & READ fluency grid ════ */
.rr-howto {
  font-family: "Baloo 2", sans-serif; font-weight: 600; font-size: 14.5px;
  color: var(--sheet-soft); text-align: center; margin: -6px 0 16px;
}
.rr-grid { width: 100%; border-collapse: collapse; table-layout: fixed; }
.rr-grid th {
  color: var(--sheet-ink); padding: 8px 4px; border: 2px solid var(--sheet-ink);
  background: rgba(255, 194, 76, .18);
}
.rr-grid td {
  border: 2px solid var(--sheet-ink); text-align: center; padding: 10px 4px;
  font-family: "Andika", "Baloo 2", sans-serif; font-weight: 700; color: var(--sheet-ink);
}
.wks-kg .rr-grid td { font-size: 22px; padding: 13px 4px; }
.wks-g1 .rr-grid td { font-size: 19px; padding: 11px 4px; }
.wks-g2 .rr-grid td { font-size: 17px; }
.font-dyslexic .rr-grid td { font-family: "OpenDyslexic", "Andika", sans-serif !important; }
/* On a narrow preview the 6-column grid can't hold full-size words — shrink the
   on-screen type so nothing spills its cell. Print/A4 keeps the large size. */
@media screen and (max-width: 720px) {
  .rr-grid td { font-size: 13px !important; padding: 7px 1px !important; letter-spacing: 0; word-break: break-word; }
  .rr-grid th { padding: 5px 1px; }
  .rr-grid th svg { width: 20px; height: 20px; }
}

/* Teacher reference tab (annotated decodability) */
.annotated-passage .pc-title {
  font-family: "Fredoka", sans-serif; font-weight: 700; font-size: 19px; margin-bottom: 8px;
}

/* =========================================================
   Print — one product sheet per page.
   ========================================================= */

@page { size: A4; margin: 12mm 14mm; }

@media print {
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  html, body { background: #fff !important; }

  /* Hide every piece of app chrome */
  .scene, .topbar, .toolbar, .toast, .twk-panel, .twk-fab,
  .ws-controls, .result-tabs, .passage-actions, .ws-history-btn,
  .ws-mode-hint, .ws-empty, .auth-error, .pc-meta,
  .product-switch, .product-toolbar,
  .agent-trace, .validator-report { display: none !important; }

  .app, .workspace, .ws-output {
    display: block !important;
    padding: 0 !important; margin: 0 !important; max-width: none !important;
  }

  /* The result card sheds its chrome — the active product sheet IS the page.
     Only one product mounts at a time, so exactly one A4 page prints. */
  .passage-card, .result-workspace, .product-stage {
    border: none !important; box-shadow: none !important; border-radius: 0 !important;
    padding: 0 !important; margin: 0 !important; max-width: 100% !important;
    background: #fff !important; overflow: visible !important;
  }

  .sheet {
    border: none !important; box-shadow: none !important; border-radius: 0 !important;
    max-width: none !important; padding: 0 !important; margin: 0 !important;
  }
  /* The decorated passage keeps room for its frame (frame is its own element,
     so it survives the generic border strip above). */
  .passage-sheet { padding: 5mm 6mm !important; }
  .psheet-frame { inset: 2mm !important; }

  /* Keep logical units together across page breaks */
  .wks-warmup, .wks-block, .wks-reread, .wks-q-list li, .wks-draw,
  .wb-howto, .wb-writeword, .wb-write-list,
  .sa-section, .sa-card, .sa-blend-line, .sa-box-word { break-inside: avoid; }

  /* Cut guides: card borders go dashed on paper */
  .sa-cut-zone .sa-card { border-style: dashed !important; box-shadow: none !important; }

  .wks-draw-box { height: 62mm; }
}

/* =========================================================
   Responsive
   ========================================================= */

@media (max-width: 720px) {
  :root {
    --shadow-card: 4px 5px 0 var(--ink);
    --shadow-pop: 6px 8px 0 var(--ink);
  }
  .app {
    padding:
      max(12px, env(safe-area-inset-top))
      max(10px, env(safe-area-inset-right))
      max(82px, calc(72px + env(safe-area-inset-bottom)))
      max(10px, env(safe-area-inset-left));
    gap: 12px;
  }
  .topbar { display: grid; gap: 12px; }
  .brand { gap: 10px; min-width: 0; }
  .brand h1 { font-size: 24px; line-height: 1.02; }
  .brand .subline { font-size: 13px; }
  .brand-mark { width: 44px; height: 44px; border-radius: 14px; }
  .brand-mark svg { width: 30px; height: 30px; }
  .toolbar {
    gap: 8px;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding: 2px 2px 8px;
    margin-inline: -2px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .toolbar::-webkit-scrollbar { display: none; }
  .tool-btn { flex: 0 0 auto; min-height: 44px; padding: 9px 13px; font-size: 14px; box-shadow: 4px 5px 0 var(--ink); }
  .tool-btn:hover { transform: none; box-shadow: 4px 5px 0 var(--ink); }
  .tool-btn.account-chip { max-width: 190px; }

  .gallery { grid-template-columns: 1fr; gap: 16px; }
  .tool-card { padding: 18px; }
  .tool-card:hover { transform: none; box-shadow: var(--shadow-card); }

  .workspace { gap: 14px; }
  .ws-controls { position: static; padding: 16px; }
  .passage-card { padding: 18px; }
  .passage-card .pc-title { font-size: 22px; padding-right: 0; }
  .passage-body { font-size: 17px; }

  .auth-page {
    align-items: start;
    padding:
      max(18px, env(safe-area-inset-top))
      max(12px, env(safe-area-inset-right))
      max(18px, env(safe-area-inset-bottom))
      max(12px, env(safe-area-inset-left));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .auth-card { margin-top: 42px; padding: 20px; border-radius: 22px; box-shadow: 6px 8px 0 var(--ink); }
  .auth-brand h1 { font-size: 27px; }
  .auth-tabs { gap: 8px; }
  .auth-tabs button { min-height: 44px; padding: 8px 10px; box-shadow: 3px 4px 0 var(--ink); }

  .scene .cloud,
  .scene .planet-bg,
  .scene .star-bg { display: none; }
  .scene .sun-bg {
    top: 70px;
    right: -34px;
    width: 150px;
    height: 150px;
    animation: none;
    opacity: .72;
  }
}
