/* The studio: the shell, the app bar, the three ways in (draw, upload, text), the
   output column with its previews, settings, files and code, and the status bar - one
   section per part of the page. Only the shell pages (the studio and /not-found) load it.

   Breakpoints, written at 1.2x because of the root scale (see app.css):
     1228.8px  the two halves go side by side and the shell owns the viewport
      599.98px phones: the root scale drops to 100% (app.css)
   Inside the studio and the output, container queries decide the rest, so each part
   lays itself out by the room it actually has rather than by the window. */

[hidden] {
    display: none !important;
}

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

/* ==== Shell ================================================================= */

:root {
    --fi-statusbar-h: 1.625rem;
    --fi-sans: 'Inter', 'Segoe UI Variable Text', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --fi-mono: 'JetBrains Mono', 'Cascadia Mono', 'Consolas', ui-monospace, monospace;
    --fi-gap: 0.875rem;
}

.fi-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--fi-bg);
    color: var(--fi-text);
    font-family: var(--fi-sans);
    font-size: 0.875rem;
}

.fi {
    flex: 1;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 1228.8px) and (min-height: 560px) {
    body:has(.fi-shell) {
        overflow: hidden;
    }

    .fi-shell {
        position: fixed;
        inset: 0;
        min-height: 0;
    }

    .fi {
        min-height: 0;
        grid-template-columns: minmax(0, 1fr) clamp(27rem, 36vw, 56rem);
    }

    .studio,
    .output {
        min-height: 0;
    }

    .output {
        border-left: 1px solid var(--fi-border);
    }

    /* A short window: the studio scrolls rather than clipping the tools. */
    .studio-panel {
        overflow: auto;
    }

    .output-scroll {
        flex: 1;
        min-height: 0;
        overflow: auto;
        overscroll-behavior: contain;
    }
}

/* ==== App bar =============================================================== */

.appbar {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    flex: none;
    height: 2.75rem;
    padding: 0 0.875rem;
    background: var(--fi-chrome);
    border-bottom: 1px solid var(--fi-border);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: none;
    color: inherit;
    text-decoration: none;
}

.brand-mark {
    width: 1.25rem;
    height: 1.25rem;
}

.brand-name {
    color: var(--fi-text);
    font-size: 0.9375rem;
    font-weight: 650;
    letter-spacing: -0.01em;
}

.brand-name-accent {
    color: var(--fi-accent);
}

.appbar-tagline {
    min-width: 0;
    overflow: hidden;
    padding-left: 0.875rem;
    border-left: 1px solid var(--fi-border);
    color: var(--fi-muted);
    font-size: 0.75rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.appbar-spacer {
    flex: 1;
}

@media (max-width: 899.98px) {
    .appbar-tagline {
        display: none;
    }
}

.theme-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    flex: none;
    padding: 0.25rem 0.625rem;
    border: 1px solid var(--fi-border);
    border-radius: 999px;
    background: transparent;
    color: var(--fi-muted);
    font: inherit;
    font-size: 0.75rem;
    cursor: pointer;
}

.theme-btn:hover:not(:disabled) {
    background: var(--fi-chrome-hover);
    color: var(--fi-text);
}

.theme-btn:disabled {
    cursor: default;
    opacity: 0.6;
}

/* ==== Shared controls ======================================================= */

:where(.fi-shell) button:focus-visible,
:where(.fi-shell) input:focus-visible,
:where(.fi-shell) select:focus-visible,
:where(.fi-shell) [tabindex]:focus-visible {
    outline: 2px solid var(--fi-accent);
    outline-offset: 1px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4375rem;
    flex: none;
    padding: 0.4375rem 0.875rem;
    border: 1px solid var(--fi-border);
    border-radius: 0.5rem;
    background: var(--fi-raised);
    color: var(--fi-text);
    font: inherit;
    font-size: 0.8125rem;
    font-weight: 550;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease, transform 0.08s ease;
}

.btn svg,
.icon-btn svg,
.bar-btn svg,
.rail-btn svg,
.source-tab svg,
.seg-icon svg {
    flex: none;
    width: 1rem;
    height: 1rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.svg-fill {
    fill: currentColor;
    stroke: none;
}

.btn:hover:not(:disabled) {
    background: var(--fi-chrome-hover);
}

.btn:active:not(:disabled) {
    transform: translateY(1px);
}

.btn:disabled {
    cursor: default;
    opacity: 0.5;
}

.btn-primary {
    border-color: transparent;
    background: var(--fi-accent);
    color: var(--fi-accent-ink);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.15) inset, 0 4px 14px var(--fi-accent-wash);
}

.btn-primary:hover:not(:disabled) {
    background: var(--fi-accent-bright);
}

.btn-quiet {
    border-color: transparent;
    background: transparent;
    color: var(--fi-muted);
}

.btn-quiet:hover:not(:disabled) {
    color: var(--fi-text);
}

.btn-small {
    padding: 0.25rem 0.5625rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
}

.btn-small svg {
    width: 0.875rem;
    height: 0.875rem;
}

.btn-sub {
    opacity: 0.7;
    font-weight: 500;
}

.btn.is-done {
    border-color: var(--fi-ok);
    color: var(--fi-ok);
}

.btn-primary.is-done {
    background: var(--fi-ok);
    color: #06210f;
}

.icon-btn {
    display: inline-grid;
    place-items: center;
    flex: none;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 0.4375rem;
    background: transparent;
    color: var(--fi-muted);
    cursor: pointer;
}

.icon-btn:hover:not(:disabled) {
    border-color: var(--fi-border);
    background: var(--fi-chrome-hover);
    color: var(--fi-accent);
}

.icon-btn:disabled {
    cursor: default;
    opacity: 0.35;
}

/* A switch drawn as one joined strip. Pressed rather than one-shot - the state is what
   the icon is. */
.seg {
    display: inline-flex;
    flex: none;
    max-width: 100%;
    overflow: hidden;
    border: 1px solid var(--fi-border);
    border-radius: 0.4375rem;
    background: var(--fi-pane-alt);
}

.seg > button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    min-width: 0;
    padding: 0.3125rem 0.6875rem;
    border: 0;
    background: transparent;
    color: var(--fi-muted);
    font: inherit;
    font-size: 0.75rem;
    white-space: nowrap;
    cursor: pointer;
}

.seg > button + button {
    border-left: 1px solid var(--fi-border);
}

.seg > button:hover:not(.is-on) {
    background: var(--fi-chrome-hover);
    color: var(--fi-text);
}

.seg > button.is-on {
    background: var(--fi-accent-wash);
    color: var(--fi-accent);
    font-weight: 600;
}

.seg-wrap {
    flex-wrap: wrap;
}

.seg-icon svg {
    width: 0.875rem;
    height: 0.875rem;
}

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

.field + .field {
    margin-top: 0.875rem;
}

.field-row {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
}

.field-label {
    display: flex;
    align-items: baseline;
    gap: 0.375rem;
    color: var(--fi-muted);
    font-size: 0.75rem;
    font-weight: 550;
}

.field-label output {
    margin-left: auto;
    color: var(--fi-text);
    font-variant-numeric: tabular-nums;
}

.field-hint {
    color: var(--fi-faint);
    font-weight: 400;
}

.field-controls {
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.field-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(12.5rem, 1fr));
    gap: 0.875rem 1rem;
}

.field-grid .field + .field {
    margin-top: 0;
}

.text-input,
.hex-input,
.head-field select {
    box-sizing: border-box;
    min-width: 0;
    padding: 0.4375rem 0.625rem;
    border: 1px solid var(--fi-border);
    border-radius: 0.4375rem;
    background: var(--fi-pane-alt);
    color: var(--fi-text);
    font: inherit;
    font-size: 0.8125rem;
}

.text-input:hover,
.hex-input:hover {
    border-color: color-mix(in srgb, var(--fi-accent) 35%, var(--fi-border));
}

.text-input:focus,
.hex-input:focus {
    border-color: var(--fi-accent);
    outline: none;
    box-shadow: var(--fi-focus);
}

.mono,
.hex-input {
    font-family: var(--fi-mono);
}

.text-input-big {
    padding: 0.5rem 0.75rem;
    font-size: 1.375rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.range {
    width: 100%;
    margin: 0.25rem 0 0;
    accent-color: var(--fi-accent);
}

/* A colour input shown as a swatch with its hex beside it. */
.colour-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.1875rem 0.625rem 0.1875rem 0.1875rem;
    border: 1px solid var(--fi-border);
    border-radius: 999px;
    background: var(--fi-pane-alt);
    color: var(--fi-text);
    font-family: var(--fi-mono);
    font-size: 0.75rem;
    cursor: pointer;
}

.colour-pill:hover {
    border-color: color-mix(in srgb, var(--fi-accent) 35%, var(--fi-border));
}

.colour-pill-wide {
    align-self: stretch;
    border-radius: 0.4375rem;
}

.colour-pill input[type="color"],
.colour-well input[type="color"] {
    flex: none;
    width: 1.5rem;
    height: 1.5rem;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: none;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

.colour-pill-wide input[type="color"] {
    border-radius: 0.3125rem;
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"]::-webkit-color-swatch {
    border: 1px solid rgba(128, 128, 128, 0.35);
    border-radius: inherit;
}

input[type="color"]::-moz-color-swatch {
    border: 1px solid rgba(128, 128, 128, 0.35);
    border-radius: inherit;
}

.is-disabled {
    opacity: 0.45;
}

/* On and off. */
.switch {
    position: relative;
    display: inline-flex;
    flex: none;
    cursor: pointer;
}

.switch input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
}

.switch-track {
    position: relative;
    width: 2.25rem;
    height: 1.25rem;
    border-radius: 999px;
    background: var(--fi-border);
    transition: background 0.15s ease;
}

.switch-track::after {
    content: "";
    position: absolute;
    top: 0.1875rem;
    left: 0.1875rem;
    width: 0.875rem;
    height: 0.875rem;
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    transition: transform 0.15s ease;
}

.switch input:checked + .switch-track {
    background: var(--fi-accent);
}

.switch input:checked + .switch-track::after {
    transform: translateX(1rem);
}

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

/* Transparency. */
.checker {
    background-color: var(--fi-checker-a);
    background-image: conic-gradient(var(--fi-checker-b) 25%, transparent 0 50%, var(--fi-checker-b) 0 75%, transparent 0);
    background-size: 12px 12px;
}

.note {
    margin: 0;
    color: var(--fi-muted);
    font-size: 0.75rem;
    line-height: 1.5;
}

.note strong {
    color: var(--fi-text);
    font-weight: 600;
}

.note-warn {
    padding: 0.5rem 0.625rem;
    border-left: 2px solid var(--fi-warn);
    border-radius: 0 0.375rem 0.375rem 0;
    background: color-mix(in srgb, var(--fi-warn) 10%, transparent);
    color: var(--fi-text);
}

kbd {
    display: inline-block;
    padding: 0 0.3125rem;
    border: 1px solid var(--fi-border);
    border-bottom-width: 2px;
    border-radius: 0.25rem;
    background: var(--fi-pane-alt);
    color: var(--fi-text);
    font-family: var(--fi-mono);
    font-size: 0.6875rem;
    line-height: 1.5;
}

/* ==== Studio ================================================================ */

.studio {
    display: flex;
    flex-direction: column;
    min-width: 0;
    container: studio / inline-size;
}

.studio-head {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.625rem;
    flex: none;
    padding: var(--fi-gap) var(--fi-gap) 0;
}

.studio-head-spacer {
    flex: 1;
}

.source-tabs {
    display: inline-flex;
    gap: 0.25rem;
    padding: 0.25rem;
    border: 1px solid var(--fi-border);
    border-radius: 0.75rem;
    background: var(--fi-pane);
}

.source-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4375rem 1rem 0.4375rem 0.8125rem;
    border: 0;
    border-radius: 0.5rem;
    background: transparent;
    color: var(--fi-muted);
    font: inherit;
    font-size: 0.8125rem;
    font-weight: 550;
    cursor: pointer;
}

.source-tab:hover:not(.is-on) {
    background: var(--fi-chrome-hover);
    color: var(--fi-text);
}

.source-tab.is-on {
    background: var(--fi-accent-wash);
    color: var(--fi-accent);
    box-shadow: inset 0 0 0 1px var(--fi-accent-dim);
}

.head-field {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--fi-muted);
    font-size: 0.75rem;
    font-weight: 550;
}

.head-field select {
    padding: 0.3125rem 0.5rem;
    cursor: pointer;
}

.studio-panel {
    flex: 1;
    min-height: 0;
    padding: var(--fi-gap);
}

/* Drop a file anywhere on the studio. */
.studio.is-drop-target .studio-panel {
    outline: 2px dashed var(--fi-accent);
    outline-offset: -0.5rem;
    border-radius: 1rem;
}

/* ---- Draw ---- */

.panel-draw {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) 13.5rem;
    grid-template-rows: minmax(0, 1fr);
    gap: var(--fi-gap);
}

.toolrail {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    align-self: start;
    padding: 0.375rem;
    border: 1px solid var(--fi-border);
    border-radius: 0.75rem;
    background: var(--fi-pane);
}

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

.rail-sep {
    width: 1.5rem;
    height: 1px;
    background: var(--fi-border);
}

.rail-btn {
    display: grid;
    place-items: center;
    width: 2.375rem;
    height: 2.375rem;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 0.5rem;
    background: transparent;
    color: var(--fi-muted);
    cursor: pointer;
}

.rail-btn svg {
    width: 1.125rem;
    height: 1.125rem;
}

.rail-btn:hover:not(:disabled):not(.is-on) {
    background: var(--fi-chrome-hover);
    color: var(--fi-text);
}

.rail-btn.is-on {
    border-color: var(--fi-accent-dim);
    background: var(--fi-accent-wash);
    color: var(--fi-accent);
}

/* The toggles (mirror, grid, filled) are not tools, so they light up in the second
   accent rather than looking like the tool in hand. */
.rail-btn[data-toggle].is-on {
    border-color: color-mix(in srgb, var(--fi-accent-2) 50%, transparent);
    background: var(--fi-accent-2-wash);
    color: var(--fi-accent-2);
}

/* A laptop-height window: a tighter rail, so every tool fits beside the canvas. */
@media (max-height: 959.98px) {
    .toolrail {
        gap: 0.3125rem;
        padding: 0.25rem;
    }

    .rail-group {
        gap: 0.125rem;
    }

    .rail-btn {
        width: 2.125rem;
        height: 1.875rem;
    }
}

.rail-btn:disabled {
    cursor: default;
    opacity: 0.35;
}

.canvas-stage {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    border: 1px solid var(--fi-border);
    border-radius: 0.75rem;
    background:
        radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--fi-accent) 5%, transparent), transparent 70%),
        var(--fi-pane);
}

.canvas-frame {
    flex: 1;
    min-height: 0;
    display: grid;
    place-items: center;
    padding: 1.25rem;
}

.pixel-canvas {
    display: block;
    border-radius: 2px;
    box-shadow: 0 0 0 1px var(--fi-border), var(--fi-shadow);
    touch-action: none;
    cursor: crosshair;
    image-rendering: pixelated;
}

.pixel-canvas[data-tool="picker"] {
    cursor: copy;
}

.pixel-canvas[data-tool="fill"] {
    cursor: cell;
}

.canvas-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.125rem;
    flex: none;
    padding: 0.3125rem 0.5rem;
    border-top: 1px solid var(--fi-border-soft);
    background: var(--fi-pane-alt);
}

.bar-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    height: 1.875rem;
    min-width: 1.875rem;
    justify-content: center;
    padding: 0 0.375rem;
    border: 1px solid transparent;
    border-radius: 0.375rem;
    background: transparent;
    color: var(--fi-muted);
    font: inherit;
    font-size: 0.75rem;
    cursor: pointer;
}

.bar-btn:hover {
    border-color: var(--fi-border);
    background: var(--fi-chrome-hover);
    color: var(--fi-text);
}

.bar-btn-label {
    padding: 0 0.5625rem 0 0.4375rem;
}

.bar-sep {
    width: 1px;
    height: 1.125rem;
    margin: 0 0.25rem;
    background: var(--fi-border);
}

.bar-spacer {
    flex: 1;
}

.bar-readout {
    margin-right: 0.5rem;
    color: var(--fi-faint);
    font-family: var(--fi-mono);
    font-size: 0.6875rem;
    font-variant-numeric: tabular-nums;
}

.palette {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-self: start;
    max-height: 100%;
    box-sizing: border-box;
    overflow: auto;
    padding: 0.875rem;
    border: 1px solid var(--fi-border);
    border-radius: 0.75rem;
    background: var(--fi-pane);
}

.colour-now {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.colour-well {
    display: block;
    flex: none;
    cursor: pointer;
}

.colour-well input[type="color"] {
    width: 3rem;
    height: 3rem;
    border-radius: 0.625rem;
    box-shadow: var(--fi-shadow);
}

.colour-now-text {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.colour-now-text .hex-input {
    width: 100%;
    padding: 0.3125rem 0.5rem;
    text-transform: lowercase;
}

.mini-title {
    margin: 0 0 0.4375rem;
    color: var(--fi-faint);
    font-size: 0.6875rem;
    font-weight: 650;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.colour-now-text .mini-title {
    margin: 0;
}

.swatches {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(1.375rem, 1fr));
    gap: 0.25rem;
}

.swatches:empty {
    display: none;
}

.swatch {
    aspect-ratio: 1;
    padding: 0;
    border: 0;
    border-radius: 0.3125rem;
    background: var(--swatch);
    box-shadow: inset 0 0 0 1px rgba(128, 128, 128, 0.28);
    cursor: pointer;
    transition: transform 0.08s ease;
}

.swatch:hover {
    transform: scale(1.12);
}

.swatch.is-on {
    outline: 2px solid var(--fi-accent);
    outline-offset: 1px;
}

.palette-empty,
.palette-tip {
    margin: 0;
    color: var(--fi-faint);
    font-size: 0.75rem;
    line-height: 1.45;
}

/* A narrow studio: tools above the canvas, colours below it. */
@container studio (max-width: 43.99rem) {
    .panel-draw {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: none;
    }

    .toolrail {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        align-self: stretch;
    }

    .rail-group {
        flex-direction: row;
    }

    .rail-sep {
        width: 1px;
        height: 1.5rem;
    }

    .canvas-frame {
        aspect-ratio: 1;
        padding: 0.75rem;
    }

    .palette {
        max-height: none;
    }

    .swatches {
        grid-template-columns: repeat(auto-fill, minmax(1.75rem, 1fr));
    }
}

/* ---- Upload and text ---- */

.panel-image,
.panel-text {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 19rem;
    grid-template-rows: minmax(0, 1fr);
    gap: var(--fi-gap);
}

.panel-image:has(.dropzone:not([hidden])) {
    grid-template-columns: minmax(0, 1fr);
}

.image-view {
    display: contents;
}

.stage-preview {
    display: grid;
    place-items: center;
    min-height: 0;
    padding: 2rem;
    overflow: hidden;
    border: 1px solid var(--fi-border);
    border-radius: 0.75rem;
}

.big-preview {
    display: block;
    width: min(100%, 22rem);
    max-height: 100%;
    aspect-ratio: 1;
    object-fit: contain;
    filter: drop-shadow(0 10px 28px rgba(0, 0, 0, 0.28));
}

.side-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-self: start;
    max-height: 100%;
    box-sizing: border-box;
    overflow: auto;
    padding: 1rem;
    border: 1px solid var(--fi-border);
    border-radius: 0.75rem;
    background: var(--fi-pane);
}

.side-controls .field + .field {
    margin-top: 0;
}

.side-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding-top: 0.875rem;
    border-top: 1px solid var(--fi-border-soft);
}

.side-actions .btn:first-child {
    flex-basis: 100%;
}

.file-chip {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    min-width: 0;
}

.file-chip-name {
    overflow: hidden;
    color: var(--fi-text);
    font-family: var(--fi-mono);
    font-size: 0.8125rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-chip-meta {
    color: var(--fi-muted);
    font-size: 0.75rem;
}

.dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.625rem;
    min-height: 18rem;
    padding: 2rem;
    border: 2px dashed var(--fi-border);
    border-radius: 1rem;
    background:
        radial-gradient(circle at 50% 35%, var(--fi-accent-wash), transparent 60%),
        var(--fi-pane);
    text-align: center;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.studio.is-drop-target .dropzone {
    border-color: var(--fi-accent);
}

.dropzone-mark {
    width: 3.5rem;
    height: 3.5rem;
    margin-bottom: 0.25rem;
    fill: none;
    stroke: var(--fi-accent);
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.dropzone-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 650;
    letter-spacing: -0.01em;
}

.dropzone-text {
    max-width: 30rem;
    margin: 0 0 0.5rem;
    color: var(--fi-muted);
    font-size: 0.8125rem;
    line-height: 1.55;
}

.dropzone-note {
    margin: 0.25rem 0 0;
    color: var(--fi-faint);
    font-size: 0.75rem;
}

@container studio (max-width: 43.99rem) {
    .panel-image,
    .panel-text {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: none;
    }

    .stage-preview {
        padding: 1.5rem;
    }

    .big-preview {
        width: min(100%, 16rem);
    }
}

/* ==== Output ================================================================ */

.output {
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--fi-pane-alt);
    container: output / inline-size;
}

.output-scroll {
    padding: var(--fi-gap);
}

/* Cards flow down columns once the output is wide enough for two. */
.output-cards {
    columns: 2 26rem;
    column-gap: var(--fi-gap);
}

.card {
    break-inside: avoid;
    margin: 0 0 var(--fi-gap);
    padding: 0.875rem 1rem 1rem;
    border: 1px solid var(--fi-border);
    border-radius: 0.875rem;
    background: var(--fi-pane);
}

.card-head {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.25rem 0.75rem;
    margin-bottom: 0.875rem;
}

.card-title {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 650;
    letter-spacing: -0.01em;
}

.card-hint {
    color: var(--fi-faint);
    font-size: 0.75rem;
}

.output-foot {
    position: sticky;
    bottom: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    flex: none;
    padding: 0.625rem var(--fi-gap);
    border-top: 1px solid var(--fi-border);
    background: color-mix(in srgb, var(--fi-chrome) 92%, transparent);
    backdrop-filter: blur(8px);
}

.output-total {
    color: var(--fi-muted);
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
}

.output-foot-spacer {
    flex: 1;
}

@container output (max-width: 31rem) {
    .output-total {
        flex-basis: 100%;
    }

    .output-foot-spacer {
        display: none;
    }

    .output-foot .btn {
        flex: 1;
    }
}

/* ---- Previews ---- */

.scenes {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.scene {
    display: flex;
    flex-direction: column;
    gap: 0.4375rem;
    min-width: 0;
    margin: 0;
}

.scene-tabs,
.scene-search,
.scene-sizes {
    grid-column: 1 / -1;
}

.scene figcaption {
    color: var(--fi-faint);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.figcaption-note {
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
}

.icon-canvas {
    display: block;
    flex: none;
}

.icon-canvas.is-pixelated {
    image-rendering: pixelated;
}

/* Browser tabs. Fixed colours - they are Chrome's, in each of its modes, whatever this
   app's theme is. */
.scene-tabs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
    gap: 0.5rem;
}

.scene-tabs figcaption {
    grid-column: 1 / -1;
    order: -1;
}

.mock-browser {
    --tabs-bg: #dfe3e8;
    --tab-bg: #ffffff;
    --tab-text: #1f1f1f;
    --tab-muted: #5f6368;
    --url-bg: #eff1f3;
    overflow: hidden;
    border-radius: 0.625rem;
    background: var(--tabs-bg);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

.mock-dark {
    --tabs-bg: #1f2023;
    --tab-bg: #35363a;
    --tab-text: #e8eaed;
    --tab-muted: #9aa0a6;
    --url-bg: #202124;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.mock-tabs {
    display: flex;
    gap: 2px;
    padding: 6px 6px 0;
}

.mock-tab {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
    flex: 1;
    max-width: 11rem;
    height: 30px;
    padding: 0 10px;
    border-radius: 8px 8px 0 0;
    color: var(--tab-muted);
    font-size: 12px;
}

.mock-tab.is-active {
    flex: 1.6;
    background: var(--tab-bg);
    color: var(--tab-text);
}

.mock-tab-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mock-tab-x {
    color: var(--tab-muted);
    font-size: 14px;
    line-height: 1;
}

.mock-ghost {
    flex: none;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    background: var(--tab-muted);
    opacity: 0.35;
}

.mock-toolbar {
    padding: 6px 8px 8px;
    background: var(--tab-bg);
}

.mock-url {
    display: block;
    padding: 5px 12px;
    border-radius: 999px;
    background: var(--url-bg);
    color: var(--tab-muted);
    font-size: 11px;
}

/* Home screens. */
.mock-phone {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem 0.25rem;
    padding: 1.125rem 0.625rem 1rem;
    border-radius: 1rem;
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

.mock-ios {
    background:
        radial-gradient(circle at 20% 15%, rgba(255, 255, 255, 0.35), transparent 45%),
        linear-gradient(155deg, #4f7cff 0%, #9b6bff 48%, #ff8a7a 100%);
}

.mock-android {
    background:
        radial-gradient(circle at 80% 10%, rgba(255, 255, 255, 0.22), transparent 45%),
        linear-gradient(160deg, #10363c 0%, #1f6a5c 55%, #a0cf94 100%);
}

.mock-app {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    min-width: 0;
}

.mock-app .icon-canvas,
.mock-app-ghost {
    width: 52px;
    height: 52px;
    max-width: 100%;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.22);
}

.app-ios,
.mock-ios .mock-app-ghost {
    border-radius: 22.5%;
}

.app-android,
.mock-android .mock-app-ghost {
    border-radius: 50%;
}

.mock-app-ghost {
    display: block;
    background:
        linear-gradient(160deg, rgba(255, 255, 255, 0.3), transparent 60%),
        var(--g);
    opacity: 0.85;
}

.mock-app-label {
    max-width: 100%;
    overflow: hidden;
    color: #ffffff;
    font-size: 10.5px;
    text-overflow: ellipsis;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
    white-space: nowrap;
}

/* A search result. */
.mock-search {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 14px 16px;
    border-radius: 0.625rem;
    background: #ffffff;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
    color: #202124;
    font-family: Arial, system-ui, sans-serif;
}

.mock-search-site {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mock-search-icon {
    display: grid;
    place-items: center;
    flex: none;
    width: 28px;
    height: 28px;
    border: 1px solid #dadce0;
    border-radius: 50%;
    background: #f1f3f4;
}

.mock-search-icon .icon-canvas {
    border-radius: 3px;
}

.mock-search-names {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.mock-search-name {
    overflow: hidden;
    font-size: 14px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mock-search-url {
    color: #4d5156;
    font-size: 12px;
}

.mock-search-title {
    margin-top: 2px;
    overflow: hidden;
    color: #1a0dab;
    font-size: 18px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mock-search-line {
    height: 8px;
    border-radius: 4px;
    background: #e8eaed;
}

.mock-search-line.is-short {
    width: 62%;
}

/* Actual sizes. */
.sizes {
    display: flex;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 0.75rem 0.875rem;
}

.size-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3125rem;
}

.size-box {
    display: grid;
    place-items: center;
    padding: 6px;
    border-radius: 0.375rem;
    box-shadow: inset 0 0 0 1px var(--fi-border-soft);
}

.size-zoom .size-box {
    box-shadow: inset 0 0 0 1px var(--fi-accent-dim);
}

.size-label {
    color: var(--fi-muted);
    font-family: var(--fi-mono);
    font-size: 0.6875rem;
}

@container output (max-width: 24rem) {
    .scenes {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* ---- Files ---- */

.file-group + .file-group {
    margin-top: 0.875rem;
    padding-top: 0.875rem;
    border-top: 1px solid var(--fi-border-soft);
}

.file-group-head {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.375rem;
}

.file-group-text {
    flex: 1;
    min-width: 0;
}

.file-group-title {
    margin: 0;
    font-size: 0.8125rem;
    font-weight: 650;
}

.file-group-hint {
    color: var(--fi-faint);
    font-size: 0.75rem;
}

.file-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.file-group.is-off .file-list {
    opacity: 0.4;
}

.file-row {
    display: grid;
    grid-template-columns: 2.25rem minmax(0, 1fr) auto 3.75rem auto;
    align-items: center;
    gap: 0.625rem;
    padding: 0.3125rem 0.25rem 0.3125rem 0.3125rem;
    border-radius: 0.5rem;
}

.file-row:hover {
    background: var(--fi-pane-alt);
}

.file-row.is-unavailable .file-thumb,
.file-row.is-unavailable .file-name {
    opacity: 0.45;
}

.file-thumb {
    display: grid;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    overflow: hidden;
    border-radius: 0.375rem;
    box-shadow: inset 0 0 0 1px var(--fi-border-soft);
}

.file-thumb .icon-canvas {
    width: 28px;
    height: 28px;
}

.file-thumb-text {
    background: var(--fi-pane-alt);
    color: var(--fi-muted);
}

.file-thumb-text svg {
    width: 1.125rem;
    height: 1.125rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.3;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.file-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.file-name {
    overflow: hidden;
    color: var(--fi-text);
    font-family: var(--fi-mono);
    font-size: 0.75rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-note {
    overflow: hidden;
    color: var(--fi-faint);
    font-size: 0.6875rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-dims,
.file-size {
    color: var(--fi-muted);
    font-size: 0.6875rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.file-size {
    text-align: right;
}

@container output (max-width: 25rem) {
    .file-row {
        grid-template-columns: 2.25rem minmax(0, 1fr) 3.5rem auto;
    }

    .file-dims {
        display: none;
    }
}

/* ---- Code ---- */

.code-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-bottom: 0.5rem;
}

.code-tab {
    padding: 0.3125rem 0.625rem;
    border: 1px solid transparent;
    border-radius: 0.4375rem;
    background: transparent;
    color: var(--fi-muted);
    font-family: var(--fi-mono);
    font-size: 0.75rem;
    cursor: pointer;
}

.code-tab:hover:not(.is-on) {
    background: var(--fi-chrome-hover);
    color: var(--fi-text);
}

.code-tab.is-on {
    border-color: var(--fi-border);
    background: var(--fi-pane-alt);
    color: var(--fi-text);
}

.code-box {
    position: relative;
}

.code {
    max-height: 22rem;
    margin: 0;
    padding: 0.875rem 1rem;
    overflow: auto;
    border: 1px solid var(--fi-border);
    border-radius: 0.625rem;
    background: var(--fi-chrome);
    color: var(--fi-text);
    font-family: var(--fi-mono);
    font-size: 0.71875rem;
    line-height: 1.65;
    tab-size: 2;
    white-space: pre;
}

.code-actions {
    display: flex;
    gap: 0.375rem;
    margin-top: 0.5rem;
    justify-content: flex-end;
}

.t-tag { color: var(--fi-accent-2); }
.t-attr { color: var(--fi-accent); }
.t-value { color: var(--fi-ok); }
.t-key { color: var(--fi-accent); }
.t-punct { color: var(--fi-faint); }
.t-comment { color: var(--fi-faint); font-style: italic; }

/* ==== Status bar ============================================================ */

.statusbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: none;
    box-sizing: border-box;
    /* Fixed, so the privacy sheet can sit exactly on top of it. */
    height: var(--fi-statusbar-h);
    padding: 0 0.875rem;
    background: var(--fi-chrome);
    border-top: 1px solid var(--fi-border);
    color: var(--fi-muted);
    font-size: 0.6875rem;
}

.statusbar-item {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.statusbar-summary {
    color: var(--fi-text);
}

.statusbar-spacer {
    flex: 1;
}

.statusbar-note {
    color: var(--fi-faint);
    white-space: nowrap;
}

.statusbar-note::before {
    content: "";
    display: inline-block;
    width: 0.4375rem;
    height: 0.4375rem;
    margin-right: 0.4375rem;
    border-radius: 999px;
    background: var(--fi-ok);
    vertical-align: 0.05em;
}

@media (max-width: 719.98px) {
    .statusbar-note {
        display: none;
    }
}

.statusbar-warn {
    min-width: 0;
    overflow: hidden;
    color: var(--fi-warn);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.statusbar-link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    flex: none;
    padding: 0;
    border: 0;
    background: none;
    color: var(--fi-faint);
    font: inherit;
    white-space: nowrap;
    cursor: pointer;
}

.statusbar-link:hover,
.statusbar-link:focus-visible,
.statusbar:has(+ .privacy-sheet:popover-open) .statusbar-link {
    color: var(--fi-text);
}

.statusbar-chevron {
    width: 0.625rem;
    height: 0.625rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.2s ease;
}

.statusbar:has(+ .privacy-sheet:popover-open) .statusbar-chevron {
    transform: rotate(180deg);
}

/* ==== Privacy sheet ========================================================= */

/* Slides up out of the status bar, on the right under the button that opened it. A
   popover, so it lives in the top layer and needs no z-index; the UA's centring and
   border are undone. */
.privacy-sheet {
    position: fixed;
    inset: auto 0.75rem var(--fi-statusbar-h) auto;
    box-sizing: border-box;
    width: min(26rem, calc(100vw - 1.5rem));
    max-height: calc(100vh - var(--fi-statusbar-h) - 3.5rem);
    margin: 0;
    padding: 0.875rem 1rem 0.75rem;
    overflow: auto;
    background: var(--fi-pane);
    border: 1px solid var(--fi-border);
    border-bottom: 0;
    border-radius: 0.5rem 0.5rem 0 0;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.22);
    color: var(--fi-text);
    font-family: var(--fi-sans);
    font-size: 0.8125rem;
    line-height: 1.5;

    transform: translateY(100%);
    opacity: 0;
    transition:
        transform 0.22s ease,
        opacity 0.22s ease,
        overlay 0.22s allow-discrete,
        display 0.22s allow-discrete;
}

.privacy-sheet:popover-open {
    transform: none;
    opacity: 1;
}

@starting-style {
    .privacy-sheet:popover-open {
        transform: translateY(100%);
        opacity: 0;
    }
}

.privacy-sheet::backdrop {
    background: transparent;
}

.privacy-sheet-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.privacy-sheet-title {
    flex: 1;
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.privacy-sheet-close {
    display: grid;
    place-items: center;
    width: 1.5rem;
    height: 1.5rem;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 0.25rem;
    background: none;
    color: var(--fi-muted);
    cursor: pointer;
}

.privacy-sheet-close:hover,
.privacy-sheet-close:focus-visible {
    border-color: var(--fi-border);
    background: var(--fi-chrome-hover);
    color: var(--fi-text);
}

.privacy-sheet-close svg {
    width: 0.75rem;
    height: 0.75rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.privacy-sheet-list {
    margin: 0;
    padding-left: 1.125rem;
    color: var(--fi-muted);
}

.privacy-sheet-list li + li {
    margin-top: 0.4375rem;
}

.privacy-sheet-list strong {
    color: var(--fi-text);
    font-weight: 600;
}

.privacy-sheet-foot {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    margin-top: 0.75rem;
    padding-top: 0.625rem;
    border-top: 1px solid var(--fi-border-soft);
    font-size: 0.75rem;
}

.privacy-sheet-foot a {
    color: var(--fi-accent);
    text-decoration: none;
}

.privacy-sheet-foot a:hover,
.privacy-sheet-foot a:focus-visible {
    text-decoration: underline;
}

/* ==== Toast ================================================================= */

.toast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--fi-statusbar-h) + 4.5rem);
    z-index: 10;
    padding: 0.5rem 0.875rem;
    border: 1px solid var(--fi-border);
    border-radius: 999px;
    background: var(--fi-raised);
    box-shadow: var(--fi-shadow);
    color: var(--fi-text);
    font-family: var(--fi-sans);
    font-size: 0.8125rem;
    transform: translateX(-50%);
    animation: toast-in 0.18s ease;
}

.toast::before {
    content: "✓";
    margin-right: 0.4375rem;
    color: var(--fi-ok);
    font-weight: 700;
}

.toast.is-error::before {
    content: "!";
    color: var(--fi-danger);
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translate(-50%, 0.5rem);
    }
}

@media (prefers-reduced-motion: reduce) {
    .privacy-sheet,
    .statusbar-chevron,
    .toast,
    .switch-track,
    .switch-track::after {
        transition: none;
        animation: none;
    }
}

/* ==== Not found ============================================================= */

.missing {
    flex: 1;
    display: grid;
    place-items: center;
    padding: 2rem;
    text-align: center;
}

.missing h1 {
    margin: 0 0 0.5rem;
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.missing p {
    margin: 0 0 1rem;
    color: var(--fi-muted);
}

.missing a {
    color: var(--fi-accent);
}
