:root {
  color-scheme: light;
  --bg: #eef3f7;
  --surface: #ffffff;
  --surface-soft: #f7fafc;
  --text: #15202b;
  --muted: #637383;
  --border: #d8e2ea;
  --accent: #0f766e;
  --accent-dark: #0a5e58;
  --shadow: 0 18px 48px rgba(25, 43, 58, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  color: var(--text);
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.14), transparent 34%),
    linear-gradient(315deg, rgba(38, 84, 120, 0.14), transparent 40%),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

.presenter-shell {
  width: min(1760px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 20px 0;
  display: grid;
  grid-template-columns: minmax(290px, 360px) 1fr;
  gap: 18px;
}

.control-rail,
.presentation-stage {
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow);
}

.control-rail {
  position: sticky;
  top: 20px;
  align-self: start;
  display: grid;
  gap: 16px;
  padding: 20px;
}

.brand-block p {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand-block h1 {
  margin: 0;
  font-size: clamp(1.8rem, 3vw, 2.7rem);
  line-height: 1.04;
  letter-spacing: 0;
}

.upload-box {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px dashed #a9bccb;
  border-radius: 8px;
  background: var(--surface-soft);
  cursor: pointer;
}

.upload-box span {
  color: var(--accent-dark);
  font-weight: 900;
}

.upload-box input {
  width: 100%;
}

.upload-box small {
  color: var(--muted);
  line-height: 1.35;
}

.upload-section {
  display: grid;
  gap: 8px;
}

.upload-action-button {
  width: 100%;
  min-height: 48px;
}

.upload-summary {
  color: var(--muted);
  line-height: 1.35;
  font-size: 0.88rem;
}

.upload-summary.has-selection {
  color: var(--accent-dark);
  font-weight: 800;
}

.upload-confirm {
  margin: 0;
  padding: 14px 16px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.45;
}

.upload-confirm.is-success {
  background: #d1fae5;
  border: 2px solid #059669;
  color: #065f46;
}

.upload-confirm.is-progress {
  background: #fef3c7;
  border: 2px solid #d97706;
  color: #92400e;
}

.upload-confirm.is-error {
  background: #fee2e2;
  border: 2px solid #dc2626;
  color: #991b1b;
}

.build-status #status-text.is-success {
  color: #065f46;
  font-weight: 800;
}

.build-status #status-text.is-progress {
  color: #92400e;
  font-weight: 800;
}

.build-status #status-text.is-error {
  color: #991b1b;
  font-weight: 800;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 18px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-weight: 900;
  cursor: pointer;
}

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

button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.secondary-action {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
}

.secondary-action:hover {
  background: var(--surface-soft);
}

.settings-panel {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
}

.settings-panel[hidden] {
  display: none;
}

.settings-panel label {
  color: var(--muted);
  font-size: 0.77rem;
  font-weight: 900;
  text-transform: uppercase;
}

.settings-panel select {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid #a9bccb;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-weight: 800;
}

.library-panel {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.library-panel label {
  color: var(--muted);
  font-size: 0.77rem;
  font-weight: 900;
  text-transform: uppercase;
}

.library-panel select {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid #a9bccb;
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--text);
  font-weight: 800;
}

.library-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.library-panel button {
  min-height: 42px;
}

.build-status {
  display: grid;
  gap: 10px;
}

#status-text {
  margin: 0;
  color: var(--muted);
  line-height: 1.48;
  font-size: 0.94rem;
}

.progress-track,
.narration-progress {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #dbe7ee;
}

.progress-track span,
.narration-progress span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 160ms ease;
}

.pipeline-summary {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.pipeline-summary div {
  display: grid;
  grid-template-columns: 78px 1fr;
  gap: 8px;
}

.pipeline-summary dt {
  color: var(--muted);
  font-size: 0.77rem;
  font-weight: 900;
  text-transform: uppercase;
}

.pipeline-summary dd {
  margin: 0;
  color: var(--text);
  font-size: 0.9rem;
}

.presentation-stage {
  min-height: calc(100vh - 40px);
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.stage-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.stage-toolbar p {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.92rem;
}

.stage-toolbar h2 {
  margin: 0;
  font-size: 1.08rem;
  line-height: 1.28;
}

.slide-counter {
  min-width: 86px;
  text-align: right;
  color: var(--accent-dark);
  font-weight: 900;
}

.slide-upload-badge {
  margin: 6px 0 0;
  padding: 8px 12px;
  border-radius: 999px;
  background: #d1fae5;
  border: 2px solid #059669;
  color: #065f46;
  font-size: 0.92rem;
  font-weight: 800;
  text-align: right;
}

.slide-viewer {
  position: relative;
  width: 100%;
  min-height: 650px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: 18px;
  background: #f2f5f8;
}

.slide-viewer canvas,
.slide-viewer img#slide-image {
  display: block;
  max-width: 100%;
  height: auto;
  background: #fff;
  box-shadow: 0 12px 32px rgba(25, 43, 58, 0.18);
}

.slide-viewer img#slide-image {
  object-fit: contain;
}

.slide-viewer img#slide-image[hidden],
.slide-viewer canvas[hidden] {
  display: none !important;
}

.slide-render-status {
  position: absolute;
  inset: auto 18px 18px;
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

.slide-viewer.is-ready .slide-render-status {
  display: none;
}

.narration-bar {
  display: grid;
  gap: 12px;
  padding: 16px 20px 18px;
  border-top: 1px solid var(--border);
}

.seek-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.seek-row input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.seek-row output {
  min-width: 86px;
  color: var(--muted);
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  text-align: right;
}

.slide-transport {
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.slide-transport button {
  min-height: 42px;
}

.slide-transport select {
  min-height: 42px;
  width: 100%;
  padding: 0 12px;
  border: 1px solid #a9bccb;
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--text);
  font-weight: 800;
}

#caption-text {
  max-height: 116px;
  overflow: auto;
  margin: 0;
  color: #243340;
  font-size: clamp(1.02rem, 1.5vw, 1.28rem);
  line-height: 1.48;
  font-weight: 700;
}

@media (max-width: 920px) {
  .presenter-shell {
    grid-template-columns: 1fr;
  }

  .control-rail {
    position: static;
  }
}

.slide-images-append {
  width: 100%;
}

@media (max-width: 640px) {
  .presenter-shell {
    width: min(100% - 20px, 1760px);
    padding: 10px 0;
  }

  .upload-action-button,
  .slide-images-append {
    min-height: 52px;
  }

  .slide-images-append {
    width: 100%;
  }

  .stage-toolbar {
    display: grid;
  }

  .slide-counter {
    text-align: left;
  }

  .slide-viewer {
    min-height: 520px;
    padding: 10px;
  }

  .seek-row,
  .slide-transport {
    grid-template-columns: 1fr;
  }

  .seek-row output {
    text-align: left;
  }
}

.home-screen {
  width: min(920px, calc(100% - 32px));
  margin: 0 auto;
  padding: 48px 0 64px;
  display: grid;
  gap: 22px;
}

.home-parts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.home-part {
  display: grid;
  gap: 16px;
  padding: 22px;
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow);
}

.home-part-label {
  margin: 0;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.home-part h2 {
  margin: 0;
  font-size: 1.18rem;
}

.home-part-lead {
  margin: -6px 0 0;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.45;
}

.home-part-extra {
  margin-top: 4px;
}

.home-part-action {
  width: 100%;
}

.upload-screen {
  width: min(560px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 64px;
  display: grid;
  gap: 22px;
}

.upload-screen-header {
  display: grid;
  gap: 10px;
}

.upload-screen-header h1 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  line-height: 1.05;
}

.upload-screen-lead {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.upload-screen-actions {
  display: grid;
  gap: 12px;
  padding: 22px;
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow);
}

.home-header {
  display: grid;
  gap: 10px;
}

.home-eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.home-header h1 {
  margin: 0;
  font-size: clamp(2rem, 4.5vw, 2.8rem);
  line-height: 1.04;
}

.home-panel {
  display: grid;
  gap: 16px;
  padding: 22px;
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow);
}

.home-panel h2 {
  margin: 0;
  font-size: 1.18rem;
}

.home-panel-lead {
  margin: -6px 0 0;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.45;
}

.home-maker-actions {
  display: grid;
  gap: 12px;
}

.home-continue-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
}

.home-continue-row label {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 800;
  white-space: nowrap;
}

.home-continue-row select {
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid #a9bccb;
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--text);
  font-weight: 700;
}

.home-upload-box {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px dashed #a9bccb;
  border-radius: 8px;
  background: var(--surface-soft);
  cursor: pointer;
}

.home-upload-box span {
  color: var(--accent-dark);
  font-weight: 900;
}

.home-upload-box input {
  width: 100%;
}

.home-upload-box small {
  color: var(--muted);
  line-height: 1.35;
}

.back-home-button {
  justify-self: start;
  min-height: 40px;
  padding-inline: 14px;
  font-size: 0.92rem;
}

.home-stage-placeholder {
  position: relative;
}

.home-stage-message {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  pointer-events: none;
}

.home-stage-message p {
  max-width: 420px;
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.5;
}

.slide-viewer.has-slide-content .home-stage-message {
  display: none;
}

.control-rail-minimal {
  gap: 12px;
}

.control-rail-minimal .brand-block h1 {
  font-size: clamp(1.5rem, 2.5vw, 2rem);
}

.control-rail-minimal .library-panel {
  margin: 0;
}

.slide-transport-minimal {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.slide-transport-minimal button {
  min-width: 3rem;
  font-size: 1.4rem;
  line-height: 1;
  padding: 0.35rem 0.75rem;
}

@media (max-width: 640px) {
  .home-screen {
    width: min(100% - 20px, 720px);
    padding: 28px 0 40px;
  }

  .home-parts {
    grid-template-columns: 1fr;
  }

  .upload-screen {
    width: min(100% - 20px, 560px);
    padding: 24px 0 40px;
  }

  .home-continue-row {
    grid-template-columns: 1fr;
  }
}
