* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  background: #f2ece2;
  color: #1e1711;
  overflow-x: hidden;
  width: 100%;
}

.shell {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 16px 56px;
  width: 100%;
  overflow-x: clip;
}

.hero {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: space-between;
  align-items: flex-start;
  background: #fffaf1;
  border: 1px solid #e7d9c3;
  border-radius: 18px;
  padding: 20px;
  box-shadow: 0 10px 24px rgba(74, 50, 20, 0.08);
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #8f6e3e;
  font-size: 0.82rem;
}

h1 {
  margin: 0 0 10px;
  font-size: 2.5rem;
  line-height: 1.04;
}

.deck {
  margin: 0;
  max-width: 56ch;
  color: #625547;
}

.meta {
  min-width: 220px;
  background: #191613;
  color: #f8f1e4;
  padding: 14px 16px;
  border-radius: 14px;
}

.meta-label,
.summary-label,
.metric-label {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.74rem;
  color: #a58f70;
}

#generated-at {
  margin: 6px 0 12px;
  font-size: 1rem;
}

button,
.button-link {
  display: inline-block;
  border: 0;
  border-radius: 999px;
  background: #9f7d2d;
  color: #fff9ef;
  padding: 10px 16px;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

.refresh-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.secondary-button {
  background: #5a4a35;
  color: #fff7ef;
}

#refresh-button.needs-refresh {
  background: #b63123;
  color: #fff7f2;
}

.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.summary-card,
.scene-card {
  background: #fffaf1;
  border: 1px solid #e7d9c3;
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 10px 22px rgba(74, 50, 20, 0.07);
}

.ok-pill {
  display: inline-block;
  padding: 8px 12px;
  border-radius: 999px;
  background: #efe4c7;
  color: #5d4822;
  font-size: 0.92rem;
}

.summary-value {
  margin-top: 6px;
  font-size: 1.35rem;
}

.scene-root {
  display: grid;
  gap: 18px;
}

.scene-section {
  background: #fffaf1;
  border: 1px solid #e7d9c3;
  border-radius: 20px;
  padding: 14px;
  box-shadow: 0 10px 22px rgba(74, 50, 20, 0.07);
}

.scene-section.primary {
  border-color: #d8bd77;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.scene-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 0;
  background: transparent;
  color: inherit;
  border-radius: 0;
  text-align: left;
}

.toggle-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: #efe4c7;
  color: #5d4822;
  font-size: 1.2rem;
  flex: 0 0 auto;
}

.section-sub {
  color: #625547;
  font-size: 0.88rem;
}

.section-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
}

.scene-section.collapsed .generation-stack,
.scene-section.collapsed .section-controls {
  display: none;
}

.nav-button {
  min-width: 42px;
  padding: 10px 0;
  line-height: 1;
}

.nav-button:disabled {
  opacity: 0.45;
  cursor: default;
}

.dot-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.dot {
  width: 10px;
  height: 10px;
  padding: 0;
  border-radius: 999px;
  background: #d7c3a3;
}

.dot.active {
  background: #9f7d2d;
}

.generation-stack {
  width: 100%;
  overflow: hidden;
}

.generation-panel {
  display: none;
  width: 100%;
  max-width: 100%;
  background: #fffdf8;
  border: 1px solid #eadfcd;
  border-radius: 18px;
  padding: 14px;
  overflow-x: clip;
  min-width: 0;
}

.generation-panel.active {
  display: block;
}

.generation-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 12px;
}

.scene-kicker {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.74rem;
  color: #8f6e3e;
}

.generation-title {
  margin: 4px 0 0;
  font-size: 1.55rem;
}

.generation-stat {
  white-space: nowrap;
  background: #efe4c7;
  color: #5d4822;
  border-radius: 999px;
  padding: 8px 12px;
}

.generation-player {
  margin-bottom: 12px;
}

.generation-player audio {
  width: 100%;
  max-width: 100%;
}

.generation-metrics {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.metric-chip {
  background: #f7efe2;
  border-radius: 999px;
  padding: 8px 10px;
  font-size: 0.88rem;
  color: #5e4c39;
}

.script-flow {
  display: grid;
  gap: 10px;
  width: 100%;
  min-width: 0;
}

.script-block {
  border-radius: 14px;
  padding: 12px 14px;
  border: 1px solid #eadfcd;
  background: #fffdf8;
  width: 100%;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.script-block.spoken {
  background: #fff39a;
  border-color: #dec64d;
}

.script-block.pause {
  background: #f3efe5;
}

.script-block.silent {
  background: #eef2f5;
}

.script-block.audio {
  background: #efe7ff;
}

.block-text,
.block-meta,
.block-speaker,
.generation-title,
.deck,
.summary-value {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 640px) {
  .shell {
    padding: 14px 10px 40px;
  }

  h1 {
    font-size: 2rem;
  }

  .hero,
  .scene-section,
  .generation-panel,
  .summary-card {
    border-radius: 14px;
  }

  .section-controls {
    width: 100%;
    justify-content: space-between;
  }

  .scene-toggle {
    align-items: flex-start;
  }

  .dot-row {
    flex: 1 1 auto;
  }

  .generation-top {
    flex-wrap: wrap;
  }
}

.block-speaker {
  font-weight: 700;
  margin-bottom: 4px;
}

.block-meta {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.78rem;
  color: #756a58;
  margin-bottom: 4px;
}

.block-text {
  white-space: pre-wrap;
}

.warnings {
  margin: 12px 0 0;
  padding-left: 18px;
  color: #7b2f2f;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 640px) {
  .shell {
    padding: 14px 10px 44px;
  }

  .hero {
    padding: 16px;
    border-radius: 16px;
  }

  h1 {
    font-size: 2rem;
  }

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

  .generation-panel {
    padding: 12px;
  }

  .generation-title {
    font-size: 1.3rem;
  }

  .refresh-actions {
    width: 100%;
  }
}
