/* ==========================================================================
   Rootspeak — design system
   --------------------------------------------------------------------------
   Palette (from the brand sheet):
     Primary Orange #E85A2A   Deep Orange #D2451E
     Dark Brown     #3A1F14   Warm Brown  #5A3321
     Cream          #FFF4E6   Soft Peach  #FFDCC7
   Type: Poppins (one family, all weights)

   Everything below is tokens first, components second. Change a token and
   the whole app moves with it.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Tokens
   -------------------------------------------------------------------------- */

:root {
  /* Brand ramps */
  --primary-50:  #FFF1E8;
  --primary-100: #FFDCC7;
  --primary-200: #F9B995;
  --primary-300: #F28A5C;
  --primary-400: #EE7240;
  --primary:     #E85A2A;
  --primary-600: #D2451E;
  --primary-700: #A93517;
  --primary-800: #7A2711;
  --primary-900: #4B160A;

  /* Secondary = the brand's "Warning" yellow; buttons use Dark Brown instead */
  --secondary-100: #FDEFC2;
  --secondary-300: #F8CF5E;
  --secondary:     #F4B400;
  --secondary-600: #D49A00;
  --secondary-700: #A87A00;

  --tertiary-300: #EE7580;
  --tertiary:     #E63946;
  --tertiary-700: #B02A35;

  --brown-dark:   #3A1F14;
  --brown-warm:   #5A3321;

  --neutral:      #FFF4E6;
  --neutral-200:  #FFDCC7;
  --neutral-400:  #D9B8A0;
  --neutral-600:  #8B6A58;

  /* Dark surfaces — the app ships dark, matching the mockups */
  --bg:            #1A100C;
  --bg-elevated:   #22150F;
  --surface:       #2B1A13;
  --surface-2:     #35211A;
  --surface-3:     #4A2C20;
  --line:          rgba(255, 244, 230, 0.10);
  --line-strong:   rgba(255, 244, 230, 0.18);

  /* Text */
  --text:          #FFF4E6;
  --text-muted:    #C9AE9B;
  --text-faint:    #8B6A58;
  --text-inverted: #3A1F14;

  /* Semantic (brand "Additional Palette") */
  --success:  #28A745;
  --success-dark: #1E7E34;
  --danger:   #E63946;
  --info:     #3B82F6;
  --muted:    #8B8B8B;
  --gold:     #F4B400;
  --silver:   #C7CBD1;
  --bronze:   #C88445;
  --streak:   #FF8A34;
  --gem:      #3B82F6;

  /* Shape */
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-pill: 999px;

  /* Depth — the "bubbly" look comes from a solid bottom edge, not a blur */
  --lip: 0px;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.28);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.34);
  --shadow-lg: 0 18px 44px rgba(0, 0, 0, 0.42);
  --glow-primary: 0 0 0 4px rgba(232, 90, 42, 0.22);
  --glow-secondary: 0 0 0 4px rgba(244, 180, 0, 0.22);

  /* Type */
  --font-head: 'Poppins', ui-sans-serif, system-ui, -apple-system,
               'Segoe UI', Roboto, sans-serif;
  --font-body: 'Poppins', ui-sans-serif, system-ui, -apple-system,
               'Segoe UI', Roboto, sans-serif;

  /* Layout */
  --shell-max: 460px;
  --topnav-h: 58px;
  --bottomnav-h: 68px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Light mode is opt-in via [data-theme="light"] — the brand's Neutral
   #FAEEDA becomes the page and the same components still work. */
[data-theme='light'] {
  --bg:          #FFF4E6;
  --bg-elevated: #FFF9F1;
  --surface:     #FFFFFF;
  --surface-2:   #FFF4E6;
  --surface-3:   #FFDCC7;
  --line:        rgba(58, 31, 20, 0.10);
  --line-strong: rgba(58, 31, 20, 0.18);
  --text:        #3A1F14;
  --text-muted:  #5A3321;
  --text-faint:  #8B6A58;
  --text-inverted: #FFF4E6;
}

/* --------------------------------------------------------------------------
   2. Reset
   -------------------------------------------------------------------------- */

*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  /* Native-app feel: no text selection or tap highlight on chrome elements */
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, h4, h5 {
  font-family: var(--font-head);
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 0.4em;
  line-height: 1.2;
}

h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }

p { margin: 0 0 1em; }

a { color: var(--primary-300); text-decoration: none; }
a:hover { color: var(--primary-200); }

img, svg, video { max-width: 100%; display: block; }

button, input, select, textarea { font: inherit; color: inherit; }

button { cursor: pointer; background: none; border: none; padding: 0; }

ul, ol { margin: 0; padding: 0; list-style: none; }

:focus-visible {
  outline: 3px solid var(--secondary);
  outline-offset: 2px;
  border-radius: 6px;
}

::-webkit-scrollbar { width: 0; height: 0; }

/* --------------------------------------------------------------------------
   3. App shell
   -------------------------------------------------------------------------- */

.app {
  max-width: var(--shell-max);
  margin: 0 auto;
  min-height: 100dvh;
  position: relative;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

/* On desktop the shell reads as a phone sitting on a warm backdrop. */
@media (min-width: 900px) {
  body.has-shell {
    background:
      radial-gradient(1100px 600px at 50% -10%, #3A1F14 0%, transparent 60%),
      #120A07;
  }
  body.has-shell .app {
    margin: 20px auto;
    min-height: calc(100dvh - 40px);
    border-radius: 34px;
    border: 1px solid var(--line);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
  }
}

/* --- Top nav ------------------------------------------------------------ */

.topnav {
  position: sticky;
  top: 0;
  z-index: 40;
  height: calc(var(--topnav-h) + var(--safe-top));
  padding: var(--safe-top) 14px 0;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(26, 16, 12, 0.92);
  backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
}

.topnav__brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.topnav__logo {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  overflow: hidden;
  flex: none;
}

.topnav__logo img { width: 100%; height: 100%; object-fit: cover; }

.topnav__name {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--primary);
  letter-spacing: -0.03em;
  white-space: nowrap;
}

.topnav__stats {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: var(--r-pill);
  background: var(--surface);
  border: 1px solid var(--line);
}

.stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 0.86rem;
  color: var(--text);
  padding: 0 4px;
  white-space: nowrap;
}

.stat-chip__icon { width: 16px; height: 16px; flex: none; }
.stat-chip--streak { color: var(--streak); }
.stat-chip--xp     { color: var(--secondary); }
.stat-chip--hearts { color: var(--danger); }
.stat-chip--gems   { color: var(--gem); }

.stat-chip__divider {
  width: 1px;
  height: 14px;
  background: var(--line-strong);
}

/* --- Page --------------------------------------------------------------- */

.page {
  flex: 1;
  padding: 16px 16px calc(var(--bottomnav-h) + var(--safe-bottom) + 24px);
}

.page--flush { padding-left: 0; padding-right: 0; }

.page-head { margin-bottom: 14px; }
.page-head h1 { margin-bottom: 2px; }
.page-head .sub { color: var(--text-muted); font-size: 0.88rem; margin: 0; }

/* --- Bottom nav --------------------------------------------------------- */

.bottomnav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--shell-max);
  z-index: 50;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  align-items: center;
  gap: 4px;
  padding: 8px 10px calc(8px + var(--safe-bottom));
  background: rgba(22, 18, 15, 0.95);
  backdrop-filter: saturate(160%) blur(16px);
  border-top: 1px solid var(--line);
}

@media (min-width: 900px) {
  body.has-shell .bottomnav {
    position: absolute;
    border-radius: 0 0 33px 33px;
  }
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 7px 4px;
  border-radius: var(--r-pill);
  color: var(--text-muted);
  font-family: var(--font-head);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  transition: background 0.22s var(--ease-out), color 0.22s var(--ease-out);
}

.tab svg { width: 22px; height: 22px; }

.tab:hover { color: var(--text); }

.tab.is-active {
  background: var(--secondary);
  color: var(--text-inverted);
  box-shadow: 0 4px 14px rgba(239, 159, 39, 0.30);
}

.tab.is-active svg { stroke-width: 2.4; }

/* --------------------------------------------------------------------------
   4. Components
   -------------------------------------------------------------------------- */

/* --- Buttons ------------------------------------------------------------ */
/* Brand sheet: fully-rounded pills, Poppins SemiBold, flat fills.
   Primary = Primary Orange, Secondary = Dark Brown, Outline = orange stroke.
   Add .btn--arrow to get the trailing arrow shown on the sheet. */

.btn {
  --btn-bg: var(--primary);
  --btn-hover: var(--primary-600);
  --btn-fg: #fff;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 46px;
  padding: 12px 24px;
  border-radius: var(--r-pill);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-family: var(--font-head);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  box-shadow: 0 6px 14px rgba(232, 90, 42, 0.28);
  transition: transform 0.12s var(--ease-out), background-color 0.18s var(--ease-out),
              box-shadow 0.18s var(--ease-out);
  user-select: none;
}

.btn:hover { background: var(--btn-hover); color: var(--btn-fg); }

.btn:active {
  transform: scale(0.98);
  box-shadow: 0 2px 6px rgba(232, 90, 42, 0.22);
}

.btn--arrow::after,
.text-link--arrow::after {
  content: '';
  width: 1.05em;
  height: 1.05em;
  flex: none;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14M13 6l6 6-6 6'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14M13 6l6 6-6 6'/%3E%3C/svg%3E") center / contain no-repeat;
}

.btn[disabled],
.btn.is-disabled {
  --btn-bg: var(--surface-3);
  --btn-hover: var(--surface-3);
  --btn-fg: var(--text-faint);
  cursor: not-allowed;
  box-shadow: none;
}

.btn--secondary { --btn-bg: var(--brown-dark); --btn-hover: var(--brown-warm); --btn-fg: var(--neutral); box-shadow: 0 6px 14px rgba(58, 31, 20, 0.30); }
.btn--tertiary  { --btn-bg: var(--tertiary);  --btn-hover: var(--tertiary-700); box-shadow: 0 6px 14px rgba(230, 57, 70, 0.26); }
.btn--success   { --btn-bg: var(--success);   --btn-hover: var(--success-dark); --btn-fg: #fff; box-shadow: 0 6px 14px rgba(40, 167, 69, 0.26); }
.btn--inverted  { --btn-bg: var(--brown-dark); --btn-hover: var(--brown-warm); --btn-fg: var(--neutral); box-shadow: none; }
.btn--neutral   { --btn-bg: var(--neutral);   --btn-hover: var(--neutral-200); --btn-fg: var(--brown-dark); box-shadow: none; }

.btn--outline {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
  box-shadow: none;
}
.btn--outline:hover { background: var(--primary); color: #fff; }
.btn--outline:active { transform: scale(0.98); }

.btn--ghost {
  background: transparent;
  color: var(--primary);
  box-shadow: none;
  font-weight: 600;
}
.btn--ghost:hover { background: transparent; color: var(--primary-600); }

/* "Continue with Google" — same pill and type as the other buttons, on the warm
   dark surface instead of orange so the primary action stays the loudest thing.
   The G keeps Google's own colours (their brand rule) on a cream disc for contrast. */
.btn--google {
  --btn-bg: var(--surface-2);
  --btn-hover: var(--surface-3);
  --btn-fg: var(--text);
  border: 1.5px solid var(--line-strong);
  box-shadow: none;
  text-decoration: none;
}
.btn--google:hover { border-color: var(--primary); box-shadow: var(--glow-primary); }
.btn--google:active { box-shadow: none; }
.btn--google__mark {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: 50%;
  background: var(--neutral);
}
.btn--google__mark svg { width: 16px; height: 16px; display: block; }

.auth__or {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 14px;
  color: var(--text-faint);
  font-size: 0.8rem;
  font-weight: 600;
}
.auth__or::before,
.auth__or::after { content: ''; flex: 1; height: 1px; background: var(--line); }

.btn--sm { min-height: 36px; padding: 8px 18px; font-size: 0.82rem; }
.btn--auto { width: auto; }

/* Text link (brand sheet: orange, semibold) */
.text-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--primary);
  font-weight: 600;
}
.text-link:hover { color: var(--primary-600); }

.icon-btn {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 3px 0 var(--primary-700);
  flex: none;
}
.icon-btn:active { transform: translateY(3px); box-shadow: none; }
.icon-btn--secondary { background: var(--secondary); color: var(--text-inverted); box-shadow: 0 3px 0 var(--secondary-700); }
.icon-btn--tertiary  { background: var(--tertiary);  box-shadow: 0 3px 0 var(--tertiary-700); }
.icon-btn--quiet     { background: var(--surface-2); color: var(--text-muted); box-shadow: none; border: 1px solid var(--line); }

/* --- Cards -------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.card--flat { box-shadow: none; }
.card--tight { padding: 12px; }

.card--accent {
  background: linear-gradient(140deg, var(--primary) 0%, var(--primary-700) 100%);
  border-color: transparent;
  color: #fff;
  position: relative;
  overflow: hidden;
}

/* Soft light bloom in the corner of accent cards, as in the Plus promo. */
.card--accent::after {
  content: '';
  position: absolute;
  right: -50px;
  top: -60px;
  width: 190px;
  height: 190px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.10);
  pointer-events: none;
}

.card__title {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 1rem;
  margin: 0 0 2px;
}

.card__sub { color: var(--text-muted); font-size: 0.84rem; margin: 0; }

.section-title {
  font-family: var(--font-head);
  font-size: 1.15rem;
  font-weight: 800;
  margin: 22px 0 10px;
}
.section-title:first-child { margin-top: 0; }

/* --- Progress ----------------------------------------------------------- */

.bar {
  height: 14px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  overflow: hidden;
  position: relative;
}

.bar__fill {
  height: 100%;
  border-radius: var(--r-pill);
  background: var(--secondary);
  transition: width 0.6s var(--ease-out);
  position: relative;
}

/* A highlight along the top of the fill keeps it reading as a 3D capsule. */
.bar__fill::after {
  content: '';
  position: absolute;
  inset: 3px 6px auto 6px;
  height: 3px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.30);
}

.bar--primary .bar__fill { background: var(--primary); }
.bar--success .bar__fill { background: var(--success); }
.bar--slim { height: 9px; }
.bar--slim .bar__fill::after { display: none; }

/* --- Pills & badges ----------------------------------------------------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-family: var(--font-head);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
}

.pill--primary   { background: rgba(216, 90, 48, 0.16); color: var(--primary-300); border-color: rgba(216, 90, 48, 0.35); }
.pill--secondary { background: rgba(239, 159, 39, 0.16); color: var(--secondary); border-color: rgba(239, 159, 39, 0.35); }
.pill--success   { background: rgba(88, 204, 97, 0.14); color: var(--success); border-color: rgba(88, 204, 97, 0.32); }
.pill--muted     { color: var(--text-faint); }

.badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: var(--r-pill);
  background: var(--danger);
  color: #fff;
  font-family: var(--font-head);
  font-size: 0.68rem;
  font-weight: 800;
  display: grid;
  place-items: center;
}

/* --- Avatars ------------------------------------------------------------ */

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--neutral);
  border: 2px solid var(--line-strong);
  overflow: hidden;
  flex: none;
  display: grid;
  place-items: center;
}

.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--sm { width: 34px; height: 34px; }
.avatar--lg { width: 84px; height: 84px; border-width: 3px; }
.avatar--xl { width: 104px; height: 104px; border-width: 4px; }
.avatar--gold   { border-color: var(--gold); }
.avatar--silver { border-color: var(--silver); }
.avatar--bronze { border-color: var(--bronze); }
.avatar--me     { border-color: var(--primary); }

/* Profile frames — owned cosmetics from the store (main/store_engine.py FRAMES).
   Drawn as rings outside the avatar so they never crop the picture. */
.frame--ember    { border-color: #FF8A34; box-shadow: 0 0 0 3px #D85A30, 0 0 14px 2px rgba(255, 138, 52, .55); }
.frame--river    { border-color: #7FD8EE; box-shadow: 0 0 0 3px #2E93AC, 0 0 12px 1px rgba(76, 194, 224, .45); }
.frame--aurora   { border-color: transparent; box-shadow: 0 0 0 3px #58CC61, 0 0 0 6px #4CC2E0, 0 0 16px 4px rgba(155, 110, 230, .45); }
.frame--beadwork { border-color: #FAEEDA; box-shadow: 0 0 0 3px #A32D2D, 0 0 0 6px #EF9F27; }

/* --- Forms -------------------------------------------------------------- */

.field { margin-bottom: 14px; }

.field label {
  display: block;
  font-family: var(--font-head);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.input,
.field input[type='text'],
.field input[type='email'],
.field input[type='password'],
.field input[type='time'],
.field select,
.field textarea {
  width: 100%;
  min-height: 46px;
  padding: 12px 20px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  border: 1.5px solid var(--line-strong);
  color: var(--text);
  transition: border-color 0.18s var(--ease-out), box-shadow 0.18s var(--ease-out);
}

.input::placeholder,
.field input::placeholder { color: var(--text-faint); }

.input:focus,
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--glow-primary);
}

.field textarea { border-radius: var(--r-lg); }

.field .helptext,
.field .errorlist {
  font-size: 0.78rem;
  margin: 6px 0 0;
  color: var(--text-faint);
}

.field .errorlist { color: var(--danger); }

.checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.checkbox input { width: 18px; height: 18px; accent-color: var(--primary); }

.form-error {
  background: rgba(224, 83, 61, 0.12);
  border: 1px solid rgba(224, 83, 61, 0.35);
  color: #F3A99C;
  border-radius: var(--r-md);
  padding: 11px 14px;
  font-size: 0.86rem;
  margin-bottom: 14px;
}

/* --- Toasts ------------------------------------------------------------- */

.toast-stack {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--bottomnav-h) + var(--safe-bottom) + 16px);
  z-index: 90;
  width: min(92%, 420px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--r-md);
  background: var(--surface-3);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-md);
  font-weight: 600;
  font-size: 0.88rem;
  animation: toast-in 0.32s var(--ease-bounce);
}

.toast--success { border-color: rgba(88, 204, 97, 0.4); }
.toast--error   { border-color: rgba(224, 83, 61, 0.4); }
.toast--info    { border-color: rgba(239, 159, 39, 0.4); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(14px) scale(0.96); }
  to   { opacity: 1; transform: none; }
}

/* --- Offline banner ----------------------------------------------------- */

.offline-banner {
  position: sticky;
  top: calc(var(--topnav-h) + var(--safe-top));
  z-index: 39;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--surface-3);
  border-bottom: 1px solid var(--line-strong);
  color: var(--secondary);
  font-family: var(--font-head);
  font-size: 0.78rem;
  font-weight: 700;
}

body.is-offline .offline-banner { display: flex; }

.offline-banner .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--secondary);
  animation: pulse 1.8s ease-in-out infinite;
}

@keyframes pulse { 50% { opacity: 0.25; } }

.sync-pending {
  font-size: 0.72rem;
  color: var(--text-faint);
  font-weight: 600;
}

/* --- Modal / sheet ------------------------------------------------------ */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(10, 8, 7, 0.66);
  backdrop-filter: blur(3px);
  display: none;
  align-items: flex-end;
  justify-content: center;
}

.sheet-backdrop.is-open { display: flex; }

.sheet {
  width: 100%;
  max-width: var(--shell-max);
  background: var(--bg-elevated);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  border-top: 1px solid var(--line-strong);
  padding: 10px 18px calc(24px + var(--safe-bottom));
  max-height: 86dvh;
  overflow-y: auto;
  animation: sheet-up 0.30s var(--ease-out);
}

@keyframes sheet-up {
  from { transform: translateY(100%); }
  to   { transform: none; }
}

.sheet__grab {
  width: 42px;
  height: 4px;
  border-radius: var(--r-pill);
  background: var(--line-strong);
  margin: 6px auto 14px;
}

.sheet__title { font-family: var(--font-head); font-weight: 800; font-size: 1.15rem; margin-bottom: 4px; }

/* --- Empty state -------------------------------------------------------- */

.empty {
  text-align: center;
  padding: 46px 20px;
  color: var(--text-muted);
}

.empty__icon {
  width: 66px;
  height: 66px;
  margin: 0 auto 14px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  color: var(--text-faint);
}

.empty h3 { color: var(--text); }

/* --- Utilities ---------------------------------------------------------- */

.row { display: flex; align-items: center; gap: 10px; }
.row--between { justify-content: space-between; }
.row--wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.tiny  { font-size: 0.74rem; }
.small { font-size: 0.84rem; }
.strong { font-weight: 700; }
.head { font-family: var(--font-head); font-weight: 800; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.hidden { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.divider { height: 1px; background: var(--line); margin: 16px 0; }

/* --------------------------------------------------------------------------
   5. Motion preferences

   Taken from the reader's operating system, not from an in-app toggle: a
   person who has asked their phone to reduce motion should not have to ask
   every app again.
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* --- XP boost chip --------------------------------------------------------- */

.boost-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 0 0 14px;
  padding: 8px 14px;
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--secondary) 18%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--secondary) 45%, transparent);
  color: var(--secondary);
  font-size: 0.82rem;
}

.boost-chip svg { width: 16px; height: 16px; }
.boost-chip strong { font-family: var(--font-head); }

/* --- Language badge fallback (see main/_flag.html) ---------------------------- */
.flag-feather { display: block; width: 1em; height: 1em; color: var(--course-color, var(--lang-color, var(--primary))); }

/* Out of hearts: the count itself pulses so it can't be missed. */
.stat-chip--hearts.is-out { animation: heartsOut 1.6s ease-in-out infinite; }
@keyframes heartsOut { 50% { opacity: 0.45; } }
@media (prefers-reduced-motion: reduce) { .stat-chip--hearts.is-out { animation: none; } }
