:root {
  color-scheme: light;
  --bg: #f4f5f2;
  --ink: #171817;
  --muted: #696b66;
  --line: #d8d9d2;
  --panel: #ffffff;
  --panel-soft: #eef1eb;
  --accent: #0f6b5f;
  --accent-dark: #084940;
  --gold: #9f742d;
  --danger: #a52d2d;
  --shadow: 0 18px 50px rgb(25 24 20 / 12%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

.app-shell {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 22px 22px 110px;
}

.topbar,
.studio-grid,
.result-band {
  width: 100%;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 0 24px;
}

.topbar h1,
.panel-head h2 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: 34px;
  line-height: 1;
}

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

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.studio-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.86fr) minmax(390px, 1.3fr) minmax(330px, 0.94fr);
  gap: 16px;
  align-items: start;
}

.panel,
.result-main,
.history-panel,
.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

.panel-head {
  margin-bottom: 16px;
}

.panel-head h2 {
  font-size: 20px;
  line-height: 1.15;
}

.drop-zone {
  display: grid;
  min-height: 330px;
  place-items: center;
  align-content: center;
  gap: 10px;
  padding: 18px;
  border: 1px dashed #b6b2a3;
  border-radius: 8px;
  background: #fbfbf8;
  text-align: center;
  transition: border-color 180ms ease, background 180ms ease, transform 180ms ease;
}

.drop-zone input {
  display: none;
}

.drop-zone.is-dragover {
  border-color: var(--accent);
  background: #eef8f4;
  transform: translateY(-1px);
}

.reference-preview {
  display: grid;
  width: min(230px, 100%);
  aspect-ratio: 4 / 5;
  place-items: center;
  overflow: hidden;
  border-radius: 8px;
  background: linear-gradient(135deg, #dfe7df, #f8f8f4);
  color: var(--muted);
  font-weight: 800;
}

.reference-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-top: 13px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}

.prompt-panel textarea,
.settings-panel textarea,
.text-input,
.settings-details input,
.settings-details select,
.field input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

#finalPromptInput[readonly] {
  background: #f5f6f2;
  color: #3b3d39;
}

.prompt-panel textarea,
.settings-panel textarea {
  resize: vertical;
  padding: 14px;
  line-height: 1.45;
}

.text-input,
.settings-details input,
.settings-details select,
.field input {
  min-height: 42px;
  padding: 0 12px;
}

.prompt-panel textarea:focus,
.settings-panel textarea:focus,
.text-input:focus,
.settings-details input:focus,
.settings-details select:focus,
.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(15 107 95 / 14%);
}

.compact-controls {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin: 14px 0;
}

.control-label,
.settings-details label span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.segmented {
  display: flex;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f6f4ec;
}

.segmented.wrap {
  flex-wrap: wrap;
}

.segmented button,
.ghost-btn,
.secondary-btn,
.primary-btn,
.style-card {
  border: 0;
  border-radius: 8px;
}

.segmented button {
  min-height: 34px;
  padding: 0 11px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.segmented button.is-active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 4px 14px rgb(30 28 22 / 9%);
}

.ghost-btn,
.secondary-btn {
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
}

.secondary-btn {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.primary-btn {
  min-height: 48px;
  padding: 0 20px;
  background: var(--accent);
  color: #fff;
  font-weight: 900;
  box-shadow: 0 14px 28px rgb(15 107 95 / 28%);
}

.primary-btn:disabled,
.secondary-btn:disabled {
  cursor: not-allowed;
  opacity: 0.54;
  box-shadow: none;
}

.director-details,
.settings-details {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #faf9f4;
}

.director-details summary,
.settings-details summary {
  padding: 13px 14px;
  font-weight: 900;
  cursor: pointer;
}

.director-details textarea,
.settings-details label {
  display: block;
  margin: 0 14px 14px;
}

.setting-block {
  margin-bottom: 18px;
}

.style-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.style-card {
  padding: 12px;
  min-height: 112px;
  border: 1px solid var(--line);
  background: #fbfbf8;
  text-align: left;
}

.style-card strong,
.style-card span {
  display: block;
}

.style-card strong {
  margin-bottom: 7px;
  font-size: 15px;
}

.style-card span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.style-card.is-active {
  border-color: var(--accent);
  background: #edf7f3;
}

.settings-details {
  margin-top: 10px;
}

.result-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.38fr);
  gap: 16px;
  margin-top: 16px;
}

.result-main,
.history-panel {
  padding: 18px;
}

.result-box {
  display: grid;
  min-height: 290px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111;
  color: #fff;
  text-align: center;
  overflow: hidden;
}

.result-box video {
  width: 100%;
  max-height: 520px;
  background: #000;
}

.mock-ready {
  display: grid;
  gap: 12px;
  padding: 24px;
}

.history-list {
  display: grid;
  gap: 9px;
}

.history-item {
  display: grid;
  gap: 5px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfbf8;
}

.history-item strong {
  font-size: 14px;
}

.history-item span {
  color: var(--muted);
  font-size: 12px;
}

.history-item[data-status="failed"] {
  border-color: rgb(165 45 45 / 35%);
}

.sticky-generate {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  width: min(760px, calc(100% - 32px));
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgb(255 255 255 / 92%);
  box-shadow: 0 14px 48px rgb(25 24 20 / 18%);
  transform: translateX(-50%);
  backdrop-filter: blur(16px);
}

.sticky-generate span,
.sticky-generate small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.sticky-generate strong {
  display: block;
  font-size: 24px;
  line-height: 1.1;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 96px;
  z-index: 30;
  max-width: min(420px, calc(100% - 36px));
  padding: 13px 15px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow);
}

.login-body {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 18px;
}

.login-shell {
  width: min(520px, 100%);
}

.login-card {
  padding: 26px;
}

.login-head h1 {
  margin: 0;
  font-size: 32px;
}

.login-copy,
.error-text {
  color: var(--muted);
}

.login-form,
.field {
  display: grid;
  gap: 12px;
}

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

.error-text {
  color: var(--danger);
}

@media (max-width: 1080px) {
  .studio-grid,
  .result-band {
    grid-template-columns: 1fr;
  }

  .history-panel {
    display: none;
  }

  .history-panel.is-open {
    display: block;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 14px 12px 120px;
  }

  .topbar {
    align-items: flex-start;
    gap: 12px;
    padding-bottom: 14px;
  }

  .topbar h1 {
    font-size: 28px;
  }

  .topbar-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .ghost-btn {
    min-height: 38px;
    text-align: center;
  }

  .panel,
  .result-main,
  .history-panel {
    padding: 14px;
  }

  .drop-zone {
    min-height: 260px;
  }

  .compact-controls {
    align-items: stretch;
    flex-direction: column;
  }

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

  .sticky-generate {
    bottom: 10px;
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .sticky-generate strong {
    font-size: 21px;
  }

  .sticky-generate .primary-btn {
    width: 100%;
  }
}
