/* 뚝폴리 스튜디오 — 밤하늘 다크 · 오로라 · 유리 카드 · 프리텐다드 (3D 도구라 다크 전용) */
:root {
  --bg: #050b16;
  --text: #f5f5fa;
  --body: #d6d6e4;
  --muted: #a3a3bb;          /* 유리 카드 위 5:1 이상 */
  --glass: rgba(255, 255, 255, .05);
  --glass-hi: rgba(255, 255, 255, .09);
  --well: rgba(0, 0, 0, .32);
  --line: rgba(255, 255, 255, .09);
  --line-hi: rgba(255, 255, 255, .18);
  --sky: #0ea5e9;
  --sky-hi: #bae6fd;
  --cyan: #22d3ee;
  --pink: #ec4899;
  --ok: #5eead4;
  --warn: #fcd34d;
  --err: #fda4af;
  --grad: linear-gradient(120deg, #7dd3fc 0%, #0ea5e9 38%, #22d3ee 100%);
  --shadow: inset 0 1px 0 rgba(255, 255, 255, .07), 0 24px 60px -28px rgba(0, 0, 0, .8);
  --radius: 24px;
  --font: 'Pretendard Variable', Pretendard, -apple-system, 'Apple SD Gothic Neo', 'Malgun Gothic', system-ui, sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--body);
  font: 16px/1.55 var(--font);
  letter-spacing: -.01em;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--sky-hi); outline-offset: 3px; border-radius: 10px; }

/* 배경: 오로라 + 그레인 */
.aurora { position: fixed; inset: 0; z-index: -2; overflow: hidden; }
.aurora i { position: absolute; border-radius: 50%; filter: blur(110px); opacity: .55; animation: drift 26s var(--ease) infinite alternate; }
.aurora i:nth-child(1) { width: 52vw; height: 52vw; left: -12vw; top: -18vw; background: #0369a1; }
.aurora i:nth-child(2) { width: 40vw; height: 40vw; right: -10vw; top: 8vh; background: #0e7490; animation-delay: -8s; opacity: .45; }
.aurora i:nth-child(3) { width: 36vw; height: 36vw; left: 30vw; bottom: -22vw; background: #1e3a8a; animation-delay: -16s; opacity: .32; }
@keyframes drift { to { transform: translate3d(6vw, 4vh, 0) scale(1.12); } }
.grain {
  position: fixed; inset: -50%; z-index: -1; pointer-events: none; opacity: .07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* 머리 */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px clamp(16px, 3vw, 32px);
  background: linear-gradient(to bottom, rgba(5, 11, 22, .85), rgba(5, 11, 22, .4));
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.brand span { font-size: 21px; font-weight: 800; letter-spacing: -.04em; }
.brand small { font-size: 11px; font-weight: 600; letter-spacing: .18em; color: var(--muted); padding-top: 3px; }
.logo { width: 30px; height: 30px; filter: drop-shadow(0 4px 14px rgba(14, 165, 233, .55)); }
.logo.big { width: 64px; height: 64px; }

.engine { font-family: var(--font); display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--muted); padding: 7px 14px 7px 12px; border-radius: 99px; background: var(--glass); border: 1px solid var(--line); }
.engine .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.engine.up { color: var(--ok); }
.engine.up .dot { background: var(--ok); box-shadow: 0 0 0 0 rgba(94, 234, 212, .6); animation: ping 2.2s infinite; }
.engine.down { color: var(--warn); }
.engine.down .dot { background: var(--warn); }
.engine.off { color: var(--muted); }
.engine:disabled { cursor: default; }
.engine.admin { cursor: pointer; }
.engine.admin:hover { border-color: var(--sky); }
@keyframes ping { 70% { box-shadow: 0 0 0 8px rgba(94, 234, 212, 0); } 100% { box-shadow: 0 0 0 0 rgba(94, 234, 212, 0); } }

/* 벤토 레이아웃 */
.studio {
  display: grid; gap: 16px;
  padding: 16px clamp(16px, 3vw, 32px) 40px;
  grid-template-columns: minmax(300px, 380px) 1fr;
  grid-template-areas: "make stage" "make gallery";
  grid-template-rows: minmax(420px, 62vh) auto;
  max-width: 1680px; margin: 0 auto;
}
.make { grid-area: make; align-self: start; position: sticky; top: 76px; }
.stage { grid-area: stage; }
.gallery { grid-area: gallery; }
@media (max-width: 960px) {
  .studio { grid-template-columns: 1fr; grid-template-areas: "stage" "make" "gallery"; grid-template-rows: minmax(340px, 52vh) auto auto; }
  .make { position: static; }
}

.panel {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(140%); -webkit-backdrop-filter: blur(18px) saturate(140%);
  padding: 20px;
}
.eyebrow { margin: 0 0 14px; font-size: 13px; font-weight: 700; letter-spacing: .08em; color: var(--sky-hi); text-transform: uppercase; }

/* 올리기 */
.drop {
  position: relative; display: grid; justify-items: center; gap: 6px; text-align: center;
  padding: 26px 16px; border-radius: 18px; cursor: pointer;
  border: 1.5px dashed var(--line-hi); background: var(--well);
  transition: border-color .2s var(--ease), background .2s var(--ease), transform .2s var(--ease);
}
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop svg { width: 30px; height: 30px; color: var(--sky-hi); }
.drop strong { color: var(--text); font-size: 15px; }
.drop span { font-size: 13px; color: var(--muted); }
.drop:hover, .drop.over { border-color: var(--sky); background: rgba(14, 165, 233, .1); }
.drop.over { transform: scale(1.015); }
.drop:focus-within { outline: 2px solid var(--sky-hi); outline-offset: 3px; }

.src-tabs { margin: 0 0 14px; }
.mv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mv-slot { position: relative; aspect-ratio: 1; border-radius: 14px; border: 1.5px dashed var(--line-hi); background: var(--well) center / cover no-repeat; display: grid; place-items: center; cursor: pointer; overflow: hidden; transition: border-color .2s var(--ease); }
.mv-slot:hover, .mv-slot:focus-within { border-color: var(--sky); }
.mv-slot input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.mv-slot span { font-size: 13px; font-weight: 700; color: var(--text); padding: 4px 10px; border-radius: 99px; background: rgba(5, 11, 22, .7); }
.mv-slot span b { color: var(--sky-hi); font-weight: 700; margin-left: 2px; }
.mv-slot.has { border-style: solid; border-color: rgba(186, 230, 253, .5); }
.mv .hint, .retex .hint { margin: 8px 0 0; font-size: 13px; color: var(--muted); }
.retex { display: grid; gap: 10px; }
.rt-target { margin: 0; font-size: 14px; color: var(--body); }
.rt-target b { color: var(--text); }
.rt-up { justify-content: center; }
.rt-ref { aspect-ratio: auto; min-height: 96px; }
.retex textarea { width: 100%; resize: vertical; padding: 12px; border-radius: 14px; border: 1.5px solid var(--line-hi); background: var(--well); font: inherit; font-size: 14px; color: var(--text); }
.textsrc textarea { width: 100%; resize: vertical; min-height: 110px; padding: 14px; border-radius: 16px; border: 1.5px solid var(--line-hi); background: var(--well); font: inherit; font-size: 15px; line-height: 1.5; color: var(--text); }
.textsrc textarea:focus { outline: none; border-color: var(--sky-hi); box-shadow: 0 0 0 3px rgba(14, 165, 233, .25); }
.textsrc .hint { margin: 8px 0 0; font-size: 13px; color: var(--muted); }
.card .thumb .ph { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; text-align: center; font-size: 14px; font-weight: 700; line-height: 1.4; color: var(--text); background: radial-gradient(80% 80% at 30% 20%, rgba(14, 165, 233, .35), transparent 70%), #0b1424; }
.picked { list-style: none; margin: 12px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); gap: 8px; }
.picked:empty { display: none; }
.picked li { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: var(--well); }
.picked img { width: 100%; height: 100%; object-fit: cover; }
.picked button { position: absolute; top: 3px; right: 3px; width: 24px; height: 24px; padding: 4px; border: 0; border-radius: 50%; background: rgba(0, 0, 0, .65); cursor: pointer; }
.picked button svg { width: 100%; height: 100%; }

/* 세그먼트 */
.seg { border: 0; margin: 18px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.seg legend { width: 100%; padding: 0; margin-bottom: 8px; font-size: 13px; font-weight: 700; color: var(--text); }
.seg legend small { font-weight: 500; color: var(--muted); margin-left: 6px; }
.seg label { flex: 1 1 0; min-width: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: grid; place-items: center; min-height: 44px; padding: 6px 8px; border-radius: 12px; cursor: pointer;
  font-size: 14px; font-weight: 700; color: var(--body); text-align: center; line-height: 1.2;
  background: var(--well); border: 1px solid var(--line);
  transition: background .18s var(--ease), border-color .18s var(--ease), color .18s var(--ease);
}
.seg span em { font-style: normal; font-size: 11px; font-weight: 600; color: var(--muted); margin-top: 2px; }
.seg span:hover { border-color: var(--line-hi); }
.seg input:checked + span { color: var(--text); background: linear-gradient(160deg, rgba(125, 211, 252, .28), rgba(34, 211, 238, .14)); border-color: rgba(186, 230, 253, .55); box-shadow: 0 6px 22px -10px rgba(14, 165, 233, .8); }
.seg input:checked + span em { color: var(--sky-hi); }
.seg input:focus-visible + span { outline: 2px solid var(--sky-hi); outline-offset: 2px; }
.seg.mini { margin: 0; flex-wrap: nowrap; }
.seg.mini span { min-height: 36px; padding: 4px 12px; font-size: 13px; white-space: nowrap; }

/* 스위치 */
.switch { display: flex; align-items: center; gap: 10px; margin-top: 18px; font-size: 14px; font-weight: 600; color: var(--text); cursor: pointer; min-height: 44px; }
.switch input { position: absolute; opacity: 0; }
.switch .track { position: relative; width: 44px; height: 26px; border-radius: 99px; background: var(--well); border: 1px solid var(--line-hi); transition: background .2s var(--ease); }
.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .25s var(--ease); }
.switch input:checked + .track { background: var(--sky); border-color: var(--sky); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--sky-hi); outline-offset: 3px; }

/* 주 버튼 */
.cta {
  position: relative; width: 100%; margin-top: 20px; min-height: 54px; border: 0; border-radius: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 16px; font-weight: 800; color: #0b0b14; background: var(--grad); background-size: 160% 100%;
  box-shadow: 0 14px 36px -14px rgba(14, 165, 233, .9), inset 0 1px 0 rgba(255, 255, 255, .45);
  transition: transform .15s var(--ease), background-position .5s var(--ease), opacity .2s;
}
.cta svg { width: 20px; height: 20px; }
.cta:hover:not(:disabled) { background-position: 100% 0; transform: translateY(-1px); }
.cta:active:not(:disabled) { transform: translateY(1px) scale(.99); }
.cta:disabled { cursor: not-allowed; opacity: .45; filter: grayscale(.4); }
.msg { min-height: 1.4em; margin: 10px 0 0; font-size: 13px; color: var(--err); }
.msg.ok { color: var(--ok); }

/* 무대 */
.stage { position: relative; padding: 0; overflow: hidden; display: grid; background: radial-gradient(120% 90% at 50% 110%, rgba(14, 165, 233, .22), transparent 60%), var(--glass); }
model-viewer { width: 100%; height: 100%; min-height: 340px; --poster-color: transparent; background: transparent; }
.empty { display: grid; place-content: center; justify-items: center; gap: 30px; padding: 24px; text-align: center; color: var(--muted); perspective: 700px; }
.cube { width: 84px; height: 84px; position: relative; transform-style: preserve-3d; animation: spin 9s linear infinite; }
.cube i { position: absolute; inset: 0; border: 1.5px solid rgba(186, 230, 253, .55); background: rgba(14, 165, 233, .06); box-shadow: inset 0 0 24px rgba(34, 211, 238, .18); }
.cube i:nth-child(1) { transform: translateZ(42px); }
.cube i:nth-child(2) { transform: rotateY(180deg) translateZ(42px); }
.cube i:nth-child(3) { transform: rotateY(90deg) translateZ(42px); }
.cube i:nth-child(4) { transform: rotateY(-90deg) translateZ(42px); }
.cube i:nth-child(5) { transform: rotateX(90deg) translateZ(42px); }
.cube i:nth-child(6) { transform: rotateX(-90deg) translateZ(42px); }
@keyframes spin { from { transform: rotateX(-24deg) rotateY(0); } to { transform: rotateX(-24deg) rotateY(360deg); } }
.stage-bar {
  position: absolute; left: 14px; right: 14px; bottom: 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 10px 10px 16px; border-radius: 18px;
  background: rgba(10, 10, 18, .62); border: 1px solid var(--line); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.stage-info { min-width: 0; display: grid; }
.stage-info strong { color: var(--text); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage-info span { font-size: 12px; color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 16px; border-radius: 12px; cursor: pointer;
  font-size: 14px; font-weight: 700; color: var(--text); text-decoration: none; white-space: nowrap;
  background: var(--glass-hi); border: 1px solid var(--line-hi); transition: background .18s var(--ease);
}
.btn:hover { background: rgba(255, 255, 255, .14); }
.dl { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.dl .btn { min-height: 40px; padding: 0 12px; }
select.btn { appearance: none; padding-right: 12px; }
select.btn option { background: #0b1220; color: var(--text); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.btn svg { width: 18px; height: 18px; }

/* 갤러리 */
.gal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.gal-head .eyebrow { margin: 0; }
#count { color: var(--muted); font-weight: 600; letter-spacing: 0; }
.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); }
@media (max-width: 600px) { .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } }
.card {
  position: relative; border-radius: 18px; overflow: hidden; background: var(--well); border: 1px solid var(--line);
  transition: transform .2s var(--ease), border-color .2s var(--ease); animation: rise .4s var(--ease) both;
}
.card.done { cursor: pointer; }
.card.done:hover { transform: translateY(-3px); border-color: rgba(186, 230, 253, .5); }
.card.sel { border-color: var(--sky-hi); box-shadow: 0 0 0 1px var(--sky-hi), 0 14px 34px -16px rgba(14, 165, 233, .9); }
@keyframes rise { from { opacity: 0; transform: translateY(10px) scale(.97); } }
.card .thumb { position: relative; aspect-ratio: 1; background: #0d0d16; }
.card .thumb img { width: 100%; height: 100%; object-fit: contain; }
.card.running .thumb::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(186, 230, 253, .22) 50%, transparent 70%); background-size: 250% 100%;
  animation: scan 1.6s linear infinite;
}
@keyframes scan { from { background-position: 150% 0; } to { background-position: -100% 0; } }
.card .body { padding: 10px 12px 12px; display: grid; gap: 4px; }
.card .name { color: var(--text); font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .meta { font-size: 12px; color: var(--muted); }
.card .err { font-size: 12px; color: var(--err); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.badge { position: absolute; top: 8px; left: 8px; display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; white-space: nowrap; background: rgba(8, 8, 14, .72); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border: 1px solid var(--line); }
.badge.queued { color: var(--body); }
.badge.running { color: var(--sky-hi); }
.badge.running::before { content: ''; width: 10px; height: 10px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: rot .8s linear infinite; }
.badge.done { color: var(--ok); }
.badge.failed { color: var(--err); }
@keyframes rot { to { transform: rotate(360deg); } }
.acts { position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; opacity: 0; transition: opacity .18s; }
.card:hover .acts, .card:focus-within .acts { opacity: 1; }
@media (hover: none) { .acts { opacity: 1; } }
.acts a, .acts button { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; border: 1px solid var(--line); background: rgba(8, 8, 14, .72); color: var(--text); cursor: pointer; }
.acts svg { width: 17px; height: 17px; }
.acts a:hover, .acts button:hover { background: rgba(14, 165, 233, .45); }
.none { margin: 4px 0 0; color: var(--muted); font-size: 14px; }

/* 로그인 */
.login { width: min(380px, calc(100vw - 32px)); margin: 12vh auto 0; display: grid; justify-items: center; gap: 6px; padding: 32px 24px; text-align: center; }
.login h1 { margin: 8px 0 0; font-size: 26px; font-weight: 800; letter-spacing: -.04em; color: var(--text); }
.login p { margin: 0 0 14px; color: var(--muted); }
.login label { justify-self: start; font-size: 13px; font-weight: 700; color: var(--text); }
.login .tabs { width: 100%; margin: 0 0 14px; }
.login label small { font-weight: 500; color: var(--muted); margin-left: 4px; }
.login label[for] { margin-top: 8px; }
.top-right { display: flex; align-items: center; gap: 10px; }
.account { display: flex; align-items: center; gap: 8px; }
.credits { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px; border-radius: 99px; font-size: 14px; font-weight: 800; color: var(--text); background: linear-gradient(160deg, rgba(125, 211, 252, .22), rgba(34, 211, 238, .1)); border: 1px solid rgba(186, 230, 253, .4); }
.credits svg { width: 15px; height: 15px; color: var(--sky-hi); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 13px; }
@media (max-width: 600px) { .engine .txt { display: none; } }
.login input { width: 100%; min-height: 50px; padding: 0 16px; border-radius: 14px; border: 1px solid var(--line-hi); background: var(--well); font-size: 16px; }
.login input:focus { outline: none; border-color: var(--sky-hi); box-shadow: 0 0 0 3px rgba(14, 165, 233, .3); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
