:root {
  --bg: #070a12;
  --bg2: #0e1424;
  --card: rgba(22, 28, 48, 0.72);
  --stroke: rgba(255, 255, 255, 0.08);
  --text: #f4f6ff;
  --muted: #9aa3bf;
  --primary: #7c5cff;
  --primary2: #5b8cff;
  --ok: #2fd39a;
  --warn: #ffb020;
  --err: #ff5d7a;
  --radius: 18px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: "SF Pro Display", "PingFang SC", "Noto Sans SC", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background: radial-gradient(1200px 600px at 10% -10%, #1a1240 0%, transparent 55%),
              radial-gradient(900px 500px at 100% 0%, #0d2a4a 0%, transparent 50%),
              var(--bg);
  min-height: 100dvh;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
.hidden { display: none !important; }
.center { text-align: center; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
.stack { display: flex; flex-direction: column; gap: 14px; }

.bg-glow {
  pointer-events: none;
  position: fixed; inset: 0;
  background: radial-gradient(500px 280px at 50% 0%, rgba(124,92,255,.18), transparent 70%);
  z-index: 0;
}
.page, .topbar, .auth-wrap, .footer { position: relative; z-index: 1; }

.glass {
  background: var(--card);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  position: sticky; top: 0; z-index: 20;
  background: rgba(7,10,18,.72);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--stroke);
}
.brand-inline { display: flex; gap: 10px; align-items: center; }
.logo-dot, .logo-orb {
  width: 34px; height: 34px; border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--primary2));
  box-shadow: 0 8px 24px rgba(124,92,255,.45);
}
.logo-orb { width: 48px; height: 48px; border-radius: 16px; }
.top-actions { display: flex; gap: 6px; align-items: center; }
.icon-btn, .linkish, .back {
  background: transparent; border: 0; color: var(--muted);
  padding: 8px 10px; border-radius: 10px; cursor: pointer;
}
.icon-btn:hover, .linkish:hover, .back:hover { color: var(--text); background: rgba(255,255,255,.05); }
.top-title { font-size: 16px; margin: 0; font-weight: 600; }

.page {
  width: min(720px, 100%);
  margin: 0 auto;
  padding: 16px 16px calc(28px + var(--safe-b));
  display: flex; flex-direction: column; gap: 16px;
}

.hero-mini { padding: 18px 18px 16px; border-radius: var(--radius); }
.hero-mini h1 { margin: 0 0 6px; font-size: 22px; letter-spacing: .2px; }
.hero-mini p { margin: 0; }

.tabs {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
  padding: 6px; border-radius: 14px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--stroke);
}
.tab {
  border: 0; background: transparent; color: var(--muted);
  padding: 10px 8px; border-radius: 10px; cursor: pointer; font-weight: 600;
}
.tab.active {
  color: var(--text);
  background: linear-gradient(135deg, rgba(124,92,255,.35), rgba(91,140,255,.25));
}

.card { border-radius: var(--radius); padding: 16px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field > span { font-size: 13px; color: var(--muted); font-weight: 600; }
.field input, .field textarea, .field select {
  width: 100%;
  background: rgba(0,0,0,.28);
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 12px 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field textarea { resize: vertical; min-height: 110px; }
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: rgba(124,92,255,.7);
  box-shadow: 0 0 0 3px rgba(124,92,255,.18);
}
.hint { color: var(--muted); font-size: 12px; }
.row-2 {
  display: grid; grid-template-columns: 1.4fr .8fr; gap: 12px; align-items: end;
}
@media (max-width: 520px) {
  .row-2 { grid-template-columns: 1fr; }
}

.switch-field {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 12px 14px; border-radius: 12px;
  background: rgba(0,0,0,.28); border: 1px solid var(--stroke); min-height: 48px;
}
.switch-field input { width: 18px; height: 18px; accent-color: var(--primary); }

.btn {
  border: 0; border-radius: 14px; padding: 12px 16px;
  font-weight: 700; cursor: pointer;
  transition: transform .12s, opacity .12s, box-shadow .12s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary {
  color: white;
  background: linear-gradient(135deg, var(--primary), var(--primary2));
  box-shadow: 0 12px 30px rgba(124,92,255,.35);
}
.btn-block { width: 100%; }
.btn-ghost {
  background: rgba(255,255,255,.06);
  border: 1px solid var(--stroke);
  color: var(--text);
}

.alert {
  border-radius: 12px; padding: 12px 14px; font-size: 14px;
  border: 1px solid transparent;
}
.alert-error { background: rgba(255,93,122,.12); border-color: rgba(255,93,122,.35); color: #ffd0d9; }
.alert-warn { background: rgba(255,176,32,.12); border-color: rgba(255,176,32,.35); color: #ffe2a8; }
.alert-ok { background: rgba(47,211,154,.12); border-color: rgba(47,211,154,.35); color: #c8ffe8; }

.progress-card {
  display: flex; gap: 14px; align-items: center;
}
.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.12);
  border-top-color: var(--primary);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.clips { display: grid; gap: 14px; }
.clip {
  display: grid; grid-template-columns: 88px 1fr; gap: 14px;
  padding: 14px; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--stroke);
}
.clip-cover {
  width: 88px; height: 88px; border-radius: 14px; object-fit: cover;
  background: linear-gradient(135deg, #2a2158, #1a3058);
}
.clip-body { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.clip-title { margin: 0; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clip audio { width: 100%; height: 36px; }
.clip-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.clip-actions a, .clip-actions button {
  font-size: 12px; padding: 8px 10px; border-radius: 10px;
}

.history-item {
  padding: 14px; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--stroke);
}
.history-item h3 { margin: 0 0 4px; font-size: 15px; }
.badge {
  display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: rgba(255,255,255,.06); color: var(--muted); margin-right: 6px;
}
.badge.ok { color: #b6ffe0; background: rgba(47,211,154,.15); }
.badge.fail { color: #ffd0d9; background: rgba(255,93,122,.15); }
.badge.run { color: #d7ccff; background: rgba(124,92,255,.18); }

.chip {
  display: inline-block; margin-left: 8px; font-style: normal;
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: rgba(47,211,154,.15); color: #b6ffe0;
}
.chip-warn { background: rgba(255,176,32,.15); color: #ffe2a8; }

.auth-wrap {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px;
}
.auth-card {
  width: min(420px, 100%);
  padding: 28px 22px;
  border-radius: 24px;
}
.brand-mark { display: flex; gap: 14px; align-items: center; margin-bottom: 18px; }
.brand-mark h1 { margin: 0; font-size: 24px; }
.brand-mark .muted { margin: 2px 0 0; }
.tip { margin-top: 16px; }
.check { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 14px; }
.check input { accent-color: var(--primary); }
.settings-form { gap: 16px; }
.footer { padding: 8px 16px 20px; opacity: .7; }

@media (min-width: 860px) {
  .page { padding-top: 22px; }
  .hero-mini h1 { font-size: 26px; }
  .clips { grid-template-columns: 1fr 1fr; }
  .clip { grid-template-columns: 1fr; }
  .clip-cover { width: 100%; height: 160px; }
}

/* ---- auth / account / admin extras ---- */
.row-code { display:flex; gap:10px; align-items:flex-end; }
.row-code .grow { flex:1; }
.btn-ghost {
  background: transparent; border:1px solid rgba(255,255,255,.18);
  color: var(--text, #e8ecff); border-radius: 12px; padding: 12px 14px; cursor:pointer;
}
.chip-credits {
  display:inline-flex; align-items:center; gap:4px; padding:6px 10px;
  border-radius:999px; background:rgba(124,92,255,.18); color:#d7ccff; text-decoration:none; font-size:13px;
}
.credits-big { font-size:1.25rem; }
.credits-big strong { color:#b7a6ff; font-size:1.6rem; }
.packages { display:grid; grid-template-columns: repeat(auto-fit,minmax(140px,1fr)); gap:10px; }
.pkg { border:1px solid rgba(255,255,255,.1); border-radius:14px; padding:12px; display:flex; flex-direction:column; gap:6px; }
.admin-page h2 { margin:0 0 8px; font-size:1.1rem; }
.admin-page h3 { margin:12px 0 6px; font-size:1rem; color:#c7b8ff; }
.table-wrap { overflow:auto; -webkit-overflow-scrolling:touch; }
table.data { width:100%; border-collapse:collapse; font-size:13px; }
table.data th, table.data td { padding:8px 6px; border-bottom:1px solid rgba(255,255,255,.08); text-align:left; white-space:nowrap; }
table.data th { color:#9aa3c7; font-weight:600; }
.alert-warn { background:rgba(255,186,73,.12); border:1px solid rgba(255,186,73,.35); color:#ffd59a; padding:10px 12px; border-radius:12px; }
