/* Dark-first. Telegram's themeParams are applied over these in app.js where
   they exist, so the app still looks right in a light client. */
:root {
  --bg: #0b0f14;
  --surface: #151c26;
  --surface-2: #1d2634;
  --line: #27313f;
  --text: #eef3f9;
  --muted: #8b97a8;
  --accent: #ff8a3d;
  --accent-2: #ff5e62;
  --good: #35c759;
  --radius: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}

.boot, .gate { padding: 64px 20px; text-align: center; color: var(--muted); }
.gate h2 { color: var(--text); font-size: 18px; margin: 0 0 8px; }

/* ── top bar ─────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 16px 10px;
  position: sticky; top: 0; z-index: 5;
  background: linear-gradient(var(--bg) 70%, transparent);
}
.brand { font-size: 19px; font-weight: 650; letter-spacing: -0.2px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--text); border-radius: 999px;
  padding: 7px 12px; font-size: 13px; font-weight: 600;
  cursor: pointer;
}
.pill-ghost { color: var(--muted); }
.gem { color: #4fc3f7; }
.wallet-tag {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #1a1004; border-radius: 999px;
  padding: 2px 9px; font-size: 12px; font-weight: 700;
}

main { padding: 0 16px; }

/* ── search ──────────────────────────────────────── */
.search {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 11px 14px; margin-bottom: 12px;
}
.search-icon { color: var(--muted); font-size: 17px; }
.search input {
  flex: 1; background: none; border: 0; outline: none;
  color: var(--text); font-size: 15px; min-width: 0;
}
.search input::placeholder { color: var(--muted); }

/* ── chips ───────────────────────────────────────── */
.chips {
  display: flex; gap: 8px; overflow-x: auto; padding-bottom: 12px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; border-radius: 999px; padding: 8px 15px;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer;
}
.chip.is-active { background: var(--text); color: #0b0f14; border-color: var(--text); }

/* ── cards ───────────────────────────────────────── */
.card {
  width: 100%; display: flex; align-items: center; gap: 13px; text-align: left;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; margin-bottom: 18px;
  color: var(--text); cursor: pointer;
}
.card-invite {
  background: linear-gradient(135deg, #2a1c3f, #1b2334);
  border-color: #3b2a55;
}
.card-icon { font-size: 24px; }
.card-body { flex: 1; min-width: 0; }
.card-title { font-weight: 650; display: flex; align-items: center; gap: 8px; }
.card-sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.card-chev { color: var(--muted); font-size: 20px; }
.badge {
  font-size: 11px; font-weight: 700; border-radius: 999px; padding: 2px 8px;
}
.badge-free { background: var(--accent); color: #1a1004; }
.card-daily .card-icon { filter: saturate(1.2); }
.card.is-done { opacity: .55; }
.card.is-done .badge { background: var(--line); color: var(--muted); }
.tag-new {
  margin-left: 6px; font-size: 9px; font-weight: 800; letter-spacing: .5px;
  background: var(--accent); color: #1a1004; border-radius: 4px; padding: 1px 4px;
}
.card-clone { margin-top: 18px; }

.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 4px 0 12px;
}
.section-head h2 { font-size: 17px; margin: 0; font-weight: 650; }

/* ── catalog grid ────────────────────────────────── */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.model {
  text-align: left; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 13px; color: var(--text); cursor: pointer;
}
.model-group { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .4px; }
.model-name { font-weight: 650; margin: 5px 0 9px; }
.model-foot { display: flex; align-items: center; justify-content: space-between; }
.price { color: var(--accent); font-weight: 700; font-size: 14px; }
.tag-free { font-size: 11px; color: var(--good); font-weight: 600; }

/* ── gallery ─────────────────────────────────────── */
.jobs { display: flex; flex-direction: column; gap: 8px; }
.job {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 13px; padding: 12px 14px;
}
.job-main { flex: 1; min-width: 0; }
.job-id { font-weight: 600; }
.job-date { color: var(--muted); font-size: 12px; margin-top: 2px; }
.status { font-size: 12px; font-weight: 700; border-radius: 999px; padding: 4px 10px; }
.s-completed { background: rgba(53,199,89,.14); color: var(--good); }
.s-failed { background: rgba(255,94,98,.14); color: var(--accent-2); }
.s-queued, .s-processing { background: rgba(255,138,61,.14); color: var(--accent); }

/* ── stats / account ─────────────────────────────── */
.stat-row { display: flex; gap: 10px; margin-bottom: 16px; }
.stat {
  flex: 1; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; text-align: center;
}
.stat-num { font-size: 21px; font-weight: 700; }
.stat-lbl { color: var(--muted); font-size: 12px; margin-top: 3px; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; margin: 0 0 16px; }
.kv dt { color: var(--muted); font-size: 14px; }
.kv dd { margin: 0; text-align: right; font-size: 14px; }

.linkbox {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 13px; font-size: 13px; word-break: break-all; margin-bottom: 12px;
}

.btn {
  width: 100%; border: 0; border-radius: 13px; padding: 14px;
  font-size: 15px; font-weight: 650; cursor: pointer;
}
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #1a1004; }
.btn-ghost { background: var(--surface); color: var(--text); border: 1px solid var(--line); }

.muted { color: var(--muted); font-size: 13px; }
.pad { margin: 0 0 14px; }
.empty { color: var(--muted); text-align: center; padding: 36px 10px; }

/* ── tab bar ─────────────────────────────────────── */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-around;
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
}
.tabbtn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: none; border: 0; color: var(--muted);
  font-size: 11px; font-weight: 600; cursor: pointer; padding: 4px 0;
}
.tabbtn span { font-size: 17px; line-height: 1; }
.tabbtn.is-active { color: var(--accent); }
.fab {
  flex: 0 0 auto; width: 52px; height: 52px; margin-top: -22px;
  border: 4px solid var(--bg); border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #1a1004; font-size: 26px; font-weight: 300; cursor: pointer;
}
