:root {
  --bg: #0a0a0f;
  --surface: #13131b;
  --surface-2: #1b1b26;
  --line: #262633;
  --text: #ededf2;
  --muted: #9a9aab;
  --purple: #8b5cf6;
  --purple-soft: rgba(139, 92, 246, 0.16);
  --danger: #f87171;
  --ok: #4ade80;
  --radius: 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 16px; line-height: 1.45; }
body { min-height: 100vh; padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--bg); border-bottom: 1px solid var(--line); }
.topbar .title { font-weight: 600; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; border: 0; background: transparent; cursor: pointer; }
.icon-btn:active { background: var(--surface-2); }
.icon-btn svg { width: 24px; height: 24px; stroke: var(--text); fill: none; stroke-width: 1.8; stroke-linecap: round; }

/* drawer */
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); opacity: 0; pointer-events: none; transition: opacity 0.2s; z-index: 10; }
.scrim.open { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; bottom: 0; left: 0; width: min(84vw, 330px); background: var(--surface); border-right: 1px solid var(--line); transform: translateX(-102%); transition: transform 0.22s ease; z-index: 11; display: flex; flex-direction: column; padding: calc(16px + env(safe-area-inset-top)) 0 calc(16px + env(safe-area-inset-bottom)); }
.drawer.open { transform: none; }
.drawer .brand { display: flex; align-items: center; gap: 10px; padding: 0 20px 16px; font-weight: 700; font-size: 1.15rem; }
.drawer .section { padding: 12px 20px 6px; font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.drawer .list { overflow-y: auto; flex: 1; }
.nav-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 20px; background: transparent; border: 0; text-align: left; cursor: pointer; border-left: 3px solid transparent; }
.nav-item:active, .nav-item.active { background: var(--purple-soft); border-left-color: var(--purple); }
.nav-item .count { margin-left: auto; color: var(--muted); font-size: 0.85rem; }
.drawer .foot { border-top: 1px solid var(--line); }

/* layout */
.page { padding: 18px 16px 48px; max-width: 720px; margin: 0 auto; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card.accent { border-color: var(--purple); background: linear-gradient(180deg, var(--purple-soft), var(--surface)); }
.hero { padding: 36px 0 8px; }
.hero .logo { width: 56px; height: 56px; margin-bottom: 18px; }

/* forms */
label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 6px; }
input, select, textarea { width: 100%; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--purple); }
textarea { min-height: 84px; resize: vertical; }
select option { background: var(--surface-2); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 12px; padding: 13px 18px; font-weight: 600; cursor: pointer; background: var(--purple); color: #fff; }
.btn:active { filter: brightness(0.9); }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn.small { padding: 8px 12px; font-size: 0.85rem; border-radius: 10px; }
.btn.danger { background: transparent; border: 1px solid var(--danger); color: var(--danger); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; background: var(--purple-soft); color: #c4b5fd; font-size: 0.78rem; font-weight: 600; }
.pill.ok { background: rgba(74, 222, 128, 0.14); color: var(--ok); }
.pill.off { background: var(--surface-2); color: var(--muted); }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 0 -16px; padding: 0 16px; overflow-x: auto; }
.tab { padding: 12px 14px; background: transparent; border: 0; border-bottom: 2px solid transparent; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tab.active { color: var(--text); border-bottom-color: var(--purple); }

/* plans */
.plan { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.plan .price { font-size: 1.4rem; font-weight: 700; }
.plan.current { border-color: var(--purple); }

/* products */
.dropzone { border: 1.5px dashed #3a3a52; border-radius: var(--radius); padding: 22px; text-align: center; color: var(--muted); cursor: pointer; }
.dropzone.drag { border-color: var(--purple); background: var(--purple-soft); }
.meter { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--purple); }
.product { display: flex; gap: 12px; }
.thumb { width: 72px; height: 72px; border-radius: 12px; background: var(--surface-2); object-fit: cover; flex: none; display: grid; place-items: center; color: var(--muted); font-size: 0.75rem; }
.preview-box { background: var(--surface-2); border-radius: 12px; padding: 12px; white-space: pre-wrap; font-size: 0.92rem; }
.tag { color: #c4b5fd; }

/* chat demo */
.bubble { max-width: 86%; padding: 10px 14px; border-radius: 16px; font-size: 0.95rem; }
.bubble.me { align-self: flex-end; background: var(--purple); }
.bubble.bot { align-self: flex-start; background: var(--surface-2); }
.bubble .src { display: block; margin-top: 6px; font-size: 0.72rem; color: var(--muted); }
.chat { display: flex; flex-direction: column; gap: 8px; min-height: 120px; }

/* toast */
#toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); background: var(--surface-2); border: 1px solid var(--purple); padding: 10px 16px; border-radius: 12px; opacity: 0; pointer-events: none; transition: all 0.2s; z-index: 30; max-width: 90vw; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
