:root {
  color-scheme: dark;
  --bg: #071214;
  --panel: #0b1b1d;
  --panel-2: #102427;
  --ink: #edf8f4;
  --muted: #89a5a0;
  --line: rgba(147, 207, 195, .18);
  --teal: #48ddc3;
  --gold: #efbd58;
  --coral: #ff7c70;
  --blue: #65b8ff;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-width: 1180px; min-height: 100%; }
body {
  color: var(--ink);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  background: radial-gradient(circle at 55% 0, rgba(72,221,195,.08), transparent 38rem), repeating-linear-gradient(135deg, rgba(255,255,255,.012) 0 1px, transparent 1px 12px), var(--bg);
}
button, input, select, textarea { font: inherit; color: inherit; }
button, select, input, textarea { border: 1px solid var(--line); background: #081719; }
button { cursor: pointer; }
button:hover { border-color: rgba(72,221,195,.66); }
button:disabled { opacity: .42; cursor: not-allowed; }

.studio-topbar { position: sticky; top: 0; z-index: 20; height: 68px; display: grid; grid-template-columns: 290px 1fr auto; align-items: center; border-bottom: 1px solid var(--line); background: rgba(7,18,20,.95); backdrop-filter: blur(14px); }
.studio-brand { height: 100%; display: flex; align-items: center; gap: 13px; padding: 0 20px; color: var(--ink); text-decoration: none; border-right: 1px solid var(--line); }
.brand-mark { width: 27px; height: 27px; border: 1px solid var(--teal); transform: rotate(45deg); position: relative; }
.brand-mark::after { content: ""; position: absolute; inset: 8px; border: 2px solid var(--teal); border-radius: 50%; }
.studio-brand b, .studio-brand small { display: block; }
.studio-brand b { font: 800 .84rem/1 Consolas, monospace; letter-spacing: .12em; }
.studio-brand small { margin-top: 4px; color: var(--muted); font-size: .68rem; }
.draft-state { display: flex; align-items: center; gap: 9px; padding-left: 22px; color: var(--muted); font-size: .74rem; }
.draft-state i { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 10px rgba(239,189,88,.5); }
.draft-state.saved i { background: var(--teal); box-shadow: 0 0 10px rgba(72,221,195,.55); }
.identity { display: flex; align-items: center; gap: 12px; padding-right: 18px; font-size: .75rem; }
.identity span { color: var(--muted); }
.identity button { padding: 9px 13px; }

.studio-shell { min-height: calc(100vh - 68px); display: grid; grid-template-columns: 290px minmax(650px, 1fr) 370px; }
.studio-sidebar, .preview-sidebar { min-width: 0; background: rgba(8,22,24,.76); }
.studio-sidebar { border-right: 1px solid var(--line); }
.preview-sidebar { border-left: 1px solid var(--line); }
.studio-sidebar section, .preview-sidebar section { padding: 22px 20px; border-bottom: 1px solid var(--line); }
.kicker { margin: 0 0 8px; color: var(--teal); font: 700 .64rem/1 Consolas, monospace; letter-spacing: .14em; text-transform: uppercase; }
h1, h2 { margin: 0; font-family: Georgia, serif; letter-spacing: -.025em; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.12rem; }
.intro, .fine-print { color: var(--muted); font-size: .72rem; line-height: 1.55; }
.field { display: grid; gap: 6px; margin-top: 14px; }
.field > span, .frame-navigation label span, .preview-controls label > span { color: var(--muted); font-size: .65rem; text-transform: uppercase; letter-spacing: .06em; }
.field input, .field textarea, .field select { width: 100%; padding: 9px; outline: none; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--teal); }
.base-list { width: 100%; min-height: 160px; margin-top: 8px; padding: 4px; }
.base-list option { padding: 6px 7px; }
.template-summary { margin-top: 10px; padding: 10px; min-height: 52px; color: var(--muted); font-size: .68rem; line-height: 1.5; border: 1px solid var(--line); background: rgba(0,0,0,.14); }
.choice { display: flex; align-items: center; gap: 8px; margin-top: 11px; color: var(--muted); font-size: .72rem; cursor: pointer; }
.choice input { accent-color: var(--teal); }
.project-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 14px; }
.project-actions button, .file-button { padding: 9px; text-align: center; font-size: .68rem; border: 1px solid var(--line); background: #0b1d20; cursor: pointer; }
.file-button input { display: none; }
.submission-list { display: grid; gap: 7px; color: var(--muted); font-size: .7rem; }
.submission-card { padding: 9px; border: 1px solid var(--line); background: rgba(255,255,255,.018); }
.submission-card b, .submission-card span { display: block; }
.submission-card span { margin-top: 4px; }
.submission-card button { width: 100%; margin-top: 8px; }
.submission-card .pending { color: var(--gold); }
.submission-card .approved { color: var(--teal); }
.submission-card .rejected { color: var(--coral); }
.disabled-section { opacity: .42; pointer-events: none; }
.disabled-section.ready { opacity: 1; pointer-events: auto; }

.editor-workspace { min-width: 0; padding: 20px; }
.editor-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.editor-heading-actions { display: flex; gap: 17px; }
.frame-navigation { display: grid; grid-template-columns: 110px 105px minmax(190px,1fr) 100px 110px 130px; gap: 7px; margin: 16px 0 10px; }
.frame-navigation label { display: grid; gap: 5px; }
.frame-navigation select { width: 100%; min-width: 0; padding: 8px; }
.frame-education { display: grid; grid-template-columns: minmax(250px, .7fr) minmax(390px, 1.3fr); gap: 12px; margin-bottom: 10px; }
.frame-explanation, .pose-browser { min-width: 0; padding: 13px; border: 1px solid var(--line); background: rgba(7,20,22,.82); }
.frame-explanation h3 { margin: 0; font: 700 .9rem/1.3 "Trebuchet MS", sans-serif; }
.frame-explanation > p:not(.kicker) { margin: 6px 0 0; color: var(--muted); font-size: .69rem; line-height: 1.45; }
.frame-equation { display: inline-flex; margin-top: 9px; padding: 6px 8px; color: var(--gold); border: 1px solid rgba(239,189,88,.24); background: rgba(239,189,88,.06); font: 700 .64rem/1.35 Consolas, monospace; }
.tester-notice { display: grid; gap: 4px; margin: 12px 0; padding: 10px; color: var(--muted); border: 1px solid rgba(239,189,88,.35); background: rgba(239,189,88,.07); font-size: .62rem; line-height: 1.45; }
.tester-notice[hidden] { display: none; }
.tester-notice b { color: var(--gold); text-transform: uppercase; letter-spacing: .08em; }
.pose-browser-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 9px; }
.pose-browser-heading b { font-size: .72rem; }
.pose-browser-heading span { color: var(--muted); font-size: .61rem; }
.frame-strip { display: flex; gap: 7px; padding-bottom: 7px; overflow-x: auto; scrollbar-color: var(--teal) #071416; scrollbar-width: thin; }
.frame-card { flex: 0 0 92px; display: grid; grid-template-rows: 54px auto auto; gap: 3px; padding: 6px; color: var(--muted); text-align: left; border: 1px solid var(--line); background: #091719; }
.frame-card:hover { color: var(--ink); }
.frame-card.active { color: var(--ink); border-color: var(--teal); box-shadow: inset 0 -2px var(--teal); background: rgba(72,221,195,.08); }
.frame-card.complete::after { content: "Confirmed"; color: var(--teal); font: 700 .52rem Consolas, monospace; }
.frame-card:not(.complete)::after { content: "Not confirmed"; color: var(--muted); font: .52rem Consolas, monospace; }
.frame-card canvas { width: 54px; height: 54px; justify-self: center; image-rendering: pixelated; border: 1px solid rgba(255,255,255,.08); background: #0a1719; }
.frame-card b { overflow: hidden; font-size: .6rem; line-height: 1.15; text-overflow: ellipsis; white-space: nowrap; }
.editor-grid { min-height: 650px; display: grid; grid-template-columns: 92px minmax(430px,1fr) 190px; border: 1px solid var(--line); background: #081416; }
.tool-column { display: flex; flex-direction: column; gap: 4px; padding: 9px; border-right: 1px solid var(--line); }
.tool-column button { padding: 8px 5px; color: var(--muted); font-size: .68rem; }
.tool-column button.active { color: #061412; border-color: var(--teal); background: var(--teal); }
.tool-column button.danger { color: var(--coral); }
.tool-rule { height: 1px; margin: 4px 0; background: var(--line); }
.pixel-stage { position: relative; min-width: 0; min-height: 650px; overflow: hidden; touch-action: none; background: #081315; }
.pixel-checker { position: absolute; inset: 0; opacity: .34; background: conic-gradient(#183033 25%, #0e2022 0 50%, #183033 0 75%, #0e2022 0) 0 0 / 24px 24px; }
.canvas-transform { position: absolute; left: 50%; top: 50%; transform-origin: center center; image-rendering: pixelated; }
.canvas-transform canvas { position: absolute; left: 0; top: 0; image-rendering: pixelated; }
#onionCanvas { opacity: .24; filter: sepia(1) saturate(4) hue-rotate(300deg); }
#guideCanvas { opacity: .42; }
#editCanvas { cursor: crosshair; }
.character-context { opacity: .58; pointer-events: none; }
.bounds-canvas { z-index: 5; pointer-events: none; }
.selection-box { position: absolute; z-index: 4; border: 1px dashed #fff; box-shadow: 0 0 0 1px #000; pointer-events: none; }
.frame-inspector { padding: 13px; border-left: 1px solid var(--line); }
.color-field { display: grid; grid-template-columns: 1fr 42px; align-items: center; gap: 8px; color: var(--muted); font-size: .7rem; }
.color-field input { width: 42px; height: 34px; padding: 2px; }
.color-field output { grid-column: 1 / -1; font: 700 .75rem Consolas, monospace; color: var(--ink); }
.palette { display: grid; grid-template-columns: repeat(5,1fr); gap: 5px; margin: 12px 0 18px; }
.palette button { aspect-ratio: 1; border-radius: 50%; border: 2px solid rgba(255,255,255,.18); }
.zoom-field { display: grid; gap: 7px; color: var(--muted); font-size: .68rem; }
.zoom-field input { width: 100%; accent-color: var(--gold); }
.center-canvas, .apply-linked { width: 100%; margin-top: 8px; padding: 7px 5px; color: var(--muted); font-size: .64rem; }
.linked-frames { display: flex; gap: 8px; margin-top: 13px; padding: 9px; border: 1px solid rgba(72,221,195,.24); background: rgba(72,221,195,.05); }
.linked-frames input { margin-top: 2px; accent-color: var(--teal); }
.linked-frames b, .linked-frames small { display: block; }
.linked-frames b { color: var(--ink); font-size: .65rem; }
.linked-frames small { margin-top: 4px; color: var(--muted); font-size: .57rem; line-height: 1.4; }
.linked-frame-status { min-height: 2.6em; margin: 6px 1px 0; color: var(--teal); font-size: .56rem; line-height: 1.35; }
.frame-stepper { display: grid; grid-template-columns: 32px 1fr 32px; align-items: center; gap: 5px; margin-top: 18px; }
.frame-stepper button { height: 32px; }
.frame-stepper span { color: var(--muted); font-size: .66rem; text-align: center; }
.complete-row { display: flex; gap: 9px; margin-top: 18px; padding: 11px; border: 1px solid rgba(239,189,88,.25); background: rgba(239,189,88,.05); }
.complete-row input { accent-color: var(--gold); }
.complete-row b, .complete-row small { display: block; }
.complete-row b { font-size: .7rem; }
.complete-row small { margin-top: 4px; color: var(--muted); font-size: .62rem; line-height: 1.4; }
.canvas-legend { display: grid; gap: 6px; margin-top: 12px; padding: 9px; color: var(--muted); border: 1px solid var(--line); background: rgba(0,0,0,.12); font-size: .59rem; }
.canvas-legend b { color: var(--ink); font-size: .64rem; }
.canvas-legend span { display: flex; align-items: center; gap: 7px; }
.canvas-legend i { width: 18px; height: 2px; flex: 0 0 auto; }
.legend-edge { background: var(--teal); }
.legend-pivot { background: var(--gold); }
.legend-body { height: 8px !important; background: rgba(101,184,255,.5); }
.frame-facts { margin-top: 14px; color: var(--muted); font: .64rem/1.55 Consolas, monospace; white-space: pre-line; }

.preview-heading { display: flex; align-items: start; justify-content: space-between; }
.preview-heading > span { color: var(--teal); font: .65rem Consolas, monospace; }
#livePreview { display: block; width: 100%; height: auto; margin-top: 12px; image-rendering: pixelated; border: 1px solid var(--line); background: radial-gradient(circle at 50% 65%, rgba(72,221,195,.09), transparent 45%), #071416; }
.preview-sync { margin-top: 11px; color: var(--ink); }
.preview-frame-status { min-height: 2.8em; margin: 6px 0 0; color: var(--teal); font-size: .62rem; line-height: 1.4; }
.preview-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; margin-top: 12px; }
.preview-controls label { display: grid; gap: 4px; }
.preview-controls .choice { display: flex; margin: 0; }
.preview-controls select { padding: 7px; }
#previewDyeColor { width: 100%; height: 34px; padding: 2px; }
.completion-summary { padding: 12px; color: var(--muted); font-size: .7rem; line-height: 1.55; border: 1px solid var(--line); background: rgba(0,0,0,.14); }
.completion-summary strong { color: var(--ink); }
.submit-button { width: 100%; margin-top: 12px; padding: 13px; color: #041310; border-color: var(--teal); background: var(--teal); font-weight: 800; }

dialog { width: min(470px, 90vw); padding: 0; color: var(--ink); border: 1px solid rgba(72,221,195,.38); background: #0b1b1d; box-shadow: 0 30px 90px rgba(0,0,0,.65); }
dialog::backdrop { background: rgba(0,0,0,.74); backdrop-filter: blur(5px); }
dialog form { padding: 20px; }
.dialog-heading { display: flex; justify-content: space-between; }
.dialog-heading button { width: 34px; height: 34px; }
.local-identities { display: grid; gap: 7px; margin: 18px 0; }
.local-identities button, .discord-login { display: block; padding: 11px; text-align: center; text-decoration: none; border: 1px solid var(--line); background: #102427; color: var(--ink); }
.discord-login { border-color: #6579e8; background: rgba(101,121,232,.16); }
.studio-toast { position: fixed; right: 18px; bottom: 18px; z-index: 50; max-width: 380px; padding: 12px 15px; color: var(--ink); border: 1px solid var(--teal); background: #102427; opacity: 0; transform: translateY(10px); pointer-events: none; transition: .18s ease; }
.studio-toast.show { opacity: 1; transform: none; }

@media (max-width: 1320px) {
  .studio-shell { grid-template-columns: 270px minmax(610px,1fr) 330px; }
  .editor-grid { grid-template-columns: 82px minmax(390px,1fr) 176px; }
}
