:root {
  --bg: #121417;
  --bg2: #1b1e23;
  --bg3: #242830;
  --line: #2f343d;
  --fg: #e6e8eb;
  --fg2: #9aa3ad;
  --accent: #4f8cff;
  --accent2: #ff8c42;
  --danger: #e5484d;
  --ok: #46c27a;
  --radius: 6px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 13px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); }
#app { height: 100%; display: flex; flex-direction: column; }
button, input, select, textarea { font: inherit; color: inherit; }
button {
  background: var(--bg3); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 5px 10px; cursor: pointer; line-height: 1.2; white-space: nowrap;
}
button:hover { background: #2c313a; }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: #3f7bea; }
button.danger { color: var(--danger); }
button.small { padding: 2px 7px; font-size: 12px; }
button.icon { padding: 5px 8px; min-width: 34px; }
input[type=text], input[type=number], select, textarea {
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 6px;
}
input[type=number] { width: 84px; }
textarea { width: 100%; resize: vertical; }
label { color: var(--fg2); }
.muted { color: var(--fg2); }
.hidden { display: none !important; }
.row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  background: var(--bg2); border-bottom: 1px solid var(--line); flex: none;
}
.topbar h1 { font-size: 15px; margin: 0; font-weight: 600; }
.topbar .name { font-size: 15px; font-weight: 600; background: transparent; border-color: transparent; min-width: 200px; }
.topbar .name:hover, .topbar .name:focus { border-color: var(--line); }
.badge { font-size: 11px; padding: 2px 6px; border-radius: 10px; background: var(--bg3); color: var(--fg2); }
.badge.dirty { background: #5a3d12; color: #ffc27a; }
.badge.ok { background: #16402a; color: #7fe0a8; }

/* ---------- Projektliste ---------- */
.projects { padding: 24px; max-width: 900px; margin: 0 auto; width: 100%; }
.projects h2 { margin: 0 0 12px; }
.project-list { display: grid; gap: 8px; margin-top: 16px; }
.project-card {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer;
}
.project-card:hover { border-color: var(--accent); }
.project-card .title { font-weight: 600; font-size: 14px; }
.empty { padding: 30px; text-align: center; color: var(--fg2); border: 1px dashed var(--line); border-radius: var(--radius); }

/* ---------- Editor ---------- */
.editor { flex: 1; display: grid; grid-template-columns: 1fr 340px; min-height: 0; }
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.sidebar { border-left: 1px solid var(--line); background: var(--bg2); display: flex; flex-direction: column; min-height: 0; }

.stage-wrap { flex: 1; position: relative; min-height: 0; background: #000; }
.stage { position: absolute; inset: 0; display: flex; gap: 2px; }
.stage.stack { flex-direction: column; }
.pane { flex: 1; position: relative; overflow: hidden; background: #000; min-width: 0; min-height: 0; touch-action: none; }
.pane video {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain;
  transform-origin: 50% 50%; will-change: transform; pointer-events: none; background: #000;
}
.pane.out video { opacity: .15; }
.pane .pane-label {
  position: absolute; top: 6px; left: 8px; z-index: 3; font-size: 11px; font-weight: 700;
  background: rgba(0,0,0,.55); padding: 2px 6px; border-radius: 4px; pointer-events: none;
}
.pane .pane-tools { position: absolute; top: 6px; right: 8px; z-index: 3; display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.pane:hover .pane-tools { opacity: 1; }
.pane .pane-tools button { background: rgba(0,0,0,.6); }
.pane .pane-zoom { position: absolute; bottom: 6px; right: 8px; z-index: 3; font-size: 11px; font-variant-numeric: tabular-nums; background: rgba(0,0,0,.55); padding: 2px 6px; border-radius: 4px; pointer-events: none; }
.pane .pane-status {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; z-index: 2; color: var(--fg2); text-align: center; padding: 20px;
}
.pane .pane-status.drop { border: 2px dashed var(--line); margin: 12px; border-radius: 10px; }
.pane .pane-status.dragover { border-color: var(--accent); background: rgba(79,140,255,.08); color: var(--fg); }
.pane .pane-status.drop input[type=file] { display: none; }
.progress { width: 220px; height: 6px; background: var(--bg3); border-radius: 3px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); transition: width .3s; }
.pane .error { color: var(--danger); max-width: 360px; font-size: 12px; }

.overlay-layer { position: absolute; inset: 0; pointer-events: none; z-index: 4; }
.ov {
  position: absolute; max-width: 40%; padding: 8px 12px; border-radius: 6px;
  background: rgba(10,12,16,.72); color: #fff; font-size: 15px; line-height: 1.35;
  white-space: pre-wrap; backdrop-filter: blur(4px); border-left: 3px solid var(--accent2);
}
.ov.tl { top: 30px; left: 14px; } .ov.tr { top: 30px; right: 14px; }
.ov.bl { bottom: 14px; left: 14px; } .ov.br { bottom: 14px; right: 14px; }
.ov.tc { top: 30px; left: 50%; transform: translateX(-50%); }
.ov.bc { bottom: 14px; left: 50%; transform: translateX(-50%); }

/* ---------- Transport + Timeline ---------- */
.transport {
  display: flex; align-items: center; gap: 6px; padding: 6px 10px; background: var(--bg2);
  border-top: 1px solid var(--line); flex-wrap: wrap;
}
.transport .time { font-variant-numeric: tabular-nums; font-family: ui-monospace, Menlo, monospace; font-size: 13px; min-width: 150px; }
.transport .sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.transport select { padding: 4px; }

.timeline {
  position: relative; height: 64px; background: var(--bg2); border-top: 1px solid var(--line);
  user-select: none; cursor: crosshair; flex: none;
}
.timeline .track { position: absolute; left: 12px; right: 12px; top: 30px; height: 10px; background: var(--bg3); border-radius: 5px; }
.timeline .range { position: absolute; top: 30px; height: 10px; background: rgba(79,140,255,.28); border-radius: 5px; }
.timeline .buffer-b { position: absolute; top: 44px; height: 3px; background: #4a5566; border-radius: 2px; }
.timeline .buffer-a { position: absolute; top: 24px; height: 3px; background: #4a5566; border-radius: 2px; }
.timeline .playhead { position: absolute; top: 14px; width: 2px; height: 42px; background: #fff; transform: translateX(-1px); pointer-events: none; }
.timeline .kf {
  position: absolute; top: 6px; width: 12px; height: 12px; background: var(--accent2); transform: translateX(-6px) rotate(45deg);
  border-radius: 2px; cursor: pointer; border: 1px solid #000;
}
.timeline .kf:hover, .timeline .kf.active { background: #ffd28f; }
.timeline .ov-mark { position: absolute; top: 52px; height: 6px; background: #b56cff; border-radius: 3px; opacity: .8; cursor: pointer; }
.timeline .ticks { position: absolute; left: 12px; right: 12px; top: 0; height: 100%; pointer-events: none; }
.timeline .tick { position: absolute; bottom: 0; font-size: 10px; color: var(--fg2); transform: translateX(-50%); }
.timeline .io { position: absolute; top: 26px; width: 4px; height: 18px; background: var(--accent); border-radius: 2px; transform: translateX(-2px); cursor: ew-resize; }

/* ---------- Sidebar ---------- */
.tabs { display: flex; border-bottom: 1px solid var(--line); flex: none; }
.tabs button { flex: 1; border: 0; border-radius: 0; background: transparent; padding: 9px 4px; color: var(--fg2); border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--fg); border-bottom-color: var(--accent); }
.tab-body { flex: 1; overflow: auto; padding: 10px; display: none; }
.tab-body.active { display: block; }
.section { margin-bottom: 14px; }
.section h3 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--fg2); }
.list { display: flex; flex-direction: column; gap: 4px; }
.item {
  padding: 7px 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); cursor: pointer;
  display: flex; flex-direction: column; gap: 4px;
}
.item:hover { border-color: #4a5160; }
.item.active { border-color: var(--accent); background: rgba(79,140,255,.08); }
.item .head { display: flex; align-items: center; gap: 6px; }
.item .head .t { font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: var(--fg2); }
.item .head .n { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .sub { font-size: 11px; color: var(--fg2); }
.item .actions { display: flex; gap: 4px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; align-items: center; }
.field { display: flex; flex-direction: column; gap: 3px; margin-bottom: 8px; }
.slider-row { display: grid; grid-template-columns: 22px 1fr 80px; gap: 6px; align-items: center; margin-bottom: 4px; }
.slider-row input[type=range] { width: 100%; }
.slider-row .t { font-family: ui-monospace, Menlo, monospace; font-size: 12px; text-align: right; }
.help { font-size: 11px; color: var(--fg2); line-height: 1.4; }
kbd { background: var(--bg3); border: 1px solid var(--line); border-radius: 3px; padding: 0 4px; font-size: 11px; font-family: ui-monospace, Menlo, monospace; }

.toast {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: #2b3038; color: #fff;
  padding: 8px 14px; border-radius: 6px; border: 1px solid var(--line); z-index: 50; box-shadow: 0 4px 20px rgba(0,0,0,.4);
}
.toast.error { border-color: var(--danger); }

@media (max-width: 900px) {
  .editor { grid-template-columns: 1fr; grid-template-rows: 1fr 300px; }
  .sidebar { border-left: 0; border-top: 1px solid var(--line); }
}

/* ---------- Eigene Timeline pro Video ---------- */
.vtimelines { background: var(--bg2); border-top: 1px solid var(--line); padding: 4px 12px 6px; display: flex; flex-direction: column; gap: 4px; flex: none; }
.vtl { display: grid; grid-template-columns: 18px 26px 1fr 26px 150px; gap: 6px; align-items: center; height: 24px; }
.vtl .lbl { font-weight: 700; font-size: 12px; }
.vtl .vtime { font-family: ui-monospace, Menlo, monospace; font-size: 12px; text-align: right; color: var(--fg2); font-variant-numeric: tabular-nums; }
.vtl .vstep { padding: 1px 0; min-width: 0; }
.vtl .vtrack { position: relative; height: 16px; background: var(--bg3); border-radius: 4px; cursor: pointer; touch-action: none; }
.vtl .vrange { position: absolute; top: 0; height: 100%; background: rgba(79,140,255,.28); border-radius: 4px; }
.vtl .vhead { position: absolute; top: -3px; width: 2px; height: 22px; background: #fff; transform: translateX(-1px); pointer-events: none; }
.vtl .vhead.out { background: var(--danger); }
.vtl.disabled { opacity: .35; }
.vtl.disabled .vtrack { cursor: default; }

/* ---------- Login ---------- */
.login { flex: 1; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-form { width: 320px; display: flex; flex-direction: column; gap: 10px; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 24px; }
.login-form h1 { margin: 0; font-size: 18px; }
.login-form p { margin: 0 0 6px; }
.login-form input { padding: 8px 10px; font-size: 14px; }
.login-form button { padding: 8px; font-size: 14px; margin-top: 4px; }
.login-error { color: var(--danger); min-height: 16px; font-size: 12px; }
