:root {
  --bg: #111215; --panel: #191b20; --panel2: #1f2228; --line: #2b2f37; --line2: #363b45;
  --text: #e7e8eb; --muted: #8d929c; --accent: #d97757; --accent2: #e8916f;
  --video: #3d6fd6; --image: #8a5cd6; --text-c: #c9922e; --audio: #2c9a6a;
  --hdr: 168px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 13px/1.4 "Segoe UI", system-ui, -apple-system, sans-serif; overflow: hidden; }
body { display: flex; flex-direction: column; }
button, .btn { font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--line2);
  border-radius: 6px; padding: 5px 10px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
button:hover, .btn:hover { border-color: #4a505c; background: #262a31; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover, .btn.primary:hover { background: var(--accent2); }
button.small { padding: 2px 8px; font-size: 12px; }
button.danger:hover { border-color: #c0504d; color: #ff8a86; }
button:disabled { opacity: .45; cursor: default; }
input, select, textarea { font: inherit; color: var(--text); background: #121418; border: 1px solid var(--line2);
  border-radius: 5px; padding: 4px 6px; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
input[type=range] { padding: 0; accent-color: var(--accent); }
input[type=checkbox] { accent-color: var(--accent); }
input[type=color] { padding: 1px 2px; height: 26px; width: 44px; }
code { background: #23262d; padding: 0 4px; border-radius: 3px; font-size: 12px; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }
svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

#topbar { height: 46px; flex: none; display: flex; align-items: center; gap: 8px; padding: 0 12px;
  background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; letter-spacing: .3px; display: flex; align-items: center; gap: 8px; }
.logo { width: 18px; height: 18px; border-radius: 5px; background: linear-gradient(135deg, var(--accent), #b9573a); }
.projtitle { color: var(--muted); margin-left: 8px; }
.sync { font-size: 12px; color: var(--muted); margin-right: 6px; display: flex; align-items: center; gap: 6px; }
.sync::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #777; }
.sync.ok::before { background: #3fbf7f; box-shadow: 0 0 6px #3fbf7f; }
.sync.bad::before { background: #e0524d; }
.sync.warn::before { background: #e8b13c; }

#workspace { flex: 1; min-height: 180px; display: grid; grid-template-columns: 330px 1fr 300px; }
.lpane { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* chat */
#chatLog { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.chat-intro { color: var(--muted); font-size: 12.5px; padding: 4px 2px; }
.chat-intro b { color: var(--text); font-weight: 600; }
.chat-intro ul { margin: 6px 0 0; padding-left: 18px; }
.chat-intro li { margin: 3px 0; cursor: pointer; }
.chat-intro li:hover { color: var(--accent2); }
.msg { max-width: 92%; padding: 7px 10px; border-radius: 10px; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: #3a2a22; border: 1px solid #5a3b2c; border-bottom-right-radius: 3px; }
.msg.assistant { align-self: flex-start; background: var(--panel2); border: 1px solid var(--line2); border-bottom-left-radius: 3px; }
.msg.error { border-color: #7a3533; background: #2a1919; }
.msg code { font-size: 11.5px; }
.msg .t + .t { margin-top: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 4px; }
.chips:empty { display: none; }
.chip { font-size: 11px; color: var(--muted); background: #15171b; border: 1px solid var(--line2); border-radius: 10px; padding: 1px 7px; }
.chip.edit { color: #f0a383; border-color: #5a3b2c; }
.msg .login { margin-top: 8px; }
#chatStatus { display: flex; align-items: center; gap: 8px; padding: 6px 12px; color: var(--accent2); font-size: 12px; border-top: 1px solid var(--line); }
.spinner { width: 12px; height: 12px; border: 2px solid #5a3b2c; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#chatBox { border-top: 1px solid var(--line); padding: 8px; display: flex; flex-direction: column; gap: 6px; }
#chatInput { resize: none; width: 100%; min-height: 62px; }
.chat-btns { display: flex; align-items: center; gap: 6px; }
.panel { background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
#leftPanel { border-right: 1px solid var(--line); }
#rightPanel { border-left: 1px solid var(--line); }
.panel-title { display: flex; align-items: center; gap: 6px; padding: 8px 10px; font-weight: 600;
  border-bottom: 1px solid var(--line); }
.hint { padding: 8px 10px; font-size: 11.5px; color: var(--muted); border-top: 1px solid var(--line); }

#mediaList { flex: 1; overflow-y: auto; padding: 6px; display: flex; flex-direction: column; gap: 4px; }
#mediaList .empty { color: var(--muted); padding: 14px 6px; text-align: center; }
.media-item { display: flex; gap: 8px; align-items: center; padding: 5px; border-radius: 6px; cursor: grab;
  border: 1px solid transparent; user-select: none; }
.media-item:hover { background: var(--panel2); border-color: var(--line2); }
.media-item.bad, .media-item.missing { opacity: .55; cursor: default; }
.thumb { width: 64px; height: 38px; flex: none; border-radius: 4px; background: #0c0d10; overflow: hidden;
  display: flex; align-items: center; justify-content: center; color: var(--audio); }
.thumb video, .thumb img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.thumb svg { width: 20px; height: 20px; }
.meta { min-width: 0; }
.mname { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msub { font-size: 11px; color: var(--muted); }

#viewer { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #0b0c0e; }
#stageWrap { flex: 1; min-height: 0; position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; }
#stage { background: #000; box-shadow: 0 0 0 1px #24272e; touch-action: none; }
#emptyState { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; color: var(--muted); pointer-events: none; gap: 4px; }
#transport { flex: none; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 7px;
  border-top: 1px solid var(--line); background: var(--panel); }
#transport button { min-width: 34px; justify-content: center; }
#transport .play { min-width: 46px; }
.tc { font-variant-numeric: tabular-nums; font-family: Consolas, "Cascadia Mono", monospace; margin-left: 10px; }

.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; border: 0; border-radius: 0; background: transparent; padding: 9px; color: var(--muted);
  border-bottom: 2px solid transparent; justify-content: center; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.badge { background: var(--accent); color: #fff; border-radius: 9px; padding: 0 6px; font-size: 11px; }
.tabpane { flex: 1; overflow-y: auto; padding: 10px 12px 20px; }

.ins-title { font-weight: 600; font-size: 14px; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; text-transform: capitalize; }
.dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.dot.video { background: var(--video); } .dot.image { background: var(--image); }
.dot.text { background: var(--text-c); } .dot.audio { background: var(--audio); }
.group { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 8px; }
.gtitle { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin-bottom: 6px; }
.f { display: grid; grid-template-columns: 92px 1fr; align-items: center; gap: 8px; margin-bottom: 6px; }
.f .fl { color: var(--muted); font-size: 12px; }
.f textarea { resize: vertical; min-height: 54px; }
.f.wide { grid-template-columns: 1fr; }
.rng { display: grid; grid-template-columns: 1fr 58px; gap: 6px; align-items: center; }
.copt { display: flex; gap: 6px; align-items: center; }
.btnrow { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.src { font-size: 11.5px; color: var(--muted); word-break: break-all; margin-top: 8px; }
.kbd { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; font-size: 12px; color: var(--muted); }
.kbd b { color: var(--text); font-weight: 500; font-family: Consolas, monospace; font-size: 11.5px; }
.mk-list div { display: flex; gap: 8px; padding: 3px 4px; border-radius: 4px; cursor: pointer; }
.mk-list div:hover { background: var(--panel2); }

.act-intro { color: var(--muted); font-size: 12px; margin-bottom: 10px; }
.act { border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 6px; padding: 7px 9px; margin-bottom: 7px; background: var(--panel2); }
.act.err { border-left-color: #e0524d; }
.act .when { font-size: 11px; color: var(--muted); }
.act .note { margin-top: 3px; }

#splitter { height: 5px; flex: none; cursor: row-resize; background: var(--line); }
#splitter:hover { background: var(--accent); }

#timelineArea { height: 300px; flex: none; display: flex; flex-direction: column; background: var(--panel); min-height: 120px; }
#tlToolbar { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.sep { width: 1px; height: 20px; background: var(--line2); margin: 0 4px; }
.chk, .zoom { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.zoom input { width: 140px; }

#tlScroll { flex: 1; overflow: auto; position: relative; background: #141519; }
#tlInner { position: relative; min-height: 100%; }
#rulerRow { position: sticky; top: 0; z-index: 8; display: flex; height: 28px; background: var(--panel); border-bottom: 1px solid var(--line); }
#rulerRow .corner { position: sticky; left: 0; width: var(--hdr); flex: none; background: var(--panel); border-right: 1px solid var(--line); z-index: 9; }
#ruler { position: relative; flex: none; cursor: col-resize; user-select: none; }
.tick { position: absolute; bottom: 0; width: 1px; height: 6px; background: #4a4f5a; }
.tick.major { height: 12px; background: #6b717d; }
.tick span { position: absolute; left: 4px; bottom: 9px; font-size: 10.5px; color: var(--muted); white-space: nowrap; font-family: Consolas, monospace; }
.marker { position: absolute; top: 0; height: 14px; transform: translateX(-5px); cursor: grab; z-index: 2; }
.marker::before { content: ""; display: block; width: 10px; height: 12px; background: var(--mc, #f5c542);
  clip-path: polygon(0 0, 100% 0, 100% 65%, 50% 100%, 0 65%); }
.marker span { position: absolute; left: 13px; top: -1px; font-size: 10.5px; color: var(--mc, #f5c542); white-space: nowrap; pointer-events: none; }
.marker.sel::before { outline: 2px solid #fff; }
#phHead { position: absolute; top: 0; bottom: 0; width: 0; z-index: 3; pointer-events: none; }
#phHead::before { content: ""; position: absolute; left: -6px; bottom: 0; width: 12px; height: 12px; background: var(--accent);
  clip-path: polygon(0 0, 100% 0, 100% 50%, 50% 100%, 0 50%); }

#rows { position: relative; }
.row { display: flex; height: 58px; border-bottom: 1px solid #22252b; }
.row.audio { height: 46px; }
.row.drop .lane { background: rgba(217,119,87,.08); }
.hdr { position: sticky; left: 0; z-index: 6; width: var(--hdr); flex: none; background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; justify-content: center; gap: 3px; padding: 0 8px; }
.tname { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; cursor: text; }
.tbtns { display: flex; gap: 3px; }
.tb { padding: 2px 5px; border-radius: 4px; background: transparent; border-color: transparent; color: var(--muted); }
.tb:hover { background: var(--panel2); }
.tb.on { color: #ffb36b; background: #3a2a1d; }
.lane { position: relative; flex: 1; }
.row.locked .lane { background: repeating-linear-gradient(135deg, transparent 0 8px, rgba(255,255,255,.025) 8px 16px); }
.clip { position: absolute; top: 4px; bottom: 4px; border-radius: 5px; overflow: hidden; cursor: grab;
  color: #fff; font-size: 11.5px; display: flex; align-items: flex-start; padding: 3px 8px; user-select: none;
  border: 1px solid rgba(255,255,255,.18); box-shadow: inset 0 -14px 18px -14px rgba(0,0,0,.35); }
.clip.video { background: var(--video); } .clip.image { background: var(--image); }
.clip.text { background: var(--text-c); } .clip.audio { background: var(--audio); }
.clip.sel { outline: 2px solid #fff; outline-offset: -1px; z-index: 2; }
.clip.flash { animation: flash 1.2s ease-in-out 2; }
@keyframes flash { 50% { box-shadow: 0 0 0 3px var(--accent), 0 0 16px var(--accent); } }
.clip .lbl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; text-shadow: 0 1px 2px rgba(0,0,0,.4); }
.clip .h { position: absolute; top: 0; bottom: 0; width: 7px; cursor: ew-resize; z-index: 1; }
.clip .h.l { left: 0; } .clip .h.r { right: 0; }
.clip .h:hover { background: rgba(255,255,255,.35); }
.clip .fade { position: absolute; top: 0; bottom: 0; pointer-events: none; background: rgba(0,0,0,.28); }
.clip .fade.in { left: 0; clip-path: polygon(0 0, 100% 0, 0 100%); }
.clip .fade.out { right: 0; clip-path: polygon(0 0, 100% 0, 100% 100%); }
#mlines { position: absolute; inset: 28px 0 0 0; pointer-events: none; z-index: 1; }
.mline { position: absolute; top: 0; bottom: 0; width: 1px; opacity: .45; }
#playhead { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--accent); z-index: 5; pointer-events: none; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: #2a2d34; border: 1px solid var(--line2);
  padding: 8px 14px; border-radius: 8px; opacity: 0; pointer-events: none; transition: .2s; z-index: 50; max-width: 70vw; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.claude { border-color: var(--accent); }
#toast.warn { border-color: #e8b13c; }

.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 40; }
.modal { background: var(--panel); border: 1px solid var(--line2); border-radius: 10px; padding: 18px 20px; width: min(420px, 92vw); }
.modal h3 { margin: 0 0 8px; }
.bar { height: 8px; background: #0f1013; border-radius: 4px; overflow: hidden; margin: 10px 0; }
#exportBar { height: 100%; width: 0; background: var(--accent); }
.modal-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }

/* ================= premium theme: gradient backdrop + glass panels ================= */
:root {
  --grad: linear-gradient(135deg, #f4a77f 0%, #e07a55 40%, #b44b86 100%);
  --glass: rgba(24, 22, 34, .55); --glass-solid: rgba(22, 20, 31, .94);
  --edge: rgba(255,255,255,.09); --edge2: rgba(255,255,255,.16);
  --blur: blur(22px) saturate(160%);
  --line: rgba(255,255,255,.08); --line2: rgba(255,255,255,.13);
  --panel2: rgba(255,255,255,.06);
}
html { background: #0a0a10; } body { background: transparent; }
.bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none;
  background: radial-gradient(1100px 650px at 0% 0%, #2a1630 0%, transparent 60%),
              radial-gradient(1000px 700px at 100% 20%, #13203f 0%, transparent 60%),
              radial-gradient(900px 600px at 50% 110%, #2b1410 0%, transparent 60%), #0a0a10; }
.blob { position: absolute; border-radius: 50%; filter: blur(100px); will-change: transform; }
.b1 { width: 520px; height: 520px; left: -140px; top: -120px; background: #e07a55; opacity: .45; animation: drift1 24s ease-in-out infinite alternate; }
.b2 { width: 620px; height: 620px; right: -200px; top: 0; background: #6d4bd6; opacity: .35; animation: drift2 28s ease-in-out infinite alternate; }
.b3 { width: 520px; height: 520px; left: 35%; bottom: -260px; background: #c2477f; opacity: .32; animation: drift1 32s ease-in-out infinite alternate-reverse; }
@keyframes drift1 { to { transform: translate(120px, 80px) scale(1.12); } }
@keyframes drift2 { to { transform: translate(-140px, 110px) scale(.92); } }
@media (prefers-reduced-motion: reduce) { .blob { animation: none; } }

/* glass surfaces */
#topbar, .panel, #timelineArea, #transport {
  background: var(--glass); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05);
}
#topbar { border-bottom: 1px solid var(--edge); }
#leftPanel { border-right: 1px solid var(--edge); } #rightPanel { border-left: 1px solid var(--edge); }
#viewer { background: rgba(0,0,0,.28); }
#stage { box-shadow: 0 0 0 1px rgba(255,255,255,.08), 0 24px 60px rgba(0,0,0,.55); border-radius: 4px; }
#transport { border-top: 1px solid var(--edge); }
#splitter { background: rgba(255,255,255,.06); }
#splitter:hover { background: var(--grad); }
#tlScroll { background: rgba(8,8,14,.35); }
#rulerRow, #rulerRow .corner, .hdr { background: var(--glass-solid); }   /* stay opaque so clips scroll under them */
.row { border-bottom-color: rgba(255,255,255,.05); }

/* controls */
button, .btn { background: rgba(255,255,255,.06); border-color: var(--edge); border-radius: 8px; transition: .15s; }
button:hover, .btn:hover { background: rgba(255,255,255,.11); border-color: var(--edge2); }
button.primary, .btn.primary { background: var(--grad); border: 1px solid rgba(255,255,255,.22); color: #fff; font-weight: 600;
  box-shadow: 0 6px 18px rgba(224,122,85,.32), inset 0 1px 0 rgba(255,255,255,.3); }
button.primary:hover, .btn.primary:hover { background: var(--grad); filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: rgba(255,255,255,.07); border-color: var(--edge); }
input, select, textarea { background: rgba(0,0,0,.28); border-color: var(--edge); border-radius: 7px; }
input:focus, select:focus, textarea:focus { border-color: rgba(240,163,131,.7); box-shadow: 0 0 0 3px rgba(224,122,85,.16); }
.logo { background: var(--grad); box-shadow: 0 4px 14px rgba(224,122,85,.45), inset 0 1px 0 rgba(255,255,255,.4); }
.tabs button.active { border-bottom-color: transparent; background: linear-gradient(to top, rgba(224,122,85,.16), transparent 70%);
  box-shadow: inset 0 -2px 0 #e8825e; }
.badge { background: var(--grad); }

/* chat bubbles */
.msg.user { background: linear-gradient(135deg, rgba(224,122,85,.32), rgba(180,75,134,.26)); border-color: rgba(240,163,131,.3); }
.msg.assistant { background: rgba(255,255,255,.05); border-color: var(--edge); backdrop-filter: blur(10px); }
.chip { background: rgba(0,0,0,.3); border-color: var(--edge); }

/* clips: glossy gradients */
.clip { border: 1px solid rgba(255,255,255,.22); box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 4px 12px rgba(0,0,0,.3); }
.clip.video { background: linear-gradient(180deg, #5b8cf0, #3559c4); }
.clip.image { background: linear-gradient(180deg, #a47ef0, #6d48c6); }
.clip.text  { background: linear-gradient(180deg, #f0b452, #c98422); }
.clip.audio { background: linear-gradient(180deg, #3fc08a, #23845a); }
.clip.sel { outline: 2px solid #fff; box-shadow: 0 0 0 4px rgba(224,122,85,.35), 0 6px 18px rgba(0,0,0,.4); }
#playhead { background: linear-gradient(180deg, #f4a77f, #b44b86); width: 2px; box-shadow: 0 0 10px rgba(224,122,85,.6); }

/* audio */
.clip canvas.wave { position: absolute; left: 0; top: 50%; transform: translateY(-50%); pointer-events: none; opacity: .8; }
.clip canvas.wave.half { top: auto; bottom: 2px; transform: none; opacity: .55; }
.clip canvas.wave.muted { opacity: .22; }
.clip.audio .lbl { position: relative; z-index: 1; text-shadow: 0 1px 3px rgba(0,0,0,.7); }
.meter { width: 90px; height: 8px; border-radius: 4px; background: rgba(0,0,0,.4); border: 1px solid var(--edge); overflow: hidden; margin-left: 6px; }
.meter i { display: block; height: 100%; width: 0; border-radius: 4px; background: linear-gradient(90deg, #3fc08a 0%, #3fc08a 65%, #f0b452 85%, #ff5a4e 100%); background-size: 90px 100%; }
.meter.clip { box-shadow: 0 0 0 1px #ff5a4e; }
#btnLoop.on { background: var(--grad); color: #fff; }
.tb.solo { font-weight: 700; font-size: 11px; min-width: 22px; justify-content: center; }
.tb.solo.on { color: #1b1300; background: #f5c542; }
#btnRecord { color: #ff8a80; }
#btnRecord.rec { background: #d93a30; color: #fff; border-color: #ff7b72; animation: recpulse 1.2s ease-in-out infinite; }
@keyframes recpulse { 50% { box-shadow: 0 0 0 4px rgba(217,58,48,.35); } }

/* import + fonts */
.importbar { display: flex; gap: 6px; padding: 8px 10px 0; }
.importbar button { flex: 1; justify-content: center; }
.watchbox { display: flex; align-items: center; gap: 8px; margin: 8px 10px 0; padding: 6px 8px; border-radius: 8px; background: rgba(255,255,255,.05); border: 1px solid var(--edge); font-size: 12px; }
.watchbox .wname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.watchbox b { color: var(--text); font-weight: 600; }
.wdot { width: 8px; height: 8px; border-radius: 50%; background: #888; flex: none; }
.wdot.on { background: #3fc08a; box-shadow: 0 0 8px #3fc08a; animation: recpulse 2s infinite; }
.autoplace { display: flex; align-items: center; gap: 7px; padding: 8px 12px 2px; font-size: 12px; color: var(--muted); cursor: pointer; }
.fontbtn { width: 100%; justify-content: space-between; font-size: 15px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.fontbtn::after { content: "▾"; font-family: "Segoe UI"; font-size: 11px; color: var(--muted); }
.fontpop { position: fixed; z-index: 60; width: 280px; height: 370px; display: flex; flex-direction: column; border-radius: 12px; overflow: hidden;
  background: rgba(24,22,34,.96); border: 1px solid var(--edge2); box-shadow: 0 24px 60px rgba(0,0,0,.55); backdrop-filter: var(--blur); }
.fontpop .fsearch { margin: 8px; width: auto; }
.flist { flex: 1; overflow-y: auto; padding: 0 6px 8px; }
.fgroup { font-size: 10.5px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); padding: 10px 8px 4px; font-family: "Segoe UI"; }
.fitem { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 6px 9px; font-size: 18px; border-radius: 7px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fitem:hover { background: rgba(255,255,255,.08); } .fitem.on { background: rgba(224,122,85,.22); }
.flocal { display: block; width: calc(100% - 4px); margin: 10px 2px 4px; justify-content: center; font-size: 12px; }
.stylebtns { display: flex; gap: 4px; flex-wrap: wrap; }
.sbtn { min-width: 32px; justify-content: center; padding: 4px 8px; font-weight: 700; }
.sbtn.on { background: var(--grad); color: #fff; border-color: transparent; }

/* chat attach + web */
.attached { display: flex; flex-wrap: wrap; gap: 5px; }
.achip { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; padding: 3px 8px; border-radius: 99px; background: rgba(255,255,255,.07); border: 1px solid var(--edge); max-width: 100%; }
.achip b { cursor: pointer; color: var(--muted); font-weight: 700; } .achip b:hover { color: #ff8a80; }
.attachwrap { position: relative; }
.attachmenu { position: absolute; bottom: calc(100% + 6px); left: 0; z-index: 20; min-width: 170px; padding: 5px; border-radius: 10px;
  background: rgba(24,22,34,.97); border: 1px solid var(--edge2); box-shadow: 0 16px 40px rgba(0,0,0,.5); display: flex; flex-direction: column; }
.attachmenu button { border: 0; background: transparent; justify-content: flex-start; padding: 7px 10px; }
.attachmenu button:hover { background: rgba(255,255,255,.08); }
.fulltog.on { background: linear-gradient(135deg, #f4a77f, #b44b86); color: #fff; border-color: transparent; box-shadow: 0 0 12px rgba(224,122,85,.4); }
.webtog.on { background: linear-gradient(135deg, #3fa7d6, #6a48e0); color: #fff; border-color: transparent; }

/* background tasks + transcript */
.taskpanel { position: fixed; left: 16px; bottom: 16px; z-index: 45; width: 320px; padding: 12px 14px; border-radius: 14px; display: flex; flex-direction: column; gap: 4px;
  background: rgba(28,26,38,.9); border: 1px solid var(--edge2); backdrop-filter: var(--blur); box-shadow: 0 20px 50px rgba(0,0,0,.5); font-size: 12.5px; }
.taskpanel b { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.taskpanel span { color: var(--muted); }
.tbar { height: 5px; border-radius: 4px; background: rgba(255,255,255,.08); overflow: hidden; margin-top: 4px; }
.tbar i { display: block; height: 100%; background: var(--grad); transition: width .3s; }
.taskpanel.indet .tbar i { width: 35% !important; animation: indet 1.2s ease-in-out infinite; }
@keyframes indet { from { transform: translateX(-100%); } to { transform: translateX(300%); } }
.tmodal { width: min(720px, 94vw); }
.tlist { max-height: 60vh; overflow-y: auto; margin-top: 10px; display: flex; flex-direction: column; gap: 2px; }
.tline { display: grid; grid-template-columns: 52px 1fr; gap: 10px; padding: 6px 8px; border-radius: 7px; cursor: pointer; font-size: 13.5px; }
.tline:hover { background: rgba(255,255,255,.06); } .tline.out { opacity: .4; cursor: default; }
.tline span { color: var(--muted); font-family: Consolas, monospace; font-size: 12px; padding-top: 2px; }

/* ================= purple theme (both modes) ================= */
:root { --grad: linear-gradient(135deg, #b79cff 0%, #8b6cf0 45%, #6a4ae0 100%); --accent: #8b6cf0; --accent2: #a98bf7; }
button.primary, .btn.primary { box-shadow: 0 6px 18px rgba(106,74,224,.35), inset 0 1px 0 rgba(255,255,255,.3); }
.b1 { background: #8b6cf0; } .b3 { background: #c084fc; }
#playhead { background: linear-gradient(180deg, #c4adff, #6a4ae0); box-shadow: 0 0 10px rgba(139,108,240,.6); }
.msg.user { background: linear-gradient(135deg, rgba(169,139,247,.42), rgba(106,74,224,.32)); border-color: rgba(196,173,255,.35); }
.tabs button.active { background: linear-gradient(to top, rgba(139,108,240,.18), transparent 70%); box-shadow: inset 0 -2px 0 #8b6cf0; }
input:focus, select:focus, textarea:focus { border-color: #a98bf7; box-shadow: 0 0 0 3px rgba(139,108,240,.18); }
.clip.sel { box-shadow: 0 0 0 4px rgba(139,108,240,.4), 0 6px 18px rgba(0,0,0,.3); }
.fitem.on { background: rgba(139,108,240,.25); }

/* ================= light mode (default): white + lavender glass ================= */
html[data-theme="light"] {
  --text: #1c1733; --muted: #6e6890; --line: rgba(91,63,209,.12); --line2: rgba(91,63,209,.2); --edge: rgba(91,63,209,.14); --edge2: rgba(91,63,209,.26);
  --panel2: rgba(255,255,255,.7); --glass: rgba(255,255,255,.66); --glass-solid: rgba(250,248,255,.97); background: #f4f1fd;
}
html[data-theme="light"] .bg { background: radial-gradient(900px 600px at 85% -5%, #e3d8ff 0%, transparent 60%), radial-gradient(800px 600px at -5% 30%, #efe9ff 0%, transparent 60%), #f4f1fd; }
html[data-theme="light"] .blob { opacity: .35; }
html[data-theme="light"] #viewer { background: rgba(236,231,252,.65); }
html[data-theme="light"] #tlScroll { background: rgba(255,255,255,.45); }
html[data-theme="light"] .row { border-bottom-color: rgba(91,63,209,.08); }
html[data-theme="light"] .lane { background: transparent; }
html[data-theme="light"] .tick { background: #b9b2d6; } html[data-theme="light"] .tick.major { background: #8f87b5; }
html[data-theme="light"] button, html[data-theme="light"] .btn { background: rgba(255,255,255,.8); color: var(--text); }
html[data-theme="light"] button:hover, html[data-theme="light"] .btn:hover { background: #fff; }
html[data-theme="light"] button.primary, html[data-theme="light"] .btn.primary { background: var(--grad); color: #fff; }
html[data-theme="light"] input, html[data-theme="light"] select, html[data-theme="light"] textarea { background: #fff; color: var(--text); }
html[data-theme="light"] .msg.assistant, html[data-theme="light"] .chip, html[data-theme="light"] .achip, html[data-theme="light"] .watchbox { background: rgba(255,255,255,.8); color: var(--text); }
html[data-theme="light"] .msg.user { color: #1c1733; }
html[data-theme="light"] code { background: #efeafc; color: #4a2fb8; }
html[data-theme="light"] .meter, html[data-theme="light"] .bar, html[data-theme="light"] .tbar { background: #e6e0f7; }
html[data-theme="light"] .modal, html[data-theme="light"] #toast, html[data-theme="light"] .fontpop, html[data-theme="light"] .attachmenu, html[data-theme="light"] .taskpanel {
  background: rgba(255,255,255,.95); color: var(--text); box-shadow: 0 30px 80px rgba(91,63,209,.25); }
html[data-theme="light"] .overlay { background: rgba(60,40,140,.18); }
html[data-theme="light"] .fitem:hover, html[data-theme="light"] .attachmenu button:hover, html[data-theme="light"] .tline:hover { background: #f1ecff; }
html[data-theme="light"] .tb.on { background: #ede6ff; color: #5b3fd1; }
html[data-theme="light"] .tabs button { color: var(--muted); } html[data-theme="light"] .tabs button.active { color: var(--text); }
html[data-theme="light"] .hdr, html[data-theme="light"] #rulerRow, html[data-theme="light"] #rulerRow .corner { background: var(--glass-solid); }
html[data-theme="light"] #stage { box-shadow: 0 0 0 1px rgba(91,63,209,.15), 0 24px 60px rgba(91,63,209,.25); }

/* ================= new tools ================= */
.ghostbtn { background: transparent !important; border-color: transparent !important; font-size: 15px; padding: 4px 9px; }
.ghostbtn:hover { background: var(--panel2) !important; border-color: var(--edge) !important; }
.brollbtn { background: linear-gradient(135deg, rgba(139,108,240,.2), rgba(106,74,224,.12)); }
.seqbar { display: flex; gap: 4px; padding: 6px 10px 0; overflow-x: auto; }
.seqtab { border-radius: 9px 9px 0 0; padding: 5px 12px; font-size: 12.5px; white-space: nowrap; border-bottom-color: transparent; opacity: .75; }
.seqtab.on { opacity: 1; background: var(--grad) !important; color: #fff !important; border-color: transparent; }
.seqtab.add { opacity: .7; border-style: dashed; }
.kfbtn { padding: 1px 6px; font-size: 11px; color: var(--muted); margin-left: 4px; min-width: 24px; justify-content: center; }
.kfbtn.anim { color: #a98bf7; } .kfbtn.on { background: var(--grad) !important; color: #fff !important; }
.rng { grid-template-columns: 1fr 58px auto; }
.kfdot { position: absolute; bottom: 2px; width: 8px; height: 8px; background: #fff; transform: rotate(45deg); border: 1px solid #6a4ae0; z-index: 2; pointer-events: none; }
.expdlg { width: min(520px, 94vw); }
.exgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 12px 0; }
.exgrid label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
.exgrid label:nth-child(-n+2) { grid-column: span 2; }
.exdir { display: flex; gap: 6px; } .exdir input { flex: 1; }
.keysdlg { width: min(560px, 94vw); }
.exfast { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 12px; border-radius: 10px; margin-bottom: 8px; background: rgba(139,108,240,.1); border: 1px solid rgba(139,108,240,.25); font-size: 13px; }
.klist { max-height: 58vh; overflow-y: auto; margin-top: 10px; }
.krow { display: flex; align-items: center; justify-content: space-between; padding: 5px 4px; border-bottom: 1px solid var(--line); font-size: 13px; }
.kbtn { font-family: Consolas, monospace; font-size: 12px; min-width: 120px; justify-content: center; }
.kbtn.rec { background: var(--grad) !important; color: #fff !important; }
/* silent export: hide the playing preview behind a solid screen */
body.exporting #stage, body.exporting #rows { opacity: 0; }
body.exporting #exportOverlay { background: rgba(14,10,30,.97); }
html[data-theme="light"] body.exporting #exportOverlay { background: rgba(244,241,253,.98); }

/* dialogs & toast */
.overlay { background: rgba(6,6,10,.45); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.modal, #toast { background: rgba(28,26,38,.68); border: 1px solid var(--edge2); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border-radius: 16px; box-shadow: 0 30px 80px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.08); }
#exportBar { background: var(--grad); }
.spinner { border-color: rgba(255,255,255,.12); border-top-color: #e8825e; }

/* ---------- Cutline Agent (free AI editor) ---------- */
#agPane { gap: 8px; padding: 8px; overflow: hidden; }
#agPane.hidden { display: none; }
.aghead { display: flex; align-items: center; gap: 8px; padding: 2px 4px; }
.aghead b { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; font-size: 14px; }
.aglogo { font-size: 18px; filter: drop-shadow(0 0 8px rgba(224,122,85,.5)); }
.agbrain { margin-left: auto; font-size: 11px; padding: 2px 8px; border-radius: 99px; background: rgba(60,200,140,.14); border: 1px solid rgba(60,200,140,.35); color: #7fe0b5; max-width: 50%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agbrain.bad { background: rgba(230,90,90,.14); border-color: rgba(230,90,90,.4); color: #f09a9a; }
.agcard { background: var(--glass, rgba(255,255,255,.05)); border: 1px solid var(--edge, rgba(255,255,255,.1)); border-radius: 14px; padding: 8px 10px; backdrop-filter: var(--blur, blur(18px)); box-shadow: 0 8px 24px rgba(0,0,0,.18); flex-shrink: 0; }
.agcard summary { cursor: pointer; font-weight: 600; list-style: none; user-select: none; }
.agcard summary::-webkit-details-marker { display: none; }
.agcard[open] summary { margin-bottom: 8px; }
.agauto { position: relative; overflow: hidden; }
.agauto::before { content: ''; position: absolute; inset: 0; background: var(--grad); opacity: .08; pointer-events: none; }
.agset, .agauto { display: flex; flex-direction: column; gap: 7px; }
.agset label, .aggrid label { display: flex; flex-direction: column; gap: 3px; font-size: 11.5px; color: var(--muted); }
.agset input, .agset select, .aggrid select, #agScript { width: 100%; box-sizing: border-box; }
.aggrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 7px; }
#agScript { resize: vertical; min-height: 36px; font-size: 12px; margin-bottom: 7px; }
.agchecks { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 8px; font-size: 11.5px; margin-bottom: 9px; }
.agchecks label { display: flex; gap: 5px; align-items: center; cursor: pointer; }
.aggo { width: 100%; padding: 9px; font-weight: 700; font-size: 13.5px; background: var(--grad) !important; border: 0 !important; color: #fff !important; border-radius: 11px; box-shadow: 0 6px 18px rgba(180,75,134,.35); }
.aggo:disabled { opacity: .7; }
#agPane.working .aggo { animation: agpulse 1.4s ease-in-out infinite; }
@keyframes agpulse { 50% { box-shadow: 0 6px 26px rgba(224,122,85,.65); } }
.aglink { font-size: 11.5px; color: var(--accent2); }
.agnote { font-size: 11.5px; color: var(--muted); line-height: 1.4; }
.agrow { display: flex; gap: 8px; align-items: center; }
#agLog { flex: 1; min-height: 60px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding: 2px; }
.agmsg { padding: 7px 10px; border-radius: 11px; font-size: 12.5px; line-height: 1.4; max-width: 94%; word-wrap: break-word; border: 1px solid var(--edge, rgba(255,255,255,.1)); background: rgba(255,255,255,.05); }
.agmsg.user { align-self: flex-end; background: linear-gradient(135deg, rgba(224,122,85,.32), rgba(180,75,134,.26)); }
.agmsg.step { font-size: 11.5px; color: var(--muted); background: transparent; border-style: dashed; }
.agmsg.step::before { content: '▸ '; color: var(--accent2); }
.agmsg.warn { border-color: rgba(240,180,80,.45); background: rgba(240,180,80,.08); font-size: 11.5px; }
.agmsg.error { border-color: rgba(230,90,90,.5); background: rgba(230,90,90,.1); }
.agmsg.done { border-color: rgba(60,200,140,.45); background: rgba(60,200,140,.1); }
#agBox { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
#agInput { width: 100%; box-sizing: border-box; resize: none; }
html[data-theme="light"] .agmsg, html[data-theme="light"] .agcard { background: rgba(255,255,255,.75); }

/* ---------- Pro tools (Premiere / CapCut style) ---------- */
.probar { display: flex; align-items: center; gap: 6px; padding: 5px 10px; border-bottom: 1px solid var(--line); flex-wrap: wrap;
  background: linear-gradient(90deg, rgba(224,122,85,.07), rgba(139,108,240,.07)); }
.probar button, .probar select { font-size: 12px; padding: 4px 9px; }
.probar select { border-radius: 8px; }
.probar .sep { width: 1px; height: 18px; background: var(--line2); margin: 0 2px; }
.probar button.on { background: var(--grad) !important; color: #fff !important; border-color: transparent !important; }
body.razor #rows .clip { cursor: crosshair !important; }
.probadge { position: absolute; right: 4px; top: 2px; font-size: 10px; padding: 0 5px; border-radius: 6px; background: rgba(0,0,0,.45); color: #fff; pointer-events: none; z-index: 2; }
.protrans { position: absolute; left: 0; top: 0; bottom: 0; pointer-events: none; z-index: 2;
  background: linear-gradient(90deg, rgba(255,255,255,.55), rgba(255,255,255,0)); border-left: 2px solid #fff; }
.prorange { position: absolute; top: 0; bottom: 0; background: rgba(139,108,240,.28); border-left: 2px solid #8b6cf0; border-right: 2px solid #8b6cf0; pointer-events: none; }
.group.pro .gtitle { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; font-weight: 700; }
.speedrow { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.speedrow .sbtn { min-width: 40px; }
.agchips { display: flex; flex-wrap: wrap; gap: 5px; flex-shrink: 0; }
.agchips:empty { display: none; }
.agchip { font-size: 11.5px; padding: 4px 10px; border-radius: 99px; background: linear-gradient(135deg, rgba(224,122,85,.18), rgba(139,108,240,.18)) !important; border: 1px solid var(--edge2, rgba(255,255,255,.18)) !important; }
.agchip:hover { filter: brightness(1.2); }
#agBox .chat-btns { display: flex; gap: 5px; align-items: center; }
#agBox .chat-btns button.on { background: var(--grad) !important; color: #fff !important; border-color: transparent !important; }
.agmic.live { background: linear-gradient(135deg, #ff5f6d, #e0457b) !important; color: #fff !important; animation: agpulse 1.1s ease-in-out infinite; }
.agcheck { flex-direction: row !important; align-items: center; gap: 6px !important; }
.agmsg.thinking { display: flex; gap: 4px; padding: 10px 12px; }
.agmsg.thinking i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent2); animation: agdot 1s infinite ease-in-out; }
.agmsg.thinking i:nth-child(2) { animation-delay: .15s; } .agmsg.thinking i:nth-child(3) { animation-delay: .3s; }
@keyframes agdot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.probar select { width: auto; max-width: 160px; }
