:root {
  --bg: #f3efe5;
  --panel: rgba(255, 250, 242, 0.8);
  --panel-strong: #fffaf2;
  --line: rgba(56, 44, 31, 0.12);
  --text: #23190f;
  --muted: #6f6358;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --warning: #c2410c;
  --danger: #9f1239;
  --shadow: 0 24px 60px rgba(38, 25, 16, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(15, 118, 110, 0.16), transparent 28%),
    radial-gradient(circle at top right, rgba(194, 65, 12, 0.16), transparent 24%),
    linear-gradient(180deg, #f8f4ea 0%, #ede5d7 100%);
  color: var(--text);
  font-family: "Space Grotesk", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.page-shell {
  width: min(1380px, calc(100vw - 2rem));
  margin: 0 auto;
  padding: 1rem 0 2rem;
}

.top-nav {
  display: flex;
  gap: 0.7rem;
  margin-bottom: 1rem;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.62rem 0.95rem;
  background: rgba(255, 252, 246, 0.72);
  color: var(--text);
  text-decoration: none;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.nav-link.active {
  background: var(--text);
  color: white;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(18rem, 0.9fr);
  gap: 1rem;
  padding: 1.4rem;
  background: rgba(255, 252, 246, 0.82);
  border: 1px solid rgba(76, 55, 30, 0.12);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.eyebrow,
.source-label,
.stat-label {
  margin: 0;
  font-family: "IBM Plex Mono", monospace;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-size: 0.76rem;
  color: var(--muted);
}

.hero h1 {
  margin: 0.4rem 0 0.6rem;
  font-size: clamp(2.2rem, 4vw, 4.1rem);
  line-height: 0.95;
  max-width: 14ch;
}

.subtitle {
  margin: 0;
  max-width: 56ch;
  color: var(--muted);
  line-height: 1.6;
}

.hero-actions {
  display: grid;
  gap: 0.75rem;
  align-content: start;
}

.action-btn {
  border: none;
  border-radius: 16px;
  padding: 0.95rem 1.15rem;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, opacity 140ms ease;
  text-decoration: none;
  text-align: center;
}

.action-btn:hover {
  transform: translateY(-1px);
}

.action-btn.primary {
  background: linear-gradient(135deg, var(--accent), #14b8a6);
  color: white;
  box-shadow: 0 12px 24px rgba(15, 118, 110, 0.22);
}

.action-btn.secondary {
  background: linear-gradient(135deg, #ea580c, #fb923c);
  color: white;
  box-shadow: 0 12px 24px rgba(194, 65, 12, 0.2);
}

.action-btn.ghost {
  background: rgba(255, 255, 255, 0.65);
  color: var(--text);
  border: 1px solid var(--line);
}

.action-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.9rem;
  margin-top: 1rem;
}

.stat-card,
.notes-panel,
.control-bar,
.clip-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.stat-card {
  padding: 1rem 1.1rem;
}

.stat-card strong {
  display: block;
  margin-top: 0.35rem;
  font-size: 2rem;
}

.control-bar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  margin-top: 1rem;
  padding: 1rem 1.1rem;
}

.filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.filter-pill {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
  color: var(--text);
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  cursor: pointer;
}

.filter-pill.active {
  background: var(--text);
  color: white;
}

.source-block {
  text-align: right;
}

.source-block code,
.default-context {
  display: block;
  margin-top: 0.25rem;
  font-family: "IBM Plex Mono", monospace;
  color: var(--muted);
  word-break: break-word;
}

.results-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(18rem, 0.7fr);
  gap: 1rem;
  margin-top: 1rem;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 0.9rem;
}

.section-header h2,
.notes-panel h3 {
  margin: 0;
}

.section-header p,
.notes-panel ol,
.clip-thread,
.clip-excerpt,
.clip-reason,
.modal-meta,
.modal-match {
  color: var(--muted);
}

.clip-list {
  display: grid;
  gap: 0.9rem;
}

.clip-card {
  padding: 1rem 1.1rem;
}

.clip-card-top {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.badges {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.status-badge,
.subreddit-badge,
.rank-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.28rem 0.62rem;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.status-requested {
  background: rgba(15, 118, 110, 0.12);
  color: var(--accent-strong);
}

.status-clipped {
  background: rgba(14, 116, 144, 0.14);
  color: #0f4c81;
}

.status-not-found {
  background: rgba(159, 18, 57, 0.12);
  color: var(--danger);
}

.subreddit-badge {
  background: rgba(255, 255, 255, 0.85);
  color: var(--muted);
}

.rank-pill {
  background: rgba(35, 25, 15, 0.08);
  color: var(--text);
}

.clip-title {
  margin: 0.45rem 0 0;
  font-size: 1.3rem;
}

.clip-thread {
  margin: 0.35rem 0 0;
  font-size: 0.92rem;
}

.clip-excerpt,
.clip-reason {
  margin: 0.7rem 0 0;
  line-height: 1.55;
}

.clip-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.9rem;
}

.metric-chip {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.32rem 0.6rem;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.72rem;
}

.clip-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1rem;
}

.mini-btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
  border-radius: 12px;
  padding: 0.65rem 0.8rem;
  cursor: pointer;
}

.mini-btn.primary {
  background: var(--accent);
  color: white;
  border-color: transparent;
}

.mini-btn.warn {
  background: rgba(194, 65, 12, 0.1);
  color: var(--warning);
}

.mini-btn.danger {
  background: rgba(159, 18, 57, 0.1);
  color: var(--danger);
}

.notes-panel {
  padding: 1rem 1.1rem;
  align-self: start;
  position: sticky;
  top: 1rem;
}

.notes-panel ol {
  padding-left: 1.2rem;
  line-height: 1.7;
}

.panel-section {
  margin-top: 1.2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.clip-modal {
  border: none;
  padding: 0;
  width: min(960px, calc(100vw - 1rem));
  border-radius: 26px;
  background: transparent;
}

.clip-modal::backdrop {
  background: rgba(24, 17, 10, 0.55);
  backdrop-filter: blur(8px);
}

.clip-modal-card {
  position: relative;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 26px;
  box-shadow: var(--shadow);
}

.close-btn {
  position: absolute;
  right: 1rem;
  top: 1rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  border-radius: 999px;
  padding: 0.45rem 0.8rem;
  cursor: pointer;
}

.clip-modal-body {
  padding: 1.5rem;
}

#modal-video {
  width: 100%;
  margin-top: 1rem;
  border-radius: 20px;
  background: #000;
}

.transcript-hero {
  grid-template-columns: minmax(0, 1.3fr) minmax(20rem, 0.8fr);
}

.transcript-meta-panel,
.transcript-controls,
.transcript-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.transcript-meta-panel {
  padding: 1rem 1.1rem;
  display: grid;
  gap: 0.9rem;
}

.transcript-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}

.transcript-meta-row strong {
  text-align: right;
}

.transcript-controls {
  margin-top: 1rem;
  padding: 1rem 1.1rem;
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(18rem, 0.7fr);
  gap: 1rem;
}

.transcript-search {
  display: grid;
  gap: 0.55rem;
}

.transcript-search-row {
  display: flex;
  gap: 0.7rem;
  align-items: stretch;
}

.transcript-search-row input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.95rem 1rem;
  background: rgba(255, 255, 255, 0.86);
  color: var(--text);
}

.transcript-summary-card {
  padding: 0.2rem 0;
}

.transcript-summary-card code {
  display: block;
  margin-top: 0.3rem;
  font-family: "IBM Plex Mono", monospace;
  color: var(--muted);
  word-break: break-word;
}

.transcript-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(18rem, 0.7fr);
  gap: 1rem;
  margin-top: 1rem;
}

.transcript-main {
  min-width: 0;
}

.transcript-pager {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.transcript-list {
  display: grid;
  gap: 0.85rem;
}

.transcript-card {
  padding: 1rem 1.1rem;
}

.transcript-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.8rem;
}

.timestamp-pill {
  border: 1px solid rgba(15, 118, 110, 0.18);
  background: rgba(15, 118, 110, 0.1);
  color: var(--accent-strong);
  border-radius: 999px;
  padding: 0.38rem 0.7rem;
  font-family: "IBM Plex Mono", monospace;
  cursor: pointer;
}

.transcript-end {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.82rem;
  color: var(--muted);
}

.transcript-text {
  margin: 0;
  line-height: 1.7;
  font-size: 1rem;
  color: var(--text);
}

.transcript-text mark {
  background: rgba(251, 146, 60, 0.28);
  color: inherit;
  padding: 0 0.1rem;
  border-radius: 0.2rem;
}

.transcript-empty {
  text-align: left;
}

.transcript-empty h3 {
  margin: 0 0 0.45rem;
}

.transcript-notes {
  top: 1rem;
}

@media (max-width: 980px) {
  .hero,
  .results-layout,
  .transcript-hero,
  .transcript-controls,
  .transcript-layout {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .notes-panel {
    position: static;
  }

  .control-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .transcript-search-row {
    flex-direction: column;
  }

  .source-block {
    text-align: left;
  }
}

@media (max-width: 640px) {
  .page-shell {
    width: min(100vw - 1rem, 100%);
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .hero h1 {
    max-width: none;
  }

  .top-nav,
  .transcript-pager {
    flex-wrap: wrap;
  }

  .transcript-card-top {
    align-items: flex-start;
    flex-direction: column;
  }
}
