/* Spark web — modern dark UI */
:root {
  --bg-deep: #070a0f;
  --bg-elevated: rgba(18, 24, 36, 0.72);
  --bg-input: rgba(8, 11, 18, 0.85);
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.1);
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-faint: #64748b;
  --accent: #38bdf8;
  --accent-dim: rgba(56, 189, 248, 0.12);
  --accent-glow: rgba(56, 189, 248, 0.35);
  --violet: #a78bfa;
  --success-bg: rgba(34, 197, 94, 0.12);
  --success-border: rgba(34, 197, 94, 0.25);
  --error-bg: rgba(248, 113, 113, 0.1);
  --error-border: rgba(248, 113, 113, 0.22);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 999px;
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.35), 0 0 0 1px var(--border-subtle);
  --font-sans: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "Cascadia Code", monospace;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background-color: var(--bg-deep);
  background-image:
    radial-gradient(ellipse 100% 70% at 50% -15%, rgba(56, 189, 248, 0.14), transparent 55%),
    radial-gradient(ellipse 60% 45% at 100% 20%, rgba(167, 139, 250, 0.1), transparent 50%),
    radial-gradient(ellipse 50% 40% at 0% 80%, rgba(56, 189, 248, 0.06), transparent 45%);
  background-attachment: fixed;
}

/* Subtle grid overlay */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 80% 70% at 50% 30%, black, transparent);
  pointer-events: none;
  z-index: 0;
}

.wrap {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: 2.25rem 1.25rem 3.5rem;
}

.landing-wrap {
  max-width: 880px;
}

/* Brand / top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: inherit;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent) 0%, var(--violet) 100%);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--bg-deep);
  box-shadow: 0 4px 20px var(--accent-glow);
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  line-height: 1.2;
}

.brand-name {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.brand-tag {
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
}

.header-block {
  margin-bottom: 1.75rem;
}

.header-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem 1rem;
}

header h1,
.hero-title {
  font-size: clamp(1.55rem, 4vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin: 0 0 0.65rem;
  flex: 1 1 auto;
  min-width: 0;
  background: linear-gradient(180deg, #fff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid rgba(56, 189, 248, 0.25);
  margin-bottom: 1rem;
}

.hero-badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

.sub {
  color: var(--text-muted);
  font-size: 0.9375rem;
  margin: 0;
  max-width: 62ch;
}

.sub + .sub {
  margin-top: 0.85rem;
}

.sub code {
  font-family: var(--font-mono);
  font-size: 0.84em;
  background: rgba(255, 255, 255, 0.06);
  padding: 0.12em 0.4em;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
  color: var(--accent);
}

.auth {
  flex-shrink: 0;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.15rem;
}

.auth-user {
  color: var(--text-muted);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

a.auth-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

a.auth-link:hover {
  text-decoration: underline;
}

a.auth-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  background: linear-gradient(180deg, #fff 0%, #e2e8f0 100%);
  color: #0f172a;
  padding: 0.5rem 1.1rem;
  border-radius: var(--radius-pill);
  font-weight: 600;
  text-decoration: none;
  font-size: 0.8125rem;
  border: none;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

a.auth-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(56, 189, 248, 0.25);
}

.card {
  background: var(--bg-elevated);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.5rem;
  margin-top: 1.5rem;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-card);
}

.card-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  margin: 0 0 1.1rem;
}

.field {
  margin-bottom: 1.15rem;
}

.field:last-of-type {
  margin-bottom: 1.35rem;
}

.field label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.field input[type="file"],
.field textarea,
.field input[type="number"] {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: var(--radius-md);
  padding: 0.55rem 0.75rem;
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input[type="file"] {
  padding: 0.45rem 0.65rem;
  cursor: pointer;
}

.field input[type="file"]::file-selector-button {
  margin-right: 0.75rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
}

.field input[type="file"]::file-selector-button:hover {
  background: rgba(255, 255, 255, 0.1);
}

.field textarea {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  resize: vertical;
  min-height: 140px;
  line-height: 1.5;
}

.field textarea::placeholder {
  color: var(--text-faint);
}

.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: rgba(56, 189, 248, 0.45);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

button[type="submit"] {
  width: 100%;
  background: linear-gradient(135deg, #0ea5e9 0%, #6366f1 100%);
  color: #fff;
  border: none;
  padding: 0.75rem 1.35rem;
  border-radius: var(--radius-pill);
  font-weight: 600;
  cursor: pointer;
  font-size: 0.95rem;
  font-family: inherit;
  box-shadow: 0 4px 20px rgba(14, 165, 233, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

button[type="submit"]:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 28px rgba(99, 102, 241, 0.35);
}

button[type="submit"]:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.status {
  margin-top: 1.25rem;
  padding: 0.85rem 1.1rem;
  border-radius: var(--radius-md);
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  font-size: 0.9rem;
  color: #bbf7d0;
}

.status.error {
  background: var(--error-bg);
  border-color: var(--error-border);
  color: #fecaca;
}

.quota-banner {
  margin: -0.35rem 0 1.15rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.pay-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.65rem;
  align-items: center;
}

.hidden {
  display: none !important;
}

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

.out h2,
.history h2 {
  margin-top: 0;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.out pre {
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--bg-input);
  padding: 1.1rem 1.15rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  font-family: var(--font-mono);
  font-size: 0.84rem;
  line-height: 1.55;
  max-height: 70vh;
  overflow: auto;
  margin: 0;
}

/* Landing */
.landing-header {
  text-align: center;
  max-width: 640px;
  margin: 0 auto 0.5rem;
}

.landing-header .hero-title {
  background: linear-gradient(135deg, #f8fafc 0%, #94a3b8 45%, #38bdf8 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

.landing-header .sub {
  margin-left: auto;
  margin-right: auto;
  text-align: left;
}

.landing-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin: 2rem auto 0;
  max-width: 900px;
  padding: 1.25rem 1rem;
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-card);
}

.stat-item {
  text-align: center;
  padding: 0.35rem 0.5rem;
}

.stat-value {
  display: block;
  font-size: clamp(1.65rem, 4vw, 2.15rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  background: linear-gradient(135deg, #fff 0%, #38bdf8 50%, #a78bfa 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.stat-label {
  display: block;
  margin-top: 0.45rem;
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1.35;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.landing-stat-note {
  margin: 0.65rem auto 0;
  max-width: 52ch;
  text-align: center;
  font-size: 0.7rem;
  line-height: 1.4;
  color: var(--text-faint);
}

.landing-enterprise {
  margin: 2rem auto 0;
  max-width: 560px;
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.landing-enterprise strong {
  color: var(--text);
  font-weight: 600;
}

@media (max-width: 640px) {
  .landing-stats {
    grid-template-columns: 1fr;
    gap: 1.1rem;
    padding: 1.25rem 1.1rem;
  }

  .stat-item {
    padding-bottom: 0.65rem;
    border-bottom: 1px solid var(--border-subtle);
  }

  .stat-item:last-child {
    padding-bottom: 0;
    border-bottom: none;
  }
}

.landing-features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-top: 2rem;
}

.feature-tile {
  padding: 1.15rem 1.2rem;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-card);
}

.feature-tile h3 {
  margin: 0 0 0.4rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.feature-tile p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.feature-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--accent-dim);
  border: 1px solid rgba(56, 189, 248, 0.2);
  display: grid;
  place-items: center;
  font-size: 0.8rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  margin-bottom: 0.75rem;
}

.landing-cta {
  text-align: center;
  padding: 2rem 1.5rem;
  margin-top: 2.25rem;
  background: linear-gradient(165deg, rgba(56, 189, 248, 0.08) 0%, var(--bg-elevated) 45%);
}

.landing-lead {
  margin: 0 0 1.35rem;
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text);
}

a.landing-btn {
  font-size: 1rem;
  padding: 0.7rem 1.65rem;
}

.landing-footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-subtle);
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-faint);
}

/* History */
.history h2 {
  margin-bottom: 0.35rem;
}

.history-empty {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0 0 0.5rem;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.history-item-btn {
  width: 100%;
  text-align: left;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.85rem;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.history-item-btn:hover {
  border-color: rgba(56, 189, 248, 0.35);
  background: rgba(56, 189, 248, 0.06);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.08);
}

.history-item-when {
  font-size: 0.78rem;
  color: var(--text-faint);
  font-weight: 500;
}

.history-item-flags {
  font-size: 0.72rem;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.history-item-preview {
  font-size: 0.84rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--font-mono);
}

.history-detail {
  margin-top: 1.15rem;
  padding-top: 1.15rem;
  border-top: 1px solid var(--border-subtle);
}

.history-detail-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.55rem;
}

.history-detail pre {
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--bg-input);
  padding: 1rem 1.1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  font-family: var(--font-mono);
  font-size: 0.84rem;
  max-height: 50vh;
  overflow: auto;
  margin: 0;
  line-height: 1.55;
}

@media (min-width: 640px) {
  button[type="submit"] {
    width: auto;
    min-width: 220px;
  }
}
