:root {
  --bg: #0a0e1c;
  --surface: rgba(255, 255, 255, 0.055);
  --surface-strong: rgba(255, 255, 255, 0.09);
  --border: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.18);
  --text: #eef2ff;
  --text-dim: #a9b4d0;
  --text-faint: #7783a5;
  --accent: #7c6cff;
  --accent2: #22d3ee;
  --grad: linear-gradient(135deg, #7c6cff 0%, #5ea2ff 52%, #22d3ee 100%);
  --success: #34d399;
  --warn: #fbbf24;
  --danger: #fb7185;
  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 24px 70px rgba(2, 6, 23, 0.55);
  --font: "Inter", "SF Pro Text", -apple-system, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  --mono: "JetBrains Mono", "SF Mono", Consolas, "Cascadia Code", monospace;
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}

/* ---------- backdrop ---------- */
.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background:
    radial-gradient(1200px 700px at 15% -10%, rgba(124, 108, 255, 0.22), transparent 60%),
    radial-gradient(1000px 600px at 90% 10%, rgba(34, 211, 238, 0.14), transparent 55%),
    radial-gradient(900px 700px at 50% 110%, rgba(94, 162, 255, 0.16), transparent 60%),
    var(--bg);
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.5;
  animation: drift 18s ease-in-out infinite alternate;
}
.orb-a { width: 420px; height: 420px; left: -120px; top: 8%; background: #5b4dff; }
.orb-b { width: 360px; height: 360px; right: -100px; top: 30%; background: #0ea5e9; animation-delay: -6s; }
.orb-c { width: 300px; height: 300px; left: 35%; bottom: -120px; background: #7c3aed; animation-delay: -12s; }

.grid-overlay {
  position: absolute;
  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 90% 60% at 50% 0%, #000 30%, transparent 75%);
}

.noise {
  position: absolute;
  inset: 0;
  opacity: 0.04;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
}

@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(40px, -30px, 0) scale(1.12); }
}

/* ---------- layout ---------- */
.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 12px 20px 56px;
}

.topbar {
  max-width: 860px;
  margin: 0 auto;
  padding: 22px 20px 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand { display: flex; align-items: center; gap: 10px; }
.logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--grad);
  color: #fff;
  box-shadow: 0 8px 22px rgba(124, 108, 255, 0.45);
}
.brand-name { font-weight: 800; font-size: 16px; letter-spacing: 0.2px; }

.lang-switch {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.lang-switch button {
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 7px 14px;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.18s, color 0.18s, box-shadow 0.18s;
}
.lang-switch button:hover { color: var(--text); }
.lang-switch button.active {
  background: var(--grad);
  color: #fff;
  box-shadow: 0 4px 14px rgba(124, 108, 255, 0.4);
}

/* ---------- hero ---------- */
.hero { text-align: center; padding: 44px 8px 34px; animation: rise 0.6s ease both; }
.hero-title {
  font-size: clamp(30px, 6vw, 48px);
  line-height: 1.16;
  margin: 0 0 16px;
  font-weight: 850;
  letter-spacing: -0.5px;
}
.gradient {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-sub {
  max-width: 620px;
  margin: 0 auto 22px;
  color: var(--text-dim);
  font-size: 15.5px;
}
.hero-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  font-size: 12.5px;
  font-weight: 600;
  backdrop-filter: blur(10px);
}
.badge svg { color: var(--accent2); }

/* ---------- panels ---------- */
.panel {
  background: linear-gradient(180deg, var(--surface-strong), var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  padding: 24px;
  margin-bottom: 18px;
}

.generator { animation: rise 0.7s 0.08s ease both; }
.result { animation: rise 0.5s ease both; }

.field { margin-bottom: 20px; }
.field:last-child { margin-bottom: 0; }
.field-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 9px;
}
label {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.2px;
}
.count, .hint { font-size: 12px; color: var(--text-faint); font-variant-numeric: tabular-nums; }

textarea, select, pre {
  font: inherit;
  color: var(--text);
}

textarea {
  width: 100%;
  min-height: 150px;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(8, 12, 28, 0.55);
  padding: 14px 15px;
  line-height: 1.7;
  font-size: 14.5px;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
}
textarea:focus {
  border-color: rgba(124, 108, 255, 0.65);
  box-shadow: 0 0 0 4px rgba(124, 108, 255, 0.16);
}

.toolbar { display: flex; gap: 8px; margin-top: 10px; }

.ghost {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  padding: 8px 13px;
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.18s, color 0.18s, background 0.18s;
}
.ghost:hover {
  border-color: var(--border-strong);
  color: var(--text);
  background: var(--surface-strong);
}

.segmented {
  display: flex;
  gap: 6px;
  padding: 5px;
  background: rgba(8, 12, 28, 0.55);
  border: 1px solid var(--border);
  border-radius: 14px;
}
.seg {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 13.5px;
  font-weight: 700;
  padding: 10px 8px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.18s, color 0.18s, box-shadow 0.18s;
}
.seg:hover { color: var(--text); }
.seg.active {
  background: var(--grad);
  color: #fff;
  box-shadow: 0 6px 18px rgba(124, 108, 255, 0.35);
}

.row2 {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 16px;
}

.select-wrap { position: relative; }
.select-wrap::after {
  content: "";
  position: absolute;
  right: 15px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--text-faint);
  border-bottom: 2px solid var(--text-faint);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}
select {
  width: 100%;
  appearance: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(8, 12, 28, 0.55);
  padding: 12px 38px 12px 14px;
  font-size: 14px;
  font-weight: 600;
  outline: none;
  cursor: pointer;
  transition: border-color 0.18s, box-shadow 0.18s;
}
select:focus {
  border-color: rgba(124, 108, 255, 0.65);
  box-shadow: 0 0 0 4px rgba(124, 108, 255, 0.16);
}

.lang-pill {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(8, 12, 28, 0.55);
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.flag { font-size: 17px; }
.pill-dot {
  margin-left: auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 10px rgba(52, 211, 153, 0.8);
}

.primary {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  border: 0;
  border-radius: 14px;
  background: var(--grad);
  color: #fff;
  font: inherit;
  font-size: 16px;
  font-weight: 800;
  padding: 15px 26px;
  cursor: pointer;
  box-shadow: 0 12px 32px rgba(124, 108, 255, 0.42);
  transition: transform 0.16s, box-shadow 0.16s, filter 0.16s, opacity 0.16s;
}
.primary:hover { transform: translateY(-2px); filter: brightness(1.08); box-shadow: 0 16px 40px rgba(124, 108, 255, 0.5); }
.primary:active { transform: translateY(0); }
.primary:disabled { opacity: 0.62; cursor: wait; transform: none; filter: none; }
.primary.small {
  width: auto;
  padding: 11px 20px;
  font-size: 14px;
  border-radius: 12px;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- result ---------- */
.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.result-head h2 { margin: 0; font-size: 18px; font-weight: 800; }
.status-pill {
  font-size: 12px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
}
.status-pill.ok { color: var(--success); border-color: rgba(52, 211, 153, 0.35); background: rgba(52, 211, 153, 0.08); }
.status-pill.err { color: var(--danger); border-color: rgba(251, 113, 133, 0.35); background: rgba(251, 113, 133, 0.08); }
.status-pill.busy { color: var(--warn); border-color: rgba(251, 191, 36, 0.35); background: rgba(251, 191, 36, 0.08); }

audio { width: 100%; margin-bottom: 16px; }
audio::-webkit-media-controls-panel { background: rgba(255, 255, 255, 0.06); }

.actions { display: flex; flex-wrap: wrap; gap: 10px; }

.details { margin-top: 18px; border-top: 1px dashed var(--border); padding-top: 14px; }
.details summary {
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-dim);
  user-select: none;
  transition: color 0.15s;
}
.details summary:hover { color: var(--text); }
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 14px;
}
pre {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(8, 12, 28, 0.55);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.7;
  color: #d8def0;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 220px;
  overflow: auto;
}

/* ---------- history ---------- */
.history { animation: rise 0.5s ease both; }
.history .result-head { margin-bottom: 14px; }
.ghost.small { padding: 6px 12px; font-size: 12.5px; border-radius: 9px; }

.history-list { display: flex; flex-direction: column; gap: 10px; }
.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(8, 12, 28, 0.45);
  transition: border-color 0.18s, background 0.18s;
}
.history-item:hover { border-color: var(--border-strong); background: rgba(8, 12, 28, 0.65); }
.history-main { flex: 1; min-width: 0; }
.history-text {
  margin: 0 0 4px;
  font-size: 13.5px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 11.5px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.history-actions { display: flex; gap: 6px; flex: none; }
.hbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text-dim);
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s, background 0.15s, transform 0.15s;
}
.hbtn:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-strong); transform: translateY(-1px); }
.hbtn.play:hover { color: var(--accent2); border-color: rgba(34, 211, 238, 0.35); }
.hbtn.fill:hover { color: var(--success); border-color: rgba(52, 211, 153, 0.35); }
.hbtn.danger:hover { color: var(--danger); border-color: rgba(251, 113, 133, 0.35); background: rgba(251, 113, 133, 0.08); }
.history-empty {
  padding: 26px 14px;
  text-align: center;
  font-size: 13.5px;
  color: var(--text-faint);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
}

/* ---------- credits ---------- */
.credits {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
}
.credits-info { display: flex; align-items: flex-start; gap: 14px; }
.credits-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 13px;
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.18), rgba(251, 113, 133, 0.18));
  border: 1px solid rgba(251, 191, 36, 0.3);
  color: var(--warn);
}
.credits h2 { margin: 0 0 3px; font-size: 16px; font-weight: 800; }
.credits p { margin: 0 0 10px; font-size: 13px; color: var(--text-dim); }
.provider-badges { display: flex; flex-wrap: wrap; gap: 7px; }
.provider-badges span {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-dim);
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.soon-pill {
  flex: none;
  font-size: 12px;
  font-weight: 800;
  color: #7a5cff;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid rgba(124, 108, 255, 0.4);
  background: rgba(124, 108, 255, 0.12);
}

/* ---------- footer ---------- */
footer {
  max-width: 860px;
  margin: 0 auto;
  padding: 8px 20px 42px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-faint);
}
.dot { margin: 0 8px; }

/* ---------- misc ---------- */
[hidden] { display: none !important; }
::selection { background: rgba(124, 108, 255, 0.4); }

@keyframes rise {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- responsive ---------- */
@media (max-width: 720px) {
  .container, .topbar { padding-left: 14px; padding-right: 14px; }
  .hero { padding-top: 30px; }
  .row2, .detail-grid { grid-template-columns: 1fr; }
  .segmented { flex-wrap: wrap; }
  .seg { flex: 1 1 40%; }
  .credits { flex-direction: column; align-items: flex-start; }
  .brand-name { font-size: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- topbar right / user ---------- */
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.user-area { display: flex; align-items: center; }
.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--grad);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 12px;
  flex: none;
}
.user-info { display: flex; flex-direction: column; line-height: 1.25; }
.user-name {
  font-size: 12.5px;
  font-weight: 700;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-quota { font-size: 11px; color: var(--text-dim); white-space: nowrap; }
.user-logout {
  border: 0;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 2px 5px;
  border-radius: 6px;
}
.user-logout:hover { color: var(--danger); background: rgba(251, 113, 133, 0.12); }

/* ---------- auth modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(6px);
  padding: 20px;
}
.modal {
  width: 100%;
  max-width: 400px;
  background: linear-gradient(180deg, var(--surface-strong), var(--surface));
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.modal-head h3 { margin: 0; font-size: 18px; }
.modal-close {
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 8px;
}
.modal-close:hover { color: var(--text); background: var(--surface); }
.auth-oauth { display: flex; flex-direction: column; gap: 10px; }
.oauth-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 11px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s;
}
.oauth-btn:hover { background: rgba(255, 255, 255, 0.08); }
.oauth-logo {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 800;
  font-size: 12px;
  flex: none;
}
.oauth-btn.google .oauth-logo { background: #fff; color: #4285f4; }

/* ---------- packages / top-up ---------- */
.package-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.package-card {
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
  transition: border-color 0.18s, transform 0.18s;
}
.package-card:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.package-name { font-size: 13px; color: var(--text-dim); font-weight: 600; }
.package-credits { font-size: 26px; font-weight: 850; line-height: 1.1; }
.package-credits-label { font-size: 12px; color: var(--text-faint); font-weight: 600; margin-bottom: 8px; }
.package-price { color: var(--accent2); font-weight: 700; font-size: 15px; margin-top: 2px; }
.package-per { color: var(--text-faint); font-size: 12px; font-weight: 600; margin: 2px 0 8px; }
.package-card .primary { margin-top: 4px; }
.package-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
  width: 100%;
}
.package-actions .primary { margin-top: 0; flex: 1; min-width: 0; }
.pay-hint { color: var(--text-faint); font-size: 12.5px; margin: 14px 0 0; }
