/* Local-only Studio shell. It composes the gallery tokens rather than
   introducing a second palette, so the workbench sits beside the site. */

.studio-app {
    --studio-line: var(--site-border);
    --studio-line-strong: var(--site-border-hover);
    --studio-text: var(--site-text);
    --studio-muted: var(--site-muted);
    --studio-panel: var(--site-bg-elevated);
    --studio-accent: var(--site-accent);
    --studio-ok: var(--lumen-green, #1f7a4d);
    --studio-warn: var(--lumen-amber, #8a610f);
    --studio-danger: var(--lumen-red, #b3261e);
    --studio-panel-bg: color-mix(in oklab, var(--site-bg-elevated) 74%, var(--site-bg));
    --studio-card: color-mix(in oklab, var(--site-bg-card) 82%, transparent);
    --studio-accent-soft: color-mix(in oklab, var(--site-accent) 15%, transparent);
    --studio-accent-line: color-mix(in oklab, var(--site-accent) 38%, transparent);
    /* Accent ink: the label on an accent-tinted control. The tint stays light
       enough that the page's own text colour always reads on it, whatever
       accent the reader picked, in Light, Dark, High contrast and 2077. */
    --studio-accent-wash: color-mix(in oklab, var(--site-accent) 22%, transparent);
    --studio-accent-wash-strong: color-mix(in oklab, var(--site-accent) 32%, transparent);
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
    background: var(--site-bg);
    color: var(--site-text);
    font-family: var(--site-font);
}

.studio-shell {
    height: 100dvh;
    display: flex;
    flex-direction: column;
}

.studio-app [hidden] {
    display: none !important;
}

/* —— Submit identity question ——
   Asked in the panel, not in a modal: the answer decides whether the package
   is sent as a listing update or as the submitter's own new theme. */

.studio-identity {
    margin: 0 0 16px;
    padding: 14px;
    border: 1px solid var(--studio-accent-line);
    border-radius: 12px;
    background: var(--studio-accent-soft);
}

.studio-identity-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.studio-identity-head .studio-eyebrow {
    margin: 0;
}

.studio-identity-lead {
    margin: 0 0 12px;
    color: var(--site-text);
    font-size: 0.8rem;
    line-height: 1.45;
}

.studio-identity-lead strong {
    color: color-mix(in oklab, var(--site-accent) 62%, var(--site-text));
}

.studio-identity-q {
    margin: 0 0 8px;
    color: var(--site-text);
    font-size: 0.82rem;
    font-weight: 650;
}

.studio-identity-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.studio-identity-actions .studio-btn {
    flex: 1 1 138px;
    min-height: 38px;
    justify-content: center;
}

.studio-identity-result {
    display: grid;
    gap: 7px;
    justify-items: start;
}

.studio-identity-result .studio-hint {
    margin: 0;
}

.studio-modal {
    position: fixed;
    inset: 0;
    z-index: 400;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(6, 7, 11, 0.68);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}

.studio-modal-card {
    width: min(100%, 520px);
    max-height: min(86dvh, 640px);
    overflow: auto;
    padding: 26px 26px 22px;
    border: 1px solid var(--studio-line-strong);
    border-radius: 18px;
    background: color-mix(in oklab, var(--site-bg-elevated) 94%, var(--site-bg));
    box-shadow: var(--lumen-shadow);
    color: var(--site-text);
}

.studio-modal-card h2 {
    margin: 6px 0 10px;
    font-family: var(--site-font-display);
    font-size: 1.5rem;
    font-weight: 400;
    line-height: 1.15;
    letter-spacing: -0.02em;
}

.studio-modal-card p {
    margin: 0 0 14px;
    color: var(--site-muted);
    font-size: 0.9rem;
    line-height: 1.55;
}

.studio-modal-card .studio-inline-check {
    margin-top: 6px;
}

.studio-modal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* —— Masks —— */

.studio-mask-editor {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--studio-line);
}

.studio-mask-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.studio-mask-head .studio-eyebrow { margin: 0; }
.studio-mask-head > span { color: var(--site-muted); font-size: 0.68rem; }

.studio-mask-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
}

.studio-mask-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px;
    border: 1px solid var(--studio-line);
    border-radius: 10px;
    background: var(--studio-card);
}

.studio-mask-top { display: flex; align-items: center; gap: 8px; min-width: 0; }

.studio-mask-art {
    position: relative;
    flex: 0 0 56px;
    width: 56px;
    height: 42px;
    display: grid;
    place-items: center;
    overflow: hidden;
    border: 1px solid var(--studio-line);
    border-radius: 8px;
    background: color-mix(in oklab, var(--site-bg) 60%, #000);
    color: var(--site-muted);
}

.studio-mask-art.has-live-crop { background: #05070c; }

.studio-mask-art img { width: 100%; height: 100%; object-fit: contain; }

.studio-mask-copy { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.studio-mask-copy strong { font-size: 0.76rem; line-height: 1.2; }
.studio-mask-copy > span { overflow: hidden; color: var(--site-muted); font: 500 0.62rem var(--site-font-mono); text-overflow: ellipsis; white-space: nowrap; }

.studio-mask-badge {
    color: var(--site-muted);
    font: 600 0.56rem var(--site-font-mono);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.studio-mask-badge.is-changed { color: var(--site-accent); }
.studio-mask-badge.is-missing { color: var(--studio-danger, #e2564f); }

.studio-mask-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }

.studio-mask-actions button {
    min-height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 4px 6px;
    border: 1px solid var(--studio-line);
    border-radius: 7px;
    background: var(--site-bg);
    color: var(--site-text);
    font: 600 0.64rem var(--site-font);
    cursor: pointer;
}

.studio-mask-actions button:hover { border-color: var(--site-accent); color: var(--site-accent); }
.studio-mask-actions button:focus-visible { outline: 2px solid var(--site-accent); outline-offset: 1px; }
.studio-mask-actions button:disabled { opacity: 0.45; cursor: not-allowed; }
.studio-mask-actions button.is-primary { border-color: var(--site-accent); color: var(--site-accent); }

.studio-mask-hint {
    margin: 8px 0 0;
    color: var(--site-muted);
    font-size: 0.68rem;
    line-height: 1.45;
}

/* Watch-sized trays: keep the two buttons per mask, drop their labels so the
   actions stay inside a 200px column. */
@media (max-width: 300px) {
    body.studio-app .studio-mask-actions button span { display: none; }
    body.studio-app .studio-mask-actions button { min-height: 30px; }
    body.studio-app .studio-mask-copy > span { display: none; }
}

/* —— Swap an asset in from another theme —— */

.studio-theme-picker-card {
    width: min(100%, 660px);
    display: flex;
    flex-direction: column;
    padding: 22px 22px 16px;
    overflow: hidden;
}

.studio-theme-picker-card h2 { margin: 6px 0 4px; font-size: 1.3rem; }
.studio-theme-picker-card > p { margin: 0 0 12px; }

.studio-theme-picker-search {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 38px;
    margin-bottom: 10px;
    padding: 0 10px;
    border: 1px solid var(--studio-line);
    border-radius: 10px;
    background: var(--site-bg);
    color: var(--site-muted);
}

.studio-theme-picker-search input {
    flex: 1;
    min-width: 0;
    border: 0;
    background: transparent;
    color: var(--site-text);
    font: inherit;
    font-size: 0.85rem;
}

.studio-theme-picker-search input:focus { outline: none; }
.studio-theme-picker-search:focus-within { border-color: var(--site-accent); }

.studio-theme-picker-list {
    flex: 1 1 auto;
    min-height: 0;
    max-height: 52dvh;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow: auto;
    padding-right: 2px;
}

.studio-theme-row {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 9px;
    border: 1px solid var(--studio-line);
    border-radius: 10px;
    background: var(--site-bg);
    color: var(--site-text);
    text-align: left;
    cursor: pointer;
}

.studio-theme-row:hover { border-color: var(--site-accent); }
.studio-theme-row:focus-visible { outline: 2px solid var(--site-accent); outline-offset: 1px; }
.studio-theme-row.is-empty { opacity: 0.5; cursor: default; }
.studio-theme-row.is-empty:hover { border-color: var(--studio-line); }

.studio-theme-row-thumb {
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    overflow: hidden;
    border: 1px solid var(--studio-line);
    border-radius: 8px;
    background: color-mix(in oklab, var(--site-bg) 60%, #000);
    color: var(--site-muted);
    font-size: 0.85rem;
}

.studio-theme-row-thumb img { width: 100%; height: 100%; object-fit: contain; }

.studio-theme-row-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.studio-theme-row-copy strong { overflow: hidden; font-size: 0.78rem; text-overflow: ellipsis; white-space: nowrap; }
.studio-theme-row-copy span { overflow: hidden; color: var(--site-muted); font-size: 0.66rem; text-overflow: ellipsis; white-space: nowrap; }

.studio-theme-row-badge {
    flex: 0 0 auto;
    max-width: 38%;
    overflow: hidden;
    color: var(--site-muted);
    font: 600 0.58rem var(--site-font-mono);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.studio-theme-row.has-asset .studio-theme-row-badge { color: var(--site-accent); }
.studio-theme-more { margin-top: 4px; }
.studio-theme-picker-empty { margin: 8px 0 0; color: var(--site-muted); font-size: 0.82rem; }

@media (max-width: 460px), (max-height: 560px) {
    .studio-modal { padding: 10px; }
    .studio-theme-picker-card { padding: 16px 14px 10px; max-height: 92dvh; }
    .studio-theme-picker-card h2 { font-size: 1.1rem; }
    .studio-theme-picker-list { max-height: 58dvh; }
    .studio-theme-row { padding: 6px 7px; }
    .studio-theme-row-badge { max-width: 30%; }
}

/* Reachable only by typing its URL: no locality gate and no in-site link,
   so every feature stays available to whoever opens it. */

/* —— Top bar —— */

.studio-topbar {
    position: relative;
    z-index: 20;
    flex: 0 0 64px;
    height: 64px;
    display: grid;
    grid-template-columns: minmax(140px, 1fr) auto minmax(140px, 1fr);
    align-items: center;
    gap: 16px;
    padding: 0 18px;
    border-bottom: 1px solid var(--studio-line);
    background: color-mix(in oklab, var(--site-bg) 84%, transparent);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
}

.studio-brand {
    justify-self: start;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    color: var(--site-text);
    text-decoration: none;
    border-radius: 9px;
}

.studio-brand:hover {
    color: var(--site-text);
    text-decoration: none;
}

.studio-brand-mark {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    border: 1px solid var(--studio-accent-line);
    border-radius: 10px;
    background: linear-gradient(145deg, var(--studio-accent-soft), transparent);
    color: var(--site-accent);
    font-size: 0.95rem;
}

.studio-brand-copy {
    display: flex;
    flex-direction: column;
    gap: 2px;
    line-height: 1.05;
}

.studio-brand-copy strong {
    font-size: 0.95rem;
    letter-spacing: -0.02em;
}

.studio-brand-copy span {
    color: var(--site-muted);
    font-family: var(--site-font-mono);
    font-size: 0.62rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.studio-modes {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 4px;
    border: 1px solid var(--studio-line);
    border-radius: 12px;
    background: color-mix(in oklab, var(--site-bg-elevated) 72%, transparent);
}

.studio-mode {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 32px;
    padding: 6px 12px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--site-muted);
    font: 600 0.78rem var(--site-font);
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.studio-mode i {
    font-size: 0.76rem;
}

.studio-mode:hover {
    color: var(--site-text);
    background: color-mix(in oklab, var(--site-text) 6%, transparent);
}

.studio-mode.is-active {
    background: var(--site-accent);
    color: #07101d;
    box-shadow: 0 2px 14px color-mix(in oklab, var(--site-accent) 28%, transparent);
}

.studio-top-actions {
    justify-self: end;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.studio-local-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--site-muted);
    font: 600 0.62rem var(--site-font-mono);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
}

.studio-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--lumen-green);
    box-shadow: 0 0 0 3px color-mix(in oklab, var(--lumen-green) 16%, transparent);
}

.studio-gallery-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 32px;
    padding: 6px 10px;
    border: 1px solid var(--studio-line);
    border-radius: 8px;
    color: var(--site-text);
    font-size: 0.76rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.studio-gallery-link:hover {
    border-color: var(--studio-line-strong);
    background: color-mix(in oklab, var(--site-text) 5%, transparent);
    color: var(--site-text);
    text-decoration: none;
}

/* —— Workbench —— */

.studio-main {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 384px;
}

.studio-stage {
    position: relative;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 20px 26px 14px;
    overflow: hidden;
    background:
        radial-gradient(circle at 26% 12%, color-mix(in oklab, var(--site-accent) 11%, transparent), transparent 52%),
        radial-gradient(circle at 82% 86%, color-mix(in oklab, var(--lumen-green) 5%, transparent), transparent 45%),
        var(--site-bg);
}

.studio-stage::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-image: radial-gradient(color-mix(in oklab, var(--site-text) 8%, transparent) 1px, transparent 1px);
    background-size: 24px 24px;
    opacity: 0.45;
    mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.65), transparent 82%);
    -webkit-mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.65), transparent 82%);
}

.studio-stage > * {
    position: relative;
    z-index: 1;
}

/* The head owns the player badge and its explanation. It has to stack above
   the preview below it, or the device shell paints over the open popover. */
.studio-stage > .studio-stage-head {
    z-index: 3;
}

.studio-stage-head {
    flex: 0 0 auto;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
}

.studio-stage-copy {
    min-width: 0;
}

.studio-eyebrow {
    margin: 0;
    color: var(--site-muted);
    font-family: var(--site-font-mono);
    font-size: 0.64rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.studio-breadcrumb {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 7px;
}

.studio-sep {
    opacity: 0.35;
}

.studio-stage h1 {
    margin: 0;
    font-family: var(--site-font-display);
    font-size: clamp(1.75rem, 2.4vw, 2.35rem);
    font-weight: 400;
    line-height: 1.04;
    letter-spacing: -0.032em;
    overflow-wrap: anywhere;
}

#studio-byline {
    display: -webkit-box;
    max-width: 62ch;
    margin: 6px 0 0;
    overflow: hidden;
    color: var(--site-muted);
    font-size: 0.84rem;
    line-height: 1.45;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.studio-stage-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
    flex-shrink: 0;
}

.studio-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 26px;
    padding: 4px 9px;
    border: 1px solid var(--studio-line);
    border-radius: 999px;
    background: color-mix(in oklab, var(--site-bg-elevated) 58%, transparent);
    color: var(--site-text);
    font: 600 0.66rem var(--site-font-mono);
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.studio-chip i {
    color: var(--site-accent);
    font-size: 0.68rem;
}

.studio-chip--muted {
    color: var(--site-muted);
}

.studio-preview-area {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px 0;
    overflow: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--studio-line-strong) transparent;
}

.studio-preview {
    width: min(100%, 568px);
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s ease, filter 0.2s ease;
}

.studio-preview .y1-tp-root {
    height: auto;
    min-height: 0;
}

.studio-preview .y1-tp-device--full {
    max-width: min(500px, 100%);
}

/* The full shell is width-driven, so shrink it on shorter viewports instead
   of letting the click wheel fall below the preview area. */
@media (max-height: 800px) {
    .studio-preview .y1-tp-device--full {
        max-width: min(420px, 100%);
    }
}

@media (max-height: 720px) {
    .studio-preview .y1-tp-device--full {
        max-width: min(390px, 100%);
    }
}

@media (max-height: 640px) {
    .studio-preview .y1-tp-device--full {
        max-width: min(330px, 100%);
    }
}

.studio-preview-area.is-loading .studio-preview {
    opacity: 0.32;
    filter: blur(3px);
}

.studio-preview-loading {
    position: absolute;
    inset: 0;
    z-index: 4;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--site-muted);
    font-size: 0.76rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
}

.studio-preview-area.is-loading .studio-preview-loading {
    opacity: 1;
}

.studio-spinner {
    width: 28px;
    height: 28px;
    border: 2px solid color-mix(in oklab, var(--site-text) 14%, transparent);
    border-top-color: var(--site-accent);
    border-radius: 50%;
    animation: studio-spin 0.8s linear infinite;
}

@keyframes studio-spin {
    to {
        transform: rotate(360deg);
    }
}

/* In flow, not an overlay: an absolutely positioned card contributed no height
   to .studio-preview-area, so the area collapsed to its 0px flex base and the
   card was either clipped by the stage or scrolled out of a 16px strip. */
.studio-empty {
    position: static;
    margin: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.studio-empty-card {
    width: min(100%, 380px);
    padding: 26px;
    border: 1px dashed var(--studio-accent-line);
    border-radius: 16px;
    background: color-mix(in oklab, var(--site-bg-elevated) 74%, transparent);
    text-align: center;
}

.studio-empty-icon {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    margin: 0 auto 12px;
    border: 1px solid var(--studio-line);
    border-radius: 12px;
    color: var(--lumen-amber);
    font-size: 1rem;
}

.studio-empty-card strong {
    display: block;
    font-size: 0.98rem;
}

.studio-empty-card p {
    margin: 7px 0 0;
    color: var(--site-muted);
    font-size: 0.8rem;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.studio-empty-card .studio-eyebrow {
    display: block;
    margin-bottom: 6px;
}

.studio-empty[data-kind='start'] .studio-empty-card {
    width: min(100%, 440px);
    border-style: solid;
    background: color-mix(in oklab, var(--site-bg-elevated) 88%, transparent);
}

.studio-empty[data-kind='start'] .studio-empty-icon {
    color: var(--site-accent);
    border-color: var(--studio-accent-line);
}

.studio-empty-actions {
    display: grid;
    gap: 8px;
    margin-top: 18px;
}

.studio-empty-actions .studio-btn {
    justify-content: center;
    width: 100%;
}

.studio-empty-hint,
.studio-empty-card .studio-empty-hint {
    margin-top: 12px;
}

.studio-stage-foot {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding-top: 6px;
    color: var(--site-muted);
    font: 500 0.68rem var(--site-font-mono);
}

.studio-stage-foot i {
    margin-right: 5px;
    color: var(--site-accent);
}

.studio-foot-sep {
    width: 1px;
    height: 12px;
    background: var(--studio-line);
}

/* —— Inspector —— */

.studio-panel {
    min-height: 0;
    border-left: 1px solid var(--studio-line);
    background: linear-gradient(180deg, var(--studio-panel-bg), color-mix(in oklab, var(--site-bg) 92%, transparent));
}

.studio-panel-scroll {
    height: 100%;
    overflow: auto;
    padding: 20px 20px 34px;
    scrollbar-width: thin;
    scrollbar-color: var(--studio-line-strong) transparent;
}

.studio-panel-scroll::-webkit-scrollbar,
.studio-preview-area::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.studio-panel-scroll::-webkit-scrollbar-thumb,
.studio-preview-area::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: var(--studio-line-strong);
}

.studio-pane {
    animation: studio-pane-in 0.18s ease both;
}

@keyframes studio-pane-in {
    from {
        opacity: 0;
        transform: translateY(4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.studio-pane-head h2 {
    margin: 3px 0 0;
    font-family: var(--site-font-display);
    font-size: 1.72rem;
    font-weight: 400;
    line-height: 1.04;
    letter-spacing: -0.03em;
}

.studio-pane-head > p:last-child {
    margin: 9px 0 0;
    color: var(--site-muted);
    font-size: 0.82rem;
    line-height: 1.52;
}

.studio-source-card,
.studio-package {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    padding: 12px;
    border: 1px solid var(--studio-line);
    border-radius: 13px;
    background: var(--studio-card);
}

.studio-cover {
    position: relative;
    display: grid;
    place-items: center;
    width: 60px;
    height: 60px;
    flex: 0 0 60px;
    overflow: hidden;
    border: 1px solid var(--studio-line);
    border-radius: 10px;
    background: linear-gradient(145deg, var(--studio-accent-soft), color-mix(in oklab, var(--site-bg) 86%, transparent));
}

.studio-cover img {
    position: absolute;
    inset: 0;
    display: none;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.studio-cover.has-image img {
    display: block;
}

.studio-cover.has-image .studio-cover-fallback {
    display: none;
}

.studio-cover-fallback {
    color: var(--site-accent);
    font-size: 1rem;
    opacity: 0.82;
}

.studio-source-copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
    justify-content: center;
}

.studio-source-copy strong {
    font-size: 0.9rem;
    line-height: 1.28;
    overflow-wrap: anywhere;
}

.studio-source-copy > span {
    color: var(--site-muted);
    font-size: 0.74rem;
    line-height: 1.3;
}

.studio-source-desc {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.studio-package {
    padding: 10px;
}

.studio-package .studio-cover {
    width: 44px;
    height: 44px;
    flex-basis: 44px;
    border-radius: 9px;
}

.studio-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 14px;
}

.studio-field label {
    color: var(--site-text);
    font-size: 0.74rem;
    font-weight: 650;
    letter-spacing: 0.01em;
}

.studio-field input,
.studio-field select,
.studio-field textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 9px 11px;
    border: 1px solid var(--studio-line);
    border-radius: 9px;
    outline: none;
    background: color-mix(in oklab, var(--site-bg) 74%, transparent);
    color: var(--site-text);
    font: 500 0.81rem var(--site-font);
    color-scheme: dark;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.studio-field textarea {
    min-height: 72px;
    resize: vertical;
    line-height: 1.45;
}

.studio-field input::placeholder,
.studio-field textarea::placeholder {
    color: var(--site-muted);
    opacity: 0.7;
}

.studio-field input:focus,
.studio-field select:focus,
.studio-field textarea:focus {
    border-color: var(--studio-accent-line);
    box-shadow: 0 0 0 3px var(--studio-accent-soft);
}

.studio-field select {
    padding-right: 30px;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%239aa0b8' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 10px 6px;
}

.studio-field select option {
    background: var(--site-bg-elevated);
    color: var(--site-text);
}

.studio-hint {
    margin: 0;
    color: var(--site-muted);
    font-size: 0.68rem;
    line-height: 1.4;
    opacity: 0.82;
}

.studio-action-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 12px;
}

.studio-action-grid--single {
    grid-template-columns: 1fr;
}

.studio-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 38px;
    padding: 8px 11px;
    border: 1px solid var(--studio-line);
    border-radius: 9px;
    background: color-mix(in oklab, var(--site-text) 4%, transparent);
    color: var(--site-text);
    font: 600 0.78rem var(--site-font);
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease, filter 0.15s ease;
}

.studio-btn i {
    font-size: 0.74rem;
    opacity: 0.9;
}

.studio-btn:hover {
    border-color: var(--studio-line-strong);
    background: color-mix(in oklab, var(--site-text) 8%, transparent);
    color: var(--site-text);
    text-decoration: none;
}

.studio-btn:focus-visible,
.studio-mode:focus-visible,
.studio-brand:focus-visible,
.studio-gallery-link:focus-visible {
    outline: 2px solid var(--site-accent);
    outline-offset: 2px;
}

.studio-btn--primary {
    border-color: var(--studio-accent-line);
    background: var(--studio-accent-wash);
    color: var(--site-text);
}

.studio-btn--primary:hover {
    border-color: var(--site-accent);
    background: var(--studio-accent-wash-strong);
    color: var(--site-text);
    filter: none;
}

.studio-divider {
    height: 1px;
    margin: 20px 0 0;
    background: var(--studio-line);
}

.studio-import {
    margin-top: 16px;
}

.studio-import-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.studio-import p {
    margin: 8px 0 0;
    color: var(--site-muted);
    font-size: 0.78rem;
    line-height: 1.5;
}

.studio-note {
    display: flex;
    gap: 8px;
    margin-top: 18px;
    padding: 10px 11px;
    border: 1px solid var(--studio-line);
    border-radius: 10px;
    background: color-mix(in oklab, var(--site-bg) 46%, transparent);
    color: var(--site-muted);
    font-size: 0.7rem;
    line-height: 1.45;
}

.studio-note i {
    margin-top: 2px;
    color: var(--site-accent);
}

.studio-coming {
    display: flex;
    gap: 12px;
    margin-top: 16px;
    padding: 14px;
    border: 1px solid var(--studio-accent-line);
    border-radius: 13px;
    background: linear-gradient(145deg, var(--studio-accent-soft), color-mix(in oklab, var(--site-bg) 64%, transparent));
}

.studio-coming-icon {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    border: 1px solid var(--studio-accent-line);
    border-radius: 9px;
    color: var(--site-accent);
}

.studio-coming strong {
    display: block;
    font-size: 0.83rem;
    line-height: 1.3;
}

.studio-coming p {
    margin: 5px 0 0;
    color: var(--site-muted);
    font-size: 0.75rem;
    line-height: 1.5;
}

.studio-section {
    margin-top: 19px;
}

.studio-section h3 {
    margin: 0 0 9px;
    color: var(--site-muted);
    font: 600 0.64rem var(--site-font-mono);
    letter-spacing: 0.13em;
    text-transform: uppercase;
}

.studio-tool-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
}

.studio-tool {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 10px;
    border: 1px dashed var(--studio-line);
    border-radius: 9px;
    color: var(--site-muted);
    font-size: 0.75rem;
}

.studio-tool i {
    font-size: 0.72rem;
}

.studio-tool.is-active {
    border-style: solid;
    border-color: var(--studio-accent-line);
    background: var(--studio-accent-soft);
    color: var(--site-text);
}

.studio-palette {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
}

.studio-swatch {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    padding: 7px;
    border: 1px solid var(--studio-line);
    border-radius: 9px;
    background: var(--studio-card);
}

.studio-swatch i {
    width: 24px;
    height: 24px;
    flex: 0 0 24px;
    border: 1px solid color-mix(in oklab, #fff 18%, transparent);
    border-radius: 7px;
    box-shadow: inset 0 0 0 1px color-mix(in oklab, #000 18%, transparent);
}

.studio-swatch span {
    overflow: hidden;
    color: var(--site-muted);
    font-size: 0.66rem;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.studio-kv {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 10px;
    border: 1px solid var(--studio-line);
    border-radius: 9px;
    background: var(--studio-card);
    color: var(--site-muted);
    font-size: 0.73rem;
}

.studio-kv code {
    max-width: 62%;
    overflow: hidden;
    padding: 0;
    background: transparent;
    color: var(--site-text);
    font: 500 0.7rem var(--site-font-mono);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.studio-screen-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.studio-screen {
    padding: 6px 8px;
    border: 1px solid var(--studio-line);
    border-radius: 7px;
    background: var(--studio-card);
    color: var(--site-muted);
    font-size: 0.68rem;
}

.studio-screen strong {
    margin-right: 4px;
    color: var(--site-text);
    font-weight: 600;
}

.studio-pane-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 22px;
    padding-top: 16px;
    border-top: 1px solid var(--studio-line);
}

.studio-checklist {
    display: grid;
    gap: 7px;
    margin: 16px 0 0;
    padding: 0;
    list-style: none;
}

.studio-checklist li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border: 1px solid var(--studio-line);
    border-radius: 10px;
    background: var(--studio-card);
}

.studio-check {
    display: grid;
    place-items: center;
    width: 21px;
    height: 21px;
    flex: 0 0 21px;
    border: 1px solid var(--studio-line-strong);
    border-radius: 50%;
    color: transparent;
    font-size: 0.56rem;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.studio-checklist li[data-state="ok"] .studio-check {
    border-color: color-mix(in oklab, var(--lumen-green) 58%, transparent);
    background: color-mix(in oklab, var(--lumen-green) 20%, transparent);
    color: var(--lumen-green);
}

.studio-checklist li[data-state="pending"] .studio-check {
    border-style: dashed;
    color: transparent;
}

.studio-checklist li > div {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.studio-checklist strong {
    font-size: 0.76rem;
    font-weight: 600;
}

.studio-check-detail {
    color: var(--site-muted);
    font-size: 0.68rem;
    line-height: 1.35;
}

.studio-submit-btn {
    width: 100%;
    margin-top: 16px;
}

.studio-fineprint {
    margin: 16px 0 0;
    color: var(--site-muted);
    font-size: 0.7rem;
    line-height: 1.45;
}

.studio-fineprint a {
    color: var(--site-accent);
    text-decoration: underline;
    text-underline-offset: 0.15em;
}

/* —— Drop target and toast —— */

.studio-drop {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: none;
    place-items: center;
    padding: 24px;
    background: color-mix(in oklab, #05070c 72%, transparent);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}

.studio-drop.is-visible {
    display: grid;
}

.studio-drop-card {
    width: min(100%, 460px);
    padding: 34px 28px;
    border: 2px dashed var(--studio-accent-line);
    border-radius: 20px;
    background: color-mix(in oklab, var(--site-bg-elevated) 88%, transparent);
    text-align: center;
    box-shadow: var(--lumen-shadow);
}

.studio-drop-icon {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    margin: 0 auto 14px;
    border: 1px solid var(--studio-accent-line);
    border-radius: 14px;
    background: var(--studio-accent-soft);
    color: var(--site-accent);
    font-size: 1.15rem;
}

.studio-drop-card strong {
    display: block;
    font-family: var(--site-font-display);
    font-size: 1.55rem;
    font-weight: 400;
    letter-spacing: -0.02em;
}

.studio-drop-card > span:last-child {
    display: block;
    margin-top: 6px;
    color: var(--site-muted);
    font-size: 0.78rem;
}

.studio-toast {
    position: fixed;
    left: 50%;
    bottom: 22px;
    z-index: 250;
    width: max-content;
    max-width: min(92vw, 560px);
    padding: 10px 14px;
    border: 1px solid var(--studio-line-strong);
    border-radius: 10px;
    background: color-mix(in oklab, var(--site-bg-elevated) 94%, transparent);
    box-shadow: var(--lumen-shadow);
    color: var(--site-text);
    font-size: 0.77rem;
    line-height: 1.4;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 10px);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.studio-toast.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* —— Responsive —— */

@media (max-width: 1080px) {
    .studio-main {
        grid-template-columns: minmax(0, 1fr) 350px;
    }

    .studio-stage {
        padding-inline: 20px;
    }
}

@media (max-width: 940px) {
    html,
    body.studio-app {
        height: auto;
        min-height: 100%;
        overflow: auto;
    }

    .studio-app,
    .studio-shell {
        height: auto;
        min-height: 100dvh;
    }

    .studio-topbar {
        grid-template-columns: minmax(0, 1fr) auto;
        height: auto;
        flex-basis: auto;
        padding: 10px 14px;
        row-gap: 10px;
    }

    .studio-modes {
        grid-column: 1 / -1;
        grid-row: 2;
        justify-self: center;
    }

    .studio-main {
        grid-template-columns: 1fr;
    }

    .studio-stage {
        min-height: 660px;
        overflow: visible;
    }

    .studio-panel {
        border-top: 1px solid var(--studio-line);
        border-left: 0;
    }

    .studio-panel-scroll {
        height: auto;
        overflow: visible;
    }
}

@media (max-width: 620px) {
    .studio-brand-copy span,
    .studio-local-badge {
        display: none;
    }

    .studio-top-actions {
        gap: 8px;
    }

    .studio-gallery-link span {
        display: none;
    }

    .studio-gallery-link {
        width: 32px;
        padding: 0;
        justify-content: center;
    }

    .studio-mode {
        padding: 6px 10px;
    }

    .studio-stage {
        min-height: 560px;
        padding: 16px 14px 12px;
    }

    .studio-stage-head {
        flex-direction: column;
        gap: 10px;
    }

    .studio-stage-meta {
        justify-content: flex-start;
    }

    .studio-stage-foot {
        display: none;
    }

    .studio-preview {
        height: auto;
        min-height: 420px;
    }

    .studio-action-grid,
    .studio-pane-actions {
        grid-template-columns: 1fr;
    }

    .studio-panel-scroll {
        padding: 18px 14px 30px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .studio-pane,
    .studio-toast,
    .studio-preview,
    .studio-preview-loading,
    .studio-mode,
    .studio-btn,
    .studio-check {
        animation: none !important;
        transition: none !important;
    }

    .studio-spinner {
        animation-duration: 1.6s;
    }
}

/* ==========================================================================
   Production Studio chrome
   The shared site header stays at the top. Studio is a normal document that
   scrolls, with one sticky command bar and a compact preview that does not
   own the viewport.
   ========================================================================== */

html,
body.studio-app {
    height: auto;
    min-height: 100%;
    overflow-x: hidden;
}

body.studio-app {
    background: var(--site-bg);
    color: var(--site-text);
}

.studio-app .studio-shell {
    height: auto;
    min-height: 100dvh;
    display: block;
}

.studio-app .studio-commandbar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    padding: 10px clamp(14px, 2.4vw, 28px);
    border-bottom: 1px solid var(--studio-line);
    background: color-mix(in oklab, var(--site-bg) 92%, transparent);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
}

.studio-command-copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.studio-command-context {
    overflow: hidden;
    color: var(--site-muted);
    font-size: 0.72rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.studio-command-actions {
    justify-self: end;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.studio-asset-warm {
    margin: 0 0 12px;
    padding: 10px 12px;
    border: 1px solid var(--studio-line);
    border-radius: 10px;
    background: color-mix(in oklab, var(--site-text) 4%, transparent);
}

.studio-asset-warm[hidden] {
    display: none;
}

.studio-asset-warm__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 7px;
    font-size: 0.78rem;
    color: var(--studio-muted);
}

.studio-asset-warm__head strong {
    font-size: 0.76rem;
    font-variant-numeric: tabular-nums;
    color: var(--site-text);
}

.studio-asset-warm progress {
    display: block;
    width: 100%;
    height: 6px;
    border: 0;
    border-radius: 999px;
    overflow: hidden;
    background: color-mix(in oklab, var(--site-text) 10%, transparent);
    appearance: none;
    -webkit-appearance: none;
}

.studio-asset-warm progress::-webkit-progress-bar {
    background: color-mix(in oklab, var(--site-text) 10%, transparent);
}

.studio-asset-warm progress::-webkit-progress-value {
    background: var(--site-accent);
}

.studio-asset-warm progress::-moz-progress-bar {
    background: var(--site-accent);
}

.studio-commandbar .studio-modes {
    justify-self: center;
}

.studio-commandbar .studio-mode.is-active {
    color: var(--lumen-on-accent, #07101d);
}

.studio-btn--save {
    min-height: 38px;
    white-space: nowrap;
}

.studio-unsaved {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--lumen-amber, #e8a23a);
    font: 600 0.68rem var(--site-font-mono);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
}

.studio-unsaved i {
    font-size: 0.42rem;
}

.studio-save-progress {
    position: fixed;
    left: 50%;
    bottom: calc(18px + env(safe-area-inset-bottom, 0px));
    z-index: 120;
    width: min(420px, calc(100vw - 32px));
    display: grid;
    gap: 9px;
    padding: 12px 14px 13px;
    border: 1px solid var(--studio-line);
    border-radius: 14px;
    background: color-mix(in oklab, var(--site-bg) 94%, transparent);
    color: var(--site-text);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
    transform: translateX(-50%);
}

.studio-save-progress[hidden] {
    display: none;
}

.studio-save-progress-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    min-width: 0;
    font-size: 0.76rem;
    font-weight: 650;
}

.studio-save-progress-head span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.studio-save-progress-head strong {
    color: var(--site-accent);
    font: 650 0.72rem var(--site-font-mono);
    white-space: nowrap;
}

.studio-save-progress progress {
    width: 100%;
    height: 8px;
    display: block;
    overflow: hidden;
    border: 0;
    border-radius: 999px;
    background: var(--studio-line);
    appearance: none;
    -webkit-appearance: none;
}

.studio-save-progress progress::-webkit-progress-bar {
    border-radius: 999px;
    background: var(--studio-line);
}

.studio-save-progress progress::-webkit-progress-value {
    border-radius: 999px;
    background: var(--site-accent);
    transition: width 160ms ease;
}

.studio-save-progress progress::-moz-progress-bar {
    border-radius: 999px;
    background: var(--site-accent);
}

@media (max-width: 700px) {
    .studio-save-progress {
        bottom: calc(10px + env(safe-area-inset-bottom, 0px));
        width: calc(100vw - 20px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .studio-save-progress progress::-webkit-progress-value {
        transition: none;
    }
}

/* The stage only ever holds a 330px player, so the leftover width belongs to
   the inspector: the asset trays, colour groups and listing form all read
   better with room, and the fixed 400px cap used to squeeze names to an
   ellipsis while the stage sat half empty. */
.studio-app .studio-main {
    width: min(100%, 1760px);
    margin: 0 auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) clamp(440px, 36vw, 620px);
    align-items: start;
    min-height: 0;
}

.studio-app .studio-stage {
    position: sticky;
    top: 62px;
    max-height: calc(100dvh - 74px);
    min-height: 0;
    overflow: auto;
    padding: 18px clamp(14px, 2vw, 26px) 14px;
    scrollbar-width: thin;
}

.studio-stage h1 {
    font-size: clamp(1.45rem, 2.2vw, 2rem);
}

.studio-app .studio-preview-area {
    flex: 0 1 auto;
    min-height: 0;
    max-height: min(57vh, 520px);
    padding: 8px 0;
}

.studio-app .studio-preview {
    width: 100%;
    height: auto;
    min-height: 0;
}

.studio-app .studio-preview .y1-tp-root {
    height: auto;
    min-height: 0;
}

.studio-app .studio-preview .y1-tp-device--full {
    width: min(100%, 330px);
    max-width: min(330px, 100%);
    padding: 11px 12px 12px;
    border-radius: 22px;
    gap: 8px;
}

.studio-app .studio-preview .y1-tp-device--full .y1-tp-clickwheel {
    width: 112px;
    height: 112px;
}

.studio-app .studio-preview .y1-tp-device--full .y1-tp-cw--center {
    width: 44px;
    height: 44px;
}

.studio-app .studio-preview .y1-tp-device--full .y1-tp-cw--menu {
    top: 7px;
    font-size: 8px;
}

.studio-app .studio-preview .y1-tp-device--full .y1-tp-cw--prev { left: 6px; }
.studio-app .studio-preview .y1-tp-device--full .y1-tp-cw--next { right: 6px; }
.studio-app .studio-preview .y1-tp-device--full .y1-tp-cw--play { bottom: 8px; }

.studio-app .studio-panel {
    min-width: 0;
    min-height: calc(100dvh - 62px);
    border-left: 1px solid var(--studio-line);
    background: var(--studio-panel-bg);
}

.studio-app .studio-panel-scroll {
    height: auto;
    overflow: visible;
    padding: clamp(16px, 2vw, 24px) clamp(14px, 2vw, 22px) 56px;
}

.studio-swap-btn {
    width: 100%;
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
    border: 1px solid var(--studio-line);
    border-radius: 10px;
    background: var(--studio-card);
    color: var(--site-text);
    font: 600 0.8rem var(--site-font);
    cursor: pointer;
}

.studio-swap-btn:hover {
    border-color: var(--studio-accent-line);
    color: var(--site-accent);
}

.studio-swap-panel {
    display: block;
}

.studio-import {
    margin-top: 14px;
}

.studio-source-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 10px;
}

.studio-origin-card {
    margin: 0 0 14px;
    padding: 12px;
    border: 1px solid var(--studio-accent-line);
    border-radius: 11px;
    background: var(--studio-accent-soft);
}

.studio-origin-card strong {
    display: block;
    margin: 3px 0 4px;
    font-size: 0.86rem;
}

.studio-origin-card p {
    margin: 0 0 7px;
    color: var(--site-muted);
    font-size: 0.78rem;
    line-height: 1.45;
}

.studio-origin-card a {
    color: var(--site-accent);
    font-size: 0.76rem;
    font-weight: 700;
}

.studio-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.studio-inline-check {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    margin: 2px 0 14px;
    color: var(--site-muted);
    font-size: 0.78rem;
    line-height: 1.42;
}

.studio-inline-check input {
    margin-top: 3px;
    accent-color: var(--site-accent);
}

.studio-required,
.studio-optional {
    margin-left: 5px;
    color: var(--site-muted);
    font: 500 0.62rem var(--site-font-mono);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.studio-update-notice,
.studio-policy-banner {
    margin: 0 0 14px;
    padding: 11px 12px;
    border: 1px solid var(--studio-accent-line);
    border-radius: 10px;
    background: var(--studio-accent-soft);
    color: var(--site-text);
    font-size: 0.78rem;
    line-height: 1.45;
}

.studio-update-notice strong,
.studio-policy-banner strong {
    display: block;
    margin-bottom: 4px;
}

.studio-update-notice p {
    margin: 0 0 8px;
    color: var(--site-muted);
}

.studio-policy-banner.is-block {
    border-color: color-mix(in oklab, var(--lumen-red, #e55) 48%, transparent);
    background: color-mix(in oklab, var(--lumen-red, #e55) 12%, transparent);
}

.studio-submit-status {
    margin-top: 12px;
    font-size: 0.8rem;
    line-height: 1.45;
}

.studio-submit-status.is-ok { color: var(--lumen-green, #57b87a); }
.studio-submit-status.is-error { color: var(--lumen-red, #e55); }
.studio-submit-status a { margin-left: 7px; color: var(--site-accent); font-weight: 700; }

/* —— Bounded asset list —— */

.studio-asset-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: 14px 0 10px;
}

.studio-asset-filters,
.studio-asset-tools {
    display: flex;
    align-items: center;
    gap: 4px;
}

.studio-asset-filter {
    min-height: 32px;
    padding: 5px 8px;
    border: 1px solid transparent;
    border-radius: 7px;
    background: transparent;
    color: var(--site-muted);
    font: 600 0.68rem var(--site-font);
    cursor: pointer;
}

.studio-asset-filter span { margin-left: 3px; font-family: var(--site-font-mono); }
.studio-asset-filter:hover { color: var(--site-text); }
.studio-asset-filter.is-active { border-color: var(--studio-line); background: var(--studio-card); color: var(--site-text); }

.studio-mini-btn {
    min-height: 32px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 8px;
    border: 1px solid var(--studio-line);
    border-radius: 7px;
    background: var(--studio-card);
    color: var(--site-text);
    font: 600 0.68rem var(--site-font);
    cursor: pointer;
}

.studio-mini-btn:hover { border-color: var(--studio-line-strong); }

.studio-asset-list {
    max-height: clamp(292px, 43vh, 430px);
    overflow: auto;
    overscroll-behavior: contain;
    border: 1px solid var(--studio-line);
    border-radius: 11px;
    background: var(--studio-card);
    scrollbar-width: thin;
    scrollbar-color: var(--studio-line-strong) transparent;
}

.studio-asset-row {
    position: relative;
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 8px;
    min-height: 58px;
    padding: 7px 8px;
    border-bottom: 1px solid var(--studio-line);
    cursor: pointer;
    outline: none;
    scroll-margin-block: 42px;
    transition: background 0.14s ease, box-shadow 0.14s ease;
}

.studio-asset-row:last-child { border-bottom: 0; }
.studio-asset-row:hover,
.studio-asset-row.is-hovered { background: color-mix(in oklab, var(--site-accent) 8%, transparent); }
.studio-asset-row.is-selected { background: var(--studio-accent-soft); box-shadow: inset 3px 0 0 var(--site-accent); }
.studio-asset-row:focus-visible { box-shadow: inset 0 0 0 2px var(--site-accent); }
.studio-asset-row.is-missing .studio-asset-badge { color: var(--lumen-red, #e55); }
.studio-asset-row.is-preview-linked {
    outline: 2px dashed var(--site-accent);
    outline-offset: -3px;
    background: color-mix(in oklab, var(--site-accent) 13%, transparent);
}

/* Assets that belong to the row the reader just picked in the preview. */

.studio-related {
    margin: 6px 4px 10px;
    padding: 6px;
    border: 1px solid var(--studio-accent-line);
    border-radius: 12px;
    background: color-mix(in oklab, var(--site-accent) 7%, transparent);
}

.studio-related-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 2px 4px;
    color: var(--site-muted);
    font-family: var(--site-font-mono);
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.studio-related-count {
    margin-left: auto;
    font-weight: 500;
    letter-spacing: 0.04em;
}

.studio-related-close {
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    padding: 0;
    border: 1px solid var(--studio-line);
    border-radius: 7px;
    background: transparent;
    color: var(--site-muted);
    font-size: 0.7rem;
    cursor: pointer;
}

.studio-related-close:hover {
    color: var(--site-text);
    border-color: var(--studio-line-strong);
}

.studio-related .studio-asset-row {
    min-height: 52px;
    padding-inline: 6px;
    border-bottom: 0;
    border-radius: 9px;
}

.studio-related-sub {
    margin: 14px 10px 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    opacity: 0.62;
}

.studio-related .studio-color-row {
    margin: 0 10px 6px;
    padding: 4px 6px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
}

.studio-related .studio-color-row code {
    display: none;
}

.studio-related .studio-asset-row.is-selected {
    box-shadow: inset 3px 0 0 var(--site-accent);
}

.studio-preview [data-theme-asset-path] {
    cursor: pointer;
    transition: box-shadow 0.14s ease, filter 0.14s ease;
}

.studio-preview [data-theme-asset-path].is-studio-linked {
    outline: 2px solid var(--site-accent);
    outline-offset: 2px;
    box-shadow: inset 0 0 0 2px var(--site-accent);
    filter: brightness(1.06) saturate(1.08);
}

@media (prefers-reduced-motion: reduce) {
    .studio-preview [data-theme-asset-path] { transition: none; }
}

.studio-asset-thumb {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    overflow: hidden;
    border: 1px solid var(--studio-line);
    border-radius: 7px;
    background: var(--site-bg);
    color: var(--site-muted);
}

.studio-asset-thumb img { width: 100%; height: 100%; object-fit: cover; }

/* Font rows show the face, not a generic glyph: Aa is short enough to read at
   tray size and different enough between typefaces to choose by eye. */
.studio-font-thumb-sample {
    font-size: 1.2rem;
    font-weight: 600;
    line-height: 1;
    letter-spacing: 0.01em;
    color: var(--site-text);
}

.studio-font-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    color: var(--site-text);
    text-align: center;
}

.studio-font-preview-glyph {
    font-size: clamp(3.5rem, 5.2vw, 5rem);
    line-height: 1;
}

.studio-font-preview-line {
    color: var(--site-muted);
    font-size: 0.95rem;
    line-height: 1.2;
    letter-spacing: 0.02em;
}

.studio-asset-row-copy { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.studio-asset-row-copy strong { overflow: hidden; font-size: 0.78rem; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
.studio-asset-row-copy > span { overflow: hidden; color: var(--site-muted); font: 500 0.64rem var(--site-font-mono); text-overflow: ellipsis; white-space: nowrap; }

.studio-asset-row-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; min-width: 58px; }
.studio-asset-row-meta > span:first-child { max-width: 116px; overflow: hidden; color: var(--site-muted); font-size: 0.6rem; text-overflow: ellipsis; white-space: nowrap; }
.studio-asset-badge { color: var(--site-muted); font: 600 0.56rem var(--site-font-mono); letter-spacing: 0.04em; text-transform: uppercase; }
.studio-asset-row.is-changed .studio-asset-badge { color: var(--site-accent); }

.studio-asset-row-actions { display: flex; align-items: center; gap: 3px; }
.studio-asset-row-action {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border: 1px solid var(--studio-line);
    border-radius: 8px;
    background: var(--site-bg);
    color: var(--site-muted);
    cursor: pointer;
}
.studio-asset-row-action:hover { border-color: var(--site-accent); color: var(--site-accent); }
.studio-asset-row-action:focus-visible { outline: 2px solid var(--site-accent); outline-offset: 1px; }

.studio-asset-empty { margin: 12px 0; color: var(--site-muted); font-size: 0.8rem; line-height: 1.45; }

.studio-asset-group { border-bottom: 1px solid var(--studio-line); }
.studio-asset-group:last-child { border-bottom: 0; }

.studio-asset-group-head {
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    color: var(--site-muted);
    font: 600 0.66rem var(--site-font-mono);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    list-style: none;
    background: color-mix(in oklab, var(--site-bg) 34%, transparent);
}

.studio-asset-group-head::-webkit-details-marker { display: none; }
.studio-asset-group-head::before {
    content: '\25B8';
    margin-right: 6px;
    color: var(--site-accent);
    transition: transform 0.14s ease;
}
.studio-asset-group[open] > .studio-asset-group-head::before { transform: rotate(90deg); }
.studio-asset-group-head > span:first-child { flex: 1; }
.studio-asset-group-count {
    min-width: 22px;
    padding: 2px 6px;
    border: 1px solid var(--studio-line);
    border-radius: 999px;
    color: var(--site-muted);
    font: 600 0.6rem var(--site-font-mono);
    text-align: center;
}

.studio-asset-group-body .studio-asset-row:last-child { border-bottom: 0; }

.studio-color-editor {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--studio-line);
}

.studio-color-editor[hidden] { display: none; }
.studio-color-editor-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}
.studio-color-editor-head .studio-eyebrow { margin: 0; }
.studio-color-editor-head > span { color: var(--site-muted); font: 600 0.6rem var(--site-font-mono); }

.studio-color-group {
    overflow: hidden;
    margin-bottom: 7px;
    border: 1px solid var(--studio-line);
    border-radius: 9px;
    background: var(--studio-card);
}
.studio-color-group > summary {
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 7px 9px;
    color: var(--site-muted);
    font: 600 0.66rem var(--site-font-mono);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
    list-style: none;
}
.studio-color-group > summary::-webkit-details-marker { display: none; }
.studio-color-group > summary::before {
    content: '\25B8';
    margin-right: 5px;
    color: var(--site-accent);
    transition: transform 0.14s ease;
}
.studio-color-group[open] > summary::before { transform: rotate(90deg); }
.studio-color-group > summary > span:first-of-type { flex: 1; }

.studio-color-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 44px minmax(86px, 108px);
    align-items: center;
    gap: 6px;
    padding: 6px 9px;
    border-top: 1px solid var(--studio-line);
}
.studio-color-copy { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.studio-color-copy label { overflow: hidden; color: var(--site-text); font-size: 0.72rem; text-overflow: ellipsis; white-space: nowrap; }
.studio-color-copy code { overflow: hidden; color: var(--site-muted); font-size: 0.56rem; text-overflow: ellipsis; white-space: nowrap; }
.studio-color-row input[type="color"] {
    width: 44px;
    height: 36px;
    padding: 3px;
    border: 1px solid var(--studio-line);
    border-radius: 7px;
    background: var(--site-bg);
    cursor: pointer;
}
.studio-color-value {
    width: 100%;
    min-height: 36px;
    padding: 5px 7px;
    border: 1px solid var(--studio-line);
    border-radius: 7px;
    background: var(--site-bg);
    color: var(--site-text);
    font: 500 0.68rem var(--site-font-mono);
}
.studio-color-value:focus { border-color: var(--site-accent); outline: none; box-shadow: 0 0 0 2px var(--studio-accent-soft); }

.studio-asset-detail {
    margin-top: 12px;
    padding: 12px;
    border: 1px solid var(--studio-line);
    border-radius: 11px;
    background: var(--studio-card);
}

.studio-asset-detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.studio-asset-detail-copy { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.studio-asset-detail-copy strong { font-size: 0.88rem; }
.studio-asset-detail-copy code { overflow: hidden; color: var(--site-muted); font-size: 0.62rem; text-overflow: ellipsis; white-space: nowrap; }
.studio-asset-status { flex: 0 0 auto; color: var(--site-muted); font: 600 0.6rem var(--site-font-mono); letter-spacing: 0.05em; text-transform: uppercase; }
.studio-asset-status[data-state="changed"] { color: var(--site-accent); }
.studio-asset-status[data-state="missing"] { color: var(--lumen-red, #e55); }

/* The detail plate is a 4:3 window onto the live screen, not a full-width
   banner: a 64px status icon on a 1300px plate read as an empty box. */
.studio-asset-detail-preview {
    position: relative;
    width: min(100%, 400px);
    aspect-ratio: 4 / 3;
    min-height: 0;
    max-height: none;
    display: grid;
    place-items: center;
    margin: 10px auto;
    overflow: hidden;
    border: 1px solid var(--studio-line);
    border-radius: 8px;
    background: var(--site-bg);
    color: var(--site-muted);
    font-size: 2rem;
}
.studio-asset-detail-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.studio-asset-detail-preview > img.is-fit-plate { width: 100%; height: 100%; object-fit: contain; object-position: center; }

/* —— Preview heading switcher —— */

.studio-asset-title-row {
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
}

.studio-asset-title-row strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.studio-mask-title {
    display: flex;
    align-items: center;
    gap: 3px;
    min-width: 0;
}

.studio-mask-title strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.studio-asset-switch-toggle {
    flex: 0 0 auto;
    width: 24px;
    height: 24px;
    display: inline-grid;
    place-items: center;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--site-muted);
    font-size: 0.64rem;
    cursor: pointer;
}

.studio-mask-title .studio-asset-switch-toggle { width: 20px; height: 20px; font-size: 0.56rem; }

.studio-asset-switch-toggle:hover,
.studio-asset-switch-toggle[aria-expanded="true"] {
    border-color: var(--studio-line);
    background: var(--studio-accent-soft);
    color: var(--site-accent);
}

.studio-asset-switch-toggle:focus-visible { outline: 2px solid var(--site-accent); outline-offset: 1px; }

.studio-asset-switch-menu {
    position: fixed;
    z-index: 5000;
    width: min(300px, calc(100vw - 16px));
    max-height: min(56vh, 340px);
    overflow: auto;
    padding: 6px;
    border: 1px solid var(--studio-line);
    border-radius: 10px;
    background: var(--studio-card, var(--site-bg));
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.48);
}

.studio-asset-switch-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--site-text);
    text-align: left;
    cursor: pointer;
}

.studio-asset-switch-item:hover,
.studio-asset-switch-item:focus-visible { background: var(--studio-accent-soft); outline: none; }
.studio-asset-switch-item.is-current { background: var(--studio-accent-soft); }

.studio-asset-switch-thumb {
    flex: 0 0 32px;
    width: 32px;
    height: 24px;
    display: grid;
    place-items: center;
    overflow: hidden;
    border: 1px solid var(--studio-line);
    border-radius: 5px;
    background: #05070c;
    color: var(--site-muted);
}

.studio-asset-switch-thumb img { width: 100%; height: 100%; object-fit: contain; }

.studio-asset-switch-copy { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.studio-asset-switch-copy strong { font-size: 0.72rem; line-height: 1.2; }
.studio-asset-switch-copy span { overflow: hidden; color: var(--site-muted); font: 500 0.6rem var(--site-font-mono); text-overflow: ellipsis; white-space: nowrap; }
.studio-asset-switch-check { margin-left: auto; flex: 0 0 auto; color: var(--site-accent); font-size: 0.66rem; }

/* A live crop is a clone of the mounted screen, scaled around the asset. */
.studio-asset-detail-preview.has-live-crop { background: #05070c; }
.studio-live-crop * { animation: none !important; transition: none !important; }
.has-live-crop > img:not(.studio-thumb-layer) { display: none; }
.studio-asset-detail-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.studio-asset-detail-actions .studio-btn { flex: 1 1 96px; min-height: 38px; padding: 7px 8px; font-size: 0.72rem; }
.studio-asset-detail-actions .studio-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* —— Future ad reservations. Hidden until a publisher places them. —— */
.studio-ad-slots { display: none; }
.studio-ad-slot { min-height: 0; }
.studio-ad-slot[data-ad-size="300x250"] { min-height: 250px; }
.studio-ad-slot[data-ad-size="300x600"] { min-height: 600px; }
.studio-ad-slot[data-ad-size="320x50"] { min-height: 50px; }
.studio-ad-slot[data-ad-size="728x90"] { min-height: 90px; }
.studio-ad-slot[data-ad-size="970x250"] { min-height: 250px; }
.studio-ad-slot[data-ad-size="970x90"] { min-height: 90px; }

/* —— Narrow and novel displays —— */
@media (max-width: 1040px) {
    .studio-commandbar { grid-template-columns: minmax(0, 1fr) auto; }
    .studio-commandbar .studio-modes { grid-column: 1 / -1; grid-row: 2; justify-self: stretch; }
    .studio-commandbar .studio-mode { flex: 1; }
    .studio-app .studio-main { grid-template-columns: 1fr; }
    .studio-app .studio-stage { position: relative; top: auto; max-height: none; overflow: visible; }
    .studio-app .studio-panel { min-height: 0; border-top: 1px solid var(--studio-line); border-left: 0; }
    .studio-app .studio-preview-area { max-height: none; }
    .studio-app .studio-preview .y1-tp-device--full { width: min(100%, 310px); }
}

@media (max-width: 700px) {
    .studio-commandbar { gap: 8px; padding: 8px 12px; }
    .studio-command-copy { display: none; }
    .studio-commandbar { grid-template-columns: minmax(0, 1fr); }
    .studio-commandbar .studio-modes { grid-row: 1; }
    .studio-command-actions { grid-row: 2; justify-self: stretch; }
    .studio-command-actions .studio-btn { flex: 1; justify-content: center; }
    .studio-command-actions .studio-unsaved { flex: 1 0 100%; justify-content: flex-end; }
    .studio-btn--save span { display: inline; }
    .studio-stage { padding: 14px 12px 10px; }
    .studio-stage-head { gap: 8px; }
    .studio-app .studio-preview .y1-tp-device--full { width: min(100%, 286px); padding: 9px 10px 10px; }
    .studio-app .studio-preview .y1-tp-device--full .y1-tp-clickwheel { width: 96px; height: 96px; }
    .studio-app .studio-preview .y1-tp-device--full .y1-tp-cw--center { width: 38px; height: 38px; }
    .studio-form-grid { grid-template-columns: 1fr; }
    .studio-panel-scroll { padding: 16px 13px 44px; }
    .studio-asset-list { max-height: min(46vh, 360px); }
    .studio-asset-row { grid-template-columns: 38px minmax(0, 1fr) auto; }
    .studio-asset-row-meta { display: none; }
    .studio-asset-row-action { width: 38px; height: 38px; }
    .studio-asset-detail-actions .studio-btn { flex: 1 1 46%; }
    .studio-mini-btn { min-height: 38px; }
    .studio-action-grid, .studio-pane-actions { grid-template-columns: 1fr; }
    .studio-submit-btn { min-height: 46px; }
}

@media (max-width: 420px), (max-height: 560px) {
    .studio-commandbar .studio-mode span { font-size: 0.7rem; }
    .studio-commandbar .studio-mode { padding: 7px 6px; }
    .studio-btn--save span { max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
    .studio-app .studio-preview .y1-tp-device--full { width: min(100%, 250px); }
    .studio-app .studio-preview .y1-tp-device--full .y1-tp-clickwheel { width: 86px; height: 86px; }
    .studio-stage-foot { display: none; }
    .studio-asset-row { grid-template-columns: 34px minmax(0, 1fr) auto; gap: 6px; padding: 6px; }
    .studio-asset-thumb { width: 34px; height: 34px; }
    .studio-asset-row-action { width: 34px; height: 34px; }
}

/* Square and passport foldables: the preview must not become the whole page. */
@media (max-width: 520px) and (min-height: 700px) {
    .studio-app .studio-preview-area { max-height: 52vh; }
}

@media (hover: none) {
    .studio-asset-row-actions { opacity: 1; }
    .studio-asset-row:hover { background: transparent; }
    .studio-asset-row.is-selected { background: var(--studio-accent-soft); }
}

/* —— Compact workbench: phones, foldables, square and watch screens ——
   Below 760px the workbench stops being two columns inside one long page. The
   shell holds exactly one screenful, the mode tabs switch between the player
   surface and the inspector surface, and the command bar collapses to a single
   row so the surface that matters keeps the height. Selectors are anchored on
   body.studio-app so they beat the site and base rules they replace. */

@media (max-width: 760px) {
    html,
    body.studio-app {
        height: 100%;
        min-height: 0;
        overflow: hidden;
    }

    body.studio-app {
        height: 100vh;
        height: 100dvh;
        min-height: 0;
        overflow: hidden;
    }

    /* The workbench owns the whole screen here; the site chrome would only cost
       height the player and the tray need. */
    body.studio-app #nav-root,
    body.studio-app #footer-root,
    body.studio-app #support-toolbar-slot {
        display: none !important;
    }

    body.studio-app .studio-shell {
        display: flex;
        flex-direction: column;
        height: 100%;
        min-height: 0;
        overflow: hidden;
    }

    body.studio-app .studio-commandbar {
        position: relative;
        top: auto;
        display: flex;
        flex-wrap: nowrap;
        align-items: center;
        gap: 6px;
        padding: calc(6px + env(safe-area-inset-top)) 8px 6px;
        flex: 0 0 auto;
    }

    body.studio-app .studio-commandbar .studio-command-copy,
    body.studio-app .studio-commandbar .studio-unsaved {
        display: none;
    }

    body.studio-app .studio-commandbar .studio-modes {
        flex: 1 1 auto;
        min-width: 0;
        grid-column: auto;
        grid-row: auto;
        justify-self: stretch;
        padding: 3px;
    }

    body.studio-app .studio-commandbar .studio-mode {
        flex: 1 1 0;
        min-width: 0;
        min-height: 36px;
        padding: 5px 4px;
        gap: 5px;
        font-size: 0.72rem;
    }

    body.studio-app .studio-command-actions {
        flex: 0 0 auto;
        grid-row: auto;
        justify-self: auto;
    }

    body.studio-app .studio-command-actions .studio-btn {
        flex: 0 0 auto;
    }

    body.studio-app .studio-btn--save {
        width: 40px;
        min-height: 36px;
        padding: 0;
        justify-content: center;
    }

    body.studio-app .studio-btn--save span {
        display: none;
    }

    body.studio-app .studio-main {
        position: relative;
        display: block;
        flex: 1 1 auto;
        min-height: 0;
        overflow: hidden;
    }

    body.studio-app .studio-stage {
        position: absolute;
        inset: 0;
        height: auto;
        max-height: none;
        padding: 6px 8px 2px;
        overflow: hidden;
    }

    body.studio-app .studio-panel {
        position: absolute;
        inset: 0;
        display: flex;
        flex-direction: column;
        border: 0;
    }

    body.studio-app[data-mode='edit'] .studio-stage,
    body.studio-app[data-mode='submit'] .studio-stage {
        display: none;
    }

    body.studio-app[data-mode='preview'] .studio-panel {
        display: none;
    }

    body.studio-app .studio-panel-scroll {
        flex: 1 1 auto;
        height: auto;
        min-height: 0;
        overflow: auto;
        padding: 10px 10px calc(18px + env(safe-area-inset-bottom));
        -webkit-overflow-scrolling: touch;
    }

    body.studio-app .studio-stage-head {
        flex-direction: column;
        gap: 2px;
    }

    body.studio-app #studio-title {
        font-size: 1rem;
    }

    body.studio-app .studio-stage-meta,
    body.studio-app .studio-stage-foot {
        display: none;
    }

    body.studio-app .studio-preview-area {
        max-height: none;
        padding: 0;
    }

    body.studio-app .studio-preview {
        width: 100%;
        height: 100%;
    }

    /* Height-driven as well as width-driven: the device keeps its aspect, so
       the whole shell (screen plus wheel) fits whatever height is left after
       the command bar, from a 200px watch to a tall foldable. */
    body.studio-app .studio-preview .y1-tp-device--full {
        width: min(100%, 320px, calc((100dvh - 56px) / 1.2));
    }

    /* The filter chips plus Font/Reset do not fit side by side on a watch, so
       the toolbar wraps instead of pushing the Reset button past the panel
       edge (which used to give the tray a 62px horizontal scroll at 200px). */
    body.studio-app .studio-asset-toolbar {
        flex-wrap: wrap;
        row-gap: 8px;
    }

    body.studio-app .studio-asset-filters {
        min-width: 0;
        flex-wrap: wrap;
    }

    body.studio-app .studio-asset-tools {
        flex: 0 0 auto;
        margin-left: auto;
    }
}

/* Square screens, small foldable covers and watches: every non-essential
   caption goes, and the player shell shrinks far enough to leave the wheel and
   the tray rows reachable. */
@media (max-width: 380px), (max-height: 420px) {
    body.studio-app .studio-commandbar .studio-mode {
        min-height: 32px;
        padding: 4px 3px;
        gap: 4px;
        font-size: 0.64rem;
    }

    body.studio-app .studio-btn--save {
        width: 34px;
        min-height: 32px;
    }

    body.studio-app .studio-stage-head {
        display: none;
    }

    body.studio-app .studio-preview .y1-tp-device--full {
        padding: 6px 7px 8px;
        border-radius: 18px;
    }

    body.studio-app .studio-preview .y1-tp-device--full .y1-tp-clickwheel {
        width: 72px;
        height: 72px;
    }

    body.studio-app .studio-asset-row {
        min-height: 46px;
    }

    body.studio-app .studio-pane-head h2 {
        font-size: 1.1rem;
    }
}

/* Watch-sized screens: labels only, rows on one line, 30px targets. */
@media (max-width: 300px) {
    body.studio-app .studio-commandbar .studio-mode i {
        display: none;
    }

    body.studio-app .studio-commandbar .studio-mode {
        min-height: 30px;
        padding: 3px;
        font-size: 0.6rem;
    }

    body.studio-app .studio-btn--save {
        width: 30px;
        min-height: 30px;
    }

    body.studio-app .studio-preview .y1-tp-device--full {
        padding: 5px 6px 6px;
    }

    body.studio-app .studio-preview .y1-tp-device--full .y1-tp-clickwheel {
        width: 58px;
        height: 58px;
    }

    body.studio-app .studio-preview .y1-tp-device--full .y1-tp-cw--center {
        width: 24px;
        height: 24px;
    }

    body.studio-app .studio-asset-row {
        grid-template-columns: 28px minmax(0, 1fr) auto;
        gap: 4px;
        padding: 4px;
    }

    body.studio-app .studio-asset-thumb {
        width: 28px;
        height: 28px;
    }

    body.studio-app .studio-asset-row-copy span {
        display: none;
    }

    body.studio-app .studio-asset-row-action {
        width: 30px;
        height: 30px;
    }

    /* Watch-sized trays: Font and Reset keep their icons but drop their labels,
       so the toolbar stays one line and an asset row is still on screen. */
    body.studio-app .studio-mini-btn {
        width: 30px;
        min-height: 30px;
        justify-content: center;
        padding: 0;
        font-size: 0;
    }

    body.studio-app .studio-mini-btn i {
        font-size: 0.8rem;
    }

    body.studio-app .studio-panel-scroll {
        padding: 8px 8px 14px;
    }
}

/* Short screens (200x200 watches, 320x320 squares): the pane heading is a
   caption, not a control, so drop it and give the height to the asset rows. */
@media (max-height: 320px) {
    body.studio-app .studio-pane-head .studio-eyebrow,
    body.studio-app .studio-pane-head p {
        display: none;
    }

    body.studio-app .studio-pane-head {
        min-height: 0;
        margin-bottom: 0;
    }

    body.studio-app .studio-pane-head h2 {
        margin: 0;
        font-size: 1rem;
    }

    body.studio-app .studio-asset-toolbar {
        margin: 8px 0 8px;
    }
}

/* Short landscape (884x344 class phones): keep both surfaces side by side and
   take the height back from the stage head and foot. */
@media (min-width: 761px) and (max-height: 640px) {
    html,
    body.studio-app {
        height: 100%;
        min-height: 0;
        overflow: hidden;
    }

    body.studio-app,
    body.studio-app .studio-shell {
        height: 100%;
        min-height: 0;
        overflow: hidden;
    }

    body.studio-app #nav-root,
    body.studio-app #footer-root,
    body.studio-app #support-toolbar-slot {
        display: none !important;
    }

    body.studio-app .studio-shell {
        display: flex;
        flex-direction: column;
    }

    body.studio-app .studio-commandbar {
        position: relative;
        top: auto;
        padding: 6px 12px;
        flex: 0 0 auto;
    }

    body.studio-app .studio-commandbar .studio-command-context {
        display: none;
    }

    body.studio-app .studio-main {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(270px, 330px);
        flex: 1 1 auto;
        min-height: 0;
    }

    body.studio-app .studio-stage {
        position: relative;
        inset: auto;
        display: flex;
        flex-direction: column;
        height: 100%;
        max-height: none;
        padding: 6px 12px 4px;
        overflow: hidden;
    }

    body.studio-app .studio-stage-head,
    body.studio-app .studio-stage-foot {
        display: none;
    }

    body.studio-app .studio-panel {
        position: relative;
        inset: auto;
        display: flex;
        flex-direction: column;
        height: 100%;
        min-height: 0;
        overflow: hidden;
        border-left: 1px solid var(--studio-line);
    }

    body.studio-app .studio-panel-scroll {
        flex: 1 1 auto;
        height: auto;
        min-height: 0;
        overflow: auto;
        padding: 10px 12px 18px;
    }

    body.studio-app #studio-title {
        font-size: 1rem;
    }

    body.studio-app .studio-preview-area {
        flex: 1 1 auto;
        min-height: 0;
    }

    body.studio-app .studio-preview .y1-tp-device--full {
        width: min(100%, 250px, calc((100dvh - 92px) / 1.2));
        padding: 8px 9px 9px;
    }

    body.studio-app .studio-preview .y1-tp-device--full .y1-tp-clickwheel {
        width: 78px;
        height: 78px;
    }
}

/* Very short screens (200x200 watches, 240x240 squares): the player is
   width-driven, so shrink it until the whole device fits the strip of height
   the command bar leaves behind. */
@media (max-height: 340px) {
    body.studio-app .studio-preview-area {
        align-items: flex-start;
    }

    body.studio-app .studio-preview .y1-tp-device--full {
        padding: 4px 5px 6px;
        gap: 6px;
        border-radius: 14px;
    }

    body.studio-app .studio-asset-detail-preview {
        min-height: 64px;
        max-height: 96px;
    }

    body.studio-app .studio-preview .y1-tp-device--full .y1-tp-clickwheel {
        width: 48px;
        height: 48px;
    }
}

@media (max-height: 260px) {
    body.studio-app .studio-preview .y1-tp-device--full {
        padding: 3px 4px 4px;
    }

    body.studio-app .studio-preview .y1-tp-device--full .y1-tp-clickwheel {
        width: 40px;
        height: 40px;
    }
}

/* ==========================================================================
   Workbench on every screen: square foldable covers, phones, tablets and
   desktop-class monitors.
   ========================================================================== */

/* The picker lives in the inspector, which is always on screen above 760px, so
   the command-bar shortcut would only duplicate it there. */
.studio-btn--themes {
    display: none;
}

@media (max-width: 760px) {
    /* The stage is a column that owns the leftover height. The preview area had
       a 0px flex base (it has no in-flow child while the theme loads or when
       nothing is open), which pinned the player to the top of a tall screen and
       clipped the empty card. */
    body.studio-app .studio-preview-area {
        flex: 1 1 auto;
        min-height: 0;
    }

    body.studio-app .studio-preview {
        height: 100%;
        min-height: 0;
    }

    /* Height-driven player that may use the whole width of a phone: the 320px
       cap left a 390px screen showing a postage stamp in the corner. */
    body.studio-app .studio-preview .y1-tp-device--full {
        width: min(100%, calc((100dvh - 56px) / 1.2));
        max-width: min(100%, 460px);
    }

    /* Nothing open yet: the only theme picker is in the inspector, so show that
       instead of an empty stage the reader cannot act on. */
    body.studio-app:not(.has-theme)[data-mode='preview'] .studio-stage,
    body.studio-app.studio-chooser[data-mode='preview'] .studio-stage {
        display: none;
    }

    body.studio-app:not(.has-theme)[data-mode='preview'] .studio-panel,
    body.studio-app.studio-chooser[data-mode='preview'] .studio-panel {
        display: flex;
    }

    body.studio-app:not(.has-theme) .studio-source-card,
    body.studio-app:not(.has-theme) .studio-swap-btn,
    body.studio-app:not(.has-theme) .studio-action-grid--single {
        display: none;
    }

    /* Swap themes without leaving the player. */
    body.studio-app .studio-btn--themes {
        display: inline-flex;
        width: 40px;
        min-height: 36px;
        padding: 0;
        justify-content: center;
    }

    body.studio-app .studio-btn--themes span {
        display: none;
    }

    body.studio-app.studio-chooser .studio-btn--themes {
        border-color: var(--site-accent);
        color: var(--site-accent);
    }
}

@media (max-width: 760px) and (max-height: 420px) {
    body.studio-app .studio-btn--themes {
        width: 34px;
        min-height: 32px;
    }
}

/* Desktop-class screens: the player was capped at 330px inside a stage that can
   be 1100px wide, which is a thumbnail on a 48in monitor. */
@media (min-width: 1600px) and (min-height: 820px) {
    body.studio-app .studio-preview .y1-tp-device--full {
        width: min(100%, 440px);
        max-width: min(100%, 440px);
    }
}

/* —— Player badge and its explanation ——
   The badge names the players a theme is listed for, which is a fact about the
   package, not a label on the device family. Y2 added a file manager icon to
   the home screen, so a theme only earns the Y1 / Y2 wording when that icon is
   part of it; a theme without it is an Y1 theme. The badge is a button because
   the answer is only useful if the reader can jump straight to the asset. */
.studio-platform {
    position: relative;
    display: inline-flex;
}

.studio-chip--platform {
    cursor: pointer;
    font-family: var(--site-font);
    font-size: 0.7rem;
    font-weight: 650;
    letter-spacing: 0.01em;
    color: var(--site-text);
}

.studio-chip--platform:hover,
.studio-chip--platform:focus-visible,
.studio-chip--platform[aria-expanded='true'] {
    border-color: var(--studio-accent-line);
    color: var(--site-accent);
}

.studio-chip--platform:focus-visible {
    outline: 2px solid var(--site-accent);
    outline-offset: 2px;
}

.studio-chip--platform.is-y1-only {
    color: var(--site-muted);
}

.studio-platform-info {
    font-size: 0.62rem;
    opacity: 0.55;
}

.studio-platform-pop {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 60;
    display: grid;
    gap: 8px;
    width: min(312px, calc(100vw - 28px));
    padding: 12px;
    border: 1px solid var(--studio-accent-line);
    border-radius: 12px;
    background: var(--site-bg-elevated);
    box-shadow: 0 18px 42px rgba(0, 0, 0, 0.46);
}

.studio-platform-pop[hidden] {
    display: none;
}

.studio-platform-pop strong {
    color: var(--site-text);
    font: 650 0.82rem var(--site-font);
}

.studio-platform-pop p {
    margin: 0;
    color: var(--site-muted);
    font-size: 0.76rem;
    line-height: 1.45;
}

.studio-platform-pop .studio-btn {
    justify-content: center;
    min-height: 34px;
}

/* The row the badge sent the reader to, ringed until they move on. */
.studio-asset-row.is-platform-focus {
    outline: 2px solid var(--site-accent);
    outline-offset: -2px;
    background: color-mix(in oklab, var(--site-accent) 12%, transparent);
}

@media (prefers-reduced-motion: reduce) {
    .studio-chip--platform,
    .studio-platform-pop {
        transition: none;
    }
}

/* —— Backdrop-aware asset thumbnails ————————————————————————————
   A thumbnail answers "what will this look like on the player?". In dark mode a
   dark icon on the plain tray tile is invisible, so each one is drawn on the
   surface it is drawn over: the wallpaper, a file-list row, or a menu row. The
   theme's own files supply the backdrop, and moody themes get a readable thumb. */
.studio-asset-thumb,
.studio-mask-art,
.studio-asset-detail-preview {
    position: relative;
}

.studio-asset-thumb.has-backdrop,
.studio-mask-art.has-backdrop,
.studio-asset-detail-preview.has-backdrop {
    background-color: transparent;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
}

.studio-thumb-strip {
    position: absolute;
    inset: 24% 0;
    background-position: center;
    background-repeat: no-repeat;
    background-size: 100% 100%;
    pointer-events: none;
}

.studio-asset-thumb.has-backdrop > img,
.studio-mask-art.has-backdrop > img,
.studio-asset-detail-preview.has-backdrop > img {
    position: relative;
    z-index: 1;
    width: 72%;
    height: 72%;
    object-fit: contain;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.55));
}

/* The detail plate is wide, so a percentage size stretched a 64px battery icon
   to 600px. Let the art keep its own size and only cap it. */
.studio-asset-detail-preview.has-backdrop > img {
    width: auto;
    height: auto;
    max-width: 84%;
    max-height: 84%;
}

.studio-asset-thumb.has-backdrop > i,
.studio-mask-art.has-backdrop > i {
    position: relative;
    z-index: 1;
}

/* —— Restored-session banner —— */
.studio-recovery {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 14px;
    padding: 10px 12px;
    border: 1px solid color-mix(in oklab, var(--site-accent) 45%, var(--studio-line));
    border-radius: 10px;
    background: color-mix(in oklab, var(--site-accent) 12%, var(--studio-card));
    color: var(--site-text);
    font-size: 0.78rem;
    line-height: 1.35;
}

.studio-recovery[hidden] { display: none; }
.studio-recovery > i { flex: 0 0 auto; color: var(--site-accent); }
.studio-recovery p { flex: 1 1 auto; margin: 0; min-width: 0; }

.studio-recovery-btn {
    flex: 0 0 auto;
    padding: 6px 10px;
    border: 1px solid var(--studio-line);
    border-radius: 7px;
    background: var(--site-bg);
    color: var(--site-text);
    font: 600 0.72rem var(--site-font-mono);
    cursor: pointer;
}
.studio-recovery-btn:hover { border-color: var(--site-accent); color: var(--site-accent); }
.studio-recovery-btn:focus-visible { outline: 2px solid var(--site-accent); outline-offset: 1px; }

.studio-recovery-close {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border: 1px solid transparent;
    border-radius: 7px;
    background: none;
    color: var(--site-muted);
    cursor: pointer;
}
.studio-recovery-close:hover { border-color: var(--studio-line); color: var(--site-text); }
.studio-recovery-close:focus-visible { outline: 2px solid var(--site-accent); outline-offset: 1px; }

/* —— Managing a listing ——
   The update, text-fix and removal paths share one block so the submit pane
   does not grow three near-identical forms with three different buttons. */

.studio-manage {
    border: 1px solid var(--studio-line, rgba(255, 255, 255, 0.14));
    border-radius: 14px;
    background: var(--studio-panel, rgba(255, 255, 255, 0.04));
    padding: 16px;
    margin-bottom: 16px;
}

.studio-manage h2 {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px;
    margin: 0 0 2px;
    font-size: 1.05rem;
}

.studio-manage h2 [data-manage-name] {
    font-weight: 600;
    color: var(--studio-text, #f3f5fb);
    overflow-wrap: anywhere;
}

.studio-manage-author {
    margin: 0 0 6px;
    color: var(--studio-muted, #9aa3b5);
    font-size: 0.85rem;
}

.studio-manage-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 12px 0 4px;
}

.studio-manage-form {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--studio-line, rgba(255, 255, 255, 0.12));
}

.studio-manage-form[hidden] {
    display: none;
}

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

.studio-manage-status {
    margin: 10px 0 0;
    min-height: 1.2em;
    font-size: 0.86rem;
    color: var(--studio-muted, #9aa3b5);
}

.studio-manage-status.is-ok {
    color: var(--studio-ok, #5ee0a0);
}

.studio-manage-status.is-error {
    color: var(--studio-danger, #ff8b85);
}

.studio-btn--danger {
    background: color-mix(in oklab, var(--studio-danger, #ff8b85) 26%, transparent);
    border-color: color-mix(in oklab, var(--studio-danger, #ff8b85) 55%, transparent);
    color: var(--studio-text, #fff);
}

.studio-btn--danger:hover {
    background: color-mix(in oklab, var(--studio-danger, #ff8b85) 38%, transparent);
}

/* —— Status bar states ——
   One chip per state the theme actually ships; the artwork lives in the tray,
   so a chip doubles as a shortcut to the file. */

.studio-status-editor {
    margin: 14px 0 4px;
}

.studio-status-editor h3 {
    margin: 0 0 2px;
    font-size: 0.9rem;
    letter-spacing: 0.01em;
}

.studio-status-text {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 9px;
    font-size: 0.72rem;
    color: var(--studio-muted, #9aa3b5);
}

.studio-status-text > span {
    margin-right: 2px;
}

.studio-status-text button {
    padding: 4px 10px;
    border: 1px solid var(--studio-line, rgba(255, 255, 255, 0.16));
    border-radius: 999px;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 0.72rem;
    cursor: pointer;
}

.studio-status-text button:hover {
    border-color: var(--studio-line-strong, rgba(255, 255, 255, 0.3));
}

.studio-status-text button.is-active {
    border-color: var(--site-accent);
    color: var(--site-accent);
    background: color-mix(in oklab, var(--site-accent) 14%, transparent);
}

.studio-status-text button:focus-visible {
    outline: 2px solid var(--site-accent);
    outline-offset: 2px;
}

.studio-status-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.studio-status-chip {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid var(--studio-line, rgba(255, 255, 255, 0.16));
    background: color-mix(in oklab, var(--site-text) 6%, transparent);
    color: var(--studio-text, #eceff8);
    font-size: 0.8rem;
    cursor: pointer;
}

.studio-status-chip:hover {
    border-color: color-mix(in oklab, var(--studio-accent, #8fb7ff) 55%, transparent);
    background: rgba(255, 255, 255, 0.08);
}

.studio-status-chip.is-active {
    border-color: var(--studio-accent, #8fb7ff);
    background: color-mix(in oklab, var(--studio-accent, #8fb7ff) 22%, transparent);
}

.studio-status-chip.is-changed::after {
    content: "";
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--studio-warn, #ffcf6b);
}

.studio-status-chip:focus-visible {
    outline: 2px solid var(--studio-accent, #8fb7ff);
    outline-offset: 2px;
}

/* The type sample under the font row: the theme's own face, at a size where
   letter shapes are visible without opening the player. */
.studio-font-sample {
    margin: 8px 0 0;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px dashed var(--studio-line, rgba(255, 255, 255, 0.18));
    background: rgba(255, 255, 255, 0.03);
    font-size: 1.35rem;
    line-height: 1.3;
    letter-spacing: 0.02em;
    color: var(--studio-text, #f0f3fb);
    overflow-wrap: anywhere;
}

/* —— Thumbnails that show the screen, not just the art ——
   Home icons sit on the home mask and the mask sits on the wallpaper, so the
   crop stacks all three. Each layer is positioned from the live preview's own
   rectangles, which keeps the mask window and the icon lined up. */
.studio-asset-thumb.has-layers,
.studio-mask-art.has-layers,
.studio-asset-detail-preview.has-layers {
    position: relative;
    overflow: hidden;
    background-color: #05070c;
}

.studio-thumb-layer {
    position: absolute;
    display: block;
    pointer-events: none;
}

.studio-thumb-wallpaper {
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
}

.studio-thumb-mask,
.studio-thumb-art {
    object-fit: fill;
}

/* The plain centred icon would sit on top of the crop and hide it. */
.has-layers > img:not(.studio-thumb-layer) {
    display: none;
}

/* The workbench hides #footer-root, and the site footer is what reserves the
   dock's height on content pages, so the studio reserves it on body instead. */
body.studio-app:not(.y1-dock-closed) {
    padding-bottom: var(--y1-dock-space, 0px);
}
