/* Stamp It! page styles. Clicker Wonderland's layout, type, spacing, radii,
   buttons, shadows and motion (clicker-wonderland/style.css and
   src/styles/studio.css), recoloured Chop Red through src/tokens.css, which
   index.html links first. One screen: the controls on the left, the 3D stage
   on the right; under 768 px the controls become a bottom sheet. */

@font-face {
    font-family: 'Bitter';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('./vendor/fonts/Bitter-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'Overpass';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('./vendor/fonts/Overpass-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

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

[hidden] {
    display: none !important;
}

/* ---- Focus, skip link, screen-reader text (as Clicker) ---- */
:focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 2px;
    border-radius: var(--radius-inset);
}
.sidebar :focus-visible {
    box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.95), 0 0 0 9px rgba(168, 48, 42, 0.22);
}
input[type="range"]:focus-visible {
    outline: none;
    box-shadow: none;
}
input[type="range"]:focus-visible::-webkit-slider-thumb {
    box-shadow: 0 0 0 3px var(--c-white), 0 0 0 6px var(--focus-ring);
}
input[type="range"]:focus-visible::-moz-range-thumb {
    box-shadow: 0 0 0 3px var(--c-white), 0 0 0 6px var(--focus-ring);
}

.skip-link {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 3010;
    transform: translateY(-140%);
    padding: 0.7rem 1.2rem;
    background: var(--c-white);
    color: var(--accent-text);
    border: 3px solid var(--focus-ring);
    border-radius: 0 0 var(--radius-card) 0;
    font: 700 var(--fs-base) var(--font-display);
    text-decoration: none;
    transition: transform var(--dur-150) ease;
}
.skip-link:focus {
    transform: translateY(0);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

:where(button, input, select, textarea) {
    font-family: var(--font-ui);
}

/* ---- Page ---- */
html,
body {
    height: 100%;
}

body {
    font-family: var(--font-ui);
    font-size: var(--fs-base);
    line-height: var(--lh-base);
    background-color: var(--bg-1);
    background-image:
        radial-gradient(at 0% 0%, rgba(170, 90, 110, 0.10) 0px, transparent 55%),
        radial-gradient(at 100% 0%, rgba(170, 90, 110, 0.08) 0px, transparent 55%),
        radial-gradient(at 50% 100%, rgba(170, 90, 110, 0.06) 0px, transparent 55%);
    color: var(--text-primary);
    overflow: hidden;
}

#app {
    display: flex;
    width: 100%;
    height: 100vh;
    height: 100dvh;
}

/* ---- Sidebar ---- */
.sidebar {
    width: var(--sidebar-width);
    flex: 0 0 var(--sidebar-width);
    display: flex;
    flex-direction: column;
    background: var(--sidebar-bg);
    backdrop-filter: blur(18px) saturate(1.4);
    -webkit-backdrop-filter: blur(18px) saturate(1.4);
    border-right: 1px solid var(--border-card);
    box-shadow: 6px 0 30px var(--shadow-soft);
    z-index: 10;
    min-height: 0;
}

.sidebar-content {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1.25rem 1.75rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.sidebar-content::-webkit-scrollbar { width: 10px; }
.sidebar-content::-webkit-scrollbar-track { background: transparent; }
.sidebar-content::-webkit-scrollbar-thumb {
    background: rgba(232, 80, 63, 0.35);
    border-radius: var(--radius-control);
    border: 2px solid transparent;
    background-clip: content-box;
}

/* The phone sheet's grab handle; desktop has no use for it. */
.sheet-grab {
    display: none;
}

.intro {
    font-size: var(--fs-base);
    font-weight: var(--fw-strong);
    color: var(--text-secondary);
    line-height: var(--lh-tight);
}

.group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.group-title {
    font-family: var(--font-heading);
    font-size: var(--fs-lg);
    font-weight: var(--fw-strong);
    letter-spacing: var(--tracking-title);
    color: var(--text-primary);
    padding: 0 var(--space-hug);
}

.card {
    background: var(--c-white);
    border-radius: var(--radius-dialog);
    border: 1.5px solid var(--border-card);
    box-shadow: 0 4px 16px var(--shadow-soft);
    padding: 1rem 1.125rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.field-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
}

/* A label beside its control (Clicker's inline-field rule): label, slider,
   value on one row, an optional hint under the slider. */
.field-inline {
    display: grid;
    grid-template-columns: 2.6rem minmax(0, 1fr) 3.4rem;
    align-items: center;
    column-gap: 0.75rem;
    row-gap: 0;
}
.field-inline .field-value {
    text-align: right;
}
.field-inline .field-hint {
    grid-column: 2 / 4;
    margin-top: -0.35rem;
}

.field-label {
    font-size: var(--fs-sm);
    font-weight: var(--fw-strong);
    color: var(--text-primary);
}

.field-value {
    font-size: var(--fs-sm);
    font-weight: var(--fw-strong);
    color: var(--accent-text);
    font-variant-numeric: tabular-nums;
}

.hint {
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    line-height: var(--lh-tight);
}

/* A link under a hint (ALI-230), tall enough to tap, as the footer's links are. */
.hint-link {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    font-size: var(--fs-sm);
    font-weight: var(--fw-strong);
    color: var(--accent-text);
}

/* The 0.2 mm nozzle caution (ALI-211): a hint in the warning colour, as .facts-note is. */
.hint-caution {
    color: var(--warn-text);
    font-weight: var(--fw-strong);
}

/* Advanced (ALI-211): a quiet disclosure at the foot of the Shape and size card.
   Closed, it is one line with a chevron; open, it holds the face pad nozzle. */
.advanced {
    border-top: 1px solid var(--border-soft);
}
.advanced summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    min-height: 44px;
    margin-top: 0.125rem;
    padding: 0 0.125rem;
    font-size: var(--fs-sm);
    font-weight: var(--fw-strong);
    color: var(--text-secondary);
    list-style: none;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    transition: color var(--dur-150) ease;
}
.advanced summary::-webkit-details-marker {
    display: none;
}
.advanced summary:hover {
    color: var(--accent-text);
}
.advanced-chevron {
    display: inline-flex;
    transform: rotate(180deg);
    transition: transform var(--dur-180) ease;
}
.advanced[open] .advanced-chevron {
    transform: none;
}
.advanced-chevron svg {
    width: 18px;
    height: 18px;
}
/* With 0.2 mm on, the section stays open, so it says nothing about closing. */
.advanced.is-held summary {
    cursor: default;
}
.advanced.is-held summary:hover {
    color: var(--text-secondary);
}
.advanced.is-held .advanced-chevron {
    visibility: hidden;
}
.advanced .field {
    padding-bottom: 0.25rem;
}

/* ---- Drop zone (Clicker's .revamp-dropzone) ---- */
.dropzone {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    text-align: center;
    padding: 0.8rem 1rem;
    min-height: 84px;
    border: 2px dashed var(--accent-color);
    border-radius: var(--radius-card);
    background: #fff6f4;
    color: var(--text-primary);
    cursor: pointer;
    transition: transform var(--dur-150) ease, box-shadow var(--dur-150) ease, background var(--dur-150) ease;
}
.dropzone:hover,
.dropzone.is-dragover {
    background: #ffeeea;
    transform: scale(1.02);
    box-shadow: 0 6px 20px var(--icon-shadow);
}
.dropzone.is-dragover {
    border-style: solid;
}
.dropzone-icon svg {
    display: block;
    width: 34px;
    height: 34px;
}
.dropzone-title {
    font-size: var(--fs-base);
    font-weight: var(--fw-strong);
}
.dropzone-sub {
    font-size: var(--fs-sm);
    color: var(--text-secondary);
}
.dropzone-file {
    font-size: var(--fs-sm);
    font-weight: var(--fw-strong);
    color: var(--accent-text);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---- Starter thumbnails ---- */
.starter-row {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 6px;
}
.starter-btn {
    aspect-ratio: 1;
    min-width: 44px;
    min-height: 44px;
    padding: 3px;
    background: var(--c-white);
    border: 2px solid var(--border-card);
    border-radius: var(--radius-control);
    cursor: pointer;
    transition: transform var(--dur-180) ease, box-shadow var(--dur-180) ease, border-color var(--dur-180) ease;
}
.starter-btn img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 6px;
}
.starter-btn:hover {
    border-color: var(--icon-accent);
    transform: translateY(-2px);
    box-shadow: 0 6px 14px var(--icon-shadow);
}
.starter-btn[aria-pressed="true"] {
    border-color: var(--accent-text);
    box-shadow: 0 0 0 2px var(--accent-text), 0 4px 12px var(--shadow-pink);
}

/* ---- Chips (Clicker's .preset-btn, selected as its cut-style chips) ---- */
.chip-row {
    display: flex;
    gap: 0.5rem;
}
.chip {
    flex: 1 1 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: 44px;
    padding: 0.5rem 0.6rem;
    font-size: var(--fs-sm);
    font-weight: var(--fw-strong);
    line-height: 1.1;
    color: var(--text-primary);
    background: var(--c-white);
    border: 2px solid var(--border-card);
    border-radius: var(--radius-card);
    cursor: pointer;
    transition: transform var(--dur-180) ease, box-shadow var(--dur-180) ease, border-color var(--dur-180) ease;
}
.chip svg {
    flex: none;
    width: 20px;
    height: 20px;
}
.chip:hover:not(:disabled) {
    border-color: var(--icon-accent);
    transform: translateY(-2px);
    box-shadow: 0 6px 14px var(--icon-shadow);
}
.chip[aria-pressed="true"] {
    background: var(--grad-primary);
    color: var(--c-white);
    border-color: transparent;
    box-shadow: 0 4px 12px var(--shadow-pink);
}
.chip:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}
.chip[aria-pressed="true"]:disabled {
    opacity: 0.7;
}

/* ---- Pill buttons: Clicker's secondary pill, and the primary one for the main action ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: 44px;
    padding: 0.5rem 1rem;
    font-size: var(--fs-sm);
    font-weight: var(--fw-strong);
    line-height: 1.1;
    color: var(--text-primary);
    background: var(--c-white);
    border: 1.5px solid var(--border-card);
    border-radius: var(--radius-chip);
    cursor: pointer;
    transition: transform var(--dur-150) ease, box-shadow var(--dur-150) ease, border-color var(--dur-150) ease;
}
.btn svg {
    flex: none;
    width: 18px;
    height: 18px;
}
.btn:hover:not(:disabled) {
    border-color: var(--icon-accent);
    box-shadow: 0 6px 14px var(--icon-shadow);
}
.btn:active:not(:disabled) {
    transform: scale(0.97);
}
.btn:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}
.btn.primary {
    color: var(--c-white);
    background: var(--grad-primary);
    border-color: transparent;
    box-shadow: 0 4px 12px var(--shadow-pink);
}
.btn.primary:hover:not(:disabled) {
    background: var(--grad-primary-hover);
    border-color: transparent;
}
.card > .btn {
    width: 100%;
}

/* ---- Sliders (Clicker's 13 px track and 24 px thumb, inside a 44 px row) ---- */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 44px;
    background: transparent;
    cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
    height: 13px;
    border-radius: var(--radius-inset);
    background: linear-gradient(to right, var(--icon-accent), var(--accent-2));
}
input[type="range"]::-moz-range-track {
    height: 13px;
    border-radius: var(--radius-inset);
    background: linear-gradient(to right, var(--icon-accent), var(--accent-2));
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    margin-top: -5.5px;
    border-radius: var(--radius-chip);
    background: var(--c-white);
    border: 4px solid var(--accent-color);
}
input[type="range"]::-moz-range-thumb {
    width: 24px;
    height: 24px;
    box-sizing: border-box;
    border-radius: var(--radius-chip);
    background: var(--c-white);
    border: 4px solid var(--accent-color);
}
input[type="range"]:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

/* ---- Toggle (Clicker's .revamp-toggle-row) ---- */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    min-height: 44px;
    cursor: pointer;
    position: relative;
}
.toggle-text {
    display: flex;
    flex-direction: column;
}
.toggle-row input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
    opacity: 0;
}
.toggle-switch {
    flex: none;
    width: 36px;
    height: 20px;
    background: var(--border-control);
    border-radius: var(--radius-dialog);
    position: relative;
    transition: background var(--dur-200);
}
.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: var(--c-white);
    border-radius: var(--radius-chip);
    transition: transform var(--dur-200);
}
.toggle-row input:checked + .toggle-switch {
    background: var(--accent-text);
}
.toggle-row input:checked + .toggle-switch::after {
    transform: translateX(16px);
}
.toggle-row input:focus-visible + .toggle-switch {
    outline: 3px solid var(--focus-ring);
    outline-offset: 2px;
}

/* ---- Facts line ---- */
.facts {
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    line-height: var(--lh-tight);
    padding-top: 0.6rem;
    border-top: 1px dashed var(--border-color);
}
.facts-hint,
.facts-main {
    display: block;
}
.facts strong {
    color: var(--text-primary);
    font-weight: var(--fw-strong);
    font-variant-numeric: tabular-nums;
}
.facts-note {
    display: block;
    margin-top: 0.25rem;
    color: var(--warn-text);
    font-weight: var(--fw-strong);
    /* One line per note when there are two. */
    white-space: pre-line;
}

/* ---- Panel footer (Clicker's .revamp-panel-footer) ---- */
.panel-footer {
    flex: none;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    padding: 0 1.25rem;
    border-top: 1px solid var(--border-soft);
    font-size: var(--fs-sm);
    line-height: var(--lh-tight);
    color: var(--text-secondary);
}
.panel-footer a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    color: inherit;
    text-decoration: none;
}
.panel-footer a:hover,
.panel-footer a:focus-visible {
    color: var(--accent-text);
    text-decoration: underline;
}

/* ---- Stage ---- */
.stage {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    background: var(--stage-bg);
    overflow: hidden;
}
.viewer {
    position: absolute;
    inset: 0;
}
.viewer canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
}

/* The brand lockup, top left of the stage (Clicker's #revamp-brand). First
   in the page so the h1 leads the outline; fixed, so it sits over the stage. */
.brand {
    position: fixed;
    top: 14px;
    left: calc(var(--sidebar-width) + 18px);
    z-index: 50;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    pointer-events: none;
}
.brand h1 {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin: 0;
    font-family: 'Inter', 'Segoe UI Variable Display', 'Segoe UI', system-ui,
        -apple-system, 'Helvetica Neue', Arial, sans-serif;
    font-size: var(--fs-mark);
    font-weight: var(--fw-display);
    line-height: var(--lh-tight);
    letter-spacing: var(--tracking-tight);
}
.brand-mark {
    flex: none;
    width: 28px;
    height: 28px;
}
.brand-word {
    background: var(--grad-wordmark);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: var(--accent-text);
}
.brand-line {
    font-size: var(--fs-sm);
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
    color: var(--accent-text);
    margin: 0;
}
.brand-line strong {
    font-weight: var(--fw-display);
}

/* "What it prints": the paper side of the stamp, top right of the stage. It is
   a button: it opens the large view (.print-dialog below). */
.print-card {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 20;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    padding: 0.5rem 0.5rem 0.4rem;
    font: inherit;
    color: inherit;
    cursor: zoom-in;
    background: var(--c-white);
    border: 1.5px solid var(--border-card);
    border-radius: var(--radius-card);
    box-shadow: 0 4px 16px var(--shadow-soft);
    transition: border-color var(--dur-150) ease, box-shadow var(--dur-150) ease;
}
.print-card:hover {
    border-color: var(--border-card-open);
    box-shadow: 0 6px 20px var(--shadow-soft);
}
.print-card canvas {
    display: block;
    width: 120px;
    height: 120px;
    border-radius: var(--radius-inset);
    background: #ffffff;
}
.print-card-cap {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: var(--fs-sm);
    font-weight: var(--fw-strong);
    color: var(--text-secondary);
    line-height: var(--lh-tight);
}
.print-card-cap svg {
    flex: none;
    width: 14px;
    height: 14px;
}

/* The large view of "What it prints": a native dialog, as big as fits. */
.print-dialog {
    --print-big: min(calc(100vw - 3.5rem), calc(100vh - 10rem), 720px);
    --print-big: min(calc(100vw - 3.5rem), calc(100dvh - 10rem), 720px);
    padding: 0;
    margin: auto;
    max-width: calc(100vw - 1.5rem);
    max-height: calc(100vh - 1.5rem);
    max-height: calc(100dvh - 1.5rem);
    overflow: auto;
    color: var(--text-primary);
    background: var(--c-white);
    border: 1.5px solid var(--border-card);
    border-radius: var(--radius-dialog);
    box-shadow: 0 12px 40px var(--shadow-soft);
}
.print-dialog::backdrop {
    background: var(--scrim-color);
}
.print-dialog[open] {
    animation: print-dialog-in var(--dur-200) var(--ease-settle);
}
@keyframes print-dialog-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}
.print-dialog-body {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding: 0.75rem 1rem 1rem;
}
.print-dialog-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}
.print-dialog-head h2 {
    font-family: var(--font-heading);
    font-size: var(--fs-lg);
    font-weight: var(--fw-strong);
    letter-spacing: var(--tracking-title);
}
.print-dialog-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    color: var(--text-primary);
    cursor: pointer;
    background: var(--c-white);
    border: 1.5px solid var(--border-card);
    border-radius: var(--radius-chip);
    transition: background var(--dur-150) ease;
}
.print-dialog-close:hover {
    background: #f6ecea;
}
.print-dialog canvas {
    display: block;
    width: var(--print-big);
    height: var(--print-big);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-inset);
    background: #ffffff;
}

/* The 0.2 mm nozzle question: the same dialog, as wide as its sentence needs. */
.nozzle-dialog {
    width: 26rem;
}
.dialog-text {
    font-size: var(--fs-base);
    line-height: var(--lh-tight);
    color: var(--text-primary);
}

/* Move and zoom: the same dialog, with a draggable photo and a slider under it. */
.frame-dialog {
    --print-big: min(calc(100vw - 3.5rem), calc(100vh - 19.5rem), 560px);
    --print-big: min(calc(100vw - 3.5rem), calc(100dvh - 19.5rem), 560px);
}
.frame-dialog canvas {
    cursor: grab;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}
.frame-dialog canvas.is-dragging {
    cursor: grabbing;
}
.dialog-actions {
    display: flex;
    gap: 0.5rem;
}
.dialog-actions .btn {
    flex: 1 1 0;
}

/* Quiet progress and errors, just above the dock. Never a modal. */
.stage-status {
    position: absolute;
    left: 50%;
    bottom: calc(1.5rem + 64px);
    transform: translateX(-50%);
    z-index: 30;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    max-width: min(560px, calc(100% - 2rem));
    padding: 0.4rem 0.9rem;
    background: var(--c-white);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-chip);
    box-shadow: 0 4px 16px var(--shadow-soft);
    font-size: var(--fs-sm);
    font-weight: var(--fw-strong);
    color: var(--text-secondary);
    line-height: var(--lh-tight);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--dur-200) ease;
}
.stage-status.is-shown {
    opacity: 1;
}
.stage-status.is-error {
    color: var(--fail-text);
    border-color: rgba(163, 36, 60, 0.35);
    border-radius: var(--radius-card);
    pointer-events: auto;
}
.spinner {
    flex: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2.5px solid var(--border-color);
    border-top-color: var(--accent-color);
    animation: spin 0.9s linear infinite;
}
.stage-status:not(.is-busy) .spinner {
    display: none;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
.status-retry {
    flex: none;
    min-height: 32px;
    padding: 0.25rem 0.8rem;
    border: 1.5px solid var(--border-card);
    border-radius: var(--radius-chip);
    background: var(--c-white);
    color: var(--text-primary);
    font-size: var(--fs-sm);
    font-weight: var(--fw-strong);
    cursor: pointer;
}

/* The bottom pill dock (Clicker's .revamp-dock). */
.dock {
    position: absolute;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.6rem;
    background: var(--sidebar-bg);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-chip);
    box-shadow: 0 6px 24px var(--shadow-soft);
    white-space: nowrap;
}
.dock button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-height: 44px;
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    border-radius: var(--radius-chip);
    font-size: var(--fs-sm);
    font-weight: var(--fw-strong);
    color: var(--text-primary);
    cursor: pointer;
    transition: background var(--dur-150) ease, transform var(--dur-150) ease, box-shadow var(--dur-150) ease;
}
.dock button svg {
    flex: none;
    width: 18px;
    height: 18px;
}
.dock button:not(.primary):hover:not(:disabled) {
    background: #f6ecea;
}
.dock .primary {
    padding: 0.55rem 1.25rem;
    font-size: var(--fs-base);
    background: var(--grad-primary);
    color: var(--c-white);
    box-shadow: 0 4px 12px var(--shadow-pink);
}
.dock .primary:hover:not(:disabled) {
    background: var(--grad-primary-hover);
    transform: translateY(-1px);
}
.dock button:active:not(:disabled) {
    transform: scale(0.97);
}
.dock button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

/* Download stamp and its menu of two files (owner, 2026-10-22, ALI-207). The menu
   opens above the button, centred on it, as a small card over the stage. */
.dock-split {
    position: relative;
    display: flex;
}
.dock-menu {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 0.9rem);
    z-index: 5;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    width: max-content;
    min-width: 15rem;
    max-width: calc(100vw - 1.5rem);
    padding: 0.4rem;
    background: var(--c-white);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-card);
    box-shadow: 0 6px 24px var(--shadow-soft);
    animation: dock-menu-in var(--dur-150) var(--ease-settle);
    transform: translateX(-50%);
}
@keyframes dock-menu-in {
    from { opacity: 0; transform: translate(-50%, 6px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}
.dock .dock-menu-item {
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 0.1rem;
    width: 100%;
    padding: 0.5rem 0.85rem;
    border-radius: var(--radius-control);
    font-size: var(--fs-sm);
    line-height: var(--lh-tight);
    text-align: left;
    white-space: normal;
}
.menu-title {
    font-weight: var(--fw-strong);
    color: var(--text-primary);
}
.menu-sub {
    font-weight: var(--fw-normal);
    color: var(--text-secondary);
}

/* ---- Phones: the controls become a bottom sheet under the stage ---- */
@media (max-width: 768px) {
    #app {
        flex-direction: column-reverse;
    }

    .stage {
        flex: 1 1 auto;
        min-height: 36vh;
    }

    .sidebar {
        width: 100%;
        flex: 0 1 auto;
        max-height: 50vh;
        max-height: 50dvh;
        border-right: none;
        border-radius: 20px 20px 0 0;
        background: var(--c-white);
        box-shadow: 0 -8px 30px rgba(170, 90, 110, 0.2);
        margin-top: -20px;
        /* Room for the dock, which is fixed over the foot of the sheet. */
        padding-bottom: calc(4.25rem + env(safe-area-inset-bottom, 0px));
    }

    .sheet-grab {
        display: flex;
        align-items: center;
        justify-content: center;
        flex: none;
        width: 100%;
        min-height: 44px;
        background: transparent;
        border: none;
        cursor: pointer;
    }
    .sheet-grab::before {
        content: '';
        display: block;
        width: 44px;
        height: 5px;
        border-radius: 5px;
        background: #cfa9a3;
    }

    /* The whole sheet scrolls, so the footer sits at the end of it. */
    .sidebar {
        overflow-y: auto;
        overscroll-behavior: contain;
    }
    .sheet-grab {
        position: sticky;
        top: 0;
        z-index: 2;
        background: var(--c-white);
        border-radius: 20px 20px 0 0;
    }
    .sidebar-content {
        flex: none;
        overflow: visible;
        padding: 0 0.75rem 0.75rem;
        gap: 1rem;
    }

    .sidebar.is-peeked .sidebar-content,
    .sidebar.is-peeked .panel-footer {
        display: none;
    }

    .card {
        padding: 0.85rem 0.75rem;
    }

    .starter-row {
        gap: 4px;
    }

    .panel-footer {
        padding: 0 0.75rem;
    }

    .brand {
        top: 10px;
        left: 12px;
    }

    .print-card {
        top: 10px;
        right: 10px;
        padding: 0.35rem 0.35rem 0.25rem;
    }
    .print-card canvas {
        width: 76px;
        height: 76px;
    }
    .print-card-cap {
        font-size: 0.75rem;
    }

    .dock {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        transform: none;
        justify-content: space-between;
        gap: 0.25rem;
        padding: 0.5rem 0.6rem calc(0.5rem + env(safe-area-inset-bottom, 0px));
        border-radius: 20px 20px 0 0;
        border-bottom: none;
        background: var(--c-white);
        box-shadow: 0 -6px 24px var(--shadow-soft);
    }
    .dock button {
        flex: 1 1 0;
        min-width: 0;
        padding: 0.5rem 0.25rem;
        font-size: 0.8125rem;
        white-space: normal;
        line-height: 1.15;
        text-align: center;
    }
    .dock button svg {
        display: none;
    }
    .dock-split {
        flex: 1.25 1 0;
        min-width: 0;
    }
    .dock .primary {
        flex: 1 1 0;
        padding: 0.5rem 0.5rem;
        font-size: var(--fs-sm);
    }

    .stage-status {
        bottom: calc(20px + 0.75rem);
    }
}

@media (max-width: 359px) {
    .starter-row {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

/* Every animation on the page is decorative. */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
    .dropzone:hover,
    .dropzone.is-dragover,
    .chip:hover:not(:disabled),
    .starter-btn:hover,
    .dock .primary:hover:not(:disabled),
    .dock button:active:not(:disabled),
    .btn:active:not(:disabled) {
        transform: none;
    }
}

/* ---- 404.html ---- */
body.not-found {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    overflow: auto;
}
.not-found-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    max-width: 420px;
    padding: 2rem 1.75rem;
    text-align: center;
    background: var(--c-white);
    border: 1.5px solid var(--border-card);
    border-radius: var(--radius-dialog);
    box-shadow: 0 4px 16px var(--shadow-soft);
}
.not-found-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-display);
    font-size: var(--fs-mark);
    font-weight: var(--fw-display);
    letter-spacing: var(--tracking-tight);
}
.not-found-card h1 {
    font-family: var(--font-heading);
    font-size: var(--fs-lg);
    font-weight: var(--fw-strong);
    letter-spacing: var(--tracking-title);
}
.not-found-card p {
    color: var(--text-secondary);
}
.not-found-link {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0.5rem 1.25rem;
    border-radius: var(--radius-chip);
    background: var(--grad-primary);
    color: var(--c-white);
    font-weight: var(--fw-strong);
    text-decoration: none;
    box-shadow: 0 4px 12px var(--shadow-pink);
}
.not-found-link:hover {
    background: var(--grad-primary-hover);
}
