:root {
  /* Layout idea: a mixing desk. Capture and library on the left rail, the waveform as the lit centre, tools on the right rail. Single dark theme by choice. */
  --ink: #11141b;
  --deck: #191d27;
  --rail: #222735;
  --line: #2f3648;
  --text: #e9ebf1;
  --mute: #8e96aa;
  --wave: #8adfd0;
  --amber: #f5b544;
  --rec: #f0584a;
  --ok: #7ed492;
  --ui: "Schibsted Grotesk", "Segoe UI", system-ui, sans-serif;
  --display: "Unbounded", "Schibsted Grotesk", "Segoe UI", sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--ink); color: var(--text); font: 14px/1.45 var(--ui); display: flex; flex-direction: column; overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
h2 { font: 600 13px var(--ui); margin: 0; color: var(--text); }
h3 { font: 600 12px var(--ui); margin: 0 0 8px; color: var(--mute); }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
[hidden] { display: none !important; }

.top { height: 50px; flex: none; display: flex; align-items: center; gap: 16px; padding: 0 16px; border-bottom: 1px solid var(--line); background: var(--deck); }
.brand { display: flex; align-items: center; gap: 10px; font: 600 15px var(--display); letter-spacing: 0.01em; color: var(--wave); }
.brand span { color: var(--text); }
.top-mid { flex: 1; color: var(--mute); font-size: 12px; }
.top-mid.dirty { color: var(--amber); }
.top-right { display: flex; align-items: center; gap: 12px; }
.usage { color: var(--mute); font-size: 12px; font-variant-numeric: tabular-nums; }

.app { flex: 1; min-height: 0; display: grid; grid-template-columns: 290px minmax(0, 1fr) 350px; }
.col { min-height: 0; min-width: 0; display: flex; flex-direction: column; }
.left { border-right: 1px solid var(--line); background: var(--deck); overflow-y: auto; }
.right { border-left: 1px solid var(--line); background: var(--deck); }
.card { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.card + .card { border-top: 1px solid var(--line); }
.library { flex: 1; min-height: 240px; }

.btn { background: var(--rail); border: 1px solid var(--line); border-radius: 6px; padding: 7px 12px; cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover:not(:disabled) { border-color: var(--mute); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.small { padding: 4px 9px; font-size: 12.5px; }
.btn.wide { width: 100%; }
.btn.ghost { background: transparent; }
.btn.primary { background: var(--amber); border-color: var(--amber); color: #1c1503; font-weight: 600; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); border-color: var(--amber); }
.btn.danger { background: transparent; color: var(--rec); border-color: color-mix(in srgb, var(--rec) 45%, transparent); }
.btn.rec { display: inline-flex; align-items: center; gap: 8px; flex: 1; justify-content: center; padding: 10px 12px; font-weight: 600; }
.btn.rec .dot { width: 11px; height: 11px; border-radius: 50%; background: var(--rec); }
.btn.rec.on { background: var(--rec); border-color: var(--rec); color: #fff; }
.btn.rec.on .dot { background: #fff; border-radius: 2px; }
.btn.play { min-width: 76px; background: var(--wave); border-color: var(--wave); color: #06231e; font-weight: 600; }

.seg { display: flex; background: var(--ink); border: 1px solid var(--line); border-radius: 7px; padding: 2px; gap: 2px; }
.segbtn { flex: 1; background: transparent; border: 0; border-radius: 5px; padding: 6px 8px; cursor: pointer; color: var(--mute); font-weight: 500; font-size: 13px; }
.segbtn.on { background: var(--rail); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.segbtn.live { background: color-mix(in srgb, var(--ok) 20%, var(--rail)); color: var(--ok); }
.seg.small .segbtn { font-size: 12.5px; padding: 5px 6px; }
.hint, .note, .drop-hint, .scope { color: var(--mute); font-size: 12px; line-height: 1.45; }
.hint b, .note b { color: var(--text); font-weight: 600; }
.hint.err { color: var(--rec); }
.scope { padding: 8px 10px; border-radius: 6px; background: var(--ink); border-left: 3px solid var(--line); }
.scope.sel { border-left-color: var(--amber); color: var(--text); }
.meter { height: 7px; background: var(--ink); border-radius: 4px; overflow: hidden; border: 1px solid var(--line); margin-top: -4px; }
.meter-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--ok) 0 70%, var(--amber) 85%, var(--rec) 100%); background-size: 258px 100%; transition: width 60ms linear; }
.cap-row { display: flex; align-items: center; gap: 12px; }
.timecode { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 16px; min-width: 64px; text-align: right; }
.pair { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pair label { color: var(--mute); font-size: 12.5px; }
select, input[type="text"], input[type="number"], input[type="search"], textarea { background: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; min-width: 0; }
textarea { width: 100%; resize: vertical; }
input[type="number"] { width: 68px; font-variant-numeric: tabular-nums; }
input[type="range"] { accent-color: var(--amber); flex: 1; min-width: 60px; }
input[type="checkbox"] { accent-color: var(--amber); width: 15px; height: 15px; margin: 0; flex: none; }

.lib-head { display: flex; align-items: center; justify-content: space-between; }
.lib-tools { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--mute); }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; }
.clips { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; min-height: 80px; }
.clip { display: grid; grid-template-columns: 15px 44px minmax(0, 1fr) auto auto; align-items: center; gap: 9px; padding: 6px 8px; border-radius: 6px; cursor: pointer; border: 1px solid transparent; }
.clip:hover { background: var(--rail); }
.clip.on { background: var(--rail); border-color: var(--line); box-shadow: inset 3px 0 0 var(--wave); }
.clip canvas { width: 44px; height: 22px; display: block; }
.clip .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.clip .tg { display: block; color: var(--mute); font-size: 11.5px; font-weight: 400; overflow: hidden; text-overflow: ellipsis; }
.clip .du { color: var(--mute); font-size: 12px; font-variant-numeric: tabular-nums; }
.pill { display: inline-block; font-size: 10.5px; padding: 0 5px; border-radius: 8px; margin-left: 6px; vertical-align: 1px; border: 1px solid var(--line); color: var(--mute); }
.pill.loop { color: var(--amber); border-color: color-mix(in srgb, var(--amber) 50%, transparent); }
.pill.warn { color: var(--rec); border-color: color-mix(in srgb, var(--rec) 50%, transparent); }

.center { padding: 14px 18px; gap: 10px; }
.clip-head { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; }
#clipName { font: 600 19px var(--ui); background: transparent; border: 1px solid transparent; padding: 2px 6px; margin-left: -7px; flex: 1; min-width: 140px; border-radius: 6px; }
#clipName:hover { border-color: var(--line); }
.facts { display: flex; gap: 14px; color: var(--mute); font-size: 12.5px; font-variant-numeric: tabular-nums; flex-wrap: wrap; }
.facts b { color: var(--text); font-weight: 500; }
.facts .hot { color: var(--rec); }
.toolbar { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.tb { background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 5px 9px; cursor: pointer; color: var(--text); font-size: 13px; font-weight: 500; }
.tb:hover:not(:disabled) { background: var(--rail); border-color: var(--line); }
.tb:disabled { opacity: 0.35; cursor: not-allowed; }
.tb.strong { color: var(--amber); }
.sep { width: 1px; height: 18px; background: var(--line); margin: 0 4px; }
.wavewrap { flex: 1; min-height: 160px; display: flex; flex-direction: column; gap: 6px; }
.mini { width: 100%; height: 44px; display: block; border-radius: 6px; background: var(--deck); border: 1px solid var(--line); cursor: grab; }
.stage { position: relative; flex: 1; min-height: 120px; border-radius: 8px; background: #0c0f15; border: 1px solid var(--line); overflow: hidden; touch-action: none; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.stage.drop { border-color: var(--amber); }
.empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--mute); padding: 20px; text-align: center; }
.transport { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.toggle { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--mute); cursor: pointer; }
.readout { display: flex; gap: 16px; margin-left: auto; font-variant-numeric: tabular-nums; }
.readout div { display: flex; flex-direction: column; line-height: 1.25; }
.readout span { color: var(--mute); font-size: 11px; }
.readout b { font-weight: 600; font-size: 13.5px; min-width: 62px; }
.zoom { display: flex; gap: 2px; }

.tabs { display: flex; border-bottom: 1px solid var(--line); flex: none; }
.tab { flex: 1; background: transparent; border: 0; border-bottom: 2px solid transparent; padding: 12px 4px 10px; cursor: pointer; color: var(--mute); font-weight: 600; font-size: 13px; }
.tab.on { color: var(--text); border-bottom-color: var(--amber); }
.panel { flex: 1; overflow-y: auto; padding: 14px 16px 24px; display: flex; flex-direction: column; gap: 16px; }
.group { display: flex; flex-direction: column; gap: 8px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.group:last-of-type { border-bottom: 0; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row > label { color: var(--text); font-size: 13px; min-width: 96px; }
.row > label.inline { min-width: 0; margin-left: 6px; }
.row.eq > label { min-width: 40px; }
.row.btns { gap: 6px; }
.row output { font-variant-numeric: tabular-nums; min-width: 46px; text-align: right; font-size: 12.5px; color: var(--mute); }
.row .btn.small { margin-left: auto; }
.row.btns .btn.small { margin-left: 0; }
.unit { color: var(--mute); font-size: 12px; }
.stack { display: flex; flex-direction: column; gap: 4px; }
.stack label { font-size: 12px; color: var(--mute); }
.fmts { display: flex; gap: 16px; }
.loopinfo { font-variant-numeric: tabular-nums; padding: 8px 10px; background: var(--ink); border-radius: 6px; font-size: 13px; }
.stats { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; margin: 0; font-variant-numeric: tabular-nums; font-size: 13px; }
.stats dt { color: var(--mute); }
.stats dd { margin: 0; }
.built table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-bottom: 10px; font-variant-numeric: tabular-nums; }
.built th { text-align: left; color: var(--mute); font-weight: 500; padding: 4px 0; border-bottom: 1px solid var(--line); }
.built td { padding: 4px 0; border-bottom: 1px solid var(--line); word-break: break-all; }
.built td:last-child, .built th:last-child { text-align: right; white-space: nowrap; padding-left: 10px; }
.built tfoot td { font-weight: 600; border-bottom: 0; }

.toast { position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 20px); background: var(--text); color: var(--ink); padding: 9px 16px; border-radius: 8px; font-weight: 500; opacity: 0; pointer-events: none; transition: opacity 0.18s, transform 0.18s; max-width: min(520px, 90vw); z-index: 30; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--rec); color: #fff; }
.busy, .modal { position: fixed; inset: 0; background: rgba(8, 10, 14, 0.66); display: grid; place-items: center; z-index: 20; }
.busy-box { background: var(--rail); border: 1px solid var(--line); border-radius: 10px; padding: 16px 22px; display: flex; align-items: center; gap: 12px; }
.spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--amber); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.modal-box { background: var(--deck); border: 1px solid var(--line); border-radius: 12px; padding: 20px 22px; width: min(460px, 92vw); max-height: 86vh; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5); }
.modal-box h2 { font-size: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 7px 16px; margin: 0; }
.keys dt { font-variant-numeric: tabular-nums; }
.keys dd { margin: 0; color: var(--mute); }
kbd { background: var(--rail); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 6px; font: 500 12px var(--ui); }

@media (max-width: 1180px) {
  html, body { height: auto; }
  body { display: block; overflow: auto; }
  .app { display: grid; grid-template-columns: 280px minmax(0, 1fr); }
  .col { min-height: auto; }
  .left { overflow: visible; }
  .center { height: 620px; }
  .clips { max-height: 300px; }
  .right { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); }
  .panel { overflow: visible; }
}
@media (max-width: 720px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .left { border-right: 0; border-bottom: 1px solid var(--line); }
  .center { height: auto; padding: 14px 16px; }
  .wavewrap { flex: none; height: 300px; }
  .readout { margin-left: 0; }
  .top { height: auto; min-height: 50px; padding: 8px 16px; flex-wrap: wrap; gap: 8px 12px; }
  .top-mid, #btnHelp, .brand .tag { display: none; }
  .top-right { margin-left: auto; }
  .tab { padding: 14px 4px 12px; }
  .btn.small, .tb { padding: 8px 11px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation-duration: 0.01ms !important; } }
.brand .tag { font: 400 12px var(--ui); font-style: normal; color: var(--mute); letter-spacing: 0; margin-left: 4px; }
@media (max-width: 720px) { .brand .tag { display: none; } }

.pair select { max-width: 170px; text-overflow: ellipsis; }

.acct { display: flex; align-items: center; gap: 10px; }
.quota { width: 90px; height: 6px; border-radius: 3px; background: var(--ink); border: 1px solid var(--line); overflow: hidden; }
.quota-fill { height: 100%; background: var(--wave); width: 0; }
.quota-fill.high { background: var(--amber); }
.quota-fill.full { background: var(--rec); }
.quota-text { color: var(--mute); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pill.cloud { color: var(--wave); border-color: color-mix(in srgb, var(--wave) 45%, transparent); }
.pill.changed { color: var(--amber); border-color: color-mix(in srgb, var(--amber) 45%, transparent); }
.cloudonly { display: flex; flex-direction: column; gap: 4px; border-top: 1px solid var(--line); padding-top: 10px; }
.cloudonly .clips { flex: none; max-height: 180px; }
.cloudonly .clip { grid-template-columns: minmax(0, 1fr) auto; }
.form { display: flex; flex-direction: column; gap: 12px; }
.form .stack input { padding: 8px 10px; }
.form .err { color: var(--rec); font-size: 13px; }
.form .alt { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line); padding-top: 12px; }
.form a, .linkbtn { color: var(--wave); background: none; border: 0; padding: 0; cursor: pointer; font-size: 13px; text-decoration: underline; text-underline-offset: 2px; }
.notice { padding: 10px 12px; border-radius: 6px; background: var(--ink); border-left: 3px solid var(--amber); font-size: 13px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.plans { display: grid; gap: 6px; }
.plan { display: flex; justify-content: space-between; gap: 12px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; font-variant-numeric: tabular-nums; }
.plan.on { border-color: var(--wave); }
.plan span { color: var(--mute); }
.acct-actions { display: flex; flex-wrap: wrap; gap: 8px; }
@media (max-width: 720px) { .quota, .usage { display: none; } }

.skip { position: absolute; left: -999px; top: 8px; background: var(--amber); color: #1c1503; padding: 8px 12px; border-radius: 6px; z-index: 50; font-weight: 600; }
.skip:focus { left: 8px; }
h1.brand { margin: 0; }
.brand a { display: flex; align-items: center; gap: 10px; color: var(--wave); text-decoration: none; }
.brand a span { color: var(--text); }
a.btn { text-decoration: none; display: inline-block; color: var(--text); }

.ver { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ver label { color: var(--mute); font-size: 12.5px; }
.ver select { max-width: min(420px, 100%); min-width: 200px; }
.ver .count { color: var(--mute); font-size: 12px; font-variant-numeric: tabular-nums; }
.clip .del { background: transparent; border: 1px solid transparent; color: var(--mute); border-radius: 5px; width: 24px; height: 24px; line-height: 1; font-size: 17px; cursor: pointer; padding: 0; opacity: 0; }
.clip:hover .del, .clip.on .del, .clip .del:focus-visible { opacity: 1; }
.clip .del:hover { color: var(--rec); border-color: color-mix(in srgb, var(--rec) 50%, transparent); }
.linkbtn { color: var(--wave); background: none; border: 0; padding: 0; cursor: pointer; font-size: 12.5px; text-decoration: underline; text-underline-offset: 2px; }
.linkbtn.danger { color: var(--rec); }
.cloudonly .clip { grid-template-columns: minmax(0, 1fr) auto auto; }
@media (hover: none) { .clip .del { opacity: 1; } }

.clip .tg .pill { margin: 0 6px 0 0; }

.choice { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.choice legend { padding: 0 6px; font-weight: 600; font-size: 13px; }
.usage { cursor: help; }
