/* CUTROOM — dark NLE theme. The app is a fixed full-viewport grid; the page never
   scrolls. Anything long scrolls inside its own panel. */

:root {
  --bg: #141519;
  --bg-2: #1b1d23;
  --bg-3: #22252d;
  --line: #2e323c;
  --ink: #e8eaf0;
  --ink-dim: #9aa0ad;
  --accent: #e8613c;        /* the one warm colour: the cut */
  --accent-ink: #fff;
  --sel: #3d7bd9;
  --clip-video: #2c4a6e;
  --clip-video-edge: #4a7bb5;
  --clip-audio: #2e5c46;
  --clip-audio-edge: #4d9c77;
  --danger: #d94f4f;
  --radius: 8px;
  font-size: 15px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; overflow: hidden;
  background: var(--bg); color: var(--ink);
  font-family: system-ui, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; }
input, select { font: inherit; color: var(--ink); }
h1 { font-size: 1.5rem; margin: .4em 0; }
h2 { font-size: 1.05rem; margin: .6em 0 .4em; color: var(--ink); }
.dim { color: var(--ink-dim); }
.grow { flex: 1; }
[hidden] { display: none !important; }

/* ---------- shared widgets ---------- */
.btn {
  background: var(--bg-3); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px 14px; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: #48506088; background: #272b34; }
.btn.accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.accent:hover { filter: brightness(1.1); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--bg-3); }
.btn.small { padding: 5px 10px; font-size: .88rem; }
.btn.toggled { border-color: var(--sel); color: #9ec2f5; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.play { font-size: 1.1rem; min-width: 52px; }

input[type=text], select {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 8px 10px;
}
input[type=text]:focus, select:focus { outline: 1px solid var(--sel); }

.veil {
  position: fixed; inset: 0; z-index: 50;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  overflow: auto;
}
#export-veil { background: #0009; backdrop-filter: blur(3px); }

.modal {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 22px 26px; width: min(440px, 92vw);
}
.modal h2 { margin-top: 0; }
.modal label { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 10px 0; }
.modal-btns { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.bar { height: 10px; background: var(--bg-3); border-radius: 5px; overflow: hidden; margin: 14px 0 6px; }
#ex-bar-fill { height: 100%; width: 0%; background: var(--accent); transition: width .2s; }

.brand-mark { font-weight: 800; letter-spacing: .08em; font-size: 1.1rem; }
.brand-mark span { color: var(--accent); }
.brand-mark.big { font-size: 2.2rem; }

/* ---------- capability gate ---------- */
.gate-card { max-width: 520px; padding: 32px; text-align: left; line-height: 1.5; }
.gate-missing { color: var(--ink-dim); font-size: .9rem; }

/* ---------- project screen ---------- */
.home-inner { width: min(880px, 94vw); max-height: 100vh; overflow: auto; padding: 40px 16px 24px; }
.home-head { margin-bottom: 26px; }
.tagline { color: var(--ink-dim); margin-top: 6px; }
.home-new .new-row { display: flex; gap: 10px; flex-wrap: wrap; }
#np-name { flex: 1; min-width: 180px; }
.proj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin-top: 10px; }
.proj-card {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px;
  overflow: hidden; cursor: pointer; position: relative;
}
.proj-card:hover { border-color: #4a5265; }
.proj-poster { width: 100%; aspect-ratio: 16/9; background: #000; object-fit: cover; display: block; }
.proj-poster.blank { display: flex; align-items: center; justify-content: center; color: #444; font-size: 1.6rem; }
.proj-meta { padding: 10px 12px; }
.proj-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj-sub { color: var(--ink-dim); font-size: .82rem; margin-top: 2px; }
.proj-del {
  position: absolute; top: 6px; right: 6px; background: #000a; border: none; color: #ccc;
  border-radius: 6px; width: 26px; height: 26px; cursor: pointer; display: none;
}
.proj-card:hover .proj-del { display: block; }
.proj-del:hover { color: #fff; background: var(--danger); }
.home-foot { margin-top: 30px; }

/* ---------- editor frame ---------- */
#editor {
  position: fixed; inset: 0;
  display: grid;
  grid-template-rows: 48px 1fr 240px;
  /* minmax(0,…): the timeline scroller's content must never propagate its
     intrinsic width up and blow the whole app grid past the viewport */
  grid-template-columns: minmax(0, 1fr);
}
#topbar {
  display: flex; align-items: center; gap: 10px; padding: 0 12px;
  background: var(--bg-2); border-bottom: 1px solid var(--line);
}
.proj-name {
  background: transparent; border: 1px solid transparent; border-radius: 6px;
  padding: 5px 8px; width: 220px; font-weight: 600;
}
.proj-name:hover, .proj-name:focus { border-color: var(--line); background: var(--bg); }
.save-dot { color: #57b97a; font-size: .7rem; transition: color .3s; }
.save-dot.dirty { color: var(--ink-dim); }
.storage-meter { font-size: .82rem; }

#workspace {
  display: grid; grid-template-columns: 264px minmax(0, 1fr) 250px; min-height: 0;
}
#pool-panel, #inspector-panel {
  background: var(--bg-2); display: flex; flex-direction: column; min-height: 0;
}
#pool-panel { border-right: 1px solid var(--line); }
#inspector-panel { border-left: 1px solid var(--line); }
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; border-bottom: 1px solid var(--line);
  font-weight: 600; font-size: .92rem; flex: none;
}

/* ---------- media pool ---------- */
.pool-list { overflow: auto; padding: 10px; display: flex; flex-direction: column; gap: 10px; }
.pool-item {
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 8px;
  overflow: hidden; cursor: grab; user-select: none;
}
.pool-item:hover { border-color: #4a5265; }
.pool-thumb { width: 100%; aspect-ratio: 16/9; object-fit: cover; background: #000; display: block; }
.pool-item .pi-meta { padding: 7px 9px; }
.pool-item .pi-name { font-size: .86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pool-item .pi-sub { font-size: .78rem; color: var(--ink-dim); display: flex; justify-content: space-between; margin-top: 2px; }
.pool-item { position: relative; }
.pool-item .pi-del {
  position: absolute; top: 5px; right: 5px; z-index: 2;
  background: #000a; border: none; color: #ccc; border-radius: 6px;
  width: 24px; height: 24px; cursor: pointer; display: none;
}
.pool-item:hover .pi-del { display: block; }
.pool-item .pi-del:hover { color: #fff; background: var(--danger); }
.pool-item.importing { opacity: .65; cursor: progress; }
.pool-item .pi-bar { height: 3px; background: var(--accent); width: 0%; }
.pool-hint { padding: 18px 16px; line-height: 1.45; font-size: .9rem; }
.pool-hint p { margin: 0 0 10px; }

/* ---------- preview ---------- */
#preview-panel { display: flex; flex-direction: column; min-width: 0; background: #0c0d10; }
#preview-wrap { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; padding: 12px; }
#preview { max-width: 100%; max-height: 100%; background: #000; border-radius: 4px; }
#transport {
  display: flex; align-items: center; gap: 4px; padding: 6px 14px;
  background: var(--bg-2); border-top: 1px solid var(--line); flex: none;
}
.timecode { font-family: ui-monospace, Consolas, monospace; font-size: .95rem; min-width: 88px; }

/* ---------- inspector ---------- */
.insp-body { padding: 12px 14px; overflow: auto; font-size: .9rem; line-height: 1.5; }
.insp-body dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 14px; margin: 0 0 12px; }
.insp-body dt { color: var(--ink-dim); }
.insp-body dd { margin: 0; font-family: ui-monospace, Consolas, monospace; font-size: .86rem; }
.insp-section {
  font-weight: 700; font-size: .8rem; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-dim); margin: 16px 0 6px; padding-top: 10px;
  border-top: 1px solid var(--line);
}
.insp-row { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.insp-label { width: 82px; flex: none; color: var(--ink-dim); font-size: .84rem; }
.insp-row input[type=range] { flex: 1; min-width: 0; }
.insp-row select { flex: 1; min-width: 0; padding: 4px 8px; }
.insp-val { font-family: ui-monospace, Consolas, monospace; font-size: .8rem; min-width: 38px; text-align: right; }
.insp-valwrap { display: flex; align-items: center; gap: 6px; flex: none; }
.kf-btn {
  background: transparent; border: 1px solid var(--line); border-radius: 5px;
  color: var(--ink-dim); width: 24px; height: 22px; cursor: pointer; font-size: .7rem;
}
.kf-btn.on { color: #e8b13c; border-color: #e8b13c88; }
.kf-btn:hover { background: var(--bg-3); }
.insp-text {
  width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  color: var(--ink); padding: 8px 10px; font: inherit; resize: vertical;
}
.insp-hint { font-size: .8rem; line-height: 1.4; }

/* ---------- timeline ---------- */
#timeline-zone {
  display: flex; flex-direction: column; min-height: 0; min-width: 0;
  background: var(--bg-2); border-top: 1px solid var(--line);
}
#tl-toolbar { display: flex; align-items: center; gap: 8px; padding: 6px 12px; flex: none; }
.zoom-label { display: flex; align-items: center; gap: 8px; font-size: .85rem; }
#tl-zoom { width: 140px; }
#tl-scroll { flex: 1; overflow-x: auto; overflow-y: hidden; position: relative; }
#tl-content { position: relative; height: 100%; min-width: 100%; }
#tl-ruler { display: block; height: 26px; cursor: text; position: sticky; left: 0; }
#tl-tracks { position: relative; }
.tl-track {
  position: relative; height: 62px; border-top: 1px solid var(--line);
  background: repeating-linear-gradient(90deg, transparent 0, transparent 100%);
}
.tl-track.audio { height: 48px; }
.tl-track-label {
  position: sticky; left: 0; top: 4px; z-index: 3;
  display: inline-block; margin: 4px; padding: 1px 7px; border-radius: 4px;
  background: #0007; color: var(--ink-dim); font-size: .72rem; font-weight: 700;
  pointer-events: none;
}
.tl-clip {
  position: absolute; top: 4px; bottom: 4px; border-radius: 6px;
  background: var(--clip-video); border: 1px solid var(--clip-video-edge);
  overflow: hidden; cursor: grab; user-select: none;
}
.tl-clip.audio { background: var(--clip-audio); border-color: var(--clip-audio-edge); }
.tl-clip.title { background: #4a3a63; border-color: #7a63a8; }
.clip-trans {
  position: absolute; left: 2px; bottom: 1px; z-index: 2;
  color: #ffd47f; font-size: .78rem; text-shadow: 0 1px 2px #000; pointer-events: none;
}
.clip-kf {
  position: absolute; right: 10px; bottom: 1px; z-index: 2;
  color: #e8b13c; font-size: .6rem; text-shadow: 0 1px 2px #000; pointer-events: none;
}
.tl-track-del {
  position: sticky; left: 44px; top: 4px; z-index: 3;
  margin: 4px 0; background: #0007; border: none; color: var(--ink-dim);
  border-radius: 4px; width: 20px; height: 18px; cursor: pointer; font-size: .65rem;
}
.tl-track-del:hover { color: #fff; background: var(--danger); }
.tl-clip.selected { outline: 2px solid var(--sel); outline-offset: 0; }
.tl-clip.linked-hl { outline: 2px dashed #3d7bd966; outline-offset: 0; }
.tl-clip canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.tl-clip .clip-name {
  position: absolute; left: 6px; top: 3px; right: 6px; z-index: 2;
  font-size: .72rem; font-weight: 600; color: #fffd; text-shadow: 0 1px 2px #000;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; pointer-events: none;
}
.tl-clip .trim-l, .tl-clip .trim-r {
  position: absolute; top: 0; bottom: 0; width: 8px; cursor: ew-resize; z-index: 2;
}
.tl-clip .trim-l { left: 0; } .tl-clip .trim-r { right: 0; }
.tl-clip .trim-l:hover, .tl-clip .trim-r:hover { background: #fff3; }
#tl-playhead {
  position: absolute; top: 0; bottom: 0; width: 1px; background: var(--accent);
  z-index: 5; pointer-events: none;
}
#tl-playhead .ph-cap {
  position: absolute; top: 0; left: -5px; border: 6px solid transparent;
  border-top: 8px solid var(--accent); border-bottom: none;
}
.tl-drop-ok { outline: 2px dashed var(--sel); outline-offset: -2px; }

/* ---------- toasts ---------- */
#toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 90;
  display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 16px; font-size: .9rem; box-shadow: 0 4px 18px #000a;
  animation: toast-in .18s ease-out;
}
.toast.error { border-color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
