:root {
  color-scheme: dark;
  --bg: #050505;
  --bg-soft: #0b0b0b;
  --panel: rgba(17, 17, 17, 0.84);
  --panel-solid: #111111;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #f4f2ee;
  --muted: #9b9993;
  --muted-2: #6e6c66;
  --orange: #ff6838;
  --orange-2: #ff9d45;
  --amber: #f1c85b;
  --green: #67d391;
  --blue: #7bb7ff;
  --danger: #ff6b6b;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 58% 112%, rgba(255, 104, 56, 0.5), transparent 28rem),
    radial-gradient(circle at 88% 18%, rgba(255, 157, 69, 0.16), transparent 18rem),
    linear-gradient(180deg, #090909 0%, #030303 100%);
}

body::before {
  position: fixed;
  inset: 0;
  pointer-events: none;
  content: "";
  opacity: 0.34;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.026) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: linear-gradient(to bottom, #000, transparent 74%);
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.68;
}

body.locked {
  overflow: hidden;
}

body.locked .page-shell {
  display: none;
}

.login-screen {
  position: relative;
  z-index: 2;
  display: grid;
  min-height: 100vh;
  padding: 28px;
  place-items: center;
}

body:not(.locked) .login-screen {
  display: none;
}

.login-card {
  display: grid;
  width: min(1120px, 100%);
  min-height: 680px;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.75fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(7, 7, 7, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.login-copy {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 26px;
  padding: 42px;
  background:
    radial-gradient(circle at 72% 28%, rgba(255, 157, 69, 0.28), transparent 18rem),
    linear-gradient(140deg, rgba(255, 104, 56, 0.12), rgba(255, 255, 255, 0.02));
}

.login-brand {
  margin-bottom: 12px;
}

.login-copy h1 {
  max-width: 720px;
  margin: 18px 0 12px;
  font-size: clamp(42px, 6vw, 72px);
  line-height: 0.94;
  letter-spacing: 0;
}

.login-copy p {
  max-width: 620px;
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.7;
}

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

.price-card {
  display: grid;
  gap: 6px;
  min-height: 132px;
  padding: 16px;
  text-align: left;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.price-card.selected {
  border-color: rgba(255, 157, 69, 0.72);
  background: rgba(255, 104, 56, 0.12);
  box-shadow: 0 0 0 3px rgba(255, 104, 56, 0.09);
}

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

.price-card strong {
  color: var(--text);
  font-size: 26px;
}

.payment-link {
  display: inline-flex;
  width: fit-content;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  color: #190802;
  font-weight: 800;
  text-decoration: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--orange), var(--orange-2));
}

.login-form {
  display: grid;
  align-content: center;
  gap: 18px;
  padding: 42px;
  border-left: 1px solid var(--line);
  background: rgba(12, 12, 12, 0.9);
}

.login-form h2 {
  margin: 0 0 10px;
  font-size: 30px;
}

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

.page-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: calc(100vh - 32px);
  margin: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgba(5, 5, 5, 0.82);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(18, 18, 18, 0.92), rgba(8, 8, 8, 0.82));
}

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

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 10px;
  color: #120905;
  font-weight: 800;
  background: linear-gradient(135deg, var(--orange), var(--orange-2));
}

.brand strong,
.brand span {
  display: block;
}

.brand span,
.sidebar-card p,
.metric-card small,
.output-box span,
label {
  color: var(--muted);
}

.brand strong {
  font-size: 15px;
}

.brand span {
  margin-top: 3px;
  font-size: 12px;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-list a {
  padding: 11px 12px;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: 8px;
  transition: 160ms ease;
}

.nav-list a:hover,
.nav-list a.active {
  color: var(--text);
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.06);
}

.sidebar-card,
.panel,
.metric-card,
.output-box {
  border: 1px solid var(--line);
  background: var(--panel);
}

.sidebar-card {
  margin-top: auto;
  padding: 16px;
  border-radius: 8px;
}

.sidebar-card strong {
  display: block;
  margin-top: 8px;
  line-height: 1.3;
}

.sidebar-card p {
  margin: 10px 0 0;
  font-size: 13px;
  line-height: 1.5;
}

.workspace {
  min-width: 0;
  padding: 28px;
  overflow: auto;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.topbar h1 {
  max-width: 820px;
  margin: 12px 0 0;
  font-size: clamp(30px, 4vw, 62px);
  line-height: 0.98;
  letter-spacing: 0;
}

.topbar-actions,
.button-strip,
.production-actions,
.project-row {
  display: flex;
  gap: 12px;
}

.topbar-actions {
  flex-shrink: 0;
  padding-top: 6px;
}

.status-pill,
.eyebrow,
.step-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  color: var(--orange-2);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.status-pill {
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid rgba(255, 104, 56, 0.34);
  border-radius: 999px;
  background: rgba(255, 104, 56, 0.1);
}

.status-pill::after {
  width: 7px;
  height: 7px;
  content: "";
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 16px rgba(103, 211, 145, 0.8);
}

.primary-button,
.ghost-button,
.download-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  color: var(--text);
  text-decoration: none;
  border-radius: 999px;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}

.primary-button {
  color: #190802;
  font-weight: 800;
  border: 0;
  background: linear-gradient(135deg, var(--orange), var(--orange-2));
}

.ghost-button {
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.04);
}

.download-button {
  color: #05130a;
  font-weight: 800;
  border: 0;
  background: var(--green);
}

.download-button.disabled {
  pointer-events: none;
  color: var(--muted);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.045);
}

.primary-button:hover,
.ghost-button:hover,
.download-button:hover {
  transform: translateY(-1px);
}

.ghost-button:hover {
  border-color: rgba(255, 255, 255, 0.28);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric-card {
  min-height: 118px;
  padding: 18px;
  border-radius: 8px;
}

.metric-card span,
.metric-card small {
  display: block;
  font-size: 13px;
}

.metric-card strong {
  display: block;
  margin: 12px 0 7px;
  font-size: 30px;
  line-height: 1;
}

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

.main-column,
.right-column {
  display: grid;
  gap: 18px;
  align-content: start;
}

.panel {
  padding: 20px;
  border-radius: 8px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.panel h2 {
  margin: 6px 0 0;
  font-size: 18px;
  letter-spacing: 0;
}

.step-badge {
  justify-content: center;
  min-width: 34px;
  height: 28px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
}

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

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

.character-field {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: minmax(220px, 0.75fr) minmax(280px, 1.25fr);
  gap: 14px;
  align-items: end;
}

label {
  display: grid;
  gap: 8px;
  min-width: 0;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

input,
select,
textarea {
  width: 100%;
  min-height: 43px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  background: rgba(0, 0, 0, 0.28);
}

input,
select {
  padding: 0 12px;
}

input[type="file"] {
  padding: 10px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(255, 104, 56, 0.72);
  box-shadow: 0 0 0 4px rgba(255, 104, 56, 0.1);
}

.character-preview {
  display: flex;
  min-height: 74px;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 12px;
  border: 1px dashed rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.character-preview img {
  flex: 0 0 auto;
  width: 54px;
  height: 54px;
  object-fit: contain;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.32);
}

.character-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.character-copy strong {
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.character-copy p {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.stickman {
  position: relative;
  flex: 0 0 auto;
  width: 58px;
  height: 58px;
  border-radius: 8px;
  background: linear-gradient(145deg, #191919, #0c0c0c);
}

.stickman::before {
  position: absolute;
  top: 10px;
  left: 22px;
  width: 14px;
  height: 14px;
  content: "";
  border: 2px solid var(--text);
  border-radius: 999px;
}

.stickman::after {
  position: absolute;
  top: 27px;
  left: 28px;
  width: 2px;
  height: 18px;
  content: "";
  background: var(--text);
}

.stickman span::before,
.stickman span::after {
  position: absolute;
  left: 18px;
  width: 24px;
  height: 2px;
  content: "";
  background: var(--text);
}

.stickman span::before {
  top: 32px;
  transform: rotate(-18deg);
}

.stickman span::after {
  top: 45px;
  transform: rotate(28deg);
}

.project-row {
  display: flex;
  gap: 14px;
  align-items: end;
  justify-content: space-between;
}

.project-hint {
  max-width: 560px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.output-grid {
  display: grid;
  grid-template-columns: minmax(220px, 0.6fr) minmax(0, 1.4fr);
  gap: 14px;
  margin-top: 14px;
}

.output-box {
  min-height: 160px;
  padding: 16px;
  border-radius: 8px;
}

.output-box span {
  display: block;
  margin-bottom: 10px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.output-box p,
.output-box pre {
  margin: 0;
  color: #d9d6cd;
  line-height: 1.55;
}

.output-box pre {
  max-height: 300px;
  overflow: auto;
  white-space: pre-wrap;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
}

.production-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1.2fr;
  margin-bottom: 14px;
}

.thinker-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.button-strip {
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.thumbnail-grid {
  display: grid;
  grid-template-columns: minmax(260px, 520px);
  gap: 12px;
}

.thumb-card {
  position: relative;
  display: grid;
  min-height: 142px;
  align-content: end;
  padding: 12px;
  overflow: hidden;
  color: #151008;
  border: 1px solid transparent;
  border-radius: 8px;
  background: linear-gradient(135deg, #ffe15b 0%, #ff793f 62%, #1a1a1a 100%);
}

.thumb-card::before {
  position: absolute;
  top: 18px;
  right: 16px;
  width: 42px;
  height: 42px;
  content: "";
  border: 3px solid #151008;
  border-radius: 999px;
}

.thumb-card::after {
  position: absolute;
  top: 60px;
  right: 36px;
  width: 3px;
  height: 48px;
  content: "";
  background: #151008;
}

.thumb-card strong {
  position: relative;
  z-index: 1;
  max-width: 82%;
  font-size: 17px;
  line-height: 1.05;
}

.thumb-visual {
  position: absolute;
  inset: 0;
  background-position: center;
  background-size: cover;
}

.thumb-card button {
  position: relative;
  z-index: 1;
  width: fit-content;
  margin-top: 10px;
  padding: 7px 10px;
  color: var(--text);
  border: 0;
  border-radius: 999px;
  background: #111111;
}

.thumb-card.selected {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(103, 211, 145, 0.16);
}

.thumb-card.featured {
  min-height: 292px;
  aspect-ratio: 16 / 9;
}

.thumb-card.featured strong {
  max-width: 72%;
  font-size: 28px;
}

.compact {
  padding: 18px;
}

.checklist {
  display: grid;
  gap: 10px;
  padding: 0;
  margin: 0;
  list-style: none;
  counter-reset: steps;
}

.checklist li {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  color: var(--muted);
  font-size: 14px;
}

.checklist li::before {
  display: grid;
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  place-items: center;
  color: var(--muted-2);
  content: counter(steps);
  counter-increment: steps;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
}

.checklist li.done {
  color: var(--text);
}

.checklist li.done::before {
  color: #061108;
  content: "OK";
  border-color: transparent;
  background: var(--green);
}

.full {
  width: 100%;
  margin-top: 12px;
}

.upload-summary {
  margin-top: 14px;
  padding: 13px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 13px;
  line-height: 1.5;
}

.license-progress-label {
  display: block;
  margin: 10px 0 8px;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
}

.license-progress-bar {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.license-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--orange-2);
  transition: width 0.3s ease;
}

@media (max-width: 1180px) {
  .page-shell {
    grid-template-columns: 220px minmax(0, 1fr);
  }

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

  .right-column {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .page-shell {
    grid-template-columns: 1fr;
    margin: 0;
    border-radius: 0;
  }

  .sidebar {
    position: static;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav-list {
    grid-template-columns: repeat(5, max-content);
    overflow-x: auto;
  }

  .sidebar-card {
    display: none;
  }

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

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

  .topbar {
    display: grid;
  }
}

@media (max-width: 680px) {
  .workspace {
    padding: 18px;
  }

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

  .topbar-actions,
  .project-row,
  .button-strip {
    display: grid;
    grid-template-columns: 1fr;
  }

  .metrics,
  .form-grid,
  .output-grid,
  .production-actions,
  .thinker-grid,
  .thumbnail-grid,
  .right-column {
    grid-template-columns: 1fr;
  }

  .character-field {
    grid-template-columns: 1fr;
  }

  .character-preview {
    align-items: flex-start;
  }

  .character-copy strong {
    white-space: normal;
  }

  .primary-button,
  .ghost-button {
    width: 100%;
  }
}

/* One-click full pipeline */
.full-pipeline-row {
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.full-pipeline-button {
  width: 100%;
  min-height: 50px;
  font-size: 15px;
}

.full-pipeline-row .validate-hint {
  margin-top: 8px;
  text-align: center;
}

/* API key validation + production progress */
.validate-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 8px;
}

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

.validate-results {
  display: grid;
  gap: 8px;
  margin: 14px 0 4px;
}

.validate-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-soft);
  font-size: 14px;
  color: var(--text);
}

.validate-item .validate-flag {
  min-width: 26px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 700;
  color: #050505;
}

.validate-item.ok {
  border-color: rgba(103, 211, 145, 0.4);
}
.validate-item.ok .validate-flag {
  background: var(--green);
}

.validate-item.warn {
  border-color: rgba(241, 200, 91, 0.4);
}
.validate-item.warn .validate-flag {
  background: var(--amber);
}

.validate-item.fail {
  border-color: rgba(255, 107, 107, 0.45);
}
.validate-item.fail .validate-flag {
  background: var(--danger);
}

.production-status {
  margin: 14px 0 4px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 14px;
}

.field-hint {
  margin: 6px 0 0;
  color: var(--muted-2);
  font-size: 12px;
  font-weight: 400;
}

@media (max-width: 900px) {
  .login-card {
    min-height: auto;
    grid-template-columns: 1fr;
  }

  .login-form {
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}

@media (max-width: 680px) {
  .login-screen {
    padding: 14px;
  }

  .login-copy,
  .login-form {
    padding: 24px;
  }

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

  .login-copy h1 {
    font-size: 40px;
  }
}
