:root {
  --bg: #14161a;
  --bg-panel: #1c1f26;
  --bg-elevated: #262a33;
  --border: #333844;
  --text: #e8eaed;
  --text-dim: #9aa0ab;
  --accent: #ff6a1a;
  --accent-dim: #b84e12;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 13px;
}

.app {
  display: flex;
  height: 100%;
}

/* ---------- Sidebar / library ---------- */

.sidebar {
  width: 260px;
  flex: 0 0 260px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-header h1 {
  font-size: 14px;
  margin: 0;
  color: var(--text);
  letter-spacing: 0.02em;
}

.btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}

.btn:hover { background: #303542; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent-dim); color: #1a1a1a; font-weight: 600; }
.btn.primary:hover { background: #ff7c34; }
.btn.small { padding: 4px 8px; font-size: 11px; }
.btn.active { background: var(--accent); color: #1a1a1a; border-color: var(--accent-dim); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.clip-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
}

.clip-item {
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-dim);
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.clip-item:hover { background: var(--bg-elevated); color: var(--text); }
.clip-item.active { background: var(--accent); color: #1a1a1a; font-weight: 600; }

.play-info {
  border-top: 1px solid var(--border);
  padding: 10px 12px;
  font-size: 11px;
  color: var(--text-dim);
  max-height: 280px;
  overflow-y: auto;
  flex: 0 0 auto;
}

.play-info h2 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text);
  margin: 0 0 6px;
}

.play-info .field-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 3px 0;
  border-bottom: 1px solid var(--border);
}

.play-info .field-row .k { color: var(--text-dim); }
.play-info .field-row .v { color: var(--text); text-align: right; }

.play-info table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  font-size: 10px;
}

.play-info table th,
.play-info table td {
  border: 1px solid var(--border);
  padding: 3px 5px;
  text-align: left;
}

.play-info table th {
  background: var(--bg-elevated);
  color: var(--text);
}

.play-info-source {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
  font-size: 10px;
  color: var(--text-dim);
  line-height: 1.5;
}

.empty-hint {
  padding: 16px;
  color: var(--text-dim);
  line-height: 1.5;
  font-size: 12px;
}

/* ---------- Main / player ---------- */

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.telestration-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.telestration-bar .sep {
  width: 1px;
  align-self: stretch;
  background: var(--border);
  margin: 0 4px;
}

.color-swatch {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
}

.color-swatch.active { border-color: #fff; }

.notes-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
}

.notes-label {
  color: var(--text-dim);
  font-size: 11px;
  white-space: nowrap;
}

.notes-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  flex: 1;
}

.note-chip {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 12px;
  padding: 3px 10px;
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.note-chip:hover { color: var(--text); border-color: var(--accent-dim); }
.note-chip.active { background: var(--accent); color: #1a1a1a; border-color: var(--accent-dim); font-weight: 600; }

.video-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  min-height: 0;
  overflow: hidden;
}

.video-wrap {
  position: relative;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 16 / 9;
  width: 100%;
  background: #000;
}

.video-wrap video {
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
}

.video-wrap canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.video-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 13px;
  text-align: center;
  padding: 20px;
}

.controls {
  padding: 10px 14px 14px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
}

.seek-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.seek-row input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
}

.time-label {
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
  font-size: 12px;
  min-width: 92px;
  text-align: center;
}

.transport-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.transport-row .spacer { flex: 1; }

select.speed-select {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 12px;
}

.width-slider {
  width: 70px;
  accent-color: var(--accent);
}

label.field {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
  font-size: 11px;
}
