:root {
  --bg: #161826;
  --panel: #232532;
  --border: #3f424d;
  --border-soft: rgba(233, 233, 237, 0.16);
  --text: #e9e9ed;
  --accent: #9184d9;
  --accent-hover: #b5abfc;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

a { color: var(--accent); text-decoration: none; text-underline-offset: 3px; }
a:hover { color: var(--accent-hover); }
::selection { background: rgba(145, 132, 217, 0.3); }
input::placeholder { color: rgba(233, 233, 237, 0.45); }
input { caret-color: var(--accent); }

#progress-bar {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  width: 0%;
  background: var(--accent);
  transition: width 0.15s ease;
  z-index: 1000;
}
#progress-bar.hidden { display: none; }

.file-warning {
  background: #3a2a1e;
  color: #f2c98a;
  font-size: 13px;
  line-height: 1.6;
  padding: 12px 40px;
  border-bottom: 1px solid rgba(242, 201, 138, 0.3);
}
.file-warning code {
  background: rgba(0, 0, 0, 0.25);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: ui-monospace, monospace;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 22px 40px;
}
.brand {
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.03em;
}
.yt-link {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text);
  opacity: 0.6;
}
.yt-link:hover { opacity: 0.9; color: var(--text); }

.page { max-width: 740px; margin: 0 auto; padding: 32px 40px 80px; }
.page-home { max-width: 720px; margin: 64px auto 0; padding: 0 40px 80px; }
.page-search, .page-lore, .page-who { max-width: 860px; }

.eyebrow {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 16px;
}
h1 { font-size: 52px; margin: 0 0 16px; }
.page-lore h1 { font-size: 34px; margin: 0 0 14px; }
h2 { font-size: 25px; margin: 0 0 4px; }
.subtitle { font-size: 16px; line-height: 1.6; opacity: 0.75; max-width: 540px; margin: 0 0 40px; }

.searchbox {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 4px 4px 4px 16px;
}
.searchbox svg { opacity: 0.5; flex: none; }
.searchbox input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  padding: 12px 0;
}
.searchbox.small input { font-size: 14px; padding: 10px 0; }
.home .searchbox { margin-bottom: 22px; }
.search .searchbox, .who .searchbox, .lore .searchbox { max-width: 520px; margin: 22px 0 30px; }

.buttons { display: flex; gap: 12px; flex-wrap: wrap; }
.btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 1px solid rgba(233, 233, 237, 0.24);
  color: var(--text);
  border-radius: 8px;
  padding: 12px 20px;
  font-size: 14px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
}
.btn:hover { background: rgba(233, 233, 237, 0.07); }
.btn.primary { border-color: var(--accent); color: var(--accent); }
.btn.primary:hover { background: rgba(145, 132, 217, 0.12); }

.hr {
  height: 1px;
  margin: 60px 0 22px;
  background: linear-gradient(to right, transparent, var(--border-soft) 48px, var(--border-soft) calc(100% - 48px), transparent);
}
.hr-tight { margin: 0 0 4px; }
.footer-note { font-size: 12px; opacity: 0.45; line-height: 1.6; }

.back-link { cursor: pointer; font-size: 13px; opacity: 0.6; background: none; border: none; color: var(--text); font-family: inherit; padding: 0; display: inline-flex; align-items: center; gap: 6px; }
.back-link:hover { opacity: 1; color: var(--text); }

.result-count { font-size: 13px; opacity: 0.5; margin: 0 0 28px; }

.card {
  cursor: pointer;
  background: var(--panel);
  border-radius: 8px;
  box-shadow: 0 0 0 1px var(--border);
  padding: 20px 22px;
  margin-bottom: 14px;
}
.card:hover { box-shadow: 0 0 0 1px var(--accent); }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.card-title { font-size: 17px; font-weight: 500; }
.card-meta { font-size: 11px; opacity: 0.5; white-space: nowrap; }
.card-meta.badge-new { color: var(--accent); opacity: 1; font-weight: 600; letter-spacing: 0.04em; }
.card-summary { font-size: 13px; opacity: 0.75; margin: 8px 0 10px; line-height: 1.55; }
.card-sub { font-size: 11px; opacity: 0.45; }

.empty { opacity: 0.5; font-size: 14px; }

.lore-summary { font-size: 15px; line-height: 1.65; opacity: 0.82; margin: 0 0 28px; }
.first-box {
  background: var(--panel);
  border-radius: 8px;
  box-shadow: 0 0 0 1px var(--border);
  padding: 18px 20px;
  margin-bottom: 38px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}
.first-label { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); margin-bottom: 8px; }
.first-title { font-size: 15px; font-weight: 500; margin-bottom: 4px; }
.first-meta { font-size: 12px; opacity: 0.55; }

.section-label { font-size: 13px; letter-spacing: 0.05em; text-transform: uppercase; opacity: 0.55; margin: 0 0 14px; }

.yt-btn {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: var(--accent);
}
.yt-btn:hover { background: rgba(145, 132, 217, 0.12); }
.yt-btn.small { width: 26px; height: 26px; border-radius: 7px; }

.ref-row {
  padding: 20px 0;
  background: linear-gradient(to right, transparent, var(--border-soft) 48px, var(--border-soft) calc(100% - 48px), transparent) no-repeat bottom / 100% 1px;
}
.ref-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.ref-title { font-size: 14px; font-weight: 500; }
.ref-meta { display: flex; align-items: center; gap: 10px; font-size: 11px; opacity: 0.5; white-space: nowrap; }
.ref-note { font-size: 13px; opacity: 0.75; line-height: 1.55; margin: 8px 0; }

.transcript-toggle {
  background: none;
  border: none;
  color: var(--accent);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
  margin-top: 2px;
}
.transcript-toggle:hover { color: var(--accent-hover); }

.transcript-box {
  margin-top: 12px;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 4px 14px;
}
.transcript-line {
  padding: 10px 0;
  border-bottom: 1px solid var(--border-soft);
}
.transcript-line:last-child { border-bottom: none; }
.transcript-line-match {
  margin: 0 -14px;
  padding: 10px 14px;
  background: rgba(145, 132, 217, 0.1);
  border-left: 2px solid var(--accent);
  border-bottom: 1px solid var(--border-soft);
}

.who-line {
  padding: 14px 0;
  background: linear-gradient(to right, transparent, var(--border-soft) 48px, var(--border-soft) calc(100% - 48px), transparent) no-repeat bottom / 100% 1px;
}
.who-ep-group { margin-bottom: 30px; }
.who-ep-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 6px; }
.who-ep-title { font-size: 15px; font-weight: 500; }
.who-ep-meta { font-size: 11px; opacity: 0.5; }
.who-line-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.who-speaker { font-size: 11px; font-weight: 600; color: var(--accent); }
.who-ts { font-size: 11px; opacity: 0.45; margin-left: 10px; }
.who-text { font-size: 14px; line-height: 1.55; margin: 4px 0 0; }
mark { background: rgba(145, 132, 217, 0.35); color: inherit; border-radius: 2px; padding: 0 1px; }

.hint { font-size: 11px; opacity: 0.4; margin: 0 0 26px; }
.loading { font-size: 13px; opacity: 0.5; padding: 20px 0; }
