:root {
  --bg: #0f172a;
  --card: #1e293b;
  --card-2: #334155;
  --line: #2b3a50;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --green: #22c55e;
  --red: #f87171;
  --gold: #fbbf24;
  --pink: #f472b6;
}
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
html, body {
  margin: 0;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  overscroll-behavior-y: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) 16px calc(env(safe-area-inset-bottom) + 32px);
  max-width: 560px;
  margin: 0 auto;
  line-height: 1.35;
}
a { color: var(--accent); }
header { text-align: center; padding: 22px 0 6px; }
header h1 { font-size: 1.5rem; margin: 0; }
header p { color: var(--muted); margin: 4px 0 0; font-size: 0.85rem; }
.hidden { display: none !important; }

button {
  font-family: inherit;
  font-size: inherit;
  border: none;
  cursor: pointer;
  color: var(--text);
  background: var(--card-2);
}
button:disabled { opacity: 0.5; }
input, textarea, select {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--card-2);
  background: var(--bg);
  color: var(--text);
  font-size: 16px; /* 16px stops iOS zooming into the field */
  font-family: inherit;
}
textarea { resize: vertical; min-height: 64px; }
label.field { display: block; margin: 12px 0 0; }
label.field span { display: block; color: var(--muted); font-size: 0.78rem; margin: 0 0 6px; }

/* ---- Login + PIN lock (as on the allowance app) ---- */
.login, .lock { max-width: 320px; margin: 40px auto 0; text-align: center; }
.login input { margin: 10px 0; }
.login button {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  background: var(--accent);
  color: #04293a;
  font-weight: 700;
}
.err { color: var(--red); font-size: 0.85rem; min-height: 1.1em; margin: 6px 0 0; }
.lock p { color: var(--muted); margin: 0 0 4px; }
.pin-dots { display: flex; justify-content: center; gap: 16px; margin: 18px 0; }
.pin-dots span { width: 16px; height: 16px; border-radius: 50%; border: 1px solid var(--card-2); }
.pin-dots span.filled { background: var(--accent); border-color: var(--accent); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; max-width: 260px; margin: 16px auto 0; }
.keypad button {
  width: 76px; height: 76px; margin: 0 auto; border-radius: 50%;
  font-size: 1.5rem; font-weight: 600; transition: transform 0.05s;
  -webkit-user-select: none; user-select: none;
}
.keypad button:active { transform: scale(0.92); }
.keypad button.ghost { background: none; color: var(--muted); font-size: 0.85rem; font-weight: 500; }
.lock.shake { animation: shake 0.3s; }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-8px); }
  40%, 60% { transform: translateX(8px); }
}

/* ---- Cards ---- */
.card {
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
  margin: 14px 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
.card-title {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 10px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.muted { color: var(--muted); }
.small { font-size: 0.8rem; }

/* ---- Avatars ---- */
.avatar {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--card-2) center/cover no-repeat;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1.1rem; flex: none;
  color: var(--text);
}
.avatar.sm { width: 34px; height: 34px; font-size: 0.85rem; }
.avatar.lg { width: 64px; height: 64px; font-size: 1.4rem; }

/* ---- Quick add ---- */
.pick-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 0; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 12px; border-radius: 999px;
  background: var(--bg); border: 1px solid var(--card-2);
  color: var(--muted); font-size: 0.85rem; font-weight: 600;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: #04293a; }
.chip.kidchip { padding: 4px 12px 4px 4px; }
.chip.kidchip.on { background: #0c4a6e; border-color: var(--accent); color: var(--text); }
.chip .avatar.sm { width: 28px; height: 28px; font-size: 0.75rem; }
.add-row { display: flex; gap: 10px; align-items: center; margin-top: 12px; }
.btn-primary {
  flex: 1; padding: 14px; border-radius: 12px;
  background: var(--accent); color: #04293a; font-weight: 700;
}
.btn { padding: 12px 14px; border-radius: 12px; font-weight: 600; }
.btn-ghost { background: none; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; padding: 8px 4px; font-size: 0.85rem; }
.who { font-size: 0.8rem; color: var(--muted); text-transform: none; letter-spacing: 0; font-weight: 500; }
.who button { background: none; color: var(--accent); padding: 4px; font-weight: 600; }

/* ---- Kid cards on the home page ---- */
.kid-card { display: block; text-decoration: none; color: inherit; }
.kid-head { display: flex; align-items: center; gap: 12px; }
.kid-head .name { font-size: 1.15rem; font-weight: 700; }
.kid-head .meta { color: var(--muted); font-size: 0.8rem; }
.kid-head .go { margin-left: auto; color: var(--muted); font-size: 1.4rem; }
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  background: var(--gold); color: #3b2a00; font-size: 0.72rem; font-weight: 700;
}

/* Budget bar: bought (green) + loved (accent) + Claude's plan (outline). */
.budget { margin-top: 14px; }
.budget-nums { display: flex; justify-content: space-between; font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; margin-bottom: 6px; }
.budget-nums b { color: var(--text); }
.bar { position: relative; height: 10px; border-radius: 999px; background: var(--card-2); overflow: hidden; }
.bar span { position: absolute; top: 0; bottom: 0; border-radius: 999px; }
.bar .plan { background: rgba(56,189,248,0.25); }
.bar .loved { background: var(--accent); }
.bar .bought { background: var(--green); }
.bar.over .loved, .bar.over .bought { background: var(--red); }
.legend { display: flex; gap: 12px; margin-top: 6px; font-size: 0.72rem; color: var(--muted); flex-wrap: wrap; }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }

/* ---- Kid page ---- */
.back { display: inline-block; color: var(--muted); text-decoration: none; font-size: 0.9rem; padding: 8px 0; }
.tabs { display: flex; background: var(--card); border-radius: 12px; padding: 4px; margin: 14px 0 0; position: sticky; top: env(safe-area-inset-top); z-index: 5; }
.tabs button { flex: 1; padding: 10px; border-radius: 9px; background: none; color: var(--muted); font-weight: 600; font-size: 0.9rem; }
.tabs button.on { background: var(--card-2); color: var(--text); }
.agent-note { white-space: pre-wrap; font-size: 0.9rem; }
.section-h { margin: 22px 4px 4px; font-size: 0.8rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); display: flex; justify-content: space-between; }

.rec { display: flex; flex-direction: column; gap: 8px; padding: 14px; }
.rec + .rec { margin-top: 10px; }
.rec-top { display: flex; gap: 12px; }
.rec-img {
  width: 76px; height: 76px; border-radius: 12px; flex: none;
  background: #fff center/contain no-repeat;
}
.rec-title { font-weight: 700; font-size: 0.98rem; }
.rec-title a { color: var(--text); text-decoration: none; }
.rec-meta { color: var(--muted); font-size: 0.8rem; margin-top: 2px; }
.price { font-weight: 800; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.price s { color: var(--muted); font-weight: 500; font-size: 0.8rem; margin-left: 6px; }
.price .drop { color: var(--green); font-size: 0.75rem; font-weight: 700; margin-left: 6px; }
.price .rise { color: var(--red); font-size: 0.75rem; font-weight: 700; margin-left: 6px; }
.tier { font-size: 0.65rem; font-weight: 800; letter-spacing: 0.06em; padding: 2px 6px; border-radius: 6px; vertical-align: 2px; margin-right: 4px; }
.tier.big { background: var(--pink); color: #3d0a24; }
.tier.small { background: var(--card-2); color: var(--muted); }
.inplan { font-size: 0.65rem; font-weight: 800; padding: 2px 6px; border-radius: 6px; background: #0c4a6e; color: var(--accent); vertical-align: 2px; }
.why { font-size: 0.88rem; color: #cbd5e1; }
.trend { font-size: 0.8rem; color: var(--gold); }
.local { font-size: 0.8rem; color: #86efac; }
.oos { color: var(--red); font-weight: 700; }
.rec-actions { display: flex; gap: 8px; }
.rec-actions button { flex: 1; padding: 10px 0; border-radius: 10px; font-weight: 700; font-size: 0.85rem; background: var(--bg); border: 1px solid var(--card-2); color: var(--muted); }
.rec-actions button.on.love { background: var(--accent); border-color: var(--accent); color: #04293a; }
.rec-actions button.on.bought { background: var(--green); border-color: var(--green); color: #04200f; }
.rec-actions button.on.pass { background: #4c2230; border-color: #4c2230; color: var(--red); }
.parent-note { font-size: 0.8rem; color: var(--muted); font-style: italic; }
.rec.passed { opacity: 0.6; }

/* ---- Notes ---- */
.note { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; }
.note + .note { border-top: 1px solid var(--line); }
.note .txt { flex: 1; font-size: 0.92rem; }
.note .by { color: var(--muted); font-size: 0.72rem; }
.note .del { background: none; color: var(--muted); padding: 2px 6px; font-size: 1.1rem; }
.kind-h { margin: 14px 0 0; font-size: 0.75rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }

/* ---- Research card ---- */
.trend-item { padding: 8px 0; font-size: 0.88rem; }
.trend-item + .trend-item { border-top: 1px solid var(--line); }
.trend-item b { display: block; }
.warn { color: var(--gold); font-size: 0.82rem; margin-top: 8px; }
details summary { cursor: pointer; color: var(--muted); font-size: 0.85rem; padding: 6px 0; }

/* ---- Modal + toast ---- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: none; align-items: flex-end; justify-content: center; padding: 16px; z-index: 20; }
.overlay.show { display: flex; }
.modal { background: var(--card); border-radius: 18px; padding: 20px; width: 100%; max-width: 420px; margin-bottom: env(safe-area-inset-bottom); }
.modal h2 { margin: 0 0 6px; font-size: 1.15rem; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.modal-actions button { flex: 1; padding: 14px; border-radius: 12px; font-weight: 700; }
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 20px); transform: translateX(-50%) translateY(120px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-weight: 600; font-size: 0.9rem;
  transition: transform 0.2s; z-index: 30; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.empty { color: var(--muted); font-size: 0.88rem; text-align: center; padding: 14px 0; }
