/* Token system — colors come from Telegram's live theme (set in app.js from
   Telegram.WebApp.themeParams) so the mini app always matches the person's
   actual Telegram skin (light/dark/custom). The values below are fallbacks
   for previewing this page in a plain browser, not the intended look. */
:root {
  --bg: #15131c;
  --bg-secondary: #1e1c28;
  --text: #f2eef7;
  --hint: #948fa8;
  --accent: #9b8afb;      /* moonlit violet — Lynnie's signature */
  --accent-2: #e6a4c9;    /* warm rose highlight, used sparingly */
  --divider: #2a2735;
  --danger: #ef6a6a;
  --ok: #6fcf97;
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
}

.brand {
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.who {
  font-size: 13px;
  color: var(--hint);
}

main#view {
  flex: 1;
  padding: 4px 16px 90px;
}

/* ---- native-list rows, matching Telegram's own settings screens ---- */
.section {
  margin: 18px 0;
}

.section-title {
  font-size: 13px;
  color: var(--hint);
  padding: 0 4px 6px;
}

.list {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  overflow: hidden;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--divider);
}
.row:last-child { border-bottom: none; }

.row-label { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.row-title { font-size: 15px; font-weight: 500; }
.row-sub { font-size: 12.5px; color: var(--hint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.row-value { font-size: 14px; color: var(--hint); flex-shrink: 0; }

/* ---- toggle switch, Telegram-style ---- */
.switch {
  position: relative;
  width: 46px;
  height: 27px;
  flex-shrink: 0;
}
.switch input { display: none; }
.switch .track {
  position: absolute;
  inset: 0;
  background: var(--divider);
  border-radius: 999px;
  transition: background 0.15s ease;
  cursor: pointer;
}
.switch .thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 23px;
  height: 23px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s ease;
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track .thumb { transform: translateX(19px); }

/* ---- dashboard stat cards (colored top border), console-style ---- */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.stat-card {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  border-top: 3px solid var(--accent);
  padding: 18px 14px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.stat-card.c-teal { border-top-color: #5fd6c4; }
.stat-card.c-orange { border-top-color: #e8a84f; }
.stat-card.c-green { border-top-color: #6fcf97; }
.stat-card.c-red { border-top-color: var(--danger); }
.stat-icon { font-size: 20px; }
.stat-value { font-size: 26px; font-weight: 700; letter-spacing: -0.01em; }
.stat-value.state-on { color: var(--ok); }
.stat-value.state-off { color: var(--hint); }
.stat-label { font-size: 11.5px; color: var(--hint); letter-spacing: 0.02em; }

.uptime-card {
  grid-column: 1 / -1;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 18px 14px;
  text-align: center;
}
.uptime-value { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.uptime-label { font-size: 11.5px; color: var(--hint); margin-top: 4px; letter-spacing: 0.02em; }

/* ---- quick command grid (toggle buttons) ---- */
.qc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.qc-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  padding: 16px 10px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-family: var(--font);
  color: var(--text);
}
.qc-btn .qc-icon { font-size: 22px; }
.qc-btn .qc-label { font-size: 13px; font-weight: 500; }
.qc-btn.is-on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.qc-btn:active { opacity: 0.75; }

/* ---- cards for hub items (shop / inventory) ---- */
.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.item-card {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.item-emoji { font-size: 26px; }
.item-name { font-size: 14px; font-weight: 600; }
.item-desc { font-size: 12px; color: var(--hint); }
.item-price { font-size: 13px; color: var(--accent-2); font-weight: 600; margin-top: auto; }

/* ---- headline balance block ---- */
.balance-hero {
  padding: 22px 4px 6px;
}
.balance-amount {
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.balance-label {
  color: var(--hint);
  font-size: 13px;
  margin-top: 2px;
}

/* ---- leaderboard ---- */
.lb-row { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-bottom: 1px solid var(--divider); }
.lb-row:last-child { border-bottom: none; }
.lb-rank { width: 22px; text-align: center; color: var(--hint); font-size: 13px; font-variant-numeric: tabular-nums; }
.lb-name { flex: 1; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-coins { font-size: 14px; color: var(--accent-2); font-variant-numeric: tabular-nums; }

/* ---- tab bar ---- */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: var(--bg-secondary);
  border-top: 1px solid var(--divider);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1;
  border: none;
  background: none;
  color: var(--hint);
  font-family: var(--font);
  font-size: 12.5px;
  padding: 10px 0 8px;
  cursor: pointer;
}
.tab.active { color: var(--accent); }

/* ---- misc ---- */
.empty {
  color: var(--hint);
  font-size: 13.5px;
  padding: 24px 6px;
  text-align: center;
}

textarea, input[type="text"] {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--divider);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  padding: 10px 12px;
  resize: vertical;
}

.btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
}
.btn.secondary {
  background: var(--bg-secondary);
  color: var(--text);
  border: 1px solid var(--divider);
}

.picker {
  width: 100%;
  background: var(--bg-secondary);
  color: var(--text);
  border: 1px solid var(--divider);
  border-radius: 10px;
  padding: 10px 12px;
  font-family: var(--font);
  font-size: 14px;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
