:root {
  --ink: #0b0d14;
  --panel: #121624;
  --panel-2: #161c2e;
  --line: rgba(190, 205, 230, 0.14);
  --text: #e8ecf6;
  --muted: #9aa6bf;
  --gold: #d9b36a;
  --gold-soft: rgba(217, 179, 106, 0.16);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(52, 78, 130, 0.35), transparent 60%),
    radial-gradient(900px 500px at 110% 10%, rgba(120, 82, 40, 0.22), transparent 55%),
    var(--ink);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  font-weight: 300;
  display: flex;
  flex-direction: column;
}

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px clamp(18px, 5vw, 56px);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.brand { display: flex; align-items: center; gap: 14px; }

.mark {
  color: var(--gold);
  font-size: 22px;
  line-height: 1;
  text-shadow: 0 0 18px rgba(217, 179, 106, 0.5);
}

.brand h1 {
  margin: 0;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 600;
  font-size: clamp(24px, 3.2vw, 32px);
  letter-spacing: 0.02em;
}

.brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12.5px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.voice-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}

.voice-toggle input { accent-color: var(--gold); }

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.85fr);
  gap: 22px;
  padding: 22px clamp(18px, 5vw, 56px) 30px;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
}

.chat-panel, .studio {
  background: linear-gradient(180deg, rgba(22, 28, 46, 0.92), rgba(15, 19, 31, 0.92));
  border: 1px solid var(--line);
  border-radius: 16px;
}

.chat-panel {
  display: flex;
  flex-direction: column;
  min-height: 66vh;
  overflow: hidden;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.msg { display: flex; max-width: 92%; }
.msg.user { align-self: flex-end; }
.msg.assistant { align-self: flex-start; }

.bubble {
  padding: 13px 16px;
  border-radius: 14px;
  line-height: 1.58;
  font-size: 14.6px;
  white-space: pre-wrap;
}

.msg.assistant .bubble {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-top-left-radius: 4px;
}

.msg.user .bubble {
  background: var(--gold-soft);
  border: 1px solid rgba(217, 179, 106, 0.28);
  border-top-right-radius: 4px;
}

.bubble p { margin: 0 0 10px; }
.bubble p:last-child { margin-bottom: 0; }

.sources {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--muted);
}

.sources summary { cursor: pointer; letter-spacing: 0.04em; }
.sources li { margin: 6px 0; line-height: 1.45; }
.sources code { color: var(--gold); font-size: 10.5px; }

.typing { color: var(--muted); font-size: 13px; font-style: italic; }

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 22px 12px;
}

.suggestions button {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.suggestions button:hover { border-color: var(--gold); color: var(--text); }

.composer {
  display: flex;
  gap: 10px;
  padding: 14px 18px 18px;
  border-top: 1px solid var(--line);
  background: rgba(10, 13, 22, 0.5);
}

.composer textarea {
  flex: 1;
  resize: none;
  background: #0d101a;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  font-size: 14.5px;
  line-height: 1.5;
  outline: none;
}

.composer textarea:focus { border-color: rgba(217, 179, 106, 0.55); }

button { font: inherit; }

.composer button, .primary {
  border: 1px solid rgba(217, 179, 106, 0.55);
  background: linear-gradient(180deg, #d9b36a, #b98f45);
  color: #171207;
  border-radius: 12px;
  padding: 0 20px;
  font-weight: 500;
  cursor: pointer;
  transition: filter 0.2s, opacity 0.2s;
}

.composer button:hover, .primary:hover { filter: brightness(1.06); }
.composer button:disabled, .primary:disabled { opacity: 0.55; cursor: default; }

.studio { padding: 22px; align-self: start; }

.studio h2 {
  margin: 0 0 6px;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 24px;
  font-weight: 600;
}

.studio-lede { margin: 0 0 18px; color: var(--muted); font-size: 13px; line-height: 1.55; }

.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 11.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 7px; }

.field textarea {
  width: 100%;
  resize: vertical;
  background: #0d101a;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 12px;
  padding: 11px 13px;
  font: inherit;
  font-size: 14px;
  line-height: 1.5;
  outline: none;
}

.field textarea:focus { border-color: rgba(217, 179, 106, 0.55); }

.primary { width: 100%; padding: 12px 16px; }

.progress-wrap { margin-top: 18px; }
.progress-head { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }

.bar {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #8a6a2f, var(--gold));
  transition: width 0.5s ease;
}

.hint { margin: 8px 0 0; font-size: 12px; color: var(--muted); }

.storyboard-result { margin-top: 20px; }
.storyboard-result h3 {
  margin: 0 0 8px;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 21px;
  font-weight: 600;
}

.sb-meta { margin: 0 0 12px; color: var(--muted); font-size: 12.5px; line-height: 1.55; }

.download-button {
  display: block;
  text-align: center;
  background: rgba(217, 179, 106, 0.14);
  border: 1px solid rgba(217, 179, 106, 0.45);
  color: var(--gold);
  padding: 11px 14px;
  border-radius: 10px;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.2s;
}

.download-button:hover { background: rgba(217, 179, 106, 0.24); }

.preview { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.preview summary { cursor: pointer; color: var(--muted); font-size: 12.5px; }

.preview pre {
  max-height: 320px;
  overflow: auto;
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  line-height: 1.55;
  color: #c9d3e6;
  background: #0b0e17;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  margin-top: 10px;
}

.video-optional { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 14px; }
.video-optional summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.optional-note { margin: 10px 0; color: var(--muted); font-size: 12px; line-height: 1.5; }

.secondary {
  width: 100%;
  padding: 10px 16px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.2s, opacity 0.2s;
}

.secondary:hover { border-color: var(--gold); }
.secondary:disabled { opacity: 0.5; cursor: default; }

.video-result { margin-top: 18px; }
.video-result h3 { margin: 0 0 10px; font-family: 'Cormorant Garamond', Georgia, serif; font-size: 19px; font-weight: 600; }

.video-result video {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #000;
  aspect-ratio: 16 / 9;
}

.download {
  display: inline-block;
  margin-top: 10px;
  color: var(--gold);
  font-size: 13px;
  text-decoration: none;
  border-bottom: 1px solid rgba(217, 179, 106, 0.4);
}

.fineprint { margin: 18px 0 0; font-size: 11.5px; line-height: 1.55; color: var(--muted); }

.foot {
  padding: 14px clamp(18px, 5vw, 56px) 22px;
  color: var(--muted);
  font-size: 11.5px;
  letter-spacing: 0.05em;
  text-align: center;
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .chat-panel { min-height: 60vh; }
}

.header-actions { display: flex; align-items: center; gap: 14px; }

.unlock-btn {
  background: rgba(217, 179, 106, 0.14);
  border: 1px solid rgba(217, 179, 106, 0.5);
  color: var(--gold);
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  cursor: pointer;
}
.unlock-btn:hover { background: rgba(217, 179, 106, 0.24); }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 13, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}
.modal-backdrop[hidden] { display: none; }

.modal {
  background: linear-gradient(180deg, #161c2e, #0f131f);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 26px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}
.modal h2 {
  margin: 0 0 8px;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 26px;
  font-weight: 600;
}
.modal-lede { margin: 0 0 18px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.modal .field input {
  width: 100%;
  background: #0d101a;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 11px 13px;
  font: inherit;
  font-size: 14px;
}
.modal .primary { margin-top: 6px; }
.modal .secondary { margin-top: 10px; }
.modal-error {
  margin: 0 0 12px;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 12.5px;
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.modal-error[hidden] { display: none; }
