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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --border: #2a2d3a;
  --accent: #4f8ef7;
  --accent-hover: #6ba3ff;
  --text: #e2e4ed;
  --muted: #7a7f96;
  --highlight-bg: #3a3000;
  --highlight-text: #ffd54f;
  --mark-bg: #4f3a00;
  --mark-text: #ffd54f;
  --radius: 8px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  height: 100vh;
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ── Header ─────────────────────────────────────────── */
header {
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

header h1 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text);
}

#search-bar {
  display: flex;
  gap: 8px;
  align-items: center;
}

#search-input {
  flex: 1;
  max-width: 500px;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
}
#search-input:focus { border-color: var(--accent); }

button {
  padding: 8px 16px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: background .15s;
}

button:disabled { opacity: .4; cursor: default; }

#search-btn { background: var(--accent); color: #fff; }
#search-btn:hover:not(:disabled) { background: var(--accent-hover); }

button.secondary { background: var(--border); color: var(--text); }
button.secondary:hover:not(:disabled) { background: #353848; }

#total-count {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

/* ── Main layout ─────────────────────────────────────── */
main {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* ── List panel ──────────────────────────────────────── */
#list-panel {
  width: 280px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--surface);
}

#list-header {
  padding: 10px 14px;
  font-size: 12px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  min-height: 34px;
}

#video-list {
  list-style: none;
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

#video-list li {
  padding: 10px 14px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background .1s, border-color .1s;
}

#video-list li:hover { background: rgba(79,142,247,.08); }
#video-list li.active {
  background: rgba(79,142,247,.14);
  border-left-color: var(--accent);
}

.video-title {
  font-size: 13px;
  color: var(--text);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.video-meta-row {
  display: flex;
  gap: 8px;
  margin-top: 3px;
  font-size: 11px;
  color: var(--muted);
}

.video-duration::before { content: '⏱ '; }
.video-published { margin-left: auto; }

/* Search result extras */
.search-snippet {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.search-snippet mark {
  background: var(--mark-bg);
  color: var(--mark-text);
  border-radius: 2px;
  padding: 0 2px;
}

#pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  gap: 8px;
}

#pagination button { padding: 6px 10px; font-size: 12px; }
#page-indicator { font-size: 12px; color: var(--muted); }

/* ── Viewer ──────────────────────────────────────────── */
#viewer {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

#viewer-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  overflow: hidden;
  max-height: 200px;
  opacity: 1;
  transition: max-height 0.3s ease, opacity 0.2s ease, padding 0.3s ease;
}

#viewer-placeholder.collapsed {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}

#viewer-header {
  margin-bottom: 20px;
}

#viewer-header-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

#viewer-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
}

#viewer-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

#download-btn { padding: 6px 12px; font-size: 12px; }

#viewer-yt-link {
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}
#viewer-yt-link:hover { color: var(--accent); }

#viewer-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
}

#viewer-meta span + span::before {
  content: '·';
  margin-right: 12px;
}

.viewer-video-id {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--accent);
}

#transcript-lines {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.t-line {
  display: flex;
  gap: 16px;
  padding: 4px 8px;
  border-radius: 4px;
  line-height: 1.6;
  transition: background .1s;
}

.t-line:hover { background: rgba(255,255,255,.04); }

.t-line.highlight {
  background: var(--highlight-bg);
  border-left: 3px solid var(--highlight-text);
  padding-left: 5px;
}

.t-ts {
  flex-shrink: 0;
  width: 64px;
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--muted);
  padding-top: 2px;
  cursor: pointer;
}
.t-ts:hover { color: var(--accent); text-decoration: underline; }

.t-text { flex: 1; }

.t-text mark {
  background: var(--mark-bg);
  color: var(--mark-text);
  border-radius: 2px;
  padding: 0 2px;
}

/* ── Scrollbar ───────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
