/* ===================================================================
 * Al-Qalam · Man-Machine Schematic (light rendition)
 * seed b3abea09 · mode operate
 * ===================================================================
 * Arabic joining is a circuit, and this tool shows the wiring.
 *
 * Enamel-flat fills, no texture, no gradient on chrome. Separation is a
 * hairline rule, never a shadow — the one real shadow in the file lifts
 * the sheet off the bench, because that is a physical object on a
 * surface and nothing else here is.
 *
 * Signal colours are re-tuned, not inverted: the world's own neons
 * (#00FF66, #FFD100, #FF3B30) measure 1.36:1, 1.46:1 and 3.55:1 on
 * white and are unusable. Every value below was computed against the
 * paper ground before it was written.
 * ------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Ground */
  --paper:      #FFFFFF;
  --panel:      #F4F5F3;
  --panel-2:    #ECEEE9;
  --bench:      #EDEEEA;
  --grid:       #DEE0DA;
  --rule:       #0A0A0A;
  --hairline:   #C9CCC4;

  /* Ink — 19.8:1 and 8.5:1 on paper */
  --ink:        #0A0A0A;
  --ink-2:      #4A4E45;
  /* #7C8177 measured 3.99:1 on paper and 3.65:1 on panel — it carries 9px
     labels, so it has to clear 4.5. This value clears both grounds. */
  --ink-3:      #666A60;

  /* Signals — all ≥5:1 on paper, verified */
  --green:      #007A38;
  --green-fill: #00A344;
  --amber:      #8A5A00;
  --amber-fill: #E5A400;
  --red:        #C81E10;

  --ui: 'Jost', ui-sans-serif, system-ui, sans-serif;

  /* One authored curve. Exponential ease-out: movement is visible
     immediately, which is the moment the eye is actually watching. */
  --ease: cubic-bezier(0.23, 1, 0.32, 1);
  /* Spacing scale. Tight inside a group, generous between them. */
  --s-1: 4px;   /* hairline gaps */
  --s-2: 8px;   /* label to its control */
  --s-3: 16px;  /* control to control */
  --s-4: 28px;  /* group to group */

  --rail: 320px;
  --track: 44px;
}

html, body { height: 100%; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ------------------------------------------------------------------ */
/* Shell — masthead over three tracks                                  */
/* ------------------------------------------------------------------ */
.app {
  display: grid;
  grid-template-columns: var(--rail) 1fr var(--rail);
  grid-template-rows: var(--track) 1fr;
  grid-template-areas:
    "masthead masthead masthead"
    "left     stage    right";
  height: 100vh;
}

.masthead {
  grid-area: masthead;
  display: flex; align-items: center; gap: 16px;
  padding: 0 18px;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  position: relative;
}
/* The single hazard rule. One per surface; it is the accent, not a set. */
.masthead::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -3px;
  height: 2px; background: var(--red);
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand__mark {
  width: 26px; height: 26px; flex: none;
  border: 1.5px solid var(--rule);
  display: grid; place-items: center;
  font-family: 'Amiri', serif; font-size: 15px; line-height: 1;
  color: var(--ink);
}
.brand__name {
  font-size: 13px; font-weight: 500;
  letter-spacing: .22em; text-transform: uppercase;
}
.brand__sub {
  font-size: 9px; letter-spacing: .3em; text-transform: uppercase;
  color: var(--ink-3);
  padding-inline-start: 14px; margin-inline-start: 4px;
  border-inline-start: 1px solid var(--hairline);
}
.masthead__spacer { flex: 1; }
.masthead__meta {
  font-size: 9.5px; letter-spacing: .18em; text-transform: uppercase;
  color: var(--ink-3);
  display: flex; align-items: center; gap: 14px;
}
.masthead__meta b { color: var(--ink); font-weight: 500; }

.rail {
  background: var(--panel);
  display: flex; flex-direction: column; overflow: hidden;
}
.rail--left  { grid-area: left;  border-right: 1px solid var(--rule); }
.rail--right { grid-area: right; border-left:  1px solid var(--rule); }
.rail__body  { overflow-y: auto; overflow-x: hidden; flex: 1; }

/* ------------------------------------------------------------------ */
/* Tracks (sections)                                                   */
/* ------------------------------------------------------------------ */
/* Numbered because the sequence is the workflow: text, then script,
   then setting, then ink, then out. A practitioner moves down it. */
.sec { border-bottom: 1px solid var(--hairline); }
.sec:last-child { border-bottom: 0; }

.sec__head {
  width: 100%; background: none; border: 0; cursor: pointer;
  padding: var(--s-3) var(--s-3) var(--s-2) var(--s-3);
  display: flex; align-items: center; gap: 10px;
  color: var(--ink); font-family: var(--ui);
  font-size: 10px; letter-spacing: .2em; text-transform: uppercase;
  position: relative;
}
.sec__head::before {
  content: attr(data-track);
  font-size: 9px; letter-spacing: .1em;
  color: var(--ink-3);
  min-width: 16px;
}
/* Connector: the label wires to its panel. Dim rule at rest, signal
   when the track is open — current reaching a lamp. */
.sec__head::after {
  content: ''; margin-inline-start: auto;
  width: 26px; height: 1px; background: var(--hairline);
  transform: scaleX(.55); transform-origin: right center;
  transition: background 200ms var(--ease), transform 200ms var(--ease);
}
.sec:not(.is-closed) .sec__head::after { background: var(--green-fill); transform: scaleX(1); }
@media (hover: hover) and (pointer: fine) {
  .sec__head:hover::after { background: var(--ink); }
}
.sec__body { padding: 0 var(--s-3) var(--s-4) 42px; }
.sec.is-closed .sec__body { display: none; }

.field { margin-bottom: var(--s-3); }
.field:last-child { margin-bottom: 0; }
.field__label {
  display: flex; align-items: baseline; gap: 8px;
  font-size: 9.5px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--ink-2); margin-bottom: var(--s-2);
}
.field__label .ar {
  font-family: 'Amiri', serif; font-size: 12px;
  letter-spacing: 0; text-transform: none; color: var(--ink-3);
}
.field__val { margin-inline-start: auto; color: var(--ink); letter-spacing: .08em; }

.hint { font-size: 10.5px; line-height: 1.6; color: var(--ink-2); margin-top: var(--s-2); }
.hint b { color: var(--ink); font-weight: 500; }

/* ------------------------------------------------------------------ */
/* Inputs                                                              */
/* ------------------------------------------------------------------ */
textarea, input[type=text], select {
  width: 100%; background: var(--paper);
  border: 1px solid var(--hairline); border-radius: 0;
  padding: 9px 10px; color: var(--ink);
  font-family: var(--ui); font-size: 12.5px; line-height: 1.55;
  transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease);
}
textarea:focus, input:focus, select:focus {
  outline: none; border-color: var(--ink);
  box-shadow: inset 0 -2px 0 var(--green-fill);
}
textarea { resize: vertical; min-height: 84px; }
textarea.rtl {
  direction: rtl; text-align: right;
  font-family: 'Amiri', serif; font-size: 17px; line-height: 2;
}
select {
  appearance: none; cursor: pointer; padding-inline-end: 26px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ink) 50%),
    linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: right 12px center, right 7px center;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}

/* Sliders are dragged continuously — the one place motion is banned
   outright. A transition here fights the user's own hand. */
input[type=range] {
  -webkit-appearance: none; appearance: none; width: 100%;
  height: 1px; background: var(--hairline); outline: none; margin: 8px 0;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 3px; height: 15px; border-radius: 0;
  background: var(--ink); cursor: ew-resize;
}
input[type=range]:focus-visible::-webkit-slider-thumb { background: var(--green-fill); }
input[type=range]::-moz-range-thumb {
  width: 3px; height: 15px; border: 0; border-radius: 0;
  background: var(--ink); cursor: ew-resize;
}
input[type=range]:disabled { opacity: .35; }

input[type=color] {
  width: 100%; height: 30px; padding: 0; cursor: pointer;
  background: none; border: 1px solid var(--hairline); border-radius: 0;
}
input[type=color]::-webkit-color-swatch-wrapper { padding: 3px; }
input[type=color]::-webkit-color-swatch { border: none; border-radius: 0; }

.row { display: flex; gap: var(--s-2); }
.row > * { flex: 1; min-width: 0; }

/* Segmented — node row on a shared rail */
.seg { display: flex; border: 1px solid var(--hairline); }
.seg button {
  flex: 1; background: var(--paper); border: 0; cursor: pointer;
  padding: 7px 4px; color: var(--ink-2); font-family: var(--ui);
  font-size: 9.5px; letter-spacing: .14em; text-transform: uppercase;
  white-space: nowrap;
  transition: color 160ms var(--ease), background 160ms var(--ease);
  border-inline-end: 1px solid var(--hairline);
}
.seg button:last-child { border-inline-end: 0; }
@media (hover: hover) and (pointer: fine) { .seg button:hover { color: var(--ink); } }
.seg button.is-on { background: var(--ink); color: var(--paper); }
.seg button:active { transform: scale(0.97); }

/* Chips */
.chips { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s-1); }
.chips--3 { grid-template-columns: repeat(3, 1fr); }
.chip {
  background: var(--paper); border: 1px solid var(--hairline);
  padding: 8px 5px; color: var(--ink-2); cursor: pointer;
  font-family: var(--ui); font-size: 9.5px; letter-spacing: .1em;
  text-transform: uppercase; text-align: center; line-height: 1.35;
  transition: border-color 160ms var(--ease), color 160ms var(--ease);
}
@media (hover: hover) and (pointer: fine) {
  .chip:hover { border-color: var(--ink); color: var(--ink); }
}
.chip.is-on { border-color: var(--green-fill); box-shadow: inset 0 0 0 1px var(--green-fill); color: var(--ink); }
.chip:active { transform: scale(0.97); }
.chip__ar {
  display: block; font-family: 'Amiri', serif; font-size: 14px;
  letter-spacing: 0; text-transform: none; margin-bottom: 2px; color: var(--ink);
}

/* Toggle — a switch on a circuit */
.toggle { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; padding: 4px 0; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle__track {
  width: 30px; height: 14px; flex: none; position: relative;
  background: var(--paper); border: 1px solid var(--hairline);
  transition: border-color 160ms var(--ease);
}
.toggle__track::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 10px; height: 8px; background: var(--ink-3);
  transition: transform 160ms var(--ease), background 160ms var(--ease);
}
.toggle input:checked + .toggle__track { border-color: var(--green-fill); }
.toggle input:checked + .toggle__track::after { transform: translateX(14px); background: var(--green-fill); }
.toggle input:focus-visible + .toggle__track { outline: 2px solid var(--ink); outline-offset: 2px; }
.toggle__label { font-size: 11px; color: var(--ink-2); }
.toggle input:checked ~ .toggle__label { color: var(--ink); }

/* ------------------------------------------------------------------ */
/* Script picker                                                       */
/* ------------------------------------------------------------------ */
.khatt-group { margin-bottom: var(--s-4); }
.khatt-group__title {
  font-size: 9px; letter-spacing: .2em; text-transform: uppercase;
  color: var(--ink-3); margin-bottom: 7px; padding-bottom: 5px;
  border-bottom: 1px solid var(--hairline);
  display: flex; justify-content: space-between; align-items: baseline;
}
.khatt-group__title .ar { font-family: 'Amiri', serif; font-size: 12px; letter-spacing: 0; text-transform: none; }

.khatt {
  width: 100%; text-align: right; direction: rtl;
  background: var(--paper); border: 1px solid var(--hairline);
  padding: 8px 11px; margin-bottom: 5px; cursor: pointer; position: relative;
  transition: border-color 160ms var(--ease);
}
@media (hover: hover) and (pointer: fine) { .khatt:hover { border-color: var(--ink); } }

/* Selected hand. Unmistakable at a glance across 47 rows: the row inverts
   its ground, takes a full ink border, and lights a signal node. A thick
   coloured side-bar would read as the generic accent-tab tell. */
.khatt.is-on {
  border-color: var(--ink);
  background: var(--panel-2);
  box-shadow: inset 0 0 0 1px var(--ink);
}
.khatt.is-on::before {
  content: ''; position: absolute; top: 10px; inset-inline-start: 10px;
  width: 6px; height: 6px; background: var(--green-fill);
}
.khatt.is-on .khatt__en { color: var(--ink); }
.khatt__ar { font-size: 21px; line-height: 1.5; color: var(--ink); display: block; min-height: 30px; }
.khatt__en {
  direction: ltr; text-align: left; font-family: var(--ui);
  font-size: 9px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3);
  display: flex; align-items: center; gap: 5px;
}
.khatt__tag {
  font-size: 8px; letter-spacing: .12em; text-transform: uppercase;
  padding: 1px 4px; margin-inline-start: auto; border: 1px solid currentColor;
}
/* Provenance reads as signal state: verified, ordinary, caution. */
.tag-revival      { color: var(--green); }
.tag-contemporary { color: var(--ink-3); }
.tag-surrogate    { color: var(--amber); }
.tag-custom       { color: var(--ink); }

.khatt-note {
  font-size: 10.5px; line-height: 1.6; color: var(--ink-2);
  background: var(--panel-2); border-inline-start: 1px solid var(--ink);
  padding: 9px 11px; margin-top: 4px;
}
.khatt-note__meta {
  display: block; margin-top: 6px; color: var(--ink-3);
  font-size: 9px; letter-spacing: .12em; text-transform: uppercase;
}

/* ------------------------------------------------------------------ */
/* Transliteration                                                     */
/* ------------------------------------------------------------------ */
.words { display: flex; flex-wrap: wrap; gap: 4px; direction: rtl; }
.word {
  background: var(--paper); border: 1px solid var(--hairline);
  padding: 3px 9px; cursor: pointer;
  font-family: 'Amiri', serif; font-size: 17px; line-height: 1.7;
  color: var(--ink); position: relative;
  transition: border-color 160ms var(--ease);
}
@media (hover: hover) and (pointer: fine) { .word:hover { border-color: var(--ink); } }
.word--guess         { border-color: var(--amber); }
.word--untranslated  { border-color: var(--red); }
.word--user          { box-shadow: inset 0 -2px 0 var(--green-fill); }

.wordedit { background: var(--panel-2); border: 1px solid var(--ink); padding: 11px; margin-top: 9px; }
.wordedit__latin {
  font-size: 9px; letter-spacing: .18em; text-transform: uppercase;
  color: var(--ink-3); margin-bottom: 8px;
}
.wordedit__input { direction: rtl; text-align: right; font-family: 'Amiri', serif; font-size: 21px; line-height: 1.8; margin-bottom: 9px; }
.letters { display: flex; flex-wrap: wrap; gap: 4px; direction: rtl; margin-bottom: 9px; }
.letter-col { display: flex; flex-direction: column; gap: 3px; }
.letter-opt {
  width: 28px; height: 28px; display: grid; place-items: center;
  background: var(--paper); border: 1px solid var(--hairline);
  font-family: 'Amiri', serif; font-size: 16px; color: var(--ink-2); cursor: pointer;
  transition: border-color 140ms var(--ease), color 140ms var(--ease);
}
@media (hover: hover) and (pointer: fine) { .letter-opt:hover { border-color: var(--ink); color: var(--ink); } }
.letter-opt.is-on { border-color: var(--ink); background: var(--ink); color: var(--paper); }

/* ------------------------------------------------------------------ */
/* Buttons                                                             */
/* ------------------------------------------------------------------ */
.btn {
  width: 100%; border: 1px solid var(--ink); background: var(--paper);
  color: var(--ink); padding: 8px 11px; cursor: pointer;
  font-family: var(--ui); font-size: 9.5px; letter-spacing: .16em;
  text-transform: uppercase;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  transition: background 160ms var(--ease), color 160ms var(--ease), transform 120ms var(--ease);
}
@media (hover: hover) and (pointer: fine) { .btn:hover { background: var(--ink); color: var(--paper); } }
.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: 2px solid var(--green-fill); outline-offset: 2px; }

/* Black on green measures 5.96:1; white on green is only 3.32:1. */
.btn--primary {
  background: var(--green-fill); border-color: var(--green-fill);
  color: #0A0A0A; font-weight: 500; padding: 11px; letter-spacing: .2em;
}
@media (hover: hover) and (pointer: fine) {
  .btn--primary:hover { background: var(--green); border-color: var(--green); color: var(--paper); }
}
.btn--ghost { border-color: var(--hairline); color: var(--ink-2); }
.btn:disabled { opacity: .35; cursor: not-allowed; }

.btn-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s-1); }
.btn-grid--3 { grid-template-columns: repeat(3, 1fr); }
.btn-grid--4 { grid-template-columns: repeat(4, 1fr); }
.btn-grid--4 .btn, .btn-grid--3 .btn { padding: 8px 3px; letter-spacing: .1em; }

.rail__foot { padding: var(--s-3); border-top: 1px solid var(--rule); background: var(--panel); }

/* ------------------------------------------------------------------ */
/* Stage                                                               */
/* ------------------------------------------------------------------ */
.stage {
  grid-area: stage; position: relative; overflow: hidden;
  display: grid; place-items: center;
  background: var(--bench);
}
/* The graticule. Everything on this surface is measured against it. */
.stage__grid {
  position: absolute; inset: 0; pointer-events: none;
  background-image:
    repeating-linear-gradient(0deg,  transparent 0 47px, var(--grid) 47px 48px),
    repeating-linear-gradient(90deg, transparent 0 47px, var(--grid) 47px 48px);
}

.artboard-wrap { position: relative; }
.artboard {
  position: absolute; top: 50%; left: 50%;
  overflow: hidden; transform-origin: center center;
  /* The only shadow in the system: a real sheet on a real surface. */
  box-shadow: 0 18px 40px -18px rgba(10,10,10,.45), 0 0 0 1px var(--rule);
}
.artboard__bg   { position: absolute; inset: 0; }
.artboard__art  { position: absolute; inset: 0; }
.artboard__text { position: absolute; inset: 0; }
.artboard__frame{ position: absolute; inset: 0; pointer-events: none; }
/* pre-wrap, not pre: explicit line breaks still count, but a long passage
   now wraps inside the sheet instead of running off it as one line. */
.art-line { white-space: pre-wrap; overflow-wrap: break-word; }

.artboard.is-drawing { cursor: crosshair; }
.artboard.is-drawing .artboard__text { opacity: .25; }
.kufic-hit { fill: transparent; }

/* Registration marks — the sheet is a plate on a bench */
.artboard-wrap::before, .artboard-wrap::after {
  content: ''; position: absolute; width: 14px; height: 14px;
  border: 1px solid var(--ink-3); pointer-events: none;
}
.artboard-wrap::before { top: -13px; left: -13px; border-right: 0; border-bottom: 0; }
.artboard-wrap::after  { bottom: -13px; right: -13px; border-left: 0; border-top: 0; }

.stage__bar {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 2px; z-index: 6;
  background: var(--paper); border: 1px solid var(--rule); padding: 3px;
}
.stage__bar button {
  min-width: 30px; height: 26px; padding: 0 9px; white-space: nowrap;
  background: none; border: 0; color: var(--ink-2); cursor: pointer;
  font-family: var(--ui); font-size: 9.5px; letter-spacing: .14em; text-transform: uppercase;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  transition: background 140ms var(--ease), color 140ms var(--ease);
}
@media (hover: hover) and (pointer: fine) {
  .stage__bar button:hover { background: var(--ink); color: var(--paper); }
}
.stage__bar button:active { transform: scale(0.97); }
.stage__bar button.is-on { background: var(--green-fill); color: #0A0A0A; }
.stage__bar button svg { width: 13px; height: 13px; display: block; }
.stage__bar .divider { width: 1px; height: 15px; background: var(--hairline); margin: 0 3px; }

/* The text no longer fits the sheet, so the export would clip. Silent
   clipping is the worst outcome; this names it and the fix. */
.stage__info[data-overflow="1"] {
  border-color: var(--red); color: var(--red);
}
.stage__info {
  position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%);
  font-size: 9px; letter-spacing: .2em; text-transform: uppercase;
  color: var(--ink-3); background: var(--paper);
  padding: 5px 12px; border: 1px solid var(--hairline); white-space: nowrap;
}

/* ------------------------------------------------------------------ */
/* Toast                                                               */
/* ------------------------------------------------------------------ */
.toast {
  position: fixed; bottom: var(--s-4); left: 50%;
  transform: translate(-50%, 12px);
  background: var(--ink); color: var(--paper);
  border: 0; padding: 11px 16px; font-size: 11.5px; line-height: 1.5;
  z-index: 100; opacity: 0; max-width: 460px; overflow: hidden;
  transition: transform 140ms var(--ease), opacity 140ms var(--ease);
}
/* State reads as a rule across the top, echoing the masthead hazard rule.
   A thick coloured side border is the category's most recognisable tell. */
.toast::before {
  content: ''; position: absolute; inset: 0 0 auto 0;
  height: 2px; background: var(--green-fill);
}
.toast.is-on {
  transform: translate(-50%, 0); opacity: 1;
  transition: transform 240ms var(--ease), opacity 240ms var(--ease);
}
.toast--err::before { background: var(--red); }

/* Spacing utilities — markup uses the scale instead of inventing values. */
.mt-1 { margin-top: var(--s-1); }
.mt-2 { margin-top: var(--s-2); }
.mt-3 { margin-top: var(--s-3); }
.mb-2 { margin-bottom: var(--s-2); }
.mb-3 { margin-bottom: var(--s-3); }

/* Scrollbars */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: var(--panel); }
::-webkit-scrollbar-thumb { background: var(--hairline); border: 3px solid var(--panel); }
::-webkit-scrollbar-thumb:hover { background: var(--ink-3); }

/* ------------------------------------------------------------------ */
/* The one authored moment                                             */
/* ------------------------------------------------------------------ */
/* Current reaching a lamp. Tracks arrive in sequence on load and never
   again; nothing else on this surface animates its entrance. */
@media (prefers-reduced-motion: no-preference) {
  .rail .sec {
    opacity: 0;
    animation: track-live 320ms var(--ease) forwards;
  }
  .rail .sec:nth-child(1) { animation-delay: 40ms; }
  .rail .sec:nth-child(2) { animation-delay: 90ms; }
  .rail .sec:nth-child(3) { animation-delay: 140ms; }
  .rail .sec:nth-child(4) { animation-delay: 190ms; }
  .rail .sec:nth-child(5) { animation-delay: 240ms; }
  .rail .sec:nth-child(6) { animation-delay: 290ms; }
  .rail .sec:nth-child(n+7) { animation-delay: 330ms; }

  .masthead::after {
    transform-origin: left center;
    animation: rule-energise 420ms var(--ease) both;
  }
}
@keyframes track-live {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes rule-energise {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}

/* Print — the PDF export path */
@media print {
  body { overflow: visible; background: #fff; }
  .rail, .masthead, .stage__bar, .stage__grid, .stage__info, .toast { display: none !important; }
  .app { display: block; height: auto; }
  .stage { display: block; background: none; }
  .artboard { transform: none !important; box-shadow: none; }
  .artboard-wrap::before, .artboard-wrap::after { display: none; }
}

@media (max-width: 1440px) { :root { --rail: 288px; } }
@media (max-width: 1180px) {
  :root { --rail: 260px; }
  .masthead__meta { display: none; }
}

/* Below this the three tracks cannot sit side by side — two 260px rails
   alone exceed the viewport, which crushed the stage to nothing and put
   the sheet off-screen entirely. Stack them: sheet first, controls under. */
@media (max-width: 900px) {
  body { overflow: auto; }
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: var(--track) 56vh auto auto;
    grid-template-areas:
      "masthead"
      "stage"
      "left"
      "right";
    height: auto; min-height: 100vh;
  }
  .masthead { position: sticky; top: 0; z-index: 20; }
  .brand__sub { display: none; }

  .stage { min-height: 56vh; border-bottom: 1px solid var(--rule); }
  .stage__bar { top: 10px; max-width: calc(100vw - 20px); overflow-x: auto; }
  .stage__info { bottom: 10px; }

  .rail { overflow: visible; }
  .rail--left, .rail--right { border-inline: 0; border-top: 1px solid var(--rule); }
  .rail__body { overflow: visible; }
  .sec__body { padding-left: 34px; }
  .rail__foot { position: sticky; bottom: 0; }

  /* Comfortable touch targets. Desktop keeps its density — a mouse is
     precise and this surface is control-dense by design. */
  .seg button { padding-block: 13px; }
  .btn { padding-block: 13px; }
  .chip { padding-block: 12px; }
  .sec__head { padding-block: 15px; }
  .word { padding-block: 7px; }
  .letter-opt { width: 40px; height: 40px; }
  .stage__bar button { height: 38px; }
  input[type=color] { height: 44px; }
  input[type=range] { padding-block: 14px; margin: 0; background-clip: content-box; }

  /* Registration marks crowd the sheet at this size. */
  .artboard-wrap::before, .artboard-wrap::after { display: none; }
}

@media (max-width: 520px) {
  .sec__body { padding-left: 18px; padding-right: 14px; }
  .sec__head { padding-inline: 14px; }
  .btn-grid--4, .btn-grid--3 { grid-template-columns: repeat(2, 1fr); }
}
