/* ─── Generate workspace + PDF preview (split layout) ─────────────────────── */
.generate-workspace {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  max-width: 42rem;
  margin-left: auto;
  margin-right: auto;
  gap: 0;
}

.gen-surface {
  border-color: rgba(255, 255, 255, 0.06);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.03) inset,
    0 18px 40px -16px rgba(0, 0, 0, 0.5);
}

.gen-surface-head {
  letter-spacing: 0.02em;
}

.generate-workspace.preview-mode {
  max-width: none;
  margin-left: 0;
  margin-right: 0;
  width: 100%;
  gap: 0.65rem 1rem;
}

.generate-workspace.preview-mode {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

@media (min-width: 1024px) {
  .generate-workspace.preview-mode {
    display: grid;
    grid-template-columns: minmax(0, var(--left-col-width)) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    align-items: start;
  }
}

/* PDF column */
.pdf-preview-stack {
  min-width: 0;
}

.pdf-tab-bar-wrap {
  display: none;
  align-items: center;
  width: auto;
  max-width: 100%;
  min-width: 0;
}

.pdf-tab-bar-wrap[hidden] {
  display: none !important;
}

/* Two-column grid: [back-btn auto] [sliders centered in 1fr].
   Ranking button is position:absolute so it can't disturb the grid. */
body.preview-mode-active #pdf-tab-bar-wrap:not([hidden]) {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  position: relative;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  opacity: 1;
}

body.preview-mode-active #pdf-tab-bar-wrap:not([hidden]) > .pdf-tab-primary-clip {
  justify-self: center;
}

/* ─── Ranking area — wrapper carries the absolute position ────────────── */
.ranking-tab-area {
  position: absolute;
  left: calc(2rem + 10%);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
  max-width: 40%;
}

/* ─── Ranking button — styled like the back button ────────────────────── */
.pdf-tab-ranking-btn {
  position: static;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  padding: 0.3rem 0.5rem;
  border-radius: 9999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: rgb(148 163 184);
  font-size: 0.70rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.pdf-tab-ranking-btn svg:not(.hidden) {
  display: block;
  width: 1.12rem;
  height: 1.12rem;
  flex-shrink: 0;
}

.pdf-tab-ranking-btn:hover:not(:disabled) {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.09);
  color: rgb(226 232 240);
}

.pdf-tab-ranking-btn:active:not(:disabled) {
  background: rgba(255, 255, 255, 0.13);
}

.pdf-tab-ranking-btn[aria-selected="true"] {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.09);
  color: rgb(226 232 240);
}

.pdf-tab-ranking-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.pdf-tab-ranking-btn--generating {
  opacity: 1;
  cursor: default;
}

.pdf-tab-ranking-btn:focus-visible {
  outline: 2px solid rgba(34, 211, 238, 0.45);
  outline-offset: 2px;
}

/* Tab track sits in the auto centre column, truly centred over the PDF pane */
.pdf-tab-primary-clip {
  display: flex;
  justify-content: center;
  align-items: center;
  min-width: 0;
}

/* ─── Back button (shown in preview tab bar) ─────────────────────────────── */
.pdf-tab-back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0.4rem;
  border-radius: 9999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: rgb(148 163 184);
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.pdf-tab-back-btn svg {
  display: block;
  width: 1.1rem;
  height: 1.1rem;
  flex-shrink: 0;
  overflow: visible;
  /* Explicit stroke: avoids invisible icon if currentColor chain breaks in flex/grid */
  stroke: rgb(148 163 184);
  stroke-width: 2px;
  fill: none;
}

.pdf-tab-back-btn:hover {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.09);
  color: rgb(226 232 240);
}

.pdf-tab-back-btn:hover svg {
  stroke: rgb(226 232 240);
}

.pdf-tab-back-btn:active {
  background: rgba(255, 255, 255, 0.13);
}

.pdf-tab-back-btn:focus-visible {
  outline: 2px solid rgba(34, 211, 238, 0.45);
  outline-offset: 2px;
}

/* Single-row preview control: [ Exercise sheet + 1/2/4-up ] | [ Mark scheme ] */
.pdf-tab-primary-track {
  --pdf-bar-edge: rgba(56, 189, 248, 0.22);
  --pdf-bar-fill-top: rgba(10, 28, 58, 0.82);
  --pdf-bar-fill-bot: rgba(6, 16, 42, 0.88);
  --pdf-sheet-pill: linear-gradient(152deg, rgba(56, 189, 248, 0.38) 0%, rgba(99, 102, 241, 0.24) 50%, rgba(79, 70, 229, 0.16) 100%);
  --pdf-sheet-pill-glow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 0 0 1px rgba(56, 189, 248, 0.28), 0 0 32px -5px rgba(56, 189, 248, 0.32);
  --pdf-answers-pill: linear-gradient(152deg, rgba(52, 211, 153, 0.45) 0%, rgba(45, 212, 191, 0.28) 50%, rgba(20, 184, 166, 0.18) 100%);
  --pdf-answers-pill-glow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 0 0 1px rgba(52, 211, 153, 0.28), 0 0 32px -5px rgba(52, 211, 153, 0.3);
  --pdf-solutions-pill: linear-gradient(152deg, rgba(251, 113, 133, 0.42) 0%, rgba(244, 114, 182, 0.26) 50%, rgba(236, 72, 153, 0.16) 100%);
  --pdf-solutions-pill-glow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 0 0 1px rgba(251, 113, 133, 0.28), 0 0 32px -5px rgba(251, 113, 133, 0.3);
  --pdf-embed-border: rgba(56, 189, 248, 0.25);
  --pdf-embed-bg: linear-gradient(180deg, rgba(6, 24, 52, 0.88) 0%, rgba(4, 14, 36, 0.92) 100%);
  --pdf-embed-inset: inset 0 1px 2px rgba(0, 0, 0, 0.5);

  position: relative;
  display: flex;
  align-items: stretch;
  gap: 0.3rem;
  min-width: 0;
  max-width: 100%;
  width: min(100%, 32rem);
  padding: 0.24rem;
  border-radius: 9999px;
  border: 1px solid var(--pdf-bar-edge);
  background: linear-gradient(180deg, var(--pdf-bar-fill-top) 0%, var(--pdf-bar-fill-bot) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 0 0 1px rgba(56, 189, 248, 0.1),
    0 8px 28px -6px rgba(0, 0, 0, 0.55),
    0 0 48px -10px rgba(56, 189, 248, 0.2);
  backdrop-filter: blur(18px) saturate(1.15);
  -webkit-backdrop-filter: blur(18px) saturate(1.15);
  transition:
    border-color 0.28s ease,
    box-shadow 0.32s ease;
}

.pdf-tab-primary-track:hover {
  border-color: rgba(56, 189, 248, 0.5);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    0 0 0 1px rgba(56, 189, 248, 0.18),
    0 8px 32px -6px rgba(0, 0, 0, 0.55),
    0 0 56px -8px rgba(56, 189, 248, 0.35);
}

.pdf-tab-sheet-column,
.pdf-tab-answers-column,
.pdf-tab-solutions-column,
.pdf-tab-layout-column {
  position: relative;
  display: flex;
  align-items: stretch;
  min-width: 0;
}

.pdf-tab-sheet-column {
  flex: 0 0 auto;
  align-items: center;
  padding-left: 0.55rem;
  padding-right: 0.15rem;
  cursor: pointer;
}

.pdf-tab-layout-column {
  flex: 0 0 auto;
  align-items: center;
  padding: 0.15rem 0;
  z-index: 1;
}

.pdf-tab-answers-column {
  flex: 0 0 auto;
  padding-left: 0.15rem;
  padding-right: 0.1rem;
}

.pdf-tab-solutions-column {
  flex: 0 0 auto;
  padding-right: 0.25rem;
}

/* Single pill that slides between the sheet, mark-scheme and worked-solutions sides.
   JS (syncSidePill) measures getBoundingClientRect() and writes
   --pill-right-inset / --pill-left-inset on the pill element.
   CSS owns left, right, and the asymmetric transition so the
   expanding (leading) edge is faster than the trailing edge. */
.pdf-tab-side-pill {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: 9999px;
  pointer-events: none;
  z-index: 0;
  will-change: left, right;
}

.pdf-tab-primary-track[data-side="sheet"] .pdf-tab-side-pill {
  background: var(--pdf-sheet-pill);
  box-shadow: var(--pdf-sheet-pill-glow);
  left: 0;
  right: var(--pill-right-inset, 0px);
  transition:
    left  0.26s cubic-bezier(0.16, 1, 0.3, 1),
    right 0.42s cubic-bezier(0.16, 1, 0.3, 1),
    background 0.32s ease,
    box-shadow 0.32s ease;
}

.pdf-tab-primary-track[data-side="answers"] .pdf-tab-side-pill {
  background: var(--pdf-answers-pill);
  box-shadow: var(--pdf-answers-pill-glow);
  left: var(--pill-left-inset, 0px);
  right: var(--pill-answers-right-inset, 0px);
  transition:
    left  0.42s cubic-bezier(0.16, 1, 0.3, 1),
    right 0.26s cubic-bezier(0.16, 1, 0.3, 1),
    background 0.32s ease,
    box-shadow 0.32s ease;
}

.pdf-tab-primary-track[data-side="solutions"] .pdf-tab-side-pill {
  background: var(--pdf-solutions-pill);
  box-shadow: var(--pdf-solutions-pill-glow);
  left: var(--pill-left-inset, 0px);
  right: 0;
  transition:
    left  0.42s cubic-bezier(0.16, 1, 0.3, 1),
    right 0.26s cubic-bezier(0.16, 1, 0.3, 1),
    background 0.32s ease,
    box-shadow 0.32s ease;
}

.pdf-tab-sheet-label {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.015em;
  color: rgb(100 116 139);
  transition: color 0.30s ease, text-shadow 0.30s ease;
  user-select: none;
  cursor: pointer;
  padding: 0.4rem 0 0.4rem 0;
}

.pdf-tab-primary-track[data-side="sheet"] .pdf-tab-sheet-label {
  color: rgb(186 230 253);
  text-shadow: 0 0 16px rgba(56, 189, 248, 0.25);
}

.pdf-tab-primary-track[data-side="answers"] .pdf-tab-sheet-label,
.pdf-tab-primary-track[data-side="solutions"] .pdf-tab-sheet-label {
  color: rgb(120 140 165);
}

.pdf-tab-layout-track {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: stretch;
  flex: 0 0 auto;
  min-width: 0;
  padding: var(--pill-pad);
  gap: 0;
  border-radius: 9999px;
  border: 1px solid var(--pdf-embed-border);
  background: var(--pdf-embed-bg);
  box-shadow: var(--pdf-embed-inset);
}

.pdf-tab-layout-track--embedded {
  min-width: 5.75rem;
  transition:
    opacity 0.30s ease,
    border-color 0.30s ease,
    box-shadow 0.30s ease,
    filter 0.30s ease;
}

.pdf-tab-layout-track--embedded:hover {
  border-color: rgba(56, 189, 248, 0.4);
  box-shadow:
    var(--pdf-embed-inset),
    0 0 18px -4px rgba(56, 189, 248, 0.25);
}

.pdf-tab-primary-track[data-side="answers"] .pdf-tab-layout-track--embedded {
  opacity: 1;
  border-color: rgba(52, 211, 153, 0.22);
}

.pdf-tab-primary-track[data-side="solutions"] .pdf-tab-layout-track--embedded {
  opacity: 1;
  border-color: rgba(251, 113, 133, 0.24);
}

.pdf-tab-layout-pill {
  position: absolute;
  top: var(--pill-pad);
  bottom: var(--pill-pad);
  left: var(--pill-pad);
  width: calc((100% - var(--pill-gap)) / 3);
  border-radius: 9999px;
  will-change: left;
  transition:
    left 0.32s cubic-bezier(0.16, 1, 0.3, 1),
    background 0.28s ease,
    box-shadow 0.28s ease;
  pointer-events: none;
  z-index: 0;
}

.pdf-tab-layout-track[data-layout="exercise"] .pdf-tab-layout-pill {
  left: var(--pill-pad);
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.42) 0%, rgba(56, 189, 248, 0.2) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.24),
    0 0 0 1px rgba(125, 211, 252, 0.28),
    0 0 20px -3px rgba(56, 189, 248, 0.45);
}

.pdf-tab-layout-track[data-layout="two-up"] .pdf-tab-layout-pill {
  left: calc(var(--pill-pad) + (100% - var(--pill-gap)) / 3);
  background: linear-gradient(180deg, rgba(251, 191, 36, 0.44) 0%, rgba(245, 158, 11, 0.22) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    0 0 0 1px rgba(252, 211, 77, 0.3),
    0 0 20px -3px rgba(251, 191, 36, 0.42);
}

.pdf-tab-layout-track[data-layout="four-up"] .pdf-tab-layout-pill {
  left: calc(var(--pill-pad) + (100% - var(--pill-gap)) * 2 / 3);
  background: linear-gradient(180deg, rgba(167, 139, 250, 0.44) 0%, rgba(139, 92, 246, 0.22) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    0 0 0 1px rgba(196, 181, 253, 0.3),
    0 0 20px -3px rgba(167, 139, 250, 0.42);
}

.pdf-tab-primary-facet {
  position: relative;
  z-index: 1;
  align-self: center;
  border: none;
  border-radius: 9999px;
  padding: 0.4rem 0.8rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.015em;
  background: transparent;
  color: rgb(110 200 170);
  cursor: pointer;
  transition: color 0.30s ease, opacity 0.30s ease, text-shadow 0.30s ease;
}

/* Hover glow when sheet label is clickable (a key document is showing) */
.pdf-tab-primary-track[data-side="answers"] .pdf-tab-sheet-column:hover .pdf-tab-sheet-label,
.pdf-tab-primary-track[data-side="solutions"] .pdf-tab-sheet-column:hover .pdf-tab-sheet-label {
  color: rgb(224 242 254);
  text-shadow: 0 0 20px rgba(56, 189, 248, 0.5);
}

.pdf-tab-primary-facet:hover:not(:disabled) {
  color: rgb(110 235 183);
  text-shadow: 0 0 20px rgba(52, 211, 153, 0.55);
}

.pdf-tab-primary-facet:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* The answer key is built beside the sheet and can still be running when the sheet opens.
   The tab stays unclickable, but at full strength with its spinner, so it reads as "coming"
   rather than as the dimmed "not generated for this run". */
.pdf-tab-primary-facet--building:disabled {
  opacity: 1;
  cursor: default;
}

/* ⚠️ display is load-bearing: .gen-spinner sets width/height but no display, and its rings are
   `position:absolute; inset:0`. The ranking button is a flex container, which blockifies it;
   this facet is a plain button, so without inline-flex the span stays a zero-size inline box
   and only the centre dot shows. */
.pdf-tab-primary-facet .gen-spinner {
  display: inline-flex;
  margin-right: 0.35rem;
  vertical-align: -0.18em;
}

/* The rule above outranks `.hidden`, so a landed key kept spinning: hide it here. */
.pdf-tab-primary-facet .gen-spinner.hidden {
  display: none;
}

.pdf-tab-primary-facet:focus-visible {
  outline: 2px solid rgba(52, 211, 153, 0.45);
  outline-offset: 2px;
}

.pdf-tab-primary-facet[aria-selected="true"]:not(:disabled) {
  color: rgb(248 250 252);
}

.pdf-tab-primary-track[data-side="answers"] .pdf-tab-primary-facet#tab-btn-answers:not(:disabled) {
  color: rgb(167 243 208);
  text-shadow: 0 0 18px rgba(52, 211, 153, 0.3);
}

/* Worked solutions: rose, so it never reads as a second mark scheme */
.pdf-tab-primary-facet--solutions {
  color: rgb(244 160 175);
}

.pdf-tab-primary-facet--solutions:hover:not(:disabled) {
  color: rgb(253 186 198);
  text-shadow: 0 0 20px rgba(251, 113, 133, 0.55);
}

.pdf-tab-primary-facet--solutions:focus-visible {
  outline-color: rgba(251, 113, 133, 0.5);
}

.pdf-tab-primary-track[data-side="solutions"] .pdf-tab-primary-facet#tab-btn-solutions:not(:disabled) {
  color: rgb(255 228 230);
  text-shadow: 0 0 18px rgba(251, 113, 133, 0.3);
}

.pdf-spinner--rose {
  border-color: rgba(251, 113, 133, 0.25);
  border-top-color: rgb(251 113 133);
}

/* Layout toggles: icon colors match .dl-icon-btn--sky / --amber / --violet */
.pdf-tab-layout-btn {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  width: 100%;
  padding: 0.35rem 0.4rem;
  border: none;
  border-radius: 9999px;
  background: transparent;
  cursor: pointer;
  transition: color 0.28s ease, opacity 0.28s ease, transform 0.22s cubic-bezier(0.22, 1, 0.36, 1), filter 0.28s ease;
}

.pdf-tab-layout-btn--sky {
  color: rgb(125 211 252);
  filter: drop-shadow(0 0 10px rgba(56, 189, 248, 0.5));
}

.pdf-tab-layout-btn--amber {
  color: rgb(253 230 138);
  filter: drop-shadow(0 0 10px rgba(251, 191, 36, 0.45));
}

.pdf-tab-layout-btn--violet {
  color: rgb(216 180 254);
  filter: drop-shadow(0 0 10px rgba(167, 139, 250, 0.45));
}

.pdf-tab-layout-btn:hover:not(:disabled) {
  transform: scale(1.14) translateY(-0.5px);
}

.pdf-tab-layout-btn:active:not(:disabled) {
  transform: scale(0.95);
}

.pdf-tab-layout-btn--sky:hover:not(:disabled) {
  color: rgb(224 242 254);
  filter: drop-shadow(0 0 20px rgba(56, 189, 248, 0.8)) drop-shadow(0 0 6px rgba(56, 189, 248, 0.5));
}

.pdf-tab-layout-btn--amber:hover:not(:disabled) {
  color: rgb(254 249 195);
  filter: drop-shadow(0 0 20px rgba(251, 191, 36, 0.75)) drop-shadow(0 0 6px rgba(251, 191, 36, 0.45));
}

.pdf-tab-layout-btn--violet:hover:not(:disabled) {
  color: rgb(237 233 254);
  filter: drop-shadow(0 0 20px rgba(167, 139, 250, 0.75)) drop-shadow(0 0 6px rgba(167, 139, 250, 0.45));
}

.pdf-tab-layout-btn--sky[aria-selected="true"]:not(:disabled) {
  color: rgb(34 211 238);
  filter: drop-shadow(0 0 16px rgba(34, 211, 238, 0.65));
}

.pdf-tab-layout-btn--amber[aria-selected="true"]:not(:disabled) {
  color: rgb(251 191 36);
  filter: drop-shadow(0 0 16px rgba(251, 191, 36, 0.6));
}

.pdf-tab-layout-btn--violet[aria-selected="true"]:not(:disabled) {
  color: rgb(192 132 252);
  filter: drop-shadow(0 0 16px rgba(192, 132, 252, 0.6));
}

.pdf-tab-layout-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  filter: none;
}

.pdf-tab-layout-btn:focus-visible {
  outline: 2px solid var(--glow-cyan, rgba(34, 211, 238, 0.45));
  outline-offset: 2px;
}

.pdf-tab-layout-btn--amber:focus-visible {
  outline-color: rgba(251, 191, 36, 0.5);
}

.pdf-tab-layout-btn--violet:focus-visible {
  outline-color: rgba(167, 139, 250, 0.5);
}

.pdf-tab-layout-icon {
  display: flex;
  width: 1.35rem;
  height: 1.35rem;
}

.pdf-tab-layout-icon svg {
  width: 100%;
  height: 100%;
}

.gen-left-col {
  width: 100%;
  max-width: 42rem;
  margin-left: auto;
  margin-right: auto;
}

.preview-mode .gen-left-col {
  margin-left: 0;
  margin-right: 0;
}

@media (min-width: 1024px) {
  .preview-mode .gen-left-col {
    width: var(--left-col-width);
    max-width: var(--left-col-width);
    flex-shrink: 0;
    grid-column: 1;
    grid-row: 1;
  }
}

.hero-collapse {
  max-height: 40rem;
  opacity: 1;
  overflow: hidden;
  transition:
    max-height 0.32s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.22s ease,
    margin 0.28s ease;
}

/* The example-prompts wrapper holds three subject grids (IGCSE + A-Level + AP),
   taller than the default 40rem cap. Raise its cap — kept just above the natural
   content height per breakpoint so the collapse-to-0 animation stays tight — so
   the grids are neither clipped nor overflow onto the feature cards on landing.
   (2-col mobile layout is taller than the 3-col desktop grid, hence the media query.) */
.hero-collapse.mt-2 {
  max-height: 66rem;
}
@media (max-width: 639px) {
  .hero-collapse.mt-2 {
    max-height: 104rem;
  }
}

/* Landing: allow hover lifts + hero icon float without clipping top borders */
#generate-workspace:not(.preview-mode) .hero-collapse {
  overflow: visible;
}

.preview-mode .hero-collapse {
  max-height: 0;
  opacity: 0;
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  pointer-events: none;
}

.preview-mode #gen-form {
  margin-top: 0;
}

/* Specificity: form#gen-form (1,0,1) beats Tailwind's [type="text"] (0,1,1) — no !important needed. */
.preview-mode form#gen-form #prompt {
  min-height: 8rem;
  max-height: min(42vh, 22rem);
  resize: vertical;
  border-color: rgba(56, 189, 248, 0.22);
  background: linear-gradient(
    165deg,
    rgba(6, 22, 42, 0.92) 0%,
    rgba(4, 16, 36, 0.88) 45%,
    rgba(8, 28, 52, 0.85) 100%
  );
  color: rgb(226 232 240);
  box-shadow:
    inset 0 1px 0 rgba(56, 189, 248, 0.06),
    inset 0 0 0 1px rgba(0, 0, 0, 0.25),
    0 0 28px -10px rgba(56, 189, 248, 0.15);
  caret-color: rgb(34 211 238);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.preview-mode form#gen-form #prompt::placeholder {
  color: rgba(186, 240, 253, 0.52);
}

.preview-mode form#gen-form #prompt:hover {
  border-color: rgba(56, 189, 248, 0.32);
  box-shadow:
    inset 0 1px 0 rgba(56, 189, 248, 0.1),
    inset 0 0 0 1px rgba(0, 0, 0, 0.2),
    0 0 32px -8px rgba(56, 189, 248, 0.22);
}

.preview-mode form#gen-form #prompt:focus {
  border-color: rgba(34, 211, 238, 0.45);
  outline: none;
  box-shadow:
    inset 0 1px 0 rgba(56, 189, 248, 0.12),
    inset 0 0 0 1px rgba(0, 0, 0, 0.15),
    0 0 0 2px rgba(34, 211, 238, 0.2),
    0 0 40px -8px rgba(34, 211, 238, 0.25);
}

/* Header nav pills (Generate / Library) — subtle glass + hint of cyan.
   INERT since 2026-08-10: the nav is display:none in the sheet preview (the fixed account
   pill was sitting on top of it — see the "Sheet preview: no site nav" block in
   07-header-preview-chrome.css). Kept so re-enabling it doesn't mean re-deriving the look. */
body.preview-mode-active .site-header-nav {
  border-color: rgba(56, 189, 248, 0.14) !important;
  background: linear-gradient(
    180deg,
    rgba(12, 22, 42, 0.52) 0%,
    rgba(8, 14, 32, 0.58) 100%
  ) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 0 0 1px rgba(56, 189, 248, 0.035) inset,
    0 3px 18px -8px rgba(0, 0, 0, 0.38),
    0 0 28px -14px rgba(56, 189, 248, 0.07);
  backdrop-filter: blur(12px) saturate(1.06);
  -webkit-backdrop-filter: blur(12px) saturate(1.06);
}

body.preview-mode-active .site-header-nav a {
  color: rgb(132 165 196) !important;
  transition: color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

body.preview-mode-active .site-header-nav a:hover {
  color: rgb(203 230 248) !important;
  background: rgba(56, 189, 248, 0.07) !important;
  box-shadow: 0 0 12px -4px rgba(56, 189, 248, 0.12);
}

body.preview-mode-active .site-header-nav a.nav-link-active {
  color: rgb(226 246 255) !important;
  background: linear-gradient(
    135deg,
    rgba(34, 211, 238, 0.16) 0%,
    rgba(59, 130, 246, 0.12) 100%
  ) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 0 0 1px rgba(34, 211, 238, 0.12) inset,
    0 0 14px -4px rgba(34, 211, 238, 0.14);
}

/* Non-preview nav styles live in 03-core-ui.css so they apply on every page. */

#pdf-preview-pane {
  display: none;
  flex-direction: column;
  min-width: 0;
  min-height: 60vh;
  border-radius: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(148deg, rgba(15, 28, 52, 0.75) 0%, rgba(10, 18, 38, 0.5) 100%),
    rgb(2, 6, 16); /* opaque base so page bg never bleeds through */
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.04) inset,
    0 24px 48px -12px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

@media (min-width: 1024px) {
  .preview-mode .pdf-preview-stack {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    min-height: 0;
    margin-top: calc(-1 * var(--preview-sticky-top) - 0.75rem);
    padding-top: 0;
    /* NOTE: height does NOT subtract --preview-sticky-top while margin-top above
       pulls up by it — if the desktop preview bottom ever clips below the fold,
       that offset mismatch is the cause. (A prior dead duplicate that DID subtract
       it was removed; behaviour here is unchanged.) */
    height: calc(100vh - 1rem);
    max-height: calc(100vh - 1rem);
  }
}

@media (min-width: 1024px) {
  .preview-mode #pdf-preview-pane {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    border-top: none;
  }

  .preview-mode .pdf-viewport-scroll {
    padding-top: calc(var(--preview-sticky-top) + 0.75rem);
  }
}

.preview-mode #pdf-preview-pane {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  width: 100%;
}

/* Tint the pane border to match the active tab */
.preview-mode:has(#pdf-tab-primary-track[data-side="sheet"]) #pdf-preview-pane {
  border-color: rgba(56, 189, 248, 0.26);
  box-shadow:
    0 0 0 1px rgba(56, 189, 248, 0.08) inset,
    0 24px 48px -12px rgba(0, 0, 0, 0.45),
    0 0 56px -16px rgba(56, 189, 248, 0.14);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.preview-mode:has(#pdf-tab-primary-track[data-side="answers"]) #pdf-preview-pane {
  border-color: rgba(52, 211, 153, 0.26);
  box-shadow:
    0 0 0 1px rgba(52, 211, 153, 0.08) inset,
    0 24px 48px -12px rgba(0, 0, 0, 0.45),
    0 0 56px -16px rgba(52, 211, 153, 0.12);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.preview-mode:has(#pdf-tab-primary-track[data-side="solutions"]) #pdf-preview-pane {
  border-color: rgba(251, 113, 133, 0.26);
  box-shadow:
    0 0 0 1px rgba(251, 113, 133, 0.08) inset,
    0 24px 48px -12px rgba(0, 0, 0, 0.45),
    0 0 56px -16px rgba(251, 113, 133, 0.12);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.preview-mode:has(#tab-btn-ranking[aria-selected="true"]) #pdf-preview-pane {
  border-color: rgba(251, 146, 60, 0.28);
  box-shadow:
    0 0 0 1px rgba(251, 146, 60, 0.09) inset,
    0 24px 48px -12px rgba(0, 0, 0, 0.45),
    0 0 56px -16px rgba(251, 146, 60, 0.14);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

@media (max-width: 1023px) {
  .generate-workspace.preview-mode {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(14rem, 1fr);
  }

  .preview-mode #gen-left-col {
    grid-column: 1;
    grid-row: 1;
  }

  .preview-mode .pdf-preview-stack {
    grid-column: 1;
    grid-row: 2;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    min-height: 0;
    /* dvh tracks the mobile URL bar so the preview pane isn't cut off; the vh
       lines stay as the fallback for engines without dvh. */
    max-height: min(58vh, calc(100vh - var(--preview-sticky-top) - 1.25rem));
    max-height: min(58dvh, calc(100dvh - var(--preview-sticky-top) - 1.25rem));
    height: min(58vh, calc(100vh - var(--preview-sticky-top) - 1.25rem));
    height: min(58dvh, calc(100dvh - var(--preview-sticky-top) - 1.25rem));
  }
}

.pdf-tab-panels {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  background: var(--pane-bg); /* opaque — no flash during tab switch */
}

.pdf-tab-panel {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--pane-bg); /* opaque fallback — prevents flash of page bg */
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.12s ease, visibility 0s linear 0.12s;
}

/* JS toggles [hidden] alongside .is-active; UA stylesheet would force display:none. */
.pdf-tab-panel[hidden] {
  display: flex;
}

.pdf-tab-panel.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.12s ease, visibility 0s;
}

.pdf-viewport-scroll {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  width: 100%;
  overflow: auto;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 0.75rem 0.75rem 1.25rem;
  will-change: scroll-position;
  scrollbar-width: thin;
  scrollbar-color: rgba(56, 189, 248, 0.22) transparent;
}

.pdf-viewport-scroll::-webkit-scrollbar { width: 8px; height: 8px; }
.pdf-viewport-scroll::-webkit-scrollbar-track { background: transparent; }
.pdf-viewport-scroll::-webkit-scrollbar-thumb {
  background: rgba(56, 189, 248, 0.22);
  border-radius: 4px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
.pdf-viewport-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(56, 189, 248, 0.38);
  background-clip: padding-box;
  border: 2px solid transparent;
}
.pdf-viewport-scroll::-webkit-scrollbar-corner { background: transparent; }

.preview-mode .pdf-viewport-scroll {
  display: block;
  background: linear-gradient(180deg, rgba(8, 30, 52, 0.52) 0%, rgba(2, 8, 20, 0.5) 100%);
}

.pdf-pages-stack {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  min-width: 0;
  flex-shrink: 0;
  box-sizing: border-box;
}

/* Stack width is managed by JS (renderPdfContinuous / rerenderPdfZoomBuffered):
   max(contentWidth, maxPageWidth) — full-width at normal zoom for centering,
   wider-than-container at high zoom for horizontal overflow. */

/* Allow zoomed page width to exceed the pane so horizontal trackpad scroll works
   (09-overview.css caps .pdf-page-wrap at 100% which prevents overflow-x). */
.pdf-viewport-scroll .pdf-page-wrap {
  max-width: none;
}

/* ─── Portrait phones: scrollable tab track; hide ranking button ─────── */
@media (max-width: 479px) {
  .ranking-tab-area {
    display: none;
  }
  body.preview-mode-active #pdf-tab-bar-wrap:not([hidden]) > .pdf-tab-primary-clip {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    justify-self: stretch;
    justify-content: flex-start;
  }
}

/* ▼▼ LIGHT THEME — GENERATED by scripts/build_light_theme.py from the rules above. Do not edit by hand: run the builder. Hand tuning goes in 36-theme-light.css. ▼▼ */
html[data-theme="light"] .gen-surface{border-color:rgb(15 23 42/0.084);box-shadow:inset 0px 0px 0px 1px rgb(15 23 42/0.09),0px 18px 40px -16px rgb(15 23 42/0.16)}
html[data-theme="light"] .pdf-tab-ranking-btn{border-color:rgb(15 23 42/0.14);background-color:rgb(15 23 42/0.05);color:rgb(61 75 94)}
html[data-theme="light"] .pdf-tab-ranking-btn:hover:not(:disabled){border-color:rgb(15 23 42/0.18);background-color:rgb(15 23 42/0.09);color:rgb(44 63 88)}
html[data-theme="light"] .pdf-tab-ranking-btn:active:not(:disabled){background-color:rgb(15 23 42/0.13)}
html[data-theme="light"] .pdf-tab-ranking-btn[aria-selected="true"]{border-color:rgb(15 23 42/0.18);background-color:rgb(15 23 42/0.09);color:rgb(44 63 88)}
html[data-theme="light"] .pdf-tab-back-btn{border-color:rgb(15 23 42/0.14);background-color:rgb(15 23 42/0.05);color:rgb(61 75 94)}
html[data-theme="light"] .pdf-tab-back-btn svg{stroke:rgb(61 75 94)}
html[data-theme="light"] .pdf-tab-back-btn:hover{border-color:rgb(15 23 42/0.18);background-color:rgb(15 23 42/0.09);color:rgb(44 63 88)}
html[data-theme="light"] .pdf-tab-back-btn:hover svg{stroke:rgb(44 63 88)}
html[data-theme="light"] .pdf-tab-back-btn:active{background-color:rgb(15 23 42/0.13)}
html[data-theme="light"] .pdf-tab-primary-track{--pdf-bar-fill-top:rgb(242 244 248/0.82);--pdf-bar-fill-bot:rgb(246 247 250/0.88);--pdf-sheet-pill-glow:inset 0 1px 0 rgb(15 23 42/0.11), 0 0 0 1px rgb(56 189 248/0.14), 0 0 32px -5px rgb(56 189 248/0.16);--pdf-answers-pill-glow:inset 0 1px 0 rgb(15 23 42/0.1), 0 0 0 1px rgb(52 211 153/0.14), 0 0 32px -5px rgb(52 211 153/0.15);--pdf-solutions-pill-glow:inset 0 1px 0 rgb(15 23 42/0.1), 0 0 0 1px rgb(251 113 133/0.14), 0 0 32px -5px rgb(251 113 133/0.15);--pdf-embed-bg:linear-gradient(180deg, rgb(244 246 249/0.88) 0%, rgb(247 248 251/0.92) 100%);box-shadow:0px 0px 0px 1px rgb(10 131 184/0.17),0px 8px 28px -6px rgb(15 23 42/0.176),0px 14px 48px -10px rgb(15 23 42/0.05)}
html[data-theme="light"] .pdf-tab-primary-track:hover{box-shadow:0px 0px 0px 1px rgb(10 131 184/0.306),0px 8px 32px -6px rgb(15 23 42/0.176),0px 17px 56px -8px rgb(15 23 42/0.077)}
html[data-theme="light"] .pdf-tab-sheet-label{color:rgb(87 101 122)}
html[data-theme="light"] .pdf-tab-primary-track[data-side="sheet"] .pdf-tab-sheet-label{color:rgb(1 87 132);text-shadow:none}
html[data-theme="light"] .pdf-tab-primary-track[data-side="answers"] .pdf-tab-sheet-label,html[data-theme="light"] .pdf-tab-primary-track[data-side="solutions"] .pdf-tab-sheet-label{color:rgb(72 89 110)}
html[data-theme="light"] .pdf-tab-layout-track--embedded:hover{box-shadow:var(--pdf-embed-inset),0px 5px 18px -4px rgb(15 23 42/0.055)}
html[data-theme="light"] .pdf-tab-layout-track[data-layout="exercise"] .pdf-tab-layout-pill{box-shadow:0px 0px 0px 1px rgb(10 128 184/0.476),0px 6px 20px -3px rgb(15 23 42/0.099)}
html[data-theme="light"] .pdf-tab-layout-track[data-layout="two-up"] .pdf-tab-layout-pill{box-shadow:0px 0px 0px 1px rgb(184 143 10/0.51),0px 6px 20px -3px rgb(15 23 42/0.092)}
html[data-theme="light"] .pdf-tab-layout-track[data-layout="four-up"] .pdf-tab-layout-pill{box-shadow:0px 0px 0px 1px rgb(46 10 184/0.51),0px 6px 20px -3px rgb(15 23 42/0.092)}
html[data-theme="light"] .pdf-tab-primary-facet{color:rgb(40 112 88)}
html[data-theme="light"] .pdf-tab-primary-track[data-side="answers"] .pdf-tab-sheet-column:hover .pdf-tab-sheet-label,html[data-theme="light"] .pdf-tab-primary-track[data-side="solutions"] .pdf-tab-sheet-column:hover .pdf-tab-sheet-label{color:rgb(1 79 132);text-shadow:none}
html[data-theme="light"] .pdf-tab-primary-facet:hover:not(:disabled){color:rgb(13 112 70);text-shadow:none}
html[data-theme="light"] .pdf-tab-primary-facet[aria-selected="true"]:not(:disabled){color:rgb(38 66 94)}
html[data-theme="light"] .pdf-tab-primary-track[data-side="answers"] .pdf-tab-primary-facet#tab-btn-answers:not(:disabled){color:rgb(13 112 66);text-shadow:none}
html[data-theme="light"] .pdf-tab-primary-facet--solutions{color:rgb(121 11 31)}
html[data-theme="light"] .pdf-tab-primary-facet--solutions:hover:not(:disabled){color:rgb(132 1 24);text-shadow:none}
html[data-theme="light"] .pdf-tab-primary-track[data-side="solutions"] .pdf-tab-primary-facet#tab-btn-solutions:not(:disabled){color:rgb(133 0 10);text-shadow:none}
html[data-theme="light"] .pdf-tab-layout-btn--sky{color:rgb(0 90 133);filter:none}
html[data-theme="light"] .pdf-tab-layout-btn--amber{color:rgb(117 94 0);filter:none}
html[data-theme="light"] .pdf-tab-layout-btn--violet{color:rgb(65 0 133);filter:none}
html[data-theme="light"] .pdf-tab-layout-btn--sky:hover:not(:disabled){color:rgb(1 79 132);filter:none}
html[data-theme="light"] .pdf-tab-layout-btn--amber:hover:not(:disabled){color:rgb(110 100 0);filter:none}
html[data-theme="light"] .pdf-tab-layout-btn--violet:hover:not(:disabled){color:rgb(27 3 130);filter:none}
html[data-theme="light"] .pdf-tab-layout-btn--sky[aria-selected="true"]:not(:disabled){color:rgb(6 107 122);filter:none}
html[data-theme="light"] .pdf-tab-layout-btn--amber[aria-selected="true"]:not(:disabled){color:rgb(127 92 0);filter:none}
html[data-theme="light"] .pdf-tab-layout-btn--violet[aria-selected="true"]:not(:disabled){color:rgb(66 0 133);filter:none}
html[data-theme="light"] .preview-mode form#gen-form #prompt{background-image:linear-gradient(
    165deg,
    rgb(246 248 250/0.92) 0%,
    rgb(247 249 251/0.88) 45%,
    rgb(243 246 249/0.85) 100%
  );color:rgb(44 63 88);box-shadow:inset 0px 1px rgb(15 23 42/0.03),inset 0px 0px 0px 1px rgb(15 23 42/0.16),0px 8px 28px -10px rgb(15 23 42/0.05);caret-color:rgb(6 107 122)}
html[data-theme="light"] .preview-mode form#gen-form #prompt::placeholder{color:rgb(0 82 102/0.85)}
html[data-theme="light"] .preview-mode form#gen-form #prompt:hover{box-shadow:inset 0px 1px rgb(15 23 42/0.032),inset 0px 0px 0px 1px rgb(15 23 42/0.16),0px 10px 32px -8px rgb(15 23 42/0.05)}
html[data-theme="light"] .preview-mode form#gen-form #prompt:focus{box-shadow:inset 0px 1px rgb(15 23 42/0.038),inset 0px 0px 0px 1px rgb(15 23 42/0.16),0px 0px 0px 2px rgb(14 158 180/0.34),0px 12px 40px -8px rgb(15 23 42/0.055)}
html[data-theme="light"] body.preview-mode-active .site-header-nav{background-image:linear-gradient(
    180deg,
    rgb(244 246 249/0.52) 0%,
    rgb(247 248 251/0.58) 100%
  )!important;box-shadow:inset 0px 0px 0px 1px rgb(10 131 184/0.16),0px 3px 18px -8px rgb(15 23 42/0.122),0px 8px 28px -14px rgb(15 23 42/0.05)}
html[data-theme="light"] body.preview-mode-active .site-header-nav a{color:rgb(50 79 108)!important}
html[data-theme="light"] body.preview-mode-active .site-header-nav a:hover{color:rgb(13 77 119)!important;box-shadow:0px 4px 12px -4px rgb(15 23 42/0.05)}
html[data-theme="light"] body.preview-mode-active .site-header-nav a.nav-link-active{color:rgb(0 91 133)!important;box-shadow:inset 0px 0px 0px 1px rgb(14 158 180/0.204),0px 4px 14px -4px rgb(15 23 42/0.05)}
html[data-theme="light"] #pdf-preview-pane{border-color:rgb(15 23 42/0.112);background:linear-gradient(148deg, rgb(242 244 248/0.75) 0%, rgb(246 247 250/0.5) 100%),
    rgb(251 252 253);box-shadow:inset 0px 0px 0px 1px rgb(15 23 42/0.096),0px 24px 48px -12px rgb(15 23 42/0.144)}
html[data-theme="light"] .preview-mode:has(#pdf-tab-primary-track[data-side="sheet"]) #pdf-preview-pane{box-shadow:inset 0px 0px 0px 1px rgb(10 131 184/0.16),0px 24px 48px -12px rgb(15 23 42/0.144),0px 17px 56px -16px rgb(15 23 42/0.05)}
html[data-theme="light"] .preview-mode:has(#pdf-tab-primary-track[data-side="answers"]) #pdf-preview-pane{box-shadow:inset 0px 0px 0px 1px rgb(35 159 114/0.16),0px 24px 48px -12px rgb(15 23 42/0.144),0px 17px 56px -16px rgb(15 23 42/0.05)}
html[data-theme="light"] .preview-mode:has(#pdf-tab-primary-track[data-side="solutions"]) #pdf-preview-pane{box-shadow:inset 0px 0px 0px 1px rgb(184 10 35/0.16),0px 24px 48px -12px rgb(15 23 42/0.144),0px 17px 56px -16px rgb(15 23 42/0.05)}
html[data-theme="light"] .preview-mode:has(#tab-btn-ranking[aria-selected="true"]) #pdf-preview-pane{box-shadow:inset 0px 0px 0px 1px rgb(184 88 10/0.16),0px 24px 48px -12px rgb(15 23 42/0.144),0px 17px 56px -16px rgb(15 23 42/0.05)}
html[data-theme="light"] .pdf-viewport-scroll{background-color:rgb(255 255 255/0.4)}
html[data-theme="light"] .preview-mode .pdf-viewport-scroll{background-image:linear-gradient(180deg, rgb(243 246 249/0.52) 0%, rgb(251 251 253/0.5) 100%)}
/* ▲▲ LIGHT THEME END ▲▲ */
