/* Editor layout. Desktop-first; a gate is shown below 900 px. */
html, body.editor { height: 100%; }
body.editor { display: flex; flex-direction: column; overflow: hidden; }
.sbar { gap: 12px; padding: 8px 14px; }
.sbar-mid { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.title-input { max-width: 320px; background: transparent; border: 1px solid transparent; font-weight: 600; padding: 7px 10px; border-radius: 8px; }
.title-input:hover, .title-input:focus { border-color: var(--line-2); background: var(--glass); }
.sbar-hist { display: flex; gap: 6px; }
.save-state { font-size: 12px; color: var(--text-3); }
#app { flex: 1; min-height: 0; display: flex; }
.view { flex: 1; min-height: 0; }

/* ---------- home ---------- */
.view-home { overflow: auto; display: grid; place-items: start center; padding: 40px 20px; }
.home-inner { max-width: 860px; width: 100%; text-align: center; }
.home-inner h1 { font-size: clamp(28px, 4vw, 40px); font-weight: 800; margin-bottom: 22px; }
.home-new { padding: 24px 26px 18px; text-align: left; }
.home-new .btn-row { margin-top: 4px; }
.home-new .hint { margin-top: 12px; }
.preset-chips .chip { gap: 9px; }
.chip-ratio { display: inline-block; height: 16px; border: 1.5px solid currentColor; border-radius: 3px; opacity: 0.7; }
.chip small { color: var(--text-3); font-weight: 400; }
.home-unsupported { margin: 18px 0 0; padding: 12px 16px; border: 1px solid rgba(255, 176, 32, 0.5); border-radius: 12px; background: rgba(255, 176, 32, 0.08); font-size: 14px; }
.projects { margin-top: 30px; text-align: left; }
.projects h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-3); margin-bottom: 10px; }
.project-list { display: grid; gap: 8px; }
.project-card { display: grid; grid-template-columns: 96px 1fr auto; gap: 14px; align-items: center; padding: 10px 12px; border-radius: 14px; border: 1px solid var(--line); background: var(--glass); cursor: pointer; }
.project-card:hover { border-color: var(--line-2); background: var(--panel); }
.pc-poster { width: 96px; height: 56px; border-radius: 8px; background: var(--bg-3); display: grid; place-items: center; overflow: hidden; color: var(--text-3); }
.pc-poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pc-body { min-width: 0; }
.pc-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pc-meta { font-size: 12.5px; font-family: var(--mono); }
.pc-actions { display: flex; gap: 6px; align-items: center; }

/* ---------- editor ---------- */
.view-editor { display: grid; grid-template-columns: 272px 1fr 300px; grid-template-rows: 1fr; min-height: 0; }
.library, .inspector { border-right: 1px solid var(--line); background: var(--panel); backdrop-filter: blur(14px); min-height: 0; overflow: auto; display: flex; flex-direction: column; }
.inspector { border-right: 0; border-left: 1px solid var(--line); padding: 14px 14px 30px; gap: 10px; display: block; }
.stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.preview-wrap { flex: 1; min-height: 160px; display: grid; place-items: center; padding: 12px; background: radial-gradient(ellipse at 50% 40%, rgba(255, 255, 255, 0.03), transparent 70%); position: relative; overflow: hidden; }
.preview-empty { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); max-width: 360px; padding: 18px 22px; border-radius: 14px; border: 1px dashed var(--line-2); background: color-mix(in srgb, var(--bg-2) 85%, transparent); color: var(--text-2); font-size: 14px; line-height: 1.5; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; pointer-events: none; backdrop-filter: blur(6px); }
.preview-empty svg { color: var(--accent); }
#preview { border-radius: 8px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.06); background: #000; touch-action: none; display: block; }
.controls { display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg-2) 70%, transparent); flex-wrap: wrap; }
.controls .time { font-size: 13px; margin: 0 8px; }
.controls-spacer { flex: 1; }
.controls-sep { width: 1px; height: 22px; background: var(--line-2); margin: 0 4px; }
.btn-play { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--grad); color: #fff; display: grid; place-items: center; box-shadow: 0 6px 18px rgba(124, 92, 255, 0.4); padding: 0; }
.btn-play .ico-pause { display: none; } .btn-play.playing .ico-pause { display: block; } .btn-play.playing .ico-play { display: none; }
.btn-icon.on { color: var(--accent); }

/* ---------- library ---------- */
.lib-tabs { display: flex; border-bottom: 1px solid var(--line); flex: none; }
.lib-tab { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 6px; background: none; border: 0; border-bottom: 2px solid transparent; color: var(--text-3); font-size: 13px; font-weight: 600; }
.lib-tab:hover { color: var(--text); }
.lib-tab.on { color: var(--text); border-bottom-color: var(--accent); }
.lib-body { padding: 12px; overflow: auto; flex: 1; }
.lib-actions { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.lib-empty { text-align: center; padding: 30px 10px; color: var(--text-3); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.lib-empty p { margin: 0; color: var(--text-2); }
.lib-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.lib-item { position: relative; border-radius: 12px; border: 1px solid var(--line); background: var(--glass); padding: 6px; cursor: grab; transition: 0.15s; }
.lib-item:hover { border-color: var(--line-2); background: var(--bg-3); }
.lib-item:hover .lib-item-btns { opacity: 1; }
.lib-thumb { position: relative; aspect-ratio: 16 / 10; border-radius: 8px; background: var(--bg-4); display: grid; place-items: center; overflow: hidden; color: var(--text-3); }
.lib-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lib-item.kind-audio .lib-thumb { background: linear-gradient(135deg, rgba(42, 209, 122, 0.25), rgba(25, 198, 230, 0.15)); color: #2ad17a; }
.lib-dur { position: absolute; right: 5px; bottom: 5px; font-size: 10.5px; padding: 1px 6px; border-radius: 6px; background: rgba(0, 0, 0, 0.65); color: #fff; }
.lib-used { position: absolute; left: 5px; top: 5px; width: 16px; height: 16px; border-radius: 50%; background: var(--ok); color: #fff; display: grid; place-items: center; }
.lib-name { font-size: 12.5px; font-weight: 600; margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-meta { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-item-btns { position: absolute; top: 10px; right: 10px; display: flex; gap: 4px; opacity: 0; transition: 0.15s; }
.lib-hint { margin-bottom: 10px; }
.lib-list { display: flex; flex-direction: column; gap: 8px; }
.lib-text { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--glass); text-align: left; cursor: grab; }
.lib-text:hover { border-color: var(--accent); }
.lib-text-sample { color: #fff; text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5); }
[data-theme="light"] .lib-text-sample { color: var(--text); text-shadow: none; }
.lib-text-add { color: var(--text-3); }
.lib-swatches { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.lib-swatch { aspect-ratio: 1; border-radius: 10px; border: 1px solid var(--line-2); cursor: grab; display: grid; place-items: center; position: relative; overflow: hidden; }
.lib-swatch.custom { background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); color: #fff; }
.lib-swatch.custom input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }

/* ---------- inspector ---------- */
.ins-title { display: flex; align-items: center; gap: 8px; font-size: 15px; margin-bottom: 8px; }
.ins-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.ins-meta { font-size: 11.5px; color: var(--text-3); margin-bottom: 10px; line-height: 1.5; }
.ins-sec { border: 1px solid var(--line); border-radius: 12px; background: var(--glass); margin-bottom: 8px; }
.ins-sec summary { cursor: pointer; padding: 9px 12px; font-size: 13px; font-weight: 700; color: var(--text-2); list-style: none; display: flex; align-items: center; }
.ins-sec summary::-webkit-details-marker { display: none; }
.ins-sec summary::after { content: ''; margin-left: auto; width: 7px; height: 7px; border-right: 2px solid var(--text-3); border-bottom: 2px solid var(--text-3); transform: rotate(-45deg); transition: 0.2s; }
.ins-sec[open] summary::after { transform: rotate(45deg); }
.ins-sec[open] summary { color: var(--text); }
.ins-body { padding: 2px 12px 12px; display: flex; flex-direction: column; gap: 8px; }
.ins-row { display: grid; grid-template-columns: 92px 1fr; align-items: center; gap: 8px; font-size: 13px; }
.ins-row > label { color: var(--text-2); font-weight: 600; font-size: 12.5px; }
.ins-row select, .ins-row input[type="text"] { width: 100%; }
.ins-field { display: flex; flex-direction: column; gap: 2px; }
.ins-field > label, .ins-field .field-row label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.ins-field .field-row { margin-bottom: -4px; }
.ins-size { display: flex; align-items: center; gap: 6px; }
.ins-size input { width: 70px; }
.ins-tips { margin-top: 14px; font-size: 13px; color: var(--text-2); }
.ins-tips h4 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-3); margin-bottom: 8px; }
.ins-tips ul { padding-left: 18px; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.inspector .chips .chip { padding: 4px 9px; font-size: 12px; }

/* ---------- timeline ---------- */
.timeline { height: 300px; min-height: 140px; border-top: 1px solid var(--line); background: var(--bg-2); position: relative; display: flex; flex-direction: column; resize: vertical; overflow: hidden; }
.tl-scroll { flex: 1; overflow: auto; position: relative; overscroll-behavior: contain; }
.tl-grid { position: relative; min-width: 100%; }
.tl-row { display: flex; position: relative; border-bottom: 1px solid var(--line); }
.tl-ruler-row { position: sticky; top: 0; z-index: 6; height: 26px; background: var(--bg-2); }
.tl-head { position: sticky; left: 0; z-index: 5; width: 168px; flex: none; background: var(--bg-3); border-right: 1px solid var(--line-2); display: flex; align-items: center; gap: 6px; padding: 0 8px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.tl-corner { z-index: 7; background: var(--bg-3); }
.tl-row.is-sel .tl-head { background: color-mix(in srgb, var(--bg-3) 70%, var(--accent) 30%); color: var(--text); }
.tl-kind { color: var(--text-3); display: inline-flex; }
.kind-audio .tl-kind { color: #2ad17a; }
.tl-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: text; }
.tl-head-btns { display: flex; gap: 2px; }
.tl-mini { width: 21px; height: 21px; display: inline-grid; place-items: center; border-radius: 6px; border: 1px solid transparent; background: transparent; color: var(--text-3); padding: 0; font-size: 11px; font-weight: 700; }
.tl-mini:hover { background: var(--glass); color: var(--text); border-color: var(--line); }
.tl-mini.on { color: var(--accent); background: rgba(124, 92, 255, 0.15); }
.tl-mini.mute.on { color: var(--danger); background: rgba(255, 77, 109, 0.12); }
.tl-add-head { gap: 6px; justify-content: center; }
.tl-add-head .tl-mini { width: auto; padding: 0 8px; gap: 2px; border-color: var(--line); }
.tl-add-row { height: 34px; border-bottom: 0; }
.tl-ruler { position: relative; height: 26px; flex: none; }
.tl-tick { position: absolute; top: 18px; bottom: 0; width: 1px; background: var(--line-2); }
.tl-tick.major { top: 10px; background: var(--text-3); }
.tl-tick span { position: absolute; left: 4px; top: -11px; font-size: 10.5px; color: var(--text-3); font-family: var(--mono); white-space: nowrap; }
.tl-lane { position: relative; flex: none; background: repeating-linear-gradient(90deg, transparent 0 59px, var(--line) 59px 60px); background-size: 100% 100%; }
.tl-lane.kind-audio { background-color: rgba(42, 209, 122, 0.025); }
.tl-row.is-hidden .tl-lane { opacity: 0.45; }
.tl-row.is-locked .tl-lane { background-image: repeating-linear-gradient(135deg, transparent 0 10px, rgba(255, 255, 255, 0.025) 10px 12px); }
.tl-lane-empty { flex: 1; }
.tl-clip { position: absolute; top: 4px; bottom: 4px; border-radius: 8px; overflow: hidden; background: var(--bg-4); border: 1px solid rgba(255, 255, 255, 0.14); cursor: grab; user-select: none; touch-action: none; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25); }
.tl-clip.type-video { background: #1b2234; border-color: rgba(124, 92, 255, 0.5); }
.tl-clip.type-image { background: #2a2140; border-color: rgba(255, 92, 168, 0.5); }
.tl-clip.type-audio { background: #12271e; border-color: rgba(42, 209, 122, 0.5); }
.tl-clip.type-text { background: linear-gradient(180deg, #3a2e66, #2b2250); border-color: rgba(167, 139, 255, 0.7); }
.tl-clip.type-color { background: var(--clip-color, #333); border-color: rgba(255, 255, 255, 0.3); }
.tl-clip.sel { border-color: #fff; box-shadow: 0 0 0 2px var(--accent), 0 4px 14px rgba(124, 92, 255, 0.4); z-index: 2; }
.tl-clip.dragging { opacity: 0.85; z-index: 3; cursor: grabbing; }
.tl-clip.invalid { border-color: var(--danger); box-shadow: 0 0 0 2px var(--danger); }
.tl-clip.locked { cursor: default; }
.tl-clip.is-muted .tl-clip-canvas { opacity: 0.4; }
.tl-clip-canvas { position: absolute; top: 0; left: 0; height: 100%; pointer-events: none; }
.tl-clip-label { position: absolute; left: 6px; top: 3px; right: 6px; display: flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8); pointer-events: none; white-space: nowrap; overflow: hidden; }
.tl-clip-label .ico { opacity: 0.8; flex: none; }
.tl-clip-name { overflow: hidden; text-overflow: ellipsis; }
.tl-clip.type-color .tl-clip-label { mix-blend-mode: difference; }
.tl-handle { position: absolute; top: 0; bottom: 0; width: 10px; cursor: ew-resize; z-index: 2; }
.tl-handle.l { left: 0; } .tl-handle.r { right: 0; }
.tl-handle::after { content: ''; position: absolute; top: 30%; bottom: 30%; width: 3px; border-radius: 2px; background: rgba(255, 255, 255, 0.55); left: 3px; opacity: 0; transition: 0.15s; }
.tl-clip:hover .tl-handle::after, .tl-clip.sel .tl-handle::after { opacity: 1; }
.tl-fade { position: absolute; top: 0; bottom: 0; pointer-events: none; background: linear-gradient(90deg, rgba(0, 0, 0, 0.55), transparent); }
.tl-fade.l { left: 0; } .tl-fade.r { right: 0; background: linear-gradient(270deg, rgba(0, 0, 0, 0.55), transparent); }
.tl-fade::after { content: ''; position: absolute; inset: 0; border-top: 1px solid rgba(255, 255, 255, 0.45); }
.tl-trans { position: absolute; left: 0; top: 0; bottom: 0; background: repeating-linear-gradient(135deg, rgba(25, 198, 230, 0.35) 0 4px, rgba(25, 198, 230, 0.12) 4px 8px); border-right: 1px dashed rgba(25, 198, 230, 0.9); display: grid; place-items: center; color: #fff; pointer-events: none; }
.tl-playhead { position: absolute; top: 0; width: 2px; background: var(--accent-3); z-index: 8; pointer-events: none; transform: translateX(-1px); }
.tl-playhead-knob { position: absolute; top: 0; left: -6px; width: 14px; height: 14px; background: var(--accent-3); clip-path: polygon(0 0, 100% 0, 100% 55%, 50% 100%, 0 55%); }
.tl-snapline { position: absolute; top: 0; width: 1px; background: var(--accent-2); z-index: 7; pointer-events: none; box-shadow: 0 0 6px var(--accent-2); }
.tl-dropline { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--ok); z-index: 7; pointer-events: none; }
.tl-lane.drop-over { background-color: rgba(42, 209, 122, 0.08); }

/* ---------- misc ---------- */
.drop-overlay { position: fixed; inset: 0; z-index: 80; background: rgba(124, 92, 255, 0.12); border: 3px dashed var(--accent); display: none; place-items: center; pointer-events: none; }
.drop-overlay.show { display: grid; }
.drop-overlay-inner { font-size: 22px; font-weight: 700; background: var(--bg-2); padding: 16px 28px; border-radius: 14px; border: 1px solid var(--line-2); box-shadow: var(--shadow); }
.mobile-gate { display: none; position: fixed; inset: 0; z-index: 200; background: var(--bg); place-items: center; padding: 20px; }
.mobile-gate .card { padding: 26px; max-width: 420px; text-align: center; }
.mobile-gate h2 { margin-bottom: 10px; }
@media (max-width: 900px), (max-height: 480px) { .mobile-gate { display: grid; } }
.ex-summary { font-size: 13px; color: var(--text-2); margin: 4px 0 8px; }
.ex-status { font-weight: 600; margin-bottom: 8px; }
.ex-done { display: flex; align-items: center; gap: 14px; color: var(--ok); }
.ex-done b { color: var(--text); font-size: 16px; }
.ex-done .hint { margin: 2px 0 0; }
