:root {
  /* Page surfaces — pale cool gray, no gradient */
  --bg: #f6f6fb;
  --surface: #ffffff;
  --surface-soft: #f3f3fa;
  --surface-softer: #fafafd;

  /* Ink */
  --ink: #1a1632;
  --ink-soft: #5b5775;
  --ink-muted: #8e8aab;
  --line: #ebeaf3;
  --line-strong: #d8d6e8;

  /* Dual-anchor color system: purple = brand, coral+teal = energy/progress, gold = premium */
  --brand: #6841ff;          /* deeper purple — primary action */
  --brand-2: #5732e8;        /* gradient end */
  --brand-soft: #b6a4ff;     /* tints, focus rings */
  --brand-ink: #4422c2;      /* readable purple text */
  --brand-bg: #ede8ff;       /* subtle brand background tint */

  --coral: #ff5e7e;          /* streaks, urgent energy */
  --coral-soft: #ffd6e0;
  --coral-deep: #d6395a;

  --teal: #2ec5b8;           /* progress, secondary success */
  --teal-soft: #d6f5f1;
  --teal-deep: #16887e;

  --gold: #f5b300;           /* premium / achievement */
  --gold-soft: #fff1c8;
  --gold-deep: #a37700;

  --good: #2ec27e;
  --danger: #ef5a72;

  /* Legacy aliases kept so older selectors still work */
  --accent: var(--coral);
  --amber: var(--gold);
  --sky: #5b9eff;
  --warn: var(--gold);

  --shadow-sm: 0 1px 2px rgba(28, 24, 48, 0.04), 0 2px 6px rgba(28, 24, 48, 0.04);
  --shadow-md: 0 6px 18px rgba(76, 55, 184, 0.10);
  --shadow-lg: 0 14px 40px rgba(76, 55, 184, 0.16);

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --radius-xl: 28px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 18px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  color: #fff;
  box-shadow: var(--shadow-md);
}
.brand h1 {
  font-size: 17px;
  margin: 0;
  letter-spacing: -0.01em;
  font-weight: 600;
  color: var(--ink-soft);
}
.greeting {
  margin: 0 0 1px;
  color: var(--ink-soft);
  font-size: 11px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  font-weight: 600;
}
/* ---------- Auth screen ---------- */
.auth-screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px 16px;
  background:
    radial-gradient(900px 500px at -10% -10%, #efe9ff, transparent 60%),
    radial-gradient(800px 460px at 110% 0%, #ffe1ef, transparent 60%),
    radial-gradient(900px 600px at 50% 110%, #e0f2ff, transparent 55%),
    var(--bg);
  overflow-y: auto;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 28px 24px;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255,255,255,0.8);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.auth-brand {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.auth-mark {
  width: 60px;
  height: 60px;
  border-radius: 18px;
  background: linear-gradient(135deg, #efe7ff, #ffd6e7);
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-md);
  animation: bob 3.4s ease-in-out infinite;
}
.auth-brand h1 {
  margin: 4px 0 0;
  font-size: 22px;
  letter-spacing: -0.015em;
}
.auth-tagline {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
}
.auth-tabs {
  display: flex;
  gap: 4px;
  background: var(--surface-soft);
  border-radius: 999px;
  padding: 4px;
  border: 1px solid var(--line);
}
.auth-tab {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 700;
  padding: 9px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.auth-tab.is-active {
  background: var(--surface);
  color: var(--brand-ink);
  box-shadow: var(--shadow-sm);
}
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.auth-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.auth-field label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
}
.auth-field input {
  border: 1px solid var(--line);
  background: var(--surface-soft);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.auth-field input::placeholder { color: var(--ink-muted); }
.auth-field input:focus {
  border-color: var(--brand-soft);
  background: var(--surface);
  box-shadow: 0 0 0 4px rgba(124, 92, 255, 0.12);
}
.auth-error {
  margin: 0;
  font-size: 12px;
  color: var(--danger);
  background: rgba(239, 90, 114, 0.08);
  border: 1px solid rgba(239, 90, 114, 0.2);
  padding: 8px 10px;
  border-radius: 10px;
}
.auth-submit {
  height: 44px;
  width: 100%;
  margin-top: 4px;
}
.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}
.auth-divider::before, .auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}
.google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  padding: 11px 14px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.google-btn:hover { background: var(--surface-soft); border-color: var(--brand-soft); }
.google-btn:active { transform: translateY(1px); }
.auth-foot {
  margin: 4px 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-muted);
}
.auth-lang-select {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 22px 5px 10px;
  border-radius: 999px;
  cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'><path d='M3 4.5L6 8l3-3.5' fill='none' stroke='%238e8ba8' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 10px;
}

/* ---------- User menu ---------- */
.user-menu {
  position: relative;
}
.user-menu summary {
  list-style: none;
  cursor: pointer;
}
.user-menu summary::-webkit-details-marker { display: none; }
.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 4px;
  transition: border-color 0.15s ease;
}
.user-menu[open] .user-pill, .user-pill:hover { border-color: var(--line-strong); }
.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: grid;
  place-items: center;
}
.user-menu-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 6px;
  min-width: 220px;
  box-shadow: var(--shadow-lg);
  z-index: 50;
}
.user-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 10px 12px 8px;
  margin: 0 0 6px;
  border-bottom: 1px solid var(--line);
}
.user-info strong { font-size: 13px; color: var(--ink); }
.user-info span { font-size: 11px; color: var(--ink-muted); }
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: transparent;
  border: none;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 600;
  padding: 9px 12px;
  border-radius: 9px;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s ease, color 0.12s ease;
}
.menu-item:hover { background: var(--surface-soft); color: var(--ink); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover { background: rgba(239, 90, 114, 0.08); }
.menu-item.admin-item {
  color: var(--teal-deep);
  background: var(--teal-soft);
  border: 1px solid rgba(46, 197, 184, 0.3);
  margin-bottom: 4px;
}
.menu-item.admin-item:hover { background: rgba(46, 197, 184, 0.18); color: var(--teal-deep); }

/* ---------- Owner Dashboard ---------- */
.admin-card {
  max-width: 720px;
  width: 95vw;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  padding: 22px 22px 18px;
}
.admin-head { text-align: center; }
.admin-card h2 { margin: 0 0 4px; font-size: 22px; }
.admin-sub {
  margin: 0 0 14px;
  color: var(--ink-muted);
  font-size: 11.5px;
  line-height: 1.4;
}
.admin-tabs {
  display: flex;
  gap: 4px;
  background: var(--surface-soft);
  border-radius: 999px;
  padding: 4px;
  border: 1px solid var(--line);
  margin: 0 auto 14px;
  width: fit-content;
}
.admin-tab {
  background: transparent;
  border: none;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.admin-tab.is-active {
  background: var(--surface);
  color: var(--brand-ink);
  box-shadow: var(--shadow-sm);
}
.admin-panel {
  flex: 1 1 auto;
  overflow-y: auto;
  text-align: left;
  padding-right: 4px;
}
/* KPI grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
  margin-bottom: 18px;
}
.kpi {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
}
.kpi-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
  color: var(--ink-muted);
  margin-bottom: 4px;
}
.kpi-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.kpi-delta {
  font-size: 11px;
  font-weight: 700;
  margin-top: 4px;
}
.kpi-delta.up { color: var(--good); }
.kpi-delta.down { color: var(--danger); }
.kpi.accent { background: linear-gradient(135deg, var(--brand-bg), #ffe9f3); border-color: var(--brand-soft); }
.kpi.gold { background: var(--gold-soft); border-color: var(--gold); }
.kpi.gold .kpi-value { color: var(--gold-deep); }

/* Sections inside panel */
.admin-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 14px;
}
.admin-section h3 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
}
/* Bar chart */
.bar-chart { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: flex; align-items: center; gap: 8px; }
.bar-label {
  min-width: 90px;
  font-size: 12px;
  color: var(--ink-soft);
  font-weight: 600;
}
.bar-track {
  flex: 1;
  background: var(--surface-soft);
  border-radius: 999px;
  height: 14px;
  overflow: hidden;
  position: relative;
}
.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand), var(--accent));
  border-radius: 999px;
}
.bar-value {
  min-width: 36px;
  text-align: right;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
}
/* Sparkline (daily signups) */
.sparkline {
  display: flex;
  align-items: end;
  gap: 2px;
  height: 60px;
  padding: 4px 0;
}
.sparkline-bar {
  flex: 1;
  background: linear-gradient(180deg, var(--brand), var(--brand-soft));
  border-radius: 2px 2px 0 0;
  min-height: 2px;
  transition: opacity 0.2s ease;
}
.sparkline-bar:hover { opacity: 0.7; }
.sparkline-axis {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--ink-muted);
  margin-top: 4px;
}
/* Table */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.admin-table th, .admin-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}
.admin-table th {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table .num {
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
/* Promo admin form */
.promo-admin-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.promo-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.promo-cond-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
.promo-field { display: flex; flex-direction: column; gap: 4px; }
.promo-field label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
}
.promo-field input, .promo-field select {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--ink);
  outline: none;
}
.promo-field input:focus, .promo-field select:focus {
  border-color: var(--brand-soft);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.12);
}
.promo-field-inline { align-self: end; }
.promo-submit {
  align-self: flex-start;
  padding: 9px 18px;
  font-size: 13px;
}
.promo-admin-table th, .promo-admin-table td {
  padding: 7px 8px;
  font-size: 12px;
}
.promo-row-btn {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 8px;
  margin-left: 4px;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.promo-row-btn:hover { background: var(--brand-bg); color: var(--brand-ink); }
.promo-row-btn.danger { color: var(--danger); }
.promo-row-btn.danger:hover { background: rgba(239, 90, 114, 0.1); }

.demo-badge {
  display: inline-block;
  font-size: 9px;
  text-transform: uppercase;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--gold-soft);
  color: var(--gold-deep);
  margin-left: 4px;
  vertical-align: middle;
}
@media (max-width: 480px) {
  .admin-card { padding: 18px 16px 14px; }
  .admin-tabs { width: 100%; overflow-x: auto; justify-content: flex-start; }
  .kpi { padding: 10px 12px; }
  .kpi-value { font-size: 18px; }
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Trial badge in topbar */
.trial-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: linear-gradient(135deg, #fff2cc, #ffd76b);
  border: 1px solid #f0c34a;
  color: #8a5d00;
  font-size: 11px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}
.trial-badge:hover { box-shadow: 0 3px 8px rgba(240, 195, 74, 0.4); transform: translateY(-1px); }
.trial-badge:active { transform: translateY(0); }
.trial-badge.expired {
  background: linear-gradient(135deg, #ffe1e8, #ffb6c8);
  border-color: #ef5a72;
  color: #b8294a;
}
.trial-badge.premium {
  background: linear-gradient(135deg, #efe7ff, #c9b5ff);
  border-color: var(--brand-soft);
  color: var(--brand-ink);
}

/* Upgrade item in user menu */
.menu-item.upgrade-item {
  color: #b87800;
  background: linear-gradient(135deg, rgba(255, 215, 107, 0.18), rgba(245, 159, 0, 0.1));
  border: 1px solid rgba(240, 195, 74, 0.4);
  margin-bottom: 4px;
}
.menu-item.upgrade-item:hover {
  background: linear-gradient(135deg, rgba(255, 215, 107, 0.28), rgba(245, 159, 0, 0.16));
  color: #8a5d00;
}
.user-plan {
  display: inline-flex !important;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  font-size: 10px !important;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
}
.user-plan.premium { color: #b87800; }
.user-plan.trial { color: #8a5d00; }
.user-plan.expired { color: var(--danger); }

/* ---------- Paywall modal ---------- */
.paywall-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px 16px;
  background: rgba(28, 24, 48, 0.55);
  backdrop-filter: blur(8px);
  z-index: 100;
  overflow-y: auto;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.paywall-card {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 28px 24px 22px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: rise 0.3s cubic-bezier(.2,.7,.2,1);
}
@keyframes rise { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.paywall-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: var(--surface-soft);
  color: var(--ink-muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.15s ease, color 0.15s ease;
}
.paywall-close:hover { background: var(--line); color: var(--ink); }
.paywall-crown {
  width: 80px;
  height: 80px;
  margin: 0 auto 8px;
  border-radius: 24px;
  background: linear-gradient(135deg, #fff8e1, #ffe7b3);
  display: grid;
  place-items: center;
  box-shadow: 0 8px 20px rgba(245, 159, 0, 0.25);
  animation: bob 3.4s ease-in-out infinite;
}
.paywall-card h2 {
  margin: 4px 0 6px;
  font-size: 22px;
  letter-spacing: -0.01em;
}
.paywall-sub {
  margin: 0 0 16px;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.45;
}
.paywall-features {
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.paywall-features li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-soft);
  padding: 4px 0;
}
.paywall-features li::before {
  content: "";
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--good);
  flex: 0 0 auto;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M5 12.5l4.5 4.5L19 7' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-size: 14px;
  background-position: center;
  background-repeat: no-repeat;
}
/* 3-plan picker */
.plans {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.plan-pick {
  position: relative;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 14px 8px 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: border-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease, background 0.15s ease;
  text-align: center;
  min-width: 0;
}
.plan-pick:hover { border-color: var(--brand-soft); }
.plan-pick:active { transform: translateY(1px); }
.plan-pick.is-active {
  border-color: var(--brand);
  background: linear-gradient(180deg, rgba(124, 92, 255, 0.05), rgba(255, 143, 184, 0.05));
  box-shadow: 0 4px 12px rgba(124, 92, 255, 0.18);
}
.plan-pick .plan-name {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  margin-top: 2px;
}
.plan-pick.is-active .plan-name { color: var(--brand-ink); }
.plan-pick .plan-price {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--ink);
  line-height: 1.1;
  display: inline-flex;
  align-items: baseline;
  gap: 1px;
}
.plan-pick .plan-price small {
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-muted);
}
.plan-pick .plan-note {
  font-size: 10px;
  color: var(--ink-muted);
  font-weight: 600;
}
.plan-pick .plan-badge {
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--brand), #6a47ff);
  color: #fff;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(106, 71, 255, 0.4);
}
.plan-pick .plan-badge ~ .plan-name { margin-top: 6px; }
@media (max-width: 380px) {
  .plan-pick .plan-price { font-size: 16px; }
}
.paypal-container {
  min-height: 48px;
  margin-bottom: 8px;
}

/* Promo code section */
.promo-section {
  margin-bottom: 12px;
  border-top: 1px dashed var(--line);
  padding-top: 10px;
}
.promo-toggle {
  cursor: pointer;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--brand-ink);
  padding: 4px 8px;
  border-radius: 8px;
  user-select: none;
  transition: background 0.12s ease;
}
.promo-toggle:hover { background: var(--surface-soft); }
.promo-toggle::-webkit-details-marker { display: none; }
.promo-input-row {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.promo-input-row input {
  flex: 1;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.promo-input-row input:focus {
  border-color: var(--brand-soft);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.12);
  background: var(--surface);
}
.promo-apply {
  background: var(--brand);
  color: #fff;
  border: none;
  padding: 0 14px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease;
}
.promo-apply:hover { background: var(--brand-2); }
.promo-message {
  margin: 8px 0 0;
  font-size: 12px;
  padding: 8px 10px;
  border-radius: 8px;
  font-weight: 600;
}
.promo-message.ok {
  background: rgba(46, 194, 126, 0.1);
  color: var(--good);
}
.promo-message.err {
  background: rgba(239, 90, 114, 0.08);
  color: var(--danger);
}
.paywall-secure {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin: 6px 0 4px;
  font-size: 11px;
  color: var(--ink-muted);
}
.paywall-error {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--danger);
  background: rgba(239, 90, 114, 0.08);
  border-radius: 8px;
  padding: 8px 10px;
  text-align: left;
}
.paywall-later {
  background: transparent;
  border: none;
  color: var(--ink-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 8px;
  margin-top: 4px;
  border-radius: 8px;
}
.paywall-later:hover { color: var(--ink-soft); background: var(--surface-soft); }

@media (max-width: 480px) {
  .paywall-card { padding: 24px 18px 18px; }
  .paywall-card h2 { font-size: 19px; }
  .plan-price-big { font-size: 24px; }
}
.lang-select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 600;
  padding: 7px 26px 7px 10px;
  border-radius: 999px;
  cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'><path d='M3 4.5L6 8l3-3.5' fill='none' stroke='%238e8ba8' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 10px;
  transition: border-color 0.15s ease, color 0.15s ease;
  max-width: 130px;
}
.lang-select:hover { border-color: var(--line-strong); color: var(--ink); }
.lang-select:focus { outline: none; border-color: var(--brand-soft); box-shadow: 0 0 0 4px rgba(124,92,255,0.12); }

.ghost-btn {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.ghost-btn:hover { color: var(--ink); border-color: var(--line-strong); }
.ghost-btn:active { transform: translateY(1px); }

/* ---------- Pet Card ---------- */
.pet-card {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-xl);
  padding: 16px 18px 18px;
  box-shadow: var(--shadow-md);
  background:
    linear-gradient(180deg, #f3eeff 0%, #f9e7f1 70%, #fdf1f6 100%);
  border: 1px solid rgba(255, 255, 255, 0.6);
}

.pet-card-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.pet-card-bg .cloud {
  position: absolute;
  background: radial-gradient(closest-side, rgba(255, 255, 255, 0.55), transparent 70%);
  border-radius: 50%;
  filter: blur(2px);
  animation: drift 18s ease-in-out infinite;
}
.cloud-1 { width: 110px; height: 60px; top: 40px;  left: -40px; animation-duration: 22s; }
.cloud-2 { width:  80px; height: 50px; top: 110px; right: -30px; animation-duration: 28s; animation-direction: reverse; }
.cloud-3 { width: 140px; height: 70px; top:  10px; left: 55%;   animation-duration: 32s; }
.pet-card-bg .ground {
  position: absolute;
  bottom: -20px;
  left: -10%;
  right: -10%;
  height: 90px;
  background: radial-gradient(60% 100% at 50% 0%, rgba(180, 160, 255, 0.28), transparent 70%);
}

@keyframes drift {
  0%   { transform: translateX(0); }
  50%  { transform: translateX(12px); }
  100% { transform: translateX(0); }
}

.pet-head {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  z-index: 2;
}
.pet-identity { display: flex; flex-direction: column; gap: 1px; }
.pet-name {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--ink);
  line-height: 1;
}
.pet-stage-label {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.pet-stage-label .dot { color: var(--ink-muted); }
#petStageName { color: var(--brand-ink); }

.pet-mood-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.8);
  color: var(--brand-ink);
  letter-spacing: 0.01em;
  backdrop-filter: blur(6px);
}

.pet-canvas {
  position: relative;
  height: 280px;
  display: grid;
  place-items: end center;
  margin: 4px 0 12px;
  z-index: 1;
}
.pet-aura {
  position: absolute;
  width: 200px;
  height: 200px;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(124, 92, 255, 0.22), transparent 70%);
  filter: blur(2px);
  animation: aura 4s ease-in-out infinite;
}
@keyframes aura {
  0%, 100% { transform: translateX(-50%) scale(1); opacity: 0.7; }
  50% { transform: translateX(-50%) scale(1.07); opacity: 1; }
}
.pet-container {
  position: relative;
  width: 220px;
  aspect-ratio: 200 / 260;
  display: grid;
  place-items: center;
  animation: bob 3.4s ease-in-out infinite;
  cursor: grab;
}
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
.pet-container svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 14px 18px rgba(76, 55, 184, 0.22));
}
.pet-container svg .pet-eyes {
  transform-origin: center 50%;
  animation: blink 5.5s ease-in-out infinite;
}
@keyframes blink {
  0%, 92%, 100% { transform: scaleY(1); }
  94%, 96%      { transform: scaleY(0.1); }
}
@keyframes wiggle {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(-6deg); }
  40% { transform: rotate(5deg); }
  60% { transform: rotate(-3deg); }
  80% { transform: rotate(2deg); }
}
.pet-container.wiggle { animation: wiggle 0.6s ease; }
.pet-emote {
  position: absolute;
  top: 6px;
  right: 18px;
  font-size: 22px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.pet-emote.show { opacity: 1; transform: translateY(0); }

.pet-bar {
  position: relative;
  z-index: 2;
}
.pet-bar-track {
  height: 10px;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  overflow: hidden;
  backdrop-filter: blur(6px);
}
.pet-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--brand), var(--accent));
  border-radius: 999px;
  transition: width 0.55s cubic-bezier(.2,.7,.2,1);
  box-shadow: 0 1px 3px rgba(124, 92, 255, 0.4) inset;
}
.pet-bar-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 12px;
  color: var(--ink-soft);
}
.next-stage { color: var(--brand-ink); font-weight: 600; }

/* Stage progression track — mini pet silhouettes */
.stage-track {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  padding: 0 2px;
}
.stage-node {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: help;
  color: rgba(124, 92, 255, 0.25); /* not-yet, grayscale-ish purple */
  transition: color 0.3s ease, transform 0.2s ease;
}
.stage-mini {
  display: inline-block;
  width: 26px;
  height: 26px;
}
.stage-mini svg { display: block; width: 100%; height: 100%; }
.stage-node.passed { color: var(--brand-soft); }
.stage-node.current {
  color: var(--brand);
  transform: scale(1.35);
}
.stage-connector {
  flex: 1;
  height: 2px;
  background: var(--line-strong);
  margin: 0 -1px;
  border-radius: 1px;
}
.stage-connector.passed { background: var(--brand-soft); }

/* Pet action chips below pet card */
.pet-actions {
  position: relative;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}
.pet-action {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.85);
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
  backdrop-filter: blur(6px);
}
button.pet-action:hover { transform: translateY(-1px); box-shadow: 0 3px 8px rgba(76, 55, 184, 0.15); }
.pet-action.ascend-btn {
  background: linear-gradient(135deg, var(--gold-soft), #ffe7b3);
  border-color: var(--gold);
  color: var(--gold-deep);
  box-shadow: 0 3px 10px rgba(245, 179, 0, 0.3);
}
.pet-action.spinner-btn {
  position: relative;
  background: linear-gradient(135deg, var(--brand-bg), #d9c8ff);
  border-color: var(--brand-soft);
  color: var(--brand-ink);
}
.pet-action-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--coral);
  color: #fff;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  font-size: 9px;
  display: grid;
  place-items: center;
}
.pet-action.coins-pill { color: var(--gold-deep); background: var(--gold-soft); border-color: var(--gold); cursor: default; }
.pet-action.freeze-pill { color: #2b6dd6; background: #d8eef9; border-color: #5b9eff; cursor: default; }
.pet-action.season-pill { background: rgba(255, 215, 107, 0.3); border-color: rgba(245, 179, 0, 0.5); color: var(--gold-deep); cursor: default; }

/* Pet emotion overlays */
.pet-emotion-bubble {
  position: absolute;
  top: 16px;
  left: 16px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.95);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-soft);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  z-index: 5;
  backdrop-filter: blur(6px);
  animation: bobble 2s ease-in-out infinite;
}
@keyframes bobble {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

/* Ascension card */
.ascend-card { text-align: center; }
.ascend-glow {
  width: 90px;
  height: 90px;
  margin: 0 auto 8px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(closest-side, var(--gold-soft), transparent 70%);
  filter: drop-shadow(0 0 16px rgba(245, 179, 0, 0.5));
  animation: aura 2.5s ease-in-out infinite;
}

/* Daily spinner */
.spinner-card { text-align: center; }
.spinner-wheel {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 8px auto 12px;
}
.spinner-disc {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: conic-gradient(
    var(--brand) 0deg 51deg,
    var(--coral) 51deg 90deg,
    var(--teal) 90deg 141deg,
    var(--gold) 141deg 180deg,
    #b6a4ff 180deg 231deg,
    #7cdf9a 231deg 270deg,
    #ff8557 270deg 321deg,
    #5b9eff 321deg 360deg
  );
  border: 6px solid #fff;
  box-shadow: 0 4px 16px rgba(76, 55, 184, 0.25), inset 0 0 30px rgba(0,0,0,0.08);
  transition: transform 2.5s cubic-bezier(.22,1,.36,1);
}
.spinner-needle {
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 18px solid var(--ink);
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.2));
  z-index: 2;
}
.spinner-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: #fff;
  display: grid;
  place-items: center;
  font-size: 22px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.spinner-result {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 800;
  color: var(--ink);
  min-height: 24px;
}
.spinner-foot { font-size: 11px; color: var(--ink-muted); margin: 8px 0 0; }

/* Journal card */
.journal-card { text-align: left; max-width: 480px; }
.journal-card h2, .journal-card .paywall-sub { text-align: center; }
.journal-list {
  list-style: none;
  padding: 0;
  margin: 14px 0 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 60vh;
  overflow-y: auto;
}
.journal-list li {
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface-soft);
  border-left: 3px solid var(--brand-soft);
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-soft);
}
.journal-list li .journal-date {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--ink-muted);
  margin-bottom: 4px;
}
.journal-empty { color: var(--ink-muted); text-align: center; padding: 20px; }

/* League card */
.league-card { text-align: left; max-width: 440px; }
.league-card h2, .league-card .paywall-sub { text-align: center; }
.league-list {
  list-style: none;
  padding: 0;
  margin: 14px 0 0;
  counter-reset: rank;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.league-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--surface-soft);
  font-size: 13px;
  border: 1px solid var(--line);
}
.league-list li::before {
  counter-increment: rank;
  content: counter(rank);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--line);
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}
.league-list li:nth-child(1)::before { background: var(--gold); color: #fff; }
.league-list li:nth-child(2)::before { background: #d6d6e3; color: var(--ink); }
.league-list li:nth-child(3)::before { background: #d4a574; color: #fff; }
.league-list li.you {
  background: var(--brand-bg);
  border-color: var(--brand-soft);
  font-weight: 700;
}
.league-name { flex: 1; }
.league-streak {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--coral);
  font-weight: 700;
}

/* Species switcher */
.species-card { text-align: center; }
.species-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 14px;
}
.species-pick {
  border: 1.5px solid var(--line);
  background: var(--surface);
  border-radius: 14px;
  padding: 12px 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
  position: relative;
}
.species-pick:hover:not([disabled]) { border-color: var(--brand); transform: translateY(-2px); }
.species-pick.is-active {
  border-color: var(--brand);
  background: var(--brand-bg);
  box-shadow: 0 4px 12px rgba(104, 65, 255, 0.15);
}
.species-pick[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}
.species-pick[disabled]::after {
  content: "🔒";
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 10px;
}
.species-circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
}
.species-name { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink); }

/* Toast */
.toast-wrap {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}
.toast {
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s cubic-bezier(.2,.8,.2,1);
  white-space: nowrap;
}
.toast.toast-out { animation: toastOut 0.4s ease forwards; }
.toast.toast-good { background: var(--good); }
.toast.toast-gold { background: var(--gold-deep); }
.toast.toast-brand { background: var(--brand); }
.toast.toast-danger { background: var(--danger); }
@keyframes toastIn {
  from { transform: translateY(-20px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
@keyframes toastOut {
  to { transform: translateY(-20px); opacity: 0; }
}

/* ---------- Pet Stats ---------- */
.pet-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.stat {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  gap: 10px;
  align-items: center;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(255, 255, 255, 0.8);
  transition: transform 0.15s ease;
}
.stat:hover { transform: translateY(-1px); }
.stat-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}
.stat-streak .stat-icon { background: rgba(255, 143, 184, 0.16); color: var(--accent); }
.stat-total .stat-icon  { background: rgba(46, 194, 126, 0.16); color: var(--good); }
.stat-today .stat-icon  { background: rgba(124, 92, 255, 0.16); color: var(--brand); }
.stat-label {
  display: block;
  font-size: 10.5px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 600;
  margin-bottom: 1px;
  white-space: nowrap;
}
.stat-value {
  font-size: 22px;
  font-weight: 800;
  display: block;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.stat-value small {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-muted);
  margin-left: 3px;
  letter-spacing: 0;
}

/* ---------- Habits ---------- */
.habits {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 14px;
  border: 1px solid rgba(255, 255, 255, 0.8);
}
.habits-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.habits-head h2 {
  margin: 0;
  font-size: 16px;
  letter-spacing: -0.01em;
  font-weight: 700;
}
.today-label {
  font-size: 12px;
  color: var(--ink-muted);
  font-weight: 500;
}

.habit-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.habit-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-md);
  background: var(--surface-softer);
  border: 1px solid var(--line);
  position: relative;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.habit-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 12px;
  bottom: 12px;
  width: 3px;
  border-radius: 999px;
  background: var(--line-strong);
  transition: background 0.2s ease;
}
.habit-item.streak-mild::before  { background: linear-gradient(180deg, #ffb6c8, #ff8fb8); }
.habit-item.streak-warm::before  { background: linear-gradient(180deg, #ffb547, #ff8fb8); }
.habit-item.streak-hot::before   { background: linear-gradient(180deg, #ff6a4a, #ff3b8e); }
.habit-item.streak-blaze::before { background: linear-gradient(180deg, #ff3b3b, #ff8a00); box-shadow: 0 0 10px rgba(255, 90, 90, 0.5); }

.habit-item.done {
  background: linear-gradient(180deg, #eafaf2, #e2f6ec);
  border-color: #c5ecd6;
}
.habit-item.done::before { background: var(--good); }
.habit-item.done .habit-name {
  color: var(--ink-soft);
  text-decoration: line-through;
  text-decoration-color: rgba(46, 194, 126, 0.5);
  text-decoration-thickness: 2px;
}

.check-btn {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  background: #fff;
  color: transparent;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.12s ease;
}
.check-btn:hover { border-color: var(--brand-soft); }
.check-btn:active { transform: scale(0.93); }
.habit-item.done .check-btn {
  background: var(--good);
  border-color: var(--good);
  color: #fff;
  box-shadow: 0 4px 10px rgba(46, 194, 126, 0.35);
}

.habit-body {
  flex: 1 1 auto;
  min-width: 0;
}
.habit-name {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.005em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.habit-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--ink-muted);
}
.habit-streak {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
  color: var(--ink-muted);
}
.habit-streak svg { color: currentColor; opacity: 0.5; transition: opacity 0.2s ease; }
.habit-streak .streak-count { color: var(--ink-muted); }
/* Streak intensity */
.habit-streak.s-mild  { color: var(--accent); }
.habit-streak.s-warm  { color: #ff7a3b; }
.habit-streak.s-hot   { color: #ff3b3b; }
.habit-streak.s-blaze { color: #ff2566; }
.habit-streak.s-mild svg, .habit-streak.s-warm svg, .habit-streak.s-hot svg, .habit-streak.s-blaze svg { opacity: 1; }
.habit-streak.s-mild .streak-count,
.habit-streak.s-warm .streak-count,
.habit-streak.s-hot .streak-count,
.habit-streak.s-blaze .streak-count { color: var(--ink); }

.habit-total { color: var(--ink-muted); }
.habit-total .total-count { color: var(--ink-soft); font-weight: 600; }

.habit-schedule {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  padding: 3px 8px;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: 0.01em;
  background: var(--surface-soft);
  color: var(--ink-soft);
  border: 1px solid var(--line);
}
.habit-schedule::before {
  content: "";
  width: 12px;
  height: 12px;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  opacity: 0.75;
}
/* Per-type icon ONLY (no color variation) */
.habit-schedule.sched-daily::before {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235b5775' stroke-width='2.2' stroke-linecap='round'><circle cx='12' cy='12' r='4'/><path d='M12 3v2M12 19v2M3 12h2M19 12h2M5.6 5.6l1.4 1.4M17 17l1.4 1.4M5.6 18.4L7 17M17 7l1.4-1.4'/></svg>");
}
.habit-schedule.sched-weekdays::before {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235b5775' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><rect x='3' y='5' width='18' height='16' rx='2'/><path d='M3 10h18M8 3v4M16 3v4'/></svg>");
}
.habit-schedule.sched-biweekly::before {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235b5775' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><path d='M3 6h18M3 12h18M3 18h18'/></svg>");
}
.habit-schedule.sched-monthly::before {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235b5775' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><rect x='3' y='5' width='18' height='16' rx='2'/><path d='M8 3v4M16 3v4M3 10h18'/><circle cx='12' cy='15' r='1.5' fill='%235b5775' stroke='none'/></svg>");
}

.delete-btn {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--ink-muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  opacity: 0.5;
  transition: background 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}
.habit-item:hover .delete-btn { opacity: 1; }
.delete-btn:hover { background: #fde4e9; color: var(--danger); opacity: 1; }

.empty-state {
  padding: 22px 18px;
  text-align: center;
  color: var(--ink-soft);
  background: var(--surface-soft);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.empty-state p { margin: 0; font-size: 13px; }
.empty-state.subtle {
  background: transparent;
  color: var(--ink-muted);
}
.empty-illu {
  font-size: 32px;
  line-height: 1;
}

/* ---------- Other (not-today) section ---------- */
.other-section {
  border-top: 1px dashed var(--line);
  padding-top: 6px;
}
.other-section[open] { padding-bottom: 4px; }
.other-section summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 4px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 600;
  user-select: none;
}
.other-section summary::-webkit-details-marker { display: none; }
.other-count { color: var(--ink-muted); font-weight: 500; }
.other-section .chev {
  margin-left: auto;
  color: var(--ink-muted);
  transition: transform 0.2s ease;
}
.other-section[open] .chev { transform: rotate(180deg); }
.other-list { margin-top: 8px; }
.other-list .habit-item {
  background: transparent;
  border-style: dashed;
  opacity: 0.78;
}
.other-list .habit-item .check-btn {
  visibility: hidden;
  pointer-events: none;
}

/* ---------- Add panel (collapsible) ---------- */
.add-panel {
  border-top: 1px dashed var(--line);
  padding-top: 8px;
}
.add-trigger {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  border: 1px dashed var(--line-strong);
  color: var(--brand-ink);
  font-size: 13px;
  font-weight: 700;
  user-select: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.add-trigger::-webkit-details-marker { display: none; }
.add-trigger:hover {
  background: rgba(124, 92, 255, 0.06);
  border-color: var(--brand-soft);
}
.add-plus {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  font-size: 14px;
  line-height: 1;
  font-weight: 700;
}
.add-panel[open] .add-trigger {
  background: var(--surface);
  border-style: solid;
  border-color: var(--line-strong);
  color: var(--ink);
  margin-bottom: 12px;
}
.add-panel[open] .add-trigger .add-plus { transform: rotate(45deg); transition: transform 0.2s ease; }

/* ---------- Add form ---------- */
.add-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.add-row {
  display: flex;
  gap: 8px;
}

.add-form input {
  flex: 1 1 auto;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  border-radius: 999px;
  padding: 12px 16px;
  font-size: 14px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.add-form input::placeholder { color: var(--ink-muted); }
.add-form input:focus {
  border-color: var(--brand-soft);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(124, 92, 255, 0.12);
}

.primary-btn {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 0 18px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(106, 71, 255, 0.32);
  transition: transform 0.1s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
.primary-btn:hover { filter: brightness(1.04); }
.primary-btn:active { transform: translateY(1px); }

.schedule-picker {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.picker-label {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 700;
}
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.chip:hover { color: var(--ink); border-color: var(--line-strong); }
.chip:active { transform: translateY(1px); }
.chip.is-active {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  border-color: transparent;
  box-shadow: 0 3px 8px rgba(106, 71, 255, 0.28);
}
.day-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.day-chip {
  min-width: 40px;
  height: 34px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.day-chip:hover { color: var(--ink); border-color: var(--line-strong); }
.day-chip:active { transform: translateY(1px); }
.day-chip.is-active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

/* Month-day picker (grid 1–31) */
.month-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.month-day {
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease, transform 0.1s ease;
}
.month-day:hover { color: var(--ink); border-color: var(--line-strong); }
.month-day:active { transform: scale(0.95); }
.month-day.is-overflow {
  position: relative;
}
.month-day.is-overflow::after {
  content: "*";
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 10px;
  color: var(--warn);
  font-weight: 700;
}
.month-day.is-active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
  box-shadow: 0 2px 6px rgba(106, 71, 255, 0.3);
}
.month-day.is-active::after { color: #ffd166; }
.schedule-hint {
  margin: 0;
  font-size: 12px;
  color: var(--ink-muted);
}

.form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.form-label {
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--ink-muted);
}
.stepper {
  display: inline-flex;
  align-items: center;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px;
}
.step-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}
.step-btn:hover { background: #fff; color: var(--brand); }
.step-btn:active { transform: scale(0.94); }
.step-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.stepper-value {
  min-width: 42px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}

/* Multi-target check button */
.check-btn.is-multi {
  width: auto;
  min-width: 54px;
  height: 38px;
  border-radius: 19px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 800;
  color: var(--brand);
  letter-spacing: -0.01em;
}
.check-btn.is-multi.partial {
  background: rgba(124, 92, 255, 0.12);
  border-color: var(--brand-soft);
}
.habit-item.done .check-btn.is-multi {
  color: #fff;
  background: var(--good);
  border-color: var(--good);
}

/* ---------- Footer ---------- */
.footer {
  text-align: center;
  font-size: 12px;
  color: var(--ink-muted);
}
.footer p { margin: 0; }
#versionTag { opacity: 0.7; }

/* ---------- Pop/level-up animations ---------- */
@keyframes pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.18); }
  100% { transform: scale(1); }
}
.pop { animation: pop 0.4s ease; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}
.shake { animation: shake 0.3s ease; }

.sparkle {
  position: absolute;
  pointer-events: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand);
  opacity: 0;
  animation: sparkle 0.9s ease forwards;
}
@keyframes sparkle {
  0% { opacity: 1; transform: translate(0,0) scale(0.6); }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(1); }
}

/* Confetti for streak milestones */
.confetti {
  position: fixed;
  width: 10px;
  height: 14px;
  border-radius: 2px;
  pointer-events: none;
  z-index: 200;
  animation: confettiFall 1.6s cubic-bezier(.3,.6,.4,1) forwards;
}
@keyframes confettiFall {
  0%   { opacity: 1; transform: translate(0,0) rotate(0deg); }
  100% { opacity: 0; transform: translate(var(--cx), var(--cy)) rotate(var(--rot)); }
}

/* ---------- Mobile tweaks ---------- */
@media (max-width: 480px) {
  .app { padding: 14px 12px 32px; gap: 14px; }
  .pet-card { padding: 14px 14px 16px; border-radius: 22px; }
  .pet-canvas { height: 250px; margin: 2px 0 10px; }
  .pet-container { width: 190px; aspect-ratio: 200 / 260; }
  .pet-name { font-size: 16px; }
  .pet-mood-pill { font-size: 10px; padding: 4px 8px; }
  .stat-value { font-size: 15px; }
  .stat-icon { width: 30px; height: 30px; border-radius: 9px; }
  .stat-label { font-size: 10px; }
  .stat { padding: 10px; gap: 8px; border-radius: 12px; }
  .brand h1 { font-size: 17px; }
  .greeting { font-size: 10px; }
  .brand-mark { width: 36px; height: 36px; border-radius: 11px; }
  .topbar-actions { gap: 4px; }
  .lang-select { max-width: 90px; font-size: 11px; padding: 6px 22px 6px 8px; }
  .habits { padding: 16px; border-radius: 22px; gap: 12px; }
  .habits-head h2 { font-size: 15px; }
  .habit-item { padding: 10px; gap: 10px; }
  .habit-name { font-size: 14px; }
  .check-btn { width: 34px; height: 34px; }
  .check-btn.is-multi { min-width: 50px; height: 34px; border-radius: 17px; padding: 0 10px; }
  .stage-node { font-size: 9px; }
  .stage-track { padding: 0; }
  .add-form input { padding: 11px 14px; font-size: 13px; }
  .primary-btn { padding: 0 16px; font-size: 13px; }
  .month-day { font-size: 10px; border-radius: 7px; }
  .auth-card { padding: 24px 20px; }
  .auth-brand h1 { font-size: 20px; }
  .user-menu-panel { min-width: 200px; right: -4px; }
}
@media (max-width: 480px) {
  .pet-stats { gap: 8px; }
  .stat {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding: 10px 10px 12px;
    min-width: 0;
  }
  .stat-label { font-size: 9.5px; }
  .stat-value { font-size: 16px; }
  .stat-icon { width: 28px; height: 28px; border-radius: 8px; }
}
@media (max-width: 360px) {
  .stat-value { font-size: 14px; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15131f;
    --bg-grad-1: #271f48;
    --bg-grad-2: #3a1e3a;
    --bg-grad-3: #142243;
    --surface: #1f1c2e;
    --surface-soft: #25223a;
    --surface-softer: #1c1929;
    --ink: #f4f1ff;
    --ink-soft: #b6b2cf;
    --ink-muted: #8c88a8;
    --line: #2c2942;
    --line-strong: #3d3958;
    --brand-soft: #8b73ff;
    --brand-ink: #cdbcff;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3), 0 2px 8px rgba(0,0,0,0.25);
    --shadow-md: 0 8px 24px rgba(0,0,0,0.35);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.4);
  }
  .pet-card {
    background: linear-gradient(180deg, #2a2148 0%, #321935 70%, #2a1430 100%);
    border-color: rgba(255,255,255,0.05);
  }
  .pet-mood-pill { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.1); color: var(--brand-ink); }
  .pet-bar-track { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.1); }
  .habit-item.done {
    background: linear-gradient(180deg, #1f3a2c, #1a322a);
    border-color: #275642;
  }
  .add-form input:focus { background: var(--surface-soft); }
  .empty-state { background: var(--surface-soft); }
  .check-btn { background: var(--surface); }
  .delete-btn:hover { background: #43222b; }
  .add-trigger { background: var(--surface-soft); }
  .stat { border-color: rgba(255,255,255,0.05); }
  .habits { border-color: rgba(255,255,255,0.05); }
}
