:root {
  /* Tells the phone this page handles light AND dark by itself, so the phone/Chrome
     does not auto-darken it. The theme toggle is what decides light or dark. */
  color-scheme: light dark;
  --bg: #f4f7f2;
  --card: #ffffff;
  --text: #1f2a1f;
  --muted: #6b7a6b;
  --primary: #2e9e4f;
  --primary-dark: #247d3f;
  --danger: #d9534f;
  --border: #dfe7dc;
}
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121712;
  --card: #1c241c;
  --text: #e8f0e8;
  --muted: #9bb09b;
  --border: #2c382c;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 16px;
  padding-top: calc(env(safe-area-inset-top, 0px) + 16px);
}
.container { max-width: 480px; margin: 0 auto; }
.wide { max-width: 800px; }
h1, h2 { margin-bottom: 12px; }
h1 { font-size: 1.7rem; }
p { color: var(--muted); margin-bottom: 12px; }
a { color: var(--primary); text-decoration: none; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,.05);
}
label { display: block; font-size: .85rem; margin: 10px 0 4px; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=number], select {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}
.btn {
  display: block;
  width: 100%;
  padding: 13px;
  margin-top: 12px;
  border: none;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
}
.btn:active { background: var(--primary-dark); transform: scale(.98); }
.btn.secondary { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: var(--danger); }
.btn.small { display: inline-block; width: auto; padding: 6px 12px; margin: 0 4px 0 0; font-size: .8rem; }

.msg { padding: 10px; border-radius: 10px; margin-top: 10px; font-size: .9rem; display: none; }
.msg.error { display: block; background: #fdeaea; color: #a33; }
.msg.ok { display: block; background: #e6f6ea; color: #1d6b35; }

.stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin: 12px 0; }
.stat { background: var(--bg); border-radius: 12px; padding: 12px; text-align: center; }
.stat b { display: block; font-size: 1.3rem; color: var(--primary); }
.stat span { font-size: .75rem; color: var(--muted); }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 6px; text-align: left; border-bottom: 1px solid var(--border); font-size: .9rem; }
th { color: var(--muted); font-weight: 600; }
tr.me td { background: rgba(46,158,79,.12); font-weight: 700; }

.row { display: flex; align-items: center; justify-content: space-between; }
.toggle { width: 22px; height: 22px; accent-color: var(--primary); }
.avatar { width: 80px; height: 80px; border-radius: 50%; object-fit: cover; background: var(--border); display: block; margin: 0 auto 10px; }
.hidden { display: none; }
#avatarEmoji,
.avatar-emoji {
  display: none !important;
}

/* ---------- glass status bar (the strip under the Dynamic Island and the clock) ---------- */
html::before {
  content: "";
  position: fixed;
  top: 0; left: 0; right: 0;
  height: env(safe-area-inset-top, 0px);
  z-index: 3000;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(20,30,20,.34), rgba(20,30,20,.12));
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  backdrop-filter: blur(18px) saturate(180%);
}

/* ---------- logo (black / white versions) ---------- */
.logo-light { display: block; }
.logo-dark { display: none; }
[data-theme="dark"] .logo-light { display: none; }
[data-theme="dark"] .logo-dark { display: block; }
.logo { max-width: 200px; width: 70%; height: auto; margin: 0 auto 12px; }

/* logo + name side by side */
.brand { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 12px; }
.brand .logo { width: 48px; max-width: 48px; margin: 0; }
.brand span { font-size: 1.5rem; font-weight: 800; letter-spacing: 1px; color: var(--text); }

/* logo as dashboard background */
body.dash::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: url('../assets/logo-light.png') center / 70% no-repeat;
  opacity: .22;
  pointer-events: none;
}
[data-theme="dark"] body.dash::before {
  background-image: url('../assets/logo-dark.png');
}

/* ---------- glass BACK button (top of the page) ---------- */
.back-top {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  margin-bottom: 14px;
  border-radius: 999px;
  color: var(--text);
  font-size: .9rem;
  font-weight: 600;
  background: linear-gradient(135deg, rgba(255,255,255,.65), rgba(255,255,255,.3));
  -webkit-backdrop-filter: blur(14px) saturate(170%);
  backdrop-filter: blur(14px) saturate(170%);
  border: 1px solid rgba(255,255,255,.65);
  box-shadow: 0 6px 18px rgba(0,0,0,.12), inset 0 1px 0 rgba(255,255,255,.85);
}
.back-top:active { transform: scale(.95); }
[data-theme="dark"] .back-top {
  background: linear-gradient(135deg, rgba(70,88,70,.55), rgba(28,36,28,.35));
  border-color: rgba(255,255,255,.14);
  box-shadow: 0 6px 18px rgba(0,0,0,.4), inset 0 1px 0 rgba(255,255,255,.18);
}

/* ---------- glass DOCK (floating bottom bar) ---------- */
body.has-dock { padding-bottom: 120px; }
.dock {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: max(12px, env(safe-area-inset-bottom));
  max-width: 456px;
  margin: 0 auto;
  z-index: 1000;
  display: flex;
  justify-content: space-around;
  align-items: center;
  gap: 2px;
  padding: 8px;
  border-radius: 30px;
  background: linear-gradient(135deg, rgba(255,255,255,.6), rgba(255,255,255,.25));
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255,255,255,.65);
  box-shadow: 0 10px 30px rgba(0,0,0,.18),
              inset 0 1px 0 rgba(255,255,255,.9),
              inset 0 -1px 0 rgba(255,255,255,.25);
}
[data-theme="dark"] .dock {
  background: linear-gradient(135deg, rgba(70,88,70,.55), rgba(28,36,28,.35));
  border-color: rgba(255,255,255,.14);
  box-shadow: 0 10px 30px rgba(0,0,0,.5),
              inset 0 1px 0 rgba(255,255,255,.18),
              inset 0 -1px 0 rgba(255,255,255,.05);
}
.dock a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 2px;
  border-radius: 22px;
  color: var(--text);
  font-size: .68rem;
  font-weight: 600;
}
.dock a .ico { font-size: 24px; line-height: 1; }
.dock a:active { transform: scale(.92); }
.dock a.active {
  color: var(--primary);
  background: rgba(46,158,79,.2);
  box-shadow: inset 0 0 0 1px rgba(46,158,79,.35);
}

/* ---------- DR points chip (top right) ---------- */
body.has-chip { padding-top: calc(env(safe-area-inset-top, 0px) + 58px); }
.drchip {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  right: 12px;
  z-index: 999;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  color: var(--text);
  font-size: .85rem;
  font-weight: 700;
  background: linear-gradient(135deg, rgba(255,255,255,.65), rgba(255,255,255,.3));
  -webkit-backdrop-filter: blur(14px) saturate(170%);
  backdrop-filter: blur(14px) saturate(170%);
  border: 1px solid rgba(255,255,255,.65);
  box-shadow: 0 6px 18px rgba(0,0,0,.12), inset 0 1px 0 rgba(255,255,255,.85);
  font-variant-numeric: tabular-nums;
}
.drchip:active { transform: scale(.95); }
[data-theme="dark"] .drchip {
  background: linear-gradient(135deg, rgba(70,88,70,.55), rgba(28,36,28,.35));
  border-color: rgba(255,255,255,.14);
  box-shadow: 0 6px 18px rgba(0,0,0,.4), inset 0 1px 0 rgba(255,255,255,.18);
}

/* red dot on the Rewards icon when a daily reward is waiting */
.dock a .ico { position: relative; }
.dock a .ico-dot {
  position: absolute;
  top: -2px;
  right: -6px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #ff3b30;
  border: 2px solid var(--card);
}
