:root {
  --bg: #09090b;
  --surface: #18181b;
  --surface2: #1f1f23;
  --border: #27272a;
  --text: #fafafa;
  --text-muted: #71717a;
  --accent: #818cf8;
  --accent-dim: #312e81;
  --accent-hover: #a5b4fc;
  --red: #f87171;
  --green: #4ade80;
  --yellow: #fbbf24;
  --radius: 10px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

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

/* ── Header ── */
header {
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(9, 9, 11, 0.85);
  backdrop-filter: blur(12px);
}
.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}
.logo svg { width: 28px; height: 28px; color: var(--accent); }
.back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 0.9rem;
  transition: color 0.15s;
}
.back-btn:hover { color: var(--text); }
.back-btn svg { width: 18px; height: 18px; }

/* ── Main layout ── */
main { max-width: 1100px; margin: 0 auto; padding: 2.5rem 1.5rem; }

/* ── Hero / Submit form ── */
.hero {
  text-align: center;
  padding: 3rem 0 2.5rem;
}
.hero h1 {
  font-size: 2.4rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent) 0%, #c4b5fd 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.6rem;
}
.hero p { color: var(--text-muted); font-size: 1.1rem; margin-bottom: 2rem; }

.input-row {
  display: flex;
  gap: 0.6rem;
  max-width: 680px;
  margin: 0 auto;
}
.input-row input[type="url"] {
  flex: 1;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s;
}
.input-row input[type="url"]:focus { border-color: var(--accent); }
.input-row input[type="url"]::placeholder { color: var(--text-muted); }

.btn {
  padding: 0.75rem 1.4rem;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  transition: background 0.15s, opacity 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-danger {
  background: transparent;
  color: var(--red);
  border: 1px solid transparent;
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
}
.btn-danger:hover { border-color: var(--red); background: rgba(248,113,113,0.08); }
.btn-copy {
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
  font-size: 0.85rem;
  padding: 0.45rem 0.9rem;
}
.btn-copy:hover { color: var(--text); border-color: var(--accent); }
.btn-copy.copied { color: var(--green); border-color: var(--green); }

/* ── Status bar ── */
.status-bar {
  max-width: 680px;
  margin: 1rem auto 0;
  padding: 0.7rem 1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  display: none;
  align-items: center;
  gap: 0.6rem;
}
.status-bar.visible { display: flex; }
.status-bar.info { background: var(--accent-dim); border: 1px solid var(--accent); color: var(--accent-hover); }
.status-bar.error { background: rgba(248,113,113,0.12); border: 1px solid var(--red); color: var(--red); }
.status-bar.success { background: rgba(74,222,128,0.1); border: 1px solid var(--green); color: var(--green); }
.spinner {
  width: 16px; height: 16px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Transcripts section ── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 2.5rem 0 1.2rem;
}
.section-header h2 { font-size: 1.2rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
}
.empty-state svg { width: 56px; height: 56px; margin-bottom: 1rem; opacity: 0.3; }
.empty-state p { font-size: 1rem; }

/* ── Transcript cards ── */
.transcripts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.2rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.15s, transform 0.15s;
  cursor: pointer;
  display: flex;
  flex-direction: column;
}
.card:hover { border-color: var(--accent); transform: translateY(-2px); }

.card-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  background: var(--surface2);
  overflow: hidden;
}
.card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.card-thumb .duration-badge {
  position: absolute;
  bottom: 6px; right: 6px;
  background: rgba(0,0,0,0.8);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
}

.card-body { padding: 1rem; flex: 1; }
.card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.3rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-channel { font-size: 0.8rem; color: var(--text-muted); }

.card-footer {
  padding: 0.6rem 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-date { font-size: 0.78rem; color: var(--text-muted); }

/* ── Transcript detail page ── */
.video-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  margin-bottom: 1.5rem;
}
.video-wrap iframe { width: 100%; height: 100%; border: none; }

.video-meta { margin-bottom: 1.5rem; }
.video-meta h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.4rem; }
.video-meta .meta-row { display: flex; align-items: center; gap: 1rem; color: var(--text-muted); font-size: 0.875rem; }
.meta-sep { opacity: 0.3; }

/* ── Tabs ── */
.tabs { display: flex; gap: 2px; margin-bottom: 1.5rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 4px; width: fit-content; }
.tab-btn {
  padding: 0.5rem 1.2rem;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.tab-btn.active { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.tab-btn:hover:not(.active) { color: var(--text); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Markdown content ── */
.markdown-body {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  line-height: 1.75;
}
.markdown-body h2 { font-size: 1.4rem; margin: 0 0 1rem; color: var(--accent-hover); }
.markdown-body h3 { font-size: 1.1rem; margin: 1.5rem 0 0.6rem; color: var(--text); border-bottom: 1px solid var(--border); padding-bottom: 0.3rem; }
.markdown-body p { margin: 0 0 1rem; color: var(--text); }
.markdown-body ul, .markdown-body ol { padding-left: 1.5rem; margin: 0 0 1rem; color: var(--text); }
.markdown-body li { margin-bottom: 0.3rem; }
.markdown-body blockquote { border-left: 3px solid var(--accent); padding-left: 1rem; color: var(--text-muted); margin: 1rem 0; font-style: italic; }
.markdown-body code { background: var(--surface2); padding: 0.1em 0.4em; border-radius: 4px; font-size: 0.875em; color: var(--accent-hover); }
.markdown-body strong { color: var(--text); }

/* ── Raw transcript ── */
.raw-transcript {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.8;
  max-height: 600px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: 'Courier New', monospace;
}

/* ── Responsive ── */
@media (max-width: 640px) {
  .hero h1 { font-size: 1.8rem; }
  .input-row { flex-direction: column; }
  main { padding: 1.5rem 1rem; }
  .video-meta h1 { font-size: 1.2rem; }
}
