:root {
  color-scheme: dark;
  --bg: #0b1116;
  --panel: #121c24;
  --panel-2: #182630;
  --line: #2a3b47;
  --text: #edf7fa;
  --muted: #88a0ad;
  --green: #4ce13b;
  --green-2: #20a83b;
  --gold: #f5c94d;
  --danger: #ee655f;
  --radius: 12px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 1180px; min-height: 100vh; color: var(--text); background: radial-gradient(circle at 50% -20%, #213541 0, var(--bg) 48%); overflow: hidden; }
button, input, select { font: inherit; }
button { color: var(--text); border: 1px solid var(--line); background: #1b2a34; border-radius: 7px; cursor: pointer; transition: 140ms ease; }
button:hover { border-color: #587181; background: #243845; transform: translateY(-1px); }
button:active { transform: translateY(0); }
button.primary { color: #09220d; border-color: #66ef56; background: linear-gradient(#68ef55, #39c83f); font-weight: 800; box-shadow: 0 4px 18px #37db4b2b; }
button.ghost { background: transparent; }
button.danger { color: #ffaaa6; }
input, select { min-width: 0; color: var(--text); border: 1px solid var(--line); border-radius: 6px; outline: none; background: #0c151b; }
input:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 2px #4ce13b20; }

.auth-gate { min-width: 100vw; min-height: 100vh; display: grid; place-items: center; padding: 32px; background: radial-gradient(circle at 50% 10%, #263f4d 0, #0b1116 52%); }
.auth-card { width: min(420px, calc(100vw - 48px)); padding: 34px; border: 1px solid #334956; border-radius: 16px; background: #111c24f2; box-shadow: 0 24px 80px #000a; }
.auth-coin { width: 52px; height: 52px; display: grid; place-items: center; color: #47350b; border: 3px solid #7c611c; border-radius: 50%; background: radial-gradient(circle at 35% 28%, #fff0a0, var(--gold) 48%, #b27b13); font: 900 30px/1 Georgia, serif; }
.auth-eyebrow { color: var(--green); margin: 22px 0 7px; font-size: 10px; font-weight: 900; letter-spacing: .16em; }
.auth-card h1 { margin: 0; font-size: 25px; }
.auth-copy { color: var(--muted); margin: 10px 0 24px; font-size: 12px; line-height: 1.6; }
.auth-card label { display: block; color: #b8cbd3; margin-top: 14px; font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.auth-card input { width: 100%; height: 42px; padding: 8px 10px; margin-top: 6px; }
.auth-card button { width: 100%; height: 42px; margin-top: 20px; }
.auth-card button:disabled { cursor: wait; opacity: .65; }
.auth-status { min-height: 18px; color: var(--muted); margin: 14px 0 0; font-size: 11px; text-align: center; }
.auth-status.error { color: #ffaaa6; }

.topbar { height: 112px; display: grid; grid-template-columns: 210px minmax(660px, 1fr) auto; align-items: center; gap: 18px; padding: 0 22px; border-bottom: 1px solid var(--line); background: #0f181fef; box-shadow: 0 8px 30px #0007; position: relative; z-index: 5; }
.brand { display: flex; align-items: center; gap: 11px; }
.brand-coin { width: 40px; height: 40px; display: grid; place-items: center; color: #47350b; border: 3px solid #7c611c; border-radius: 50%; background: radial-gradient(circle at 35% 28%, #fff0a0, var(--gold) 48%, #b27b13); font: 900 24px/1 Georgia, serif; box-shadow: 0 2px 0 #080d10; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; letter-spacing: .01em; }
.brand small { color: var(--muted); margin-top: 2px; font-size: 11px; text-transform: uppercase; letter-spacing: .13em; }
.level-workflow { display: grid; gap: 9px; }
.level-manager { display: flex; align-items: end; justify-content: center; gap: 8px; }
.level-manager label { color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.level-manager select { display: block; width: 190px; height: 32px; padding: 5px 8px; margin-top: 4px; }
.level-manager button { height: 32px; padding: 5px 11px; font-size: 11px; }
#firebase-status { min-width: 86px; align-self: center; color: var(--muted); font-size: 10px; }
#firebase-status.dirty { color: var(--gold); }
#firebase-status.saved { color: #8bea82; }
#firebase-status.error { color: #ffaaa6; }
.level-fields { display: flex; align-items: center; justify-content: center; gap: 10px; }
.level-fields label { color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.level-fields input { display: block; width: 100px; height: 30px; padding: 5px 8px; margin-top: 4px; }
.level-fields label:first-child input { width: 145px; }
.level-fields input[type=color] { width: 54px; padding: 3px; }
.actions { display: flex; align-items: center; gap: 10px; }
.actions button { padding: 10px 13px; font-size: 12px; }
.account { min-width: 135px; display: grid; gap: 3px; }
.account span { max-width: 180px; color: var(--muted); font-size: 9px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account button { padding: 4px 8px; font-size: 10px; }

.workspace { height: calc(100vh - 112px); display: grid; grid-template-columns: 230px minmax(520px, 1fr) 250px; }
.panel { background: #101920dc; }
.palette { border-right: 1px solid var(--line); }
.inspector { border-left: 1px solid var(--line); }
.panel-heading { height: 53px; display: flex; align-items: center; justify-content: space-between; padding: 0 15px; border-bottom: 1px solid var(--line); }
.panel-heading span { color: #cfe1e8; font-size: 11px; font-weight: 900; letter-spacing: .14em; }
.panel-heading small { max-width: 120px; color: var(--muted); font-size: 10px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.palette-list { padding: 10px; display: grid; gap: 7px; }
.palette-item { width: 100%; min-height: 53px; display: grid; grid-template-columns: 45px 1fr; align-items: center; gap: 10px; padding: 7px; text-align: left; }
.palette-item span { display: block; }
.palette-item .name { font-size: 12px; font-weight: 800; }
.palette-item .desc { color: var(--muted); margin-top: 3px; font-size: 9px; }
.mini-icon { width: 42px; height: 36px; display: grid; place-items: center; color: var(--green); border: 1px solid #3b5361; border-radius: 6px; background: #0a1217; font-weight: 900; font-size: 18px; overflow: hidden; }
.tips { margin: 12px 10px; padding: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 8px; background: #0b1319; font-size: 10px; line-height: 1.7; }
.tips strong { color: #c9dbe2; font-size: 11px; }
kbd { padding: 1px 4px; color: #dbe9ed; border: 1px solid #40515b; border-bottom-width: 2px; border-radius: 3px; background: #1b2830; font-size: 9px; }

.stage-column { min-width: 0; display: flex; flex-direction: column; align-items: stretch; overflow: hidden; }
.stage-tools { height: 53px; flex: 0 0 53px; display: flex; align-items: center; justify-content: center; gap: 16px; color: var(--muted); border-bottom: 1px solid var(--line); background: #101a21aa; font-size: 11px; }
.stage-tools button { min-height: 30px; padding: 5px 10px; }
.tool-group { display: flex; }
.tool-group button { border-radius: 0; font-size: 18px; }
.tool-group button:first-child { border-radius: 6px 0 0 6px; }
.tool-group button:last-child { border-radius: 0 6px 6px 0; border-left: 0; }
.snap-control { display: flex; align-items: center; gap: 6px; }
.snap-control input { accent-color: var(--green); }
.snap-control select { padding: 5px; }
.canvas-shell { flex: 1; min-height: 0; padding: 18px; display: grid; place-items: center; position: relative; overflow: hidden; background-image: linear-gradient(#ffffff06 1px, transparent 1px), linear-gradient(90deg, #ffffff06 1px, transparent 1px); background-size: 24px 24px; }
#level-canvas { height: calc(100vh - 201px); width: auto; max-width: calc(100% - 30px); aspect-ratio: 9 / 16; border: 2px solid #567080; border-radius: 5px; background: #9a6268; box-shadow: 0 18px 50px #000b, 0 0 0 6px #0a1116; touch-action: none; cursor: crosshair; }
.canvas-badge { position: absolute; right: 14px; bottom: 10px; color: #6f8793; font-size: 9px; font-weight: 800; letter-spacing: .1em; }

.inspector { padding-bottom: 15px; overflow-y: auto; }
.empty-inspector { margin: 22px; color: var(--muted); text-align: center; font-size: 11px; line-height: 1.6; }
.crosshair { width: 56px; height: 56px; display: grid; place-items: center; margin: 0 auto 12px; color: #52717f; border: 1px dashed #3b515c; border-radius: 50%; font-size: 28px; }
#object-inspector { padding: 14px; }
#object-inspector label { display: block; color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
#object-inspector input, #object-inspector select { width: 100%; height: 34px; padding: 6px 8px; margin-top: 5px; }
#object-inspector .wide { margin-bottom: 12px; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px 9px; }
.inspector-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 18px; }
.inspector-actions button { height: 35px; }
.unity-note { margin: 15px; padding: 12px; border-left: 3px solid var(--green); border-radius: 4px; background: #0a1319; }
.unity-note strong { font-size: 11px; }
.unity-note p { color: var(--muted); margin: 7px 0 0; font-size: 10px; line-height: 1.5; }
.unity-note code { color: #93e9a0; }
#toast { position: fixed; left: 50%; bottom: 22px; z-index: 10; padding: 10px 16px; color: #09210d; border-radius: 6px; background: var(--green); box-shadow: 0 8px 30px #0009; font-size: 12px; font-weight: 800; opacity: 0; transform: translate(-50%, 12px); pointer-events: none; transition: 180ms ease; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-height: 720px) {
  .topbar { height: 96px; }
  .workspace { height: calc(100vh - 96px); }
  #level-canvas { height: calc(100vh - 177px); }
  .palette-list { gap: 4px; }
  .palette-item { min-height: 43px; }
  .tips { display: none; }
}
