:root {
  color-scheme: light;
  --ink: #151515;
  --muted: #60646c;
  --paper: #f6f0e7;
  --panel: #fffaf2;
  --line: rgba(21, 21, 21, 0.13);
  --teal: #1b7f79;
  --red: #b74838;
  --blue: #2d5f90;
  --shadow: 0 18px 60px rgba(20, 17, 13, 0.16);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: rgba(246, 240, 231, 0.88);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  background: var(--ink);
  color: var(--paper);
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
  line-height: 1.1;
}

.brand small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.topnav {
  display: flex;
  gap: 20px;
  font-size: 14px;
}

.topnav a {
  color: var(--muted);
  text-decoration: none;
}

.topnav a:hover {
  color: var(--ink);
}

.workspace {
  min-height: calc(100svh - 64px);
  display: grid;
  grid-template-columns: minmax(360px, 0.84fr) minmax(420px, 1.16fr);
  border-bottom: 1px solid var(--line);
}

.setup-pane {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 52px clamp(24px, 5vw, 72px);
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  max-width: 720px;
  margin-bottom: 18px;
  font-size: clamp(42px, 5vw, 76px);
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 16px;
  font-size: clamp(26px, 3vw, 42px);
  line-height: 1.05;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 10px;
  font-size: 20px;
  letter-spacing: 0;
}

.lead {
  max-width: 680px;
  margin-bottom: 30px;
  color: #3c3f44;
  font-size: 18px;
  line-height: 1.7;
}

.generator-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  max-width: 740px;
}

.field {
  display: grid;
  gap: 8px;
}

.field-wide {
  grid-column: 1 / -1;
}

.field span {
  color: #33363b;
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field select {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  background: rgba(255, 250, 242, 0.82);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  outline: none;
  transition:
    border-color 180ms ease,
    box-shadow 180ms ease,
    background 180ms ease;
}

.field input:focus,
.field select:focus {
  border-color: rgba(27, 127, 121, 0.65);
  box-shadow: 0 0 0 4px rgba(27, 127, 121, 0.11);
  background: #fffdf8;
}

.field input[type="range"] {
  min-height: 32px;
  padding: 0;
  accent-color: var(--teal);
  box-shadow: none;
}

.action-row {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
}

.primary-action,
.ghost-action,
.export-stack button,
.tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    background 180ms ease,
    color 180ms ease;
}

.primary-action:hover,
.ghost-action:hover,
.export-stack button:hover,
.tab:hover {
  transform: translateY(-1px);
}

.primary-action {
  padding: 0 22px;
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
  font-weight: 800;
}

.ghost-action {
  padding: 0 18px;
  background: rgba(255, 250, 242, 0.68);
  color: var(--ink);
}

.visual-pane {
  position: relative;
  min-height: 560px;
  overflow: hidden;
  background: #1e1b18;
}

.visual-pane::after {
  position: absolute;
  inset: 0;
  content: "";
  background:
    linear-gradient(90deg, rgba(10, 8, 6, 0.16), rgba(10, 8, 6, 0.02) 36%),
    linear-gradient(0deg, rgba(13, 10, 8, 0.4), transparent 34%);
  pointer-events: none;
}

.visual-pane img {
  width: 100%;
  height: 100%;
  min-height: inherit;
  object-fit: cover;
  object-position: center;
  display: block;
  transform: scale(1.02);
  animation: slowReveal 900ms ease both;
}

.visual-meter {
  position: absolute;
  right: 24px;
  bottom: 24px;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(86px, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(20, 17, 13, 0.56);
  color: white;
  backdrop-filter: blur(18px);
}

.visual-meter span {
  display: grid;
  gap: 3px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 12px;
  text-transform: uppercase;
}

.visual-meter strong {
  font-size: 24px;
  line-height: 1;
}

.outputs {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  gap: 0;
  min-height: 760px;
  border-bottom: 1px solid var(--line);
}

.run-panel {
  padding: 44px 28px;
  border-right: 1px solid var(--line);
  background: #eee4d5;
}

.run-panel h2 {
  font-size: 30px;
}

.run-stats {
  display: grid;
  gap: 0;
  margin: 24px 0 30px;
  border-top: 1px solid rgba(21, 21, 21, 0.16);
}

.run-stats div {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid rgba(21, 21, 21, 0.16);
}

.run-stats dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.run-stats dd {
  margin: 0;
  color: #303238;
}

.export-stack {
  display: grid;
  gap: 10px;
}

.export-stack button {
  justify-content: flex-start;
  width: 100%;
  padding: 0 13px;
  background: rgba(255, 250, 242, 0.64);
  color: var(--ink);
}

.output-stage {
  min-width: 0;
  padding: 44px clamp(20px, 4vw, 54px);
  background:
    linear-gradient(rgba(21, 21, 21, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(21, 21, 21, 0.035) 1px, transparent 1px), var(--panel);
  background-size: 36px 36px;
}

.tabbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 28px;
}

.tab {
  padding: 0 14px;
  background: rgba(255, 250, 242, 0.86);
  color: #373a40;
}

.tab.is-active {
  background: var(--teal);
  border-color: var(--teal);
  color: white;
}

.tab-content {
  min-height: 560px;
  animation: riseIn 260ms ease both;
}

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

.content-block {
  padding: 20px;
  background: rgba(255, 253, 248, 0.86);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 38px rgba(35, 31, 25, 0.07);
}

.content-block.full {
  grid-column: 1 / -1;
}

.content-block p,
.content-block li {
  color: #3f4248;
  line-height: 1.65;
}

.idea-list,
.metadata-list,
.scene-list,
.thumbnail-list {
  display: grid;
  gap: 14px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.idea-list li,
.metadata-list li,
.thumbnail-list li {
  padding-left: 16px;
  border-left: 3px solid var(--teal);
}

.scene-list li {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid rgba(21, 21, 21, 0.1);
}

.scene-list time {
  color: var(--red);
  font-size: 13px;
  font-weight: 800;
}

.timeline {
  display: grid;
  gap: 14px;
}

.timeline-row {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr) 56px;
  gap: 12px;
  align-items: center;
}

.timeline-track {
  position: relative;
  height: 28px;
  overflow: hidden;
  background: #eadfce;
  border: 1px solid rgba(21, 21, 21, 0.11);
  border-radius: 6px;
}

.timeline-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, var(--teal), var(--blue));
}

.timeline-row:nth-child(3n) .timeline-fill {
  background: linear-gradient(90deg, var(--red), #c6883d);
}

.scene-preview {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.sketch {
  min-height: 150px;
  padding: 10px;
  background: #fffefa;
  border: 1px solid rgba(21, 21, 21, 0.14);
  border-radius: 8px;
}

.sketch svg {
  width: 100%;
  height: auto;
  display: block;
}

pre {
  max-height: 520px;
  overflow: auto;
  padding: 18px;
  background: #191714;
  color: #fff8e9;
  border-radius: 8px;
  line-height: 1.55;
  white-space: pre-wrap;
}

code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
}

.handoff {
  display: grid;
  grid-template-columns: minmax(240px, 360px) minmax(0, 1fr);
  gap: 44px;
  padding: 54px clamp(24px, 5vw, 76px);
}

.handoff-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--line);
  border: 1px solid var(--line);
}

.handoff-list li {
  min-height: 190px;
  padding: 22px;
  background: #fff9ee;
}

.handoff-list span {
  display: block;
  margin-bottom: 28px;
  color: var(--red);
  font-weight: 900;
}

.handoff-list strong {
  display: block;
  margin-bottom: 12px;
}

.handoff-list p {
  margin: 0;
  color: #4c4f55;
  line-height: 1.65;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 30;
  max-width: min(360px, calc(100vw - 40px));
  padding: 12px 16px;
  background: var(--ink);
  color: white;
  border-radius: 6px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.svg-icon,
[data-lucide] {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slowReveal {
  from {
    opacity: 0;
    transform: scale(1.05);
  }
  to {
    opacity: 1;
    transform: scale(1.02);
  }
}

@media (max-width: 980px) {
  .workspace,
  .outputs,
  .handoff {
    grid-template-columns: 1fr;
  }

  .visual-pane {
    min-height: 420px;
    order: -1;
  }

  .run-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

@media (max-width: 680px) {
  .topbar {
    height: auto;
    min-height: 62px;
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
    padding: 12px 18px;
  }

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

  .workspace {
    min-height: auto;
  }

  .setup-pane {
    padding: 34px 18px 42px;
  }

  h1 {
    font-size: 42px;
  }

  .lead {
    font-size: 16px;
  }

  .generator-form,
  .content-grid,
  .scene-preview,
  .handoff-list {
    grid-template-columns: 1fr;
  }

  .visual-pane {
    min-height: 320px;
  }

  .visual-meter {
    right: 12px;
    bottom: 12px;
    left: 12px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .visual-meter span {
    padding: 10px;
  }

  .visual-meter strong {
    font-size: 20px;
  }

  .output-stage,
  .run-panel,
  .handoff {
    padding: 32px 18px;
  }

  .timeline-row {
    grid-template-columns: 66px minmax(0, 1fr);
  }

  .timeline-row span:last-child {
    grid-column: 2;
  }

  .scene-list li {
    grid-template-columns: 1fr;
  }
}
