:root {
  color-scheme: dark;
  --bg: #090c12;
  --panel: #121826;
  --panel-2: #172033;
  --panel-3: #1f2b42;
  --line: rgba(255,255,255,.11);
  --line-strong: rgba(255,255,255,.2);
  --text: #edf4ff;
  --muted: #9eadc4;
  --accent: #6ee7ff;
  --accent-2: #b08cff;
  --danger: #ff6f8d;
  --warn: #ffd166;
  --ok: #7cf5b6;
  --shadow: 0 20px 80px rgba(0,0,0,.35);
  --radius: 18px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: var(--bg); color: var(--text); font-family: var(--sans); }
button, input, select, textarea { font: inherit; }
button { border: 1px solid var(--line); background: linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.03)); color: var(--text); border-radius: 12px; padding: 8px 11px; cursor: pointer; transition: transform .12s ease, border-color .12s ease, background .12s ease; }
button:hover { border-color: rgba(110,231,255,.55); transform: translateY(-1px); }
button:active { transform: translateY(0); }
button.primary { border-color: rgba(110,231,255,.45); background: linear-gradient(180deg, rgba(110,231,255,.24), rgba(110,231,255,.07)); }
button.danger { border-color: rgba(255,111,141,.35); color: #ffd7df; }
button.ghost { background: transparent; }
button.small { padding: 5px 8px; border-radius: 9px; font-size: 12px; }
button.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px rgba(110,231,255,.3); }
input, select, textarea { width: 100%; background: #0b111c; color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: rgba(110,231,255,.65); box-shadow: 0 0 0 3px rgba(110,231,255,.1); }
input[type="color"] { height: 36px; padding: 3px; }
textarea { resize: vertical; min-height: 70px; font-family: var(--mono); font-size: 12px; }
label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }
.studio-root { height: 100%; display: grid; grid-template-rows: auto 1fr auto; }
.topbar { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 9px 12px; background: linear-gradient(180deg, rgba(23,32,51,.98), rgba(11,17,28,.95)); border-bottom: 1px solid var(--line); box-shadow: var(--shadow); z-index: 5; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 260px; }
.logo { width: 36px; height: 36px; border-radius: 12px; background: radial-gradient(circle at 30% 25%, #fff, var(--accent) 28%, var(--accent-2) 62%, #121826 100%); box-shadow: 0 0 35px rgba(110,231,255,.32); }
.brand-title { font-weight: 800; letter-spacing: .2px; }
.brand-subtitle { color: var(--muted); font-size: 12px; margin-top: 2px; }
.top-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; }
.top-actions .hidden-input { display: none; }
.shell { min-height: 0; display: grid; grid-template-columns: 64px minmax(0, 1fr) 360px; background: radial-gradient(circle at 50% -10%, rgba(110,231,255,.07), transparent 42%), var(--bg); }
.toolbar { display: flex; flex-direction: column; gap: 9px; padding: 10px 8px; background: rgba(11,17,28,.92); border-right: 1px solid var(--line); overflow-y: auto; }
.tool-button { width: 46px; height: 46px; display: grid; place-items: center; font-size: 16px; font-weight: 800; padding: 0; position: relative; }
.tool-button span { display: block; font-size: 9px; font-weight: 600; color: var(--muted); position: absolute; bottom: 4px; left: 0; right: 0; }
.viewport-wrap { min-width: 0; min-height: 0; position: relative; display: grid; grid-template-rows: auto 1fr; }
.viewport-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line); background: rgba(9,12,18,.75); backdrop-filter: blur(12px); z-index: 2; }
.viewport-toolbar .hint { color: var(--muted); font-size: 12px; }
.viewport-toolbar .mode { display: flex; align-items: center; gap: 8px; }
.viewport-stage { min-height: 0; position: relative; }
#viewport { width: 100%; height: 100%; display: block; background: radial-gradient(circle at 50% 30%, #141c2c, #05070b 75%); }
.overlay-card { position: absolute; left: 14px; bottom: 14px; max-width: min(520px, calc(100% - 28px)); display: grid; gap: 7px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(12,18,30,.78); backdrop-filter: blur(14px); box-shadow: var(--shadow); pointer-events: none; }
.overlay-title { font-size: 13px; font-weight: 800; }
.overlay-text { color: var(--muted); font-size: 12px; line-height: 1.45; }
.side { min-height: 0; display: grid; grid-template-rows: auto 1fr; border-left: 1px solid var(--line); background: rgba(14,20,32,.96); }
.side-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 8px; border-bottom: 1px solid var(--line); }
.side-tabs button { font-size: 12px; padding: 7px 6px; }
.side-body { overflow: auto; padding: 12px; }
.panel { border: 1px solid var(--line); background: linear-gradient(180deg, rgba(255,255,255,.045), rgba(255,255,255,.018)); border-radius: var(--radius); padding: 12px; margin-bottom: 12px; }
.panel h2, .panel h3 { margin: 0 0 10px; font-size: 14px; letter-spacing: .1px; }
.panel p { margin: 0 0 10px; color: var(--muted); line-height: 1.45; font-size: 13px; }
.panel small { color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.object-list { display: grid; gap: 6px; }
.object-row { width: 100%; text-align: left; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; padding: 9px 10px; border-radius: 12px; }
.object-row .meta { color: var(--muted); font-family: var(--mono); font-size: 11px; }
.object-row.selected { border-color: rgba(110,231,255,.7); background: rgba(110,231,255,.1); }
.kbd { font-family: var(--mono); font-size: 11px; color: var(--text); border: 1px solid var(--line); border-bottom-color: var(--line-strong); background: rgba(255,255,255,.06); border-radius: 7px; padding: 1px 5px; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { padding: 10px; border: 1px solid var(--line); border-radius: 14px; background: rgba(0,0,0,.15); }
.stat strong { display: block; font-size: 18px; }
.stat span { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }
.history-list { display: grid; gap: 5px; max-height: 190px; overflow: auto; font-size: 12px; color: var(--muted); }
.history-item { padding: 7px 8px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.03); }
.history-item.current { color: var(--text); border-color: rgba(110,231,255,.45); }
.statusbar { min-height: 32px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 6px 12px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); background: #0a0f19; }
.statusbar code { font-family: var(--mono); color: #d6e9ff; }
.badge { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 999px; padding: 4px 8px; color: var(--muted); font-size: 11px; }
.badge.ok { color: var(--ok); border-color: rgba(124,245,182,.28); }
.code-mini { font-family: var(--mono); font-size: 11px; color: #cad8ec; background: rgba(0,0,0,.25); border: 1px solid var(--line); border-radius: 10px; padding: 8px; overflow: auto; }
.toast-stack { position: fixed; right: 16px; bottom: 48px; display: grid; gap: 8px; z-index: 20; }
.toast { border: 1px solid var(--line); border-radius: 14px; background: rgba(19,27,43,.94); box-shadow: var(--shadow); padding: 10px 12px; min-width: 260px; color: var(--text); animation: toastIn .18s ease-out; }
.toast small { display: block; color: var(--muted); margin-top: 3px; }
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@media (max-width: 980px) {
  html, body { overflow: auto; }
  .studio-root { min-height: 100vh; height: auto; }
  .shell { grid-template-columns: 54px 1fr; grid-template-rows: minmax(58vh, 620px) auto; }
  .viewport-wrap { min-height: 58vh; }
  .side { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); }
  .topbar { align-items: flex-start; flex-direction: column; }
  .brand { min-width: 0; }
}
button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
button:disabled:hover { border-color: var(--line); transform: none; }
.side-tabs { grid-template-columns: repeat(auto-fit, minmax(54px, 1fr)); }
.subobject-list { display: grid; gap: 5px; max-height: 260px; overflow: auto; padding-right: 2px; }
.subobject-row { width: 100%; display: grid; grid-template-columns: auto 1fr; gap: 10px; text-align: left; align-items: center; padding: 7px 8px; border-radius: 10px; font-size: 12px; }
.subobject-row span:first-child { font-family: var(--mono); color: var(--text); min-width: 42px; }
.subobject-row span:last-child { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subobject-row.selected { border-color: rgba(255,209,102,.8); background: rgba(255,209,102,.11); }
button.tiny { padding: 4px 7px; border-radius: 8px; font-size: 11px; text-transform: capitalize; }
.mode-buttons { flex-wrap: wrap; }
.accent-panel { border-color: rgba(110,231,255,.36); background: linear-gradient(180deg, rgba(110,231,255,.08), rgba(176,140,255,.035)); }
.check-grid { display: grid; gap: 7px; }
.check-row { grid-template-columns: auto 1fr; align-items: center; gap: 8px; color: var(--text); }
.check-row input { width: auto; accent-color: var(--accent); }
.check-row span { color: var(--muted); font-size: 12px; }

.phase-card {
  border-color: rgba(255, 202, 77, 0.42);
  background: linear-gradient(180deg, rgba(255, 202, 77, 0.12), rgba(20, 28, 42, 0.78));
}

.phase-card h2 {
  color: #ffda82;
}

select[data-editing-setting] {
  width: 100%;
  margin-top: 6px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.15);
  background: #0e1624;
  color: #eaf3ff;
  padding: 8px;
}
