/* ─── Reset & Base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1117;
  --bg2: #1a1d27;
  --bg3: #242838;
  --border: #2e3347;
  --text: #e4e6f0;
  --text2: #8b92ad;
  --accent: #5b6ef5;
  --accent2: #7c3aed;
  --green: #22c55e;
  --red: #ef4444;
  --orange: #f97316;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(0,0,0,.4);
}

body { background: var(--bg); color: var(--text); font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif; font-size: 15px; line-height: 1.6; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: #7c8ff8; }

.container { max-width: 1280px; margin: 0 auto; padding: 0 20px; }
.hidden { display: none !important; }

/* ─── Header ────────────────────────────────────────────── */
.header { background: var(--bg2); border-bottom: 1px solid var(--border); padding: 14px 0; position: sticky; top: 0; z-index: 100; }
.header .container { display: flex; align-items: center; justify-content: space-between; }
.logo { font-size: 20px; font-weight: 700; color: var(--text); }
.nav-links { display: flex; gap: 20px; }
.nav-links a { color: var(--text2); font-size: 14px; }
.nav-links a:hover { color: var(--text); }

/* ─── Buttons ───────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px; border-radius: var(--radius); border: none; cursor: pointer; font-size: 14px; font-weight: 500; transition: all .15s; white-space: nowrap; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #4a5de0; }
.btn-secondary { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: #2e3347; }
.btn-accent { background: linear-gradient(135deg, #f97316, #ec4899); color: #fff; }
.btn-accent:hover:not(:disabled) { opacity: .9; }
.btn-sm { padding: 5px 12px; font-size: 13px; background: var(--bg3); color: var(--text); border: 1px solid var(--border); border-radius: 6px; cursor: pointer; }
.btn-sm:hover { background: var(--border); }

/* ─── Hero / URL Form ────────────────────────────────────── */
.hero { text-align: center; padding: 56px 0 40px; }
.hero h1 { font-size: clamp(22px, 4vw, 36px); font-weight: 700; margin-bottom: 12px; }
.subtitle { color: var(--text2); margin-bottom: 32px; font-size: 16px; }

.url-form { display: flex; gap: 10px; max-width: 700px; margin: 0 auto 20px; }
.url-input { flex: 1; padding: 12px 16px; background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); font-size: 15px; outline: none; }
.url-input:focus { border-color: var(--accent); }

.status-block { display: flex; align-items: center; gap: 12px; justify-content: center; color: var(--text2); }
.spinner { width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.error-block { background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.3); color: #fca5a5; padding: 12px 20px; border-radius: var(--radius); max-width: 600px; margin: 0 auto; }

/* ─── Videos Grid ───────────────────────────────────────── */
.videos-section { padding: 0 0 60px; }
.videos-section h2 { font-size: 20px; font-weight: 600; margin-bottom: 20px; }

.videos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }

.video-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; transition: border-color .2s, transform .2s; display: block; }
.video-card:hover { border-color: var(--accent); transform: translateY(-2px); }

.video-thumb { position: relative; aspect-ratio: 16/9; overflow: hidden; }
.video-thumb img { width: 100%; height: 100%; object-fit: cover; }
.badge { position: absolute; top: 8px; right: 8px; padding: 3px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; }
.badge-ready { background: rgba(34,197,94,.2); color: #4ade80; }
.badge-error { background: rgba(239,68,68,.2); color: #f87171; }
.badge-processing { background: rgba(91,110,245,.2); color: #818cf8; }

.video-info { padding: 12px 14px; }
.video-title { font-weight: 500; font-size: 14px; line-height: 1.4; margin-bottom: 6px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.video-meta { font-size: 12px; color: var(--text2); display: flex; align-items: center; gap: 6px; }
.dot { opacity: .4; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text2); }
.empty-icon { font-size: 48px; margin-bottom: 16px; }

/* ─── Video Page ─────────────────────────────────────────── */
.video-page { padding-top: 28px; }
.video-title-h1 { font-size: clamp(16px, 2.5vw, 24px); font-weight: 600; margin-bottom: 20px; line-height: 1.3; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.export-group { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.export-label { font-size: 13px; color: var(--text2); }

.search-panel { display: flex; gap: 10px; margin-bottom: 12px; }
.search-input { flex: 1; padding: 10px 14px; background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); font-size: 14px; outline: none; }
.search-input:focus { border-color: var(--accent); }

.search-results { margin-bottom: 16px; }
.search-title { font-weight: 600; margin-bottom: 10px; color: var(--text2); font-size: 14px; }
.search-result-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.sr-time { color: var(--accent); font-size: 13px; font-weight: 600; cursor: pointer; margin-bottom: 4px; }
.sr-time:hover { color: #7c8ff8; }
.sr-summary { font-weight: 500; margin-bottom: 4px; font-size: 14px; }
.sr-quote { color: var(--text2); font-style: italic; font-size: 13px; margin-bottom: 10px; }
.no-results { color: var(--text2); padding: 12px; }

/* ─── Content Grid ────────────────────────────────────────── */
.content-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
@media (max-width: 900px) { .content-grid { grid-template-columns: 1fr; } }

/* ─── Player ────────────────────────────────────────────── */
.left-panel { position: sticky; top: 70px; }
.player-wrap { position: relative; padding-bottom: 56.25%; height: 0; border-radius: var(--radius); overflow: hidden; background: #000; margin-bottom: 20px; }
.player-wrap iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }

/* ─── Clip Tool ─────────────────────────────────────────── */
.clip-tool { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.clip-tool h3 { font-size: 15px; margin-bottom: 12px; }
.clip-inputs { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.clip-inputs label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text2); }
.time-input { width: 80px; padding: 8px 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: 14px; text-align: center; outline: none; }
.time-input:focus { border-color: var(--accent); }
.clip-status { margin-top: 10px; font-size: 13px; color: var(--text2); padding: 8px 12px; background: var(--bg); border-radius: 8px; }

/* ─── Highlights ─────────────────────────────────────────── */
.highlights-block { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.highlights-block h3 { font-size: 15px; margin-bottom: 14px; }
.highlight-card { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin-bottom: 10px; }
.highlight-header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.highlight-num { background: linear-gradient(135deg, #f97316, #ec4899); color: #fff; width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; flex-shrink: 0; }
.highlight-time { color: var(--accent); font-size: 13px; font-weight: 600; cursor: pointer; flex: 1; }
.highlight-time:hover { color: #7c8ff8; }
.highlight-title { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.highlight-desc { color: var(--text2); font-size: 13px; line-height: 1.5; }

/* ─── Transcript ─────────────────────────────────────────── */
.right-panel { max-height: calc(100vh - 100px); overflow-y: auto; position: sticky; top: 70px; }
.transcript-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.transcript-header h2 { font-size: 16px; font-weight: 600; }
.word-count { font-size: 12px; color: var(--text2); }

.transcript { line-height: 1.8; font-size: 15px; }
.ts-label { display: inline-block; color: var(--accent); font-size: 12px; font-weight: 700; padding: 2px 8px; background: rgba(91,110,245,.12); border-radius: 5px; margin: 12px 0 4px; cursor: pointer; }
.ts-label:hover { background: rgba(91,110,245,.25); }
.ts-text { cursor: pointer; border-radius: 3px; padding: 1px 2px; transition: background .15s; }
.ts-text:hover { background: rgba(255,255,255,.06); }
.ts-text.ts-active { background: rgba(91,110,245,.2); color: #c7d0ff; }

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