:root {
  --bg-start: #0a0b10;
  --bg-end: #151821;
  --bg-radial-a: rgba(98, 104, 255, 0.16);
  --bg-radial-b: rgba(118, 203, 255, 0.1);
  --bg-radial-c: rgba(255, 255, 255, 0.04);
  --surface: rgba(17, 20, 28, 0.72);
  --surface-strong: rgba(18, 22, 31, 0.9);
  --surface-soft: rgba(255, 255, 255, 0.06);
  --ink: #f5f7fb;
  --ink-soft: #aeb7c8;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --accent: #8fb8ff;
  --accent-deep: #5e83ff;
  --gold: #d8c08f;
  --card: rgba(17, 20, 28, 0.72);
  --shadow: 0 28px 90px rgba(0, 0, 0, 0.28);
  --poster-top: #0c1020;
  --poster-mid: #18243f;
  --poster-bottom: #223560;
  --poster-glow-a: rgba(255, 255, 255, 0.92);
  --poster-glow-b: rgba(151, 195, 255, 0.7);
  --toggle-bg: rgba(255, 255, 255, 0.08);
  --toggle-text: #eef3ff;
  --toggle-ring: rgba(255, 255, 255, 0.12);
}

body[data-theme="light"] {
  --bg-start: #f7f1e6;
  --bg-end: #efe3d1;
  --bg-radial-a: rgba(179, 61, 48, 0.12);
  --bg-radial-b: rgba(175, 125, 42, 0.12);
  --bg-radial-c: rgba(255, 255, 255, 0.28);
  --surface: rgba(255, 251, 245, 0.72);
  --surface-strong: rgba(255, 249, 240, 0.9);
  --surface-soft: rgba(255, 255, 255, 0.44);
  --ink: #171311;
  --ink-soft: #5f5348;
  --line: rgba(23, 19, 17, 0.12);
  --line-strong: rgba(23, 19, 17, 0.2);
  --accent: #b33d30;
  --accent-deep: #842219;
  --gold: #af7d2a;
  --card: rgba(255, 251, 245, 0.78);
  --shadow: 0 22px 60px rgba(60, 31, 10, 0.12);
  --poster-top: #140f0d;
  --poster-mid: #281714;
  --poster-bottom: #583226;
  --poster-glow-a: rgba(255, 242, 208, 1);
  --poster-glow-b: rgba(227, 183, 101, 0.8);
  --toggle-bg: rgba(255, 255, 255, 0.6);
  --toggle-text: #171311;
  --toggle-ring: rgba(23, 19, 17, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 0% 0%, var(--bg-radial-a), transparent 22%),
    radial-gradient(circle at 100% 10%, var(--bg-radial-b), transparent 18%),
    radial-gradient(circle at 50% 50%, var(--bg-radial-c), transparent 40%),
    linear-gradient(180deg, var(--bg-start) 0%, var(--bg-end) 100%);
  color: var(--ink);
  font-family: "Space Grotesk", sans-serif;
}

.page-shell {
  width: min(1280px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 44px;
}

.hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 28px;
  align-items: stretch;
  padding: 28px;
  border: 1px solid var(--line-strong);
  border-radius: 34px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.01)),
    var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px);
}

.eyebrow,
.panel-kicker,
.card-label {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  color: var(--accent);
}

.hero h1,
.panel-heading h2,
.result-card h3,
.preview-card h3,
.process-copy h2,
.process-steps h3 {
  margin: 10px 0 0;
  font-family: "Cormorant Garamond", serif;
  font-weight: 700;
}

.hero h1 {
  max-width: 11ch;
  font-size: clamp(3rem, 5.6vw, 5.2rem);
  line-height: 0.96;
  letter-spacing: -0.03em;
  text-wrap: balance;
  margin-top: 14px;
}

.hero-copy {
  max-width: 52ch;
  color: var(--ink-soft);
  font-size: 1rem;
  line-height: 1.68;
  text-wrap: pretty;
  margin-top: 18px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

.hero-link,
button {
  transition: transform 120ms ease, opacity 120ms ease;
}

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

.hero-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 13px 18px;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 600;
}

.primary-link {
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #f8fbff;
}

.secondary-link {
  border: 1px solid var(--line-strong);
  background: var(--surface-soft);
  color: var(--ink);
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.hero-meta span {
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.48);
  color: var(--ink);
  font-size: 0.82rem;
}

.hero-stage {
  display: flex;
  align-items: stretch;
}

.theme-switcher {
  position: absolute;
  top: 24px;
  right: 24px;
  z-index: 3;
}

.theme-toggle {
  border: 1px solid var(--line-strong);
  background: var(--toggle-bg);
  color: var(--toggle-text);
  width: 52px;
  height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0;
  backdrop-filter: blur(12px);
  box-shadow: inset 0 1px 0 var(--toggle-ring);
}

.theme-icon {
  position: absolute;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  transition: opacity 160ms ease, transform 160ms ease;
}

.theme-icon svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.theme-icon-sun {
  opacity: 0;
  transform: scale(0.75) rotate(-18deg);
}

.theme-icon-moon {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

body[data-theme="light"] .theme-icon-sun {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

body[data-theme="light"] .theme-icon-moon {
  opacity: 0;
  transform: scale(0.75) rotate(18deg);
}

.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;
}

.stage-frame {
  width: 100%;
  min-height: 100%;
  padding: 16px;
  border-radius: 24px;
  border: 1px solid var(--line-strong);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02));
}

.stage-label {
  margin: 0 0 14px;
  color: var(--ink-soft);
  font-size: 0.82rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.stage-poster {
  position: relative;
  overflow: hidden;
  min-height: 245px;
  padding: 18px;
  border-radius: 20px;
  background:
    radial-gradient(circle at 50% 33%, var(--poster-glow-a), transparent 16%),
    radial-gradient(circle at 50% 28%, var(--poster-glow-b), transparent 26%),
    linear-gradient(180deg, var(--poster-top) 0%, var(--poster-mid) 48%, var(--poster-bottom) 100%);
}

.poster-orb {
  position: absolute;
  inset: 18% 24% auto 24%;
  height: 160px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, var(--poster-glow-a), var(--poster-glow-b) 38%, rgba(227, 183, 101, 0.06) 70%, transparent 72%);
}

.poster-copy {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 20px;
}

.poster-copy p {
  margin: 0;
  color: #fff1df;
  font-family: "Cormorant Garamond", serif;
  max-width: 7ch;
  font-size: clamp(2.2rem, 3.2vw, 3.4rem);
  line-height: 0.95;
  text-wrap: balance;
}

.poster-copy span {
  display: block;
  max-width: 205px;
  margin-top: 10px;
  color: rgba(255, 241, 223, 0.8);
  line-height: 1.42;
  font-size: 0.94rem;
}

.stage-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.stage-grid article,
.preview-card,
.process-steps article {
  border: 1px solid var(--line);
  background: var(--surface-soft);
}

.stage-grid article {
  padding: 12px;
  border-radius: 16px;
}

.stage-grid span,
.process-steps span {
  display: block;
  color: var(--accent);
  font-size: 0.74rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.stage-grid strong {
  display: block;
  margin-top: 6px;
  font-size: 0.9rem;
  line-height: 1.3;
}

.workspace {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  margin-top: 16px;
  scroll-margin-top: 24px;
}

.panel,
.result-card {
  border: 1px solid var(--line-strong);
  border-radius: 28px;
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px);
}

.panel-heading,
.copy-row {
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
}

.result-card .card-label + h3,
.result-card .card-label + p,
.result-card .card-label + .helper-copy {
  margin-top: 10px;
}

.panel {
  padding: 24px;
}

.input-panel {
  position: static;
}

.panel-heading h2 {
  font-size: 1.9rem;
  line-height: 0.95;
  text-wrap: balance;
}

.field {
  display: block;
  margin-top: 18px;
}

.field span {
  display: block;
  margin-bottom: 8px;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

textarea,
select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  padding: 14px 16px;
  font: inherit;
  color-scheme: dark;
}

body[data-theme="light"] textarea,
body[data-theme="light"] select {
  background: rgba(255, 255, 255, 0.68);
  color-scheme: light;
}

select option {
  background: #1b1f2a;
  color: #f5f7fb;
}

body[data-theme="light"] select option {
  background: #ffffff;
  color: #171311;
}

textarea {
  resize: vertical;
  min-height: 126px;
}

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

.idea-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.idea-chip {
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface-soft);
  color: var(--ink);
  font-size: 0.88rem;
}

.idea-assist {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
}

.idea-assist-copy p:last-child {
  margin: 8px 0 0;
  color: var(--ink-soft);
  font-size: 0.94rem;
}

.output-panel .empty-state {
  min-height: 220px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 22px;
}

#hermesStatus {
  margin: 12px 0 0;
}

button {
  cursor: pointer;
  border: 0;
  border-radius: 999px;
  font: inherit;
}

.primary-button,
.secondary-button {
  padding: 13px 18px;
}

.primary-button {
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #fff8f4;
  font-weight: 700;
}

.secondary-button {
  background: var(--surface-soft);
  color: var(--ink);
  border: 1px solid var(--line-strong);
}

.small-button {
  padding: 10px 14px;
  font-size: 0.9rem;
}

.agent-note {
  margin-top: 18px;
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink-soft);
  font-size: 0.95rem;
  line-height: 1.6;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 280px;
  border: 1px dashed var(--line-strong);
  border-radius: 22px;
  color: var(--ink-soft);
}

.hidden {
  display: none;
}

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

.board-overview-grid,
.board-direction-grid,
.board-lower-grid {
  display: grid;
  gap: 14px;
  align-items: stretch;
}

.board-overview-grid,
.board-direction-grid,
.board-lower-grid {
  grid-template-columns: 1fr;
}

.title-treatment {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  min-height: 100%;
}

.title-treatment-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 14px;
  flex: 1 1 auto;
}

.title-treatment-text {
  margin: 8px 0 0;
  font-family: "Cormorant Garamond", serif;
  font-size: clamp(2.35rem, 4vw, 3.35rem);
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--ink);
  max-width: none;
  white-space: nowrap;
  word-break: normal;
  overflow-wrap: normal;
  text-wrap: nowrap;
}

.title-treatment-tagline {
  margin: 0;
  max-width: none;
  font-size: 1rem;
  line-height: 1.55;
  white-space: nowrap;
}

.palette-panel {
  flex: 0 0 220px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 16px;
}

.section-stack {
  display: grid;
  gap: 16px;
  margin-top: 12px;
}

.section-block {
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.section-block:first-child {
  padding-top: 0;
  border-top: 0;
}

.sub-label {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.palette {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 18px;
  width: 100%;
  max-width: 280px;
}

.palette-swatch {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.palette-chip {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  flex: 0 0 40px;
}

.palette-meta {
  min-width: 0;
}

.palette-name,
.palette-hex {
  display: block;
  line-height: 1.2;
}

.palette-name {
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
}

.palette-hex {
  margin-top: 3px;
  color: var(--ink-soft);
  font-size: 0.74rem;
  letter-spacing: 0.04em;
}

@media (max-width: 1180px) {
  .palette {
    grid-template-columns: 1fr;
    max-width: 180px;
  }
}

.storyboard-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  grid-auto-rows: 1fr;
}

.storyboard-card {
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 14px;
  min-height: 188px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02)),
    rgba(255, 255, 255, 0.02);
  display: flex;
  flex-direction: column;
}

.storyboard-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.storyboard-label {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.storyboard-pill {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.storyboard-copy strong {
  display: block;
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 1rem;
}

.storyboard-copy p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.9rem;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  overflow: hidden;
}

.result-card {
  padding: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02));
  min-height: 100%;
}

.accent-card {
  background:
    linear-gradient(135deg, rgba(143, 184, 255, 0.16), rgba(255, 255, 255, 0.03)),
    rgba(255, 255, 255, 0.02);
}

body[data-theme="light"] .accent-card {
  background:
    linear-gradient(135deg, rgba(179, 61, 48, 0.1), rgba(175, 125, 42, 0.08)),
    rgba(255, 251, 244, 0.86);
}

.result-card h3 {
  font-size: 1.6rem;
  line-height: 1;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.result-card p,
.beat-list li {
  color: var(--ink-soft);
  line-height: 1.6;
}

.serif-copy {
  font-family: "Cormorant Garamond", serif;
  font-size: 1.28rem;
  color: var(--ink) !important;
  line-height: 1.34;
  max-width: none;
}

.beat-list {
  margin: 12px 0 0;
  padding-left: 18px;
  display: grid;
  gap: 10px;
}

.beat-list li + li {
  margin-top: 0;
}

.copy-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.mini-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.handoff-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.helper-copy {
  margin-top: 8px;
  font-size: 0.9rem;
}

.hermes-button {
  border-color: rgba(154, 214, 170, 0.5);
  background: linear-gradient(135deg, rgba(24, 82, 46, 0.72), rgba(88, 154, 104, 0.28));
  color: #effbf1;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 0 0 1px rgba(154, 214, 170, 0.12);
}

.hermes-button:hover {
  background: linear-gradient(135deg, rgba(29, 96, 55, 0.86), rgba(104, 177, 122, 0.34));
}

body[data-theme="light"] .hermes-button {
  border-color: rgba(111, 138, 61, 0.34);
  background: linear-gradient(135deg, rgba(216, 198, 123, 0.34), rgba(163, 193, 92, 0.26));
  color: #2c2a18;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), 0 0 0 1px rgba(186, 169, 95, 0.16);
}

body[data-theme="light"] .hermes-button:hover {
  background: linear-gradient(135deg, rgba(224, 208, 138, 0.42), rgba(171, 205, 103, 0.34));
}

.storyboard-shell {
  padding-bottom: 20px;
}

.storyboard-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.storyboard-intro {
  margin: 10px 0 0;
  max-width: 56ch;
  color: var(--ink-soft);
  font-size: 0.94rem;
}

.board-overview-grid > .result-card,
.board-direction-grid > .result-card {
  min-height: 0;
}

.prompt-box {
  margin: 14px 0 0;
  padding: 16px;
  border-radius: 18px;
  overflow: auto;
  white-space: pre-wrap;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line-strong);
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92rem;
  line-height: 1.6;
  max-height: 320px;
}

body[data-theme="light"] .prompt-box {
  background: rgba(255, 255, 255, 0.72);
}

.prompt-details {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
  overflow: hidden;
}

.prompt-details summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 16px;
  color: var(--ink);
  font-weight: 600;
}

.prompt-details summary::-webkit-details-marker {
  display: none;
}

.prompt-details[open] summary {
  border-bottom: 1px solid var(--line);
}

.prompt-details summary::after {
  content: "+";
  float: right;
  color: var(--accent);
}

.prompt-details[open] summary::after {
  content: "−";
}

.prompt-details .prompt-box {
  margin: 0;
  border: 0;
  border-radius: 0;
  max-height: 280px;
}

@media (max-width: 960px) {
  .hero,
  .field-grid,
  .stage-grid {
    grid-template-columns: 1fr;
  }

  .board-overview-grid,
  .board-direction-grid,
  .board-lower-grid {
    grid-template-columns: 1fr;
  }

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

  .title-treatment {
    flex-direction: column;
  }

  .title-treatment-text {
    white-space: normal;
    text-wrap: balance;
  }

  .palette-panel {
    flex: none;
    align-items: flex-start;
    width: 100%;
  }

  .palette {
    max-width: none;
  }

  .title-treatment-tagline {
    white-space: normal;
  }

  .idea-assist {
    flex-direction: column;
    align-items: flex-start;
  }

  .hero {
    gap: 18px;
    padding: 22px;
  }

  .hero h1 {
    max-width: none;
    font-size: clamp(2.6rem, 12vw, 4.3rem);
  }

  .input-panel {
    position: static;
  }

  .copy-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .mini-row {
    flex-direction: column;
  }
}
