:root {
  color-scheme: dark;
  --bg: #090a0d;
  --surface: rgba(18, 20, 24, 0.84);
  --surface-strong: rgba(28, 31, 37, 0.94);
  --field: rgba(5, 7, 10, 0.68);
  --line: rgba(255, 255, 255, 0.13);
  --text: #f4f0e8;
  --muted: #a49d91;
  --gold: #f2c766;
  --blue: #72d5ff;
  --mint: #6ee7b7;
  --red: #ff786d;
  --violet: #b995ff;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.48);
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(120deg, rgba(242, 199, 102, 0.12), transparent 28%),
    linear-gradient(230deg, rgba(114, 213, 255, 0.13), transparent 34%),
    radial-gradient(circle at 52% -18%, rgba(255, 255, 255, 0.13), transparent 34%),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.035) 0 1px, transparent 1px 92px),
    repeating-linear-gradient(0deg, rgba(255,255,255,0.026) 0 1px, transparent 1px 92px),
    var(--bg);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  background-image: linear-gradient(rgba(255,255,255,0.055) 1px, transparent 1px);
  background-size: 100% 6px;
  opacity: 0.11;
  pointer-events: none;
}

button, textarea, input { font: inherit; }
a { color: inherit; text-decoration: none; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(9, 10, 13, 0.76);
  backdrop-filter: blur(24px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 900;
}

.brand-mark {
  display: inline-grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid rgba(242, 199, 102, 0.45);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(242, 199, 102, 0.23), rgba(114, 213, 255, 0.1));
  color: var(--gold);
}

.main-nav {
  display: inline-flex;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.045);
}

.main-nav a {
  min-width: 92px;
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
  font-weight: 800;
}

.main-nav a.active,
.main-nav a:hover {
  background: rgba(255,255,255,0.1);
  color: var(--text);
}

.home-shell {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.hero-panel,
.provider-overview,
.composer-panel,
.workspace,
.mode-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px);
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(360px, 0.72fr);
  gap: 24px;
  min-height: 520px;
  overflow: hidden;
  padding: 28px;
}

.hero-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
}

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

h1, h2, h3, p { letter-spacing: 0; }

h1 {
  max-width: 900px;
  margin: 0;
  font-size: clamp(42px, 8vw, 96px);
  line-height: 0.88;
}

.hero-lead,
.panel-lead {
  max-width: 680px;
  margin: 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.55;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 10px;
}

.primary-link,
.secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  border-radius: 8px;
  padding: 0 18px;
  font-weight: 900;
}

.primary-link {
  background: linear-gradient(135deg, var(--gold), var(--red), var(--blue));
  color: #11100d;
}

.secondary-link {
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.06);
}

.showcase {
  position: relative;
  min-height: 460px;
}

.showcase-card {
  position: absolute;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 8px;
  background:
    linear-gradient(140deg, rgba(255,255,255,0.18), transparent 28%),
    linear-gradient(320deg, rgba(114,213,255,0.24), transparent 44%),
    #15171c;
  box-shadow: 0 30px 80px rgba(0,0,0,0.42);
}

.showcase-card.large {
  inset: 20px 20px 110px 74px;
  background:
    radial-gradient(circle at 38% 28%, rgba(255,255,255,0.7), transparent 0 7%, transparent 12%),
    linear-gradient(135deg, #1f222a, #4b2231 42%, #f2c766 43%, #211b18 53%, #172b31);
}

.showcase-card.warm {
  right: 0;
  bottom: 20px;
  width: 54%;
  height: 42%;
  background: linear-gradient(135deg, #2a1714, #ff786d 46%, #f2c766);
}

.showcase-card.cool {
  left: 0;
  bottom: 56px;
  width: 44%;
  height: 32%;
  background: linear-gradient(135deg, #12151d, #72d5ff 52%, #b995ff);
}

.text-card {
  left: 42px;
  top: 72px;
  width: 210px;
  min-height: 110px;
  padding: 18px;
  background: rgba(8, 10, 13, 0.76);
}

.text-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.text-card strong {
  display: block;
  margin-top: 12px;
  font-size: 22px;
  line-height: 1.05;
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 18px;
}

.mode-card {
  position: relative;
  min-height: 260px;
  overflow: hidden;
  padding: 24px;
}

.mode-card::after {
  position: absolute;
  right: 20px;
  bottom: 20px;
  width: 190px;
  height: 118px;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 8px;
  content: "";
  opacity: 0.82;
}

.text-mode::after {
  background:
    linear-gradient(rgba(255,255,255,0.26) 0 0) 18px 20px / 120px 8px no-repeat,
    linear-gradient(rgba(255,255,255,0.16) 0 0) 18px 44px / 150px 7px no-repeat,
    linear-gradient(rgba(255,255,255,0.12) 0 0) 18px 66px / 104px 7px no-repeat,
    rgba(255,255,255,0.05);
}

.image-mode::after {
  background: linear-gradient(135deg, #151820, #6ee7b7, #72d5ff, #f2c766);
}

.mode-kicker,
.mode-meta {
  display: inline-flex;
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.mode-card h2 {
  max-width: 420px;
  margin: 22px 0 10px;
  font-size: clamp(30px, 4vw, 48px);
  line-height: 0.96;
}

.mode-card p {
  max-width: 520px;
  color: var(--muted);
  line-height: 1.5;
}

.mode-meta {
  position: absolute;
  left: 24px;
  bottom: 22px;
  color: var(--mint);
}

.provider-overview {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 20px;
  margin-top: 18px;
  padding: 22px;
}

.provider-overview h2 {
  margin: 8px 0 0;
  font-size: 30px;
}

.provider-status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}

.status-chip,
.provider-option {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,0.05);
}

.status-chip {
  padding: 12px;
}

.status-chip strong {
  display: block;
  margin-bottom: 6px;
}

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

.ok { color: var(--mint); }
.bad { color: var(--red); }

.lab-shell {
  display: grid;
  grid-template-columns: minmax(330px, 430px) minmax(0, 1fr);
  gap: 18px;
  width: min(1720px, 100%);
  min-height: calc(100vh - 67px);
  margin: 0 auto;
  padding: 18px;
}

.composer-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
}

.composer-panel h1 {
  font-size: clamp(34px, 5vw, 58px);
}

.field-head,
.section-head,
.workspace-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

label,
.section-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

.counter,
.section-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

textarea {
  width: 100%;
  min-height: 190px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  background: var(--field);
  color: var(--text);
  padding: 15px;
  line-height: 1.45;
}

textarea:focus {
  border-color: rgba(114, 213, 255, 0.62);
  box-shadow: 0 0 0 3px rgba(114, 213, 255, 0.13);
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.preset {
  width: auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  color: var(--text);
  cursor: pointer;
  padding: 8px 11px;
  font-size: 12px;
  font-weight: 900;
}

.provider-picker {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

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

.provider-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 10px;
}

.provider-option.disabled {
  opacity: 0.52;
}

.provider-option input {
  width: 18px;
  height: 18px;
  accent-color: var(--gold);
}

.provider-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 850;
}

.provider-state {
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  padding: 5px 8px;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.ad-checker {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.ad-checker .section-head span {
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  padding: 5px 8px;
  text-transform: uppercase;
}

.ad-checker .section-head span.checking {
  color: var(--blue);
}

.ad-checker .section-head span.ready,
.ad-checker .section-head span.ok {
  color: var(--mint);
}

.ad-check-button {
  min-height: 46px;
  border: 1px solid rgba(110, 231, 183, 0.35);
  border-radius: 8px;
  cursor: pointer;
  background: linear-gradient(135deg, rgba(110, 231, 183, 0.17), rgba(114, 213, 255, 0.12));
  color: var(--text);
  font-weight: 900;
}

.ad-check-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.ad-check-status {
  position: relative;
  overflow: hidden;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0,0,0,0.22);
  color: var(--muted);
  padding: 12px 12px 12px 42px;
  font-size: 13px;
  line-height: 1.35;
}

.ad-check-status::before {
  position: absolute;
  left: 13px;
  top: 15px;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.18);
  border-top-color: var(--blue);
  border-radius: 50%;
  content: "";
  opacity: 0.75;
}

.ad-check-status.is-checking::before {
  animation: spin 900ms linear infinite;
}

.ad-check-status.is-checking::after {
  position: absolute;
  inset: 0;
  content: "";
  background: linear-gradient(90deg, transparent, rgba(114, 213, 255, 0.12), transparent);
  animation: sweep 1.4s linear infinite;
}

.ad-check-status.is-success {
  border-color: rgba(110, 231, 183, 0.42);
  background: rgba(110, 231, 183, 0.08);
  color: #d7ffe9;
}

.ad-check-status.is-success::before {
  display: grid;
  place-items: center;
  border: none;
  color: var(--mint);
  content: "✓";
  font-size: 18px;
  font-weight: 950;
  opacity: 1;
}

.provider-links {
  grid-column: 2 / 4;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--blue);
  font-size: 12px;
}

.run-button {
  position: relative;
  min-height: 54px;
  overflow: hidden;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  background: linear-gradient(135deg, var(--gold), var(--red) 52%, var(--blue));
  color: #11100d;
  font-weight: 950;
  box-shadow: 0 18px 50px rgba(242, 199, 102, 0.22);
}

.run-button::after {
  position: absolute;
  inset: 0;
  content: "";
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.42), transparent);
  transform: translateX(-120%);
}

body.is-running .run-button::after {
  animation: sweep 1.2s linear infinite;
}

.run-button:disabled {
  cursor: wait;
  filter: saturate(0.76);
}

.status,
.pill {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0,0,0,0.22);
  color: var(--muted);
}

.status {
  padding: 11px 12px;
  font-size: 13px;
  line-height: 1.35;
}

.workspace {
  min-width: 0;
  overflow: hidden;
}

.workspace-head {
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, rgba(255,255,255,0.075), rgba(255,255,255,0.02));
  padding: 18px;
}

.workspace-head h2 {
  margin: 7px 0 0;
  font-size: clamp(30px, 4vw, 54px);
  line-height: 0.96;
}

.pill {
  padding: 9px 12px;
  font-size: 12px;
  font-weight: 900;
}

.cards {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.text-results {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
}

.image-results {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
}

.card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.035));
  padding: 14px;
  animation: rise 260ms ease both;
}

.card::before {
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  content: "";
  background: linear-gradient(90deg, var(--gold), var(--mint), var(--blue));
}

.card h3 {
  margin: 5px 0 9px;
  font-size: 17px;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
}

.output {
  white-space: pre-wrap;
  color: #f7f1df;
  font-size: 15px;
  line-height: 1.55;
}

.image-box {
  overflow: hidden;
  border-radius: 8px;
  background: #050506;
}

.image-box img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
}

.empty-state {
  display: grid;
  min-height: 300px;
  place-items: center;
  border: 1px dashed rgba(255,255,255,0.18);
  border-radius: 8px;
  background: rgba(255,255,255,0.025);
  color: var(--muted);
  padding: 28px;
  text-align: center;
}

.empty-state strong {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
  font-size: 20px;
}

.skeleton {
  min-height: 190px;
}

.skeleton::after {
  display: block;
  width: 100%;
  height: 116px;
  border-radius: 8px;
  content: "";
  background: linear-gradient(90deg, rgba(255,255,255,0.05), rgba(255,255,255,0.14), rgba(255,255,255,0.05));
  background-size: 220% 100%;
  animation: shimmer 1s linear infinite;
}

@keyframes sweep {
  to { transform: translateX(120%); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes shimmer {
  to { background-position: -220% 0; }
}

@media (max-width: 1100px) {
  .hero-panel,
  .overview-grid,
  .provider-overview,
  .lab-shell {
    grid-template-columns: 1fr;
  }

  .showcase { min-height: 380px; }
}

@media (max-width: 720px) {
  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
  }

  .main-nav {
    width: 100%;
    overflow-x: auto;
  }

  .main-nav a {
    min-width: max-content;
  }

  .home-shell,
  .lab-shell {
    padding: 10px;
  }

  .hero-panel {
    min-height: auto;
    padding: 18px;
  }

  h1 {
    font-size: 42px;
  }
}
