/* Stickman Studio - layout: CSS grid/flex only */
:root {
  --bg: #16181d;
  --panel: #1e2128;
  --panel2: #252932;
  --line: #323846;
  --text: #e6e8ee;
  --muted: #9aa3b5;
  --accent: #ff8a3d;
  --accent2: #4c9aff;
  --good: #3ecf8e;
  --danger: #ff5c5c;
  --radius: 8px;
  --tl-h: 300px;
  font-family: "Nunito", "Segoe UI", Arial, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-size: 13px; }
body { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }

.app {
  display: grid;
  height: 100vh;
  grid-template-columns: 250px minmax(0, 1fr) 300px;
  grid-template-rows: 48px minmax(0, 1fr) var(--tl-h);
  grid-template-areas: "top top top" "left center right" "tl tl tl";
}

/* top bar */
.topbar { grid-area: top; display: flex; align-items: center; gap: 14px; padding: 0 12px; background: var(--panel); border-bottom: 1px solid var(--line); min-width: 0; overflow-x: auto; }
.brand { font-weight: 900; font-size: 15px; white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.logo { color: var(--accent); font-size: 20px; }
.tb-group { display: flex; align-items: center; gap: 6px; }
.tb-spacer { flex: 1; }
.tb-label { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); white-space: nowrap; }
.tb-label input[type=number] { width: 70px; }

.btn { background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; cursor: pointer; white-space: nowrap; line-height: 1.2; }
.btn:hover { border-color: #4a5366; background: #2c313c; }
a.btn { color: inherit; text-decoration: none; display: inline-flex; align-items: center; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #1b1206; font-weight: 800; }
.btn.primary:hover { background: #ff9d5c; }
.btn.accent { background: #2f5ea8; border-color: #3d73c9; font-weight: 700; }
.btn.danger { color: var(--danger); }
.btn.icon { min-width: 32px; padding: 5px 8px; }
.btn.small { padding: 3px 8px; font-size: 12px; }
.btn.seg { border-radius: 0; }
.btn.seg:first-child { border-radius: 6px 0 0 6px; }
.btn.seg:last-child { border-radius: 0 6px 6px 0; }
.btn.on { background: var(--accent2); border-color: var(--accent2); color: #fff; font-weight: 800; }
.mode-switch { gap: 0; }

select, input[type=text], input[type=number], textarea {
  background: #12141a; border: 1px solid var(--line); border-radius: 5px; padding: 4px 6px;
}
textarea { resize: vertical; width: 100%; min-height: 64px; }
input[type=color] { width: 34px; height: 26px; padding: 0; border: 1px solid var(--line); border-radius: 5px; background: none; }
input[type=range] { width: 100%; accent-color: var(--accent); }

/* panels */
.panel { background: var(--panel); min-height: 0; overflow-y: auto; }
.left { grid-area: left; border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.right { grid-area: right; border-left: 1px solid var(--line); }
.tabs { display: grid; grid-template-columns: repeat(5, 1fr); border-bottom: 1px solid var(--line); }
.combo-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 5px; margin-bottom: 4px; }
.btn.combo { justify-content: flex-start; text-align: left; gap: 6px; }
.btn.combo.off { opacity: 0.55; }
.combo-ic { font-size: 14px; line-height: 1; }
.ss-row { display: flex; align-items: center; gap: 6px; }
.ss-row .ss-sec { width: 60px; }
.ss-row select { flex: 1; min-width: 0; }
.tab { background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 2px; font-size: 11px; cursor: pointer; color: var(--muted); font-weight: 700; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.lib { padding: 10px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; min-height: 0; }
.lib h4 { margin: 6px 0 0; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.tiles.two { grid-template-columns: repeat(2, 1fr); }
.tile { background: #f4f5f7; border: 2px solid transparent; border-radius: 8px; padding: 4px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; color: #333; font-size: 11px; font-weight: 700; }
.tile:hover { border-color: var(--accent); }
.tile.on { border-color: var(--accent2); }
.tile canvas { width: 100%; height: auto; display: block; }
.tile.dark { background: var(--panel2); color: var(--text); }
.tile[draggable=true] { cursor: grab; }
.tile-add { align-self: stretch; text-align: center; background: #2f5ea8; color: #fff; border-radius: 5px; font-size: 10px; padding: 1px 0; }
.tile-add::after { content: " Timeline"; }
.tile-add:hover { background: #3d73c9; }
.lib.drop { outline: 2px dashed var(--accent2); outline-offset: -6px; }
.drop-empty { border: 2px dashed var(--line); border-radius: 8px; padding: 26px 10px; text-align: center; color: var(--muted); }
.media-list { display: flex; flex-direction: column; gap: 8px; }
.media-item { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 8px; align-items: start; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 6px; }
.media-item[draggable=true] { cursor: grab; }
.media-item.missing { border-color: var(--danger); }
.media-item canvas, .media-th { width: 96px; height: 54px; border-radius: 4px; display: block; }
.media-missing { width: 96px; height: 54px; border-radius: 4px; background: #3b2224; color: var(--danger); display: flex; align-items: center; justify-content: center; font-size: 22px; }
.media-meta { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.media-meta b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-meta span { color: var(--muted); font-size: 11px; }
.media-meta .btnrow { gap: 4px; }
.media-meta .btn.small { padding: 2px 6px; font-size: 11px; }

/* center */
.center { grid-area: center; display: grid; grid-template-rows: minmax(0, 1fr) auto; min-width: 0; min-height: 0; }
.stage-wrap { min-height: 0; min-width: 0; display: flex; background: #0f1115; overflow: hidden; }
#stage { flex: 1; min-width: 0; min-height: 0; display: block; touch-action: none; cursor: default; }
.transport { display: flex; align-items: center; gap: 6px; padding: 6px 10px; background: var(--panel); border-top: 1px solid var(--line); flex-wrap: wrap; }
.transport .play { min-width: 44px; font-size: 14px; }
.tcode { font-variant-numeric: tabular-nums; font-weight: 800; min-width: 64px; }
.zoom-pct { font-variant-numeric: tabular-nums; font-weight: 700; min-width: 44px; text-align: center; }
.tframe { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 70px; }
.sep { width: 1px; height: 22px; background: var(--line); }
.chk { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.chk input { accent-color: var(--accent); }
.stop-only { display: none; align-items: center; gap: 8px; }
.app.stop .stop-only { display: inline-flex; }
.status { color: var(--muted); opacity: 0; transition: opacity .25s; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40%; }
.status.show { opacity: 1; color: var(--good); }

/* inspector */
.insp { display: flex; flex-direction: column; }
.insp details { border-bottom: 1px solid var(--line); }
.insp summary { padding: 9px 12px; cursor: pointer; font-weight: 800; list-style: none; display: flex; justify-content: space-between; align-items: center; }
.insp summary::after { content: "▾"; color: var(--muted); }
.insp details:not([open]) summary::after { content: "▸"; }
.insp .sec { padding: 4px 12px 12px; display: flex; flex-direction: column; gap: 8px; }
.row { display: grid; grid-template-columns: 82px 1fr auto; align-items: center; gap: 8px; }
.row > label { color: var(--muted); }
.row .val { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 38px; text-align: right; font-size: 12px; }
.row .valbox { display: flex; align-items: center; gap: 4px; }
.row .valbox .num { width: 62px; padding: 2px 4px; font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }
.row .valbox .unit { color: var(--muted); font-size: 12px; white-space: nowrap; min-width: 12px; }
.rst { background: none; border: 1px solid transparent; border-radius: 4px; color: var(--muted); font-size: 14px; line-height: 1; padding: 1px 3px; cursor: pointer; }
.rst:hover:not(:disabled) { color: var(--accent); border-color: var(--line); }
.rst:disabled { opacity: .25; cursor: default; }
.chkwrap { display: inline-flex; align-items: center; gap: 2px; min-width: 0; }
.row.full { grid-template-columns: 1fr; }
.row > select, .row > input[type=text], .row > input[type=number] { min-width: 0; width: 100%; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.btnrow { display: flex; flex-wrap: wrap; gap: 6px; }
.chips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.chips.five { grid-template-columns: repeat(5, 1fr); }
.chip { background: #f4f5f7; color: #222; border: 2px solid transparent; border-radius: 7px; padding: 2px; cursor: pointer; display: flex; flex-direction: column; align-items: center; font-size: 10px; font-weight: 700; line-height: 1.1; }
.chip:hover { border-color: var(--accent); }
.chip.on { border-color: var(--accent2); background: #dfeaff; }
.chip canvas { width: 100%; height: auto; display: block; }
.chip.text { background: var(--panel2); color: var(--text); padding: 6px 2px; font-size: 12px; }
.chip.text.on { background: var(--accent2); color: #fff; }
.muted { color: var(--muted); }
.subhead { color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; margin-top: 4px; }
.sec-flat { display: flex; flex-direction: column; gap: 6px; }
.note { color: var(--muted); font-size: 12px; line-height: 1.4; }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.empty { padding: 18px 12px; color: var(--muted); }

/* timeline */
.timeline { grid-area: tl; display: grid; grid-template-rows: auto minmax(0, 1fr); background: var(--panel); border-top: 1px solid var(--line); min-height: 0; }
.tl-bar { display: flex; align-items: center; gap: 8px; padding: 5px 10px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tl-title { font-weight: 800; }
.tl-hint { color: var(--muted); font-size: 11px; }
.tl-grid { display: grid; grid-template-columns: 170px minmax(0, 1fr); grid-template-rows: 24px minmax(0, 1fr) 14px; min-height: 0; }
.tl-corner { background: var(--panel2); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.tl-corner-b { border-bottom: 0; border-top: 1px solid var(--line); }
.tl-hbar { overflow-x: auto; overflow-y: hidden; background: var(--panel2); border-top: 1px solid var(--line); scrollbar-width: thin; scrollbar-color: #4a5366 transparent; }
.tl-hbar-in { height: 1px; }
.tl-ruler { width: 100%; height: 24px; display: block; background: var(--panel2); border-bottom: 1px solid var(--line); cursor: ew-resize; }
.tl-scroll { grid-column: 1 / span 2; display: grid; grid-template-columns: 170px minmax(0, 1fr); overflow-y: auto; overflow-x: hidden; min-height: 0; align-items: start; }
.tl-names { border-right: 1px solid var(--line); }
.tl-name { height: 24px; display: flex; align-items: center; gap: 6px; padding: 0 8px; border-bottom: 1px solid #262a33; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.tl-name.sub { padding-left: 22px; color: var(--muted); font-size: 12px; }
.tl-name.obj { font-weight: 800; }
.tl-name.sel { background: #2a3550; }
.tl-name .eye { margin-left: auto; color: var(--muted); cursor: pointer; }
.tl-name .lbl { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.tl-name.media { font-weight: 800; background: rgba(255, 255, 255, .035); border-bottom-color: #303644; cursor: default; }
.tgls { margin-left: auto; display: flex; gap: 5px; flex-shrink: 0; }
.tgl { cursor: pointer; opacity: .4; font-size: 11px; font-weight: 400; }
.tgl.on { opacity: 1; }
.tgl:hover { opacity: .85; }
.tl-canvas { width: 100%; display: block; }

/* dialogs */
.dlg { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 0; width: min(560px, 92vw); }
.dlg::backdrop { background: rgba(0, 0, 0, .55); }
.dlg-body { padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.dlg h2 { margin: 0; }
.dlg h3 { margin: 10px 0 4px; font-size: 14px; }
.dlg p { margin: 0; line-height: 1.45; }
.dlg fieldset { border: 1px solid var(--line); border-radius: 8px; display: flex; flex-direction: column; gap: 6px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; }
.radio { display: flex; gap: 6px; align-items: center; cursor: pointer; }
.progress { height: 10px; background: #12141a; border-radius: 6px; overflow: hidden; }
.progress .bar { height: 100%; width: 0; background: var(--accent); transition: width .15s; }
#dlgHelp { width: min(860px, 94vw); }
.help-cols { display: grid; grid-template-columns: 1.3fr 1fr; gap: 20px; }
.keys td { padding: 3px 8px 3px 0; }
.keys td:first-child { color: var(--accent); font-weight: 800; white-space: nowrap; }

@media (max-width: 1100px) {
  .app { grid-template-columns: 210px minmax(0, 1fr) 260px; }
}

/* layers panel */
.ly-bar { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.ly-list { display: flex; flex-direction: column; gap: 2px; margin: 4px 0 8px; }
.ly-row { display: flex; align-items: center; gap: 6px; padding: 5px 6px; border-radius: 6px; background: var(--panel2, #252932); cursor: pointer; border: 1px solid transparent; }
.ly-row:hover { border-color: var(--line); }
.ly-row.sel { border-color: #4c9aff; background: rgba(76, 154, 255, 0.16); }
.ly-row.hid .ly-name, .ly-row.hid .ly-type { opacity: 0.45; }
.ly-row.child { margin-left: 18px; }
.ly-row.dragging { opacity: 0.4; }
.ly-row.drop-above { box-shadow: inset 0 2px 0 #ff8a3d; }
.ly-row.drop-below { box-shadow: inset 0 -2px 0 #ff8a3d; }
.ly-grip { color: var(--muted); cursor: grab; font-size: 11px; letter-spacing: -2px; }
.ly-type { width: 16px; text-align: center; color: var(--muted); }
.ly-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ly-rename { flex: 1; min-width: 0; }
.ly-tag { font-size: 10px; padding: 1px 5px; border-radius: 8px; background: #3a3f4b; color: #cfd4dc; }
.ly-tag.z { background: #5f3dc4; color: #fff; }
.ly-ic { background: none; border: 0; color: var(--text, #e6e8ec); cursor: pointer; padding: 0 2px; font-size: 12px; opacity: 0.8; }
.ly-ic.off, .ly-ic.on { opacity: 1; color: #ff8a3d; }
.ly-lock:not(.on) { opacity: 0.3; }
.ly-ic:hover { opacity: 1; }


/* ---------- work-flow features (selection, kit, brand, captions, audio, versions) */
.align-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.align-grid .btn { padding: 3px 4px; font-size: 11px; }
.color-cell { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.swatches { display: flex; flex-wrap: wrap; gap: 3px; }
.swatch { width: 16px; height: 16px; border-radius: 4px; border: 1px solid rgba(255, 255, 255, .35); padding: 0; cursor: pointer; }
.swatch:hover { outline: 2px solid var(--accent); }
.brand-pal { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.brand-sw { display: inline-flex; align-items: center; gap: 2px; }
.marker-row { display: grid; grid-template-columns: 12px auto minmax(0, 1fr) auto; gap: 6px; align-items: center; }
.marker-row input { min-width: 0; }
.marker-dot { width: 10px; height: 10px; border-radius: 3px; }
.lib-search { width: 100%; background: #12141a; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
.tile-top { align-self: stretch; display: flex; justify-content: flex-end; height: 14px; margin-bottom: -4px; }
.fav { font-size: 14px; line-height: 1; color: #adb5bd; cursor: pointer; padding: 0 2px; height: 16px; }
.fav.on { color: #f59f00; }
.fav:hover { color: #f59f00; }
.tile img { width: 100%; height: auto; display: block; border-radius: 4px; }
.tile-tools { align-self: stretch; display: flex; justify-content: center; gap: 10px; font-size: 12px; }
.tile-tool { cursor: pointer; color: #555; }
.tile-tool:hover { color: var(--accent); }
.tile-tool.danger:hover { color: var(--danger); }
.sfx-list { display: flex; flex-direction: column; gap: 3px; }
.sfx-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: 6px; align-items: center; background: var(--panel2); border-radius: 6px; padding: 3px 6px; }
.sfx-row .fav { height: auto; }
.sfx-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
.cap-list { display: flex; flex-direction: column; gap: 3px; max-height: 260px; overflow-y: auto; }
.cap-row { display: grid; grid-template-columns: auto 54px 54px minmax(0, 1fr) auto; gap: 4px; align-items: center; }
.cap-row input { min-width: 0; padding: 3px 4px; font-size: 12px; }
.cap-row.on input[type=text] { border-color: var(--accent2); }
.tts-status { min-height: 1.2em; color: var(--good); }
.tts-spk { display: flex; flex-direction: column; gap: 6px; }
.ver-list { display: flex; flex-direction: column; gap: 6px; max-height: 50vh; overflow-y: auto; }
.ver-row { display: grid; grid-template-columns: 96px minmax(0, 1fr) auto; gap: 10px; align-items: center; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 6px; }
.ver-th { width: 96px; height: auto; border-radius: 4px; background: #fff; display: block; }
.ver-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ver-meta span { color: var(--muted); font-size: 12px; }
.dlg fieldset .checks { gap: 4px 10px; }

/* timeline context menu (appended to body, placed at the pointer like the Poly Craft dropdowns) */
.ctx-menu { position: fixed; z-index: 50; min-width: 220px; max-width: 320px; background: #1b1e25; border: 1px solid #3a4150; border-radius: 8px; padding: 4px; display: flex; flex-direction: column; box-shadow: 0 8px 24px rgba(0, 0, 0, .45); }
.ctx-item { background: none; border: 0; text-align: left; padding: 6px 10px; border-radius: 5px; cursor: pointer; font-size: 12px; color: var(--text); }
.ctx-item:hover:not([disabled]) { background: #2a3550; }
.ctx-item[disabled] { opacity: .35; cursor: default; }
.ctx-item.danger { color: #ff8787; }
.ctx-item.on::before { content: "✓ "; color: var(--accent2); }
.ctx-head { padding: 5px 10px 3px; font-size: 10px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.ctx-sep { height: 1px; background: var(--line); margin: 3px 4px; }
.tl-more { margin-left: auto; opacity: .35; cursor: pointer; padding: 0 3px; font-weight: 900; }
.tl-name:hover .tl-more { opacity: .9; }
.tl-name .eye ~ .tl-more { margin-left: 0; }
