:root {
  --bg: #1b1714;
  --paper: #f4efe6;
  --ink: #1c1612;
  --muted: #b3a89c;
  --faint: #8c8278;
  --line: #3a332c;
  --field: #2a241f;
  --accent: #c4492c;
  --accent-ink: #fff8f4;
  --danger: #ffb1a3;
  --serif: "Fraunces", "Iowan Old Style", Palatino, Georgia, serif;
  --sans: "Avenir Next", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }

/* Author display rules (e.g. .segmented { display: grid }) must not revive [hidden]. */
[hidden] {
  display: none !important;
}

html, body { min-height: 100%; }

body {
  margin: 0;
  display: grid;
  grid-template-columns: minmax(280px, 380px) 1fr;
  background:
    radial-gradient(1200px 700px at 70% 20%, #2a241f 0%, transparent 55%),
    var(--bg);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
}

aside {
  padding: 32px 28px 36px;
  border-right: 1px solid var(--line);
  overflow: auto;
  max-height: 100vh;
}

.kicker {
  margin: 0 0 8px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand-block {
  display: inline-block;
  max-width: 100%;
  vertical-align: top;
}

.brand {
  --brand-pad-y: 0.22em;
  --brand-pad-right: 0.55em;
  /* Square matching the pill end circle (logo height + vertical padding). */
  --brand-well: calc(1.012em + 2 * var(--brand-pad-y));
  /* Logo aspect after tight crop → width at height 1.012em */
  --brand-c-width: calc(1.012em * 153 / 188);
  /* Pull past empty well space only — “o” sits clear of the C opening,
     roughly one mono cell right of the over-tucked nest. */
  --brand-kern-tuck: 0.07em;
  display: inline-flex;
  align-items: flex-end;
  gap: 0;
  margin: 0;
  padding: var(--brand-pad-y) var(--brand-pad-right) var(--brand-pad-y) 0;
  border-radius: 999px;
  /* Same color as the slogan text so the C’s black lines stay visible. */
  background: var(--muted);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 44px;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1;
  box-shadow: inset 0 0 0 1px rgba(28, 22, 18, 0.12);
}

/* Left circular end of the pill — spans the full pill height so its center
   is the left radius center. Negative margin pulls “ofiants” in to normal
   mono letter spacing after the C glyph. */
.brand-c-well {
  box-sizing: border-box;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  flex: 0 0 var(--brand-well);
  width: var(--brand-well);
  height: var(--brand-well);
  margin-block: calc(-1 * var(--brand-pad-y));
  /* Cancel empty well space to the right of the C, then apply --brand-kern-tuck. */
  margin-right: calc(
    (var(--brand-c-width) - var(--brand-well)) / 2 - var(--brand-kern-tuck, 0.07em)
  );
  padding-bottom: var(--brand-pad-y);
  align-self: center;
}

.brand-c {
  display: block;
  /* 0.92em × 1.10 — 10% larger than the first logo mark */
  height: 1.012em;
  width: auto;
  object-fit: contain;
}

.brand-rest {
  display: block;
  padding-bottom: 0.02em;
}

.tagline {
  margin: 8px 0 0;
  width: 100%;
  box-sizing: border-box;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.08em;
  line-height: 1.2;
  text-transform: uppercase;
  white-space: nowrap;
  text-align: left;
}

.lede {
  margin: 10px 0 0;
  max-width: 36ch;
  color: var(--muted);
}

.mode-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 4px;
  margin-top: 16px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--field);
}

.mode-toggle button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 0;
  border-radius: 10px;
  padding: 8px 6px;
  line-height: 1.15;
  text-align: center;
}

.mode-toggle .mode-word {
  display: block;
  text-align: center;
}

.mode-toggle button[aria-selected="true"] {
  background: var(--paper);
  color: var(--ink);
}

#start-panel,
#lines-panel,
#figure-block,
#colors-panel,
#real-panel {
  margin-top: 15px;
}

.seed-sequence-row {
  display: grid;
  grid-template-columns: 1fr 3fr;
  gap: 12px;
  align-items: start;
}

.seed-block {
  min-width: 0;
}

.seed-block .figure-code {
  padding: 10px 8px;
  font-size: 14px;
  text-align: center;
}

.sequence-field {
  min-width: 0;
}

.triple {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  margin-top: 11px;
}

#colors-panel {
  margin-top: 6px;
}

#real-panel {
  margin-top: 12px;
}

.progression-bar {
  display: flex;
  width: 100%;
  height: 2.75rem;
  margin-top: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--field);
}

.progression-bar .progression-swatch {
  flex: 1 1 0;
  min-width: 0;
  height: 100%;
}

.suggested-palettes {
  display: grid;
  gap: 8px;
  margin: 0 0 6px;
}

.suggested-palette {
  display: flex;
  width: 100%;
  height: calc(2.75rem / 3);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--field);
  cursor: pointer;
}

.suggested-palette:hover,
.suggested-palette:focus-visible {
  border-color: var(--paper);
  outline: none;
}

.suggested-palette[aria-current="true"] {
  box-shadow: inset 0 0 0 1px var(--paper);
}

.suggested-palette .progression-swatch {
  flex: 1 1 0;
  min-width: 0;
  height: 100%;
  pointer-events: none;
}

.color-actions-secondary {
  margin-top: 4px;
}

.real-toggles {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 12px 14px;
  margin-top: 11px;
}

.real-toggles .export-mode {
  width: auto;
  min-width: 8.25rem;
  flex: 1 1 auto;
  margin-left: auto;
}

.frame-dims {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  align-items: end;
  margin-top: 12px;
}

.frame-dim {
  margin: 0;
}

.frame-dim input {
  width: 100%;
}

.frame-capture {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  min-width: 0;
}

.frame-capture > .field-label {
  margin: 0;
  text-align: center;
}

.frame-capture-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.frame-swap,
.frame-arm {
  width: 2.5rem;
  height: 2.5rem;
  min-width: 2.5rem;
  padding: 0;
  border-radius: 8px;
  font-size: 16px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.frame-swap svg {
  display: block;
}

.frame-swap:disabled {
  opacity: 0.4;
  cursor: default;
}

.frame-arm[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.print-order {
  margin-top: 14px;
}

.print-picks {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: 10px;
  align-items: end;
}

.print-order .field {
  min-width: 0;
}

.print-order select {
  width: 100%;
  box-sizing: border-box;
  height: 2.5rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--field);
  color: var(--paper);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.02em;
  text-transform: none;
  padding: 0 12px;
  cursor: pointer;
}

.print-order select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.print-summary {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  margin-top: 8px;
}

#print-hint {
  min-height: 3.2em;
  margin: 0;
}

.checkout-price {
  min-width: 0;
  text-align: right;
}

.checkout-price-label {
  margin: 0 0 4px;
  color: #fff;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.checkout-price-value {
  margin: 0;
  color: #fff;
  font-family: var(--mono);
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.capture-dialog {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(12, 9, 7, 0.72);
}

.capture-dialog-card {
  width: min(560px, 100%);
  max-height: min(92vh, 900px);
  overflow: auto;
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #404040;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

.capture-dialog-image {
  width: 100%;
  max-height: 58vh;
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
}

.capture-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
}

#capture-order {
  flex: 1 1 14rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

#view.frame-armed {
  cursor: crosshair;
}

form { margin-top: 0; }

.field-label {
  margin: 0 0 8px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.figure-code {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  color: var(--paper);
  font-family: var(--mono);
  font-size: 16px;
  letter-spacing: 0.04em;
}

.scheme-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 16px;
  align-items: start;
  margin-top: 6px;
}

.size-column,
.gradient-column {
  display: grid;
  grid-template-rows: 2.5rem 2.5rem;
  gap: 10px;
  justify-items: start;
  align-items: center;
  min-width: 0;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  align-items: stretch;
  box-sizing: border-box;
  height: 2.5rem;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--field);
  width: min(100%, 10.5rem);
}

.segmented button {
  border: 0;
  border-radius: 999px;
  padding: 0 10px;
  height: 100%;
}

.segmented button[aria-pressed="true"] {
  background: var(--paper);
  color: var(--ink);
}

.segmented button:disabled {
  opacity: 0.4;
}

.gradient-column .switch {
  align-self: center;
}

.gradient-steps {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  box-sizing: border-box;
  height: 2.5rem;
  width: min(100%, 10.5rem);
  margin: 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.gradient-steps-label {
  flex: 0 0 auto;
}

.gradient-steps input {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  height: 100%;
  padding: 0 10px;
  text-transform: none;
  letter-spacing: 0;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  color: var(--paper);
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.02em;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.switch-ui {
  position: relative;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: #3a332c;
  border: 1px solid var(--line);
  transition: background 0.15s ease;
  flex: 0 0 auto;
}

.switch-ui::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--paper);
  transition: transform 0.15s ease;
}

.switch input:checked + .switch-ui {
  background: var(--accent);
  border-color: var(--accent);
}

.switch input:checked + .switch-ui::after {
  transform: translateX(18px);
}

.switch input:focus-visible + .switch-ui {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.gradient-steps input:disabled {
  opacity: 0.45;
  cursor: default;
}

.color-slots {
  display: grid;
  gap: 10px;
  margin-top: 4px;
}

.color-slot-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.color-slot {
  display: grid;
  grid-template-columns: 2.2em minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--field);
  color: var(--paper);
  padding: 8px 10px;
  text-align: left;
}

.color-slot .swatch {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25);
}

.color-slot .slot-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.color-slot .slot-name {
  color: var(--paper);
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.color-slot-custom {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
  min-width: 0;
}

.slot-hex-input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  color: var(--paper);
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 10px 10px;
}

.slot-hex-input[aria-invalid="true"] {
  border-color: var(--danger);
}

.slot-hex-apply {
  min-width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border-radius: 8px;
  font-size: 16px;
  line-height: 1;
}

.color-actions { margin-top: 12px; }

#colors-panel .color-actions {
  margin-top: 6px;
}

.color-export-nolines {
  margin-top: 12px;
}

.swatch-popover {
  position: fixed;
  z-index: 40;
  width: min(280px, calc(100vw - 24px));
  max-height: min(70vh, 520px);
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #241e19;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

.swatch-list {
  display: grid;
  gap: 4px;
}

.swatch-option {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  align-items: center;
  width: 100%;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--paper);
  padding: 6px 8px;
  text-align: left;
}

.swatch-option:hover {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.04);
}

.swatch-option[aria-current="true"] {
  border-color: var(--accent);
  background: rgba(196, 73, 44, 0.14);
}

.swatch-option .swatch {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25);
}

.swatch-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.swatch-name {
  font-family: var(--sans);
  font-size: 13px;
}

.swatch-hex {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--faint);
}

#view.picking {
  cursor: crosshair;
}

#view.coloring-busy {
  cursor: progress;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

input[type="text"],
input:not([type]),
input[type="number"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  color: var(--paper);
  font-family: var(--mono);
  font-size: 16px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 10px 12px;
}

input[type="number"] {
  text-transform: none;
  letter-spacing: 0;
}

input[aria-invalid="true"] {
  border-color: var(--danger);
}

.hint {
  min-height: 2.6em;
  margin: 8px 0 0;
  color: var(--faint);
  font-size: 13px;
}

/* Keep Color slots from jumping when Seed/Size hint copy changes length. */
#scheme-hint {
  min-height: 5.2em;
  margin-top: 4px;
  margin-bottom: 2px;
}

#colors-panel .field-label {
  margin-bottom: 4px;
}

#colors-panel #coloring-hint {
  margin-top: 4px;
}

.hint.error { color: var(--danger); }

.scrub-hint {
  min-height: 0;
  margin-top: 10px;
}

.presets {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  margin-top: 9px;
  overflow: hidden;
}

.pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 11px;
}

.canvas-section {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.canvas-section > .field-label {
  margin-bottom: 10px;
}

.canvas-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px 18px;
}

.canvas-finite-options {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px 18px;
  flex: 1 1 12rem;
  min-width: 0;
}

.canvas-size-pair {
  margin-top: 0;
  flex: 1 1 10rem;
  min-width: 0;
}

.range {
  margin-top: 11px;
}

.range span {
  display: flex;
  justify-content: space-between;
}

.range output {
  color: var(--paper);
  text-transform: none;
  letter-spacing: 0;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--paper);
  font: 500 13px/1 var(--mono);
  letter-spacing: 0.02em;
  padding: 9px 12px;
  cursor: pointer;
}

button:hover { border-color: #6d6258; }

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

button[aria-pressed="true"] {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--paper);
}

button:disabled {
  opacity: 0.4;
  cursor: default;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.growth-codes {
  margin-top: 12px;
}

.lines-bottom-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
  align-items: start;
}

.code-key,
.line-colors-panel {
  min-width: 0;
}

.code-key .code-sort {
  width: 100%;
  max-width: none;
  margin-bottom: 10px;
}

.line-color-toggles {
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 8px;
}

.line-gradient-group {
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-end;
  gap: 8px;
  min-width: 0;
}

.switch-stacked {
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.switch-stacked .switch-label {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.line-gradient-steps {
  display: block;
  margin: 0;
}

.line-gradient-steps input {
  width: 3.25rem;
  height: 2.5rem;
  padding: 0 8px;
  text-align: center;
}

.line-color-mode {
  grid-template-columns: 1fr 1fr 1fr;
  width: 100%;
  max-width: none;
  margin: 0 0 8px;
}

.line-color-mode button {
  padding: 0 6px;
  font-size: 12px;
}

.line-color-slots {
  gap: 6px;
  margin-top: 0;
}

.line-color-slots .color-slot {
  padding: 6px 8px;
  border-radius: 8px;
}

.line-color-slots .color-slot .swatch {
  width: 22px;
  height: 22px;
}

.line-color-slots .color-slot .slot-name {
  font-size: 12px;
}

.legend {
  margin: 0;
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(var(--legend-rows, 1), auto);
  gap: 8px 10px;
  justify-content: start;
  width: 100%;
}

.legend div {
  display: grid;
  grid-template-columns: 1.6em 2.5rem;
  gap: 8px;
  align-items: center;
}

.legend dt {
  margin: 0;
  font-family: var(--mono);
  font-weight: 500;
}

.legend dd {
  margin: 0;
  color: var(--muted);
  line-height: 0;
}

.action-glyph {
  display: block;
  overflow: visible;
}

.action-glyph .glyph-stem,
.action-glyph .glyph-branch {
  fill: none;
  stroke: var(--paper);
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.action-glyph .glyph-stem {
  stroke: var(--muted);
  stroke-width: 1.5;
}

.action-glyph .glyph-dot {
  fill: var(--paper);
}

.status {
  min-height: 2.8em;
  margin: 15px 0 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

main {
  min-height: 100vh;
  min-width: 0;
  position: relative;
}

.stage {
  position: relative;
  min-height: 100vh;
  height: 100%;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(27, 23, 20, 0.15), transparent 30%),
    var(--bg);
}

#view {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 100vh;
  cursor: grab;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  background: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

#view.dragging { cursor: grabbing; }

.view-tools {
  position: absolute;
  top: 18px;
  right: 18px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(27, 23, 20, 0.78);
  backdrop-filter: blur(8px);
}

.view-tools button {
  min-width: 34px;
  padding: 8px 10px;
}

.zoom-readout {
  min-width: 3.4em;
  text-align: center;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

.view-hint {
  position: absolute;
  left: 18px;
  bottom: 16px;
  margin: 0;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 12px;
  pointer-events: none;
  text-shadow: 0 1px 0 rgba(27, 23, 20, 0.55);
}

.face-progress {
  position: absolute;
  right: 18px;
  bottom: 16px;
  margin: 0;
  max-width: min(22rem, calc(100% - 36px));
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(27, 23, 20, 0.78);
  backdrop-filter: blur(8px);
  color: var(--paper);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
  display: grid;
  gap: 6px;
  justify-items: end;
  text-align: right;
}

.face-progress-tip {
  margin: 0;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.35;
  letter-spacing: 0;
  text-wrap: pretty;
}

.face-progress-pct {
  margin: 0;
  color: var(--paper);
  letter-spacing: 0.04em;
}

@media (max-width: 860px) {
  body {
    display: flex;
    flex-direction: column;
  }

  aside {
    max-height: none;
    border-right: 0;
    border-top: 1px solid var(--line);
    order: 2;
  }

  /* Cap the canvas at two-thirds of the screen in the stacked (mobile)
     layout so controls below stay reachable by scrolling. The canvas uses
     touch-action: none for pan/zoom, so a full-viewport stage blocks scroll. */
  main {
    order: 1;
    flex: none;
    height: 66.666vh;
    height: 66.666dvh;
    max-height: 66.666vh;
    max-height: 66.666dvh;
    min-height: 0;
  }

  .stage {
    height: 100%;
    max-height: 100%;
    min-height: 0;
  }

  #view {
    height: 100%;
    max-height: 100%;
    min-height: 0;
  }

  .view-hint {
    left: 12px;
    right: 5.5rem;
    bottom: 12px;
  }

  .face-progress {
    right: 12px;
    bottom: 12px;
  }

  .brand { font-size: 36px; }
}
