:root {
  --bg: #070912;
  --text: #eef1ff;
  --muted: rgba(226, 232, 255, .62);
  --glass: rgba(255, 255, 255, .07);
  --glass-strong: rgba(255, 255, 255, .12);
  --stroke: rgba(255, 255, 255, .14);
  --acc1: #7c5cff;
  --acc2: #22d3ee;
  --ok: #22c55e;
  --bad: #f43f5e;
  --warn: #f59e0b;
  --radius: 22px;
  --shadow: 0 10px 40px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #eef1fb; --text: #141834; --muted: rgba(20, 24, 52, .6);
    --glass: rgba(255, 255, 255, .55); --glass-strong: rgba(255, 255, 255, .75);
    --stroke: rgba(255, 255, 255, .8); --shadow: 0 10px 40px rgba(60, 70, 140, .15);
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #eef1fb; --text: #141834; --muted: rgba(20, 24, 52, .6);
  --glass: rgba(255, 255, 255, .55); --glass-strong: rgba(255, 255, 255, .75);
  --stroke: rgba(255, 255, 255, .8); --shadow: 0 10px 40px rgba(60, 70, 140, .15);
  color-scheme: light;
}
:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font-family: "Vazirmatn", system-ui, sans-serif; font-size: 15px; line-height: 1.6;
  overflow-x: hidden; padding-bottom: calc(96px + env(safe-area-inset-bottom));
}
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); margin: 0; font-size: 13px; }

/* ---------- animated background ---------- */
.bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; }
.blob { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .55; animation: float 18s ease-in-out infinite; }
.b1 { width: 360px; height: 360px; background: var(--acc1); top: -120px; right: -80px; }
.b2 { width: 300px; height: 300px; background: var(--acc2); bottom: 10%; left: -120px; animation-delay: -6s; }
.b3 { width: 260px; height: 260px; background: #ec4899; top: 40%; right: -100px; opacity: .35; animation-delay: -12s; }
.grain { position: absolute; inset: 0; background-image: radial-gradient(rgba(255,255,255,.06) 1px, transparent 1px); background-size: 3px 3px; opacity: .4; }
@keyframes float { 0%,100% { transform: translate(0,0) scale(1); } 33% { transform: translate(30px,40px) scale(1.08); } 66% { transform: translate(-20px,20px) scale(.95); } }

/* ---------- glass ---------- */
.glass {
  background: linear-gradient(135deg, var(--glass-strong), var(--glass));
  border: 1px solid var(--stroke); border-radius: var(--radius);
  backdrop-filter: blur(22px) saturate(160%); -webkit-backdrop-filter: blur(22px) saturate(160%);
  box-shadow: var(--shadow);
}
.pad { padding: 16px; }

/* ---------- header ---------- */
.top { position: sticky; top: 10px; z-index: 5; margin: 10px 16px 0; padding: 10px 14px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: .3px; }
.logo { font-size: 20px; filter: drop-shadow(0 0 10px rgba(124, 92, 255, .8)); }
.pill { display: flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 99px; background: rgba(255,255,255,.08); font-size: 12px; border: 1px solid var(--stroke); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.pill.on .dot { background: var(--ok); box-shadow: 0 0 10px var(--ok); animation: pulse 1.6s infinite; }
.pill.off .dot { background: var(--bad); }
.pill.wait .dot { background: var(--warn); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

main { padding: 16px; max-width: 560px; margin: 0 auto; }
.page { display: none; animation: in .35s ease; }
.page.active { display: block; }
@keyframes in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.sec-title { font-size: 14px; margin: 22px 4px 10px; font-weight: 700; color: var(--muted); }

/* ---------- hero ---------- */
.hero { display: flex; align-items: center; gap: 18px; padding: 20px; }
.ring-wrap { position: relative; width: 132px; height: 132px; flex: none; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: rgba(255,255,255,.1); stroke-width: 9; }
.ring-fg { fill: none; stroke: url(#rg); stroke-width: 9; stroke-linecap: round; stroke-dasharray: 327; stroke-dashoffset: 327; transition: stroke-dashoffset 1s cubic-bezier(.2,.8,.2,1); }
.power {
  position: absolute; inset: 22px; border-radius: 50%; border: 1px solid var(--stroke); cursor: pointer;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,.25), rgba(255,255,255,.04));
  display: grid; place-items: center; transition: transform .15s, box-shadow .3s;
}
.power:active { transform: scale(.94); }
.power svg { width: 38px; height: 38px; fill: none; stroke: var(--muted); stroke-width: 2.2; stroke-linecap: round; }
.power.on { box-shadow: 0 0 0 4px rgba(34,197,94,.15), 0 0 40px rgba(34,197,94,.55); }
.power.on svg { stroke: var(--ok); }
.power.busy { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.hero-info { min-width: 0; }
.days b { font-size: 40px; font-weight: 800; background: linear-gradient(90deg, var(--acc1), var(--acc2)); -webkit-background-clip: text; background-clip: text; color: transparent; line-height: 1; }
.days span { margin-right: 6px; color: var(--muted); font-size: 13px; }
.acct { margin-top: 6px; font-size: 13px; direction: ltr; text-align: right; opacity: .85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.cta { display: flex; gap: 12px; align-items: center; padding: 14px; margin-top: 14px; flex-wrap: wrap; }
.cta-icon { font-size: 28px; }
.cta > div { flex: 1; min-width: 160px; }

.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.tile { padding: 14px 6px; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 13px; cursor: pointer; border-radius: 18px; transition: transform .15s; }
.tile span { font-size: 22px; }
.tile:active { transform: scale(.96); }

/* ---------- lists & switches ---------- */
.list { padding: 4px 0; }
.row-switch { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; }
.list .row-switch + .row-switch { border-top: 1px solid rgba(255,255,255,.07); }
.row-switch .t { display: flex; flex-direction: column; }
.row-switch small { color: var(--muted); font-size: 12px; }
.form .row-switch { padding: 6px 0; }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch i { position: absolute; inset: 0; border-radius: 99px; background: rgba(255,255,255,.15); border: 1px solid var(--stroke); transition: .25s; cursor: pointer; }
.switch i::after { content: ""; position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: .25s cubic-bezier(.3,1.4,.6,1); box-shadow: 0 2px 6px rgba(0,0,0,.3); }
.switch input:checked + i { background: linear-gradient(90deg, var(--acc1), var(--acc2)); }
.switch input:checked + i::after { transform: translateX(-20px); }
.group-card { margin-bottom: 14px; }
.group-card h4 { margin: 0; padding: 14px 16px 4px; font-size: 14px; }

/* ---------- forms ---------- */
.form { display: flex; flex-direction: column; gap: 8px; }
.form label { font-size: 13px; color: var(--muted); margin-top: 6px; }
.form label small { opacity: .8; direction: ltr; display: inline-block; }
input, select, textarea {
  width: 100%; padding: 11px 14px; border-radius: 14px; border: 1px solid var(--stroke);
  background: rgba(0,0,0,.18); outline: none; transition: border .2s, box-shadow .2s; resize: vertical;
}
:root[data-theme="light"] input, :root[data-theme="light"] select, :root[data-theme="light"] textarea { background: rgba(255,255,255,.6); }
input:focus, select:focus, textarea:focus { border-color: var(--acc1); box-shadow: 0 0 0 3px rgba(124,92,255,.25); }
input[type=range] { padding: 0; accent-color: var(--acc1); background: none; border: 0; box-shadow: none; }
select option { background: #1b1e33; color: #fff; }
.inline { display: flex; gap: 8px; }
.inline input { min-width: 0; }

.btn { border: 1px solid var(--stroke); background: rgba(255,255,255,.1); border-radius: 14px; padding: 11px 16px; cursor: pointer; font-weight: 700; transition: transform .15s, filter .2s; white-space: nowrap; }
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(135deg, var(--acc1), var(--acc2)); border: 0; color: #fff; box-shadow: 0 6px 20px rgba(124,92,255,.35); }
.btn.success { background: linear-gradient(135deg, #16a34a, #22c55e); border: 0; color: #fff; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 8px 14px; }
.btn.big { padding: 14px; font-size: 16px; }
.form .btn { margin-top: 8px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 8px 12px; border-radius: 12px; border: 1px solid var(--stroke); background: rgba(255,255,255,.06); cursor: pointer; direction: ltr; font-size: 15px; }
.chip.sel { background: linear-gradient(135deg, var(--acc1), var(--acc2)); color: #fff; border-color: transparent; }

.flist { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.fitem { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 14px; background: rgba(255,255,255,.06); border: 1px solid var(--stroke); }
.fitem b { white-space: nowrap; }
.fitem span { flex: 1; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fitem button { background: none; border: 0; cursor: pointer; font-size: 16px; }

/* ---------- shop ---------- */
.shop-head { margin-bottom: 12px; }
.plans { display: grid; gap: 12px; margin-bottom: 14px; }
.plan { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 18px; cursor: pointer; position: relative; overflow: hidden; transition: transform .15s; }
.plan:active { transform: scale(.98); }
.plan::before { content: ""; position: absolute; inset: 0; background: linear-gradient(120deg, transparent 30%, rgba(255,255,255,.12) 50%, transparent 70%); transform: translateX(100%); transition: transform .8s; }
.plan:hover::before { transform: translateX(-100%); }
.plan h4 { margin: 0; font-size: 16px; }
.plan .price { text-align: left; }
.plan .price b { display: block; font-size: 17px; }
.plan .price s { color: var(--muted); font-size: 12px; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 99px; background: linear-gradient(90deg, #f59e0b, #ec4899); color: #fff; margin-right: 6px; }

/* ---------- tabs ---------- */
.tabs { position: fixed; bottom: calc(12px + env(safe-area-inset-bottom)); left: 16px; right: 16px; max-width: 528px; margin: 0 auto; display: flex; padding: 6px; z-index: 10; }
.tab { flex: 1; background: none; border: 0; padding: 8px 2px; border-radius: 16px; font-size: 12px; display: flex; flex-direction: column; align-items: center; cursor: pointer; color: var(--muted); transition: .2s; }
.tab span { font-size: 19px; }
.tab.active { background: rgba(255,255,255,.12); color: var(--text); }

/* ---------- modal / toast / loader ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 20; display: flex; align-items: flex-end; justify-content: center; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.sheet { width: 100%; max-width: 560px; border-radius: 26px 26px 0 0; padding: 12px 18px calc(22px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; animation: up .3s cubic-bezier(.2,.8,.2,1); }
@keyframes up { from { transform: translateY(100%); } }
.sheet h3 { margin: 4px 0 0; }
.sheet-handle { width: 42px; height: 5px; border-radius: 9px; background: var(--stroke); margin: 0 auto 6px; }
.invoice { display: flex; flex-direction: column; gap: 6px; padding: 12px; border-radius: 16px; background: rgba(0,0,0,.18); }
.invoice div { display: flex; justify-content: space-between; }
.invoice span { color: var(--muted); }

.toast { position: fixed; top: 70px; left: 50%; transform: translate(-50%, -20px); opacity: 0; z-index: 30; padding: 10px 18px; border-radius: 14px; background: rgba(20,22,40,.9); color: #fff; border: 1px solid var(--stroke); backdrop-filter: blur(10px); transition: .3s; pointer-events: none; max-width: calc(100% - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: rgba(120, 20, 40, .92); }

.gate { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; z-index: 40; background: var(--bg); }
.center { text-align: center; }
.big-emoji { font-size: 48px; }
.loader { position: fixed; inset: 0; display: grid; place-items: center; z-index: 35; background: var(--bg); transition: opacity .4s; }
.loader span { width: 44px; height: 44px; border-radius: 50%; border: 3px solid rgba(255,255,255,.15); border-top-color: var(--acc1); animation: spin .8s linear infinite; }
.loader.gone { opacity: 0; pointer-events: none; }

@media (max-width: 380px) {
  .hero { flex-direction: column; text-align: center; }
  .acct { text-align: center; }
}
