/* Editroom web — design language lifted from Editroom (SwiftUI Theme.swift) */

:root {
  --bg: #0A0A0A;
  --panel: #111111;
  --lane: #0D0D0D;
  --lane-alt: #0A0A0A;
  --raised: #1A1A1A;
  --field: #181818;
  --line: #1F1F1F;
  --line2: #2E2E2E;
  --text: #F2F2F0;
  --dim: #9A9A96;
  --faint: #5C5C59;
  --accent: #FF4A1C;
  --alert: #FF4A1C;
  --snap: #F2C14E;
  --on-text: #0A0A0A;
  --video: #1E1E1E;
  --audio: #151515;
  --text-clip: #1B1B1B;
  --clip-stroke: #2C2C2C;
  --well: #262626;
  --control: #3A3A3A;
  --button: #242424;
  --button-hover: #2E2E2E;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Menlo, monospace;
  --sans: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", sans-serif;
  --lib-w: 268px;
  --insp-w: 322px;
  --tl-h: 340px;
  --head-w: 176px;
  --radius: 8px;
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; max-width: 100%; overflow-x: hidden; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
svg { display: block; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2a2a2a; border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #3a3a3a; }

.lbl {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--faint);
}

/* ---------- App shell ---------- */

.app {
  height: 100%;
  display: grid;
  grid-template-rows: 48px minmax(0, 1fr) 4px var(--tl-h);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px 0 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  min-width: 0;
}

.brand { display: flex; align-items: center; gap: 8px; color: var(--text); }
.brand .logo { width: 19px; height: 19px; color: var(--accent); }
.wordmark { font-weight: 600; font-size: 13.5px; letter-spacing: -.01em; }

.top-sep { width: 1px; height: 18px; background: var(--line2); flex: none; }
.top-sep.wide { margin: 0 2px; }

.project-name {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12.5px;
  color: var(--text);
  width: 160px;
  min-width: 60px;
  transition: background .12s, border-color .12s;
}
.project-name:hover { background: var(--raised); }
.project-name:focus { outline: none; background: var(--field); border-color: var(--line2); }

.local-note {
  display: flex; align-items: center; gap: 6px;
  font-size: 10.5px; color: var(--dim);
  padding: 3px 9px 3px 8px; border-radius: 20px; background: var(--raised);
  white-space: nowrap;
}
.local-note .dot { width: 5px; height: 5px; border-radius: 50%; background: #3DDC97; }

.top-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.top-actions .btn { height: 30px; }
.top-actions .icon-btn { width: 30px; height: 30px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 13px;
  border-radius: 16px;
  font-size: 12px; font-weight: 600;
  white-space: nowrap;
  transition: background .12s, color .12s, box-shadow .12s, transform .06s;
  user-select: none;
}
.btn svg { width: 15px; height: 15px; }
.btn:active { transform: translateY(.5px); }
.btn.primary { background: var(--text); color: var(--on-text); }
.btn.primary:hover { background: #fff; }
.btn.ghost { background: var(--button); color: var(--dim); }
.btn.ghost:hover { background: var(--button-hover); color: var(--text); }
.btn.tiny { height: 27px; padding: 0 11px; font-size: 11.5px; background: var(--raised); color: var(--text); }
.btn.tiny:hover { background: var(--button-hover); }
.btn.lg { height: 40px; padding: 0 20px; font-size: 13px; border-radius: 20px; }
.btn:disabled { opacity: .4; cursor: default; }

.icon-btn {
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 7px;
  color: var(--dim);
  font-size: 15px; line-height: 1;
  transition: background .12s, color .12s, opacity .12s;
  flex: none;
}
.icon-btn svg { width: 15px; height: 15px; }
.icon-btn:hover { background: var(--raised); color: var(--text); }
.icon-btn.on { background: rgba(255,255,255,.1); color: var(--text); }
.icon-btn:disabled { opacity: .3; pointer-events: none; }

.only-narrow { display: none; }

/* ---------- Main panes ---------- */

.main {
  display: grid;
  grid-template-columns: var(--lib-w) minmax(0, 1fr) var(--insp-w);
  min-height: 0;
  background: var(--bg);
}

.library {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

.panel-head {
  display: flex; align-items: center;
  height: 44px; padding: 0 8px 0 14px;
  flex: none;
}
.panel-head .lbl { flex: 1; color: var(--dim); }
.head-tools { display: flex; gap: 1px; }

.search {
  display: flex; align-items: center; gap: 8px;
  height: 30px; margin: 0 12px 10px;
  padding: 0 10px;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--faint);
  flex: none;
  transition: border-color .12s;
}
.search:focus-within { border-color: var(--line2); }
.search svg { width: 13px; height: 13px; flex: none; }
.search input {
  flex: 1; min-width: 0;
  background: none; border: 0; outline: none;
  font-size: 12px; color: var(--text);
}
.search input::placeholder { color: var(--faint); }

.asset-list {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 0 8px 12px;
  display: flex; flex-direction: column; gap: 2px;
}
.asset {
  display: flex; gap: 10px; align-items: center;
  padding: 5px 6px;
  border-radius: 9px;
  cursor: grab;
  user-select: none;
  position: relative;
  transition: background .1s;
}
.asset:hover { background: rgba(255,255,255,.045); }
.asset.sel { background: rgba(255,255,255,.075); }
.asset.sel::after {
  content: ""; position: absolute; inset: 0;
  border-radius: 9px; box-shadow: inset 0 0 0 1.5px var(--text);
  pointer-events: none;
}
.asset.dragging { opacity: .45; }
.asset.offline { opacity: .55; }
.asset.offline .thumb { box-shadow: inset 0 0 0 1px rgba(255,74,28,.45); }
.asset.offline .sub { color: rgba(255,74,28,.8); }
.asset .thumb {
  width: 72px; height: 41px; flex: none;
  border-radius: 5px; overflow: hidden;
  background: #141414;
  position: relative;
  display: flex; align-items: center; justify-content: center;
}
.asset .thumb img, .asset .thumb canvas { width: 100%; height: 100%; object-fit: cover; }
.asset .thumb .ph-icon { width: 18px; height: 18px; color: #4a4a48; }
.asset .meta { min-width: 0; flex: 1; }
.asset .name {
  font-size: 12px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.asset .sub { font-family: var(--mono); font-size: 10px; color: var(--faint); margin-top: 3px; }
.asset .kind-badge {
  position: absolute; right: 8px; top: 8px;
  width: 5px; height: 5px; border-radius: 50%;
}
.asset .add {
  position: absolute; right: 8px; bottom: 8px;
  width: 20px; height: 20px; border-radius: 6px;
  background: rgba(255,255,255,.9); color: #0A0A0A;
  display: none; align-items: center; justify-content: center;
}
.asset:hover .add { display: flex; }
.asset .add svg { width: 12px; height: 12px; }

.asset-empty {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; color: var(--faint); text-align: center; padding: 20px;
  font-size: 12px; line-height: 1.7;
}
.asset-empty .ae-icon { width: 34px; height: 34px; opacity: .5; }
.asset-empty.hide { display: none; }

.panel-foot {
  display: flex; justify-content: space-between;
  padding: 9px 14px;
  border-top: 1px solid var(--line);
  font-size: 10px; color: var(--faint);
  flex: none;
}

/* ---------- Viewer ---------- */

.viewer {
  display: flex; flex-direction: column;
  min-width: 0; min-height: 0;
  background: var(--bg);
  position: relative;
}
.viewer-stage {
  flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 18px 24px 8px;
  position: relative;
}
#preview {
  max-width: 100%; max-height: 100%;
  border-radius: 4px;
  background: #000;
  box-shadow: 0 0 0 1px rgba(255,255,255,.06), 0 18px 60px rgba(0,0,0,.55);
  display: block;
}
#preview.empty { background: #060606; }

.viewer-empty {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
  padding: 20px;
}
.viewer-empty.hide { display: none; }
.ve-card {
  text-align: center;
  padding: 30px 34px;
  border-radius: 14px;
  background: radial-gradient(120% 120% at 50% 0%, rgba(255,255,255,.05), transparent 70%);
  pointer-events: auto;
}
.ve-title { font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
.ve-sub { margin-top: 6px; font-size: 12px; color: var(--dim); }
.ve-sub kbd {
  font-family: var(--mono); font-size: 10.5px;
  background: var(--raised); border: 1px solid var(--line2);
  border-radius: 4px; padding: 1px 5px; color: var(--text);
}
.ve-actions { margin-top: 18px; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

.transport {
  height: 62px; flex: none;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 0 20px;
  gap: 12px;
}
.tc { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.tc .now { font-size: 17px; font-weight: 500; letter-spacing: .02em; }
.tc .dur { font-size: 10.5px; color: var(--faint); }
.keys { display: flex; align-items: center; gap: 2px; }
.key {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--dim);
  transition: background .12s, color .12s;
}
.key svg { width: 14px; height: 14px; }
.key:hover { color: var(--text); background: rgba(255,255,255,.06); }
.play {
  width: 44px; height: 44px; margin: 0 8px;
  border-radius: 50%;
  background: var(--text); color: var(--on-text);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 5px #161616;
  transition: transform .1s, background .12s;
}
.play svg { width: 15px; height: 15px; }
.play:hover { background: #fff; }
.play:active { transform: scale(.95); }
.play .ic-pause { display: none; }
body.playing .play .ic-play { display: none; }
body.playing .play .ic-pause { display: block; }

.transport .right { display: flex; align-items: center; justify-content: flex-end; gap: 9px; }
.vol-icon { width: 14px; height: 14px; color: var(--faint); }
.meter { display: flex; gap: 2px; height: 20px; align-items: flex-end; }
.meter .mbar {
  width: 3px; height: 100%; border-radius: 2px;
  background: #222; overflow: hidden; position: relative;
}
.meter .mbar::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0;
  height: calc(var(--lv, 0) * 100%);
  background: linear-gradient(to top, #4ad07a 0%, #c9d94a 62%, var(--alert) 92%);
  opacity: .9;
  transition: height .07s linear;
}
.pill {
  height: 24px; padding: 0 9px;
  border-radius: 12px; background: var(--raised);
  font-size: 10.5px; font-weight: 500; color: var(--dim);
  display: inline-flex; align-items: center;
}

/* ---------- Inspector ---------- */

.inspector {
  background: var(--panel);
  border-left: 1px solid var(--line);
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.side-tabs {
  display: flex; gap: 2px; padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.side-tab {
  flex: 1; height: 28px; border-radius: 7px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 11.5px; font-weight: 500; color: var(--dim);
  transition: background .12s, color .12s;
}
.side-tab svg { width: 13px; height: 13px; }
.side-tab:hover { color: var(--text); background: rgba(255,255,255,.045); }
.side-tab.on { color: var(--text); background: var(--raised); box-shadow: 0 0 0 1px var(--line2); }
.side-pane { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.side-pane[hidden] { display: none; }
#pane-props { overflow-y: auto; overflow-x: hidden; padding-bottom: 24px; }

/* ---------- AI panel ---------- */

.ai-wrap { display: flex; flex-direction: column; min-height: 0; height: 100%; }

.ai-log {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 14px 14px 6px;
  display: flex; flex-direction: column; gap: 12px;
  scroll-behavior: smooth;
}

.ai-msg { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; line-height: 1.65; }
.ai-msg .who {
  font-size: 9.5px; letter-spacing: .14em; text-transform: uppercase;
  font-weight: 600; color: var(--faint);
}
.ai-msg.user .who { color: var(--faint); }
.ai-msg.user .body {
  background: var(--raised); border-radius: 10px 10px 3px 10px;
  padding: 8px 11px; align-self: flex-end; max-width: 92%;
  white-space: pre-wrap; word-break: break-word;
}
.ai-msg.user { align-items: flex-end; }
.ai-msg.ai .body { color: var(--text); white-space: pre-wrap; word-break: break-word; }
.ai-msg.err .body { color: #FF8B6B; }

.ai-steps { display: flex; flex-direction: column; gap: 4px; margin-top: 2px; }
.ai-step {
  display: flex; align-items: flex-start; gap: 7px;
  font-size: 11.5px; color: var(--dim);
  padding: 5px 8px; border-radius: 7px; background: rgba(255,255,255,.03);
}
.ai-step .tick { color: #3DDC97; flex: none; font-size: 11px; line-height: 1.5; }
.ai-step.fail .tick { color: var(--alert); }
.ai-step .txt { min-width: 0; }

.ai-typing { display: inline-flex; gap: 3px; align-items: center; height: 16px; }
.ai-typing i {
  width: 5px; height: 5px; border-radius: 50%; background: var(--dim);
  animation: blink 1.15s infinite ease-in-out;
}
.ai-typing i:nth-child(2) { animation-delay: .18s; }
.ai-typing i:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%,60%,100% { opacity: .25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-2px); } }

.ai-suggest {
  display: flex; gap: 6px; flex-wrap: wrap;
  padding: 0 14px 10px; flex: none;
}
.ai-suggest:empty { display: none; }
.ai-suggest button {
  font-size: 10.5px; color: var(--dim);
  background: var(--raised); border-radius: 12px;
  padding: 5px 10px; text-align: left;
  transition: color .1s, background .1s;
}
.ai-suggest button:hover { color: var(--text); background: var(--button-hover); }

.ai-input {
  margin: 0 12px; flex: none;
  background: var(--field);
  border: 1px solid var(--line2);
  border-radius: 11px;
  padding: 8px 8px 6px 11px;
  display: flex; flex-direction: column; gap: 4px;
  transition: border-color .12s;
}
.ai-input:focus-within { border-color: #3A3A3A; }
.ai-input textarea {
  background: none; border: 0; outline: none; resize: none;
  font-size: 12.5px; line-height: 1.55;
  max-height: 120px; min-height: 20px;
  color: var(--text);
}
.ai-input textarea::placeholder { color: var(--faint); }
.ai-input-actions { display: flex; align-items: center; gap: 4px; }
.ai-input-actions .icon-btn { margin-right: auto; width: 24px; height: 24px; }
.ai-send {
  width: 26px; height: 26px; border-radius: 7px;
  background: var(--text); color: var(--on-text);
  display: flex; align-items: center; justify-content: center;
  transition: background .12s, opacity .12s;
}
.ai-send svg { width: 13px; height: 13px; }
.ai-send:hover { background: #fff; }
.ai-send .ic-stop { display: none; }
.ai-send.busy { background: var(--alert); }
.ai-send.busy .ic-send { display: none; }
.ai-send.busy .ic-stop { display: block; }
.ai-send:disabled { opacity: .35; pointer-events: none; }

.ai-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 16px 10px; flex: none;
  font-size: 10px; color: var(--faint);
}
.ai-link { font-size: 10px; color: var(--faint); }
.ai-link:hover { color: var(--text); }
#ai-model-badge { display: inline-flex; align-items: center; gap: 5px; }
#ai-model-badge::before {
  content: ""; width: 4px; height: 4px; border-radius: 50%;
  background: var(--faint);
}
#ai-model-badge.remote::before { background: #3DDC97; }
.insp-empty {
  height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 30px 24px; color: var(--faint); text-align: center;
  font-size: 12px; line-height: 1.7;
}
.insp-empty svg { width: 28px; height: 28px; opacity: .45; }

.insp-head {
  display: flex; align-items: center; gap: 9px;
  padding: 14px 16px 12px;
  position: sticky; top: 0; z-index: 3;
  background: linear-gradient(var(--panel) 78%, transparent);
}
.insp-head .k-icon {
  width: 24px; height: 24px; border-radius: 6px;
  background: var(--raised); color: var(--dim);
  display: flex; align-items: center; justify-content: center; flex: none;
}
.insp-head .k-icon svg { width: 13px; height: 13px; }
.insp-head .n {
  font-size: 13px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.insp-head .info { min-width: 0; }
.insp-head .k { font-family: var(--mono); font-size: 9.5px; color: var(--faint); margin-top: 1px; }

.sec { border-top: 1px solid var(--line); padding: 12px 16px 14px; }
.sec-h { display: flex; align-items: center; margin-bottom: 11px; }
.sec-h .lbl { flex: 1; }
.sec-h .reset { font-size: 10.5px; color: var(--dim); }
.sec-h .reset:hover { color: var(--text); }
.sec-h .val { font-family: var(--mono); font-size: 10px; color: var(--faint); }

.readouts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.ro .v { font-family: var(--mono); font-size: 19px; line-height: 1; letter-spacing: -.01em; }
.ro .v small { font-size: 11px; color: var(--dim); margin-left: 2px; }
.ro .rule { height: 1px; background: var(--line2); margin: 7px 0 5px; }
.ro .k { font-size: 9.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--faint); font-weight: 600; }

.field-row { display: flex; align-items: center; gap: 10px; height: 32px; }
.field-row .rk { width: 66px; flex: none; font-size: 11.5px; color: var(--dim); }
.field-row .rv { width: 54px; flex: none; text-align: right; font-family: var(--mono); font-size: 10.5px; color: var(--text); }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  flex: 1; min-width: 0; height: 18px;
  background: transparent; cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 2px; border-radius: 1px;
  background: linear-gradient(to right, var(--text) var(--fill, 50%), #2a2a2a var(--fill, 50%));
}
input[type="range"]::-moz-range-track {
  height: 2px; border-radius: 1px;
  background: linear-gradient(to right, var(--text) var(--fill, 50%), #2a2a2a var(--fill, 50%));
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 13px; height: 13px; margin-top: -5.5px;
  border-radius: 50%; background: var(--text);
  box-shadow: 0 0 0 3px var(--panel);
  transition: transform .1s;
}
input[type="range"]::-moz-range-thumb {
  width: 13px; height: 13px; border: 0;
  border-radius: 50%; background: var(--text);
  box-shadow: 0 0 0 3px var(--panel);
}
input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.15); }
input[type="range"]:disabled { opacity: .35; pointer-events: none; }

.seg-sm {
  display: flex; gap: 2px; padding: 2px;
  background: var(--bg); border-radius: 7px;
}
.seg-sm button {
  flex: 1; height: 24px; border-radius: 5px;
  font-size: 10.5px; font-weight: 500; color: var(--dim);
  transition: background .1s, color .1s;
}
.seg-sm button:hover { color: var(--text); }
.seg-sm button.on { background: var(--raised); color: var(--text); box-shadow: 0 0 0 1px var(--line2); }

.select {
  height: 29px; width: 100%;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 28px 0 9px;
  font-size: 11.5px;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%239A9A96' stroke-width='1.3' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.select:focus { border-color: var(--line2); }

.text-in, .num-in {
  height: 29px; width: 100%;
  background: var(--field); border: 1px solid var(--line);
  border-radius: 7px; padding: 0 9px;
  font-size: 11.5px; outline: none;
}
.text-in:focus, .num-in:focus { border-color: var(--line2); }
textarea.text-in { height: auto; min-height: 58px; padding: 7px 9px; resize: vertical; line-height: 1.4; }

.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatch {
  width: 22px; height: 22px; border-radius: 6px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.16);
  transition: transform .1s;
}
.swatch:hover { transform: scale(1.1); }
.swatch.on { box-shadow: inset 0 0 0 1px rgba(255,255,255,.16), 0 0 0 2px var(--text); }

.toggle-row { display: flex; align-items: center; justify-content: space-between; height: 32px; gap: 10px; }
.toggle-row .rk { font-size: 11.5px; color: var(--dim); }
.switch {
  width: 34px; height: 19px; border-radius: 10px;
  background: var(--well); position: relative; flex: none;
  transition: background .14s;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--dim);
  transition: transform .14s, background .14s;
}
.switch.on { background: var(--text); }
.switch.on::after { transform: translateX(15px); background: var(--on-text); }

.grade-wheels { display: flex; justify-content: space-between; gap: 8px; }
.wheel { text-align: center; flex: 1; }
.wheel .ring {
  width: 62px; height: 62px; border-radius: 50%;
  margin: 0 auto 6px;
  background: conic-gradient(from 90deg, #ff5a4a, #f7c84a, #5ad17a, #4ac8f0, #5a6cff, #e05ae0, #ff5a4a);
  padding: 2px; position: relative;
}
.wheel .ring::before { content: ""; position: absolute; inset: 2px; border-radius: 50%; background: #141414; }
.wheel .ring::after {
  content: ""; position: absolute; left: 50%; top: 50%;
  width: 9px; height: 9px; margin: -4.5px; border-radius: 50%;
  background: #fff; box-shadow: 0 0 0 2px #141414;
  transform: translate(calc(var(--wx, 0) * 18px), calc(var(--wy, 0) * -18px));
}
.wheel .k { font-size: 9px; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); font-weight: 600; }

.fold {
  display: flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 16px;
  border-top: 1px solid var(--line);
  font-size: 11.5px; color: var(--dim);
  width: 100%; text-align: left;
}
.fold:hover { color: var(--text); background: rgba(255,255,255,.02); }
.fold .lbl { flex: 1; color: var(--dim); font-size: 10px; }
.fold svg { width: 12px; height: 12px; transition: transform .15s; color: var(--faint); }
.fold.open svg { transform: rotate(180deg); }

.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  height: 26px; padding: 0 10px; border-radius: 13px;
  background: var(--raised); color: var(--dim);
  font-size: 10.5px; font-weight: 500;
  display: inline-flex; align-items: center;
  transition: background .1s, color .1s;
}
.chip:hover { color: var(--text); background: var(--button-hover); }
.chip.on { background: var(--text); color: var(--on-text); }

.hint { font-size: 10.5px; color: var(--faint); line-height: 1.6; margin-top: 8px; }
.sec-body[hidden] { display: none; }

/* ---------- Splitter ---------- */

.splitter {
  background: var(--line);
  cursor: row-resize;
  position: relative;
  z-index: 20;
}
.splitter::after { content: ""; position: absolute; inset: -4px 0; }
.splitter:hover, .splitter.drag { background: var(--line2); }

/* ---------- Timeline ---------- */

.timeline {
  background: var(--bg);
  border-top: 1px solid var(--line);
  display: flex; flex-direction: column;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

.tl-tools {
  height: 40px; flex: none;
  display: flex; align-items: center; gap: 6px;
  padding: 0 10px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}
.tl-tools::-webkit-scrollbar { display: none; }

.seg { display: flex; gap: 2px; padding: 3px; background: var(--bg); border-radius: 9px; flex: none; }
.seg button {
  width: 29px; height: 23px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: var(--dim);
}
.seg button svg { width: 13px; height: 13px; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--raised); color: var(--text); box-shadow: 0 0 0 1px var(--line2); }

.tg {
  height: 24px; padding: 0 9px; border-radius: 7px;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 10.5px; font-weight: 500; color: var(--dim);
  white-space: nowrap; flex: none;
  transition: background .1s, color .1s;
}
.tg svg { width: 13px; height: 13px; }
.tg:hover { color: var(--text); background: var(--raised); }
.tg.on { color: var(--text); background: var(--raised); }
.tg .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); display: none; }
.tg.on .dot { display: block; }
.tl-sep { width: 1px; height: 18px; background: var(--line2); margin: 0 3px; flex: none; }
.tl-tools .sp { flex: 1; min-width: 8px; }
.tl-tools .icon-btn { width: 26px; height: 26px; font-size: 13px; }

.tl-main {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: var(--head-w) minmax(0, 1fr);
  grid-template-rows: 26px minmax(0, 1fr);
}
.tl-corner {
  grid-column: 1; grid-row: 1;
  background: var(--panel);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center;
  padding: 0 13px;
  position: relative; z-index: 4;
}
.tl-heads {
  grid-column: 1; grid-row: 2;
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow: hidden;
  position: relative;
  z-index: 3;
}
.tl-scroll {
  grid-column: 2; grid-row: 1 / 3;
  overflow: auto;
  position: relative;
  overscroll-behavior: contain;
}
.tl-content { position: relative; min-width: 100%; }

.tl-ruler {
  position: sticky; top: 0; z-index: 2;
  height: 26px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  overflow: hidden;
}
.tl-ruler .tick {
  position: absolute; top: 0; bottom: 0;
  border-left: 1px solid #2a2a2a;
}
.tl-ruler .tick.major { border-left-color: #4a4a4a; }
.tl-ruler .tick span {
  position: absolute; top: 5px; left: 5px;
  font-family: var(--mono); font-size: 9.5px; color: var(--faint);
  white-space: nowrap; pointer-events: none;
}

.tl-lanes { position: relative; }

.track-head {
  display: flex; align-items: center; gap: 5px;
  padding: 0 8px 0 13px;
  border-bottom: 1px solid var(--line);
  position: relative;
}
.track-head .t {
  font-family: var(--mono); font-size: 10.5px; font-weight: 500;
  width: 22px; flex: none; color: var(--dim);
}
.track-head .mini {
  width: 19px; height: 19px; border-radius: 5px;
  background: var(--field); color: var(--dim);
  display: flex; align-items: center; justify-content: center;
  font-size: 9.5px; font-weight: 700; flex: none;
  transition: background .1s, color .1s;
}
.track-head .mini svg { width: 11px; height: 11px; }
.track-head .mini:hover { background: var(--button-hover); color: var(--text); }
.track-head .mini.on { background: var(--text); color: var(--on-text); }
.track-head .gain {
  margin-left: auto;
  font-family: var(--mono); font-size: 9.5px; color: var(--dim);
  background: var(--field); border-radius: 6px; padding: 3px 6px;
  flex: none;
}
.track-head .tname {
  font-size: 10px; color: var(--faint);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.lane {
  position: relative;
  border-bottom: 1px solid var(--line);
  background: var(--lane);
  overflow: hidden;
}
.lane.alt { background: var(--lane-alt); }
.lane.dropping { background: rgba(255,74,28,.06); box-shadow: inset 0 0 0 1px rgba(255,74,28,.35); }
.lane.locked::before {
  content: ""; position: absolute; inset: 0; z-index: 1;
  background: repeating-linear-gradient(135deg, rgba(0,0,0,.18) 0 6px, transparent 6px 12px);
  pointer-events: none;
}

.clip {
  position: absolute; top: 4px; bottom: 4px;
  border-radius: 7px;
  background: var(--video);
  box-shadow: inset 0 0 0 1px var(--clip-stroke);
  overflow: hidden;
  cursor: grab;
  user-select: none;
  contain: layout paint;
}
.clip.audio { background: var(--audio); }
.clip.text, .clip.solid { background: var(--text-clip); }
.clip.sel { box-shadow: inset 0 0 0 1.5px var(--text); z-index: 2; }
.clip.sel .nm { color: #fff; }
.clip.dragging { opacity: .75; cursor: grabbing; }
.clip .nm {
  position: absolute; left: 7px; top: 4px; right: 24px;
  font-size: 10px; font-weight: 600; color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,.6);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  z-index: 2; pointer-events: none;
}
.clip .film { position: absolute; inset: 0; display: flex; opacity: .8; }
.clip .film > i {
  flex: 1; min-width: 0;
  background-size: cover; background-position: center;
  border-right: 1px solid rgba(0,0,0,.35);
}
.clip .shade {
  position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: linear-gradient(180deg, rgba(0,0,0,.5), rgba(0,0,0,0) 46%);
}
.clip .wave {
  position: absolute; left: 4px; right: 4px; top: 17px; bottom: 5px;
  display: flex; align-items: center; gap: 1px;
  pointer-events: none;
}
.clip .wave i { flex: 1; background: #bdbdb9; border-radius: 1px; opacity: .85; }
.clip .kind-glyph {
  position: absolute; left: 8px; bottom: 5px;
  font-size: 15px; font-weight: 700; color: #3a3a3a;
  pointer-events: none; letter-spacing: -.02em;
}
.clip .fade {
  position: absolute; top: 0; bottom: 0; z-index: 2;
  background: linear-gradient(90deg, rgba(0,0,0,.62), transparent);
  pointer-events: none;
}
.clip .fade.out { background: linear-gradient(270deg, rgba(0,0,0,.62), transparent); }
.clip .clip-trans {
  position: absolute; left: 0; top: 0; bottom: 0; z-index: 2;
  pointer-events: none;
  background: repeating-linear-gradient(135deg, rgba(255,74,28,.5) 0 3px, rgba(255,74,28,.1) 3px 7px);
  border-right: 1px solid rgba(255,74,28,.6);
}
.clip .badge {
  position: absolute; right: 5px; top: 4px; z-index: 3;
  font-family: var(--mono); font-size: 8.5px;
  color: #d9d9d6; background: rgba(0,0,0,.45);
  border-radius: 4px; padding: 1px 4px;
  pointer-events: none;
}
.clip .badge.fx { top: auto; bottom: 4px; right: 5px; }
.clip .handle {
  position: absolute; top: 0; bottom: 0; width: 7px;
  cursor: ew-resize; z-index: 4;
}
.clip .handle.l { left: 0; }
.clip .handle.r { right: 0; }
.clip .handle:hover { background: rgba(255,255,255,.16); }
.lane.locked .clip { cursor: default; }
.lane.locked .clip .handle { display: none; }

.clip .trim-line {
  position: absolute; top: 0; bottom: 0; width: 1.5px;
  background: var(--text); z-index: 6; pointer-events: none;
  display: none;
}

.tl-playhead {
  position: absolute; top: 0; bottom: 0; width: 1px;
  background: var(--accent);
  z-index: 8;
  pointer-events: none;
  will-change: transform;
}
.tl-playhead::before {
  content: ""; position: absolute; top: 0; left: -5.5px;
  width: 12px; height: 9px; background: var(--accent);
  clip-path: polygon(0 0, 100% 0, 100% 55%, 50% 100%, 0 55%);
}

.snap-line {
  position: absolute; top: 0; bottom: 0; width: 1px;
  background: var(--snap); z-index: 7; pointer-events: none;
  opacity: 0;
}
.snap-line.on { opacity: .8; }

.tl-empty {
  position: absolute; left: var(--head-w); right: 0; top: 66px; bottom: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--faint); font-size: 11.5px;
  pointer-events: none;
}
.tl-empty.hide { display: none; }

/* ---------- Welcome ---------- */

.welcome {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(6,6,6,.82);
  backdrop-filter: blur(14px) saturate(.8);
  -webkit-backdrop-filter: blur(14px) saturate(.8);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  animation: fade .25s ease;
}
.welcome.hide { display: none; }
@keyframes fade { from { opacity: 0; } }

.welcome-card {
  width: min(560px, 100%);
  background: var(--panel);
  border: 1px solid var(--line2);
  border-radius: 18px;
  padding: 36px 34px 22px;
  box-shadow: 0 40px 120px rgba(0,0,0,.7);
  animation: rise .3s cubic-bezier(.2,.9,.2,1);
  position: relative;
}
@keyframes rise { from { opacity: 0; transform: translateY(10px) scale(.985); } }
.welcome-mark {
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--raised);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 20px;
}
.welcome-mark svg { width: 24px; height: 24px; color: var(--accent); }
.welcome-card h1 { font-size: 25px; font-weight: 600; letter-spacing: -.02em; }
.welcome-sub { margin-top: 9px; color: var(--dim); font-size: 12.5px; line-height: 1.7; }
.welcome-steps { list-style: none; display: flex; gap: 8px; margin: 22px 0; }
.welcome-steps li {
  flex: 1; background: var(--field); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px;
}
.welcome-steps b {
  display: block; font-family: var(--mono); font-size: 9.5px;
  color: var(--accent); letter-spacing: .1em; margin-bottom: 3px; font-weight: 600;
}
.welcome-steps span { font-size: 11.5px; color: var(--dim); }
.welcome-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.welcome-close {
  position: absolute; top: 16px; right: 18px;
  font-size: 11px; color: var(--faint);
}
.welcome-close:hover { color: var(--text); }
.welcome-foot { margin-top: 16px; font-size: 10.5px; color: var(--faint); }

/* ---------- Modal ---------- */

.modal { position: fixed; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal-scrim { position: absolute; inset: 0; background: rgba(6,6,6,.7); backdrop-filter: blur(6px); }
.modal-card {
  position: relative;
  width: min(420px, 100%);
  background: #141414;
  border: 1px solid var(--line2);
  border-radius: 14px;
  box-shadow: 0 30px 90px rgba(0,0,0,.7);
  overflow: hidden;
  animation: rise .22s cubic-bezier(.2,.9,.2,1);
}
.modal-card.wide { width: min(520px, 100%); }

.model-grid { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 2px; }
.model-row {
  display: grid; grid-template-columns: 62px 1fr; gap: 4px 10px;
  align-items: center;
  background: var(--field); border: 1px solid var(--line);
  border-radius: 9px; padding: 8px 10px;
}
.model-k { font-size: 11px; color: var(--text); font-weight: 600; }
.model-hint { grid-column: 2; font-size: 9.5px; color: var(--faint); line-height: 1.4; }
.modal-head {
  display: flex; align-items: center;
  padding: 16px 14px 10px 20px;
}
.modal-head h2 { flex: 1; font-size: 15px; font-weight: 600; }
.modal-body { padding: 6px 20px 18px; }
.modal-body .field { display: block; margin-bottom: 12px; }
.field-k { display: block; font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); font-weight: 600; margin-bottom: 6px; }
.modal-body select {
  width: 100%; height: 34px;
  background: #1E1E1E; border: 1px solid #2E2E2E;
  border-radius: 8px; padding: 0 30px 0 11px;
  font-size: 12px; outline: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%239A9A96' stroke-width='1.3' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
}
.modal-hint { font-size: 10.5px; color: var(--faint); line-height: 1.6; margin-top: 4px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--line);
}
.modal-body.exporting, .modal-body.done { padding-top: 8px; }
.exp-name { font-size: 13px; font-weight: 500; margin-bottom: 10px; }
.exp-bar { height: 4px; background: var(--well); border-radius: 2px; overflow: hidden; }
.exp-bar i { display: block; height: 100%; width: 0; background: var(--text); border-radius: 2px; transition: width .2s linear; }
.exp-meta { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--faint); margin-top: 7px; }
.exp-done-icon {
  width: 42px; height: 42px; border-radius: 50%;
  background: rgba(61,220,151,.12); color: #3DDC97;
  display: flex; align-items: center; justify-content: center;
  margin: 6px 0 12px;
}
.exp-done-icon svg { width: 20px; height: 20px; }
.exp-done-title { font-size: 14px; font-weight: 600; margin-bottom: 14px; }

/* ---------- Context menu & toasts ---------- */

.menu {
  position: fixed; z-index: 90;
  min-width: 190px;
  background: #1C1C1C;
  border: 1px solid var(--line2);
  border-radius: 9px;
  padding: 5px;
  box-shadow: 0 18px 50px rgba(0,0,0,.65);
  font-size: 12px;
}
.menu[hidden] { display: none; }
.menu button {
  display: flex; align-items: center; gap: 8px;
  width: 100%; height: 28px; padding: 0 9px;
  border-radius: 6px; color: var(--text); text-align: left;
}
.menu button:hover { background: var(--raised); }
.menu button .sc { margin-left: auto; font-family: var(--mono); font-size: 9.5px; color: var(--faint); }
.menu hr { border: 0; border-top: 1px solid var(--line2); margin: 5px 4px; }

.toasts {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  z-index: 100; display: flex; flex-direction: column; gap: 8px;
  align-items: center; pointer-events: none;
}
.toast {
  background: #1E1E1E; border: 1px solid var(--line2);
  border-radius: 9px; padding: 9px 15px;
  font-size: 12px; color: var(--text);
  box-shadow: 0 12px 40px rgba(0,0,0,.6);
  animation: toast-in .2s cubic-bezier(.2,.9,.2,1);
  max-width: min(460px, calc(100vw - 40px));
}
.toast.err { border-color: rgba(255,74,28,.42); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Responsive ---------- */

@media (max-width: 1180px) {
  :root { --insp-w: 288px; --lib-w: 244px; }
}
@media (max-width: 980px) {
  :root { --insp-w: 300px; --lib-w: 232px; }
  .main { grid-template-columns: var(--lib-w) minmax(0, 1fr); }
  .inspector {
    position: fixed; right: 0; top: 48px; bottom: 0;
    width: min(360px, 92vw); z-index: 40;
    box-shadow: -24px 0 60px rgba(0,0,0,.6);
    transform: translateX(105%);
    transition: transform .22s cubic-bezier(.2,.9,.2,1);
  }
  body.insp-open .inspector { transform: none; }
  .only-narrow { display: inline-flex; }
  .top-actions .btn span { display: none; }
  .top-actions .btn { padding: 0; width: 32px; border-radius: 50%; }
  .local-note { display: none; }
}
@media (max-width: 760px) {
  :root { --tl-h: 300px; }
  .app { grid-template-rows: 48px minmax(0, 1fr) 4px var(--tl-h); }
  .main { grid-template-columns: minmax(0, 1fr); }
  .library {
    position: fixed; left: 0; top: 48px; bottom: 0;
    width: min(300px, 84vw); z-index: 40;
    box-shadow: 24px 0 60px rgba(0,0,0,.6);
    transform: translateX(-105%);
    transition: transform .22s cubic-bezier(.2,.9,.2,1);
  }
  body.lib-open .library { transform: none; }
  .wordmark { display: none; }
  .project-name { width: 110px; }
  .topbar { padding: 0 8px 0 10px; gap: 6px; overflow: hidden; }
  .top-actions { gap: 3px; flex: none; }
  .top-actions .btn { width: 28px; height: 28px; }
  .top-actions .icon-btn { width: 28px; height: 28px; }
  .top-sep { display: none; }
  .transport { grid-template-columns: auto 1fr; padding: 0 14px; height: 56px; }
  .tc .now { font-size: 14px; }
  .keys { justify-self: center; }
  .transport .right { display: none; }
  .viewer-stage { padding: 10px 12px 4px; }
  .tl-tools { gap: 2px; }
  .tg span { display: none; }
  .tg { padding: 0 7px; }
  .welcome-card { padding: 26px 22px 18px; }
  .welcome-steps { flex-direction: column; }
}
@media (max-width: 460px) {
  .brand { display: none; }
  .top-sep.wide { display: none; }
  .project-name { width: 84px; font-size: 11.5px; padding: 4px 6px; }
  .top-actions .btn { width: 26px; height: 26px; }
  .top-actions .icon-btn { width: 26px; height: 26px; }
  #save-project, #open-project { display: none; }
  .tl-tools { padding: 0 6px; }
  .welcome { padding: 12px; }
  .welcome-card { padding: 22px 18px 16px; border-radius: 14px; }
  .welcome-card h1 { font-size: 20px; }
  .welcome-actions .btn { flex: 1; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
