/* HKUST VIC · Z0 Traffic Driver — motion tool (Claude · R2 v01 · 2026-11-24) */
@font-face { font-family: "Mulish Z0"; src: url(../fonts/Mulish-VF-latin.woff2) format("woff2"); font-weight: 200 1000; font-display: block; }
@font-face { font-family: "Noto Sans TC Z0"; src: url(../fonts/NotoSansTC-Light-z0.woff) format("woff"); font-weight: 100 349; font-display: block; }
@font-face { font-family: "Noto Sans TC Z0"; src: url(../fonts/NotoSansTC-Regular-z0.woff) format("woff"); font-weight: 350 599; font-display: block; }
@font-face { font-family: "Noto Sans TC Z0"; src: url(../fonts/NotoSansTC-Bold-z0.woff) format("woff"); font-weight: 600 900; font-display: block; }
@font-face { font-family: "Noto Sans SC Z0"; src: url(../fonts/NotoSansSC-Light-z0.woff) format("woff"); font-weight: 100 349; font-display: block; }
@font-face { font-family: "Noto Sans SC Z0"; src: url(../fonts/NotoSansSC-Regular-z0.woff) format("woff"); font-weight: 350 599; font-display: block; }
@font-face { font-family: "Noto Sans SC Z0"; src: url(../fonts/NotoSansSC-Bold-z0.woff) format("woff"); font-weight: 600 900; font-display: block; }

:root {
  --bg: #0e0e10; --panel: #17171a; --panel2: #1e1e22; --line: #2c2c31; --fg: #e9e7e2; --dim: #8f8c86; --accent: #e0a54a;
  --c-spawnIn: #4fae7b; --c-changeLanguage: #4f8fe0; --c-changeContent: #d9a03f; --c-spawnOut: #d0625b;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); font: 13px/1.4 "Mulish Z0", system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
button, select, input, textarea { font: inherit; color: inherit; }
button { background: var(--panel2); border: 1px solid var(--line); border-radius: 7px; padding: 5px 10px; cursor: pointer; }
button:hover { border-color: #47474f; }
button.primary { border-color: var(--accent); color: var(--accent); }
button:disabled { opacity: .4; cursor: default; }
button:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
select, input[type=number], input[type=text], textarea { background: #101013; border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; }
input[type=number] { width: 78px; font-variant-numeric: tabular-nums; }
input[type=range] { accent-color: var(--accent); }
label { color: var(--dim); }

/* ---------- layout ---------- */
#app { display: grid; height: 100vh; grid-template-columns: 230px 1fr 310px; grid-template-rows: 46px minmax(220px, 1fr) 6px var(--tl-h, 330px); grid-template-areas: "top top top" "assets preview inspector" "split split split" "timeline timeline timeline"; }
#topbar { grid-area: top; display: flex; align-items: center; gap: 8px; padding: 0 12px; border-bottom: 1px solid var(--line); background: var(--panel); }
#topbar h1 { font-size: 14px; font-weight: 700; margin: 0 10px 0 0; letter-spacing: .02em; white-space: nowrap; }
#topbar .sp { flex: 1; }
#topbar .status { color: var(--dim); font-size: 12px; white-space: nowrap; }
#assets { grid-area: assets; border-right: 1px solid var(--line); background: var(--panel); overflow: auto; }
#preview { grid-area: preview; position: relative; overflow: hidden; background: #050506; display: grid; place-items: center; }
#inspector { grid-area: inspector; border-left: 1px solid var(--line); background: var(--panel); overflow: auto; padding: 0 0 20px; }
#split { grid-area: split; cursor: row-resize; background: var(--line); }
#timeline { grid-area: timeline; display: grid; grid-template-rows: 38px 1fr; background: var(--panel); min-height: 0; }

.sec { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.sec h2 { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--dim); margin: 0 0 8px; font-weight: 700; display: flex; justify-content: space-between; align-items: center; }
.row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 5px 0; }
.row > label { min-width: 74px; }
.kv { display: grid; grid-template-columns: 80px 1fr; gap: 4px 8px; align-items: center; }
.kv b { font-weight: 600; font-variant-numeric: tabular-nums; }
.note { color: var(--dim); font-size: 12px; }
.warn { color: #f0b35a; font-size: 12px; background: rgba(240,179,90,.08); border: 1px solid rgba(240,179,90,.3); border-radius: 6px; padding: 6px 8px; margin: 6px 0; }
.err { color: #ff8a80; }

/* block list */
.blist { list-style: none; margin: 0; padding: 6px; }
.blist li { display: flex; gap: 8px; align-items: center; padding: 6px 8px; border-radius: 7px; cursor: pointer; border: 1px solid transparent; }
.blist li:hover { background: var(--panel2); }
.blist li.sel { border-color: var(--accent); background: rgba(224,165,74,.08); }
.blist .sw { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.blist .nm { font-weight: 700; }
.blist .sub { color: var(--dim); font-size: 11px; display: block; }
.lib { padding: 6px 12px 12px; }
.lib details { margin: 4px 0; }
.lib summary { cursor: pointer; color: var(--fg); }
.lib .vlist { margin: 4px 0 6px 12px; color: var(--dim); font-size: 11px; }

/* preview */
#stageBox { position: relative; }
#stage { position: absolute; left: 0; top: 0; width: 8100px; height: 1600px; transform-origin: 0 0; overflow: hidden; background: #000; isolation: isolate; }
#bg { position: absolute; inset: 0; width: 8100px; height: 1600px; display: block; }
#wall { position: absolute; inset: 0; }
.selbox { position: absolute; border: 6px solid var(--accent); border-radius: 18px; pointer-events: none; display: none; box-shadow: 0 0 0 3px rgba(0,0,0,.6); }
.hit { position: absolute; cursor: pointer; }
#previewInfo { position: absolute; left: 10px; bottom: 8px; color: var(--dim); font-size: 12px; pointer-events: none; font-variant-numeric: tabular-nums; }

/* presentation mode: wall only */
body.present #app { display: block; }
body.present #topbar, body.present #assets, body.present #inspector, body.present #split, body.present #timeline, body.present #previewInfo { display: none; }
body.present #preview { position: fixed; inset: 0; }
body.present .selbox, body.present .hit { display: none !important; }
#presentHint { position: fixed; right: 14px; top: 10px; color: rgba(255,255,255,.35); font-size: 12px; display: none; z-index: 5; }
body.present #presentHint { display: block; }
body.capture #presentHint { display: none; }

/* timeline */
#transport { display: flex; align-items: center; gap: 8px; padding: 0 10px; border-bottom: 1px solid var(--line); }
#transport .time { font-variant-numeric: tabular-nums; min-width: 128px; font-size: 13px; }
#tlBody { position: relative; overflow: auto; min-height: 0; }
#tlGrid { position: relative; }
.tl-head { position: sticky; left: 0; z-index: 3; width: 190px; background: var(--panel); border-right: 1px solid var(--line); }
.tl-row { position: absolute; left: 0; right: 0; height: 30px; border-bottom: 1px solid #222226; }
.tl-row.sel { background: rgba(224,165,74,.05); }
.tl-label { position: absolute; left: 0; width: 190px; height: 30px; padding: 6px 10px; background: var(--panel); border-right: 1px solid var(--line); z-index: 2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.tl-label .sw { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; }
.tl-row.sel .tl-label { color: var(--accent); }
#ruler { position: sticky; top: 0; z-index: 4; height: 24px; background: #141417; border-bottom: 1px solid var(--line); cursor: ew-resize; }
.tick { position: absolute; top: 0; height: 24px; border-left: 1px solid #34343a; font-size: 10px; color: var(--dim); padding-left: 3px; padding-top: 5px; }
.tick.minor { height: 8px; top: 16px; border-color: #2a2a2f; }
.clip { position: absolute; top: 4px; height: 22px; border-radius: 5px; cursor: grab; font-size: 11px; line-height: 22px; padding: 0 7px; color: #0d0d0f; font-weight: 700; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; z-index: 1; box-shadow: inset 0 0 0 1px rgba(0,0,0,.25); }
.clip.sel { box-shadow: 0 0 0 2px #fff, inset 0 0 0 1px rgba(0,0,0,.25); z-index: 2; }
.clip.bad { background-image: repeating-linear-gradient(45deg, rgba(0,0,0,.25) 0 6px, transparent 6px 12px); }
.clip .h { position: absolute; top: 0; bottom: 0; width: 7px; cursor: ew-resize; }
.clip .h.l { left: 0; } .clip .h.r { right: 0; }
.clip[data-type=spawnIn] { background: var(--c-spawnIn); }
.clip[data-type=changeLanguage] { background: var(--c-changeLanguage); }
.clip[data-type=changeContent] { background: var(--c-changeContent); }
.clip[data-type=spawnOut] { background: var(--c-spawnOut); }
#playhead { position: absolute; top: 0; width: 2px; background: #ff5a4f; z-index: 5; pointer-events: none; }
#playhead::before { content: ""; position: absolute; top: 0; left: -5px; border: 6px solid transparent; border-top-color: #ff5a4f; }
.dot-type { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px; vertical-align: -1px; }

/* ---------- block rendering (wall px) ---------- */
.block { position: absolute; visibility: hidden; }
.block.on { visibility: visible; }
.panel { position: absolute; border-radius: 80px; }
.panel .backing, .panel .fill, .panel .inner { position: absolute; inset: 0; border-radius: inherit; corner-shape: inherit; pointer-events: none; }
.vp { position: absolute; overflow: hidden; }
.cell { position: absolute; left: 0; top: 0; display: none; }
.cell.vis { display: block; }
.el { position: absolute; margin: 0; }
.tx { color: #fff; white-space: pre-wrap; word-break: normal; overflow-wrap: break-word; }
.tx.nw { white-space: pre; }
.tx .sh { position: absolute; left: 0; top: 0; width: 100%; color: transparent; pointer-events: none; }
.tx .gl { position: relative; text-shadow: none; }
.tx .ch { position: relative; }
.tx .tok { display: inline; }
.tx .sup { font-size: .6em; vertical-align: .5625em; line-height: 0; }
.im { overflow: hidden; }
.im > i { position: absolute; display: block; background-repeat: no-repeat; }
.gf { display: block; background-repeat: no-repeat; background-size: 100% 100%; }
.dt { border-radius: 50%; }
.rl { height: 1px; background: #fff; }
.gl-row { position: absolute; }
.gl-row .fill, .gl-row .inner { position: absolute; inset: 0; border-radius: inherit; }
.ct { position: absolute; left: 0; top: 0; }
.panel .backing { background: #000; }
.win { position: absolute; overflow: hidden; }
.trk { position: absolute; left: 0; top: 0; right: 0; }
.lang-layer .el { will-change: auto; }

/* ---------- editor additions ---------- */
#topbar .btn { background: var(--panel2); border: 1px solid var(--line); border-radius: 7px; padding: 5px 10px; cursor: pointer; color: var(--fg); }
#topbar input#projName { background: #101013; border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; }
#transport .sp { flex: 1; }
#transport label { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
#transport button { white-space: nowrap; }
#tlGrid { position: relative; min-width: 100%; }
#ruler { position: sticky; top: 0; }
#ruler .corner { position: sticky; left: 0; width: 190px; height: 24px; background: #141417; border-right: 1px solid var(--line); z-index: 6; float: left; padding: 4px 10px; color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
#rows { position: absolute; left: 0; top: 0; }
.tl-row { position: absolute; left: 0; }
.tl-label { position: sticky; left: 0; display: block; z-index: 3; }
.tl-label .note { font-size: 11px; }
#playhead { z-index: 2; }
.clip { z-index: 1; user-select: none; touch-action: none; }
.clip .h { z-index: 2; }
.clip .h:hover { background: rgba(255,255,255,.35); }
#hits { position: absolute; inset: 0; }
.hit:hover { outline: 4px solid rgba(255,255,255,.25); outline-offset: 4px; border-radius: 16px; }
.blist li { justify-content: flex-start; }
.blist li > span:nth-child(2) { flex: 1; min-width: 0; }
.blist .sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib summary { padding: 3px 0; }
.lib .vlist { display: flex; flex-wrap: wrap; gap: 4px; }
.vbtn { font-size: 11px; padding: 3px 7px; border-radius: 5px; }
.vbtn.on { border-color: var(--accent); color: var(--accent); }
.kv select, .kv input[type=text] { width: 100%; min-width: 0; }
.kv > span { display: flex; gap: 6px; }
.row .val { min-width: 36px; text-align: right; font-variant-numeric: tabular-nums; }
.row input[type=range] { flex: 1; }
.addrow { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin-bottom: 8px; }
.addrow button { text-align: left; font-size: 12px; }
.evlist { list-style: none; margin: 0; padding: 0; }
.evlist li { padding: 5px 7px; border-radius: 6px; cursor: pointer; border: 1px solid transparent; display: flex; align-items: center; gap: 2px; flex-wrap: wrap; font-size: 12px; }
.evlist li:hover { background: var(--panel2); }
.evlist li.sel { border-color: var(--accent); }
.evlist li.bad { text-decoration: line-through; text-decoration-color: rgba(255,138,128,.6); }
.evlist .tm { margin-left: auto; color: var(--dim); font-variant-numeric: tabular-nums; }
.evlist .err, .evlist .wn { margin-left: 4px; font-weight: 800; }
.evlist .wn { color: #f0b35a; }
.evedit { background: rgba(255,255,255,.02); }
button.danger { border-color: rgba(208,98,91,.6); color: #ff9a92; }
.okbox { background: rgba(79,174,123,.07); border: 1px solid rgba(79,174,123,.3); border-radius: 6px; padding: 6px 8px; margin: 6px 0; }
.warn ul, .okbox ul { margin: 4px 0 0; padding-left: 16px; }
.tlab { display: block; margin: 8px 0 2px; font-size: 11px; }
textarea { width: 100%; resize: vertical; font-size: 12px; }
.keys { line-height: 1.7; }
.err { color: #ff8a80; }
#wall { z-index: 1; }
#hits { z-index: 2; }
.selbox { z-index: 3; }
#wall.warm .block:not(.on) { visibility: visible; opacity: .002; }
#wall.warm .cell:not(.vis) { display: block; opacity: .002; }
/* inspector runs full height on the right; the timeline shows all 12 rows at 1080p */
#app { grid-template-areas: "top top top" "assets preview inspector" "split split inspector" "timeline timeline inspector"; grid-template-rows: 46px minmax(200px, 1fr) 6px var(--tl-h, 440px); }

/* ---------- v02: background track, selected range, export dialog ---------- */
#timeline { grid-template-rows: auto 1fr; }
#transport { flex-wrap: wrap; padding: 5px 10px; row-gap: 5px; }
.rangeCtl { display: flex; align-items: center; gap: 5px; padding: 2px 8px; border: 1px solid var(--line); border-radius: 8px; }
.rangeCtl.on { border-color: rgba(120,190,255,.55); background: rgba(80,150,255,.07); }
.rangeCtl input[type=number] { width: 66px; }
.rangeCtl #rDur { font-weight: 600; font-variant-numeric: tabular-nums; color: #9fd0ff; min-width: 120px; }
.rangeCtl button { padding: 3px 7px; }
.clip[data-type=bgIn] { background: linear-gradient(90deg, rgba(201,145,63,.25), #c9913f); color: #1a1205; }
.clip[data-type=bgOut] { background: linear-gradient(90deg, #4f6fd0, rgba(79,111,208,.25)); color: #fff; }
.tl-row.bg-row { border-bottom: 1px solid #34343a; background: rgba(255,255,255,.015); }
.rng { position: absolute; top: 0; height: 24px; background: rgba(90,160,255,.28); border-left: 2px solid #7fbfff; border-right: 2px solid #7fbfff; z-index: 5; cursor: grab; color: #dff0ff; font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.rng span { pointer-events: none; white-space: nowrap; overflow: hidden; }
.rh { position: absolute; top: 0; width: 10px; height: 24px; cursor: ew-resize; }
.rh.l { left: -6px; } .rh.r { right: -6px; }
.rh::after { content: ""; position: absolute; left: 3px; top: 3px; width: 4px; height: 18px; border-radius: 2px; background: #9fd0ff; }
.rngShade { position: absolute; background: rgba(90,160,255,.08); border-left: 1px solid rgba(127,191,255,.6); border-right: 1px solid rgba(127,191,255,.6); pointer-events: none; z-index: 1; }
.kv.bgt { margin-top: 8px; padding: 6px; border-radius: 6px; }
.kv.bgt.hl { outline: 1px solid var(--accent); background: rgba(224,165,74,.06); }
.kv.bgt input[type=number] { width: 72px; }
.dlg { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: grid; place-items: center; z-index: 100; }
.dlg[hidden] { display: none; }
.dlg-box { width: min(560px, calc(100vw - 32px)); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.dlg-box h2 { margin: 0 0 4px; font-size: 16px; }
.dlg-box .kv { grid-template-columns: 110px 1fr; margin: 10px 0; }
.dlg-box .kv select, .dlg-box .kv input { width: 100%; }
.xprog { height: 8px; border-radius: 4px; background: #101013; border: 1px solid var(--line); overflow: hidden; margin-top: 10px; }
.xprog i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #4f8fe0, #7fd0ff); transition: width .2s; }
.xmsg { margin: 8px 0; font-size: 13px; }
.xmsg.err { color: #ff9a92; } .xmsg.ok { color: #9be3b6; }
.xmsg code { display: block; margin: 6px 0; padding: 6px 8px; background: #0c0c0e; border: 1px solid var(--line); border-radius: 6px; color: #e9e7e2; font-family: ui-monospace, Menlo, monospace; font-size: 12px; white-space: pre-wrap; word-break: break-all; }
.xmsg a { color: #8fd0ff; }
.dlg-btns { margin-top: 10px; }
.dlg-btns .sp { flex: 1; }
