:root {
  --background: #f5f5f2;
  --surface: #ffffff;
  --text: #171717;
  --secondary: #5f5f5a;
  --quiet: #777772;
  --border: #d9d9d4;
  --border-dark: #b8b8b1;
  --accent: #315c42;
  --accent-dark: #284d36;
  --surface-muted: #efefe9;
  --shadow-sm: 0 1px 2px rgba(24, 31, 26, .05), 0 5px 18px rgba(24, 31, 26, .04);
  --sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--background);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
}

a { color: inherit; }
button, input, select { font: inherit; }
button { color: inherit; }

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

.site-header,
main,
footer {
  width: min(1240px, calc(100% - 48px));
  margin-inline: auto;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 78px;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: baseline;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -.01em;
  text-decoration: none;
}

.brand-secondary {
  padding-left: 12px;
  border-left: 1px solid var(--border);
  color: var(--secondary);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0;
}

.snapshot-label,
.eyebrow {
  margin: 0;
  color: var(--secondary);
  font-family: var(--mono);
  font-size: 12px;
}

.snapshot-label {
  display: flex;
  gap: 8px;
  align-items: center;
}

.snapshot-label::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  content: "";
}

main { min-height: 72vh; }
h1, h2, h3, p { overflow-wrap: anywhere; }

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(340px, .8fr);
  gap: clamp(56px, 7vw, 104px);
  align-items: end;
  padding: 96px 0 84px;
}

.hero-copy { min-width: 0; }

.hero h1 {
  max-width: 760px;
  margin: 0 0 24px;
  font-size: clamp(40px, 5vw, 64px);
  font-weight: 570;
  letter-spacing: -.045em;
  line-height: 1.02;
}

.hero-note {
  max-width: 720px;
  margin: 0;
  color: #454541;
  font-size: clamp(18px, 2vw, 22px);
  letter-spacing: -.015em;
  line-height: 1.52;
}

.hero-note em { font-style: italic; }

.archive-downloads {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  min-width: 0;
}

.download-option {
  display: inline-flex;
  gap: 13px;
  align-items: center;
  min-width: 0;
  min-height: 78px;
  padding: 15px 46px 15px 17px;
  border: 1px solid var(--border-dark);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  position: relative;
  text-decoration: none;
  transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}

.download-option::after {
  position: absolute;
  right: 17px;
  color: var(--quiet);
  content: "↓";
  font-size: 18px;
}

.download-option:hover {
  border-color: var(--text);
  box-shadow: 0 2px 4px rgba(24, 31, 26, .07), 0 9px 24px rgba(24, 31, 26, .06);
  transform: translateY(-1px);
}

.download-option-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.download-option-primary:hover {
  border-color: var(--accent-dark);
  background: var(--accent-dark);
}

.download-option-primary::after { color: rgba(255, 255, 255, .82); }

.download-option svg {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.download-option span,
.download-option strong,
.download-option small { display: block; }

.download-option span { min-width: 0; }

.download-option strong {
  font-size: 14px;
  font-weight: 620;
  letter-spacing: -.005em;
}

.download-option small {
  margin-top: 3px;
  color: var(--secondary);
  font-size: 11px;
  line-height: 1.35;
}

.download-option-primary small { color: rgba(255, 255, 255, .78); }

.archive-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  overflow: hidden;
  border: 1px solid rgba(49, 92, 66, .18);
  border-radius: 8px;
  background: rgba(49, 92, 66, .055);
}

.stat + .stat {
  border-left: 1px solid rgba(49, 92, 66, .16);
}

.stat {
  display: flex;
  gap: 15px;
  align-items: baseline;
  padding: 29px 32px 28px;
}

.stat strong {
  display: block;
  color: var(--accent);
  font-size: 38px;
  font-variant-numeric: tabular-nums;
  font-weight: 590;
  letter-spacing: -.045em;
  line-height: 1;
}

.stat span {
  color: #4f5c53;
  font-size: 13px;
}

.catalogue { padding: 64px 0 116px; }

.comments-heading h2 {
  margin: 0;
  font-size: 30px;
  font-weight: 560;
  letter-spacing: -.03em;
}

.result-count {
  align-self: center;
  justify-self: end;
  color: var(--secondary);
  font-size: 12px;
  white-space: nowrap;
}

.controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 190px auto;
  gap: 12px;
  margin-bottom: 26px;
}

.search-wrap { position: relative; }

.search-wrap::before {
  position: absolute;
  top: 50%;
  left: 15px;
  color: var(--quiet);
  content: "⌕";
  transform: translateY(-54%);
}

input,
select {
  width: 100%;
  height: 48px;
  border: 1px solid var(--border);
  border-radius: 6px;
  outline: 0;
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  transition: border-color .15s ease, box-shadow .15s ease;
}

input { padding: 0 14px 0 40px; }
select { padding: 0 12px; }

input:focus,
select:focus,
button:focus-visible,
a:focus-visible {
  border-color: var(--border-dark);
  outline: 2px solid rgba(49, 92, 66, .22);
  outline-offset: 1px;
  box-shadow: 0 0 0 3px rgba(49, 92, 66, .07);
}

.video-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px 20px;
}

.video-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(24, 31, 26, .03);
  transition: border-color .17s ease, box-shadow .17s ease, transform .17s ease;
}

.video-card:hover {
  border-color: var(--border-dark);
  box-shadow: var(--shadow-sm);
  transform: translateY(-2px);
}

.card-link { display: block; height: 100%; text-decoration: none; }

.thumbnail-wrap {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  border-radius: 6px;
  background: #e7e7e2;
}

.thumbnail {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity .18s ease;
}

.video-card .thumbnail-wrap { border-radius: 6px 6px 0 0; }

.card-link:hover .thumbnail { opacity: .9; }

.duration,
.status-pill {
  position: absolute;
  padding: 4px 7px;
  border-radius: 3px;
  background: rgba(20, 20, 19, .84);
  color: white;
  font-family: var(--mono);
  font-size: 11px;
}

.duration { right: 8px; bottom: 8px; }
.status-pill { top: 8px; left: 8px; text-transform: capitalize; }
.status-pill.complete { background: var(--accent); }

.card-copy { padding: 15px 16px 17px; }

.card-copy h3 {
  margin: 0 0 9px;
  font-size: 16px;
  font-weight: 590;
  line-height: 1.38;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 14px;
  color: var(--secondary);
  font-size: 12px;
}

.card-meta span + span::before {
  margin-right: 14px;
  color: var(--quiet);
  content: "·";
}

.empty-state,
.error-state,
.loading-state {
  display: grid;
  place-items: center;
  min-height: 50vh;
  color: var(--secondary);
  text-align: center;
}

.loader {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.detail { padding: 48px 0 110px; }

.back-link {
  display: inline-block;
  margin-bottom: 30px;
  color: var(--secondary);
  font-size: 13px;
  text-decoration: none;
}

.back-link:hover { color: var(--text); }

.video-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, .85fr);
  gap: clamp(34px, 5vw, 72px);
  align-items: start;
}

.video-hero .thumbnail-wrap {
  position: sticky;
  top: 20px;
}

.detail-copy { padding-top: 2px; }

.detail-copy h1 {
  margin: 12px 0 12px;
  font-size: clamp(34px, 4vw, 52px);
  font-weight: 570;
  letter-spacing: -.045em;
  line-height: 1.08;
}

.channel { margin: 0 0 26px; color: var(--secondary); font-size: 15px; }

.video-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 28px;
  padding: 18px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.video-metrics strong,
.video-metrics span {
  display: block;
}

.video-metrics strong {
  font-size: 17px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  letter-spacing: -.015em;
  line-height: 1.35;
}

.video-metrics span {
  margin-top: 2px;
  color: var(--secondary);
  font-size: 12px;
}

.description {
  display: -webkit-box;
  overflow: hidden;
  margin: 22px 0 8px;
  color: var(--secondary);
  font-size: 15px;
  line-height: 1.6;
  white-space: pre-wrap;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 6;
}

.description.expanded { display: block; }

.text-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font-size: 13px;
}

.original-link {
  display: inline-block;
  margin-top: 24px;
  padding-bottom: 2px;
  border-bottom: 1px solid var(--border-dark);
  font-size: 13px;
  text-decoration: none;
}

.original-link:hover { border-color: var(--text); }

.comments-section { max-width: 860px; margin: 96px auto 0; }

.comments-heading {
  display: flex;
  gap: 20px;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 22px;
}

.comments-heading span { color: var(--secondary); font-size: 13px; }
.comment-list { border-top: 1px solid var(--border); }

.comment {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 14px;
  padding: 25px 0;
  border-bottom: 1px solid var(--border);
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #e4e4df;
  object-fit: cover;
}

.avatar-fallback {
  display: grid;
  place-items: center;
  color: var(--secondary);
  font-size: 13px;
}

.comment-head {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 10px;
  align-items: baseline;
  margin-bottom: 7px;
}

.author { font-size: 14px; font-weight: 620; text-decoration: none; }
a.author:hover { text-decoration: underline; }

.comment-badge {
  padding: 1px 5px;
  border: 1px solid var(--border-dark);
  border-radius: 3px;
  color: var(--secondary);
  font-size: 11px;
}

.comment-date,
.edited {
  color: var(--quiet);
  font-family: var(--mono);
  font-size: 11px;
}

.comment-text {
  margin: 0;
  color: #30302d;
  font-size: 15px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.comment-likes {
  display: inline-block;
  margin-top: 9px;
  color: var(--secondary);
  font-size: 12px;
}

.replies {
  margin-top: 18px;
  padding-left: 16px;
  border-left: 1px solid var(--border);
}

.replies[hidden] { display: none; }

.reply-toggle {
  display: block;
  margin-top: 13px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font-size: 13px;
  font-weight: 560;
}

.reply-toggle:hover { text-decoration: underline; }

.more-replies {
  margin: 8px 0 4px 44px;
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--secondary);
  cursor: pointer;
  font-size: 12px;
}

.more-replies:hover {
  border-color: var(--border-dark);
  color: var(--text);
}

.reply {
  grid-template-columns: 30px minmax(0, 1fr);
  padding: 14px 0;
  border: 0;
}

.reply .avatar { width: 30px; height: 30px; }

.load-more {
  display: block;
  width: 100%;
  margin-top: 20px;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  cursor: pointer;
  font-size: 13px;
}

.load-more:hover { border-color: var(--border-dark); }

.notice {
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--secondary);
}

.comments-section > .notice { margin: 0 0 20px; }

footer {
  display: flex;
  justify-content: space-between;
  padding: 30px 0 44px;
  border-top: 1px solid var(--border);
  color: var(--quiet);
  font-size: 12px;
}

@media (max-width: 900px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 36px;
    align-items: start;
  }
  .archive-downloads { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .video-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .video-hero { grid-template-columns: 1fr; }
  .video-hero .thumbnail-wrap { position: relative; top: auto; }
}

@media (max-width: 620px) {
  .site-header, main, footer { width: calc(100% - 28px); }
  .snapshot-label { display: none; }
  .brand { display: block; }
  .brand-secondary { display: block; margin-top: 1px; padding-left: 0; border-left: 0; }
  .hero { gap: 30px; padding: 62px 0 56px; }
  .hero h1 { font-size: 38px; line-height: 1.04; }
  .archive-downloads { grid-template-columns: 1fr; }
  .archive-stats { grid-template-columns: 1fr; }
  .stat { padding: 23px 20px; }
  .stat + .stat { border-top: 1px solid rgba(49, 92, 66, .16); border-left: 0; }
  .controls { grid-template-columns: 1fr; }
  .result-count { justify-self: start; }
  .video-grid { grid-template-columns: 1fr; }
  .comments-section { margin-top: 68px; }
  footer { display: block; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
  .download-option:hover,
  .video-card:hover { transform: none; }
}
