:root {
  --ink: #1a1a1a; --muted: #4b5561; --line: #c9d1da; --soft: #f4f6f9; --panel: #ffffff;
  --brand: #1f5fa8; --brand-ink: #ffffff; --danger: #b42318; --ok: #1a7f37; --focus: #ffb000;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 15px; color: var(--ink); background: #eef1f5;
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--brand); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; min-height: 36px; border: 1px solid #aab4c0; background: #fff; border-radius: 6px; white-space: nowrap; text-decoration: none; color: var(--ink); }
.btn:hover:not(:disabled) { background: var(--soft); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: #194f8c; }
.btn.danger { color: var(--danger); border-color: #e3a9a3; }
.btn.small { padding: 4px 8px; min-height: 30px; font-size: 14px; }
.btn.on { background: #e3ecf8; border-color: var(--brand); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
header.top { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: #fff; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
header.top .brand { font-weight: 700; font-size: 18px; color: var(--ink); text-decoration: none; display: flex; align-items: center; gap: 8px; }
header.top .brand .logo { width: 26px; height: 26px; border-radius: 6px; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 15px; }
header.top .spacer { flex: 1; }
.notice { padding: 10px 14px; border-radius: 6px; background: #fff8c5; border: 1px solid #d4a72c; margin: 10px 0; }
.notice.err { background: #ffebe9; border-color: #e3a9a3; }
.notice.ok { background: #dafbe1; border-color: #8fd19e; }

/* ---------- dashboard ---------- */
.dash { max-width: 1180px; margin: 0 auto; padding: 22px 18px 60px; }
.dash h1 { font-size: 24px; margin: 0 0 4px; }
.drop { border: 2px dashed #8c99a8; border-radius: 10px; background: #fff; padding: 26px; text-align: center; margin: 18px 0 26px; }
.drop.over { border-color: var(--brand); background: #eef4fc; }
.drop p { margin: 6px 0 14px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; }
.card .thumb { aspect-ratio: 16 / 9; background: #e6e9ef center / cover no-repeat; display: block; border-bottom: 1px solid var(--line); }
.card .body { padding: 10px 12px; flex: 1; }
.card h3 { margin: 0 0 4px; font-size: 16px; overflow-wrap: anywhere; }
.card h3 a { color: var(--ink); text-decoration: none; }
.card .acts { display: flex; gap: 6px; padding: 0 12px 12px; flex-wrap: wrap; }
.progress { height: 8px; background: #e3e7ec; border-radius: 4px; overflow: hidden; margin-top: 8px; }
.progress > div { height: 100%; width: 30%; background: var(--brand); animation: indet 1.2s ease-in-out infinite; }
@keyframes indet { 0% { margin-left: -30%; } 100% { margin-left: 100%; } }

/* ---------- editor ---------- */
.ed { display: grid; grid-template-columns: 210px minmax(0, 1fr) 320px; grid-template-rows: auto minmax(0, 1fr); height: 100vh; }
.ed > header { grid-column: 1 / -1; }
.ed .title-input { font-size: 17px; font-weight: 600; border: 1px solid transparent; border-radius: 6px; padding: 5px 8px; min-width: 180px; width: 30vw; background: transparent; }
.ed .title-input:hover, .ed .title-input:focus { border-color: var(--line); background: #fff; }
.savestate { font-size: 14px; color: var(--muted); min-width: 70px; }
.savestate.err { color: var(--danger); font-weight: 600; }

.strip { background: #fff; border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.strip .list { flex: 1; overflow: auto; padding: 8px; }
.strip .tools { padding: 8px; border-top: 1px solid var(--line); display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.thumbitem { display: flex; gap: 6px; align-items: flex-start; padding: 6px; border-radius: 8px; border: 2px solid transparent; cursor: pointer; margin-bottom: 4px; }
.thumbitem:hover { background: var(--soft); }
.thumbitem.sel { border-color: var(--brand); background: #eef4fc; }
.thumbitem.dragover { border-top: 3px solid var(--brand); }
.thumbitem .n { font-size: 13px; color: var(--muted); width: 18px; text-align: right; padding-top: 2px; }
.thumbitem .tbox { flex: 1; min-width: 0; }
.thumbitem .timg { aspect-ratio: 16 / 9; background: #fff center / 100% 100% no-repeat; border: 1px solid var(--line); border-radius: 4px; position: relative; overflow: hidden; }
.thumbitem .timg .q { position: absolute; inset: 0; display: grid; place-items: center; font-size: 12px; font-weight: 600; color: var(--brand); background: #f3f7fd; }
.thumbitem .tt { font-size: 12.5px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thumbitem .badges { font-size: 11px; color: var(--muted); }

.center { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #e9edf2; }
.insertbar { display: flex; gap: 6px; padding: 8px 10px; background: #fff; border-bottom: 1px solid var(--line); flex-wrap: wrap; align-items: center; }
.insertbar .sep { width: 1px; align-self: stretch; background: var(--line); margin: 0 4px; }
.insertbar svg { width: 17px; height: 17px; }
.canvaswrap { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 18px; position: relative; }
.canvaswrap .cv-stage { box-shadow: 0 2px 14px rgba(0,0,0,.16); }
.canvaswrap .cv-o { cursor: move; }
.canvaswrap .cv-o.dimmed { opacity: .28; }
.canvaswrap .cv-highlight, .canvaswrap .cv-clickbox { pointer-events: auto; }
.canvaswrap .cv-clickbox { outline: 2px dashed #8250df; background: rgba(130,80,223,.08); }
.cv-ed-label { position: absolute; left: 0; top: 0; font-size: 11px; background: #8250df; color: #fff; padding: 1px 5px; border-bottom-right-radius: 4px; pointer-events: none; }
.canvaswrap .cv-o.sel { outline: 2px solid var(--brand); outline-offset: 1px; }
.handle { position: absolute; width: 12px; height: 12px; background: #fff; border: 2px solid var(--brand); border-radius: 2px; z-index: 5; }
.handle.nw { left: -7px; top: -7px; cursor: nwse-resize; } .handle.ne { right: -7px; top: -7px; cursor: nesw-resize; }
.handle.sw { left: -7px; bottom: -7px; cursor: nesw-resize; } .handle.se { right: -7px; bottom: -7px; cursor: nwse-resize; }
.handle.n { left: calc(50% - 6px); top: -7px; cursor: ns-resize; } .handle.s { left: calc(50% - 6px); bottom: -7px; cursor: ns-resize; }
.handle.w { top: calc(50% - 6px); left: -7px; cursor: ew-resize; } .handle.e { top: calc(50% - 6px); right: -7px; cursor: ew-resize; }
.qpreview { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.empty { text-align: center; color: var(--muted); max-width: 420px; }

.timeline { background: #fff; border-top: 1px solid var(--line); height: 210px; display: flex; flex-direction: column; min-height: 0; }
.tl-head { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-bottom: 1px solid var(--line); font-size: 14px; }
.tl-body { flex: 1; overflow: auto; position: relative; }
.tl-row { display: flex; align-items: center; height: 28px; border-bottom: 1px solid #eef0f3; }
.tl-row.sel { background: #eef4fc; }
.tl-name { width: 150px; flex: none; padding: 0 8px; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.tl-lane { position: relative; flex: 1; height: 100%; }
.tl-bar { position: absolute; top: 5px; height: 18px; border-radius: 4px; background: #9fc0e8; border: 1px solid #5b8fcf; cursor: grab; font-size: 11px; padding: 0 6px; overflow: hidden; white-space: nowrap; color: #0c2d57; }
.tl-bar.open { border-right-style: dashed; background: linear-gradient(90deg, #9fc0e8 85%, #d9e7f7); }
.tl-bar .grip { position: absolute; top: 0; bottom: 0; width: 7px; cursor: ew-resize; }
.tl-bar .grip.l { left: 0; } .tl-bar .grip.r { right: 0; }
.tl-bar.audio { background: #b9e2c4; border-color: #4f9d69; color: #12391f; cursor: default; }
.tl-bar.pause { background: #d8c8f5; border-color: #8250df; color: #2c1659; }
.tl-scale { position: relative; height: 22px; margin-left: 150px; border-bottom: 1px solid var(--line); font-size: 11px; color: var(--muted); }
.tl-scale span { position: absolute; top: 4px; transform: translateX(-50%); }
.tl-end { position: absolute; top: 0; bottom: 0; width: 2px; background: #cf222e; pointer-events: none; z-index: 3; }
.tl-endlabel { position: absolute; top: 2px; font-size: 11px; color: #cf222e; transform: translateX(4px); }

.props { background: #fff; border-left: 1px solid var(--line); overflow: auto; padding: 12px 14px 40px; }
.props h2 { font-size: 16px; margin: 4px 0 12px; display: flex; align-items: center; gap: 8px; }
.props h3 { font-size: 14px; margin: 18px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.field { margin-bottom: 10px; }
.field > label, .field > .lab { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 4px; }
.field input[type=text], .field input[type=number], .field input[type=url], .field select, .field textarea { width: 100%; padding: 6px 8px; border: 1px solid #aab4c0; border-radius: 6px; background: #fff; }
.field textarea { min-height: 80px; resize: vertical; }
.field .hint { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.row4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.check { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; font-size: 14px; }
.check input { width: 17px; height: 17px; }
.color { display: flex; gap: 6px; align-items: center; }
.color input[type=color] { width: 42px; height: 32px; padding: 0; border: 1px solid #aab4c0; border-radius: 6px; background: #fff; }
.choice-row { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.choice-row input[type=text] { flex: 1; }
.audio-box { border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: var(--soft); }
.audio-box audio { width: 100%; margin-top: 6px; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #cf222e; display: inline-block; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }

.modal-back { position: fixed; inset: 0; background: rgba(20,30,45,.35); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { background: #fff; border-radius: 10px; padding: 18px 20px; width: min(520px, 94vw); max-height: 90vh; overflow: auto; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.modal h2 { margin: 0 0 14px; font-size: 19px; }
.modal .acts { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.toast-msg { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #fff; border: 1px solid var(--line); border-left: 5px solid var(--brand); padding: 10px 16px; border-radius: 6px; box-shadow: 0 6px 20px rgba(0,0,0,.18); z-index: 200; max-width: 90vw; }
.toast-msg.err { border-left-color: var(--danger); }
kbd { font-family: ui-monospace, monospace; font-size: 12.5px; background: var(--soft); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; }

/* ---------- preview ---------- */
.pv { display: grid; grid-template-columns: minmax(0, 1fr) 340px; height: 100vh; }
.pv-main { display: flex; flex-direction: column; min-height: 0; }
.pv-main #player { flex: 1; min-height: 0; }
.pv-side { background: #fff; border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.pv-side .sec { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.pv-side dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; margin: 0; font-size: 13.5px; }
.pv-side dt { color: var(--muted); }
.pv-side dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.pv-log { flex: 1; overflow: auto; font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; padding: 8px 12px; margin: 0; white-space: pre-wrap; }
.pv-log .e { color: var(--danger); }
@media (max-width: 900px) { .pv { grid-template-columns: 1fr; } .pv-side { display: none; } }

/* ---------- help ---------- */
.doc { max-width: 820px; margin: 0 auto; padding: 24px 20px 80px; line-height: 1.55; font-size: 16px; }
.doc h1 { font-size: 26px; } .doc h2 { font-size: 20px; margin-top: 30px; }
.doc table { border-collapse: collapse; width: 100%; font-size: 15px; }
.doc td, .doc th { border: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
