:root {
  color-scheme: dark;

  /* Surfaces */
  --bg: #0a0b12;
  --bg-soft: #10121c;
  --surface: rgba(22, 25, 38, 0.72);
  --surface-2: rgba(30, 34, 52, 0.6);
  --surface-solid: #161927;
  --stroke: rgba(255, 255, 255, 0.08);
  --stroke-strong: rgba(255, 255, 255, 0.16);

  /* Text */
  --text: #f3f5ff;
  --muted: #9aa2bd;
  --faint: #6b7290;

  /* Brand */
  --brand: #7b6bff;
  --brand-2: #a06bff;
  --brand-soft: rgba(123, 107, 255, 0.16);
  --accent: linear-gradient(135deg, #7b6bff 0%, #b06bff 55%, #ff7bd0 100%);
  --gold: #ffcc57;
  --gold-soft: rgba(255, 204, 87, 0.14);
  --success: #35e08a;
  --danger: #ff6b6b;

  /* FX */
  --radius: 22px;
  --radius-sm: 14px;
  --shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.65);
  --shadow-brand: 0 18px 40px -16px rgba(123, 107, 255, 0.55);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Ambient mesh gradient */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(60% 45% at 15% 0%, rgba(123, 107, 255, 0.28), transparent 60%),
    radial-gradient(50% 40% at 100% 5%, rgba(255, 123, 208, 0.18), transparent 55%),
    radial-gradient(70% 50% at 50% 100%, rgba(53, 224, 138, 0.08), transparent 60%),
    var(--bg);
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
::selection { background: var(--brand-soft); }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 999px; }

.app-shell {
  max-width: 940px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 20px 16px 108px;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  gap: 12px;
}
.brand-mark { display: flex; align-items: center; gap: 10px; }
.brand-logo {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: var(--accent);
  display: grid; place-items: center;
  font-size: 1.2rem;
  box-shadow: var(--shadow-brand);
}
.eyebrow {
  margin: 0 0 3px;
  color: var(--faint);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-weight: 600;
}
h1 { margin: 0; font-size: 1.25rem; letter-spacing: -0.02em; }
.header-actions { display: flex; gap: 8px; align-items: center; }

.balance-pill {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid rgba(255, 204, 87, 0.28);
  background: var(--gold-soft);
  color: var(--gold);
  padding: 9px 15px;
  border-radius: 999px;
  font-weight: 800;
  letter-spacing: -0.01em;
  transition: transform 0.15s var(--ease), box-shadow 0.2s var(--ease);
}
.balance-pill:hover { transform: translateY(-1px); box-shadow: 0 8px 20px -8px rgba(255,204,87,0.5); }
.balance-pill:active { transform: scale(0.96); }
.ghost-pill {
  border: 1px solid var(--stroke);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  padding: 9px 13px;
  border-radius: 999px;
  font-weight: 600;
  transition: background 0.15s var(--ease);
}
.ghost-pill:hover { background: rgba(255,255,255,0.09); }
.admin-only { background: rgba(255, 107, 107, 0.12); border-color: rgba(255, 107, 107, 0.28); color: #ffb4b4; }

/* ---------- Layout ---------- */
.content { display: flex; flex-direction: column; gap: 16px; animation: fadeUp 0.4s var(--ease); }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.panel {
  background: var(--surface);
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  padding: 18px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.panel h2, .panel h3 { margin: 0 0 6px; letter-spacing: -0.01em; }
.panel > p { color: var(--muted); margin: 0; line-height: 1.5; }

.section-title {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px; gap: 10px;
}
.section-title h2, .section-title h3 { margin: 0; }
.muted-link {
  color: var(--brand-2); font-weight: 600; font-size: 0.9rem;
  transition: opacity 0.15s var(--ease);
}
.muted-link:hover { opacity: 0.7; }
.muted-link.danger { color: var(--danger); }

/* ---------- Buttons ---------- */
.primary-btn, .secondary-btn {
  border-radius: 14px;
  padding: 12px 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  transition: transform 0.15s var(--ease), box-shadow 0.2s var(--ease), background 0.15s var(--ease);
}
.primary-btn {
  background: var(--accent);
  color: white;
  box-shadow: var(--shadow-brand);
}
.primary-btn:hover { transform: translateY(-2px); box-shadow: 0 22px 44px -16px rgba(123,107,255,0.7); }
.primary-btn:active { transform: scale(0.97); }
.secondary-btn {
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--stroke);
  color: var(--text);
}
.secondary-btn:hover { background: rgba(255,255,255,0.12); transform: translateY(-1px); }
.secondary-btn:active { transform: scale(0.97); }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  overflow: hidden;
  padding: 26px 22px;
  border: 1px solid var(--stroke-strong);
  background:
    radial-gradient(120% 120% at 0% 0%, rgba(123,107,255,0.4), transparent 55%),
    radial-gradient(120% 120% at 100% 100%, rgba(255,123,208,0.28), transparent 55%),
    var(--surface-solid);
}
.hero::after {
  content: '';
  position: absolute; top: -40%; right: -10%;
  width: 260px; height: 260px;
  background: radial-gradient(circle, rgba(255,204,87,0.22), transparent 70%);
  filter: blur(10px);
}
.hero .eyebrow { color: rgba(255,255,255,0.7); }
.hero h2 { font-size: 1.5rem; line-height: 1.2; margin-bottom: 8px; max-width: 22ch; }
.hero p { color: rgba(255,255,255,0.72); max-width: 40ch; }
.hero .actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; position: relative; }

/* ---------- Wallet card ---------- */
.wallet-card {
  background:
    radial-gradient(90% 120% at 100% 0%, rgba(255,204,87,0.16), transparent 60%),
    linear-gradient(135deg, rgba(123,107,255,0.14), rgba(255,123,208,0.1)),
    var(--surface-solid);
  border: 1px solid var(--stroke-strong);
}
.wallet-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.wallet-top .eyebrow { color: var(--faint); }
.wallet-balance { font-size: 2rem; font-weight: 800; letter-spacing: -0.03em; margin: 2px 0 0; }
.wallet-balance .star { color: var(--gold); }
.wallet-sub {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--stroke);
  color: var(--muted); font-size: 0.9rem;
}
.wallet-sub.active { color: var(--success); }

/* ---------- Quick actions row ---------- */
.quick-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.quick-btn {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 14px 8px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--stroke);
  color: var(--text);
  font-size: 0.76rem; font-weight: 600;
  transition: transform 0.15s var(--ease), background 0.15s var(--ease), border-color 0.15s var(--ease);
}
.quick-btn .qi { font-size: 1.3rem; }
.quick-btn:hover { transform: translateY(-3px); border-color: var(--stroke-strong); background: rgba(255,255,255,0.07); }
.quick-btn:active { transform: scale(0.95); }

/* ---------- Streak strip ---------- */
.streak-card {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  background:
    linear-gradient(120deg, rgba(255,140,60,0.16), rgba(255,204,87,0.08)),
    var(--surface-solid);
  border: 1px solid rgba(255, 170, 80, 0.24);
}
.streak-flame { font-size: 2rem; filter: drop-shadow(0 4px 12px rgba(255,140,60,0.5)); }
.streak-info { flex: 1; }
.streak-info strong { font-size: 1.05rem; }
.streak-info small { display: block; color: var(--muted); margin-top: 2px; }
.streak-dots { display: flex; gap: 5px; margin-top: 8px; }
.streak-dot { width: 9px; height: 9px; border-radius: 50%; background: rgba(255,255,255,0.14); }
.streak-dot.on { background: linear-gradient(135deg, #ff8c3c, var(--gold)); }

/* ---------- Category chips ---------- */
.chips-scroll {
  display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px;
  scrollbar-width: none;
}
.chips-scroll::-webkit-scrollbar { display: none; }
.option-chip {
  white-space: nowrap;
  padding: 9px 14px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--stroke);
  font-weight: 600; font-size: 0.85rem;
  transition: all 0.15s var(--ease);
}
.option-chip:hover { color: var(--text); border-color: var(--stroke-strong); }
.option-chip.active {
  color: white;
  background: var(--brand-soft);
  border-color: var(--brand);
  box-shadow: 0 4px 14px -6px var(--brand);
}

/* ---------- Shop grid ---------- */
.shop-grid { display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr); }
.shop-card {
  background: var(--surface-2);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex; flex-direction: column;
  transition: transform 0.18s var(--ease), border-color 0.18s var(--ease), box-shadow 0.2s var(--ease);
}
.shop-card:hover { transform: translateY(-4px); border-color: var(--stroke-strong); box-shadow: var(--shadow); }
.shop-preview {
  height: 104px;
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 10px;
  position: relative;
}
.shop-preview::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(120deg, rgba(255,255,255,0.2), transparent 55%);
}
.shop-preview .chip, .badge {
  position: relative; z-index: 1;
  padding: 5px 9px; border-radius: 999px;
  background: rgba(0,0,0,0.4); backdrop-filter: blur(6px);
  font-size: 0.7rem; font-weight: 700; color: white;
}
.badge-collection { background: rgba(255,204,87,0.9); color: #2a1e00; }
.shop-body { padding: 12px 13px 14px; display: flex; flex-direction: column; gap: 9px; flex: 1; }
.shop-body strong { font-size: 0.94rem; letter-spacing: -0.01em; }
.shop-body .desc { color: var(--faint); font-size: 0.8rem; line-height: 1.4; flex: 1; }
.price-row { display: flex; align-items: baseline; gap: 8px; }
.price-old { color: var(--faint); text-decoration: line-through; font-size: 0.8rem; }
.price-now { color: var(--gold); font-weight: 800; font-size: 1.02rem; }
.buy-btn {
  margin-top: 2px;
  padding: 10px; border-radius: 11px;
  background: rgba(123,107,255,0.16);
  border: 1px solid rgba(123,107,255,0.3);
  color: #cdc4ff; font-weight: 700; font-size: 0.86rem;
  transition: all 0.15s var(--ease);
}
.buy-btn:hover { background: var(--accent); color: white; border-color: transparent; box-shadow: var(--shadow-brand); }
.buy-btn:active { transform: scale(0.96); }

/* ---------- Collections ---------- */
.collection-banner {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 18px;
  border-radius: var(--radius-sm);
  background: linear-gradient(120deg, rgba(255,123,208,0.2), rgba(123,107,255,0.16));
  border: 1px solid var(--stroke-strong);
  cursor: pointer;
  transition: transform 0.15s var(--ease);
}
.collection-banner:hover { transform: translateY(-2px); }
.collection-banner .cb-emoji { font-size: 1.8rem; }
.collection-banner .cb-body { flex: 1; }
.collection-banner strong { display: block; }
.collection-banner small { color: var(--muted); }
.countdown { color: var(--gold); font-weight: 700; font-size: 0.82rem; }

/* ---------- Card / order rows ---------- */
.cards-grid { display: grid; gap: 10px; }
.card-item {
  background: var(--surface-2);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-sm);
  padding: 14px;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  transition: border-color 0.15s var(--ease);
}
.card-item:hover { border-color: var(--stroke-strong); }
.card-item .meta { color: var(--muted); font-size: 0.85rem; margin-top: 3px; }
.card-item .actions { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.status-pill {
  padding: 5px 11px; border-radius: 999px;
  font-size: 0.74rem; font-weight: 700; white-space: nowrap;
}
.status-ready { background: rgba(53, 224, 138, 0.16); color: var(--success); }
/* Countdown on a library row — same clock the recipient sees. */
.live-clock {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--success);
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(53, 224, 138, 0.1);
  border: 1px solid rgba(53, 224, 138, 0.28);
  white-space: nowrap;
}
.live-clock.urgent { color: var(--danger); background: rgba(255,107,107,0.1); border-color: rgba(255,107,107,0.35); }
.live-clock.dead   { color: var(--faint); background: var(--surface-2); border-color: var(--stroke); }
.status-anon { background: rgba(255,204,87,0.16); color: var(--gold); }
.status-cancelled { background: rgba(154, 162, 189, 0.16); color: var(--muted); }

/* ---------- Feed ---------- */
.feed-grid { display: grid; gap: 14px; }
.feed-card {
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--stroke);
  background: var(--surface-2);
}
.feed-art {
  padding: 22px 18px;
  min-height: 120px;
  display: flex; flex-direction: column; justify-content: space-between;
  position: relative;
  color: white;
}
.feed-art::after { content: ''; position: absolute; inset: 0; background: linear-gradient(150deg, rgba(255,255,255,0.16), transparent 55%); }
.feed-art .chip { position: relative; z-index: 1; align-self: flex-start; }
.feed-art p { position: relative; z-index: 1; margin: 12px 0 0; font-size: 1.02rem; font-weight: 600; line-height: 1.4; }
.feed-meta { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; gap: 10px; }
.feed-author { color: var(--muted); font-size: 0.85rem; }
.feed-author .myst { color: var(--brand-2); font-weight: 700; }
.reactions { display: flex; gap: 6px; flex-wrap: wrap; }
.react-btn {
  padding: 5px 10px; border-radius: 999px;
  background: rgba(255,255,255,0.06); border: 1px solid var(--stroke);
  font-size: 0.82rem; font-weight: 600; color: var(--text);
  transition: transform 0.12s var(--ease), background 0.15s var(--ease);
}
.react-btn:hover { background: rgba(255,255,255,0.12); transform: translateY(-1px); }
.react-btn:active { transform: scale(1.2); }
.guess-btn {
  padding: 5px 11px; border-radius: 999px;
  background: var(--brand-soft); border: 1px solid rgba(123,107,255,0.3);
  color: #cdc4ff; font-size: 0.8rem; font-weight: 700;
}

/* ---------- Forms ---------- */
.form-grid { display: grid; gap: 14px; }
.field label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 0.86rem; font-weight: 500; }
.field input, .field textarea, .field select {
  width: 100%;
  border: 1px solid var(--stroke);
  background: rgba(255,255,255,0.04);
  border-radius: 12px;
  padding: 12px 14px;
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none; border-color: var(--brand); background: rgba(123,107,255,0.06);
}
.field textarea { min-height: 96px; resize: vertical; }
.field small { display: block; margin-top: 5px; color: var(--faint); font-size: 0.78rem; }

.toggle-row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--stroke);
}
.toggle-row:first-of-type { border-top: 0; }
.toggle-row span { font-size: 0.92rem; }

/* iOS-style switch */
input[type="checkbox"].switch, .toggle-row input[type="checkbox"] {
  appearance: none; -webkit-appearance: none;
  width: 46px; height: 27px; border-radius: 999px;
  background: rgba(255,255,255,0.14); position: relative; cursor: pointer;
  transition: background 0.2s var(--ease); flex-shrink: 0;
}
.toggle-row input[type="checkbox"]::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 21px; height: 21px; border-radius: 50%; background: white;
  transition: transform 0.2s var(--ease);
}
.toggle-row input[type="checkbox"]:checked { background: var(--brand); }
.toggle-row input[type="checkbox"]:checked::after { transform: translateX(19px); }

/* ---------- Admin stats ---------- */
.stat-h {
  margin: 22px 0 10px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}
.stat-h:first-of-type { margin-top: 14px; }

.kpi-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.kpi {
  display: flex; flex-direction: column; gap: 2px;
  padding: 14px;
  background: var(--surface-2);
  border: 1px solid var(--stroke);
  border-left: 3px solid var(--stroke-strong);
  border-radius: var(--radius-sm);
}
.kpi-v { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.kpi-l { font-size: 0.82rem; color: var(--muted); }
.kpi-h { font-size: 0.72rem; color: var(--faint); }
.kpi.gold  { border-left-color: var(--gold); }
.kpi.gold .kpi-v { color: var(--gold); }
.kpi.green { border-left-color: var(--success); }
.kpi.green .kpi-v { color: var(--success); }
.kpi.warn  { border-left-color: var(--danger); }
.kpi.warn .kpi-v { color: var(--danger); }

.stat-note {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--stroke);
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--muted);
}
.stat-foot { margin-top: 20px; text-align: center; font-size: 0.72rem; color: var(--faint); }

.top-list { display: flex; flex-direction: column; gap: 8px; }
.top-row { display: flex; align-items: center; gap: 10px; font-size: 0.85rem; }
.top-rank {
  flex: 0 0 20px; height: 20px;
  display: grid; place-items: center;
  border-radius: 6px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 0.7rem; font-weight: 700;
}
.top-title { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-bar {
  flex: 0 0 72px; height: 6px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}
.top-bar i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.top-n { flex: 0 0 auto; color: var(--muted); font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- Ephemeral link duration picker ---------- */
.dur-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.dur-opt {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 11px 8px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--stroke);
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s var(--ease);
}
.dur-opt:hover { color: var(--text); border-color: var(--stroke-strong); }
.dur-opt.active {
  color: #fff;
  background: var(--brand-soft);
  border-color: var(--brand);
  box-shadow: 0 4px 14px -6px var(--brand);
}
.dur-opt .dur-h { font-weight: 700; font-size: 0.9rem; }
.dur-opt .dur-p { font-size: 0.75rem; opacity: 0.75; }
.dur-opt.active .dur-p { color: var(--gold); opacity: 1; }

/* ---------- Share link state on a library card ---------- */
.share-line {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin-top: 8px; font-size: 0.78rem; color: var(--faint);
}
.share-badge {
  padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--stroke); background: var(--surface-2);
  font-weight: 600;
}
.share-badge.sealed  { color: var(--gold);    border-color: rgba(255,204,87,0.3);  background: var(--gold-soft); }
.share-badge.live    { color: var(--success); border-color: rgba(53,224,138,0.3);  background: rgba(53,224,138,0.1); }
.share-badge.expired { color: var(--faint); }
.share-badge.revoked { color: var(--danger);  border-color: rgba(255,107,107,0.3); }

.total-row {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 14px; padding: 14px 16px;
  background: var(--gold-soft); border-radius: 12px;
  font-size: 1.02rem;
}
.total-row strong { color: var(--gold); font-size: 1.2rem; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.actions .primary-btn, .actions .secondary-btn { flex: 1; min-width: 120px; }

/* ---------- Referral ---------- */
.referral-card {
  background: linear-gradient(135deg, rgba(53,224,138,0.14), rgba(123,107,255,0.12)), var(--surface-solid);
  border: 1px solid var(--stroke-strong);
}
.ref-code-box {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-top: 12px; padding: 12px 16px;
  background: rgba(0,0,0,0.25); border: 1px dashed var(--stroke-strong);
  border-radius: 12px;
}
.ref-code { font-family: ui-monospace, monospace; font-size: 1.1rem; font-weight: 800; letter-spacing: 0.05em; }
.ref-stats { display: flex; gap: 20px; margin-top: 14px; }
.ref-stat .v { font-size: 1.3rem; font-weight: 800; }
.ref-stat .l { color: var(--muted); font-size: 0.8rem; }
.ref-friends { margin-top: 16px; border-top: 1px solid var(--stroke-strong); padding-top: 12px; }
.ref-friends-title { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 8px; }
.ref-friend { display: flex; align-items: center; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid rgba(255,255,255,0.05); }
.ref-friend:last-child { border-bottom: none; }
.rf-name { font-weight: 600; }
.rf-earned { color: var(--gold); font-weight: 700; font-size: 0.9rem; }
.ref-empty { color: var(--muted); font-size: 0.85rem; margin-top: 14px; }

/* ---------- Profile ---------- */
.profile-hero {
  display: flex; align-items: center; gap: 14px; margin-bottom: 6px;
}
.avatar {
  width: 58px; height: 58px; border-radius: 18px;
  background: var(--accent); display: grid; place-items: center;
  font-size: 1.5rem; font-weight: 800; color: white; box-shadow: var(--shadow-brand);
}
.role-badge {
  display: inline-block; padding: 4px 10px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 700; margin-top: 4px;
}
.role-badge.admin { background: rgba(255,107,107,0.16); color: #ffb4b4; }
.role-badge.user { background: var(--brand-soft); color: #b3a8ff; }
.info-list { margin: 12px 0 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.info-list li { display: flex; justify-content: space-between; color: var(--muted); font-size: 0.9rem; padding: 8px 0; border-top: 1px solid var(--stroke); }
.info-list li:first-child { border-top: 0; }
.info-list li b { color: var(--text); }

/* ---------- Notifications / tx ---------- */
.notification-list { display: grid; gap: 2px; }
.notification-item {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 13px 0;
  border-top: 1px solid var(--stroke);
}
.notification-item:first-child { border-top: 0; }
.notification-item small { display: block; color: var(--faint); margin-top: 3px; font-size: 0.8rem; }
.tx-amt { font-weight: 800; white-space: nowrap; }
.tx-positive { color: var(--success); }
.tx-negative { color: var(--danger); }

/* ---------- Admin ---------- */
.admin-section { margin-bottom: 22px; padding-bottom: 20px; border-bottom: 1px solid var(--stroke); }
.admin-section:last-child { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }
.template-grid { display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr); }
.template-card {
  background: var(--surface-2); border: 1px solid var(--stroke);
  border-radius: var(--radius-sm); padding: 12px;
}
.template-preview { height: 70px; border-radius: 10px; margin-bottom: 10px; position: relative; overflow: hidden; }
.template-preview::after { content: ''; position: absolute; inset: 0; background: linear-gradient(115deg, rgba(255,255,255,0.16), transparent 60%); }
.template-card strong { display: block; margin-bottom: 3px; }
.template-card small { color: var(--muted); font-size: 0.8rem; }
.template-actions { display: flex; gap: 12px; margin-top: 10px; }
.users-list { display: grid; gap: 8px; }
.user-item {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--stroke); border-radius: 12px;
}
.user-item .meta { color: var(--muted); font-size: 0.82rem; margin-top: 2px; }

/* ---------- Admin panel v2 ---------- */
.admin-title { font-size: 1.25rem; display: flex; align-items: center; gap: 8px; }
.admin-sub { color: var(--muted); margin: 4px 0 16px; }
.count-pill {
  font-size: 0.78rem; font-weight: 700; color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--stroke);
  border-radius: 999px; padding: 2px 9px;
}
.admin-back {
  display: inline-flex; align-items: center; gap: 4px; margin-bottom: 14px;
  background: none; border: none; color: var(--muted); font-size: 0.92rem;
  font-weight: 600; cursor: pointer; padding: 4px 0;
}
.admin-back:hover { color: var(--text); }

/* Hub tiles */
.admin-hub { display: grid; gap: 10px; margin-top: 6px; }
.admin-tile {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  padding: 16px; border-radius: 16px; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--stroke); color: var(--text);
  transition: transform 0.15s, border-color 0.15s, background 0.15s;
}
.admin-tile:hover { transform: translateY(-2px); border-color: var(--stroke-strong); background: rgba(255,255,255,0.06); }
.admin-tile:active { transform: scale(0.99); }
.at-icon { font-size: 1.6rem; width: 44px; height: 44px; display: grid; place-items: center; background: rgba(255,255,255,0.05); border-radius: 12px; flex: none; }
.at-text { flex: 1; display: flex; flex-direction: column; }
.at-text strong { font-size: 1.02rem; }
.at-text small { color: var(--muted); font-size: 0.82rem; margin-top: 2px; }
.at-badge { background: var(--gold-soft); color: var(--gold); font-weight: 800; font-size: 0.8rem; padding: 2px 9px; border-radius: 999px; }
.at-arrow { color: var(--faint); font-size: 1.3rem; }

/* Search */
.admin-search {
  width: 100%; margin-bottom: 12px; padding: 12px 14px; font-size: 0.95rem;
  border: 1px solid var(--stroke); background: rgba(255,255,255,0.04);
  border-radius: 12px; color: var(--text);
}
.admin-search:focus { outline: none; border-color: var(--brand); background: rgba(123,107,255,0.06); }

/* Category manager */
.admin-cat-list { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.admin-cat-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--stroke);
}
.admin-cat-row .cat-key {
  flex: none; min-width: 64px; max-width: 96px; font-size: 0.72rem; font-weight: 700;
  color: var(--muted); font-family: ui-monospace, monospace; overflow: hidden; text-overflow: ellipsis;
}
.admin-cat-row .cat-key-input {
  flex: none; width: 96px; padding: 8px 9px; font-size: 0.8rem; font-family: ui-monospace, monospace;
  border: 1px solid var(--stroke); background: rgba(255,255,255,0.04); border-radius: 9px; color: var(--text);
}
.admin-cat-row .cat-label-input {
  flex: 1; min-width: 0; padding: 9px 11px; font-size: 0.92rem;
  border: 1px solid var(--stroke); background: rgba(255,255,255,0.04); border-radius: 9px; color: var(--text);
}
.admin-cat-row .cat-key-input:focus, .admin-cat-row .cat-label-input:focus {
  outline: none; border-color: var(--brand); background: rgba(123,107,255,0.06);
}
.admin-cat-row .cat-count { flex: none; font-size: 0.78rem; color: var(--faint); min-width: 34px; text-align: right; }
.icon-btn {
  flex: none; width: 32px; height: 32px; display: grid; place-items: center; cursor: pointer;
  border-radius: 9px; border: 1px solid var(--stroke); background: rgba(255,255,255,0.04);
  color: var(--muted); font-size: 0.9rem; line-height: 1;
}
.icon-btn:hover:not(:disabled) { color: var(--text); border-color: var(--stroke-strong); }
.icon-btn.danger:hover:not(:disabled) { color: #ff6b6b; border-color: #ff6b6b; }
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* User rows are clickable buttons */
.admin-user-row { text-align: left; cursor: pointer; color: var(--text); }
.admin-user-row:hover { border-color: var(--stroke-strong); background: rgba(255,255,255,0.06); }
.admin-user-row .ui-left { flex: 1; }

/* User detail */
.ud-head { display: flex; align-items: center; gap: 14px; margin: 6px 0 18px; }
.ud-avatar {
  width: 52px; height: 52px; border-radius: 16px; flex: none;
  display: grid; place-items: center; font-size: 1.4rem; font-weight: 800; color: #fff;
  background: var(--accent);
}
.ud-head .role-badge { margin-top: 6px; }
.ud-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 16px; }
.ud-stat { background: var(--surface-2); border: 1px solid var(--stroke); border-radius: 12px; padding: 12px 8px; text-align: center; }
.ud-stat .v { font-weight: 800; font-size: 1.05rem; }
.ud-stat .l { color: var(--muted); font-size: 0.72rem; margin-top: 3px; }
.ud-actions { display: flex; gap: 10px; margin-bottom: 18px; }
.ud-actions button { flex: 1; }
.ud-block { border-top: 1px solid var(--stroke); padding-top: 14px; margin-top: 14px; }
.ud-block-title { font-weight: 700; margin-bottom: 10px; }
.ud-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,0.05); font-size: 0.9rem;
}
.ud-row:last-child { border-bottom: none; }
.ud-dim { color: var(--faint); font-weight: 400; }
.gold { color: var(--gold); font-weight: 700; }

/* Card management list */
.admin-card-list { display: grid; gap: 8px; }
.admin-card-row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; cursor: pointer;
  padding: 10px 12px; border-radius: 14px; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--stroke);
}
.admin-card-row:hover { border-color: var(--stroke-strong); background: rgba(255,255,255,0.06); }
.acr-preview { width: 46px; height: 46px; border-radius: 10px; flex: none; display: grid; place-items: center; font-size: 1.2rem; }
.acr-info { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.acr-info strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acr-info small { color: var(--muted); font-size: 0.8rem; margin-top: 2px; }
.acr-price { color: var(--gold); font-weight: 800; white-space: nowrap; }

/* Card editor live preview */
.card-preview-big {
  height: 130px; border-radius: 16px; margin-bottom: 16px; padding: 14px;
  position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end;
}
.card-preview-big::after { content: ''; position: absolute; inset: 0; background: linear-gradient(115deg, rgba(255,255,255,0.16), transparent 55%); }
.card-preview-big .chip {
  position: absolute; top: 12px; left: 12px; z-index: 1;
  background: rgba(0,0,0,0.32); color: #fff; font-size: 0.76rem; font-weight: 600;
  padding: 4px 10px; border-radius: 999px; backdrop-filter: blur(4px);
}
.cpb-title { position: relative; z-index: 1; color: #fff; font-weight: 800; font-size: 1.2rem; text-shadow: 0 2px 8px rgba(0,0,0,0.4); }
.editor-actions { display: flex; gap: 10px; margin-top: 16px; }
.editor-actions button { flex: 1; }
.secondary-btn.danger { color: #ff8497; border-color: rgba(255,132,151,0.4); }
.cover-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.cover-hint { color: var(--faint); font-size: 0.76rem; flex-basis: 100%; }
.ud-actions { flex-wrap: wrap; }
.ud-actions button { min-width: 130px; }

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%);
  width: min(94vw, 780px);
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px;
  padding: 7px; border-radius: 999px;
  background: rgba(10, 11, 18, 0.82);
  border: 1px solid var(--stroke-strong);
  backdrop-filter: blur(22px); -webkit-backdrop-filter: blur(22px);
  box-shadow: 0 16px 40px -12px rgba(0,0,0,0.7);
  z-index: 30;
}
.nav-item {
  color: var(--faint);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  border-radius: 999px; padding: 9px 4px; font-size: 0.68rem; font-weight: 600;
  transition: color 0.15s var(--ease), background 0.15s var(--ease);
}
.nav-item .ni { font-size: 1.15rem; }
.nav-item.active { color: white; background: var(--brand-soft); }
.nav-item:active { transform: scale(0.92); }

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(4, 5, 10, 0.72);
  backdrop-filter: blur(6px);
  display: grid; place-items: end center;
  padding: 0;
  animation: fade 0.2s var(--ease);
}
/* The `hidden` attribute must win over display:grid above, or the empty
   overlay dims/blurs the whole app. Higher specificity than `.modal`. */
.modal[hidden] { display: none; }
.toast[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  width: 100%; max-width: 560px;
  background: linear-gradient(180deg, rgba(28,32,48,0.98), rgba(14,16,24,0.99));
  border-radius: 28px 28px 0 0;
  padding: 10px 20px calc(24px + env(safe-area-inset-bottom));
  border: 1px solid var(--stroke-strong);
  box-shadow: 0 -20px 60px rgba(0,0,0,0.5);
  max-height: 92vh; overflow-y: auto;
  animation: slideUp 0.3s var(--ease);
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: none; } }
.modal-grabber { width: 40px; height: 4px; border-radius: 999px; background: rgba(255,255,255,0.2); margin: 0 auto 12px; }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.close-btn { color: var(--muted); font-size: 1.1rem; width: 34px; height: 34px; border-radius: 50%; background: rgba(255,255,255,0.06); }
.close-btn:hover { background: rgba(255,255,255,0.12); }
.envelope {
  min-height: 180px; border-radius: 20px; padding: 20px;
  display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden; color: white;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.2);
}
.envelope::before { content: ''; position: absolute; inset: 0; background: linear-gradient(150deg, rgba(255,255,255,0.22), transparent 56%); }
.envelope > * { position: relative; z-index: 1; }
.envelope .chip { display: inline-flex; width: fit-content; padding: 5px 11px; border-radius: 999px; background: rgba(0,0,0,0.3); font-size: 0.74rem; font-weight: 700; }
.envelope .meta { color: rgba(255,255,255,0.82); font-size: 0.84rem; }
.hint-box {
  margin-top: 12px; padding: 12px 14px; border-radius: 12px;
  background: var(--brand-soft); border: 1px solid rgba(123,107,255,0.3);
  color: #d5cfff; font-size: 0.9rem;
}

/* ---------- Confession "scene" cards ---------- */
.badge-tap { background: rgba(0,0,0,0.42); color: #fff; }
.scene-cover { align-items: flex-start; }
.scene-cover .scn { position: absolute; inset: 0; justify-content: center; z-index: 0; }
.scene-cover .chip, .scene-cover .badge { z-index: 1; }
.envelope.has-scene { align-items: stretch; gap: 12px; }
.envelope.has-scene .scn { margin: 4px 0; }

/* ---------- Animated "mood" cards (cute pack) ---------- */
/* Living gradient + a drifting field of emoji. The gradient is set inline from the
   template; motion is all here so any mood template animates for free. */
.mood { background-size: 180% 180%; animation: moodShift 16s ease-in-out infinite; }
.mood-fx { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.shop-preview .mood-fx, .envelope .mood-fx { z-index: 0; }
.mood-p {
  position: absolute;
  bottom: -12%;
  line-height: 1;
  opacity: 0;
  will-change: transform, opacity;
  animation-name: moodFloat;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.22));
}
@keyframes moodShift {
  0%, 100% { background-position: 0% 50%; }
  50%      { background-position: 100% 50%; }
}
@keyframes moodFloat {
  0%   { transform: translateY(0) rotate(0deg) scale(0.85); opacity: 0; }
  12%  { opacity: var(--o, 0.85); }
  86%  { opacity: var(--o, 0.85); }
  100% { transform: translateY(-460px) rotate(var(--r, 20deg)) scale(1.05); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .mood { animation: none; }
  .mood-p { display: none; }
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 92px; left: 50%; transform: translateX(-50%);
  background: rgba(20,24,34,0.98); border: 1px solid var(--stroke-strong);
  color: var(--text); padding: 12px 18px; border-radius: 999px; z-index: 60;
  font-weight: 600; font-size: 0.9rem; box-shadow: var(--shadow);
  animation: toastIn 0.25s var(--ease);
  max-width: 90vw; text-align: center;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

.empty { color: var(--faint); text-align: center; padding: 20px; font-size: 0.9rem; }

/* ---------- Admin: reminders ---------- */
.rem-list { display: grid; gap: 8px; }
.rem-row {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  background: var(--surface-2); border: 1px solid var(--stroke); border-radius: 12px;
}
.rem-row.rem-off { opacity: 0.55; }
.rem-main { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rem-main strong { font-size: 0.95rem; }
.rem-main small { color: var(--muted); font-size: 0.78rem; }
.rem-text { color: var(--faint) !important; font-style: italic; }
.rem-stat { color: var(--success) !important; }
.rem-badge {
  font-size: 0.72rem; font-weight: 800; padding: 2px 9px; border-radius: 999px;
  color: var(--faint); background: rgba(255,255,255,0.05); border: 1px solid var(--stroke);
  flex: none;
}
.rem-badge.on { color: var(--success); background: rgba(53,224,138,0.12); border-color: rgba(53,224,138,0.3); }

.offset-row { display: flex; gap: 8px; }
.offset-row input { flex: 1; min-width: 0; }
.offset-row select { flex: none; width: 110px; }

.rem-photo { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.rem-photo img {
  width: 76px; height: 76px; object-fit: cover; flex: none;
  border-radius: 10px; border: 1px solid var(--stroke);
}

/* ---------- Responsive ---------- */
@media (max-width: 560px) {
  h1 { font-size: 1.1rem; }
  .hero h2 { font-size: 1.28rem; }
  .quick-row { grid-template-columns: repeat(4, 1fr); }
  .actions .primary-btn, .actions .secondary-btn { min-width: 0; }
}

@media (min-width: 720px) {
  .shop-grid { grid-template-columns: repeat(3, 1fr); }
  .feed-grid { grid-template-columns: repeat(2, 1fr); }
  .modal { place-items: center; }
  .modal-card { border-radius: 28px; }
}

@media (min-width: 1080px) {
  .app-shell { max-width: 1040px; }
  .shop-grid { grid-template-columns: repeat(4, 1fr); }
}
