/* Pet Training Coach - warm, friendly, mobile-first */
:root {
  --bg: #fff8f0;
  --bg-warm: #fff3e2;
  --card: #ffffff;
  --ink: #26282d; --headline: #4a3226;
  --ink-soft: #4b4f56;
  --muted: #5f6368;
  --accent: #f59e0b;
  --accent-dark: #b45309;
  --accent-deep: #8a3d06;
  --accent-soft: #fef3c7;
  --accent-glow: #fbbf24;
  --green: #16a34a;
  --green-soft: #dcfce7;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --blue: #2563eb;
  --blue-soft: #dbeafe;
  --border: #f0e2cc;
  --border-soft: #f7ead3;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 2px 10px rgba(120, 72, 20, 0.08), 0 10px 28px rgba(120, 72, 20, 0.05);
  --shadow-lift: 0 4px 14px rgba(120, 72, 20, 0.12), 0 16px 40px rgba(120, 72, 20, 0.09);
  --font-display: "Fredoka", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background:
    radial-gradient(1200px 480px at 50% -140px, #ffe9c2 0%, rgba(255, 233, 194, 0) 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-warm) 100%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em; line-height: 1.28; }

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  padding-bottom: env(safe-area-inset-bottom);
}

/* Header */
.app-header {
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 45%, #ea580c 100%);
  color: #fff;
  padding: calc(12px + env(safe-area-inset-top)) 20px 18px;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 4px 20px rgba(234, 88, 12, 0.25);
}
.app-header h1 { font-size: 1.35rem; }
.greeting { font-size: 0.92rem; opacity: 0.95; }
.header-inner { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 44px; height: 44px; border-radius: 14px;
  background: rgba(255,255,255,0.22);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.app-header h1 { margin: 0; font-size: 1.15rem; font-weight: 700; letter-spacing: 0.2px; }
.greeting { margin: 2px 0 0; font-size: 0.85rem; opacity: 0.92; }
.header-copy { min-width: 0; flex: 1; }
.account-actions {
  display: flex; flex-direction: column; align-items: flex-end; gap: 2px;
  margin-left: auto; min-width: 0;
}
.account-btn, .sign-out-btn {
  border: 0; color: #fff; font-family: inherit; cursor: pointer;
}
.account-btn {
  max-width: 148px; min-height: 44px; padding: 8px 11px;
  border-radius: 12px; background: rgba(255,255,255,0.2);
  font-size: 0.78rem; font-weight: 750; line-height: 1.15;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.account-btn:focus-visible, .sign-out-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.sign-out-btn {
  padding: 2px 4px; background: transparent;
  font-size: 0.72rem; font-weight: 700; text-decoration: underline;
  text-underline-offset: 2px;
}

/* Authentication */
.auth-overlay {
  position: fixed; inset: 0; z-index: 80;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(58, 44, 30, 0.62);
  padding: 16px 12px calc(16px + env(safe-area-inset-bottom));
}
.auth-card {
  width: 100%; max-width: 480px; max-height: 92vh; max-height: 92dvh;
  overflow-y: auto; background: var(--card); border-radius: 24px;
  padding: 20px 18px 18px; box-shadow: 0 18px 48px rgba(58, 44, 30, 0.25);
}
.auth-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.auth-heading h2 { margin: 0; font-size: 1.35rem; }
.auth-close {
  width: 44px; height: 44px; flex: 0 0 44px; padding: 0;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--bg); color: var(--ink); font-size: 1.35rem;
  line-height: 1; cursor: pointer;
}
.auth-intro { margin: 6px 0 16px; color: var(--muted); }
.google-auth-slot {
  width: 100%; min-height: 44px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.google-auth-slot > div { width: 100% !important; }
.google-auth-slot iframe { width: 100% !important; }
.google-auth-slot.is-busy { opacity: 0.48; pointer-events: none; }
.btn.google-btn {
  position: relative;
  width: 100%; min-height: 44px;
  padding: 0 16px 0 52px;
  background: #fff; color: #1f1f1f;
  border: 1px solid #747775; border-radius: 8px;
  box-shadow: none;
  font-family: Roboto, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 0.875rem; font-weight: 500; line-height: 20px;
  letter-spacing: 0.25px;
}
.btn.google-btn:hover { background: #f8fafd; border-color: #5f6368; }
.btn.google-btn:active { background: #f0f4f9; }
.btn.google-btn:focus-visible { outline: 2px solid #1a73e8; outline-offset: 2px; }
.btn.google-btn .google-mark {
  position: absolute; left: 14px; top: 50%;
  width: 20px; height: 20px;
  transform: translateY(-50%);
}
.btn.google-btn:disabled { background: #f8fafd; color: #5f6368; border-color: #c4c7c5; }
.auth-divider {
  display: flex; align-items: center; gap: 10px;
  margin: 16px 0 4px; color: var(--muted); font-size: 0.82rem;
}
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.auth-status {
  margin: 12px 0 0; padding: 10px 12px; border-radius: 10px;
  background: var(--blue-soft); color: var(--blue); font-size: 0.88rem; font-weight: 650;
}
.auth-status.error { background: var(--red-soft); color: var(--red); }
.recovery-hidden { display: none !important; }
.forgot-btn {
  display: block; margin: 12px auto 0; padding: 4px 12px; min-height: 44px;
  border: 0; background: transparent; color: var(--accent-dark);
  font: inherit; font-size: 0.9rem; font-weight: 700; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px;
}
@media (min-width: 520px) { .auth-overlay { align-items: center; } }
.auth-legal { margin: 10px 0 0; text-align: center; color: var(--muted); font-size: 0.82rem; }
.auth-legal a { color: var(--accent-dark); font-weight: 700; display: inline-block; min-height: 24px; }

/* Privacy policy */
.privacy-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(58, 44, 30, 0.62);
  padding: 16px 12px calc(16px + env(safe-area-inset-bottom));
}
.privacy-page {
  width: 100%; max-width: 480px; max-height: 94vh; max-height: 94dvh;
  overflow-y: auto; background: var(--card); border-radius: 24px;
  padding: 20px 18px 18px; box-shadow: 0 18px 48px rgba(58, 44, 30, 0.25);
}
.privacy-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.privacy-heading h2 { margin: 0; font-size: 1.45rem; }
.privacy-close {
  width: 44px; height: 44px; flex: 0 0 44px; padding: 0;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--bg); color: var(--ink); font-size: 1.35rem;
  line-height: 1; cursor: pointer;
}
.privacy-close:focus-visible, .privacy-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.privacy-updated { margin: 4px 0 16px; color: var(--muted); font-size: 0.84rem; }
.privacy-page h3 { margin: 18px 0 6px; font-size: 1.02rem; }
.privacy-page p { margin: 6px 0; }
.privacy-page ul { margin: 8px 0 0; padding-left: 22px; }
.privacy-page li { margin: 7px 0; }
.privacy-link {
  display: inline-block; margin-top: 12px;
  color: var(--accent-dark); font-size: 0.86rem; font-weight: 700;
  text-underline-offset: 3px;
}
@media (min-width: 520px) { .privacy-overlay { align-items: center; } }

@media (max-width: 380px) {
  .app-header { padding-left: 14px; padding-right: 14px; }
  .header-inner { gap: 9px; }
  .logo { width: 40px; height: 40px; border-radius: 12px; }
  .account-btn { max-width: 116px; padding-left: 8px; padding-right: 8px; }
  .greeting { font-size: 0.78rem; }
}

/* Main view */
.view {
  flex: 1;
  padding: 16px 16px 96px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Cards */
.card {
  background: linear-gradient(180deg, #ffffff 0%, #fffdf8 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 8px; font-size: 1.35rem; }
.card h3 { margin: 0 0 8px; font-size: 1.1rem; }
.card p { margin: 6px 0; color: var(--ink); }
.muted { color: var(--muted); font-size: 0.9rem; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 52px;
  padding: 13px 22px;
  border: none; border-radius: 16px;
  font-size: 1.02rem; font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
  transition: transform 0.08s ease, box-shadow 0.15s ease, filter 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: linear-gradient(180deg, var(--accent-glow) 0%, var(--accent) 55%, #e8930a 100%);
  color: #3b2205; width: 100%;
  box-shadow: 0 3px 0 var(--accent-deep), 0 8px 20px rgba(245, 158, 11, 0.35);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.25);
}
.btn-primary:hover { filter: brightness(1.04); }
.btn-primary:active {
  background: linear-gradient(180deg, var(--accent) 0%, #e8930a 100%);
  box-shadow: 0 1px 0 var(--accent-deep), 0 4px 12px rgba(245, 158, 11, 0.3);
}
.btn-secondary {
  background: var(--accent-soft); color: var(--accent-dark);
  width: 100%;
  box-shadow: inset 0 0 0 1.5px #f3d9a4;
}
.btn-secondary:active { background: #fbe8bd; }
.btn-ghost {
  background: transparent; color: var(--muted);
  border: 2px solid var(--border);
}
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }
/* Training track picker: one full-width option per row. */
.track-picker { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.track-picker .btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; }
.btn:disabled { opacity: 0.45; cursor: default; }

/* Choice chips / option buttons */
.option-grid { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.option-btn {
  display: flex; align-items: center; gap: 12px;
  min-height: 56px;
  padding: 12px 16px;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem; font-weight: 600; color: var(--ink);
  cursor: pointer; text-align: left;
  font-family: inherit;
  width: 100%;
}
.option-btn .emoji { font-size: 1.4rem; }
.option-btn.selected { border-color: var(--accent); background: var(--accent-soft); }
.option-btn:active { transform: scale(0.99); }
/* Dog-first onboarding: the dog path is big and inviting; other pets stay
   available as smaller secondary choices. */
.option-btn-featured {
  min-height: 76px;
  padding: 16px 18px;
  font-size: 1.2rem;
  border-width: 3px;
  background: linear-gradient(135deg, var(--accent-soft), #fff);
}
.option-btn-featured .emoji { font-size: 2rem; }
.option-btn-featured .pet-img { width: 64px; height: 64px; border-radius: 16px; display: block; margin: 0 auto 6px; }
.pet-alt-row { display: flex; gap: 10px; justify-content: center; margin-top: 4px; }
.pet-alt-row .chip { min-height: 48px; }
.pet-alt-row .chip .pet-img { width: 40px; height: 40px; border-radius: 12px; display: block; margin: 0 auto 4px; }

/* Issue chips (multi-select) */
.chip-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.chip {
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 2px solid var(--border);
  background: var(--card);
  font-size: 0.95rem; font-weight: 600; color: var(--ink);
  cursor: pointer;
  font-family: inherit;
}
.chip.selected { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-dark); }

/* Dog switcher (multi-dog Premium) */
.dog-bar { border-top: 1px solid rgba(0,0,0,0.06); padding: 8px 16px; }
.dog-chips { display: flex; gap: 8px; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
.dog-chip {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 2px solid var(--border);
  background: var(--card);
  font-size: 0.9rem; font-weight: 600; color: var(--ink);
  cursor: pointer;
  font-family: inherit;
}
.dog-chip.active { border-color: var(--accent); background: var(--accent); color: #fff; }
.dog-chip.dog-add { border-style: dashed; color: var(--muted); }
.linklike { background: none; border: none; padding: 0; font: inherit; color: var(--accent-dark); text-decoration: underline; cursor: pointer; }

/* Inputs */
.text-input, .textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: 12px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--ink);
  background: var(--card);
  margin-top: 8px;
}
.textarea { min-height: 88px; resize: vertical; }
.text-input:focus, .textarea:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
label.field-label { font-weight: 700; display: block; margin-top: 14px; }
/* Semantic group label for the onboarding age choices (Finding 13) */
fieldset.field-group { border: 0; padding: 0; margin: 14px 0 0; min-width: 0; }
fieldset.field-group > legend.field-label { font-weight: 700; display: block; margin: 0 0 8px; padding: 0; }

/* Onboarding */
.onboarding-overlay {
  position: fixed; inset: 0;
  background: rgba(58, 44, 30, 0.55);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 50;
}
@media (min-width: 520px) { .onboarding-overlay { align-items: center; } }
.onboarding-overlay.hidden { display: none; }
.onboarding-card {
  background: var(--bg);
  width: 100%; max-width: 480px;
  max-height: 92vh; max-height: 92dvh;
  overflow-y: auto;
  border-radius: 24px 24px 0 0;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
}
@media (min-width: 520px) { .onboarding-card { border-radius: 24px; } }
.onboarding-card h2 { margin: 4px 0 6px; font-size: 1.35rem; }
.ob-progress { display: flex; gap: 6px; margin-bottom: 12px; }
.ob-dot { flex: 1; height: 6px; border-radius: 3px; background: var(--border); }
.ob-dot.done { background: var(--accent); }

/* Lesson steps */
.step-list { list-style: none; margin: 12px 0; padding: 0; counter-reset: step; display: flex; flex-direction: column; gap: 10px; }
.step-list li {
  counter-increment: step;
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}
.step-list li::before {
  content: counter(step);
  flex-shrink: 0;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.pro-tip {
  background: var(--blue-soft);
  border-left: 4px solid var(--blue);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 12px 0;
  font-size: 0.95rem;
}
.pro-tip strong { color: var(--blue); }

/* Timer */
.timer-box {
  text-align: center;
  background: var(--accent-soft);
  border-radius: var(--radius);
  padding: 14px;
  margin: 12px 0;
}
.timer-display {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  letter-spacing: 0.02em;
}

/* Badges and pills */
.pill {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.8rem; font-weight: 700;
}
.pill-time { background: var(--accent-soft); color: var(--accent-dark); }
.pill-done { background: var(--green-soft); color: var(--green); }
.pill-todo { background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
.pill-lock { background: #ede9fe; color: #6d28d9; }
.pill-streak { background: #ffedd5; color: #c2410c; }
.pill-trial { background: #dcfce7; color: #15803d; }
.pill-streak::before { content: "🔥"; display: inline-block; margin-right: 2px; animation: flame-flicker 1.6s ease-in-out infinite; transform-origin: 50% 90%; }
.pill-rest { background: #e0f2fe; color: #0369a1; }

/* Micro-delight: cheap CSS-only motion. Respects reduced-motion below. */
@keyframes flame-flicker {
  0%, 100% { transform: scale(1) rotate(-4deg); }
  50% { transform: scale(1.18) rotate(5deg); }
}
@keyframes pop-in {
  0% { transform: scale(0.92); opacity: 0; }
  60% { transform: scale(1.02); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes rise-in {
  0% { transform: translateY(10px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}
@keyframes wiggle {
  0%, 100% { transform: rotate(-6deg); }
  50% { transform: rotate(6deg); }
}
.view .card { animation: rise-in 0.25s ease both; }
.view .card:nth-child(2) { animation-delay: 0.05s; }
.view .card:nth-child(3) { animation-delay: 0.1s; }
.celebrate { animation: pop-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both; }
.celebrate .big { display: inline-block; animation: wiggle 0.6s ease-in-out 0.2s 2; }
@media (prefers-reduced-motion: reduce) {
  .pill-streak::before, .view .card, .celebrate, .celebrate .big { animation: none; }
  .btn { transition: none; }
}

/* Plan list */
.plan-day {
  display: flex; align-items: center; gap: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  min-height: 64px;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font-family: inherit; font-size: 1rem; color: var(--ink);
}
.plan-day .day-num {
  flex-shrink: 0;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 0.9rem;
}
.plan-day.done .day-num { background: var(--green-soft); border-color: var(--green); color: var(--green); }
.plan-day.today { border: 2px solid var(--accent); }
.plan-day .day-title { flex: 1; font-weight: 600; }
.plan-day.locked { opacity: 0.55; }

/* Progress bar */
.progress-track { height: 12px; background: var(--border); border-radius: 6px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), #ea580c); border-radius: 6px; transition: width 0.4s ease; }

/* Milestones */
.milestone {
  display: flex; gap: 12px; align-items: center;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
}
.milestone.earned { background: var(--green-soft); border-color: var(--green); }
.milestone .m-emoji { font-size: 1.6rem; }
.milestone .m-img { width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0; }
.milestone strong { display: block; }

/* Gamification: XP, badges, shop, weekly challenge */
.xp-wrap { margin-top: 8px; }
.xp-meta { display: flex; justify-content: space-between; align-items: baseline; font-size: 0.85rem; margin-bottom: 4px; }
.xp-meta strong { color: var(--accent-dark); }
.xp-track { height: 10px; background: var(--border); border-radius: 5px; overflow: hidden; }
.xp-fill { height: 100%; background: linear-gradient(90deg, #f59e0b, #ea580c); border-radius: 5px; transition: width 0.4s ease; }
.pup-head { display: flex; gap: 14px; align-items: center; }
.pup-avatar { position: relative; width: 96px; height: 96px; flex-shrink: 0; border-radius: 24px; overflow: hidden; background: #f7f3ec; }
.pup-avatar.lg { width: 180px; height: 180px; border-radius: 36px; }
.pup-avatar img.pup-base { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.pup-avatar img.pup-acc { position: absolute; left: 50%; transform: translateX(-50%); mix-blend-mode: multiply; pointer-events: none; }
.pup-avatar img.pup-acc.pos-head { top: 2%; width: 44%; }
.pup-avatar img.pup-acc.pos-eyes { top: 24%; width: 46%; }
.pup-avatar img.pup-acc.pos-neck { top: 42%; width: 42%; }
.pup-avatar img.pup-acc.pos-back { top: 18%; width: 92%; z-index: 0; }
.pup-avatar img.pup-base { z-index: 1; }
.pup-avatar img.pup-acc.pos-head, .pup-avatar img.pup-acc.pos-eyes, .pup-avatar img.pup-acc.pos-neck { z-index: 2; }
.badge-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.badge { text-align: center; padding: 10px 6px; border-radius: 12px; background: var(--bg); border: 1px solid var(--border); }
.badge.earned { background: var(--green-soft); border-color: var(--green); }
.badge .b-emoji { font-size: 1.8rem; display: block; }
.badge.locked .b-emoji { filter: grayscale(1); opacity: 0.35; }
.badge strong { display: block; font-size: 0.72rem; margin-top: 4px; }
.badge span { font-size: 0.66rem; color: var(--muted); display: block; }
.shop-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.shop-item { border: 1px solid var(--border); border-radius: 14px; padding: 10px; background: var(--bg); text-align: center; }
.shop-item.equipped { border-color: var(--green); background: var(--green-soft); }
.shop-item img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; background: #f7f3ec; mix-blend-mode: multiply; }
.shop-item strong { display: block; font-size: 0.85rem; margin-top: 6px; }
.shop-item .treat-cost { font-size: 0.78rem; color: var(--accent-dark); font-weight: 700; }
.treat-pill { display: inline-flex; align-items: center; gap: 4px; font-weight: 800; color: var(--accent-dark); }
.week-track { height: 10px; background: var(--border); border-radius: 5px; overflow: hidden; margin-top: 6px; }
.week-fill { height: 100%; background: linear-gradient(90deg, #34d399, #10b981); border-radius: 5px; transition: width 0.4s ease; }
.levelup-overlay { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; background: rgba(28, 23, 19, 0.55); padding: 20px; }
.levelup-card { background: var(--card); border-radius: 20px; padding: 24px; max-width: 340px; text-align: center; animation: pop-in 0.35s ease; }
.levelup-card img { width: 180px; height: 120px; object-fit: cover; border-radius: 12px; }
@keyframes pop-in { from { transform: scale(0.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .levelup-card { animation: none; } .xp-fill, .week-fill, .progress-fill { transition: none; } }

/* Notes */
.note-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
}
.note-date { font-size: 0.8rem; color: var(--muted); font-weight: 700; }
.note-lesson { font-size: 0.8rem; color: var(--accent-dark); font-weight: 700; }

/* Premium lock cards */
.premium-card {
  position: relative;
  background: linear-gradient(135deg, #faf5ff, #f5f3ff);
  border: 2px dashed #c4b5fd;
  border-radius: var(--radius);
  padding: 16px;
}
.premium-card h3 { margin-top: 6px; }

/* Lesson library and premium plans */
.library-summary { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.library-section { display: flex; flex-direction: column; gap: 8px; }
.section-heading {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 2px 2px 0;
}
.section-heading h2, .section-heading h3 { margin: 0; }
.lesson-row {
  display: flex; align-items: center; gap: 12px;
  width: 100%; min-height: 64px;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  color: var(--ink);
  text-align: left;
  font: inherit;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.lesson-row:active { background: var(--accent-soft); }
.lesson-thumb { width: 56px; height: 56px; border-radius: 12px; flex-shrink: 0; object-fit: cover; }
.lesson-row.locked { background: #faf8ff; border-color: #ddd6fe; }
.lesson-number {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; flex: 0 0 34px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.8rem; font-weight: 800;
}
.lesson-row.locked .lesson-number { background: #ede9fe; border-color: #c4b5fd; color: #6d28d9; }
.lesson-copy { min-width: 0; flex: 1; }
.lesson-copy strong { display: block; line-height: 1.25; }
.lesson-meta { display: block; margin-top: 3px; color: var(--muted); font-size: 0.78rem; }
.lock-mark { flex: 0 0 auto; color: #6d28d9; font-weight: 800; font-size: 0.78rem; }
.plan-preview { margin-top: 2px; }
.plan-preview .card { box-shadow: none; }

/* Premium paywall */
.paywall-overlay {
  position: fixed; inset: 0; z-index: 70;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(58, 44, 30, 0.62);
  padding: 16px 12px calc(16px + env(safe-area-inset-bottom));
}
.paywall-card {
  width: 100%; max-width: 480px; max-height: 92vh; max-height: 92dvh;
  overflow-y: auto;
  background: var(--card);
  border-radius: 24px;
  padding: 22px 18px 18px;
  box-shadow: 0 18px 48px rgba(58, 44, 30, 0.25);
}
.paywall-card h2 { margin: 0 0 8px; font-size: 1.45rem; }
.paywall-card > p { margin: 0 0 16px; color: var(--muted); }
.plan-option {
  padding: 14px; margin: 10px 0;
  border: 2px solid var(--border);
  border-radius: 14px;
  background: var(--bg);
}
.plan-option.founding { border-color: var(--accent); background: var(--accent-soft); }
.plan-price { display: block; font-size: 1.12rem; font-weight: 800; }
.plan-option p { margin: 2px 0 12px; color: var(--muted); font-size: 0.88rem; }
.founding-counter { margin: 2px 0 13px; }
.paywall-list { margin: 0 0 14px; padding-left: 20px; text-align: left; font-size: 0.92rem; line-height: 1.45; }
.paywall-list li + li { margin-top: 5px; }
.compare-table { width: 100%; border-collapse: collapse; margin: 0 0 14px; font-size: 0.88rem; text-align: left; }
.compare-table th, .compare-table td { padding: 7px 6px; border-bottom: 1px solid var(--border, #eee); vertical-align: top; }
.compare-table thead th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted, #777); }
.compare-table thead th:nth-child(2), .compare-table thead th:nth-child(3),
.compare-table td:nth-child(2), .compare-table td:nth-child(3) { text-align: center; width: 64px; }
.compare-table td.yes { color: var(--green, #2e7d32); font-weight: 700; }
.compare-table td.no { color: var(--muted, #aaa); }
.analytics-bars { display: flex; align-items: flex-end; gap: 6px; height: 118px; padding: 10px 2px 0; }
.abar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.abar { width: 100%; max-width: 30px; background: linear-gradient(180deg, #f6b73c, #ef8f2e); border-radius: 5px 5px 0 0; }
.abar-label { font-size: 0.68rem; color: var(--muted, #888); margin-top: 3px; }
.analytics-teaser { display: flex; align-items: flex-end; gap: 6px; height: 64px; margin: 6px 0 10px; filter: blur(4px); opacity: 0.55; pointer-events: none; }
.analytics-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 6px; }
.analytics-stats > div { text-align: center; padding: 10px 4px; background: rgba(0,0,0,0.03); border-radius: 10px; }
.analytics-stats strong { display: block; font-size: 1.35rem; }
.analytics-stats span { font-size: 0.72rem; color: var(--muted, #888); }
.soon-tag { display: inline-block; margin-left: 4px; padding: 1px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-dark); font-size: 0.72rem; font-weight: 750; white-space: nowrap; }
.founding-count-text { margin-bottom: 6px; color: var(--accent-dark); font-size: 0.8rem; font-weight: 750; }
.founding-progress {
  height: 7px; overflow: hidden;
  border-radius: 999px; background: rgba(180, 83, 9, 0.16);
}
.founding-progress-fill {
  height: 100%; width: 0;
  border-radius: inherit; background: var(--accent-dark);
  transition: width 0.35s ease;
}
.paywall-dismiss { display: block; margin: 10px auto 0; }

/* Generic choice dialog (unsynced sign-out warning, pet conflict, backup restore) */
.choice-overlay {
  position: fixed; inset: 0; z-index: 80;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(58, 44, 30, 0.62);
  padding: 16px 12px calc(16px + env(safe-area-inset-bottom));
}
@media (min-width: 520px) { .choice-overlay { align-items: center; } }
.choice-card {
  width: 100%; max-width: 440px;
  background: var(--card);
  border-radius: 24px;
  padding: 22px 18px 18px;
  box-shadow: 0 18px 48px rgba(58, 44, 30, 0.25);
}
.choice-card h2 { margin: 0 0 8px; font-size: 1.3rem; }
.choice-card > p { margin: 0 0 16px; color: var(--muted); }
.choice-card .btn { width: 100%; }

/* Account settings */
.settings-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 0; margin: 10px 0 4px;
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
.settings-copy { min-width: 0; }
.settings-copy strong { display: block; }
.settings-copy span { display: block; margin-top: 2px; color: var(--muted); font-size: 0.82rem; }
.reminder-status { min-height: 1.2em; margin: 0 0 10px; color: var(--muted); font-size: 0.8rem; }
.switch { position: relative; flex: 0 0 50px; width: 50px; height: 30px; cursor: pointer; }
.switch input {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  opacity: 0; pointer-events: none;
}
.switch-track {
  position: absolute; inset: 0;
  border-radius: 999px; background: #c8b9a9;
  transition: background 0.2s ease;
}
.switch-track::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 4px rgba(58, 44, 30, 0.25);
  transition: transform 0.2s ease;
}
.switch input:checked + .switch-track { background: var(--green); }
.switch input:checked + .switch-track::after { transform: translateX(20px); }
.switch input:focus-visible + .switch-track { outline: 3px solid var(--accent); outline-offset: 2px; }
.switch input:disabled + .switch-track { opacity: 0.52; cursor: wait; }
@media (prefers-reduced-motion: reduce) {
  .founding-progress-fill, .switch-track, .switch-track::after { transition: none; }
}
.toast {
  position: fixed; left: 50%; bottom: calc(78px + env(safe-area-inset-bottom)); z-index: 90;
  transform: translateX(-50%);
  width: max-content; max-width: calc(100% - 32px);
  padding: 11px 16px;
  border-radius: 999px;
  background: var(--ink); color: var(--card);
  font-size: 0.9rem; font-weight: 700; text-align: center;
  box-shadow: 0 8px 24px rgba(58, 44, 30, 0.22);
}
@media (min-width: 520px) { .paywall-overlay { align-items: center; } }

/* Tab bar */
.tabbar {
  position: fixed;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%; max-width: 480px;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 20;
}
.tab {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-height: 62px;
  padding: 8px 4px calc(6px + env(safe-area-inset-bottom));
  background: none; border: none;
  border-radius: 14px;
  font-size: 0.72rem; font-weight: 700; color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  transition: color 0.15s ease, background 0.15s ease, transform 0.08s ease;
}
.tab:active { transform: scale(0.94); }
.tab.active { color: var(--accent-dark); background: var(--accent-soft); }
.tab-icon { font-size: 1.35rem; }
.tab-icon { font-size: 1.35rem; }
.tab.active { color: var(--accent-dark); }

/* Celebration */
.celebrate { text-align: center; padding: 12px 0; }
.celebrate .big { font-size: 3rem; }
/* AI-generated brand illustrations (img/) for key moments. */
.mascot-img {
  display: block;
  width: 148px;
  height: auto;
  margin: 4px auto 12px;
  border-radius: 24px;
}
.celebrate-img {
  display: block;
  width: 168px;
  height: auto;
  margin: 0 auto 8px;
  border-radius: 24px;
}

/* Utility */
.hidden { display: none !important; }
.center { text-align: center; }
.mt { margin-top: 12px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.empty-state { text-align: center; color: var(--muted); padding: 24px 12px; }
.empty-img { width: 160px; height: 160px; border-radius: 20px; display: block; margin: 0 auto 12px; }

/* ---------- Browser mode: website chrome ----------
   In a regular browser the app page looks like part of the website
   (header, top section nav, footer). The installed PWA keeps the
   phone-app look: narrow column + bottom tab bar. */
.site-chrome { display: none; }
html:not(.is-installed) .site-chrome-header { display: block; }
html:not(.is-installed) .site-chrome-footer { display: block; }
html:not(.is-installed) .tabbar { display: none; }
html:not(.is-installed) .app { max-width: 860px; box-shadow: 0 0 0 1px var(--border-soft), var(--shadow); }
html:not(.is-installed) .view { padding: 20px 28px 40px; }
.site-chrome-header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.site-chrome-inner {
  max-width: 1100px; margin: 0 auto; padding: 14px 20px;
  display: flex; align-items: center; gap: 18px;
}
.site-chrome-brand {
  font-family: var(--font-display); font-weight: 700; font-size: 1.25rem;
  color: var(--ink); text-decoration: none; white-space: nowrap;
}
.site-chrome-brand span { color: var(--accent-dark); }
.site-chrome-nav { display: flex; gap: 4px; margin-left: auto; overflow-x: auto; }
.site-chrome-nav a {
  color: var(--ink-soft); text-decoration: none; font-weight: 600; font-size: 0.92rem;
  padding: 10px 12px; border-radius: 10px; white-space: nowrap;
}
.site-chrome-nav a:hover { background: var(--accent-soft); color: var(--accent-deep); }
.site-chrome-nav a[aria-current="page"] { color: var(--accent-deep); background: var(--accent-soft); }
/* App section nav for browser mode: horizontal pills under the header. */
.browser-tabnav { display: none; }
html:not(.is-installed) .browser-tabnav { display: block; background: var(--bg); border-bottom: 1px solid var(--border); }
.browser-tabnav-inner {
  max-width: 860px; margin: 0 auto; padding: 12px 20px;
  display: flex; gap: 8px; overflow-x: auto;
}
.browser-tabnav .tab {
  flex: 0 0 auto; flex-direction: row; gap: 8px;
  min-height: 44px; padding: 10px 16px;
  border: 2px solid var(--border); border-radius: 999px;
  font-size: 0.9rem; background: var(--card);
}
.browser-tabnav .tab .tab-icon { font-size: 1.1rem; }
.browser-tabnav .tab.active {
  background: var(--accent-soft); border-color: var(--accent);
  color: var(--accent-deep);
}
.site-chrome-footer {
  border-top: 1px solid var(--border); background: var(--bg);
  margin-top: 0;
}
.site-chrome-footer-inner {
  max-width: 1100px; margin: 0 auto; padding: 28px 20px;
  display: flex; flex-wrap: wrap; gap: 12px 28px; align-items: center;
  font-size: 0.9rem; color: var(--muted);
}
.site-chrome-footer-inner nav { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.site-chrome-footer-inner a { color: var(--muted); text-decoration: none; font-weight: 600; }
.site-chrome-footer-inner a:hover { color: var(--accent-deep); }
@media (max-width: 640px) {
  html:not(.is-installed) .view { padding: 16px 16px 32px; }
  .site-chrome-inner { padding: 12px 14px; gap: 10px; }
}

h1,h2{color:var(--headline)}

/* ---------- Training games ---------- */
.game-card { overflow: hidden; }
.game-cover { display: block; width: 100%; height: auto; border-radius: var(--radius-sm); margin-bottom: 12px; }
.game-head { display: flex; gap: 12px; align-items: flex-start; }
.game-icon { font-size: 2rem; line-height: 1; }
.game-head h3 { margin: 0 0 4px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip { display: inline-block; background: var(--accent-soft); color: var(--accent-deep); font-size: 0.75rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; }
.chip.free { background: var(--green-soft); color: var(--green); }
.chip.best { background: var(--blue-soft); color: var(--blue); }
.step-row { display: flex; gap: 12px; align-items: center; width: 100%; text-align: left; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px; margin-bottom: 8px; cursor: pointer; font-family: inherit; color: inherit; min-height: 64px; }
.step-row:active { transform: scale(0.98); }
.step-thumb { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; flex-shrink: 0; }
.step-row .step-num { font-weight: 800; color: var(--accent-dark); }
.step-row h4 { margin: 0 0 2px; font-size: 0.95rem; }
.step-row p { margin: 0; font-size: 0.82rem; color: var(--muted); }
.viewer-img { display: block; width: 100%; height: auto; border-radius: var(--radius); margin-bottom: 12px; }
.viewer-nav { display: flex; gap: 10px; }
.viewer-nav .btn { flex: 1; }
.score-display { text-align: center; padding: 8px 0; }
.score-num { font-family: var(--font-display); font-size: 3.5rem; font-weight: 700; color: var(--accent-deep); line-height: 1; }
.score-unit { color: var(--muted); font-weight: 700; }
.score-plus { width: 100%; min-height: 96px; font-size: 2rem; font-family: var(--font-display); }
.honest-note { font-size: 0.82rem; color: var(--muted); text-align: center; }
.safety-note { background: var(--accent-soft); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 0.88rem; }
