:root {
  --bg: #050508;
  --bg2: #0c0c14;
  --surface: rgba(255, 255, 255, 0.04);
  --border: rgba(255, 255, 255, 0.08);
  --text: #f4f4f8;
  --muted: #9ca3b8;
  --accent: #7c5cff;
  --accent2: #00e5a0;
  --gradient: linear-gradient(135deg, #7c5cff 0%, #00e5a0 100%);
  --radius: 16px;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 50% at 20% -10%, rgba(124, 92, 255, 0.25), transparent),
    radial-gradient(ellipse 60% 40% at 90% 10%, rgba(0, 229, 160, 0.12), transparent);
  z-index: 0;
}

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 24px; position: relative; z-index: 1; }

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
}
.logo {
  font-size: 1.35rem;
  font-weight: 700;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-decoration: none;
}
.nav-links { display: flex; gap: 24px; align-items: center; }
.nav-links a:not(.btn) {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
  transition: color 0.2s;
}
.nav-links a:not(.btn):hover { color: var(--text); }

/* Hamburger toggle — injected by app.js, hidden on desktop. */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 42px;
  height: 42px;
  padding: 0 11px;
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.nav-toggle span {
  display: block;
  height: 2px;
  width: 20px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.95rem;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s, box-shadow 0.15s;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary {
  background: var(--gradient);
  color: #050508;
  box-shadow: 0 8px 32px rgba(124, 92, 255, 0.35);
}
.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-sm { padding: 8px 18px; font-size: 0.875rem; }

.hero { padding: 80px 0 100px; text-align: center; }
.hero-badge {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--accent2);
  margin-bottom: 24px;
}
.hero h1 {
  font-size: clamp(2.2rem, 5vw, 3.6rem);
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: -0.02em;
  max-width: 820px;
  margin: 0 auto 20px;
}
.hero h1 span {
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero p {
  font-size: 1.15rem;
  color: var(--muted);
  max-width: 560px;
  margin: 0 auto 36px;
}
.hero-cta { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }

.section { padding: 72px 0; }
.section h2 { font-size: 2rem; text-align: center; margin-bottom: 12px; }
.section .sub {
  text-align: center;
  color: var(--muted);
  margin-bottom: 48px;
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 28px;
  align-items: start;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  backdrop-filter: blur(12px);
}
.card h3 { font-size: 1.1rem; margin-bottom: 8px; }
.card p { color: var(--muted); font-size: 0.95rem; }

.benefit-icon {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--accent2);
  margin-bottom: 12px;
  letter-spacing: 0.08em;
}
.benefit h3 { margin-bottom: 8px; }
.plan-desc { color: var(--muted); font-size: 0.9rem; margin-top: 8px; min-height: 2.8em; }
.plan-tokens { font-size: 0.8rem; color: var(--muted); margin: 8px 0 16px; }
.pricing-note { max-width: 720px; margin: 36px auto 0; text-align: center; font-size: 0.85rem; color: var(--muted); }
.cta-block { text-align: center; padding-bottom: 100px; }
.hint { font-size: 0.875rem; }

.model-card .tag {
  font-family: ui-monospace, monospace;
  font-size: 0.85rem;
  color: var(--accent2);
  margin-bottom: 8px;
}
.model-card .price { margin-top: 12px; font-size: 0.8rem; color: var(--muted); }

.pricing-card { position: relative; text-align: center; }
.pricing-card.recommended {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 20px 60px rgba(124, 92, 255, 0.2);
}
.pricing-card .badge {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--gradient);
  color: #050508;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 999px;
}
.pricing-card.is-current { border-color: var(--accent2); box-shadow: 0 0 0 1px var(--accent2), 0 20px 60px rgba(0, 229, 160, 0.15); }
.pricing-card .badge.badge-current { background: var(--accent2); color: #050508; }
.btn[disabled], .btn:disabled { opacity: 0.55; cursor: default; pointer-events: none; transform: none; box-shadow: none; }
.pricing-card .price-big { font-size: 2.5rem; font-weight: 800; margin: 16px 0 4px; }
.pricing-card .price-big small { font-size: 1rem; color: var(--muted); font-weight: 400; }
.pricing-card ul { list-style: none; text-align: left; margin: 24px 0; font-size: 0.9rem; color: var(--muted); }
.pricing-card li { padding: 6px 0; padding-left: 20px; position: relative; }
.pricing-card li::before { content: '✓'; position: absolute; left: 0; color: var(--accent2); }

.auth-box {
  max-width: 420px;
  margin: 60px auto;
  padding: 40px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.auth-box h1 { font-size: 1.5rem; margin-bottom: 8px; text-align: center; }
.auth-box .hint { text-align: center; color: var(--muted); font-size: 0.9rem; margin-bottom: 28px; }
.field { margin-bottom: 18px; }
.field label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text);
  font-size: 1rem;
}
.field input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.auth-box .btn { width: 100%; margin-top: 8px; }
.auth-box .links { text-align: center; margin-top: 20px; font-size: 0.9rem; }
.auth-box .links a { color: var(--accent); }

.cabinet-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 32px;
  padding: 32px 0 80px;
  min-height: calc(100vh - 80px);
}
@media (max-width: 768px) {
  .cabinet-layout { grid-template-columns: 1fr; gap: 20px; padding: 20px 0 64px; }
  .nav { position: relative; }
  .nav-toggle { display: inline-flex; }
  .nav-links {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    left: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 10px;
    z-index: 50;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  }
  .nav.nav-open .nav-links { display: flex; }
  .nav-links a:not(.btn) { padding: 11px 12px; border-radius: 8px; }
  .nav-links a:not(.btn):hover { background: var(--surface); }
  .nav-links .btn { width: 100%; margin-top: 4px; }
  .nav-links > span { padding: 8px 12px; }
  .nav.nav-open .nav-toggle span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .nav.nav-open .nav-toggle span:nth-child(2) { opacity: 0; }
  .nav.nav-open .nav-toggle span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
}
.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar nav a {
  padding: 10px 14px;
  border-radius: 10px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
}
.sidebar nav a.active, .sidebar nav a:hover { background: var(--surface); color: var(--text); }
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}
.stat .label { font-size: 0.8rem; color: var(--muted); }
.stat .value { font-size: 1.5rem; font-weight: 700; margin-top: 4px; }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 12px; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 500; }

.footer {
  padding: 48px 0;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}
.footer a { color: var(--muted); margin: 0 12px; }

.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-size: 0.9rem; }
.alert-error { background: rgba(239, 68, 68, 0.15); border: 1px solid rgba(239, 68, 68, 0.3); }
.alert-success { background: rgba(0, 229, 160, 0.12); border: 1px solid rgba(0, 229, 160, 0.3); }
.hidden { display: none !important; }

code.key-display {
  display: block;
  padding: 12px;
  background: var(--bg2);
  border-radius: 8px;
  font-size: 0.85rem;
  word-break: break-all;
  margin: 12px 0;
}

.compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin: 48px 0;
}
@media (max-width: 640px) { .compare { grid-template-columns: 1fr; } }
.compare .before { opacity: 0.6; }
.compare h4 { margin-bottom: 12px; font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }

.privacy-content { max-width: 720px; margin: 0 auto; padding: 40px 0 80px; }
.privacy-content h2 { font-size: 1.3rem; margin: 32px 0 12px; text-align: left; }
.privacy-content p, .privacy-content li { color: var(--muted); margin-bottom: 12px; }

.panel { display: none; }
.panel.active { display: block; }

/* ---------- Card hover polish ---------- */
.model-card { transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease; }
.model-card:hover { transform: translateY(-3px); border-color: rgba(124, 92, 255, 0.45); box-shadow: 0 18px 50px rgba(124, 92, 255, 0.15); }
.benefit { transition: transform 0.18s ease, border-color 0.18s ease; }
.benefit:hover { transform: translateY(-3px); border-color: rgba(0, 229, 160, 0.4); }
.pricing-card { transition: transform 0.18s ease, box-shadow 0.18s ease; }
.pricing-card:hover { transform: translateY(-4px); }
.btn-primary:focus-visible, .btn-ghost:focus-visible { outline: 2px solid var(--accent2); outline-offset: 2px; }

/* ---------- API key reveal card ---------- */
.key-card {
  background: linear-gradient(135deg, rgba(124,92,255,0.12), rgba(0,229,160,0.08));
  border: 1px solid rgba(124, 92, 255, 0.35);
}
.key-row { display: flex; gap: 10px; align-items: stretch; margin: 12px 0; flex-wrap: wrap; }
.key-row code {
  flex: 1; min-width: 240px;
  display: flex; align-items: center;
  padding: 12px 14px; background: var(--bg2);
  border-radius: 10px; font-size: 0.9rem; word-break: break-all;
}
.copy-btn { white-space: nowrap; }
.steps-list { counter-reset: step; list-style: none; margin-top: 8px; }
.steps-list li {
  position: relative; padding: 12px 0 12px 44px; border-bottom: 1px solid var(--border);
  color: var(--muted);
}
.steps-list li:last-child { border-bottom: none; }
.steps-list li::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: 0; top: 12px;
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--gradient); color: #050508; font-weight: 700; font-size: 0.85rem;
}
.steps-list code { color: var(--accent2); }
.steps-list strong { color: var(--text); }

/* ---------- Support widget ---------- */
.support-fab {
  position: fixed; right: 22px; bottom: 22px; z-index: 60;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 18px; border-radius: 999px;
  background: var(--gradient); color: #050508; font-weight: 700;
  border: none; cursor: pointer; text-decoration: none;
  box-shadow: 0 10px 30px rgba(124, 92, 255, 0.45);
  transition: transform 0.15s ease;
}
.support-fab:hover { transform: translateY(-2px) scale(1.02); }
.support-pop {
  position: fixed; right: 22px; bottom: 80px; z-index: 60;
  width: min(320px, calc(100vw - 44px));
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 16px; padding: 20px; box-shadow: 0 24px 60px rgba(0,0,0,0.5);
}
.support-pop h4 { font-size: 1.05rem; margin-bottom: 6px; }
.support-pop p { color: var(--muted); font-size: 0.88rem; margin-bottom: 14px; }
.support-pop .chan {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; margin-bottom: 8px;
  border-radius: 10px; background: var(--surface);
  border: 1px solid var(--border); color: var(--text);
  text-decoration: none; font-size: 0.92rem; font-weight: 600;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.support-pop .chan:hover { border-color: var(--accent); transform: translateX(2px); }
.support-pop .chan .ic { font-size: 1.1rem; }
.support-channels { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.support-channels .chan {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-radius: 10px; background: var(--surface);
  border: 1px solid var(--border); color: var(--text);
  text-decoration: none; font-size: 0.92rem; font-weight: 600;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.support-channels .chan:hover { border-color: var(--accent); transform: translateX(2px); }

/* ---------- Balance meter ---------- */
.balance-card { margin-bottom: 24px; }
.balance-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.balance-value { font-size: 1.8rem; font-weight: 800; }
.meter { height: 10px; border-radius: 999px; background: var(--bg2); overflow: hidden; margin: 16px 0 10px; }
.meter-fill { height: 100%; background: var(--gradient); border-radius: 999px; transition: width 0.4s ease; }
.meter-fill.low { background: linear-gradient(90deg, #ff7a59, #ff3b6b); }
.balance-sub { display: flex; justify-content: space-between; color: var(--muted); font-size: 0.88rem; }

/* ---------- Top-ups ---------- */
.topup-packs { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.topup-pack { font-weight: 700; }
.topup-custom { display: flex; gap: 10px; flex-wrap: wrap; }
.topup-custom input {
  flex: 1; min-width: 160px; padding: 11px 14px; border-radius: 10px;
  background: var(--bg2); border: 1px solid var(--border); color: var(--text);
}

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 0.85rem; color: var(--muted); }
.form-grid label.full { grid-column: 1 / -1; }
.form-grid label.checkbox { flex-direction: row; align-items: center; gap: 10px; color: var(--text); }
.form-grid input, .form-grid textarea {
  padding: 10px 12px; border-radius: 10px; background: var(--bg2);
  border: 1px solid var(--border); color: var(--text); font: inherit;
}
.form-grid input[type="checkbox"] { width: auto; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

/* ---------- My projects ---------- */
.project-row {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 14px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.project-row:last-child { border-bottom: none; }
.project-meta { display: flex; flex-direction: column; gap: 4px; }
.project-meta .muted { color: var(--muted); font-size: 0.82rem; }
.project-actions { display: flex; align-items: center; gap: 14px; }
.switch-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.88rem; }
.link { color: var(--accent2); text-decoration: none; }
.link:hover { text-decoration: underline; }

/* ---------- Live chat ---------- */
.badge-dot {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  background: #ff3b6b; margin-left: 6px; vertical-align: middle;
}
.chat-card { display: flex; flex-direction: column; min-height: 420px; }
.chat-log { flex: 1; overflow-y: auto; max-height: 460px; display: flex; flex-direction: column; gap: 10px; padding-bottom: 12px; }
.chat-empty { color: var(--muted); text-align: center; margin: auto; }
.chat-msg { display: flex; flex-direction: column; max-width: 78%; }
.chat-msg .bubble { padding: 10px 14px; border-radius: 14px; font-size: 0.92rem; line-height: 1.4; white-space: pre-wrap; word-break: break-word; }
.chat-msg .chat-time { font-size: 0.72rem; color: var(--muted); margin-top: 3px; }
.chat-msg.from-user { align-self: flex-end; align-items: flex-end; }
.chat-msg.from-user .bubble { background: var(--gradient); color: #050508; }
.chat-msg.from-admin { align-self: flex-start; align-items: flex-start; }
.chat-msg.from-admin .bubble { background: var(--surface); border: 1px solid var(--border); color: var(--text); }
.chat-input { display: flex; gap: 10px; border-top: 1px solid var(--border); padding-top: 14px; }
.chat-input input {
  flex: 1; padding: 11px 14px; border-radius: 10px; background: var(--bg2);
  border: 1px solid var(--border); color: var(--text); font: inherit;
}

/* ---------- Registration dev card ---------- */
.dev-card-block {
  border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 16px; margin: 8px 0 4px; background: var(--bg2);
}
.dev-card-block summary { cursor: pointer; font-weight: 600; color: var(--text); }
.dev-card-block textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px; background: var(--surface);
  border: 1px solid var(--border); color: var(--text); font: inherit;
}
