:root {
  --bg: #05060a;
  --bg-2: #0a0c14;
  --surface: rgba(18, 20, 30, 0.72);
  --surface-2: rgba(28, 30, 44, 0.65);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #e7e9f3;
  --text-dim: #a0a4b8;
  --text-mute: #6a6f85;
  --accent: #7c5cff;
  --accent-2: #22d3ee;
  --accent-glow: rgba(124, 92, 255, 0.45);
  --danger: #ff5c7a;
  --ok: #4ade80;
  --radius: 14px;
  --radius-lg: 22px;
  --shadow-xl: 0 30px 80px -20px rgba(0, 0, 0, 0.7), 0 10px 30px -10px rgba(0, 0, 0, 0.6);
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(1200px 600px at 20% -10%, rgba(124, 92, 255, 0.22), transparent 60%),
    radial-gradient(900px 500px at 100% 110%, rgba(34, 211, 238, 0.18), transparent 60%),
    linear-gradient(180deg, #05060a 0%, #07080f 100%);
  z-index: -2;
  pointer-events: none;
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse at 50% 30%, black 30%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 30%, black 30%, transparent 75%);
  z-index: -1;
  pointer-events: none;
}

.bg-orb {
  position: fixed;
  width: 560px;
  height: 560px;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.55;
  z-index: -1;
  pointer-events: none;
}
.bg-orb--a { background: radial-gradient(circle, #7c5cff 0%, transparent 60%); top: -160px; left: -180px; animation: floatA 18s ease-in-out infinite; }
.bg-orb--b { background: radial-gradient(circle, #22d3ee 0%, transparent 60%); bottom: -200px; right: -180px; animation: floatB 22s ease-in-out infinite; }

@keyframes floatA {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(40px, 30px) scale(1.05); }
}
@keyframes floatB {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-35px, -25px) scale(1.08); }
}

button { font-family: inherit; color: inherit; }
input, textarea { font-family: inherit; color: inherit; }

::selection { background: rgba(124, 92, 255, 0.35); color: #fff; }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

@media (prefers-reduced-motion: reduce) {
  .bg-orb, .bg-orb--a, .bg-orb--b { animation: none; }
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ===== Credits indicator (shared) ===== */
.credits {
  --c-accent: #4ade80;
  display: inline-flex;
  flex-direction: column;
  gap: 5px;
  padding: 7px 12px 9px;
  min-width: 148px;
  background: rgba(18, 20, 30, 0.6);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: border-color 0.2s;
  font-family: var(--font-sans);
  cursor: default;
}
.credits:hover { border-color: rgba(255,255,255,0.15); }
.credits-value {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  line-height: 1;
}
.credits-label {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 10px;
  color: var(--text-mute);
  font-weight: 600;
}
.credits-amount {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 14px;
  color: var(--c-accent);
  transition: color 0.3s;
  letter-spacing: -0.01em;
}
.credits-sub {
  font-size: 10.5px;
  color: var(--text-mute);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--font-mono);
}
.credits-bar {
  position: relative;
  height: 4px;
  background: rgba(255,255,255,0.07);
  border-radius: 999px;
  overflow: hidden;
}
.credits-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--c-accent);
  border-radius: 999px;
  transition: width 0.6s cubic-bezier(0.2, 0.8, 0.2, 1), background 0.3s;
  box-shadow: 0 0 10px var(--c-accent);
}
.credits[data-state="loading"] .credits-amount { color: var(--text-mute); }
.credits[data-state="loading"] .credits-bar-fill {
  width: 30%;
  background: rgba(124, 92, 255, 0.5);
  box-shadow: none;
  animation: credits-loading 1.4s ease-in-out infinite;
}
@keyframes credits-loading {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(400%); }
}
.credits[data-state="ok"] { --c-accent: #4ade80; }
.credits[data-state="warn"] { --c-accent: #f59e0b; border-color: rgba(245, 158, 11, 0.25); }
.credits[data-state="danger"] {
  --c-accent: #ef4444;
  border-color: rgba(239, 68, 68, 0.35);
  animation: credits-pulse 2s ease-in-out infinite;
}
@keyframes credits-pulse {
  0%, 100% { box-shadow: 0 0 0 rgba(239, 68, 68, 0); }
  50% { box-shadow: 0 0 16px rgba(239, 68, 68, 0.35); }
}
.credits[data-state="unconfigured"],
.credits[data-state="error"] {
  --c-accent: #6a6f85;
  opacity: 0.75;
}
.credits[data-state="unconfigured"] .credits-bar-fill,
.credits[data-state="error"] .credits-bar-fill { box-shadow: none; }

@media (max-width: 640px) {
  .credits { min-width: 112px; padding: 6px 10px 8px; }
  .credits-sub { display: none; }
}

/* ===== Model selector (shared) ===== */
.ms-root { display: inline-flex; align-items: center; }
.ms-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px 5px 8px;
  background: rgba(18, 20, 30, 0.6);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  transition: border-color 0.15s, background 0.15s;
}
.ms-wrap:hover { border-color: rgba(255,255,255,0.2); background: rgba(28, 30, 44, 0.75); }
.ms-select {
  background: transparent;
  border: none;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 12.5px;
  padding: 3px 4px;
  cursor: pointer;
  outline: none;
  font-weight: 500;
}
.ms-select option { background: #0d0f18; color: var(--text); }
.ms-cost {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-dim);
  padding-left: 6px;
  border-left: 1px solid rgba(255,255,255,0.08);
  white-space: nowrap;
}
.ms-compact .ms-cost { font-size: 10px; }
.ms-compact .ms-select { font-size: 12px; }
