/*
 * Wardrobe Studio.
 *
 * A dark atelier: the viewport is the room's only bright thing, so the garment is
 * what the eye lands on. Every panel is a flex column that scrolls on its own, so
 * a long template list never pushes the Generate button off screen.
 */
:root {
    --bg: #110f12;
    --panel: #19161a;
    --panel-2: #221e23;
    --panel-3: #2b262c;
    --line: rgba(255, 238, 228, 0.08);
    --line-strong: rgba(255, 238, 228, 0.16);
    --text: #f4ede6;
    --muted: #a99f9a;
    --faint: #72686a;
    --accent: #e8b9a4;
    --accent-strong: #dc9580;
    --accent-ink: #2a1712;
    --ok: #93d3a8;
    --warn: #e8c46e;
    --bad: #ef8b80;
    --radius: 12px;
    --radius-sm: 8px;
    --display: 'Fraunces', Georgia, serif;
    --ui: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font: 14px/1.45 var(--ui);
    -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

button {
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

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

code {
    font: 12px/1.3 ui-monospace, 'SF Mono', Menlo, monospace;
    background: var(--panel-3);
    padding: 1px 5px;
    border-radius: 4px;
}

/* ------------------------------------------------------------------ layout */
.app {
    display: grid;
    height: 100dvh;
    grid-template-columns: 276px minmax(0, 1fr) 376px;
    grid-template-rows: auto minmax(0, 1fr) 244px;
    grid-template-areas:
        'top top top'
        'lib stage design'
        'lib shelf design';
    gap: 1px;
    background: var(--line);
}

.topbar {
    grid-area: top;
}
.library {
    grid-area: lib;
}
.stage {
    grid-area: stage;
}
.designer {
    grid-area: design;
}
.shelf {
    grid-area: shelf;
}
.tabs {
    display: none;
}

/* ------------------------------------------------------------------ topbar */
.topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 16px;
    background: var(--panel);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-right: auto;
}

.brand-mark {
    font-size: 24px;
}

.brand h1 {
    margin: 0;
    font: 650 19px/1.1 var(--display);
    letter-spacing: 0.01em;
}

.brand-sub {
    margin: 1px 0 0;
    color: var(--muted);
    font-size: 11.5px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.caps {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-end;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 9px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
}

.pill::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--faint);
}

.pill.on::before {
    background: var(--ok);
}
.pill.off::before {
    background: var(--warn);
}
.pill.bad::before {
    background: var(--bad);
}

.icon-btn {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 1px solid var(--line-strong);
    border-radius: 50%;
    background: transparent;
}

/* F5. The key button and its Settings row are hidden unless this page needs a key. */
.icon-btn[hidden],
.settings-row[hidden] {
    display: none;
}
.icon-btn svg {
    width: 16px;
    height: 16px;
    fill: var(--muted);
}

.icon-btn.has-key svg {
    fill: var(--accent);
}

/* ------------------------------------------------------------------ panels */
.panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--panel);
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 16px 10px;
}

.panel-head h2 {
    margin: 0;
    font: 650 16px/1.2 var(--display);
}

.panel-note,
.count {
    color: var(--muted);
    font: 500 12px var(--ui);
}

.library-head-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.library-import {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 9px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: var(--panel-2);
    color: var(--text);
    font-size: 11.5px;
    font-weight: 600;
}

.library-import:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.library-import svg {
    width: 13px;
    height: 13px;
    fill: currentColor;
}

/* ------------------------------------------------------------------ library */
.avatar-list {
    flex: 1;
    min-height: 0;
    margin: 0;
    padding: 0 10px 10px;
    overflow-y: auto;
    list-style: none;
}

.avatar {
    display: flex;
    align-items: center;
    gap: 11px;
    width: 100%;
    margin-bottom: 4px;
    padding: 9px 10px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: transparent;
    text-align: left;
}

.avatar:hover:not(:disabled) {
    background: var(--panel-2);
}

.avatar[aria-current='true'] {
    border-color: var(--line-strong);
    background: var(--panel-2);
}

.avatar-glyph {
    display: grid;
    flex: none;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(145deg, var(--panel-3), var(--panel-2));
    color: var(--accent);
    font: 650 15px var(--display);
}

.avatar[aria-current='true'] .avatar-glyph {
    background: var(--accent);
    color: var(--accent-ink);
}

.avatar-meta {
    min-width: 0;
}

.avatar-name {
    display: block;
    font-weight: 600;
}

.avatar-sub {
    display: block;
    overflow: hidden;
    color: var(--muted);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.avatar-badge {
    margin-left: auto;
    padding: 1px 6px;
    border-radius: 5px;
    background: rgba(147, 211, 168, 0.12);
    color: var(--ok);
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.04em;
}

.avatar-badge.missing {
    background: rgba(239, 139, 128, 0.12);
    color: var(--bad);
}

/* ------------------------------------------------------------------ stage */
.stage {
    position: relative;
    min-height: 0;
    overflow: hidden;
    background:
        radial-gradient(ellipse 60% 55% at 50% 42%, #3a3033 0%, #231d20 45%, #151215 100%),
        var(--bg);
}

.stage-canvas,
.stage-canvas canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
}

.stage-empty {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: var(--muted);
    pointer-events: none;
}

.stage-empty[hidden] {
    display: none;
}

.stage-top {
    position: absolute;
    inset: 12px 12px auto;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    pointer-events: none;
}

.stage-top > * {
    pointer-events: auto;
}

.stage-title strong {
    display: block;
    font: 650 20px/1.15 var(--display);
}

.stage-title span {
    color: var(--muted);
    font-size: 12.5px;
}

.seg {
    display: inline-flex;
    padding: 3px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: rgba(17, 15, 18, 0.72);
    backdrop-filter: blur(8px);
}

.seg button {
    padding: 5px 12px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 500;
    white-space: nowrap;
}

.seg button[aria-checked='true'] {
    background: var(--accent);
    color: var(--accent-ink);
}

.seg .short {
    display: none;
}

.stage-tools {
    position: absolute;
    left: 12px;
    bottom: 12px;
    display: flex;
    gap: 6px;
}

.tool {
    padding: 6px 11px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: rgba(17, 15, 18, 0.72);
    backdrop-filter: blur(8px);
    color: var(--muted);
    font-size: 12.5px;
}

.tool[aria-pressed='true'] {
    border-color: var(--accent);
    color: var(--accent);
}

.stage-status {
    position: absolute;
    right: 12px;
    bottom: 14px;
    max-width: 60%;
    color: var(--muted);
    font-size: 12.5px;
    text-align: right;
}

.stage-status.error {
    color: var(--bad);
}

/* --------------------------------------------------------- full screen inspection (SV1) */
.tool-icon {
    display: inline-grid;
    place-items: center;
    padding: 5px 8px;
}

.tool-icon svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

/* The stage alone, edge to edge: a fixed layer over the page, so it works where the
   Fullscreen API does not (an iPhone's Safari) and inside it where it does. */
.stage.is-immersive {
    position: fixed;
    inset: 0;
    z-index: 1000;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
}

html.inspecting,
html.inspecting body {
    overflow: hidden;
    overscroll-behavior: none;
}

.stage.is-immersive .stage-top,
.stage.is-immersive .stage-tools,
.stage.is-immersive .stage-status,
.stage.is-immersive .stage-empty {
    display: none;
}

.inspect-close,
.inspect-bar {
    position: absolute;
    z-index: 2;
    transition: opacity 0.35s ease;
}

.inspect-close[hidden],
.inspect-bar[hidden] {
    display: none;
}

.inspect-close {
    top: max(12px, env(safe-area-inset-top));
    right: max(12px, env(safe-area-inset-right));
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: rgba(17, 15, 18, 0.62);
    backdrop-filter: blur(8px);
    color: var(--text);
}

.inspect-close svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.inspect-bar {
    left: 50%;
    bottom: max(16px, env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    max-width: calc(100% - 24px - env(safe-area-inset-left) - env(safe-area-inset-right));
    transform: translateX(-50%);
}

.inspect-bar .seg button {
    min-width: 58px;
    padding: 7px 12px;
    font-size: 13px;
}

.inspect-hint {
    margin: 0;
    padding: 3px 10px;
    border-radius: 999px;
    background: rgba(17, 15, 18, 0.5);
    color: var(--muted);
    font-size: 11px;
    text-align: center;
}

/* Faded, not removed: a tap brings them back (app.js), and nothing under them shifts. */
.stage.is-immersive.controls-hidden .inspect-close,
.stage.is-immersive.controls-hidden .inspect-bar {
    opacity: 0;
    pointer-events: none;
}

/* A phone on its side has little height: the hint goes, the bar stays one row. */
@media (max-height: 480px) {
    .inspect-hint {
        display: none;
    }
}

/* ------------------------------------------------------------------ designer */
.designer {
    overflow-y: auto;
}

#design-form {
    padding: 0 16px 16px;
}

fieldset {
    margin: 0 0 14px;
    padding: 0;
    border: 0;
}

legend {
    display: flex;
    align-items: baseline;
    gap: 8px;
    width: 100%;
    margin-bottom: 7px;
    padding: 0;
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.legend-value {
    margin-left: auto;
    color: var(--text);
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
}

.legend-hint {
    color: var(--faint);
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 9px;
}

.chip {
    padding: 5px 11px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: transparent;
    color: var(--text);
    font-size: 13px;
    text-transform: capitalize;
}

.chips.small .chip {
    padding: 3px 9px;
    font-size: 12px;
}

.chip:hover {
    border-color: var(--accent);
}

.chip[aria-checked='true'],
.chip[aria-pressed='true'] {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--accent-ink);
}

.row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.field {
    display: block;
}

.field > span {
    display: block;
    margin-bottom: 4px;
    color: var(--faint);
    font-size: 12px;
}

select,
textarea,
dialog input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--panel-2);
}

textarea {
    resize: vertical;
    min-height: 64px;
}

.swatches {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(24px, 1fr));
    gap: 6px;
}

.swatch {
    aspect-ratio: 1;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 50%;
    background: var(--swatch);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
}

.swatch.auto {
    background: conic-gradient(#b3202b, #e3c341, #3f7a4f, #2f5fa8, #6b3f9e, #b3202b);
}

.swatch[aria-checked='true'] {
    border-color: var(--text);
    box-shadow: 0 0 0 2px var(--bg) inset;
}

.request-preview {
    margin: 6px 0 0;
    color: var(--faint);
    font: 11.5px/1.45 ui-monospace, 'SF Mono', Menlo, monospace;
    word-break: break-word;
}

.primary,
.secondary,
.ghost {
    padding: 10px 16px;
    border-radius: 999px;
    font-weight: 600;
}

.primary {
    width: 100%;
    border: 0;
    background: var(--accent);
    color: var(--accent-ink);
}

.primary:hover:not(:disabled) {
    background: var(--accent-strong);
}

.secondary {
    padding: 7px 14px;
    border: 1px solid var(--accent);
    background: transparent;
    color: var(--accent);
    font-size: 13px;
}

.ghost {
    border: 1px solid var(--line-strong);
    background: transparent;
}

/* ------------------------------------------------------------------ job */
.job,
.report {
    margin: 0 16px 16px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel-2);
}

.job[hidden],
.report[hidden] {
    display: none;
}

.job-head {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.job-head span {
    color: var(--muted);
    font-size: 12.5px;
}

.steps {
    display: grid;
    gap: 3px;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: 12.5px;
}

.steps li {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--faint);
}

.steps li::before {
    content: '';
    flex: none;
    width: 8px;
    height: 8px;
    border: 1.5px solid var(--faint);
    border-radius: 50%;
}

.steps li.done {
    color: var(--muted);
}

.steps li.done::before {
    border-color: var(--ok);
    background: var(--ok);
}

.steps li.active {
    color: var(--text);
}

.steps li.active::before {
    border-color: var(--accent);
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    50% {
        background: var(--accent);
    }
}

.job-message {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 12.5px;
}

.job.failed .job-message {
    color: var(--bad);
}

.report h3 {
    margin: 0 0 8px;
    font: 650 14.5px var(--display);
}

.checks {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 12px;
    margin: 0 0 8px;
    padding: 0;
    list-style: none;
    font-size: 12.5px;
}

.checks li::before {
    content: '✓ ';
    color: var(--ok);
}

.checks li.no::before {
    content: '✕ ';
    color: var(--bad);
}

.report-line {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 12.5px;
}

.report-line.warn {
    color: var(--warn);
}

.report-line.bad {
    color: var(--bad);
}

/* ------------------------------------------------------------------ shelf */
.export {
    display: flex;
    align-items: center;
    gap: 10px;
}

.check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-size: 12.5px;
    white-space: nowrap;
}

.check input {
    accent-color: var(--accent);
}

.looks {
    display: flex;
    flex: 1;
    min-height: 0;
    gap: 10px;
    padding: 0 16px 4px;
    overflow-x: auto;
    scroll-snap-type: x proximity;
}

.looks-empty {
    align-self: center;
    margin: 0 auto;
    color: var(--muted);
    font-size: 13px;
}

.look {
    position: relative;
    display: flex;
    flex: none;
    flex-direction: column;
    width: 128px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel-2);
    scroll-snap-align: start;
}

.look[aria-current='true'] {
    border-color: var(--accent);
}

.look-open {
    display: block;
    padding: 0;
    border: 0;
    background: transparent;
    text-align: left;
}

.look img,
.look-ph {
    display: block;
    width: 100%;
    height: 82px;
    object-fit: cover;
    object-position: 50% 30%;
    background: #3a3136;
}

.look-ph {
    display: grid;
    place-items: center;
    font-size: 28px;
}

.look-body {
    display: block;
    padding: 5px 9px 7px;
}

.look-name {
    display: block;
    overflow: hidden;
    font-size: 12.5px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.look-fit {
    display: block;
    font-size: 11px;
    color: var(--ok);
}

.look-fit.failed {
    color: var(--warn);
}

.look-del {
    position: absolute;
    top: 5px;
    right: 5px;
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border: 0;
    border-radius: 50%;
    background: rgba(17, 15, 18, 0.72);
    color: var(--muted);
    font-size: 13px;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.15s;
}

.look:hover .look-del,
.look:focus-within .look-del {
    opacity: 1;
}

.export-hint {
    margin: 0;
    padding: 4px 16px 8px;
    color: var(--faint);
    font-size: 11.5px;
}

/* ------------------------------------------------------------------ body art (BA7)
 * Beside the looks on a desktop, below them on a phone: it belongs to the look on stage,
 * so it lives on the shelf with the looks, never in the garment designer.
 */
.shelf-row {
    display: flex;
    flex: 1;
    min-height: 0;
}

.shelf-looks {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
}

.body-art {
    width: 360px;
    flex: none;
    overflow-y: auto;
    padding: 0 16px 12px;
    border-left: 1px solid var(--line);
}

.body-art[hidden] {
    display: none;
}

/* A desktop shelf is a strip under the stage; with body art open it gets the room the tiles need. */
@media (min-width: 901px) {
    .app:has(#body-art:not([hidden])) {
        grid-template-rows: auto minmax(0, 1fr) 330px;
    }
}

.body-art h3 {
    margin: 0 0 6px;
    font: 650 14.5px var(--display);
}

.body-art-label {
    margin: 8px 0 4px;
    color: var(--muted);
    font: 600 11px var(--ui);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.body-art-on {
    margin: 0 0 6px;
    padding: 0;
    list-style: none;
    font-size: 12.5px;
}

.body-art-on li {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 3px 0;
}

button.link {
    padding: 0;
    border: 0;
    background: none;
    color: var(--accent);
    font: inherit;
    cursor: pointer;
}

.tattoo-tiles {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin: 8px 0;
}

.tattoo-tile {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--panel-2);
    color: var(--text);
    cursor: pointer;
}

.tattoo-tile[aria-checked='true'] {
    border-color: var(--accent);
}

/* The design's PNG is white with the ink as alpha: used as a mask, it shows the chosen ink on skin. */
.tattoo-ink {
    display: block;
    height: 46px;
    background-color: #141414;
    mask-size: contain;
    mask-repeat: no-repeat;
    mask-position: center;
    -webkit-mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-position: center;
}

/* A patch of skin behind the inked mask, so a dark ink reads as it will on her. */
.tattoo-skin {
    display: block;
    padding: 4px;
    border-radius: 4px;
    background: #d9b8a3;
}

.tattoo-name {
    overflow: hidden;
    color: var(--muted);
    font-size: 11px;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.body-art-controls {
    display: grid;
    gap: 4px;
    margin: 4px 0 10px;
}

.body-art-row {
    display: grid;
    grid-template-columns: 4.6rem minmax(0, 1fr) 3rem;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 12px;
}

.body-art-row output {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.body-art-row input[type='color'] {
    width: 44px;
    height: 24px;
    padding: 0;
    border: 1px solid var(--line-strong);
    border-radius: 4px;
    background: none;
}

.body-art .primary {
    width: 100%;
}

.body-art .export-hint {
    padding: 6px 0 0;
}

/* ------------------------------------------------------------------ dialog */
dialog {
    width: min(420px, calc(100vw - 32px));
    padding: 20px;
    border: 1px solid var(--line-strong);
    border-radius: 16px;
    background: var(--panel);
    color: var(--text);
}

dialog::backdrop {
    background: rgba(0, 0, 0, 0.55);
}

dialog h2 {
    margin: 0 0 6px;
    font: 650 18px var(--display);
}

dialog p {
    color: var(--muted);
    font-size: 13px;
}

dialog menu {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin: 14px 0 0;
    padding: 0;
}

dialog .primary {
    width: auto;
}

/* VRM import: deliberately roomier than the small settings prompts. */
dialog.import-vrm {
    position: relative;
    width: min(540px, calc(100vw - 32px));
    padding: 24px;
}

.import-close {
    position: absolute;
    top: 12px;
    right: 12px;
}

.import-heading {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding-right: 28px;
}

.import-heading h2 {
    margin-bottom: 3px;
}

.import-heading p {
    margin: 0;
    line-height: 1.45;
}

.import-mark {
    display: grid;
    flex: none;
    place-items: center;
    width: 42px;
    height: 42px;
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    background: var(--panel-2);
    color: var(--accent);
}

.import-mark svg {
    width: 23px;
    height: 23px;
    fill: currentColor;
}

.import-drop {
    display: grid;
    place-items: center;
    gap: 5px;
    margin-top: 18px;
    padding: 24px 16px;
    border: 1px dashed var(--line-strong);
    border-radius: 14px;
    background: var(--panel-2);
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.import-drop:hover,
.import-drop.drag {
    border-color: var(--accent);
    background: var(--panel-3);
}

.import-drop svg {
    width: 26px;
    height: 26px;
    margin-bottom: 3px;
    fill: var(--accent);
}

.import-drop strong {
    font-size: 14px;
}

.import-drop span,
.import-drop small {
    color: var(--muted);
    font-size: 12px;
}

.import-drop small {
    color: var(--faint);
}

.import-file-card {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel-2);
}

.import-file-card[hidden],
.import-analysis[hidden],
.import-attestation[hidden],
.import-presentation[hidden] {
    display: none;
}

.import-file-icon {
    display: grid;
    flex: none;
    place-items: center;
    width: 42px;
    height: 34px;
    border-radius: 8px;
    background: var(--panel-3);
    color: var(--accent);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.import-file-meta {
    min-width: 0;
}

.import-file-meta strong,
.import-file-meta small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.import-file-meta small {
    margin-top: 2px;
    color: var(--muted);
    font-size: 11.5px;
}

.import-file-state {
    margin-left: auto;
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
}

.import-file-state.ok {
    color: var(--ok);
}

.import-file-state.bad {
    color: var(--bad);
}

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

.import-analysis {
    margin-top: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel-2);
}

.import-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.import-stats > div {
    padding: 8px 10px;
    border-radius: 9px;
    background: var(--panel-3);
}

.import-stats span,
.import-stats strong {
    display: block;
}

.import-stats span {
    color: var(--faint);
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.import-stats strong {
    margin-top: 2px;
    font-size: 13px;
}

.import-license {
    margin-top: 10px;
    padding: 9px 10px;
    border-radius: 9px;
    background: var(--panel-3);
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
}

.import-license.ok {
    color: var(--ok);
}

.import-license.warn {
    color: var(--warn);
}

.import-license.bad {
    color: var(--bad);
}

.import-attestation {
    margin-top: 12px;
}

#import-form .form-error {
    margin: 10px 0 0;
    color: var(--bad);
    font-size: 12.5px;
}

/* ------------------------------------------------------------------ phone */
@media (max-width: 900px) {
    .app {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto 44dvh auto minmax(0, 1fr);
        grid-template-areas:
            'top'
            'stage'
            'tabs'
            'panel';
    }

    .library,
    .designer,
    .shelf {
        display: none;
        grid-area: panel;
    }

    .app[data-tab='library'] .library,
    .app[data-tab='design'] .designer,
    .app[data-tab='wardrobe'] .shelf {
        display: flex;
    }

    .tabs {
        display: flex;
        grid-area: tabs;
        gap: 4px;
        padding: 6px 10px;
        background: var(--panel);
    }

    .tabs button {
        flex: 1;
        padding: 8px 0;
        border: 0;
        border-radius: 999px;
        background: transparent;
        color: var(--muted);
        font-weight: 600;
    }

    .tabs button[aria-selected='true'] {
        background: var(--panel-3);
        color: var(--text);
    }

    .topbar {
        padding: 8px 12px;
    }

    .caps {
        display: none;
    }

    /* One row, so the view control sits beside the name and never over her face. */
    .stage-top {
        align-items: center;
    }

    .stage-title {
        min-width: 0;
    }

    .stage-title strong {
        overflow: hidden;
        font-size: 16px;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .stage-title span {
        display: none;
    }

    .seg button {
        padding: 4px 9px;
        font-size: 12px;
    }

    .seg .long {
        display: none;
    }

    .seg .short {
        display: inline;
    }

    /* Above the toolbar, not beside it: a phone is too narrow for both on one line. */
    .stage-status {
        bottom: 52px;
        max-width: calc(100% - 24px);
        font-size: 11.5px;
    }

    .shelf .panel-head {
        flex-wrap: wrap;
    }

    .looks {
        flex-wrap: wrap;
        align-content: flex-start;
        overflow-y: auto;
        overflow-x: hidden;
    }

    /* One scrolling column on a phone: the looks, then body art for the one on stage. */
    .shelf-row {
        flex-direction: column;
        overflow-y: auto;
    }

    .shelf-looks {
        flex: none;
    }

    .shelf-row .looks {
        overflow: visible;
    }

    .body-art {
        width: auto;
        overflow: visible;
        padding-top: 10px;
        border-top: 1px solid var(--line);
        border-left: 0;
    }

    .look {
        width: calc(50% - 5px);
    }

    .look img,
    .look-ph {
        height: 128px;
    }

    .look-del {
        opacity: 1;
    }
}

/* ---------------------------------------------------------------- style layer */
.style .style-row {
    display: grid;
    grid-template-columns: 5.5rem 1fr;
    align-items: start;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}
.style .style-label {
    font-size: 0.75rem;
    color: var(--muted);
    padding-top: 0.35rem;
}
.chip:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.build-on {
    margin: 0.25rem 0 0.75rem;
}
.build-on input:disabled + span {
    opacity: 0.5;
}
@media (max-width: 720px) {
    .style .style-row {
        grid-template-columns: 1fr;
        gap: 0.25rem;
    }
    .style .style-label {
        padding-top: 0;
    }
}

/* ---------------------------------------------------------------- plan preview */
#plan-btn {
    margin-top: 0.5rem;
}
.hint {
    margin: 0.5rem 0 0;
    color: var(--faint);
    font-size: 0.8rem;
    line-height: 1.4;
}
.plan {
    margin-top: 0.75rem;
    padding: 0.75rem;
    border: 1px solid var(--line);
    border-radius: 0.75rem;
}
.plan-layers {
    list-style: none;
    margin: 0 0 0.5rem;
    padding: 0;
    display: grid;
    gap: 0.35rem;
}
.plan-layers li.no {
    opacity: 0.55;
    text-decoration: line-through;
}
.plan-layer {
    display: inline-grid;
    place-items: center;
    width: 1.4rem;
    height: 1.4rem;
    border-radius: 50%;
    background: var(--accent);
    color: var(--accent-ink);
    font-size: 0.75rem;
    font-weight: 600;
}
.plan-sub {
    color: var(--muted);
    font-size: 0.8rem;
}
.build-on {
    display: flex;
    min-width: 0;
}
.build-on span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Hosiery & Suspenders */
.hosiery .check { margin: 0.2rem 0 0.5rem; }
.hosiery details.more { margin-top: 0.5rem; }
.hosiery details.more summary { cursor: pointer; font-size: 0.85rem; opacity: 0.8; }
table.tension { border-collapse: collapse; font-size: 0.8rem; margin: 0.4rem 0; }
table.tension th, table.tension td { padding: 0.15rem 0.5rem; text-align: right; }
table.tension td:first-child, table.tension th:first-child { text-align: left; }
table.tension td.warning { color: #e8b04a; }
table.tension td.error { color: #ef6b6b; }
table.tension td.slack { opacity: 0.6; }
.hosiery-previews { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.4rem; }
.hosiery-previews img { width: calc(50% - 0.2rem); border-radius: 6px; }

/* ------------------------------------------------------------------ account
 * Bottom-left, where a chat app keeps its account: a row at the foot of the
 * avatar column on a desktop, a single round button on a phone. The menu opens
 * upwards so it never runs off the bottom of the screen.
 */
.account {
    position: fixed;
    left: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    z-index: 20;
    width: 252px;
}

.library {
    padding-bottom: 68px;
}

.account-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 7px 10px 7px 7px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel-2);
    text-align: left;
}

.account-btn:hover,
.account-btn[aria-expanded='true'] {
    background: var(--panel-3);
    border-color: var(--line-strong);
}

.account-glyph {
    display: grid;
    flex: none;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--panel-3);
    color: var(--muted);
    font-weight: 650;
}

.account-glyph svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.account.signed-in .account-glyph {
    background: var(--accent);
    color: var(--accent-ink);
}

.account-label {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.2;
}

.account-name {
    font-weight: 600;
}

.account-sub {
    color: var(--muted);
    font-size: 11.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.account-menu {
    position: absolute;
    left: 0;
    bottom: calc(100% + 8px);
    display: flex;
    flex-direction: column;
    min-width: 100%;
    padding: 6px;
    border: 1px solid var(--line-strong);
    border-radius: 14px;
    background: var(--panel-2);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

.account-menu[hidden] {
    display: none;
}

.account-menu-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 8px 10px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 4px;
}

.account-menu hr {
    width: 100%;
    margin: 4px 0;
    border: 0;
    border-top: 1px solid var(--line);
}

.account-menu button {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    text-align: left;
}

.account-menu button svg {
    flex: none;
    width: 18px;
    height: 18px;
    fill: currentColor;
    opacity: 0.85;
}

.account-menu button small {
    display: block;
    color: var(--faint);
    font-size: 11px;
}

.account-menu button:hover:not(:disabled),
.account-menu button:focus-visible {
    background: var(--panel-3);
}

.account-caret {
    flex: none;
    width: 18px;
    height: 18px;
    margin-left: auto;
    fill: var(--muted);
}

.account-btn[aria-expanded='true'] .account-caret {
    transform: rotate(180deg);
}

.account-menu button[hidden] {
    display: none;
}

.account-menu .danger {
    color: var(--bad);
}

@media (max-width: 900px) {
    .account {
        width: auto;
    }

    .account-btn {
        padding: 4px;
        border-radius: 50%;
    }

    .account-btn .account-label {
        display: none;
    }

    .account-menu {
        min-width: 240px;
    }

    .library {
        padding-bottom: 0;
    }

    .panel {
        padding-bottom: 60px;
    }

    .account-caret {
        display: none;
    }
}

/* ------------------------------------------------------------------ settings */
.form-error {
    color: var(--bad);
}

/* Settings: a section list beside the section, as a chat app lays it out; tabs on a phone. */
dialog.settings {
    width: min(680px, calc(100vw - 32px));
    max-height: min(640px, calc(100dvh - 32px));
    padding: 0;
    overflow: hidden;
}

dialog.settings[open] {
    display: flex;
    flex-direction: column;
}

.settings-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
}

.settings-head h2 {
    margin: 0;
}

.settings-close {
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--muted);
    font-size: 22px;
    line-height: 1;
}

.settings-close:hover {
    background: var(--panel-3);
    color: var(--text);
}

.settings-body {
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr);
    min-height: 0;
    flex: 1;
}

.settings-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 12px;
    border-right: 1px solid var(--line);
}

.settings-nav button {
    padding: 9px 12px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    text-align: left;
    font-weight: 500;
}

.settings-nav button[aria-selected='true'] {
    background: var(--panel-3);
    color: var(--text);
}

.settings-section {
    padding: 8px 20px 20px;
    overflow-y: auto;
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
}

.settings-row strong {
    display: block;
}

.settings-row small {
    color: var(--muted);
    font-size: 12px;
}

.settings-row .secondary {
    flex: none;
}

.settings-locked {
    padding: 12px;
    border: 1px dashed var(--line-strong);
    border-radius: 10px;
}

.settings-locked p {
    margin: 0 0 10px;
}

dialog.settings > .form-error {
    margin: 0;
    padding: 0 20px 14px;
}

@media (max-width: 640px) {
    .settings-body {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto minmax(0, 1fr);
    }

    .settings-nav {
        flex-direction: row;
        padding: 8px 12px;
        border-right: 0;
        border-bottom: 1px solid var(--line);
        overflow-x: auto;
    }

    .settings-nav button {
        white-space: nowrap;
    }

    .settings-row {
        flex-wrap: wrap;
    }
}

dialog.settings h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 14px 0 0;
    font-size: 14px;
}

dialog .tag {
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--panel-3);
    color: var(--muted);
    font-size: 11px;
    font-weight: 500;
}

.declarations {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.declarations label {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 10px;
    border-radius: 10px;
    cursor: pointer;
}

.declarations label:hover {
    background: var(--panel-2);
}

.declarations .who {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
}

.declarations .who small {
    color: var(--muted);
    font-size: 11.5px;
}

/* A switch, from a checkbox, so it stays keyboard- and screen-reader-native. */
.switch {
    appearance: none;
    position: relative;
    flex: none;
    width: 38px;
    height: 22px;
    margin: 0;
    border-radius: 999px;
    background: var(--panel-3);
    border: 1px solid var(--line-strong);
    cursor: pointer;
    transition: background 0.15s;
}

.switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--muted);
    transition: transform 0.15s;
}

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

.switch:checked::after {
    transform: translateX(16px);
    background: var(--accent-ink);
}

.switch:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.settings-note {
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
}


/* On the picture's corner, opposite the remove button: the card's text rows are full. */
/* The log-in card: centred, one column, like a chat app's. */
dialog.login {
    width: min(380px, calc(100vw - 32px));
    padding: 32px 28px 24px;
}

dialog.login form {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    text-align: center;
}

.login-close {
    position: absolute;
    top: 10px;
    right: 10px;
}

.login-mark {
    font-size: 34px;
    line-height: 1;
}

dialog.login h2 {
    margin: 12px 0 4px;
    font-size: 24px;
}

.login-sub {
    margin: 0 0 20px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
    text-align: left;
}

.field span {
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 500;
}

.field input {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    background: var(--panel-2);
    font-size: 15px;
}

.field input:focus {
    border-color: var(--accent);
    outline: none;
    box-shadow: 0 0 0 3px rgba(232, 185, 164, 0.18);
}

.login-off {
    margin: 0 0 16px;
    padding: 10px 12px;
    border: 1px solid rgba(232, 196, 110, 0.35);
    border-radius: 10px;
    background: rgba(232, 196, 110, 0.08);
    color: var(--warn);
    font-size: 13px;
    text-align: left;
}

dialog.login .form-error {
    margin: 0 0 10px;
    text-align: left;
    font-size: 13px;
}

.login-submit {
    margin-top: 4px;
    padding: 12px 16px;
}

.login-foot {
    margin: 16px 0 0;
    color: var(--faint) !important;
    font-size: 12px !important;
}

.confirm-line {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 8px 0;
    padding: 11px 12px;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    cursor: pointer;
}

.confirm-line:has(input:checked) {
    border-color: var(--accent);
    background: var(--panel-2);
}

.confirm-line input {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--accent);
}

.look-private {
    position: absolute;
    top: 6px;
    left: 6px;
    padding: 1px 7px;
    border-radius: 999px;
    background: var(--accent);
    color: var(--accent-ink);
    font-size: 10.5px;
    font-weight: 600;
    pointer-events: none;
}
