:root {
  --bg: #fafaf7;
  --ink: #1a1a1a;
  --ink-muted: #6b6b66;
  --ink-faint: #b8b6ad;
  --accent: #a13d2d;
  --accent-hover: #862e21;
  --divider: #e8e6df;
  --serif: 'Newsreader', Georgia, serif;
  --sans: 'General Sans', -apple-system, system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body { padding: 5rem 1.5rem 8rem; }

.container { max-width: 680px; margin: 0 auto; }

/* Brand */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--sans);
  font-weight: 500;
  font-size: 18px;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
  margin: 0 0 3rem;
}
.brand-dot { color: var(--accent); }
.brand:hover { opacity: 0.8; }

.brand-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 16px;
  line-height: 1;
  color: var(--accent);
  background: transparent;
  border: 1.5px solid var(--ink);
  border-radius: 3px;
  padding-top: 2px;
}
.brand-icon-dot {
  color: var(--accent);
  margin-left: 1px;
}
.brand-text { display: inline-flex; align-items: baseline; }

/* Scene visibility driven by body state classes */
.scene { display: none; }
body.state-form .scene-form,
body.state-progress .scene-progress,
body.state-result .scene-result {
  display: block;
}

/* ============ Scene 1: form ============ */
.lede {
  font-family: var(--serif);
  font-size: 22px;
  line-height: 1.45;
  color: var(--ink);
  font-weight: 400;
  margin: 0 0 3rem;
  max-width: 540px;
}
.lede em { font-style: italic; color: var(--ink-muted); }

.url-field {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--ink);
  background: transparent;
  padding: 0.5rem 0;
  font-family: var(--sans);
  font-size: 20px;
  color: var(--ink);
  margin-bottom: 2rem;
  outline: none;
}
.url-field::placeholder { color: var(--ink-faint); font-weight: 300; }
.url-field:focus { border-bottom-color: var(--accent); }

.form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink-muted);
  cursor: pointer;
}
.checkbox-row input[type="checkbox"] {
  accent-color: var(--accent);
  width: 16px; height: 16px;
  margin: 0;
}

.button-primary {
  background: var(--accent);
  color: var(--bg);
  border: 0;
  font-family: var(--sans);
  font-weight: 500;
  font-size: 14px;
  letter-spacing: 0.01em;
  padding: 0.75rem 1.5rem;
  cursor: pointer;
  border-radius: 0;
  transition: background 0.15s ease;
}
.button-primary:hover:not(:disabled) { background: var(--accent-hover); }
.button-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.button-primary .arrow { display: inline-block; margin-left: 0.5rem; }

/* ============ Scene 2: progress ============ */
.source-line {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-muted);
  margin: 0 0 2.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stages { list-style: none; padding: 0; margin: 0; }
.stages li {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.45rem 0;
  font-family: var(--sans);
  font-size: 15px;
}
.stages .marker {
  width: 18px;
  text-align: center;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink-faint);
}
.stages .done .marker { color: var(--ink-muted); }
.stages .done .label  { color: var(--ink-muted); }
.stages .active .marker { color: var(--accent); }
.stages .active .label  { color: var(--ink); font-weight: 500; }
.stages .pending .label { color: var(--ink-faint); }
.stages .error  .marker { color: var(--accent); }
.stages .error  .label  { color: var(--accent); }
.stages .dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin-left: 0.5rem;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ============ Scene 3: result ============ */
.video-title {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 34px;
  line-height: 1.2;
  letter-spacing: -0.015em;
  color: var(--ink);
  margin: 0 0 1rem;
}
.meta-line {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin: 0 0 0.5rem;
}
.meta-line .sep { color: var(--ink-faint); margin: 0 0.5rem; }

.source-url {
  display: inline-block;
  max-width: 100%;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-muted);
  text-decoration: none;
  border-bottom: 1px solid var(--divider);
  padding-bottom: 1px;
  margin: 0 0 2.5rem;
  word-break: break-all;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.source-url:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.actions {
  display: flex;
  gap: 0.75rem;
  margin: 0 0 3.5rem;
  flex-wrap: wrap;
}
.button-secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--ink);
  font-family: var(--sans);
  font-weight: 500;
  font-size: 13px;
  letter-spacing: 0.01em;
  padding: 0.55rem 1.1rem;
  cursor: pointer;
  border-radius: 0;
  transition: all 0.15s ease;
}
.button-secondary:hover:not(:disabled) {
  background: var(--ink);
  color: var(--bg);
}
.button-secondary:disabled { opacity: 0.5; cursor: not-allowed; }
.button-icon { display: inline-block; margin-right: 0.45rem; opacity: 0.8; }
.button-pdf {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}
.button-pdf:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--bg);
}

.summary-failed-note {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-muted);
  margin: 0 0 2rem;
}

.pdf-error {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent);
  margin: -2.5rem 0 2rem;
}

.summary {
  border-left: 2px solid var(--accent);
  padding: 0 0 0 1.5rem;
  margin: 0 0 3.5rem;
}
.summary-label {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.75rem;
}
.summary-body {
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.65;
  color: var(--ink);
  font-style: italic;
}
.summary-body p { margin: 0 0 0.75rem; }
.summary-body ul { padding-left: 1.2rem; margin: 0.75rem 0 0; }
.summary-body li { margin-bottom: 0.4rem; }

.transcript {
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.7;
  color: var(--ink);
  font-weight: 400;
}
.transcript p { margin: 0 0 1.5rem; }
.transcript p:first-child::first-letter {
  font-family: var(--serif);
  font-weight: 500;
  float: left;
  font-size: 3.2em;
  line-height: 0.95;
  margin: 0.1rem 0.4rem 0 0;
  color: var(--accent);
}
