:root {
    --bg: #14161b;
    --panel: #1d2027;
    --line: #2d313b;
    --text: #e7e9ef;
    --muted: #8a90a0;
    --laser: #45d6ff;
    --accent: #5a4af4;
    --danger: #ff6b6b;
    --warn: #f3b74f;
    --good: #4fe3a1;
    color-scheme: dark;
    box-sizing: border-box;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}
*, *::before, *::after { box-sizing: inherit; }
html { height: 100%; }
body {
    margin: 0;
    min-height: 100%;
    background: radial-gradient(ellipse at 50% 0%, #1f2330 0%, var(--bg) 60%) fixed;
    color: var(--text);
    font: 15px/1.6 "Pretendard Variable", Pretendard, -apple-system, "Malgun Gothic", sans-serif;
}
a { color: var(--laser); text-decoration: none; }
h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 .5rem; }
h2 { font-size: 1.05rem; margin: 0 0 1rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

.mark {
    display: inline-block; width: 22px; height: 22px; border: 2px solid var(--laser);
    border-radius: 6px; transform: rotate(45deg); box-shadow: 0 0 12px rgba(69, 214, 255, .35);
}
.mark.big { width: 46px; height: 46px; border-radius: 10px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-right: .45rem; vertical-align: middle; }
.dot.on { background: var(--good); box-shadow: 0 0 8px var(--good); }

.topbar {
    position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10;
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: .8rem 1.4rem; background: rgba(20, 22, 27, .85); backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .7rem; color: var(--text); font-weight: 700; white-space: nowrap; }
.brand .mark { width: 14px; height: 14px; border-radius: 3px; }
.topbar nav { display: flex; align-items: center; gap: 1.1rem; font-size: .92rem; overflow-x: auto; }
.topbar nav a { color: var(--muted); white-space: nowrap; }
.topbar nav a:hover, .topbar nav a.on { color: var(--text); }

.page { max-width: 1100px; margin: 0 auto; padding: 2rem 1.4rem 4rem; }

.gate { display: grid; place-items: center; padding: 1.5rem; min-height: 100vh; }
.gate-card {
    width: 100%; max-width: 380px; padding: 2.2rem 2rem; text-align: center;
    background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
}
.gate-card.wide { max-width: 520px; }
.gate-card p { color: var(--muted); margin: 0 0 1.4rem; }
.gate-card form { text-align: left; }
.checks { list-style: none; padding: 0; margin: 1rem 0 1.4rem; text-align: left; font-size: .9rem; }
.checks li { display: flex; justify-content: space-between; gap: 1rem; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.checks li.pass { color: var(--good); }
.checks li.fail { color: var(--danger); }
.checks b { color: var(--text); font-weight: 500; }

.scan-stage { position: relative; height: 90px; display: grid; place-items: center; overflow: hidden; margin-bottom: 1rem; }
.scanline {
    position: absolute; left: 15%; right: 15%; height: 2px; bottom: 0;
    background: var(--laser); box-shadow: 0 0 14px 3px rgba(69, 214, 255, .55);
    animation: scan 2.4s ease-in-out 1 forwards;
}
.scanline.loop { animation: scan 2.4s ease-in-out infinite; }
@keyframes scan {
    0% { bottom: 0; opacity: 0; }
    15% { opacity: 1; }
    85% { opacity: 1; }
    100% { bottom: 100%; opacity: 0; }
}

label { display: block; margin-bottom: 1rem; font-size: .88rem; color: var(--muted); }
input, select {
    display: block; width: 100%; margin-top: .35rem; padding: .7rem .85rem;
    background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 10px;
    font: inherit;
}
input:focus, select:focus { outline: none; border-color: var(--laser); }
input[type=checkbox], input[type=radio] { width: auto; display: inline; margin: 0 .4rem 0 0; }
.pw-wrap { position: relative; display: block; margin-top: .35rem; }
.pw-wrap input { margin-top: 0; padding-right: 2.6rem; }
.inline .pw-wrap { display: inline-block; margin: 0; }
.pw-eye { position: absolute; right: .35rem; top: 50%; transform: translateY(-50%); display: grid; place-items: center; padding: .35rem; border: 0; background: none; color: var(--muted); cursor: pointer; }
.pw-eye.on { color: var(--laser); }
.pw-eye svg { width: 18px; height: 18px; }

.btn {
    display: inline-block; padding: .72rem 1.3rem; border: 0; border-radius: 999px;
    background: var(--accent); color: #fff; font: inherit; font-weight: 600; cursor: pointer; text-align: center;
}
.btn.big { width: 100%; padding: .95rem; font-size: 1.05rem; }
.btn:disabled { opacity: .5; cursor: wait; }
.gate-card .btn { width: 100%; }
.btn:hover { filter: brightness(1.12); }
.btn:focus-visible, a:focus-visible, button:focus-visible, .drop-zone:focus-visible { outline: 2px solid var(--laser); outline-offset: 2px; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); padding: .45rem .9rem; }
.btn.danger { background: transparent; border: 1px solid rgba(255, 107, 107, .4); color: var(--danger); padding: .45rem .9rem; }

.alert, .ok { padding: .7rem .9rem; border-radius: 10px; font-size: .9rem; text-align: left; margin: 0 0 1rem; }
.alert { background: rgba(255, 107, 107, .1); color: var(--danger); }
.ok { background: rgba(69, 214, 255, .08); color: var(--laser); }
.err { color: var(--danger); }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 1.4rem; margin: 1.4rem 0; }

/* create */
.create-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(300px, 1fr); gap: 1.6rem; align-items: start; }
.create-grid .panel { margin: 0; }
.drop-zone {
    min-height: 420px; border: 1.5px dashed var(--line); border-radius: 18px; background: rgba(29, 32, 39, .6);
    display: grid; place-items: center; cursor: pointer; padding: 1rem; transition: border-color .2s;
}
.drop-zone.over { border-color: var(--laser); background: rgba(69, 214, 255, .05); }
.drop-empty { display: grid; justify-items: center; gap: .8rem; text-align: center; color: var(--muted); }
.drop-empty strong { color: var(--text); font-size: 1.05rem; margin-top: .6rem; }
.drop-zone.has-files { place-items: start stretch; }
.drop-zone.has-files .drop-empty { display: none; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .8rem; width: 100%; }
.thumb-cell { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--bg); border: 2px solid transparent; }
.thumb-cell img { width: 100%; height: 100%; object-fit: contain; }
.thumb-cell.main { border-color: var(--warn); }
.thumb-cell button {
    position: absolute; top: 6px; width: 28px; height: 28px; border-radius: 50%; border: 0;
    background: rgba(20, 22, 27, .8); color: var(--muted); cursor: pointer; font-size: 14px; line-height: 28px; padding: 0;
}
.thumb-cell .star { left: 6px; }
.thumb-cell.main .star { color: var(--warn); }
.thumb-cell .remove { right: 6px; }
.thumb-cell.add { display: grid; place-items: center; font-size: 2rem; color: var(--muted); border: 1.5px dashed var(--line); }
.hint { color: var(--muted); font-size: .85rem; margin: .7rem 0 0; }
.field { margin-bottom: 1.1rem; }
.field-label { display: block; font-size: .88rem; color: var(--muted); margin-bottom: .45rem; }
.seg { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 3px; }
.seg label { flex: 1; margin: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; text-align: center; padding: .5rem .2rem; border-radius: 9px; color: var(--muted); cursor: pointer; font-size: .9rem; }
.seg input:checked + span { background: var(--panel); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.seg input:focus-visible + span { outline: 2px solid var(--laser); }
.dims { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
.dims label { margin: 0; font-size: .8rem; }
.agree { display: flex; gap: .3rem; align-items: flex-start; font-size: .82rem; line-height: 1.5; }
.agree input { margin-top: .25rem; }

/* job */
.job-page { text-align: center; max-width: 620px; }
.pedestal-stage { position: relative; height: 230px; display: grid; place-items: end center; overflow: hidden; margin-bottom: 1.5rem; }
.pedestal { position: relative; width: 220px; height: 60px; margin-bottom: 10px; }
.ring { position: absolute; inset: 0; border: 1.5px solid rgba(69, 214, 255, .5); border-radius: 50%; transform: scaleY(.35); }
.ring.r2 { inset: 14px 30px; border-color: rgba(69, 214, 255, .25); }
.job-page[data-status="failed"] .scanline, .job-page[data-status="canceled"] .scanline { display: none; }
.stage-text { font-size: 1.1rem; margin: .4rem 0 .9rem; }
.bar { height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--laser); box-shadow: 0 0 10px var(--laser); transition: width .6s ease; }
.actions { display: flex; gap: .6rem; justify-content: center; flex-wrap: wrap; margin: 1.2rem 0; }
.job-inputs { display: flex; gap: .5rem; justify-content: center; flex-wrap: wrap; margin-top: 2rem; }
.job-inputs img { width: 72px; height: 72px; object-fit: contain; background: var(--panel); border-radius: 10px; }

/* models */
.list-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.filters { display: flex; gap: .6rem; }
.filters input, .filters select { margin: 0; width: auto; }
.job-strip { display: flex; gap: .7rem; overflow-x: auto; padding-bottom: .4rem; margin-bottom: 1.4rem; }
.job-chip { flex: 0 0 auto; display: grid; padding: .6rem .9rem; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; color: var(--text); font-size: .88rem; }
.job-chip span { color: var(--muted); font-size: .8rem; }
.job-chip.running { border-color: rgba(69, 214, 255, .5); }
.job-chip.failed span { color: var(--danger); }
.model-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1.1rem; }
.model-card { display: grid; gap: .25rem; color: var(--text); }
.model-card .thumb { aspect-ratio: 1; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); display: grid; place-items: center; overflow: hidden; margin-bottom: .4rem; }
.model-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.model-card:hover .thumb { border-color: var(--laser); }
.empty { text-align: center; padding: 4rem 1rem; color: var(--muted); }

/* viewer */
.viewer-body { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
.viewer-layout { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 300px; }
.viewer { position: relative; min-height: 0; background: radial-gradient(circle at 50% 40%, #252a36, #15171c 70%); }
.viewer canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); overflow: hidden; }
.loading .scanline { left: 30%; right: 30%; }
.modes { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); display: grid; gap: .5rem; padding: .5rem; background: rgba(29, 32, 39, .85); border-radius: 999px; }
.modes button { width: 40px; height: 40px; border-radius: 50%; border: 0; background: transparent; cursor: pointer; display: grid; place-items: center; }
.modes button.on { background: var(--line); }
.sw { width: 22px; height: 22px; border-radius: 50%; }
.sw.tex { background: radial-gradient(circle at 35% 35%, #fff, #8d7a5d 70%); }
.sw.clay { background: radial-gradient(circle at 35% 35%, #fff, #9a9a9a 70%); }
.sw.normal { background: conic-gradient(#7f7fff, #ff7fbf, #7fff7f, #7f7fff); }
.sw.wire { border: 2px solid var(--laser); background: repeating-linear-gradient(45deg, transparent 0 3px, rgba(69, 214, 255, .5) 3px 4px); }
.stats { position: absolute; left: 70px; top: 14px; margin: 0; display: grid; grid-template-columns: auto auto; gap: .15rem 1rem; padding: .7rem 1rem; background: rgba(29, 32, 39, .85); border-radius: 12px; font-size: .85rem; }
.stats dt { color: var(--muted); }
.stats dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.viewer-bar { border-left: 1px solid var(--line); padding: 1.4rem; display: grid; align-content: start; gap: 1rem; overflow-y: auto; }
.title-row input { font-size: 1.1rem; font-weight: 600; margin: 0 0 .3rem; }
.viewer-bar .actions { display: grid; justify-content: stretch; margin: 0; }

/* avatar studio */
.stage-tools, .faces { display: flex; gap: .3rem; padding: .3rem; background: rgba(29, 32, 39, .88); border-radius: 999px; }
.stage-tools { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); }
.stage-tools button, .faces button {
    border: 0; background: transparent; color: var(--muted); font: inherit; font-size: .85rem;
    padding: .4rem .8rem; border-radius: 999px; cursor: pointer; white-space: nowrap;
}
.stage-tools button.on, .faces button.on { background: var(--line); color: var(--text); }
.viewer.playing .stage-tools { opacity: .35; pointer-events: none; }
.stage-bottom { position: absolute; left: 12px; right: 12px; bottom: 14px; display: flex; justify-content: space-between; align-items: center; gap: .8rem; flex-wrap: wrap; }
.faces { overflow-x: auto; max-width: 100%; }
.motion-bar { display: flex; gap: .4rem; align-items: center; }
.motion-bar select { margin: 0; width: auto; max-width: 220px; padding: .5rem .7rem; }
.studio-bar h2 { margin: .4rem 0 .6rem; }
.part-list { list-style: none; padding: 0; margin: 0 0 .8rem; display: grid; gap: .5rem; }
.part-list li { border: 1px solid var(--line); border-radius: 12px; padding: .55rem .7rem; }
.part-list li.on { border-color: var(--laser); box-shadow: 0 0 0 1px rgba(69, 214, 255, .25); }
.part-name { background: none; border: 0; color: var(--text); font: inherit; font-weight: 600; padding: 0; cursor: pointer; text-align: left; width: 100%; }
.part-opts { display: flex; gap: .4rem; margin-top: .45rem; flex-wrap: wrap; }
.part-opts select { margin: 0; width: auto; flex: 1; min-width: 96px; padding: .4rem .5rem; font-size: .85rem; }
.part-list .fit { display: block; margin: .55rem 0 0; font-size: .8rem; }
.part-list .fit span { float: right; color: var(--text); font-variant-numeric: tabular-nums; }
.part-list .fit input { padding: 0; margin-top: .25rem; border: 0; background: none; accent-color: var(--laser); }
.base-parts { list-style: none; padding: 0; margin: 0 0 .5rem; display: grid; grid-template-columns: 1fr 1fr; gap: .35rem; }
.base-parts label { display: flex; align-items: center; gap: .2rem; margin: 0; padding: .45rem .6rem; border: 1px solid var(--line); border-radius: 10px; color: var(--text); font-size: .85rem; cursor: pointer; }
.base-parts input { accent-color: var(--laser); }
.add-part { display: flex; gap: .4rem; }
.add-part select { margin: 0; flex: 1; min-width: 0; }
.new-avatar { display: grid; grid-template-columns: 1fr 1fr auto; gap: 0 1rem; align-items: end; }
.new-avatar .btn { margin-bottom: 1rem; }
.lib-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0 1rem; align-items: end; }
.lib-form .btn { margin-bottom: 1rem; }
.lib-form .bar { grid-column: 1 / -1; margin-bottom: 1rem; }
.lib-list { list-style: none; padding: 0; margin: .4rem 0 0; }
.lib-list li { display: flex; align-items: center; gap: .8rem; padding: .6rem 0; border-top: 1px solid var(--line); }
.lib-list li b { font-weight: 600; }
.lib-list li .btn { margin-left: auto; }

/* admin */
.create { display: grid; grid-template-columns: repeat(4, 1fr) auto; gap: 0 1rem; align-items: end; }
.create h2 { grid-column: 1 / -1; }
.create .btn { margin-bottom: 1rem; }
.worker-card { display: flex; justify-content: space-between; align-items: center; gap: 1.2rem; flex-wrap: wrap; }
.worker-card h2 { margin: 0 0 .2rem; }
.worker-card p { margin: 0; }
.counts { display: flex; gap: 1.4rem; }
.counts span { display: grid; text-align: center; color: var(--muted); font-size: .8rem; }
.counts b { color: var(--text); font-size: 1.3rem; }
.table-wrap { overflow-x: auto; }
.users { width: 100%; border-collapse: collapse; font-size: .92rem; }
.users th { text-align: left; color: var(--muted); font-weight: 500; padding: .6rem .7rem; border-bottom: 1px solid var(--line); }
.users td { padding: .7rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.inline { display: inline-flex; gap: .4rem; align-items: center; margin: .15rem .3rem .15rem 0; }
.inline input { margin: 0; width: 7.5rem; padding: .45rem .6rem; }
.inline input[type=number] { width: 4.8rem; }
.tag { font-size: .75rem; padding: .1rem .5rem; border-radius: 999px; background: rgba(90, 74, 244, .2); color: #b3aaff; white-space: nowrap; }
.tag.warn, .tag.st-queued { background: rgba(243, 183, 79, .15); color: var(--warn); }
.tag.off, .tag.st-failed { background: rgba(255, 107, 107, .12); color: var(--danger); }
.tag.st-running { background: rgba(69, 214, 255, .12); color: var(--laser); }
.tag.st-done { background: rgba(79, 227, 161, .12); color: var(--good); }
.tag.st-canceled { background: var(--line); color: var(--muted); }

@media (max-width: 860px) {
    .create-grid { grid-template-columns: 1fr; }
    .drop-zone { min-height: 240px; }
    .viewer-layout { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; }
    .viewer-bar { border-left: 0; border-top: 1px solid var(--line); padding: 1rem; }
    .viewer-bar .actions { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) and (orientation: landscape) {
    .viewer-layout { grid-template-columns: minmax(0, 1fr) 240px; grid-template-rows: none; }
    .viewer-bar { border-top: 0; border-left: 1px solid var(--line); }
    .viewer-bar .actions { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
    .topbar { padding: .7rem 1rem; }
    .brand { font-size: 0; gap: 0; }
    .topbar nav { gap: .9rem; font-size: .85rem; }
    .page { padding: 1.4rem 1rem 3rem; }
    .create { grid-template-columns: 1fr 1fr; }
    .create .btn { grid-column: 1 / -1; }
    .modes { top: auto; bottom: 12px; left: 50%; transform: translateX(-50%); display: flex; }
    .new-avatar { grid-template-columns: 1fr; }
    .stage-bottom { flex-direction: column; align-items: stretch; }
    .motion-bar select { flex: 1; max-width: none; }
    .stats { left: 12px; top: 12px; }
    .model-grid { grid-template-columns: repeat(2, 1fr); gap: .8rem; }
    .users thead { display: none; }
    .users tr { display: block; padding: .8rem 0; border-bottom: 1px solid var(--line); }
    .users td { display: flex; justify-content: space-between; gap: 1rem; border: 0; padding: .3rem 0; }
    .users td::before { content: attr(data-label); color: var(--muted); flex-shrink: 0; }
    .users td[data-label="관리"] { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
    .scanline { animation: none; opacity: .6; bottom: 50%; }
}

/* ===== studio workspace ===== */
.studio-body { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; background: #0f1115; }
.studio-body .topbar { position: relative; top: 0; }
.studio { flex: 1; min-height: 0; display: grid; grid-template-columns: 64px 300px minmax(0, 1fr) 272px; gap: 8px; padding: 8px; }
.studio svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

.rail { display: flex; flex-direction: column; gap: 6px; padding: 8px 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; }
.rail-btn { display: grid; justify-items: center; gap: 4px; padding: 10px 0 8px; border: 0; border-radius: 12px; background: none; color: var(--muted); font: inherit; font-size: .7rem; cursor: pointer; }
.rail-btn:hover { color: var(--text); background: rgba(255, 255, 255, .04); }
.rail-btn.on { color: var(--laser); background: rgba(69, 214, 255, .1); }
.rail-stage { display: none; }

.side { display: flex; flex-direction: column; min-height: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.side form { flex: 1; overflow-y: auto; padding: 14px 14px 8px; }
.side-head { display: flex; align-items: center; gap: 8px; font-weight: 700; padding-bottom: 12px; }
.side.right .side-head { padding: 14px 14px 10px; }
.side-title { margin: 16px 0 8px; font-size: .82rem; font-weight: 600; color: var(--text); }
.kinds span { font-size: .82rem; padding: .45rem .1rem; }

.drop { margin-top: 12px; min-height: 180px; border: 1.5px dashed #3a4150; border-radius: 14px; display: grid; place-items: center; padding: 10px; cursor: pointer; background:
    linear-gradient(45deg, rgba(255,255,255,.02) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.02) 75%) 0 0 / 16px 16px,
    linear-gradient(45deg, rgba(255,255,255,.02) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.02) 75%) 8px 8px / 16px 16px; }
.drop:hover, .drop.over { border-color: var(--laser); }
.drop .drop-empty { display: grid; justify-items: center; gap: 6px; text-align: center; color: var(--muted); font-size: .8rem; }
.drop .drop-empty svg { width: 30px; height: 30px; color: var(--laser); }
.drop .drop-empty strong { color: var(--text); font-size: .95rem; }
.drop.has-files { place-items: start stretch; }
.drop.has-files .drop-empty { display: none; }
.drop .thumbs { grid-template-columns: repeat(3, 1fr); gap: 6px; }
.drop .thumb-cell button { width: 22px; height: 22px; line-height: 22px; font-size: 11px; top: 4px; }
.drop .thumb-cell .star { left: 4px; }
.drop .thumb-cell .remove { right: 4px; }
.side .hint { font-size: .75rem; margin-top: 6px; }
.field-row { display: flex; flex-direction: column; font-size: .8rem; margin-bottom: 10px; }
.field-row em { font-style: normal; color: var(--muted); font-size: .72rem; margin-left: 4px; }
div.field-row { flex-direction: row; margin-bottom: 6px; }
.side input:not([type=checkbox]):not([type=radio]):not([type=range]) { padding: .55rem .7rem; font-size: .88rem; }
.quality { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.quality label { margin: 0; }
.quality input { position: absolute; opacity: 0; pointer-events: none; }
.quality span { display: grid; justify-items: center; padding: .55rem 0; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.quality b { font-size: .85rem; color: var(--text); font-weight: 600; }
.quality small { font-size: .68rem; color: var(--muted); }
.quality input:checked + span { border-color: var(--laser); background: rgba(69, 214, 255, .08); }
.quality input:focus-visible + span { outline: 2px solid var(--laser); }
.side .agree { margin-top: 14px; font-size: .74rem; }
.side-foot { padding: 12px 14px 14px; border-top: 1px solid var(--line); }
.gen-btn {
    width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; padding: .9rem; border: 0; border-radius: 14px; cursor: pointer;
    font: inherit; font-weight: 700; font-size: 1.02rem; color: #06212b;
    background: linear-gradient(135deg, #7ff0ff 0%, #45d6ff 45%, #5a8bff 100%); box-shadow: 0 6px 24px rgba(69, 214, 255, .25);
}
.gen-btn svg { fill: currentColor; stroke: none; }
.gen-btn:hover { filter: brightness(1.08); }
.gen-btn:disabled { opacity: .6; cursor: wait; }
.gen-btn.busy svg { animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.quota { margin: 8px 0 0; text-align: center; font-size: .74rem; color: var(--muted); }

.stage { position: relative; min-height: 0; border-radius: 16px; overflow: hidden; border: 1px solid var(--line);
    background: radial-gradient(ellipse at 50% 45%, #26303d 0%, #161a21 55%, #101318 100%); }
.viewport { position: absolute; inset: 0; }
.viewport canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.rain { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; opacity: 0; mix-blend-mode: screen; }
.stage-top { position: absolute; top: 12px; left: 12px; right: 64px; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; pointer-events: none; }
.model-name { pointer-events: auto; max-width: 320px; background: rgba(20, 23, 29, .7) !important; border-color: transparent !important; font-weight: 600; backdrop-filter: blur(6px); }
.model-name:disabled { opacity: .6; }
.stage .stats { position: static; pointer-events: auto; background: rgba(20, 23, 29, .7); backdrop-filter: blur(6px); font-size: .78rem; }
.tool-col { position: absolute; right: 12px; top: 12px; display: grid; gap: 6px; padding: 6px; background: rgba(20, 23, 29, .75); border-radius: 999px; backdrop-filter: blur(6px); }
.tool-col button { width: 38px; height: 38px; border-radius: 50%; border: 0; background: none; color: var(--muted); display: grid; place-items: center; cursor: pointer; }
.tool-col button:hover { color: var(--text); }
.tool-col button.on { color: var(--laser); }
.empty-hint { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 18px; text-align: center; color: var(--muted); font-size: .9rem; pointer-events: none; }
.empty-hint b { color: var(--laser); }
.holo-ring { width: 120px; height: 120px; border-radius: 50%; border: 1.5px solid rgba(69, 214, 255, .5); box-shadow: 0 0 30px rgba(69, 214, 255, .2), inset 0 0 30px rgba(69, 214, 255, .15); transform: rotateX(70deg); animation: holo 3s ease-in-out infinite; }
@keyframes holo { 50% { box-shadow: 0 0 50px rgba(69, 214, 255, .35), inset 0 0 40px rgba(69, 214, 255, .3); } }
.gen-overlay { position: absolute; left: 50%; bottom: 86px; transform: translateX(-50%); width: min(420px, calc(100% - 32px)); padding: 14px 18px; text-align: center; border-radius: 14px; background: rgba(15, 18, 24, .78); border: 1px solid rgba(69, 214, 255, .25); backdrop-filter: blur(8px); }
.gen-stage { margin: 0 0 10px; font-weight: 600; }
.gen-note { margin: 8px 0 0; font-size: .78rem; color: var(--muted); }
.gen-overlay .btn { margin-top: 10px; }
.load-note { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); padding: .5rem 1rem; border-radius: 999px; background: rgba(15, 18, 24, .8); font-size: .85rem; color: var(--muted); }
.dock { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); display: flex; align-items: center; gap: 4px; padding: 6px; border-radius: 16px; background: rgba(20, 23, 29, .85); border: 1px solid var(--line); backdrop-filter: blur(8px); max-width: calc(100% - 24px); overflow-x: auto; }
.dock button { display: flex; align-items: center; gap: 6px; height: 40px; padding: 0 12px; border: 0; border-radius: 11px; background: none; color: var(--text); font: inherit; font-size: .82rem; cursor: pointer; white-space: nowrap; }
.dock button:hover { background: rgba(255, 255, 255, .06); }
.dock .modes { display: flex; gap: 2px; }
.dock .modes button { width: 40px; padding: 0; justify-content: center; }
.dock .modes button.on { background: var(--line); }
.dock .danger { color: var(--danger); }
.dock .dock-main { background: var(--accent); color: #fff; padding: 0 16px; font-weight: 600; }
.dock .dock-main:hover { background: var(--accent); filter: brightness(1.12); }
.dock-sep { width: 1px; height: 24px; background: var(--line); margin: 0 4px; flex-shrink: 0; }

.gpu { margin-left: auto; font-size: .7rem; font-weight: 500; color: var(--muted); display: inline-flex; align-items: center; gap: 5px; }
.gpu::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.gpu.on { color: var(--good); }
.gpu.on::before { background: var(--good); box-shadow: 0 0 6px var(--good); }
.lib-tools { padding: 0 14px 10px; display: grid; gap: 8px; }
.lib-tools input { margin: 0; padding: .5rem .7rem; font-size: .85rem; }
.chips { display: flex; gap: 4px; overflow-x: auto; }
.chips button { flex-shrink: 0; padding: .3rem .7rem; border-radius: 999px; border: 1px solid var(--line); background: none; color: var(--muted); font: inherit; font-size: .74rem; cursor: pointer; }
.chips button.on { color: var(--text); border-color: var(--laser); background: rgba(69, 214, 255, .08); }
.lib-grid { flex: 1; overflow-y: auto; padding: 0 14px 14px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; align-content: start; }
.card { display: grid; gap: 2px; padding: 0; border: 0; background: none; text-align: left; color: var(--text); font: inherit; cursor: pointer; min-width: 0; }
.card .thumb { position: relative; aspect-ratio: 1; border-radius: 12px; border: 1px solid var(--line); background: #1a1e25; display: grid; place-items: center; overflow: hidden; margin-bottom: 4px; }
.card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.card .ph { width: 26px; height: 26px; border: 2px solid rgba(69, 214, 255, .5); border-radius: 6px; transform: rotate(45deg); }
.card:hover .thumb { border-color: #4a5566; }
.card.on .thumb { border-color: var(--laser); box-shadow: 0 0 0 1px var(--laser), 0 0 16px rgba(69, 214, 255, .25); }
.card-name { font-size: .8rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-meta { font-size: .7rem; color: var(--muted); }
.card.job .thumb b { position: absolute; font-size: .8rem; color: var(--laser); }
.card.job .ring { width: 64%; aspect-ratio: 1; border-radius: 50%; background: conic-gradient(var(--laser) calc(var(--p) * 1%), rgba(69, 214, 255, .12) 0); -webkit-mask: radial-gradient(circle, transparent 58%, #000 60%); mask: radial-gradient(circle, transparent 58%, #000 60%); }
.card.job.queued .ring { animation: spin 2.4s linear infinite; background: conic-gradient(var(--laser) 18%, rgba(69, 214, 255, .12) 0); }
.card.job.failed .thumb { border-color: rgba(255, 107, 107, .4); }
.card.job.failed .thumb b, .card.job.failed .card-meta { color: var(--danger); }
@keyframes spin { to { transform: rotate(1turn); } }
.lib-empty { grid-column: 1 / -1; text-align: center; color: var(--muted); font-size: .85rem; padding: 40px 0; }

@media (max-width: 1280px) {
    .studio { grid-template-columns: 64px 280px minmax(0, 1fr) 232px; }
}
@media (max-width: 1024px) {
    .studio { grid-template-columns: 64px 280px minmax(0, 1fr); }
    .studio .side.right { display: none; }
    .studio[data-view="library"] .side.right { display: flex; grid-column: 2; grid-row: 1; }
    .studio[data-view="library"] .side.left { display: none; }
}
@media (max-width: 760px) {
    .studio { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) 62px; padding: 6px; gap: 6px; }
    .rail { grid-row: 2; flex-direction: row; justify-content: space-around; padding: 4px; }
    .rail-btn { flex: 1; padding: 6px 0; }
    .rail-stage { display: grid; }
    .studio .side, .studio .stage { display: none; grid-row: 1; grid-column: 1; }
    .studio[data-view="create"] .side.left, .studio[data-view="library"] .side.right { display: flex; }
    .studio[data-view="stage"] .stage { display: block; }
    .stage-top { flex-direction: column; right: 60px; }
    .stage .stats { grid-template-columns: auto auto; }
    .dock button span { display: none; }
    .dock .dock-main span { display: inline; }
    .gen-overlay { bottom: 74px; }
    .topbar nav a:not(.on):not(:last-child) { display: none; }
}
@media (max-width: 900px) and (orientation: landscape) and (max-height: 500px) {
    .studio { grid-template-columns: 56px minmax(0, 1fr) 280px; grid-template-rows: 1fr; }
    .rail { grid-row: 1; flex-direction: column; }
    .rail-stage { display: none; }
    .studio .stage { display: block; grid-column: 2; grid-row: 1; }
    .studio .side { display: none; grid-column: 3; grid-row: 1; }
    .studio[data-view="create"] .side.left, .studio[data-view="stage"] .side.left, .studio[data-view="library"] .side.right { display: flex; }
    .studio-body .topbar { display: none; }
}
