:root {
  --bg: var(--tg-theme-bg-color, #f3f4f6);
  --fg: var(--tg-theme-text-color, #111827);
  --muted: var(--tg-theme-hint-color, #6b7280);
  --card: var(--tg-theme-secondary-bg-color, #ffffff);
  --accent: var(--tg-theme-button-color, #2481cc);
  --accent-fg: var(--tg-theme-button-text-color, #ffffff);
  --border: rgba(0, 0, 0, 0.06);
  --gold: #f4b400;
  --good: #10b981;
  --bad: #ef4444;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

#app {
  max-width: 540px;
  margin: 0 auto;
  padding: 16px 14px 96px;
}

.hello h1 {
  margin: 8px 0 2px;
  font-size: 24px;
}

.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin: 12px 0;
  border: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.card-title {
  font-weight: 600;
  font-size: 16px;
}

.badge {
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.06);
  color: var(--muted);
}

.badge.gold {
  background: linear-gradient(135deg, #fde68a, #f4b400);
  color: #5b3a00;
  font-weight: 600;
}

.badge.premium {
  background: linear-gradient(135deg, #fde68a, #f4b400);
  color: #5b3a00;
  font-weight: 600;
}

.meter {
  height: 10px;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 999px;
  overflow: hidden;
}

.bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), #5fb3ff);
  transition: width 0.4s ease;
}

.bar.full { background: var(--bad); }
.bar.warn { background: var(--gold); }
.bar.premium { background: linear-gradient(90deg, #f4b400, #fde68a); width: 100%; }

#plan-meter-label {
  margin: 8px 0 0;
}

.notes {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
}

.notes li {
  font-size: 13px;
  color: var(--muted);
  margin: 2px 0;
}

.cta {
  background: linear-gradient(160deg, #fffbeb, #fff);
  border-color: rgba(244, 180, 0, 0.25);
}

.features {
  list-style: none;
  padding: 0;
  margin: 8px 0 14px;
}

.features li {
  margin: 4px 0;
  font-size: 14px;
}

/* Buttons and button-like links share the same shape and rhythm */
button,
a.primary,
a.secondary {
  font: inherit;
  border-radius: 10px;
  padding: 11px 16px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  transition: opacity 0.15s, transform 0.05s;
  display: inline-block;
  text-decoration: none;
  text-align: center;
  box-sizing: border-box;
  line-height: 1.2;
}

button:active,
a.primary:active,
a.secondary:active { transform: scale(0.98); }
button[disabled] { opacity: 0.5; cursor: not-allowed; }

.primary {
  background: var(--accent);
  color: var(--accent-fg);
  width: 100%;
}

.secondary {
  background: rgba(0, 0, 0, 0.06);
  color: var(--fg);
  flex: 1;
}

/* When .primary lives inside a .row it should flex like .secondary, not span 100% */
.row .primary { width: auto; flex: 1; }

.row {
  display: flex;
  gap: 8px;
  margin: 10px 0 0;
}

.row .primary { flex: 1; }

.ref-link {
  background: rgba(0, 0, 0, 0.05);
  padding: 8px 10px;
  border-radius: 8px;
  margin: 10px 0 0;
  overflow-x: auto;
  white-space: nowrap;
}

.ref-link code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
}

.list {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  max-height: 280px;
  overflow-y: auto;
}

.list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.list li:last-child { border-bottom: none; }

.history-fmt {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
}

.history-date {
  color: var(--muted);
  font-size: 12px;
}

.history-status.ok { color: var(--good); }
.history-status.err { color: var(--bad); }

footer {
  text-align: center;
  margin-top: 20px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 80px;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 100;
  animation: toast-fade 0.2s ease;
}

@keyframes toast-fade {
  from { opacity: 0; transform: translate(-50%, 6px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.card.highlight {
  animation: card-pulse 1.6s ease;
  border-color: var(--accent);
}

@keyframes card-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(36, 129, 204, 0.55); }
  60%  { box-shadow: 0 0 0 14px rgba(36, 129, 204, 0); }
  100% { box-shadow: 0 0 0 0 rgba(36, 129, 204, 0); }
}
