:root {
  color-scheme: light;
  --bg: #f6fbff;
  --panel: rgba(255, 255, 255, 0.94);
  --panel-strong: #ffffff;
  --line: rgba(20, 27, 45, 0.12);
  --text: #172033;
  --muted: #657089;
  --pink: #ff4fa3;
  --cyan: #1eb7ff;
  --yellow: #ffd166;
  --violet: #7c3aed;
  --radius: 8px;
  --shadow: 0 20px 60px rgba(13, 18, 33, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 12% 2%, rgba(255, 209, 102, 0.34), transparent 26%),
    radial-gradient(circle at 86% 8%, rgba(30, 183, 255, 0.22), transparent 30%),
    linear-gradient(180deg, #f6fbff 0%, #eef4ff 52%, #f8fbff 100%);
  color: var(--text);
}

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

button,
select {
  cursor: pointer;
}

.shell {
  width: min(1420px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 14px 0 28px;
}

.hero {
  min-height: 245px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 18px;
  align-items: stretch;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0.88), rgba(226, 244, 255, 0.72)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='900' height='420' viewBox='0 0 900 420'%3E%3Cg fill='none' stroke='rgba(20,27,45,.14)' stroke-width='2'%3E%3Cpath d='M40 310 C130 190 250 340 350 180 S580 240 680 100 830 170 880 70'/%3E%3Cpath d='M70 80h120v90H70zM670 210h150v95H670zM390 250h170v100H390z'/%3E%3Ccircle cx='235' cy='115' r='48'/%3E%3Ccircle cx='610' cy='130' r='35'/%3E%3C/g%3E%3C/svg%3E");
  background-size: cover;
  box-shadow: var(--shadow);
}

.hero-copy {
  align-self: end;
  max-width: 780px;
}

.eyebrow {
  margin: 0 0 6px;
  color: #0d8ee0;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  font-size: clamp(36px, 7vw, 74px);
  line-height: 0.98;
}

h2 {
  margin-bottom: 0;
  font-size: 24px;
}

.hero p:not(.eyebrow) {
  max-width: 680px;
  margin-bottom: 0;
  color: #3b465c;
  font-size: 18px;
  line-height: 1.45;
}

.balance-card,
.creator-card,
.prompt-card,
.queue,
.tabs,
.how-it-works article {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.balance-card {
  display: grid;
  align-content: center;
  justify-items: start;
  padding: 18px;
}

.balance-card span,
.balance-card small {
  color: var(--muted);
}

.balance-card strong {
  display: block;
  margin: 4px 0;
  font-size: 48px;
  color: #e28a00;
}

.provider-pill {
  margin-top: 12px;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(30, 183, 255, 0.12);
  color: #116b9e;
  font-size: 12px;
  font-weight: 900;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 14px 0;
  padding: 8px;
}

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

.tab.active {
  border-color: rgba(30, 183, 255, 0.3);
  background: rgba(30, 183, 255, 0.12);
  color: var(--text);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.how-it-works {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}

.how-it-works article {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 10px;
  min-height: 84px;
  align-items: center;
  padding: 14px;
}

.how-it-works b {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--cyan), var(--violet));
  color: white;
}

.how-it-works span {
  display: block;
  font-weight: 950;
}

.how-it-works small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.creator-grid,
.admin-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(420px, 1.1fr);
  gap: 14px;
}

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

.provider-settings-card {
  grid-column: 1 / -1;
}

.provider-box {
  min-width: 0;
  margin: 0 0 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(145deg, #f8fbff, #f2f7ff);
}

.provider-box.venice-box {
  background: linear-gradient(145deg, #fff8fb, #f7f1ff);
}

.provider-box legend {
  padding: 0 8px;
  color: var(--text);
  font-size: 17px;
  font-weight: 950;
}

.provider-connection {
  display: inline-flex;
  margin: 0 0 14px;
  padding: 7px 10px;
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  box-shadow: 0 4px 16px rgba(35, 58, 92, 0.08);
}

.provider-connection.connected {
  background: #e9fff5;
  color: #087a54;
}

.provider-test {
  width: 100%;
  min-height: 44px;
}

.settings-result {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--muted);
  font-weight: 850;
}

.creator-card,
.prompt-card,
.queue {
  padding: 18px;
}

.section-title {
  margin-bottom: 16px;
}

label {
  display: grid;
  gap: 8px;
  margin-bottom: 13px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 850;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fbff;
  color: var(--text);
  outline: none;
}

input,
select {
  min-height: 54px;
  padding: 0 14px;
}

textarea {
  resize: vertical;
  min-height: 154px;
  padding: 14px;
  line-height: 1.45;
  font-size: 16px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(30, 183, 255, 0.14);
}

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

.example-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -2px 0 14px;
}

.example-row button {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid rgba(30, 183, 255, 0.24);
  border-radius: 999px;
  background: rgba(30, 183, 255, 0.09);
  color: #116b9e;
  font-weight: 850;
}

.advanced {
  margin: 0 0 14px;
  padding: 12px;
  border: 1px dashed rgba(20, 27, 45, 0.18);
  border-radius: var(--radius);
  color: var(--muted);
}

.advanced summary {
  cursor: pointer;
  font-weight: 900;
  color: #3b465c;
}

.advanced p {
  margin: 10px 0 0;
  line-height: 1.45;
}

.cost-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  margin: 4px 0 14px;
  padding: 12px;
  border: 1px solid rgba(255, 209, 102, 0.36);
  border-radius: var(--radius);
  background: rgba(255, 209, 102, 0.18);
}

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

.cost-line strong {
  color: #d17a00;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.primary,
.accent,
.small-button {
  min-height: 50px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: white;
  font-weight: 900;
}

.primary {
  padding: 0 16px;
  background: linear-gradient(135deg, var(--cyan), var(--violet));
}

.accent {
  padding: 0 18px;
  background: linear-gradient(135deg, var(--pink), #ff8a3d);
}

.big-action {
  min-width: 180px;
  font-size: 18px;
}

.small-button {
  min-height: 36px;
  padding: 0 12px;
  background: rgba(30, 183, 255, 0.16);
  border-color: rgba(30, 183, 255, 0.28);
  color: #116b9e;
}

pre {
  min-height: 290px;
  margin: 0 0 14px;
  white-space: pre-wrap;
  line-height: 1.5;
  color: #22304a;
}

.negative {
  padding: 13px;
  border: 1px solid rgba(255, 79, 163, 0.26);
  border-radius: var(--radius);
  background: rgba(255, 79, 163, 0.08);
}

.negative span {
  display: block;
  margin-bottom: 6px;
  color: var(--pink);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.negative p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.45;
}

.queue {
  margin-top: 14px;
}

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

.item-card {
  min-height: 150px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-strong);
}

.item-card strong {
  display: block;
  margin-bottom: 7px;
}

.result-image {
  width: 100%;
  aspect-ratio: 1;
  display: block;
  object-fit: cover;
  margin-bottom: 10px;
  border-radius: var(--radius);
  background: #eef4ff;
}

.item-card p,
.item-card li,
.meta {
  color: var(--muted);
  line-height: 1.45;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  font-size: 12px;
}

.pill {
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(30, 183, 255, 0.1);
  color: #116b9e;
}

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

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

.price-row,
.payment-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fbff;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(90px);
  padding: 11px 16px;
  border-radius: 999px;
  background: #172033;
  color: #f8fbff;
  font-weight: 900;
  box-shadow: var(--shadow);
  transition: transform 180ms ease;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 980px) {
  .hero,
  .creator-grid,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .how-it-works {
    grid-template-columns: 1fr;
  }

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

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

@media (max-width: 640px) {
  body {
    background: #f6fbff;
  }

  .shell {
    width: min(100vw - 20px, 520px);
    padding-bottom: 92px;
  }

  .hero {
    min-height: 250px;
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .tabs {
    position: fixed;
    z-index: 20;
    left: 10px;
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    grid-template-columns: repeat(4, 1fr);
    margin: 0;
    padding: 6px;
    background: rgba(255, 255, 255, 0.96);
  }

  .form-grid,
  .cards,
  .character-list {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 42px;
  }

  .hero p:not(.eyebrow) {
    font-size: 16px;
  }

  .balance-card strong {
    font-size: 38px;
  }

  .tab {
    min-height: 50px;
    font-size: 12px;
  }

  .how-it-works article {
    min-height: 70px;
  }

  .button-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .primary,
  .accent {
    width: 100%;
  }
}
