:root {
  --bg: #121418;
  --panel: #191c22;
  --panel-2: #20242c;
  --line: #2c313b;
  --text: #dfe3ea;
  --muted: #8a909c;
  --accent: #ffb347;
  --accent-2: #7fd1ff;
  --danger: #ff6b6b;
  --ok: #6bdc8a;
  --canvas-bg: #1d2026;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 13px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; cursor: pointer;
  transition: background .12s, border-color .12s;
}
button:hover { background: #2a2f3a; border-color: #3a414e; }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: #3a2a10; border-color: #7a5a25; color: #ffd9a3; font-weight: 600; }
button.primary:hover { background: #4a3514; }
button.danger:hover { border-color: var(--danger); color: var(--danger); }
button.mini { padding: 3px 7px; font-size: 12px; }
button.block { width: 100%; margin-top: 6px; }
button.small-btn { font-size: 12px; padding: 4px 8px; margin-top: 6px; width: 100%; }
input, select, textarea { background: #111318; border: 1px solid var(--line); border-radius: 5px; padding: 4px 6px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { width: 100%; resize: vertical; }
input[type="number"] { width: 70px; }
input[type="checkbox"] { accent-color: var(--accent); }

.topbar { height: 46px; display: flex; align-items: center; gap: 10px; padding: 0 12px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; letter-spacing: .2px; white-space: nowrap; }
.logo { color: var(--accent); }
.group { display: flex; gap: 4px; align-items: center; }
.seg { background: #111318; border-radius: 7px; padding: 2px; border: 1px solid var(--line); }
.seg button { border: none; background: transparent; padding: 4px 10px; }
.seg button.on { background: var(--panel-2); color: var(--accent); box-shadow: inset 0 0 0 1px #3a414e; }
.spacer { flex: 1; }
.chk { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; user-select: none; white-space: nowrap; }
.chk.small { font-size: 12px; color: var(--muted); margin: 6px 0; }
.api-status { font-size: 12px; color: var(--muted); padding: 3px 8px; border-radius: 10px; border: 1px solid var(--line); white-space: nowrap; }
.api-status.ok { color: var(--ok); border-color: #2f5a3d; }
.api-status.bad { color: var(--danger); border-color: #5a2f2f; }

.layout { display: grid; grid-template-columns: 250px 1fr 300px; height: calc(100% - 46px); }
.panel { background: var(--panel); overflow-y: auto; display: flex; flex-direction: column; }
.panel.left { border-right: 1px solid var(--line); }
.panel.right { border-left: 1px solid var(--line); }
.panel section { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.panel section.grow { flex: 1; }
h3 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
h3 small { text-transform: none; letter-spacing: 0; font-weight: 400; }
h3 .actions { margin-left: auto; }
.note { font-size: 12px; color: var(--muted); margin: 8px 0 0; }
.note.keys { line-height: 1.7; }
.row { display: flex; gap: 6px; margin-top: 6px; }
.row > button { flex: 1; }
details summary { cursor: pointer; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .6px; margin-bottom: 6px; }
details + details { margin-top: 8px; }

.dropzone { display: block; border: 1.5px dashed #3a414e; border-radius: 8px; padding: 12px; text-align: center; cursor: pointer; color: var(--muted); font-size: 12px; }
.dropzone b { color: var(--text); font-size: 13px; }
.dropzone:hover, body.dragging .dropzone { border-color: var(--accent); color: var(--text); }

.list { list-style: none; margin: 6px 0 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 6px; padding: 3px 6px; border-radius: 5px; cursor: pointer; white-space: nowrap; overflow: hidden; }
.list li:hover { background: var(--panel-2); }
.list li.sel { background: #3a2a10; color: #ffd9a3; }
.list li img { width: 26px; height: 26px; object-fit: contain; background: repeating-conic-gradient(#2a2e36 0 25%, #22252c 0 50%) 0 0/8px 8px; border-radius: 3px; flex: none; }
.list li .name { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.list li .tag { font-size: 10px; color: var(--accent-2); background: #16242e; padding: 1px 5px; border-radius: 8px; max-width: 80px; overflow: hidden; text-overflow: ellipsis; }
.list li .tag.none { color: var(--danger); background: #2e1616; }
.list li .ctl { display: none; gap: 2px; }
.list li:hover .ctl, .list li.sel .ctl { display: flex; }
.list li .ctl button { padding: 0 5px; font-size: 11px; line-height: 18px; }
.list li.hidden-part .name { opacity: .45; text-decoration: line-through; }
.tree li .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent-2); flex: none; }
.tree li.animated .dot { background: var(--ok); }

.center { display: grid; grid-template-rows: 1fr auto 170px; min-width: 0; min-height: 0; }
.stage { position: relative; overflow: hidden; min-height: 0; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.drop-overlay { position: absolute; inset: 12px; border: 2px dashed var(--accent); border-radius: 12px; display: none; align-items: center; justify-content: center; font-size: 20px; color: var(--accent); background: rgba(255,179,71,.06); pointer-events: none; }
body.dragging .drop-overlay { display: flex; }
.hint { position: absolute; left: 12px; bottom: 10px; font-size: 12px; color: var(--muted); background: rgba(0,0,0,.45); padding: 4px 8px; border-radius: 6px; pointer-events: none; max-width: 70%; }
.hint:empty { display: none; }

.tl-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 5px 8px; background: var(--panel); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 12px; }
.tl-bar select, .tl-bar input { padding: 2px 4px; }
.tl-bar #animSelect { min-width: 120px; }
.tl-bar input[type="number"] { width: 58px; }
.tl-bar .sep { width: 1px; height: 18px; background: var(--line); }
.tl-bar .time { font-variant-numeric: tabular-nums; min-width: 52px; color: var(--accent); }
.tl-bar label { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); }
#timeline { width: 100%; height: 100%; display: block; touch-action: none; }

.form { display: grid; gap: 6px; }
.form label { display: grid; grid-template-columns: 90px 1fr; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.form label.chk { display: flex; color: var(--text); }
.form input:not([type="checkbox"]), .form select { width: 100%; }

.props { display: grid; gap: 5px; }
.props .prow { display: grid; grid-template-columns: 70px 1fr 1fr; gap: 5px; align-items: center; font-size: 12px; color: var(--muted); }
.props .prow.one { grid-template-columns: 70px 1fr; }
.props input, .props select { width: 100%; min-width: 0; }
.props .ptitle { font-weight: 600; color: var(--text); margin-bottom: 2px; }
.props .pbtns { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 4px; }
.props .pbtns button { font-size: 12px; padding: 3px 8px; }
.props .sub { margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--line); }

.block-select { width: 100%; }
.presets { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.presets button { font-size: 11px; padding: 3px 7px; }
.presets .lbl { width: 100%; font-size: 11px; color: var(--muted); }
.ai-log { margin-top: 8px; font-size: 12px; color: var(--muted); white-space: pre-wrap; max-height: 140px; overflow-y: auto; }
.ai-log .ok { color: var(--ok); }
.ai-log .err { color: var(--danger); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: #2a2f3a; border: 1px solid #3a414e; padding: 8px 14px; border-radius: 8px; opacity: 0; pointer-events: none; transition: all .2s; max-width: 80vw; z-index: 20; }
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.err { border-color: var(--danger); color: #ffd0d0; }

.busy { position: fixed; inset: 0; background: rgba(8,9,12,.6); display: none; flex-direction: column; align-items: center; justify-content: center; gap: 12px; z-index: 30; font-size: 14px; }
.busy.show { display: flex; }
.spinner { width: 38px; height: 38px; border: 3px solid #3a414e; border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1100px) {
  .layout { grid-template-columns: 210px 1fr 260px; }
  .brand { display: none; }
}
