:root {
  color-scheme: dark;
  --bg: #111317;
  --panel: rgba(17, 22, 29, 0.84);
  --panel-strong: rgba(25, 31, 40, 0.92);
  --line: rgba(255, 255, 255, 0.1);
  --text: #f3f1e8;
  --muted: #b0b3bb;
  --accent: #ffb347;
  --accent-strong: #ffd17d;
  --danger: #ff6b6b;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
  --radius: 18px;
  --font-display: "TASA Explorer", "Segoe UI", sans-serif;
  --font-body: "Google Sans", "Google Sans Text", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(255, 179, 71, 0.18), transparent 30%),
    radial-gradient(circle at bottom right, rgba(83, 144, 217, 0.2), transparent 34%),
    linear-gradient(135deg, #0a0c0f 0%, #171d25 45%, #0f1218 100%);
  color: var(--text);
  font-family: var(--font-body);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(360px, 430px) 1fr;
  gap: 24px;
  min-height: 100vh;
  padding: 24px;
  align-items: start;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-right: 8px;
  min-width: 0;
}

.panel,
.stage-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.panel {
  padding: 18px;
}

.collapsible {
  padding: 0;
  overflow: hidden;
}

.collapsible-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  border-radius: 0;
  background: transparent;
}

.collapsible-trigger:hover {
  transform: none;
  background: rgba(255, 255, 255, 0.03);
}

.collapsible-trigger h2 {
  margin: 0;
  text-align: left;
}

.collapsible-content {
  padding: 0 18px 18px;
}

.collapsible:not(.is-open) .collapsible-content {
  display: none;
}

.chevron {
  width: 12px;
  height: 12px;
  border-right: 2px solid var(--accent-strong);
  border-bottom: 2px solid var(--accent-strong);
  transform: rotate(45deg);
  transition: transform 140ms ease;
  flex: 0 0 auto;
  margin-right: 4px;
}

.collapsible.is-open .chevron {
  transform: rotate(225deg);
}

.hero {
  background:
    linear-gradient(180deg, rgba(255, 179, 71, 0.12), transparent),
    var(--panel-strong);
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.74rem;
  color: var(--accent-strong);
  font-family: var(--font-display);
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: 2rem;
  line-height: 1.05;
  font-family: var(--font-display);
}

h2 {
  margin-bottom: 12px;
  font-size: 1.05rem;
  font-family: var(--font-display);
}

.intro,
.footnote,
.status,
.readout {
  color: var(--muted);
}

.grid {
  display: grid;
  gap: 12px;
}

.two-up {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.compact-grid {
  gap: 10px;
}

.compact-grid > .field:first-child:last-child {
  max-width: 160px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.field.inline {
  gap: 8px;
}

.field span {
  font-size: 0.82rem;
  color: var(--muted);
  padding-top: 2px;
}

.color-field input[type="color"] {
  width: 100%;
  max-width: 160px;
}

input[type="number"],
input[type="range"],
input[type="file"],
select {
  width: 100%;
}

input[type="number"],
select,
input[type="file"] {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}

input[type="range"] {
  accent-color: var(--accent);
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 2px;
}

.slider-row output {
  min-width: 56px;
  text-align: right;
  color: var(--accent-strong);
  font-size: 0.82rem;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-heading-inner {
  margin-bottom: 12px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.actions {
  background:
    linear-gradient(180deg, rgba(255, 179, 71, 0.08), transparent 22%),
    var(--panel-strong);
}

.stage-actions-panel {
  margin-top: 16px;
}

.action-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.action-field {
  min-width: 148px;
  max-width: 180px;
}

.action-field span {
  font-size: 0.75rem;
}

button,
.download-link {
  border: 0;
  border-radius: 999px;
  padding: 12px 16px;
  cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease, background 120ms ease;
}

button:hover,
.download-link:hover {
  transform: translateY(-1px);
}

button {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

button.primary,
.download-link {
  background: linear-gradient(135deg, #ffb347 0%, #ff8f5a 100%);
  color: #111317;
  font-weight: 700;
  text-decoration: none;
  text-align: center;
}

button:disabled {
  cursor: progress;
  opacity: 0.6;
}

.stage-wrap {
  min-width: 0;
  position: sticky;
  top: 24px;
  display: flex;
  justify-content: center;
}

.stage-panel {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 48px);
  padding: 18px;
  width: min(100%, 1480px);
}

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

.stage-heading {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}

.stage-heading h2 {
  margin-bottom: 0;
}

.stage-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stage-actions button {
  padding: 10px 14px;
}

.preview-timeline {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.timeline-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.8rem;
}

.preview-surface {
  position: relative;
  width: 100%;
  max-width: min(100%, 1400px);
  aspect-ratio: 16 / 9;
  min-height: 0;
  margin-inline: auto;
}

#previewCanvas {
  width: 100%;
  height: 100%;
  border-radius: 20px;
  background: #0d1117;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.preview-upload-button {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  background: rgba(17, 22, 29, 0.84);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(12px);
}

.preview-upload-button:hover {
  transform: translate(-50%, -50%);
}

input[type="color"] {
  width: 100%;
  min-height: 44px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px;
}

.hidden {
  display: none;
}

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

  .stage-wrap {
    position: static;
    top: auto;
  }

  .stage-panel {
    height: auto;
    min-height: 50vh;
  }

  .preview-surface {
    min-height: 0;
  }
}

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

  .two-up {
    grid-template-columns: 1fr;
  }

  .color-field input[type="color"],
  .compact-grid > .field:first-child:last-child {
    max-width: none;
  }

  .stage-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .stage-actions {
    width: 100%;
    justify-content: space-between;
  }

  h1 {
    font-size: 1.7rem;
  }
}
