:root {
  color-scheme: dark;
  --bg: #0d0f12;
  --panel: rgba(22, 25, 31, 0.92);
  --panel-2: rgba(29, 33, 41, 0.94);
  --line: rgba(231, 223, 210, 0.11);
  --line-2: rgba(231, 223, 210, 0.2);
  --text: #f4efe7;
  --muted: #a8afb9;
  --faint: #717986;
  --amber: #c4a46f;
  --teal: #8fb8a8;
  --green: #8fb8a8;
  --rose: #c9837c;
  --lime: #b8c986;
  --shadow: 0 18px 54px rgba(0, 0, 0, 0.34);
  --radius: 8px;
  --font-ui: "Segoe UI", -apple-system, BlinkMacSystemFont, Arial, sans-serif;
  --mono: "Cascadia Mono", "JetBrains Mono", Consolas, monospace;
}

* {
  box-sizing: border-box;
  min-width: 0;
}

html,
body {
  margin: 0;
  max-width: 100vw;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(231, 223, 210, 0.045), transparent 320px),
    linear-gradient(135deg, #12151a 0%, #0d0f12 48%, #111318 100%);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(231, 223, 210, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(231, 223, 210, 0.025) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: linear-gradient(#000 0%, rgba(0, 0, 0, 0.62) 58%, transparent 100%);
}

h1,
h2,
p,
ul {
  margin: 0;
}

button,
input,
select,
textarea,
a {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1540px, calc(100% - 32px));
  margin: 0 auto;
  padding: 14px 0 28px;
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  gap: 14px;
}

.sidebar,
.workspace > section,
.topbar,
.metrics > div,
.summary-panel,
.video-panel,
.scene-card,
.gallery-card,
.idea-card button {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent),
    var(--panel);
  box-shadow: var(--shadow);
}

.sidebar {
  position: sticky;
  top: 14px;
  max-height: calc(100vh - 28px);
  overflow-y: auto;
  padding: 14px;
}

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

.brand-mark {
  width: 52px;
  height: 40px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  overflow: hidden;
  border: 1px solid rgba(196, 164, 111, 0.38);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand strong {
  display: block;
  color: var(--text);
  font-size: 18px;
  line-height: 1.1;
}

.brand small,
.one-click-copy,
.history-block span,
label span,
legend,
.topbar p,
.gallery-body span,
.empty-gallery,
.scene-card p,
.idea-card small,
.idea-card em {
  color: var(--muted);
}

.form-stack,
.settings-panel,
.item-list,
.summary-panel,
.gallery-body,
.youtube-box {
  display: grid;
  gap: 10px;
}

label {
  display: grid;
  gap: 6px;
}

label span,
legend,
.metrics span,
.hook-box span,
.scene-card small,
.idea-card span {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

textarea,
input,
select {
  width: 100%;
  min-height: 36px;
  border: 1px solid rgba(231, 223, 210, 0.16);
  border-radius: 8px;
  background: rgba(7, 9, 12, 0.46);
  color: var(--text);
  padding: 0 11px;
  outline: 0;
}

textarea {
  padding-top: 9px;
  padding-bottom: 9px;
  resize: vertical;
}

select option {
  background: #14171c;
  color: var(--text);
}

textarea:focus,
input:focus,
select:focus {
  border-color: rgba(196, 164, 111, 0.65);
  box-shadow: 0 0 0 3px rgba(196, 164, 111, 0.12);
}

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

fieldset,
.advanced-fields,
.selected-idea,
.item-list button,
.settings-tabs,
.youtube-box,
.hook-box,
.scene-card .scene-body {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.026);
}

fieldset,
.advanced-fields,
.selected-idea,
.scene-card .scene-body {
  padding: 10px;
}

.advanced-fields summary {
  cursor: pointer;
  color: var(--amber);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.advanced-fields label,
.advanced-fields .two-col {
  margin-top: 10px;
}

.radio-row {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 8px;
}

.radio-row input {
  width: auto;
  min-height: auto;
  accent-color: var(--amber);
}

.radio-row span {
  color: var(--text);
  font-size: 12px;
  letter-spacing: 0;
  text-transform: none;
}

.primary,
.secondary,
.ghost,
.mini-action,
.settings-tab,
.item-list button,
.idea-card button {
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease, opacity 0.16s ease;
}

.primary,
.secondary,
.ghost {
  min-height: 36px;
  border-radius: 8px;
  border: 0;
  font-size: 12px;
  font-weight: 900;
}

.primary {
  background: linear-gradient(180deg, #d2b780, #a98551);
  color: #19140d;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.24);
}

.make-video-btn {
  min-height: 50px;
  font-size: 15px;
}

.secondary,
.ghost,
.mini-action {
  border: 1px solid var(--line-2);
  background: rgba(255, 255, 255, 0.035);
  color: var(--text);
}

.secondary.accent,
.ghost.strong {
  border-color: rgba(196, 164, 111, 0.42);
  background: rgba(196, 164, 111, 0.11);
  color: var(--amber);
}

.primary:hover,
.secondary:hover,
.ghost:hover,
.mini-action:hover,
.settings-tab:hover,
.item-list button:hover,
.idea-card button:hover {
  transform: translateY(-1px);
}

.one-click-copy {
  font-size: 12px;
}

.selected-idea strong,
.selected-idea span,
.item-list strong,
.item-list span,
.gallery-body strong,
.gallery-body span {
  display: block;
}

.selected-idea strong {
  margin-bottom: 3px;
  color: var(--text);
}

.settings-block,
.history-block {
  margin-top: 16px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.section-head.wide {
  margin-top: 0;
}

.section-head strong,
.section-head h2 {
  color: var(--text);
  font-size: 14px;
}

.settings-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
  padding: 4px;
}

.settings-tab {
  min-height: 30px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.settings-tab.active {
  border-color: rgba(196, 164, 111, 0.38);
  background: rgba(196, 164, 111, 0.11);
  color: var(--amber);
}

.settings-panel {
  display: none;
}

.settings-panel.active {
  display: grid;
}

.item-list button {
  width: 100%;
  padding: 10px;
  color: var(--text);
  text-align: left;
}

.item-list span {
  margin-top: 3px;
  color: var(--faint);
  font-size: 11px;
}

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

.topbar {
  position: sticky;
  top: 14px;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 12px 14px;
  backdrop-filter: blur(16px);
}

.topbar p {
  margin-bottom: 3px;
  font-size: 12px;
}

h1 {
  color: var(--text);
  font-size: clamp(18px, 2vw, 24px);
  line-height: 1.1;
}

h2 {
  color: var(--text);
  font-size: 15px;
  line-height: 1.2;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.ghost {
  padding: 0 12px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.metrics > div {
  min-height: 92px;
  display: grid;
  align-content: space-between;
  padding: 13px;
}

.metrics span {
  color: var(--muted);
}

.metrics strong {
  color: var(--text);
  font-family: var(--mono);
  font-size: clamp(19px, 2.6vw, 28px);
  line-height: 1;
}

.metrics > div:nth-child(1) strong,
.metrics > div:nth-child(5) strong {
  color: var(--amber);
}

.metrics > div:nth-child(2) strong {
  color: var(--teal);
}

.metrics > div:nth-child(3) strong {
  color: var(--lime);
}

.metrics > div:nth-child(4) strong {
  color: var(--rose);
}

.preview-grid {
  display: grid;
  grid-template-columns: minmax(260px, 350px) minmax(0, 1fr);
  gap: 14px;
}

.video-panel {
  display: grid;
  gap: 10px;
  padding: 10px;
}

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

.thumbnail-slot {
  display: grid;
  aspect-ratio: 9 / 16;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(8, 10, 13, 0.62);
  color: var(--muted);
}

.thumbnail-slot img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.video-slot {
  display: grid;
  aspect-ratio: 9 / 16;
  place-items: center;
  overflow: hidden;
  border-radius: 7px;
  background: #080a0d;
  color: var(--muted);
}

.video-slot video {
  width: 100%;
  height: 100%;
}

.summary-panel {
  align-content: start;
  padding: 14px;
}

.hook-box {
  border-left: 3px solid var(--amber);
  padding: 11px;
}

.hook-box strong {
  display: block;
  margin-top: 5px;
  color: var(--text);
  font-size: 18px;
  line-height: 1.25;
}

ul {
  margin-top: 8px;
  padding-left: 18px;
}

li {
  margin: 6px 0;
}

p {
  line-height: 1.55;
}

.idea-panel,
.gallery-panel,
.workspace > section:not(.preview-grid):not(.metrics) {
  padding: 14px;
}

.idea-list,
.scene-grid,
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
}

.idea-card button {
  width: 100%;
  height: 100%;
  display: grid;
  gap: 7px;
  padding: 12px;
  color: var(--text);
  text-align: left;
}

.idea-card.selected button {
  border-color: rgba(196, 164, 111, 0.5);
  background: rgba(196, 164, 111, 0.1);
}

.idea-card span,
.scene-card small {
  color: var(--amber);
}

.idea-card strong,
.scene-card strong {
  color: var(--text);
  font-size: 15px;
  line-height: 1.25;
}

.scene-card,
.gallery-card {
  overflow: hidden;
}

.scene-card img,
.scene-card video,
.gallery-thumbnail,
.gallery-card video {
  width: 100%;
  display: block;
  object-fit: cover;
  background: #080a0d;
}

.scene-card img,
.scene-card video {
  aspect-ratio: 9 / 12;
}

.gallery-card video {
  aspect-ratio: 9 / 16;
}

.gallery-thumbnail {
  aspect-ratio: 9 / 16;
}

.scene-body,
.gallery-body {
  padding: 12px;
}

.scene-card p {
  margin-top: 7px;
  font-size: 12px;
}

.gallery-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mini-action {
  min-height: 32px;
  display: inline-grid;
  place-items: center;
  margin-top: 8px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 900;
  text-decoration: none;
}

.preview-actions .mini-action {
  width: 100%;
  margin-top: 0;
}

.mini-action.accent {
  border-color: rgba(96, 165, 250, 0.42);
  background: rgba(96, 165, 250, 0.12);
  color: #cfe4ff;
}

.youtube-box {
  padding: 12px;
}

.youtube-box textarea {
  background: rgba(7, 9, 12, 0.55);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
}

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

  .sidebar,
  .topbar {
    position: static;
    max-height: none;
  }

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

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 16px, 1540px);
    padding-top: 10px;
  }

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

  .toolbar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: stretch;
  }

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

  .two-col,
  .settings-tabs,
  .idea-list,
  .scene-grid,
  .gallery-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 420px) {
  .metrics,
  .toolbar,
  .preview-actions {
    grid-template-columns: 1fr;
  }
}
