:root {
  --wine-950: #24050f;
  --wine-900: #330815;
  --wine-800: #4b0b20;
  --burgundy: #70142f;
  --berry: #9b2147;
  --orange: #cb571a;
  --gold: #e3aa3b;
  --gold-soft: #f4c15d;
  --cream: #fff8e9;
  --paper: #fbf7ef;
  --ink: #26181d;
  --muted: #76686d;
  --line: #ded4d0;
  --green: #2f7157;
  --red: #a72d39;
  --shadow: 0 24px 70px rgba(36, 5, 15, 0.17);
  --serif: Georgia, 'Times New Roman', serif;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
}

button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: not-allowed; }

a { color: inherit; }

.login-page {
  background: var(--wine-950);
  color: var(--cream);
}

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(390px, 1.1fr) minmax(420px, 0.9fr);
}

.login-art {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(44px, 7vw, 110px);
  background:
    radial-gradient(circle at 30% 32%, rgba(209, 91, 27, 0.38), transparent 25%),
    radial-gradient(circle at 70% 70%, rgba(155, 33, 71, 0.38), transparent 30%),
    linear-gradient(145deg, #2b0612 0%, #4a0a1f 55%, #21040d 100%);
}

.login-art::before,
.login-art::after {
  content: '';
  position: absolute;
  inset: 9%;
  z-index: -1;
  border: 1px solid rgba(244, 193, 93, 0.25);
  border-radius: 50%;
  transform: rotate(-13deg);
}

.login-art::after {
  inset: 19% 8% 13% 21%;
  transform: rotate(21deg);
  border-color: rgba(255, 248, 233, 0.12);
}

.orb {
  position: absolute;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  filter: blur(8px);
  opacity: 0.35;
  z-index: -1;
}

.orb-one { right: -100px; top: -60px; background: var(--orange); }
.orb-two { left: -150px; bottom: -80px; background: var(--berry); }

.butterfly-mark {
  width: 76px;
  height: 62px;
  margin-bottom: 28px;
  filter: drop-shadow(0 9px 20px rgba(0, 0, 0, 0.25));
}

.eyebrow, .kicker {
  margin: 0 0 10px;
  color: var(--gold-soft);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.eyebrow.dark { color: var(--orange); }

.login-art h1 {
  max-width: 720px;
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(3.4rem, 7vw, 7.5rem);
  line-height: 0.86;
  letter-spacing: -0.055em;
}

.login-art h1 em {
  color: var(--gold-soft);
  font-weight: 400;
}

.login-tagline {
  max-width: 540px;
  margin: 30px 0;
  color: rgba(255, 248, 233, 0.77);
  font-size: 1.08rem;
  line-height: 1.7;
}

.private-chip, .protected-status {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  width: fit-content;
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.private-chip span, .protected-status span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #62d8a5;
  box-shadow: 0 0 0 5px rgba(98, 216, 165, 0.11);
}

.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 45px;
  background: #f8f2e8;
}

.login-card { width: min(440px, 100%); color: var(--ink); }
.login-card h2 {
  margin: 0;
  color: var(--wine-800);
  font-family: var(--serif);
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.05;
}

.muted { color: var(--muted); line-height: 1.65; }

.login-form { display: grid; gap: 10px; margin-top: 30px; }
.login-form label, .field-group label, .quality-field legend {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

input[type='text'], input[type='password'], select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fffdf8;
  color: var(--ink);
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

input[type='text'], input[type='password'], select { min-height: 48px; padding: 0 14px; }
textarea { min-height: 132px; padding: 14px; resize: vertical; line-height: 1.55; }

input:focus, select:focus, textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 4px rgba(227, 170, 59, 0.17);
}

.button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 0 18px;
  font-weight: 800;
  transition: transform 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

.button:not(:disabled):hover { transform: translateY(-1px); }
.button-primary { background: var(--burgundy); color: white; box-shadow: 0 8px 20px rgba(112, 20, 47, 0.2); }
.button-primary:hover { background: var(--wine-800); }
.button-primary:disabled { opacity: 0.48; }
.button-primary small { display: block; font-size: 0.58rem; opacity: 0.72; }
.button-secondary { border-color: var(--burgundy); background: transparent; color: var(--burgundy); }
.button-ghost { min-height: 36px; border-color: rgba(255, 255, 255, 0.25); background: transparent; color: white; }
.button-full { width: 100%; margin-top: 15px; }

.alert, .setup-notice {
  margin: 20px 0;
  border-radius: 10px;
  padding: 13px 15px;
  font-size: 0.88rem;
  line-height: 1.55;
}

.alert-error { border: 1px solid #dc9ca4; background: #fff0f1; color: #7e1421; }
.alert-success { border: 1px solid #a8d7c2; background: #effaf5; color: #1f654b; }
.setup-notice { border: 1px solid #e1bd62; background: #fff8df; color: #56350c; }
.setup-notice p { margin: 6px 0 0; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.86em; }
.security-note { margin: 24px 0 0; color: var(--muted); font-size: 0.75rem; text-align: center; }

.studio-page {
  min-width: 320px;
  background:
    radial-gradient(circle at 95% 4%, rgba(227, 170, 59, 0.1), transparent 19%),
    var(--paper);
}

.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 12px clamp(20px, 4vw, 58px);
  background: var(--wine-950);
  color: white;
}

.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand img { width: 46px; height: 38px; }
.brand span { display: grid; gap: 2px; }
.brand strong { font-family: var(--serif); font-size: 1.08rem; }
.brand small { color: var(--gold-soft); font-size: 0.66rem; letter-spacing: 0.1em; text-transform: uppercase; }
.topbar-actions { display: flex; align-items: center; gap: 22px; }
.protected-status { color: #d8f7e9; }

.stage-banner {
  padding: 9px clamp(20px, 4vw, 58px);
  background: var(--orange);
  color: white;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-align: center;
}
.stage-banner span {
  margin-right: 9px;
  border-radius: 99px;
  padding: 3px 8px;
  background: rgba(36, 5, 15, 0.28);
  font-size: 0.64rem;
  letter-spacing: 0.12em;
}

.studio-shell {
  min-height: calc(100vh - 141px);
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
}

.studio-sidebar {
  display: flex;
  flex-direction: column;
  gap: 36px;
  padding: 34px 22px;
  border-right: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.78);
}

.studio-sidebar nav { display: grid; gap: 5px; }
.nav-item {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  align-items: center;
  gap: 9px;
  min-height: 46px;
  border-radius: 9px;
  padding: 0 12px;
  color: #5f4d53;
  font-size: 0.82rem;
  font-weight: 750;
  text-decoration: none;
}
.nav-item > span { color: var(--orange); font-size: 0.64rem; letter-spacing: 0.06em; }
.nav-item small { color: #a49499; font-size: 0.58rem; text-transform: uppercase; }
.nav-item.active { background: var(--wine-800); color: white; box-shadow: 0 10px 24px rgba(75, 11, 32, 0.16); }
.nav-item.active > span { color: var(--gold-soft); }
.nav-item.disabled { opacity: 0.62; }
.nav-item.private { border: 1px solid rgba(227, 170, 59, 0.55); background: #fff8df; color: var(--wine-800); }

.budget-card {
  margin-top: auto;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 16px;
  background: white;
  box-shadow: 0 12px 35px rgba(36, 5, 15, 0.07);
}
.budget-heading { display: flex; justify-content: space-between; gap: 12px; }
.budget-heading .kicker { margin-bottom: 5px; color: var(--muted); font-size: 0.58rem; }
.budget-heading strong { font-size: 1.18rem; }
.budget-heading strong span { color: var(--muted); font-size: 0.76rem; }
.budget-heading > span { color: var(--green); font-size: 0.72rem; font-weight: 800; }
.budget-track { height: 7px; margin: 13px 0; overflow: hidden; border-radius: 99px; background: #eee7e2; }
.budget-track span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--green); transition: width 0.4s ease; }
.budget-warning .budget-track span { background: var(--gold); }
.budget-critical .budget-track span, .budget-locked .budget-track span { background: var(--red); }
.budget-card > p { margin: 0; color: var(--muted); font-size: 0.66rem; line-height: 1.5; }

.workspace { min-width: 0; padding: clamp(28px, 4vw, 62px); }
.workspace-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 26px; }
.workspace-heading h1 {
  margin: 0 0 7px;
  color: var(--wine-800);
  font-family: var(--serif);
  font-size: clamp(2rem, 4vw, 3.65rem);
  letter-spacing: -0.035em;
}
.workspace-heading p:not(.eyebrow) { margin: 0; color: var(--muted); }
.user-chip {
  flex: 0 0 auto;
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 2px solid var(--gold);
  border-radius: 50%;
  background: var(--burgundy);
  color: white;
  font-family: var(--serif);
  font-weight: 800;
}

.creator-grid { display: grid; grid-template-columns: minmax(360px, 1fr) minmax(330px, 0.72fr); gap: clamp(24px, 4vw, 54px); align-items: start; }
.creator-form {
  display: grid;
  gap: 23px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: clamp(22px, 3vw, 34px);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
}
.field-group { display: grid; gap: 9px; }
.field-label-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.counter { color: var(--muted); font-size: 0.73rem; }
.counter strong { color: var(--burgundy); }
.field-help { margin: 0; color: var(--muted); font-size: 0.7rem; line-height: 1.5; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.quality-field { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 0; border: 0; padding: 0; }
.quality-field legend { grid-column: 1 / -1; margin-bottom: 8px; }
.quality-option {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 66px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px;
  background: #fffdf8;
  text-transform: none;
}
.quality-option:has(input:checked) { border-color: var(--gold); background: #fff9e6; box-shadow: 0 0 0 3px rgba(227, 170, 59, 0.12); }
.quality-option input { accent-color: var(--burgundy); }
.quality-option span { display: grid; gap: 4px; }
.quality-option strong { font-size: 0.76rem; }
.quality-option small { color: var(--muted); font-size: 0.61rem; font-weight: 500; }
.quality-option em { position: absolute; top: -9px; right: 7px; border-radius: 99px; padding: 3px 7px; background: var(--orange); color: white; font-size: 0.48rem; font-style: normal; }
.form-actions { display: grid; grid-template-columns: 1fr 1.2fr; gap: 12px; }

.poster-preview { min-width: 0; }
.preview-toolbar { display: flex; justify-content: space-between; margin-bottom: 10px; color: var(--muted); font-size: 0.67rem; font-weight: 750; text-transform: uppercase; letter-spacing: 0.07em; }
.poster-canvas {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  aspect-ratio: 1;
  border: 8px solid var(--wine-950);
  border-radius: 4px;
  background:
    radial-gradient(circle at 50% 42%, rgba(227, 170, 59, 0.43), transparent 31%),
    linear-gradient(145deg, #26050f 0%, #761530 53%, #bc4d19 100%);
  box-shadow: 0 28px 70px rgba(36, 5, 15, 0.25);
}
.poster-canvas::before {
  content: '';
  position: absolute;
  inset: 4%;
  border: 1px solid rgba(244, 193, 93, 0.55);
  z-index: -1;
}
.wing {
  position: absolute;
  top: 12%;
  width: 48%;
  height: 56%;
  border: 2px solid rgba(244, 193, 93, 0.3);
  border-radius: 72% 28% 65% 35%;
  transform: rotate(21deg);
}
.wing::after { content: ''; position: absolute; inset: 13%; border: 1px solid rgba(244, 193, 93, 0.2); border-radius: inherit; }
.wing-left { left: 5%; }
.wing-right { right: 5%; transform: scaleX(-1) rotate(21deg); }
.portrait-placeholder { position: absolute; top: 12%; left: 50%; width: 50%; height: 54%; transform: translateX(-50%); }
.portrait-hair { position: absolute; inset: 0 4% 22%; border-radius: 49% 52% 43% 46%; background: radial-gradient(circle, #4c1021 0 16%, #17050b 18% 54%, #5f1430 56% 64%, #1d0710 66%); box-shadow: 0 9px 25px rgba(0,0,0,.3); }
.portrait-face { position: absolute; z-index: 2; top: 20%; left: 29%; width: 42%; height: 43%; border-radius: 46% 46% 49% 49%; background: linear-gradient(135deg, #d77735, #8f3d20); }
.portrait-glasses { position: absolute; z-index: 3; top: 34%; left: 23%; width: 54%; height: 12%; border: 5px solid #4b0b20; border-radius: 20px; box-shadow: inset 0 0 0 2px var(--gold); }
.portrait-glasses::after { content: ''; position: absolute; top: 38%; left: 46%; width: 10%; border-top: 4px solid #4b0b20; }
.portrait-jacket { position: absolute; z-index: 1; left: 16%; bottom: 0; width: 68%; height: 36%; background: linear-gradient(120deg, #430a20, #8e1f42 50%, #320816); clip-path: polygon(17% 0, 83% 0, 100% 100%, 0 100%); }
.poster-copy {
  position: absolute;
  z-index: 5;
  left: 8%;
  right: 8%;
  bottom: 10%;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 25%;
  border-top: 1px solid rgba(244, 193, 93, 0.8);
  border-bottom: 1px solid rgba(244, 193, 93, 0.5);
  padding: 6% 4%;
  color: #fff4d6;
  font-family: Impact, Haettenschweiler, 'Arial Narrow Bold', sans-serif;
  font-size: clamp(1.45rem, 3.4vw, 4rem);
  line-height: 0.93;
  letter-spacing: 0.01em;
  text-align: center;
  text-transform: uppercase;
  white-space: pre-line;
  text-shadow: 2px 3px 0 var(--wine-950);
}
.poster-copy.is-placeholder { opacity: 0.68; }
.poster-footer { position: absolute; z-index: 6; right: 8%; bottom: 3.3%; left: 8%; display: flex; align-items: center; justify-content: space-between; color: var(--gold-soft); font-size: 0.56rem; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; }
.poster-footer img { width: 27px; height: 22px; }
.preview-note { margin: 13px 0 0; color: var(--muted); font-size: 0.69rem; line-height: 1.55; }

.app-footer { display: flex; justify-content: space-between; gap: 20px; border-top: 1px solid var(--line); padding: 18px clamp(20px, 4vw, 58px); color: var(--muted); font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.07em; }

@media (max-width: 1050px) {
  .studio-shell { grid-template-columns: 210px minmax(0, 1fr); }
  .creator-grid { grid-template-columns: 1fr; }
  .poster-preview { max-width: 600px; }
}

@media (max-width: 760px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-art { min-height: 48vh; padding: 48px 30px; }
  .login-art h1 { font-size: clamp(3rem, 15vw, 5rem); }
  .login-panel { padding: 45px 24px; }
  .topbar { align-items: flex-start; }
  .protected-status { display: none; }
  .studio-shell { display: block; }
  .studio-sidebar { border-right: 0; border-bottom: 1px solid var(--line); padding: 18px 20px; }
  .studio-sidebar nav { grid-template-columns: repeat(2, 1fr); }
  .nav-item { min-height: 40px; }
  .budget-card { margin-top: 8px; }
  .workspace { padding: 30px 20px; }
  .form-grid, .quality-field, .form-actions { grid-template-columns: 1fr; }
  .quality-field legend { grid-column: auto; }
  .app-footer { flex-direction: column; }
}

@media (max-width: 480px) {
  .brand strong { font-size: 0.88rem; }
  .brand small { font-size: 0.54rem; }
  .topbar { padding: 12px 14px; }
  .stage-banner { padding-inline: 16px; text-align: left; line-height: 1.45; }
  .studio-sidebar nav { grid-template-columns: 1fr; }
  .workspace-heading { align-items: center; }
  .creator-form { padding: 19px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
