/* Didact — continues recall's identity: near-black ground, Fraunces display,
   ochre accent, warm card tones. Signature element: the timecode chip. */

:root {
  --ink: #0F1115;
  --surface: #16161B;
  --card: #1C1A18;
  --card-hover: #211F1C;
  --paper: #F0EDE4;
  --muted: #918B7E;
  --border: rgba(240, 237, 228, 0.08);
  --border-strong: rgba(240, 237, 228, 0.16);
  --ochre: #D9A574;
  --ochre-dim: #9C7752;
  --sage: #7BB3A0;
  --coral: #DC8A6A;
  --danger: #DC5050;
  --font-display: 'Fraunces', ui-serif, Georgia, serif;
  --font-sans: 'Manrope', ui-sans-serif, system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;
}

* { box-sizing: border-box; }
html, body { background: var(--ink); color: var(--paper); margin: 0; }
body { font-family: var(--font-sans); -webkit-font-smoothing: antialiased; min-height: 100vh; }
a { color: inherit; }
.safe-top { padding-top: env(safe-area-inset-top); }

/* ---- Buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: 10px; font-size: 0.9rem; font-weight: 600;
  transition: all 0.15s; border: 1px solid transparent; cursor: pointer; font-family: inherit; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--ochre); color: var(--ink); }
.btn-primary:hover:not(:disabled) { background: #E5B58A; }
.btn-ghost { background: transparent; color: var(--paper); border-color: var(--border-strong); }
.btn-ghost:hover:not(:disabled) { background: rgba(240,237,228,0.06); }
.btn-danger { background: transparent; color: var(--danger); border-color: rgba(220,80,80,0.4); }
.btn-danger:hover:not(:disabled) { background: rgba(220,80,80,0.1); }
.btn-lg { padding: 13px 22px; font-size: 1rem; min-height: 50px; }
.btn-sm { padding: 5px 11px; font-size: 0.8rem; }
.btn-block { width: 100%; }

.icon-btn { display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 9px; color: var(--muted); transition: all 0.15s;
  cursor: pointer; background: transparent; border: none; }
.icon-btn:hover { background: rgba(240,237,228,0.06); color: var(--paper); }
.icon-btn.danger:hover { color: var(--danger); background: rgba(220,80,80,0.1); }

/* ---- Forms ---- */
.form-input { width: 100%; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 11px 13px; color: var(--paper); font-size: 0.92rem; font-family: inherit; }
.form-input:focus { outline: none; border-color: var(--ochre); }
.form-label { display: block; font-size: 0.78rem; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.form-help { font-size: 0.76rem; color: var(--muted); margin-top: 6px; }
.form-group { margin-bottom: 14px; }
@media (max-width: 640px) { .form-input { font-size: 16px; } }

/* ---- Layout shell ---- */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 248px; flex-shrink: 0; border-right: 1px solid var(--border);
  background: var(--ink); position: sticky; top: 0; height: 100vh; overflow-y: auto;
  transition: width 0.18s ease, transform 0.18s ease; }
.sidebar-scrim { display: none; position: fixed; inset: 0; z-index: 70; border: 0; padding: 0;
  background: rgba(0,0,0,0.48); cursor: pointer; }
.sidebar-brand { display: flex; align-items: baseline; gap: 8px; padding: 22px 20px 4px; }
.sidebar-brand h1 { font-family: var(--font-display); font-size: 1.4rem; font-weight: 600; margin: 0; }
.sidebar-brand .mark { color: var(--ochre); }
.sidebar-tag { font-family: var(--font-display); font-style: italic; font-size: 0.78rem;
  color: var(--muted); padding: 0 20px 16px; }
.nav { display: flex; flex-direction: column; gap: 2px; padding: 6px 10px; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 9px;
  font-size: 0.9rem; color: var(--muted); cursor: pointer; background: none; border: none;
  text-align: left; width: 100%; font-family: inherit; transition: all 0.12s; }
.nav-item:hover { color: var(--paper); background: rgba(240,237,228,0.04); }
.nav-item.active { color: var(--paper); background: var(--card); }
.nav-item.active .nav-ico { color: var(--ochre); }
.nav-ico { display: inline-flex; flex-shrink: 0; }
.nav-label { min-width: 0; }
.nav-badge { margin-left: auto; font-size: 0.7rem; font-family: var(--font-mono);
  background: var(--ochre); color: var(--ink); border-radius: 999px; padding: 1px 7px; font-weight: 700; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; height: 56px; display: flex; align-items: center;
  gap: 12px; padding: 0 20px; background: rgba(15,17,21,0.85); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border); }
.sidebar-toggle { flex: 0 0 auto; border: 1px solid var(--border); }
.content { flex: 1; padding: 22px 20px 100px; }
.wrap { max-width: 1080px; margin: 0 auto; }
.wrap-narrow { max-width: 760px; margin: 0 auto; }

/* ---- Bottom nav (mobile) ---- */
.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; display: none;
  background: rgba(15,17,21,0.94); backdrop-filter: blur(14px);
  border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); }
.bottom-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 4px 7px; min-height: 56px; color: var(--muted); font-size: 0.66rem; font-weight: 600;
  background: none; border: none; cursor: pointer; font-family: inherit; }
.bottom-item.active { color: var(--ochre); }

/* Desktop/tablet rail mode */
@media (min-width: 901px) {
  .shell.sidebar-collapsed .sidebar { width: 72px; }
  .shell.sidebar-collapsed .sidebar-brand { justify-content: center; padding-left: 10px; padding-right: 10px; }
  .shell.sidebar-collapsed .brand-word,
  .shell.sidebar-collapsed .sidebar-tag,
  .shell.sidebar-collapsed .nav-label,
  .shell.sidebar-collapsed .nav-badge { display: none; }
  .shell.sidebar-collapsed .nav { padding-left: 8px; padding-right: 8px; }
  .shell.sidebar-collapsed .nav-item { justify-content: center; padding-left: 10px; padding-right: 10px; }
}

/* Mobile/off-canvas mode */
@media (max-width: 900px) {
  .shell { display: block; }
  .sidebar { display: block; position: fixed; z-index: 80; inset: 0 auto 0 0;
    width: min(82vw, 280px); max-width: calc(100vw - 48px); height: 100dvh;
    transform: translateX(0); box-shadow: 20px 0 60px rgba(0,0,0,0.45); }
  .shell.sidebar-collapsed .sidebar { width: min(82vw, 280px); transform: translateX(-105%); }
  .shell:not(.sidebar-collapsed) .sidebar-scrim { display: block; }
  .bottom-nav { display: flex; }
  .content { padding-bottom: 90px; }
}

/* ---- Page headers ---- */
.page-title { font-family: var(--font-display); font-size: 2rem; font-weight: 600; margin: 0 0 2px; }
.page-sub { color: var(--muted); font-size: 0.9rem; margin: 0 0 22px; }
.section-eyebrow { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--muted); font-weight: 700; margin: 28px 0 10px; }

/* ---- Add bar ---- */
.add-bar { display: flex; gap: 10px; background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; padding: 8px 8px 8px 16px; align-items: center; }
.add-bar input { flex: 1; background: transparent; border: none; color: var(--paper);
  font-size: 0.95rem; font-family: inherit; outline: none; }
.add-bar input::placeholder { color: var(--muted); }

/* ---- Multi-link add bar ---- */
.add-bar-multi { align-items: stretch; padding: 8px; }
.add-textarea { flex: 1; min-height: 48px; max-height: 150px; resize: vertical;
  background: transparent; border: none; color: var(--paper); font-size: 0.95rem;
  font-family: inherit; outline: none; padding: 6px 8px; line-height: 1.45; }
.add-textarea::placeholder { color: var(--muted); }
.add-textarea:disabled { opacity: 0.65; }
.add-bar-multi .btn { align-self: flex-start; min-height: 44px; }
.batch-status { background: rgba(240,237,228,0.035); border: 1px solid var(--border);
  border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; }
.batch-status-title { font-size: 0.82rem; font-weight: 700; color: var(--paper); margin-bottom: 8px; }
.batch-list { display: flex; flex-direction: column; gap: 6px; }
.batch-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px;
  align-items: center; font-size: 0.78rem; color: var(--muted); }
.batch-dot { width: 7px; height: 7px; border-radius: 999px; background: var(--muted); }
.batch-row.ok .batch-dot { background: var(--sage); }
.batch-row.bad .batch-dot { background: var(--danger); }
.batch-row.bad .batch-msg { color: var(--danger); }
.batch-url { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.batch-msg { white-space: nowrap; font-family: var(--font-mono); font-size: 0.7rem; }

/* ---- Source cards (library grid) ---- */
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.src-card { background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  overflow: hidden; cursor: pointer; transition: all 0.15s; display: flex; flex-direction: column; }
.src-card:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.src-thumb { position: relative; aspect-ratio: 16/9; background: var(--surface); overflow: hidden; }
.src-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.src-thumb-placeholder { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  color: var(--muted); opacity: 0.4; }
.src-dur { position: absolute; bottom: 8px; right: 8px; font-family: var(--font-mono);
  font-size: 0.7rem; background: rgba(0,0,0,0.78); color: var(--paper); padding: 2px 6px; border-radius: 5px; }
.src-body { padding: 13px 14px 15px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.src-name { font-weight: 600; font-size: 0.95rem; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.src-channel { font-size: 0.78rem; color: var(--muted); }
.src-meta { margin-top: auto; display: flex; gap: 8px; flex-wrap: wrap; padding-top: 4px; }
.pill { font-size: 0.7rem; font-family: var(--font-mono); padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--border-strong); color: var(--muted); }
.pill.on { color: var(--ochre); border-color: rgba(217,165,116,0.35); background: rgba(217,165,116,0.08); }
.pill.kind { color: var(--sage); border-color: rgba(122,144,110,0.35); background: rgba(122,144,110,0.08);
  text-transform: capitalize; }

/* ---- Source view: readable content + responsive mini-player ---- */
.study { display: grid; grid-template-columns: minmax(0, 1fr) clamp(280px, 28vw, 380px); gap: 24px; align-items: start; max-width: 1080px; margin: 0 auto; }
.study-panel { grid-column: 1; grid-row: 1; width: 100%; max-width: none; min-width: 0; margin: 0; }
.player-col { grid-column: 2; grid-row: 1; position: sticky; top: calc(56px + env(safe-area-inset-top) + 14px); z-index: 20; width: 100%; max-width: none; margin: 0; padding: 8px; background: rgba(28, 26, 24, 0.96); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 18px 50px rgba(0,0,0,0.28); backdrop-filter: blur(12px); }
.player-frame { position: relative; aspect-ratio: 16/9; border-radius: 10px; overflow: hidden; background: #000; border: 1px solid var(--border); box-shadow: none; }
.player-frame iframe { width: 100%; height: 100%; border: 0; }
.player-meta { margin-top: 8px; }
.player-title { font-family: var(--font-sans); font-size: 0.84rem; font-weight: 700; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.player-channel { color: var(--muted); font-size: 0.72rem; margin-top: 3px; }
/* Once the layout stacks, sticky must turn off. This prevents the video from floating over summary/transcript text. */
@media (max-width: 1180px) {
  .study { grid-template-columns: 1fr; max-width: 860px; }
  .study-panel { grid-column: auto; grid-row: auto; max-width: 860px; margin: 0 auto; }
  .player-col { grid-column: auto; grid-row: auto; position: static; top: auto; z-index: auto; max-width: 520px; margin: 0 auto 18px; }
}
/* Mobile: full-width embedded player, no sticky/floating card treatment */
@media (max-width: 700px) {
  .study { gap: 16px; }
  .player-col { max-width: none; padding: 0; background: transparent; border: none; box-shadow: none; backdrop-filter: none; }
  .player-frame { border-radius: 14px; }
}

/* ---- The signature: timecode chip ---- */
.tc { display: inline-flex; align-items: center; gap: 4px; font-family: var(--font-mono);
  font-size: 0.74rem; font-weight: 600; color: var(--ochre); background: rgba(217,165,116,0.10);
  border: 1px solid rgba(217,165,116,0.22); border-radius: 6px; padding: 1px 7px 1px 5px;
  cursor: pointer; transition: all 0.12s; vertical-align: middle; white-space: nowrap; }
.tc:hover { background: var(--ochre); color: var(--ink); border-color: var(--ochre); }
.tc::before { content: ''; width: 0; height: 0; border-style: solid;
  border-width: 4px 0 4px 6px; border-color: transparent transparent transparent currentColor; }

/* ---- Tabs ---- */
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; margin-bottom: 18px; overflow-x: auto; }
.tab { flex: 1; white-space: nowrap; padding: 9px 14px; min-height: 40px; border-radius: 9px;
  font-size: 0.85rem; font-weight: 600; color: var(--muted); background: none; border: none;
  cursor: pointer; font-family: inherit; transition: all 0.12s; }
.tab:hover { color: var(--paper); }
.tab.active { background: var(--card); color: var(--ochre); border: 1px solid rgba(217,165,116,0.25); }

/* ---- Generate cards (empty-state CTAs in tabs) ---- */
.gen-card { background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 28px 22px; text-align: center; }
.gen-card .display-title { font-family: var(--font-display); font-size: 1.25rem; margin-bottom: 6px; }
.gen-card p { color: var(--muted); font-size: 0.88rem; margin: 0 0 18px; }

/* ---- Summary ---- */
.summary-overview { background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 18px 20px; margin-bottom: 18px; line-height: 1.6; }
.sum-section { margin-bottom: 22px; }
.sum-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.sum-head h3 { font-family: var(--font-display); font-size: 1.12rem; margin: 0; }
.sum-points { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.sum-point { display: flex; gap: 10px; align-items: baseline; line-height: 1.5; }
.sum-point .tc { flex-shrink: 0; }

/* ---- Flashcard / quiz lists ---- */
.card-list { display: flex; flex-direction: column; gap: 10px; }
.study-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.study-card .sc-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.type-badge { font-size: 0.64rem; font-family: var(--font-mono); text-transform: uppercase;
  letter-spacing: 0.05em; padding: 2px 7px; border-radius: 5px; background: rgba(217,165,116,0.15); color: var(--ochre); }
.sc-front { font-weight: 600; line-height: 1.45; }
.sc-back { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); color: var(--paper); line-height: 1.5; }
.sc-tags { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.sc-tag { font-size: 0.72rem; color: var(--muted); }

/* MCQ */
.mcq-opt { display: block; width: 100%; text-align: left; padding: 12px 14px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; margin-bottom: 7px; cursor: pointer;
  transition: all 0.12s; color: var(--paper); font-size: 0.92rem; font-family: inherit; }
.mcq-opt:hover:not(:disabled) { border-color: rgba(217,165,116,0.4); background: var(--card-hover); }
.mcq-opt.correct { border-color: var(--sage); background: rgba(123,179,160,0.12); }
.mcq-opt.incorrect { border-color: var(--danger); background: rgba(220,80,80,0.12); }
.mcq-opt.reveal-correct { border-color: var(--sage); opacity: 0.75; }
.mcq-exp { margin-top: 10px; font-size: 0.86rem; color: var(--muted); line-height: 1.5; }

/* ---- Review session ---- */
.review-progress { max-width: 720px; margin: 0 auto 14px; height: 4px; border-radius: 999px;
  background: rgba(240,237,228,0.08); overflow: hidden; }
.review-progress-bar { height: 100%; width: 0%; background: var(--sage); transition: width 0.25s; }
.review-card { max-width: 680px; margin: 0 auto; padding: 30px; background: var(--card);
  border: 1px solid var(--border); border-radius: 16px; min-height: 280px;
  display: flex; flex-direction: column; }
.review-card .front { font-size: 1.25rem; line-height: 1.5; }
.review-card .back { font-size: 1.08rem; line-height: 1.55; }
.review-card hr { width: 100%; margin: 22px 0; border: none; border-top: 1px solid var(--border); }
.review-src { display: flex; align-items: center; gap: 8px; justify-content: center;
  margin-top: auto; padding-top: 18px; font-size: 0.78rem; color: var(--muted); }
.grade-buttons { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; max-width: 680px; margin: 16px auto 0; }
.grade-btn { padding: 13px 8px; border-radius: 10px; font-weight: 700; cursor: pointer; border: 1px solid;
  background: none; font-family: inherit; display: flex; flex-direction: column; gap: 2px; align-items: center; transition: all 0.12s; }
.grade-btn .ivl { font-size: 0.68rem; opacity: 0.7; font-family: var(--font-mono); font-weight: 500; }
.grade-btn.again { color: var(--danger); border-color: rgba(220,80,80,0.4); }
.grade-btn.hard { color: var(--ochre); border-color: rgba(217,165,116,0.4); }
.grade-btn.good { color: var(--sage); border-color: rgba(123,179,160,0.4); }
.grade-btn.easy { color: var(--paper); border-color: var(--border-strong); }
.grade-btn:hover { background: rgba(240,237,228,0.04); }
@media (max-width: 640px) {
  .grade-buttons { position: sticky; bottom: calc(64px + env(safe-area-inset-bottom)); gap: 6px;
    padding: 8px; background: rgba(15,17,21,0.92); backdrop-filter: blur(12px);
    border: 1px solid var(--border); border-radius: 14px; }
  .grade-btn { min-height: 58px; }
  .review-card { padding: 20px 16px; }
}

/* ---- Cloze ---- */
.cloze-blank { display: inline-block; min-width: 54px; padding: 0 8px; background: var(--ochre);
  color: var(--ink); border-radius: 4px; font-weight: 700; }
.cloze-revealed { color: var(--ochre); font-weight: 700; }

/* ---- Transcript ---- */
.transcript { background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 8px; max-height: 540px; overflow-y: auto; }
.tr-line { display: flex; gap: 12px; padding: 7px 10px; border-radius: 8px; cursor: pointer;
  align-items: baseline; transition: background 0.1s; }
.tr-line:hover { background: rgba(240,237,228,0.04); }
.tr-line.active { background: rgba(217,165,116,0.08); }
.tr-time { font-family: var(--font-mono); font-size: 0.74rem; color: var(--ochre); flex-shrink: 0; min-width: 48px; }
.tr-text { font-size: 0.9rem; line-height: 1.5; color: var(--paper); }

/* ---- Empty / misc ---- */
.empty { text-align: center; padding: 56px 16px; }
.empty .display-title { font-family: var(--font-display); font-size: 1.4rem; margin-bottom: 4px; }
.empty p { color: var(--muted); font-size: 0.9rem; margin: 0 0 18px; }
.spinner { width: 24px; height: 24px; border: 2px solid var(--border-strong);
  border-top-color: var(--ochre); border-radius: 50%; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.center-pad { display: flex; justify-content: center; padding: 40px 0; }

/* progress line for generation */
.genline { display: flex; align-items: center; gap: 10px; background: var(--card);
  border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; font-size: 0.88rem; }

/* ---- Toast ---- */
#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200;
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
@media (max-width: 900px) { #toasts { bottom: calc(76px + env(safe-area-inset-bottom)); } }
.toast { background: #211F1C; color: var(--paper); padding: 10px 18px; border-radius: 9px;
  border: 1px solid var(--border-strong); font-size: 0.88rem; opacity: 0; transform: translateY(12px);
  transition: all 0.2s; pointer-events: auto; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { border-color: var(--sage); }
.toast.error { border-color: var(--danger); }
.toast.warning { border-color: var(--ochre); }

/* ---- Modal ---- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 16px; opacity: 0; transition: opacity 0.2s; }
.modal-overlay.show { opacity: 1; }
.modal { background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  max-width: 460px; width: 100%; padding: 24px; }
.modal h2 { font-family: var(--font-display); font-size: 1.2rem; margin: 0 0 6px; }

/* rich content inside cards */
.rich code { background: rgba(240,237,228,0.06); padding: 1px 5px; border-radius: 4px; font-family: var(--font-mono); font-size: 0.88em; }
.rich pre { background: var(--ink); border: 1px solid var(--border); border-radius: 8px; padding: 12px; overflow-x: auto; }
.rich pre code { background: none; padding: 0; }
.rich strong { font-weight: 700; }

/* ---- Library card quick actions ---- */
.src-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.quick-chip { border: 1px solid var(--border); background: rgba(240,237,228,0.03);
  color: var(--muted); border-radius: 999px; padding: 5px 9px; font-family: var(--font-mono);
  font-size: 0.68rem; cursor: pointer; transition: all 0.12s; }
.quick-chip:hover:not(:disabled) { color: var(--paper); border-color: rgba(217,165,116,0.4);
  background: rgba(217,165,116,0.08); }
.quick-chip.done { color: var(--ochre); background: rgba(217,165,116,0.10); }
.quick-chip:disabled { opacity: 0.65; cursor: wait; }

/* ---- Insights ---- */
.insight-list { display: flex; flex-direction: column; gap: 10px; }
.insight-card { background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px 16px; }
.insight-heading { margin: 0 0 8px; font-size: 1rem; }
.insight-takeaway { margin: 0 0 10px; line-height: 1.5; }
.insight-muted { margin: 8px 0 0; color: var(--muted); font-size: 0.88rem; line-height: 1.5; }
.insight-evidence { margin: 10px 0 0; padding-left: 10px;
  border-left: 2px solid var(--border-strong); color: var(--muted);
  font-size: 0.84rem; line-height: 1.5; }

/* ---- Playlist picker ---- */
.playlist-toolbar { display: flex; align-items: center; gap: 8px; margin: 12px 0;
  color: var(--muted); font-size: 0.85rem; }
.playlist-picker { max-height: 420px; overflow: auto; display: flex; flex-direction: column;
  gap: 8px; padding-right: 4px; }
.playlist-item { display: grid; grid-template-columns: auto 72px 1fr; gap: 10px;
  align-items: center; padding: 8px; border: 1px solid var(--border);
  border-radius: 10px; background: rgba(240,237,228,0.03); cursor: pointer; }
.playlist-thumb { width: 72px; aspect-ratio: 16 / 9; object-fit: cover;
  border-radius: 6px; background: var(--surface); }
.playlist-title { font-size: 0.86rem; line-height: 1.35; color: var(--paper); }

/* ---- Collections ---- */
.collection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}
.collection-card {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  color: var(--paper);
  cursor: pointer;
}
.collection-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}
.collection-thumb {
  width: 72px;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--surface);
  flex: 0 0 auto;
  color: var(--muted);
}
.collection-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.collection-info { min-width: 0; }
.collection-title {
  font-weight: 700;
  font-size: 0.92rem;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.collection-meta {
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--muted);
}
.collection-hero { margin-bottom: 22px; }

/* ---- Library card artifact menu ---- */
.src-card {
  position: relative;
}

.artifact-menu {
  position: relative;
  display: inline-flex;
}

.artifact-trigger {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.artifact-caret {
  font-size: 0.72rem;
  opacity: 0.75;
  transform: translateY(-1px);
}

.artifact-menu-pop {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  z-index: 40;
  min-width: 240px;
  padding: 6px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: rgba(28, 26, 24, 0.98);
  box-shadow: 0 18px 48px rgba(0,0,0,0.42);
  backdrop-filter: blur(14px);
  display: none;
}

.artifact-menu.open .artifact-menu-pop {
  display: block;
}

.artifact-menu-item {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  text-align: left;
  padding: 9px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--paper);
  cursor: pointer;
  font-family: inherit;
}

.artifact-menu-item:hover:not(:disabled) {
  background: rgba(240,237,228,0.06);
}

.artifact-menu-item.done .artifact-menu-main {
  color: var(--ochre);
}

.artifact-menu-item:disabled {
  opacity: 0.7;
  cursor: wait;
}

.artifact-menu-item.working {
  cursor: wait;
}

.artifact-menu-main {
  min-width: 0;
  font-size: 0.82rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.artifact-menu-sub {
  color: var(--muted);
  font-size: 0.68rem;
  font-family: var(--font-mono);
}

.artifact-menu-sep {
  height: 1px;
  margin: 5px 4px;
  background: var(--border);
}

.open-source-item .artifact-menu-main {
  color: var(--paper);
}

@media (max-width: 640px) {
  .artifact-menu-pop {
    left: auto;
    right: 0;
    min-width: min(280px, calc(100vw - 36px));
  }
}
