@import url('/wired-fields.css');

/* Page styles arrange these controls. Their appearance and states live here. */
:root {
  --ui-control-radius: 9px;
  --ui-control-height: 44px;
  --ui-pencil-width: 0.95;
}

/* Keep the status inside the My Adventures link, including its keyboard target. */
.book-notice {
  display: block; white-space: nowrap; font: 700 .75rem/1.25 var(--ui-font);
  color: var(--book-ink); text-align: center;
}
.book-notice::before {
  content: ''; display: inline-block; width: .48em; height: .48em; margin-right: .35em;
  background: currentColor; border-radius: 50%; vertical-align: .1em;
}

/* A drawing in progress is marked with the studio's own pencil, not a stock spinner arc.
   It stays still: the paper planet on the page already shows the work moving. */
.book-notice[data-drawing]::before {
  width: 1.35em; height: 1em; margin-right: .3em; vertical-align: -.2em; border-radius: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 24' fill='none' stroke='%232b3240' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1.8 21c3.1-3.4 5.6-2.5 4.8-.7-.9 2 1.1 1.7 3.7.1l3.4-1.8'/%3E%3Cpath d='m13.7 18.7 2-6.2L26.1 2.1q.9-.7 1.8.1l2.2 2.2q.7.8-.1 1.6L19.4 16.7z' fill='%23f6d392'/%3E%3Cpath d='m15.8 12.5 3.6 4.1m4.5-12.3 3.8 3.8m-10 6.2 7.9-8m-12 12.3 1.3-3 1.9 1.9z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.ui-button,
.ui-choice,
.ui-field,
.ui-check,
.ui-range {
  box-sizing: border-box;
  font-family: var(--ui-font);
  touch-action: manipulation;
}

.ui-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6em;
  max-width: 100%;
  min-height: var(--ui-control-height);
  padding: 0.63em 1.08em;
  border: 1px solid transparent;
  border-radius: var(--ui-control-radius);
  box-shadow: none;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.24;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}
.ui-primary {
  color: var(--ui-on-accent);
  background: var(--book-orange);
  border-color: var(--ui-on-accent);
}
.ui-secondary {
  color: var(--book-ink);
  background: var(--ui-surface);
  border-color: var(--ui-field-border);
}
.ui-text {
  color: inherit;
  background: transparent;
  text-decoration: underline;
  text-underline-offset: 0.22em;
  text-decoration-thickness: 1px;
  padding-inline: 0.15em;
}
.ui-button.ui-icon {
  min-width: var(--ui-control-height);
  padding: 0.45em;
  font-size: 1.2rem;
}
.ui-button.ui-primary:hover:not(:disabled):not([aria-disabled="true"]),
.ui-button.ui-secondary:hover:not(:disabled):not([aria-disabled="true"]) {
  box-shadow: inset 0 0 0 1px currentColor;
}
.ui-text:hover:not(:disabled),
.ui-nav a:hover {
  text-decoration: underline;
  text-decoration-thickness: 2px;
}
.ui-button[aria-busy="true"] {
  cursor: progress;
}

.ui-field {
  min-height: var(--ui-control-height);
  max-width: 100%;
  padding: 0.62em 0.76em;
  border: 1px solid var(--ui-field-border);
  border-radius: var(--ui-control-radius);
  color: var(--book-ink);
  background-color: var(--ui-surface);
  caret-color: var(--ui-focus);
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.4;
}
input.ui-field,
textarea.ui-field {
  width: 100%;
}
textarea.ui-field {
  min-height: 5.5em;
  resize: vertical;
}
.ui-field::placeholder {
  color: var(--book-muted);
  opacity: 1;
}
.ui-field:read-only:not(select) {
  background-color: var(--book-sand);
}
.ui-field:is(:user-invalid, [aria-invalid="true"]) {
  border-color: var(--ui-error);
  box-shadow: inset 0 0 0 1px var(--ui-error);
}
.ui-check {
  width: 1.16rem;
  height: 1.16rem;
  flex-shrink: 0;
  padding: 0;
  margin: 0;
  vertical-align: middle;
  accent-color: var(--book-leaf);
}
.ui-range {
  accent-color: var(--book-leaf);
  min-height: var(--ui-control-height);
  max-width: 100%;
  cursor: pointer;
}
.ui-choice {
  position: relative;
  min-height: var(--ui-control-height);
  min-width: 0;
  border: 1px solid var(--ui-field-border);
  border-radius: var(--ui-control-radius);
  background: var(--ui-surface);
  color: var(--book-ink);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.ui-choice:is(label, button):not(.ui-choice-art) {
  padding: 0.46em 0.72em;
}
label.ui-choice:not(.ui-choice-art) {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
}
.ui-choice-art > strong:last-child {
  padding: 0.3em;
}
.ui-choice:hover {
  border-color: var(--book-leaf);
}
.ui-choice:is([aria-pressed="true"], [aria-selected="true"], :has(:checked)) {
  color: var(--ui-on-sage);
  border-color: var(--book-leaf);
  background: var(--book-sage);
  box-shadow: inset 0 0 0 2px var(--book-leaf);
}
.ui-choice:has(:focus-visible) {
  outline: 3px solid var(--ui-focus);
  outline-offset: 3px;
}
.ui-choice-art {
  display: flex;
  flex-direction: column;
  text-align: center;
  overflow: hidden;
}
.ui-choice-art > .ui-check {
  position: absolute;
  top: 0.45rem;
  left: 0.45rem;
  opacity: 1;
}
.ui-choice-art img {
  max-width: 100%;
}
.ui-choice-art:has(:checked):not(:has(:focus-visible)) {
  outline: 0;
}

.ui-nav :is(a:not(.brand), button) {
  min-height: var(--ui-control-height);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-underline-offset: 0.25em;
}
.ui-nav button:not(.ui-button) {
  border: 0;
  background: transparent;
  color: inherit;
  font: 700 0.95rem/1.2 var(--ui-font);
  padding: 0.4em 0.2em;
  cursor: pointer;
}
.ui-nav [aria-current]:not([aria-current="false"]) {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.24em;
}
.ui-disclosure > summary {
  cursor: pointer;
  min-height: var(--ui-control-height);
  padding-block: 0.55em;
  text-underline-offset: 0.23em;
}
.ui-disclosure > summary:hover {
  text-decoration: underline;
}

.ui-status {
  color: var(--book-ink);
}
.ui-status:is([data-error], [data-state="error"]),
.ui-error {
  color: var(--ui-error);
}
/* A pencil-hatched bar. Wired draws the outline (ui-progress-frame); without it a plain line stands in. */
.ui-progress {
  appearance: none;
  box-sizing: border-box;
  width: min(100%, 24rem);
  height: 1.5rem;
  padding: 5px 8px 6px 6px;
  vertical-align: middle;
  border: 1.5px solid var(--ui-field-border);
  border-radius: 3px;
  background: transparent;
  color: var(--book-leaf);
  accent-color: var(--book-leaf);
}
.ui-progress::-webkit-progress-bar { background: transparent; }
/* The fill is coloured in by hand: slanted strokes of uneven weight and pressure with paper
   grain showing through, a faint wash underneath, wavy top and bottom edges, and both ends cut
   along the last stroke's slant instead of a ruler-straight line. Mask layers, top first:
   strokes ∩ (wavy band − slanted ends). */
.ui-progress {
  --ui-progress-mask:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 46 12' preserveAspectRatio='none'%3E%3Cfilter id='g' x='0' y='0' width='1' height='1'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.32 .5' numOctaves='2' seed='7'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -2.4 2.15'/%3E%3CfeComposite in='SourceGraphic' operator='in'/%3E%3C/filter%3E%3Cg filter='url(%23g)' fill='none' stroke='black' stroke-linecap='round'%3E%3Crect width='46' height='12' fill='black' fill-opacity='.2' stroke='none'/%3E%3Cpath d='M-6.2 12.8Q-3.2 6.2 0.5-.7' stroke-width='2.4' stroke-opacity='0.85'/%3E%3Cpath d='M-0.6 12.8Q2.7 6.2 6.4-.7' stroke-width='2.9' stroke-opacity='1'/%3E%3Cpath d='M5.4 12.8Q8.7 6.2 12.3-.7' stroke-width='2.1' stroke-opacity='0.8'/%3E%3Cpath d='M11.1 12.8Q13.6 6.2 17.1-.7' stroke-width='2.7' stroke-opacity='0.95'/%3E%3Cpath d='M17.3 12.8Q20.1 6.2 24.4-.7' stroke-width='2.2' stroke-opacity='0.85'/%3E%3Cpath d='M22.8 12.8Q24.8 6.2 29.9-.7' stroke-width='3' stroke-opacity='1'/%3E%3Cpath d='M28.9 12.8Q31.1 6.2 35.5-.7' stroke-width='2.3' stroke-opacity='0.8'/%3E%3Cpath d='M34.6 12.8Q37.3 6.2 41.3-.7' stroke-width='2.8' stroke-opacity='0.95'/%3E%3Cpath d='M40.4 12.8Q42.5 6.2 46.4-.7' stroke-width='2.4' stroke-opacity='0.85'/%3E%3C/g%3E%3C/svg%3E") 0 0 / 46px 100% repeat-x,
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 60 12' preserveAspectRatio='none'%3E%3Cpath d='M0 .9C12 .1 21 1.5 33 .6S52 .2 60 .9V11.2C47 12 38 10.8 27 11.6S8 11.9 0 11.2Z'/%3E%3C/svg%3E") 0 0 / 60px 100% repeat-x,
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 12' preserveAspectRatio='none'%3E%3Cpath d='M14 0H11.6C11.2 1.6 9.4 3.8 8.4 6.2S5.4 10.6 3.8 12H14Z'/%3E%3C/svg%3E") right top / 14px 100% no-repeat,
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 12' preserveAspectRatio='none'%3E%3Cpath d='M0 0H6.2C5.4 2.4 3.6 5.2 2.6 8S.8 11.4.4 12H0Z'/%3E%3C/svg%3E") left top / 10px 100% no-repeat;
}
/* Each browser's pseudo-element gets its own rule: one unknown selector would drop the whole list. */
.ui-progress::-webkit-progress-value {
  background: currentColor;
  -webkit-mask: var(--ui-progress-mask);
  -webkit-mask-composite: source-in, source-out, source-over, source-over;
  mask: var(--ui-progress-mask);
  mask-composite: intersect, subtract, add, add;
  transition: width .4s ease;
}
.ui-progress::-moz-progress-bar {
  background: currentColor;
  -webkit-mask: var(--ui-progress-mask);
  -webkit-mask-composite: source-in, source-out, source-over, source-over;
  mask: var(--ui-progress-mask);
  mask-composite: intersect, subtract, add, add;
  transition: width .4s ease;
}
.ui-progress-frame {
  position: relative;
  display: inline-block;
  width: min(100%, 24rem);
  vertical-align: middle;
}
.ui-progress-frame > .ui-progress {
  display: block;
  width: 100%;
  border-color: transparent;
  background: transparent;
}
.ui-progress-frame > wired-card.ui-pencil-frame { color: var(--book-ink); }
/* A hidden bar takes its pencil frame with it, so no empty line or stray mark is left. */
.ui-progress-frame:has(> .ui-progress[hidden]) { display: none; }
@media (prefers-reduced-motion: reduce) {
  .ui-progress::-webkit-progress-value { transition: none; }
  .ui-progress::-moz-progress-bar { transition: none; }
}
@media (forced-colors: active) {
  .ui-progress::-webkit-progress-value { background: Highlight; -webkit-mask: none; mask: none; }
  .ui-progress::-moz-progress-bar { background: Highlight; mask: none; }
}
.ui-dialog {
  box-sizing: border-box;
  width: min(28rem, calc(100% - 2rem));
  max-height: 88dvh;
  overflow: auto;
  padding: clamp(1rem, 4vw, 1.65rem);
  border: 1px solid var(--ui-field-border);
  border-radius: 16px;
  background: var(--ui-surface);
  color: var(--book-ink);
  box-shadow: 0 8px 30px color-mix(in srgb, var(--book-ink) 16%, transparent);
}
.ui-dialog::backdrop {
  background: color-mix(in srgb, var(--book-ink) 58%, transparent);
}
/* A yes-or-no question (confirm-dialog.js): the question, what it is about, then Back and the yes. */
.confirm-dialog { width: min(26rem, calc(100% - 2rem)); text-align: center; }
.confirm-dialog h2 { margin: 0 0 .75rem; font: 600 clamp(1.6rem, 6vw, 2.1rem)/1.1 var(--title); letter-spacing: -.02em; }
.confirm-dialog .dialog-actions { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-top: 1.5rem; }
.confirm-dialog .dialog-actions .cta { margin: 0; }
:is(a, button, input, textarea, select, summary):focus-visible {
  outline: 3px solid var(--ui-focus);
  outline-offset: 3px;
}
:is(
  .ui-button,
  .ui-choice,
  .ui-field,
  .ui-range,
  .ui-check,
  .ui-nav button
):disabled,
.ui-button[aria-disabled="true"],
.ui-choice:has(:disabled) {
  opacity: 0.65;
  cursor: not-allowed;
}
.ui-button[aria-busy="true"]:disabled {
  cursor: progress;
}
[hidden] {
  display: none !important;
}

/* The native action remains a form submitter or link when its Wired face is present. */
.ui-action-source { display: none !important; }
wired-button {
  font: 700 1rem/1.24 var(--ui-font);
  letter-spacing: normal;
  text-transform: none;
}
wired-button.ui-wired-action {
  display: inline-flex;
  align-items: stretch;
  justify-content: center;
  padding: 0;
  box-sizing: border-box;
  max-width: 100%;
  min-height: var(--ui-control-height);
  border: 0;
  border-radius: 5px 7px 4px 6px;
  box-shadow: none;
  cursor: pointer;
}
wired-button.ui-wired-action[disabled] {
  opacity: .65;
  cursor: not-allowed;
}
wired-button.ui-wired-action[aria-busy="true"] { cursor: progress; }
wired-button.ui-wired-action:is(.ui-primary,.ui-secondary):hover:not([disabled]) {
  box-shadow: none;
  text-decoration: underline;
  text-underline-offset: .22em;
}
wired-button.ui-wired-action:focus-within { overflow: visible; }
wired-button.ui-wired-action.ui-step {
  font-size: .9rem;
  font-weight: 700;
}
wired-button.ui-wired-action[hidden] { display: none !important; }

@media (forced-colors: active) {
  .ui-choice:is([aria-pressed="true"], [aria-selected="true"], :has(:checked)) {
    outline: 2px solid Highlight;
  }
}

/* Wired owns the perimeter. Native text editing and the radio label stay intact. */
.ui-text-frame { display: block; position: relative; min-width: 0; }
.ui-text-frame > .ui-field { display: block; margin: 0; }
.specimen-fields > label > .ui-text-frame { margin-top: 5px; }
.story-option:has(> .ui-pencil-frame) { position: relative; }
wired-card.ui-pencil-frame {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  padding: 0;
  pointer-events: none;
  color: var(--ui-field-border);
}
.ui-text-frame > :is(input,textarea).ui-field,
:is(label.ui-choice,.story-option):has(> .ui-pencil-frame) {
  border-color: transparent !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}
:is(label.ui-choice,.story-option):has(> .ui-pencil-frame):has(:checked):not(:focus-within) {
  outline: 0;
}
:is(label.ui-choice,.story-option):is(:hover,:has(:checked)) > .ui-pencil-frame {
  color: var(--book-leaf);
}
.ui-text-frame:has(:is(:user-invalid,[aria-invalid="true"])) > .ui-pencil-frame {
  color: var(--ui-error);
}
.ui-text-frame:has(:disabled) > .ui-pencil-frame { opacity: .55; }
.ui-text-frame:has(:focus-visible) > .ui-pencil-frame { color: var(--ui-focus); }
/* The pencil frame itself turns the focus color, so the field draws no second, square frame around it. */
@media (forced-colors: none) {
  .ui-text-frame > :is(input,textarea).ui-field:focus-visible { outline: none; }
  .ui-text-frame:has(:focus-visible) > .ui-pencil-frame { filter: drop-shadow(0 0 1px var(--ui-focus)) drop-shadow(0 0 1px var(--ui-focus)); }
}
@media (forced-colors: active) {
  wired-card.ui-pencil-frame { color: CanvasText; }
}

/* A mounted illustration on a sheet trimmed by hand: four straight cuts, none quite square,
   so the corners sit a hair off true. The shadow is deeper under the lower right corner,
   as if that corner lifts slightly off the page. */
.ui-paper {
  position: relative;
  isolation: isolate;
  padding: clamp(6px, .85vw, 12px);
  padding-bottom: clamp(10px, 1.35vw, 18px);
  filter: drop-shadow(0 1px 0 color-mix(in srgb, var(--book-ink) 26%, transparent))
          drop-shadow(1px 3px 3px color-mix(in srgb, var(--book-ink) 10%, transparent))
          drop-shadow(3px 6px 6px color-mix(in srgb, var(--book-ink) 7%, transparent));
}
.ui-paper::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--ui-paper-background, var(--ui-surface));
  clip-path: polygon(0 1.5px, calc(100% - 1px) 0, 100% calc(100% - 2px), 1.5px 100%);
}

/* A sheet with more of the book under it: <div class="ui-paper-stack"><div class="ui-paper">…</div></div>.
   Two blank sheets sit askew underneath (data-sheets="1" keeps one). Each has its own edge and
   shadow, and the top sheet's shadow falls across them, so the stack reads on any background
   (Adam, November 29, 2026: "you can barely tell there is a page behind it"). Page styles set its
   display (a figure or div is a block; the Ready page shrinks it to the drawing). Move or turn a
   sheet with --ui-stack-back-x/-y/-turn and --ui-stack-under-x/-y/-turn. */
.ui-paper-stack {
  position: relative;
  isolation: isolate;
}
.ui-paper-stack::before,
.ui-paper-stack::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: var(--ui-paper-stack-background, #f5f1e8);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--book-ink) 11%, transparent),
              0 1px 0 color-mix(in srgb, var(--book-ink) 24%, transparent),
              1px 4px 7px color-mix(in srgb, var(--book-ink) 12%, transparent);
}
.ui-paper-stack::before {
  transform: translate(var(--ui-stack-under-x, -5px), var(--ui-stack-under-y, 6px)) rotate(var(--ui-stack-under-turn, -2.4deg));
}
.ui-paper-stack::after {
  transform: translate(var(--ui-stack-back-x, 8px), var(--ui-stack-back-y, 9px)) rotate(var(--ui-stack-back-turn, 1.6deg));
}
.ui-paper-stack[data-sheets="1"]::before { content: none; }
.ui-paper-stack > .ui-paper { display: block; }

/* The current stop has a broad pencil swatch inside its Wired outline. */
.ui-nav .ui-step:is([aria-current="step"], [aria-current="page"]) {
  position: relative;
  isolation: isolate;
  color: var(--ui-on-sage);
  text-decoration: none;
}
.ui-nav .ui-step:is([aria-current="step"], [aria-current="page"])::before {
  content: "";
  position: absolute;
  inset: 4px;
  z-index: -1;
  pointer-events: none;
  background-color: var(--book-sage);
  background-image: repeating-linear-gradient(167deg, transparent 0 3px,
    color-mix(in srgb, var(--ui-surface) 19%, transparent) 3px 4px, transparent 4px 6px);
  clip-path: polygon(1% 9%, 30% 4%, 67% 7%, 97% 2%, 99% 27%, 97% 55%,
    100% 90%, 73% 96%, 47% 92%, 3% 99%, 1% 69%, 3% 38%);
}
@media (forced-colors: active) {
  .ui-nav .ui-step[aria-current] { outline: 2px solid Highlight; text-decoration: underline; }
}

/* The two projected axes describe a tilted orbit. Depth also determines paint
   order, so the illustration's own silhouette hides the rocket on the far pass. */
@property --moonshot-orbit-phase {
  syntax: '<angle>';
  inherits: true;
  initial-value: 0deg;
}
moonshot-orbit { display: inline-grid; position: relative; isolation: isolate; }
moonshot-orbit > :not(.orbit-flight) { grid-area: 1 / 1; position: relative; z-index: 1; }
moonshot-orbit > .orbit-flight {
  display: none; position: absolute; inset: 0; pointer-events: none;
  --depth: sin(var(--moonshot-orbit-phase));
  --side: cos(var(--moonshot-orbit-phase));
  /* Switch layers at the widest turns, with the entire ship clear of the rim. */
  --orbit-radius-x: .73;
  z-index: calc(1 + sign(var(--depth)));
  transform: translate(calc(100% * var(--orbit-radius-x) * var(--side)), calc(var(--orbit-center-y, 0%) + 14% * var(--depth) - 9% * var(--side)));
}
moonshot-orbit[active] > .orbit-flight { display: block; }
moonshot-orbit > .orbit-flight::after {
  content: ''; position: absolute; left: 50%; top: 50%; width: 28%; aspect-ratio: 1;
  background: var(--orbit-ship, url('/assets/moonshot-rocket.svg')) center / contain no-repeat;
  /* Aim the nose along the tangent and bring the near pass closer. */
  transform: translate(-50%, -50%)
    rotate(calc(54deg + atan2(calc(.14 * var(--side) + .09 * var(--depth)), calc(-1 * var(--orbit-radius-x) * var(--depth)))))
    scale(calc(.88 + .23 * var(--depth)));
}
@media screen and (prefers-reduced-motion: no-preference) {
  moonshot-orbit[active] > .orbit-flight {
    animation: moonshot-orbit var(--orbit-duration, 2s) infinite;
    animation-play-state: paused;
  }
  moonshot-orbit[active][data-in-view] > .orbit-flight { animation-play-state: running; }
  @keyframes moonshot-orbit {
    0% { --moonshot-orbit-phase: 0deg; animation-timing-function: cubic-bezier(.33, .44, .65, .79); }
    43% { --moonshot-orbit-phase: 180deg; animation-timing-function: cubic-bezier(.32, .25, .72, .51); }
    100% { --moonshot-orbit-phase: 360deg; }
  }
}
@media print { moonshot-orbit[active] > .orbit-flight { display: none; } }

moonshot-paper-planet { display: block; width: var(--paper-planet-size, 144px); aspect-ratio: 1; }
moonshot-paper-planet[hidden] { display: none; }
moonshot-paper-planet > img { display: block; width: 100%; height: 100%; object-fit: contain; }

/* Anchor the wordmark and library label to the same baseline on every screen. */
@media screen {
  header.app-header {
    box-sizing: content-box;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: min(1140px, calc(100% - 48px));
    min-height: 55px;
    margin: 0 auto;
    padding: 12px 0 0;
    border: 0;
  }
  .launch .app-header { position: absolute; inset: 12px 0 auto; z-index: 4; padding-top: 0; }
  .app-header nav, .header-section-links nav { display: flex; align-items: center; gap: 1rem; }
  .header-section-links { width: min(1140px, calc(100% - 48px)); margin: 0 auto 1rem; }
  .header-section-links nav { flex-wrap: wrap; }
  /* In-page links to the gallery's sections: quieter than the staff pages above them. */
  .header-section-links .ui-link { font-weight: 400; }
  .app-header .rocket-wordmark {
    min-height: 44px;
    font: 700 clamp(24px, 3vw, 36px)/1 var(--title);
    letter-spacing: .01em;
    gap: .17em;
    color: var(--book-ink);
    text-decoration: none;
  }
  .app-header .adventures-link {
    position: relative;
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0;
    font: 700 14px/1.45 var(--ui-font);
    letter-spacing: normal;
    white-space: nowrap;
    color: var(--book-ink);
    text-decoration: none;
  }
  .app-header .book-notice { position: absolute; top: calc(50% + 9px); right: 0; }
  @media (min-width: 701px) { header.app-header { min-height: 72px; } }
  /* On phones My Adventures offers only the next step; the page itself is the library. */
  @media (max-width: 520px) {
    .app-header:has(#gift-nav) .adventures-link { display: none; }
    .app-header #gift-nav { display: inline-flex; align-items: center; min-height: 44px; font: 700 14px/1.45 var(--ui-font); white-space: nowrap; }
  }
}

/* The staff pages' bar (admin and the Studio controls gallery), built from public/admin-pages.js:
   the wordmark home, then every staff page. It is a strip of warm paper with a pencil rule under it,
   pinned to the top so every page is one tap away however far down a long list you are. The current
   page wears the landing page's orange, so where you are is obvious at a glance (Adam, November 30,
   2026: "make it obvious what step they are on"). On phones the wordmark scrolls away and the pages
   share one row with short names; nothing wraps or squeezes. */
@media screen {
  header.admin-header {
    position: sticky; top: 0; z-index: 20;
    box-sizing: border-box; width: 100%; max-width: none; min-height: 64px;
    margin: 0; padding: 10px max(24px, calc((100% - 1140px) / 2));
    gap: 24px;
    background: var(--ui-surface);
    border-bottom: 1.5px dashed color-mix(in srgb, var(--book-ink) 35%, transparent);
    box-shadow: 0 6px 14px -12px color-mix(in srgb, var(--book-ink) 60%, transparent);
  }
  header.admin-header .rocket-wordmark { font-size: 26px; min-height: 44px; }
  /* .app-header .admin-nav, so the header's own 1rem nav gap doesn't win. */
  .app-header .admin-nav { display: flex; align-items: center; gap: 4px; }
  .admin-nav a {
    display: inline-flex; align-items: center; justify-content: center;
    min-height: 40px; padding: 0 14px; border-radius: 999px;
    font: 700 15px/1.2 var(--ui-font); color: var(--book-ink); text-decoration: none; white-space: nowrap;
  }
  .admin-nav a:hover { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: .24em; }
  .admin-nav a[aria-current="page"] { background: var(--book-orange); box-shadow: inset 0 0 0 1.5px var(--book-ink); }
  .admin-nav a[aria-current="page"]:hover { text-decoration: none; }
  .admin-nav a:focus-visible { outline: 3px solid var(--ui-focus); outline-offset: 2px; }
  .admin-nav-short { display: none; }
  @media (max-width: 700px) {
    /* The header itself steps aside so the bar alone pins to the top of the page. */
    header.admin-header { display: contents; }
    header.admin-header .rocket-wordmark { display: flex; width: calc(100% - 36px); margin: 12px auto 4px; font-size: 24px; }
    .app-header .admin-nav {
      position: sticky; top: 0; z-index: 20;
      justify-content: space-between; gap: 2px; padding: 4px 8px;
      /* Seven pages share one row; if a narrow phone can't fit them, the bar scrolls, never the page. */
      overflow-x: auto; scrollbar-width: none;
      background: var(--ui-surface);
      border-block: 1.5px dashed color-mix(in srgb, var(--book-ink) 35%, transparent);
      box-shadow: 0 6px 14px -12px color-mix(in srgb, var(--book-ink) 60%, transparent);
    }
    .admin-nav a { flex: 0 0 auto; min-height: 44px; padding: 0 4px; font-size: 13px; }
    .admin-nav-long { display: none; }
    .admin-nav-short { display: inline; }
  }
  @media (max-width: 380px) { .admin-nav a { padding: 0 3px; font-size: 12px; } }
  @media (max-width: 340px) { .admin-nav a { padding: 0 2px; font-size: 11px; } }
}

@media print { .app-header, .header-section-links { display: none; } }

/* The plain link: a quiet, underlined action with a full tap height. Used beside one primary
   button wherever a second choice should not compete with it (studio, gift page, My Adventures). */
.ui-link { display: inline-flex; align-items: center; min-height: 44px; padding: 0; border: 0; background: none; color: inherit; font: 700 1rem/1.3 var(--ui-font); cursor: pointer;
  text-decoration: underline; text-underline-offset: .22em; text-decoration-thickness: 1px; }
.ui-link:hover { text-decoration-thickness: 2px; }
.ui-link:focus-visible { outline: 3px solid var(--ui-focus); outline-offset: 3px; }
.ui-link:disabled { opacity: .55; cursor: not-allowed; }

/* The site footer on every customer page, from renderAppFooter (app-header.mjs): the wordmark,
   then quiet links to the terms and privacy pages. On phones the links get a row of their own. */
.site-footer { box-sizing: border-box; width: min(1060px, calc(100% - 48px)); margin: 48px auto 0; padding: 14px 0 max(18px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--book-rule); display: flex; align-items: center; flex-wrap: wrap; gap: 4px 24px; }
.site-footer .rocket-wordmark { margin-right: auto; min-height: 44px; font: 700 19px/1 var(--title); letter-spacing: .01em; color: var(--book-ink); text-decoration: none; }
.site-footer-links { display: flex; align-items: center; flex-wrap: wrap; gap: 0 24px; }
.site-footer-links a, .site-footer-links .ui-link { display: inline-flex; align-items: center; min-height: 44px; font: 400 15px/1.3 var(--ui-font); color: var(--book-ink);
  text-decoration: underline; text-underline-offset: .22em; text-decoration-thickness: 1px; }
.site-footer-links a:hover, .site-footer-links .ui-link:hover { text-decoration-thickness: 2px; }
@media (max-width: 600px) {
  .site-footer { flex-direction: column; align-items: flex-start; gap: 0; }
  .site-footer-links { gap: 0 22px; }
}
@media print { .site-footer { display: none; } }
/* The line under "Create account" (create, studio): accounts are for adults, and the terms they agree to. */
.account-terms { margin: 8px 0 14px; font: 400 14px/1.45 var(--ui-font); color: var(--book-muted); }
/* Links inside a sentence stay inline (the studio stretches its other links to 44px tap targets). */
.account-terms a { display: inline; min-height: 0; color: inherit; text-underline-offset: .2em; }

/* The ad cookie question (cookie-choice.js), asked only where the law wants a yes first. A small
   sheet of paper above the bottom edge (and above a step's pinned bottom bar), both answers alike. */
.cookie-choice { position: fixed; z-index: 30; left: 50%; bottom: calc(var(--ui-bottom-bar-space, 0px) + 12px); transform: translateX(-50%);
  box-sizing: border-box; width: min(30rem, calc(100% - 24px)); padding: 14px 18px 10px; color: var(--book-ink); font: 400 15px/1.45 var(--ui-font); }
.cookie-choice p { margin: 0; text-wrap: pretty; }
.cookie-choice a { color: inherit; text-underline-offset: .22em; }
.cookie-choice-actions { display: flex; flex-wrap: wrap; gap: 8px 12px; margin-top: 10px; }
/* Wider screens tuck it into the bottom-left corner, clear of the page's main button. */
@media (min-width: 761px) { .cookie-choice { left: 24px; bottom: calc(var(--ui-bottom-bar-space, 0px) + 24px); transform: none; width: min(26rem, calc(100% - 48px)); } }
@media print { .cookie-choice { display: none; } }

/* The bottom bar: a step's choice or price and its one way on, <div class="ui-bottom-bar">…</div>.
   One shared bar for every step that has one (Adam, November 30, 2026: "fixing something in one
   place should fix it everywhere"). On phones it is pinned to the bottom edge of the screen, edge
   to edge, at every scroll position and on short pages too, so no strip of sky ever shows under it.
   ui-bottom-bar.js measures it and the page keeps that much room at its end, so nothing hides
   behind it. Above 760px the page places it in its own layout. Pages arrange what is inside the
   bar; they don't set its position, margin, padding or background on phones. */
@media (max-width: 760px) {
  .ui-bottom-bar {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 20;
    box-sizing: border-box;
    margin: 0;
    padding: 10px max(16px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    background: var(--ui-paper-background, var(--book-paper));
    border: 0;
    border-top: 1px solid var(--book-rule);
    border-radius: 0;
    box-shadow: 0 -14px 26px -22px color-mix(in srgb, var(--book-ink) 70%, transparent);
    filter: none;
  }
  .ui-bottom-bar[hidden] { display: none; }
  .ui-bottom-bar::before { clip-path: none; }
  body { padding-bottom: var(--ui-bottom-bar-space, 0px); }
  html { scroll-padding-bottom: calc(var(--ui-bottom-bar-space, 0px) + 16px); }
}
