:root {
  color-scheme: light;
  --ink: #1c1917;
  --muted: #57534e;
  --line: #e7e5e4;
  --paper: #f7f4ef;
  --card: #fffcf8;
  --stage: #1f1c19;
  --accent: #2f5d56;
  --accent-hover: #244843;
  --danger: #9f2d2d;
  --ok: #2f5d56;
  --warn: #9a6700;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(28 25 23 / 6%), 0 12px 32px rgb(28 25 23 / 6%);
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

body {
  font-size: 1.05rem;
  line-height: 1.5;
}

.page {
  width: min(44rem, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2.5rem 0 3.5rem;
}

.masthead h1 {
  margin: 0.15rem 0 0.6rem;
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.lede,
.hint,
footer p {
  color: var(--muted);
}

.lede {
  margin: 0;
  max-width: 36rem;
}

.stage {
  position: relative;
  margin: 1.75rem 0 1.1rem;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--stage);
  box-shadow: var(--shadow);
  aspect-ratio: 16 / 10;
}

.stage video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--stage);
}

.placeholder {
  position: absolute;
  inset: 0;
  background: var(--stage);
  pointer-events: none;
  opacity: 1;
  transition: opacity 450ms ease, visibility 0s linear 0s;
}

.placeholder picture,
.placeholder .poster {
  display: block;
  width: 100%;
  height: 100%;
}

/* Same crop as the live <video> (object-fit: cover, centered) so the handoff does not jump. */
.placeholder .poster {
  object-fit: cover;
  object-position: 50% 50%;
}

/* Live stream is attached: cross-fade the still out over the first video frames. */
.stage.is-live .placeholder {
  opacity: 0;
  visibility: hidden;
  transition: opacity 450ms ease, visibility 0s linear 450ms;
}

.connecting {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  padding: 1.5rem;
  background: rgb(20 18 16 / 0%);
  color: #fafaf9;
  font-size: 0.95rem;
  font-weight: 500;
  text-align: center;
  opacity: 0;
  transition: opacity 250ms ease, background-color 250ms ease;
}

.stage.is-connecting .connecting {
  opacity: 1;
  background: rgb(20 18 16 / 52%);
}

.connecting-label {
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  background: rgb(20 18 16 / 62%);
  font-size: 1rem;
  letter-spacing: 0.01em;
}

.spinner {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  border: 3px solid rgb(255 255 255 / 28%);
  border-top-color: #fff;
  animation: stage-spin 0.9s linear infinite;
  animation-play-state: paused;
}

.stage.is-connecting .spinner {
  animation-play-state: running;
}

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

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation: stage-pulse 1.6s ease-in-out infinite;
    animation-play-state: paused;
  }

  @keyframes stage-pulse {
    50% {
      opacity: 0.35;
    }
  }
}

.panel,
.sources,
.transcript {
  padding: 1.1rem 1.2rem 1.2rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
}

.status {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0 0 0.75rem;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.95rem;
}

.dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: #a8a29e;
}

.dot.connecting {
  background: var(--warn);
}

.dot.connected,
.dot.live {
  background: var(--ok);
}

.dot.error {
  background: var(--danger);
}

.error {
  margin: 0 0 0.85rem;
  color: var(--danger);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.92rem;
}

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

button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 0.65rem 1.15rem;
  background: var(--accent);
  color: #f8faf9;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

button:hover:not(:disabled) {
  background: var(--accent-hover);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

#talk-button[aria-pressed='true'] {
  background: var(--warn);
}

#end-button {
  background: transparent;
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
}

#end-button:hover:not(:disabled) {
  background: #f5f0ea;
}

.hint {
  margin: 0.85rem 0 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.82rem;
}

.ask {
  margin: 0.95rem 0 0;
}

.ask-label {
  display: block;
  margin: 0 0 0.4rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.ask-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.ask-row input {
  flex: 1 1 12rem;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.6rem 0.95rem;
  background: #fff;
  color: var(--ink);
  font-family: inherit;
  font-size: 0.95rem;
}

.ask-row input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.ask-row button {
  padding: 0.6rem 1rem;
}

.transcript,
.sources {
  margin-top: 1.1rem;
}

.transcript h2 {
  margin: 0 0 0.25rem;
  font-size: 1.05rem;
  font-weight: 600;
}

.transcript ol {
  margin: 0.7rem 0 0;
  padding: 0;
  max-height: 12rem;
  overflow: auto;
  list-style: none;
}

.transcript .turn {
  padding: 0.4rem 0;
  border-top: 1px solid var(--line);
}

.transcript .turn:first-child {
  border-top: 0;
  padding-top: 0;
}

.transcript .speaker {
  display: block;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.transcript .turn.user .speaker {
  color: var(--muted);
}

.transcript .turn p {
  margin: 0.15rem 0 0;
  font-size: 0.92rem;
}

.sources h2 {
  margin: 0 0 0.25rem;
  font-size: 1.05rem;
  font-weight: 600;
}

.sources ul {
  margin: 0.7rem 0 0;
  padding: 0;
  list-style: none;
}

.sources li {
  padding: 0.45rem 0;
  border-top: 1px solid var(--line);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.92rem;
}

.sources li:first-child {
  border-top: 0;
}

.sources .section {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
}

.source-media {
  display: grid;
  gap: 0.55rem;
  margin-top: 0.55rem;
}

.source-media img,
.source-media video,
.source-media iframe {
  display: block;
  width: 100%;
  border-radius: 8px;
  background: var(--stage);
}

.source-media iframe {
  aspect-ratio: 16 / 9;
  border: 0;
}

.source-media video {
  max-height: 14rem;
}

footer {
  margin-top: 1.75rem;
}

footer p {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.8rem;
}

html.is-embed,
html.is-embed body {
  min-height: 100%;
}

html.is-embed .page {
  width: min(100% - 1rem, 56rem);
  margin: 0 auto;
  padding: 0.75rem 0 1rem;
}

html.is-embed .masthead,
html.is-embed footer {
  display: none;
}

html.is-embed .stage {
  margin-top: 0;
}

@media (min-width: 720px) {
  main.has-sources,
  html.is-embed main.has-sources {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(14rem, 22rem);
    column-gap: 1rem;
    align-items: start;
  }

  main.has-sources .stage,
  html.is-embed main.has-sources .stage {
    grid-column: 1;
    grid-row: 1;
    margin-bottom: 1.1rem;
  }

  main.has-sources .panel,
  html.is-embed main.has-sources .panel {
    grid-column: 1;
    grid-row: 2;
  }

  main.has-sources .transcript,
  html.is-embed main.has-sources .transcript {
    grid-column: 1;
    grid-row: 3;
  }

  main.has-sources .sources,
  html.is-embed main.has-sources .sources {
    grid-column: 2;
    grid-row: 1 / span 3;
    margin-top: 1.75rem;
  }

  html.is-embed main.has-sources .sources {
    margin-top: 0;
  }
}

@media (max-width: 640px) {
  .page {
    width: min(100% - 1.25rem, 44rem);
    padding-top: 1.5rem;
  }

  html.is-embed .page {
    width: min(100% - 1rem, 44rem);
    padding-top: 0.75rem;
  }

  .masthead h1 {
    font-size: 1.65rem;
  }

  .stage {
    aspect-ratio: 4 / 5;
  }
}
