/* ==========================================================================
   Doopa — design system
   ========================================================================== */

:root {
  --brand: #12B76A;
  --brand-600: #0E9F5C;
  --brand-700: #0B7F4A;
  --brand-50: #E6F8EF;
  --grad-brand: linear-gradient(135deg, #3BE38B 0%, #12B76A 48%, #0BA5A0 100%);
  --coral: #FF6B4A;
  --grad-fire: linear-gradient(135deg, #FFB547 0%, #FF6B4A 55%, #F43F5E 100%);
  --sun: #FFB020;
  --grad-sun: linear-gradient(135deg, #FFD66B 0%, #FFB020 60%, #F79009 100%);
  --violet: #7C5CFF;
  --grad-violet: linear-gradient(135deg, #A78BFA 0%, #7C5CFF 55%, #5B3DF5 100%);
  --sky: #2E90FA;
  --danger: #F04438;
  --warning: #F79009;
  --grad-title: linear-gradient(100deg, #0B8A50 0%, #0B8A7A 55%, #0A6F8F 100%);

  --bg: #F3F6F4;
  --surface: #FFFFFF;
  --surface-grad: linear-gradient(155deg, #FFFFFF 0%, #FFFFFF 30%, #EAF6EF 100%);
  --surface-2: #EDF2EF;
  --surface-3: #DFE7E2;
  --text: #0E1A14;
  --text-2: #55665D;
  --text-3: #8A9A92;
  --border: rgba(14, 26, 20, .08);
  --glass: rgba(255, 255, 255, .8);
  --shadow-sm: 0 1px 2px rgba(14, 26, 20, .05), 0 2px 6px rgba(14, 26, 20, .04);
  --shadow: 0 10px 30px -12px rgba(14, 26, 20, .18);
  --shadow-lg: 0 30px 60px -20px rgba(14, 26, 20, .35);

  --radius-sm: 12px;
  --radius: 18px;
  --radius-lg: 24px;
  --tabbar-h: 66px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Rounded", "SF Pro Display", "Segoe UI", Roboto, sans-serif;

  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0A0F0C;
  --surface: #131A16;
  --surface-grad: linear-gradient(155deg, #1C2721 0%, #131A16 55%, #0F1512 100%);
  --surface-2: #1B241F;
  --surface-3: #26322B;
  --text: #ECF3EF;
  --text-2: #A3B5AB;
  --text-3: #6E8177;
  --border: rgba(255, 255, 255, .07);
  --brand-50: rgba(18, 183, 106, .15);
  --grad-title: linear-gradient(100deg, #5BEA9B 0%, #2FD3A4 50%, #3CC8E0 100%);
  --glass: rgba(19, 26, 22, .82);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow: 0 10px 30px -12px rgba(0, 0, 0, .7);
  --shadow-lg: 0 30px 60px -20px rgba(0, 0, 0, .8);
  color-scheme: dark;
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overscroll-behavior: none;
  transition: background-color .3s;
}

h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); letter-spacing: -.02em; line-height: 1.15; }
p { margin: 0; }
a { color: inherit; }
button { font: inherit; color: inherit; }
img, svg { display: block; }
.icon { width: 22px; height: 22px; flex-shrink: 0; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- App frame (mobile layout everywhere) ---------- */

.app {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  isolation: isolate;
}

@media (min-width: 520px) {
  body {
    display: grid;
    place-items: center;
    min-height: 100vh;
    background:
      radial-gradient(900px 600px at 15% 10%, rgba(59, 227, 139, .22), transparent 60%),
      radial-gradient(800px 600px at 85% 90%, rgba(11, 165, 160, .2), transparent 60%),
      var(--bg);
  }
  [data-theme="dark"] body {
    background:
      radial-gradient(900px 600px at 15% 10%, rgba(59, 227, 139, .12), transparent 60%),
      radial-gradient(800px 600px at 85% 90%, rgba(11, 165, 160, .1), transparent 60%),
      #050806;
  }
  .app {
    --safe-top: 12px;
    --safe-bottom: 16px;
    width: 430px;
    height: min(932px, calc(100dvh - 48px));
    border-radius: 44px;
    box-shadow: var(--shadow-lg), 0 0 0 1px var(--border), 0 0 0 10px rgba(14, 26, 20, .06);
  }
}

.view { position: absolute; inset: 0; }
.app.has-tabbar .view { bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 18px); }

.screen {
  position: absolute;
  inset: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  animation: screenIn .45s var(--ease-out) both;
}
.screen.from-right { animation-name: screenInRight; }
.screen.from-left { animation-name: screenInLeft; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(var(--safe-top) + 14px) 20px 12px;
  background: var(--bg);
}
.topbar::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: 16px;
  background: linear-gradient(to bottom, var(--bg), transparent);
  pointer-events: none;
}
.topbar-title { flex: 1; min-width: 0; }
.topbar h1, .auth-hero h1, .onb-step h1 {
  width: fit-content;
  max-width: 100%;
  background: var(--grad-title);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.title-emoji { color: var(--text); }
.topbar h1 { font-size: 30px; font-weight: 800; }
.topbar.greet h1 { font-size: 24px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-sub {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-3);
  white-space: nowrap;
}
.xp-total { display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0; color: var(--brand); }
.xp-total .icon { width: 14px; height: 14px; }
.xp-level { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.xp-level::before { content: '·'; margin-right: 8px; }

.content { padding: 4px 20px 24px; }

/* ---------- Splash ---------- */

.splash {
  position: absolute;
  inset: 0;
  z-index: 500;
  display: grid;
  place-items: center;
  background: var(--bg);
  transition: opacity .4s var(--ease-out), visibility .4s;
}
.splash.hide { opacity: 0; visibility: hidden; }
.splash-logo { display: flex; flex-direction: column; align-items: center; gap: 14px; animation: pulse 1.6s ease-in-out infinite; }
.splash-logo img { border-radius: 24px; box-shadow: var(--shadow); }
.splash-logo span { font-family: var(--font-display); font-size: 28px; font-weight: 800; letter-spacing: -.03em; color: var(--brand); }

/* ---------- Tab bar ---------- */

.tabbar {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: calc(var(--safe-bottom) + 10px);
  z-index: 50;
  height: var(--tabbar-h);
  display: flex;
  padding: 0 6px;
  border-radius: 26px;
  background: var(--glass);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  box-shadow: var(--shadow), 0 0 0 1px var(--border);
  transform: translateY(calc(100% + 40px));
  transition: transform .5s var(--ease-out);
}
.app.has-tabbar .tabbar { transform: none; }

.tab-indicator {
  position: absolute;
  top: 8px;
  left: 6px;
  width: calc((100% - 12px) / 5);
  height: calc(100% - 16px);
  border-radius: 20px;
  background: var(--brand-50);
  transition: transform .45s var(--ease-spring);
}

.tab {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-3);
  text-decoration: none;
  transition: color .25s;
}
.tab .icon { width: 23px; height: 23px; transition: transform .35s var(--ease-spring); }
.tab.active { color: var(--brand); }
.tab.active .icon { transform: translateY(-1px) scale(1.1); }
.tab:active .icon { transform: scale(.88); }

/* ---------- Buttons ---------- */

.btn {
  position: relative;
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 54px;
  padding: 0 24px;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: transform .18s var(--ease-out), box-shadow .2s, opacity .2s, background-color .2s;
}
.btn:active { transform: scale(.96); }
.btn:focus-visible { outline: 3px solid var(--brand-50); outline-offset: 2px; }
.btn-block { width: 100%; }
.btn-sm { height: 40px; padding: 0 16px; font-size: 14px; }
.btn-primary { background: var(--grad-brand); color: #fff; box-shadow: 0 12px 24px -12px rgba(18, 183, 106, .8); }
.btn-secondary { background: var(--surface-2); color: var(--text); }
.btn-ghost { background: transparent; color: var(--brand); }
.btn-danger { background: rgba(240, 68, 56, .1); color: var(--danger); }
.btn-danger-solid { background: var(--danger); color: #fff; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, .9);
  border-right-color: transparent;
  animation: spin .7s linear infinite;
}
.btn-secondary.is-loading::after, .btn-ghost.is-loading::after, .btn-danger.is-loading::after { border-color: var(--brand); border-right-color: transparent; }

.icon-btn {
  appearance: none;
  border: 0;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 15px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm), 0 0 0 1px var(--border);
  cursor: pointer;
  transition: transform .18s var(--ease-out);
  text-decoration: none;
}
.icon-btn:active { transform: scale(.9); }
.icon-btn.primary { background: var(--grad-brand); color: #fff; box-shadow: 0 10px 20px -10px rgba(18, 183, 106, .9); }
.icon-btn.round { border-radius: 50%; }

.link { color: var(--brand); font-weight: 700; text-decoration: none; }
.link:active { opacity: .6; }

/* ---------- Forms ---------- */

.field { margin-bottom: 16px; }
.label { display: block; margin: 0 4px 8px; font-size: 13px; font-weight: 700; color: var(--text-2); }
.hint { margin: 6px 4px 0; font-size: 13px; color: var(--text-3); }

.input {
  width: 100%;
  height: 56px;
  padding: 0 18px;
  border: 1.5px solid transparent;
  border-radius: 16px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 16px; /* evita zoom automático no iOS */
  -webkit-appearance: none;
  appearance: none;
  transition: border-color .2s, background-color .2s, box-shadow .2s;
}
.input::placeholder { color: var(--text-3); }
.input:focus { outline: none; border-color: var(--brand); background: var(--surface); box-shadow: 0 0 0 4px var(--brand-50); }
.input.has-error { border-color: var(--danger); box-shadow: 0 0 0 4px rgba(240, 68, 56, .12); }
input[type="time"].input { display: flex; align-items: center; min-height: 56px; line-height: 56px; }
input[type="time"].input::-webkit-date-and-time-value { text-align: left; }
input[type="time"].input::-webkit-calendar-picker-indicator { opacity: .5; }
.date-trigger { display: flex; align-items: center; min-width: 0; text-align: left; cursor: pointer; }
.date-trigger span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.date-trigger .date-placeholder { color: var(--text-3); }
.date-time-row { display: grid; grid-template-columns: minmax(0, 1fr) 116px; gap: 8px; }
select.input {
  padding-right: 44px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238A9A92' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  background-size: 18px;
}

.input-wrap { position: relative; }
.input-wrap.with-icon .input { padding-left: 50px; }
.input-wrap .lead-icon { position: absolute; left: 17px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; color: var(--text-3); pointer-events: none; transition: color .2s; }
.input-wrap:focus-within .lead-icon { color: var(--brand); }
.input-wrap.with-action .input { padding-right: 56px; }
.input-action {
  position: absolute;
  right: 6px;
  top: 6px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
}
.input-suffix { position: absolute; right: 18px; top: 50%; transform: translateY(-50%); color: var(--text-3); font-weight: 600; pointer-events: none; }
.input-wrap.with-suffix .input { padding-right: 52px; }

.field-error { margin: 6px 4px 0; font-size: 13px; font-weight: 600; color: var(--danger); animation: shake .35s; }
.field-error:empty { display: none; }

.checkbox { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; font-size: 14px; color: var(--text-2); line-height: 1.4; }
.checkbox input { position: absolute; opacity: 0; pointer-events: none; }
.checkbox .box {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  border: 2px solid var(--surface-3);
  background: var(--surface);
  color: transparent;
  transition: all .25s var(--ease-spring);
}
.checkbox .box .icon { width: 16px; height: 16px; stroke-width: 3; }
.checkbox input:checked + .box { background: var(--brand); border-color: var(--brand); color: #fff; transform: scale(1.06); }
.checkbox input:focus-visible + .box { box-shadow: 0 0 0 4px var(--brand-50); }

.switch { position: relative; display: inline-block; width: 52px; height: 32px; flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch .track { position: absolute; inset: 0; border-radius: 99px; background: var(--surface-3); transition: background .25s; }
.switch .track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .2);
  transition: transform .35s var(--ease-spring);
}
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(20px); }

.segmented { position: relative; display: flex; padding: 4px; border-radius: 16px; background: var(--surface-2); }
.segmented label { flex: 1; position: relative; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 42px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-2);
  cursor: pointer;
  transition: all .25s var(--ease-out);
}
.segmented span .icon { width: 17px; height: 17px; }
.segmented input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.strength { display: flex; gap: 6px; margin: 10px 4px 0; }
.strength i { flex: 1; height: 5px; border-radius: 3px; background: var(--surface-3); transition: background .3s; }
.strength[data-score="1"] i:nth-child(-n+1) { background: var(--danger); }
.strength[data-score="2"] i:nth-child(-n+2) { background: var(--warning); }
.strength[data-score="3"] i:nth-child(-n+3) { background: #84CC16; }
.strength[data-score="4"] i { background: var(--brand); }
.strength-label { margin: 6px 4px 0; font-size: 12px; font-weight: 600; color: var(--text-3); }

/* ---------- Cards & lists ---------- */

.card {
  background: var(--surface-grad);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm), 0 0 0 1px var(--border);
}

.section-title {
  margin: 26px 8px 10px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-3);
}

.list {
  overflow: hidden;
  border-radius: 22px;
  background: var(--surface-grad);
  box-shadow: var(--shadow-sm), 0 0 0 1px var(--border);
}
.list-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 60px;
  padding: 12px 16px;
  border: 0;
  background: none;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .15s;
}
.list-item + .list-item { border-top: 1px solid var(--border); }
.list-item:active { background: var(--surface-2); }
.list-item.static { cursor: default; }
.list-item.static:active { background: none; }
.list-icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  color: #fff;
  background: var(--brand);
}
.list-icon .icon { width: 19px; height: 19px; }
.list-icon.violet { background: var(--violet); }
.list-icon.sky { background: var(--sky); }
.list-icon.sun { background: var(--sun); }
.list-icon.coral { background: var(--coral); }
.list-icon.gray { background: #64748B; }
.list-icon.danger { background: var(--danger); }
.list-text { flex: 1; min-width: 0; }
.list-title { display: block; font-weight: 650; font-size: 15.5px; }
.list-sub { display: block; font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-value { color: var(--text-3); font-size: 14px; white-space: nowrap; }
.list-chevron { color: var(--text-3); width: 18px; height: 18px; }
.list-item.danger .list-title { color: var(--danger); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 12px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 700;
  background: var(--brand-50);
  color: var(--brand-700);
}
[data-theme="dark"] .chip { color: #6EE7B7; }

.progress { height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: inherit; background: var(--grad-brand); width: 0; transition: width 1s var(--ease-out); }

.empty { padding: 36px 24px; text-align: center; color: var(--text-2); }
.empty .mascot { margin: 0 auto 16px; }
.empty h3 { font-size: 20px; color: var(--text); margin-bottom: 6px; }

.divider { display: flex; align-items: center; gap: 12px; margin: 20px 0; color: var(--text-3); font-size: 13px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ---------- Auth ---------- */

.auth {
  position: relative;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  padding: calc(var(--safe-top) + 20px) 24px calc(var(--safe-bottom) + 24px);
  overflow: hidden;
}
.auth-bg { position: absolute; inset: 0; z-index: -1; pointer-events: none; }
.auth-bg span { position: absolute; border-radius: 50%; filter: blur(50px); opacity: .5; animation: float 12s ease-in-out infinite; }
.auth-bg span:nth-child(1) { width: 260px; height: 260px; top: -80px; left: -60px; background: #3BE38B; }
.auth-bg span:nth-child(2) { width: 220px; height: 220px; top: 120px; right: -90px; background: #0BA5A0; animation-delay: -4s; opacity: .35; }
.auth-bg span:nth-child(3) { width: 180px; height: 180px; bottom: -60px; left: 30%; background: #FFD66B; animation-delay: -8s; opacity: .25; }
[data-theme="dark"] .auth-bg span { opacity: .18; }

.auth-top { display: flex; align-items: center; min-height: 44px; }
.auth-main { width: 100%; max-width: 420px; margin: auto; }
.auth-main + .auth-footer { margin-top: 0; }
.auth-hero { display: flex; flex-direction: column; align-items: center; text-align: center; margin: 12px 0 28px; }
.auth-hero h1 { margin-top: 16px; font-size: 30px; font-weight: 800; letter-spacing: -.03em; }
.auth-hero .lead { margin-top: 8px; color: var(--text-2); font-size: 16px; max-width: 300px; }
.auth-footer { margin-top: auto; padding-top: 28px; text-align: center; color: var(--text-2); font-size: 15px; }
.row-end { display: flex; justify-content: flex-end; margin: -4px 0 20px; }
.small { font-size: 14px; }

.success-state { text-align: center; padding: 20px 0; }
.success-state .badge-icon {
  width: 84px;
  height: 84px;
  margin: 0 auto 20px;
  display: grid;
  place-items: center;
  border-radius: 28px;
  background: var(--grad-brand);
  color: #fff;
  box-shadow: 0 16px 30px -12px rgba(18, 183, 106, .8);
  animation: pop .6s var(--ease-spring) both;
}
.success-state .badge-icon .icon { width: 40px; height: 40px; stroke-width: 2.5; }
.success-state h2 { font-size: 24px; margin-bottom: 8px; }
.success-state p { color: var(--text-2); }

.legal { padding-bottom: 40px; color: var(--text-2); font-size: 15px; line-height: 1.6; }
.legal h2 { color: var(--text); font-size: 18px; margin: 24px 0 8px; }
.legal p, .legal ul { margin: 0 0 10px; }
.legal ul { padding-left: 20px; }

/* ---------- Onboarding ---------- */

.onb { min-height: 100%; display: flex; flex-direction: column; padding: calc(var(--safe-top) + 14px) 20px calc(var(--safe-bottom) + 20px); }
.onb-head { display: flex; align-items: center; gap: 14px; margin-bottom: 26px; }
.onb-head .icon-btn { transition: opacity .2s, transform .18s; }
.onb-head .icon-btn.invisible { opacity: 0; pointer-events: none; }
.onb-progress { flex: 1; height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.onb-progress i { display: block; height: 100%; background: var(--grad-brand); border-radius: inherit; transition: width .6s var(--ease-out); }
.onb-step { flex: 1; display: flex; flex-direction: column; }
.onb-step.anim-forward { animation: screenInRight .45s var(--ease-out) both; }
.onb-step.anim-back { animation: screenInLeft .45s var(--ease-out) both; }
.onb-step h1 { font-size: 28px; font-weight: 800; margin-bottom: 8px; }
.onb-step .lead { color: var(--text-2); margin-bottom: 26px; }
.onb-actions { margin-top: auto; padding-top: 20px; }

.choices { display: grid; gap: 12px; }
.choices.two { grid-template-columns: 1fr 1fr; }
.choice {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 16px;
  border: 2px solid transparent;
  border-radius: 20px;
  background: var(--surface-grad);
  box-shadow: var(--shadow-sm), 0 0 0 1px var(--border);
  text-align: left;
  cursor: pointer;
  transition: transform .2s var(--ease-out), border-color .2s, background-color .2s;
}
.choice:active { transform: scale(.97); }
.choice .emoji { font-size: 30px; line-height: 1; flex-shrink: 0; }
.choice strong { display: block; font-size: 16px; }
.choice small { display: block; color: var(--text-2); font-size: 13px; margin-top: 2px; }
.choice.vertical { flex-direction: column; text-align: center; padding: 22px 12px; }
.choice.vertical .emoji { font-size: 44px; }
.choice.selected { border-color: var(--brand); background: var(--brand-50); }
.choice .check {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  transform: scale(0);
  transition: transform .3s var(--ease-spring);
}
.choice .check .icon { width: 14px; height: 14px; stroke-width: 3; }
.choice.selected .check { transform: scale(1); }

.goal-result { text-align: center; padding: 10px 0 0; }
.goal-result h1 { margin-inline: auto; }
.goal-result .mascot { margin: 0 auto 10px; }
.big-number {
  font-family: var(--font-display);
  font-size: 68px;
  font-weight: 800;
  letter-spacing: -.04em;
  line-height: 1;
  background: var(--grad-brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-variant-numeric: tabular-nums;
}
.big-unit { color: var(--text-2); font-weight: 700; margin-top: 6px; }
.goal-note { margin: 18px auto 0; max-width: 320px; font-size: 13px; color: var(--text-3); }

/* ---------- Settings / profile ---------- */

.profile-card { display: flex; align-items: center; gap: 16px; }
.avatar {
  position: relative;
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  background: var(--grad-brand);
  color: #fff;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 800;
  box-shadow: 0 10px 20px -12px rgba(18, 183, 106, .9);
}
.avatar img { display: block; width: 100%; height: 100%; object-fit: cover; }
.avatar.lg { width: 64px; height: 64px; font-size: 24px; }
.avatar.xl { width: 112px; height: 112px; font-size: 40px; }
.avatar.loading img { opacity: .5; }
.avatar.loading::after {
  content: "";
  position: absolute;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid #fff;
  border-right-color: transparent;
  animation: spin .7s linear infinite;
}
.avatar-btn {
  position: relative;
  flex-shrink: 0;
  appearance: none;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform .18s;
}
.avatar-btn:active { transform: scale(.94); }
.avatar-btn:focus-visible { outline: 3px solid var(--brand-50); outline-offset: 2px; }
.avatar-edit {
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow), 0 0 0 1px var(--border);
}
.avatar-edit .icon { width: 14px; height: 14px; }
.avatar-preview { display: flex; justify-content: center; padding: 4px 0 20px; }
.avatar-hint { margin-top: 12px; text-align: center; }
.file-overlay { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; font-size: 0; }
.sheet.is-busy .list { opacity: .5; pointer-events: none; }
.profile-card h2 { font-size: 20px; }
.profile-card p { color: var(--text-2); font-size: 14px; overflow: hidden; text-overflow: ellipsis; }
/* ---------- Journey ---------- */

.hero-card {
  position: relative;
  overflow: hidden;
  padding: 24px 20px;
  border-radius: 28px;
  background: var(--grad-brand);
  color: #fff;
  box-shadow: 0 20px 40px -20px rgba(18, 183, 106, .9);
}
.hero-card::before {
  content: "";
  position: absolute;
  width: 240px;
  height: 240px;
  right: -80px;
  top: -100px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .14);
}
.hero-card .mascot { margin: 0 auto; }
.hero-card h2 { text-align: center; font-size: 22px; margin-top: 8px; }
.hero-card .sub { text-align: center; opacity: .9; font-weight: 600; font-size: 14px; }
.hero-card .progress { margin-top: 18px; background: rgba(255, 255, 255, .25); }
.hero-card .progress > i { background: #fff; }
.hero-card .xp-row { display: flex; justify-content: space-between; margin-top: 8px; font-size: 13px; font-weight: 700; opacity: .95; }

.journey-hero {
  --hero-rgb: 11 128 99;
  --hero-ink: #0A5641;
  margin-top: 12px;
  padding-top: 28px;
  background: linear-gradient(155deg, rgb(var(--hero-rgb) / .08) 0%, rgb(var(--hero-rgb) / .24) 100%);
  box-shadow: none;
  color: var(--hero-ink);
  transition: background-color .5s;
}
.journey-hero::before { content: none; }
.journey-hero.tone-good { --hero-rgb: 47 127 104; --hero-ink: #1F5747; }
.journey-hero.tone-okay { --hero-rgb: 94 115 48; --hero-ink: #42521C; }
.journey-hero.tone-stuffed { --hero-rgb: 184 92 30; --hero-ink: #873E0F; }
.journey-hero.tone-wilted { --hero-rgb: 109 104 83; --hero-ink: #4B4738; }
.journey-hero.tone-resting { --hero-rgb: 63 122 115; --hero-ink: #285650; }
[data-theme="dark"] .journey-hero { --hero-ink: var(--text); background: linear-gradient(155deg, rgb(var(--hero-rgb) / .2) 0%, rgb(var(--hero-rgb) / .4) 100%); }
.journey-hero .sub,
.journey-hero .xp-row,
.journey-hero .hero-next { opacity: 1; }
.journey-hero .progress { background: rgb(var(--hero-rgb) / .2); }
.journey-hero .progress > i { background: rgb(var(--hero-rgb)); }
.journey-hero .xp-today { background: rgb(var(--hero-rgb) / .14); backdrop-filter: none; -webkit-backdrop-filter: none; }
.xp-today {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 1;
  padding: 5px 10px;
  border-radius: 99px;
  background: rgba(255, 255, 255, .22);
  font-size: 12px;
  font-weight: 800;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.mascot-says {
  margin: 10px auto 0;
  max-width: 300px;
  padding: 0 6px;
  text-align: center;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.45;
}
.hero-next { margin-top: 12px; text-align: center; font-size: 13px; opacity: .92; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.section-head .section-title { flex: 1; }
.section-aside { margin-right: 8px; font-size: 12.5px; font-weight: 700; color: var(--text-3); white-space: nowrap; }

.streak-card { margin-top: 14px; }
.streak-top { display: flex; align-items: center; gap: 14px; }
.streak-flame {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  font-size: 28px;
  background: var(--surface-2);
  filter: grayscale(1);
  opacity: .7;
  transition: filter .4s, opacity .4s;
}
.streak-card.lit .streak-flame { background: rgba(255, 107, 74, .14); filter: none; opacity: 1; animation: flicker 2.4s ease-in-out infinite; }
.streak-main { flex: 1; min-width: 0; }
.streak-main strong { display: block; font-family: var(--font-display); font-size: 32px; font-weight: 800; line-height: 1; }
.streak-main span { font-size: 13px; font-weight: 700; color: var(--text-2); }
.shields { display: flex; gap: 2px; padding: 6px 8px; border: 0; border-radius: 12px; background: var(--surface-2); cursor: pointer; }
.shield { font-size: 18px; filter: grayscale(1); opacity: .3; transition: all .3s; }
.shield.on { filter: none; opacity: 1; }
.streak-week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 18px; }
.sw-day { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.sw-dot {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 16px;
  background: var(--surface-2);
}
.sw-label { font-size: 11.5px; font-weight: 800; color: var(--text-3); }
.sw-day.active .sw-dot { background: rgba(255, 107, 74, .16); box-shadow: inset 0 0 0 2px rgba(255, 107, 74, .5); }
.sw-day.shield .sw-dot { background: rgba(46, 144, 250, .14); box-shadow: inset 0 0 0 2px rgba(46, 144, 250, .45); }
.sw-day.missed .sw-dot { background: transparent; box-shadow: inset 0 0 0 2px var(--surface-3); }
.sw-day.missed .sw-dot::after { content: ""; width: 10px; height: 2px; border-radius: 2px; background: var(--surface-3); }
.sw-day.today .sw-dot { background: transparent; box-shadow: inset 0 0 0 2px var(--coral); animation: pulse 1.8s ease-in-out infinite; }
.sw-day.today .sw-label, .sw-day.active .sw-label { color: var(--text); }
.sw-day.future .sw-dot { opacity: .5; }
.streak-hint { margin-top: 14px; font-size: 13px; color: var(--text-2); text-align: center; }

.challenge { gap: 12px; min-height: 72px; }
.challenge-emoji { width: 40px; height: 40px; flex-shrink: 0; display: grid; place-items: center; border-radius: 12px; background: var(--surface-2); font-size: 20px; }
.challenge-bar { display: block; height: 7px; margin-top: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.challenge-bar > i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--grad-sun); transition: width 1s var(--ease-out); }
.challenge.done .challenge-bar > i { background: var(--grad-brand); }
.challenge.done .list-title { color: var(--text-2); }
.challenge-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.challenge-side b { font-size: 14px; }
.xp-chip {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 99px;
  background: rgba(255, 176, 32, .16);
  color: #B26B00;
  font-size: 11.5px;
  font-weight: 800;
  white-space: nowrap;
}
[data-theme="dark"] .xp-chip { color: #FFC857; }
.challenge.done .xp-chip { background: var(--brand-50); color: var(--brand-700); }
[data-theme="dark"] .challenge.done .xp-chip { color: #6EE7B7; }

.league { padding: 16px; }
.league-list { display: flex; flex-direction: column; gap: 6px; }
.league-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; background: var(--surface-2); }
.league-row.podium { background: rgba(255, 176, 32, .1); }
.league-row.me { background: var(--brand-50); box-shadow: inset 0 0 0 2px rgba(18, 183, 106, .45); }
.league-pos { width: 28px; text-align: center; font-weight: 800; font-size: 15px; color: var(--text-2); }
.league-row.podium .league-pos { font-size: 20px; }
.league-name { flex: 1; min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.league-name small { display: block; font-size: 11.5px; font-weight: 600; color: var(--text-3); }
.league-xp { font-weight: 800; font-size: 14px; }
.league-gap { text-align: center; color: var(--text-3); line-height: 1; margin: 2px 0 6px; }
.league-empty { padding: 18px 8px; text-align: center; color: var(--text-2); }
.league-last { margin-top: 12px; font-size: 13px; color: var(--text-2); text-align: center; }
.league-hidden p { color: var(--text-2); margin-bottom: 14px; }

.badge-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.badge {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 4px 10px;
  border: 0;
  border-radius: 18px;
  background: var(--surface-grad);
  box-shadow: var(--shadow-sm), 0 0 0 1px var(--border);
  cursor: pointer;
  transition: transform .2s var(--ease-spring);
}
.badge:active { transform: scale(.94); }
.badge-emoji { font-size: 30px; line-height: 1.1; }
.badge-name { font-size: 11px; font-weight: 700; line-height: 1.2; text-align: center; color: var(--text-2); }
.badge.locked .badge-emoji { filter: grayscale(1); opacity: .28; }
.badge.locked .badge-name { color: var(--text-3); }
.badge.earned { background: linear-gradient(160deg, var(--surface) 40%, rgba(255, 176, 32, .12)); }
.badge.new::after {
  content: "";
  position: absolute;
  top: 8px;
  right: 8px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--coral);
  box-shadow: 0 0 0 3px var(--surface);
}
.badge.new .badge-emoji { animation: pop .6s var(--ease-spring) both; }
.badge-detail { text-align: center; padding: 6px 0 10px; }
.badge-detail .badge-emoji { display: block; font-size: 72px; margin-bottom: 8px; animation: pop .6s var(--ease-spring) both; }
.badge-detail.locked .badge-emoji { filter: grayscale(1); opacity: .35; }
.badge-detail h3 { font-size: 22px; margin-bottom: 6px; }
.badge-when { margin-top: 14px; font-size: 13px; font-weight: 700; color: var(--text-3); }

.how-xp { margin-top: 22px; }
.rules .list-item { min-height: 58px; }
.rules .list-icon.emoji { background: var(--surface-2); font-size: 19px; }

.guide { padding-bottom: 6px; }
.guide-title {
  margin: 22px 6px 10px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-3);
}
.guide-note { margin: 8px 6px 0; font-size: 13px; color: var(--text-3); }

.guide-level {
  padding: 16px 18px;
  border-radius: 22px;
  background: linear-gradient(155deg, rgba(18, 183, 106, .08), rgba(18, 183, 106, .2));
}
.guide-level-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.guide-level-top strong { font-family: var(--font-display); font-size: 17px; font-weight: 800; }
.guide-level .progress { height: 10px; background: rgba(18, 183, 106, .18); }
.guide-level p { margin-top: 10px; font-size: 13px; color: var(--text-2); }
.guide-level p b { color: var(--text); }

.guide-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.guide-tiles.two { grid-template-columns: 1fr 1fr; }
.guide-tiles.podium { margin-top: 8px; }
.guide-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 6px 12px;
  border-radius: 18px;
  background: var(--surface-grad);
  box-shadow: var(--shadow-sm), 0 0 0 1px var(--border);
}
.guide-tile strong { font-family: var(--font-display); font-size: 22px; font-weight: 800; line-height: 1; }
.guide-medal { font-size: 26px; line-height: 1; }

.guide-titles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.guide-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 4px 10px;
  border-radius: 18px;
  background: var(--surface-grad);
  box-shadow: var(--shadow-sm), 0 0 0 1px var(--border);
  text-align: center;
}
.guide-stage .mascot { margin-bottom: 6px; }
.guide-stage strong { font-size: 13.5px; font-weight: 800; }
.guide-stage span { font-size: 11.5px; font-weight: 600; color: var(--text-3); }
.guide-stage:not(.reached) .mascot { filter: grayscale(1); opacity: .4; }
.guide-stage:not(.reached) strong { color: var(--text-3); }
.guide-stage.current { background: var(--brand-50); box-shadow: inset 0 0 0 2px rgba(18, 183, 106, .5); }
.guide-stage.current span { color: var(--brand-700); }
[data-theme="dark"] .guide-stage.current span { color: #6EE7B7; }

.guide-card {
  padding: 14px;
  border-radius: 18px;
  background: var(--surface-grad);
  box-shadow: var(--shadow-sm), 0 0 0 1px var(--border);
}
.guide-card-emoji { display: block; font-size: 22px; line-height: 1; margin-bottom: 8px; }
.guide-card strong { display: block; font-size: 14.5px; font-weight: 800; margin-bottom: 4px; }
.guide-card p { font-size: 12.5px; line-height: 1.4; color: var(--text-2); }

/* Celebrations */
.xp-pop {
  position: absolute;
  left: 50%;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 40px);
  z-index: 350;
  padding: 8px 16px;
  border-radius: 99px;
  background: var(--grad-sun);
  color: #fff;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 800;
  box-shadow: 0 12px 30px -10px rgba(247, 144, 9, .8);
  pointer-events: none;
  animation: xpPop 1.6s var(--ease-out) forwards;
}
.xp-pop.minus { background: var(--surface-3); color: var(--text-2); box-shadow: none; }
.levelup { text-align: center; padding-bottom: 6px; }
.levelup-mascot { display: grid; place-items: center; margin: 0 auto 6px; padding-top: 16px; animation: pop .7s var(--ease-spring) both; }
.levelup-badge {
  display: inline-block;
  margin-bottom: 10px;
  padding: 6px 14px;
  border-radius: 99px;
  background: var(--grad-brand);
  color: #fff;
  font-weight: 800;
}
.levelup h3 { font-size: 21px; margin-bottom: 6px; }

/* Settings → data */
.data-usage { font-size: 13px; color: var(--text-2); padding: 0 8px 10px; }

/* ---------- Habits ---------- */

@property --p { syntax: "<number>"; inherits: true; initial-value: 0; }

.topbar .icon-btn + .icon-btn { margin-left: -2px; }

.week-strip { display: flex; align-items: center; gap: 2px; margin: 0 -12px 16px; touch-action: pan-y; }
.week-nav {
  flex-shrink: 0;
  width: 26px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--text-3);
  cursor: pointer;
}
.week-nav:active { background: var(--surface-2); }
.week-nav .icon { width: 18px; height: 18px; }
.week-days { flex: 1; display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.wd {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 0 10px;
  border: 0;
  border-radius: 16px;
  background: none;
  cursor: pointer;
  transition: background-color .25s, box-shadow .25s, transform .2s var(--ease-spring);
}
.wd:active { transform: scale(.92); }
.wd-name { font-size: 11.5px; font-weight: 700; color: var(--text-3); }
.wd.today .wd-name { color: var(--brand); }
.wd-ring {
  position: relative;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--brand) calc(var(--p) * 360deg), var(--surface-3) 0);
  transition: --p .6s var(--ease-out);
}
.wd-ring::before { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--bg); transition: opacity .3s; }
.wd-num { position: relative; font-size: 14px; font-weight: 800; font-variant-numeric: tabular-nums; }
.wd.selected { background: var(--surface); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border); }
.wd.selected .wd-ring::before { background: var(--surface); }
.wd.future .wd-num { color: var(--text-3); }
.wd.complete .wd-ring { background: var(--grad-brand); }
.wd.complete .wd-ring::before { opacity: 0; }
.wd.complete .wd-num { color: #fff; }

.is-refreshing { opacity: .55; transition: opacity .2s; }

/* Mascot card on the home screen; colors follow the mascot's tone. */
/*
 * Solid background, a darker shade of the mascot's color so it never blends in.
 * Each shade keeps white text at a contrast ratio of 4.5:1 or more.
 */
.buddy {
  --buddy-bg: #0B8063;
  --buddy-ink: #fff;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 12px 0 16px;
  padding: 16px 18px 16px 8px;
  border-radius: 30px;
  background: linear-gradient(135deg, rgba(255, 255, 255, .1) 0%, transparent 45%, rgba(0, 0, 0, .22) 100%) var(--buddy-bg);
  color: var(--buddy-ink);
  animation: fadeUp .45s var(--ease-out) both;
  transition: background-color .5s;
}
.buddy.tone-good { --buddy-bg: #2F7F68; }
.buddy.tone-okay { --buddy-bg: #5E7330; }
.buddy.tone-stuffed { --buddy-bg: #B85C1E; }
.buddy.tone-wilted { --buddy-bg: #6D6853; }
.buddy.tone-resting { --buddy-bg: #3F7A73; }

.buddy-mascot {
  position: relative;
  flex-shrink: 0;
  appearance: none;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.buddy-mascot:focus-visible { outline: 3px solid rgba(255, 255, 255, .8); outline-offset: 2px; }
.buddy .buddy-mascot.poke .mascot .m-bounce { animation: mascotPoke .6s var(--ease-spring); }
.buddy.changed .buddy-mascot .mascot { animation: buddyChange .7s var(--ease-spring) both; }

.buddy-text { position: relative; flex: 1; min-width: 0; }
.buddy-head { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; margin-bottom: 8px; }
.buddy-name { font-size: 22px; font-weight: 800; color: var(--buddy-ink); }
.buddy-state {
  padding: 3px 10px;
  border-radius: 99px;
  background: rgba(255, 255, 255, .18);
  color: var(--buddy-ink);
  font-size: 12px;
  font-weight: 800;
}
.buddy-says { font-size: 13px; font-weight: 400; line-height: 1.45; color: var(--buddy-ink); }
.buddy-skeleton { height: 168px; margin: 12px 0 16px; border-radius: 30px; }

.day-hint { margin: -4px 4px 12px; text-align: center; }
.center-row { display: flex; justify-content: center; margin: -2px 0 14px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 99px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 650;
  cursor: pointer;
  transition: transform .15s, background-color .2s;
}
.pill:active { transform: scale(.95); }
.pill .icon { width: 16px; height: 16px; }

.habit-list { display: flex; flex-direction: column; gap: 10px; }
.habit {
  --c: var(--brand);
  display: flex;
  align-items: stretch;
  border-radius: 20px;
  background: var(--surface-grad);
  box-shadow: var(--shadow-sm), 0 0 0 1px var(--border);
  transition: background-color .35s var(--ease-out), box-shadow .35s;
}
.habit-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 4px 14px 14px;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}
.habit-main:disabled { cursor: default; color: inherit; }
.habit-main, .habit-more { outline-offset: -3px; }
.habit-main { border-radius: 20px 0 0 20px; }
.habit-icon {
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  font-size: 24px;
  background: var(--surface-2);
  background: color-mix(in srgb, var(--c) 14%, transparent);
  transition: background-color .35s, transform .25s var(--ease-spring);
}
.habit-main:active .habit-icon { transform: scale(.9); }
.habit-text { flex: 1; min-width: 0; }
.habit-name { display: block; font-size: 16px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: color .3s; }
.habit-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 2px; font-size: 13px; color: var(--text-2); transition: color .3s; }
.habit-meta .cat { display: inline-flex; align-items: center; gap: 6px; }
.habit-meta .cat::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.habit-meta .streak { font-weight: 700; }
.habit-check {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 2.5px solid var(--surface-3);
  color: var(--c);
  transition: background-color .3s, border-color .3s, transform .35s var(--ease-spring);
}
.habit-check .icon { width: 18px; height: 18px; stroke-width: 3; transform: scale(0); transition: transform .35s var(--ease-spring); }
.habit-more {
  flex-shrink: 0;
  width: 42px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 0 20px 20px 0;
  background: none;
  color: var(--text-3);
  cursor: pointer;
}
.habit-more .icon { width: 20px; height: 20px; }
.habit.done { background: linear-gradient(135deg, transparent 0%, rgba(0, 0, 0, .2) 100%) var(--c); box-shadow: 0 14px 26px -16px var(--c), 0 0 0 1px transparent; }
.habit.done .habit-name, .habit.done .habit-meta, .habit.done .habit-more { color: #fff; }
.habit.done .habit-icon { background: rgba(255, 255, 255, .22); }
.habit.done .habit-meta .cat::before { background: #fff; }
.habit.done .habit-check { background: #fff; border-color: #fff; }
.habit.done .habit-check .icon { transform: scale(1); }
.habit.just-done { animation: habitPop .5s var(--ease-spring); }
.habit.just-done .habit-check { animation: checkBurst .5s var(--ease-spring); }
.habit.locked .habit-check { opacity: .35; }

.first-habit p { max-width: 300px; margin: 0 auto; }
.first-habit .templates { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 18px 0 20px; }
.empty.compact { padding: 22px 18px; }
.empty.compact h3 { font-size: 18px; }

/* Pickers (forms in sheets) */
.label-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.label-row .label { margin-bottom: 0; }
button.link { padding: 0 4px; border: 0; background: none; cursor: pointer; font-size: 13px; }

.emoji-opt, .color-opt, .cat-opt, .wd-opt { position: relative; }
.emoji-opt input, .color-opt input, .cat-opt input, .wd-opt input { position: absolute; opacity: 0; pointer-events: none; }
.emoji-opt input:focus-visible + span, .color-opt input:focus-visible + span,
.cat-opt input:focus-visible + span, .wd-opt input:focus-visible + span { outline: 3px solid var(--brand-50); outline-offset: 2px; }

.emoji-picker {
  display: grid;
  grid-template-rows: repeat(2, 48px);
  grid-auto-flow: column;
  grid-auto-columns: 48px;
  gap: 8px;
  margin: 0 -20px;
  padding: 2px 20px 6px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.emoji-picker::-webkit-scrollbar { display: none; }
.emoji-opt { scroll-snap-align: start; scroll-margin-left: 20px; }
.emoji-opt span {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--surface-2);
  font-size: 22px;
  cursor: pointer;
  transition: transform .2s var(--ease-spring), box-shadow .2s, background-color .2s;
}
.emoji-opt input:checked + span { background: var(--brand-50); box-shadow: inset 0 0 0 2px var(--brand); transform: scale(1.06); }

.color-picker { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.color-opt span {
  display: grid;
  place-items: center;
  width: 100%;
  max-width: 46px;
  margin: 0 auto;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--swatch);
  color: #fff;
  cursor: pointer;
  transition: transform .2s var(--ease-spring), box-shadow .2s;
}
.color-opt span .icon { width: 20px; height: 20px; stroke-width: 3; transform: scale(0); transition: transform .25s var(--ease-spring); }
.color-opt input:checked + span { transform: scale(1.06); box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--swatch); }
.color-opt input:checked + span .icon { transform: scale(1); }

.cat-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.cat-opt span, .cat-opt.add {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 14px;
  border: 0;
  border-radius: 99px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
  transition: background-color .2s, color .2s, box-shadow .2s, transform .2s var(--ease-spring);
}
.cat-opt.add { background: transparent; box-shadow: inset 0 0 0 1.5px var(--surface-3); color: var(--text-2); }
.cat-opt.add span { display: inline; height: auto; padding: 0; background: none; color: inherit; }
.cat-opt.add .icon { width: 16px; height: 16px; }
.cat-opt.add:active { transform: scale(.95); }
.cat-opt input:checked + span { background: var(--c, var(--text)); color: #fff; box-shadow: 0 8px 18px -10px var(--c, #000); }
.cat-opt:not([style]) input:checked + span { color: var(--bg); }

.weekday-picker { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.wd-opt span {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-2);
  font-weight: 800;
  cursor: pointer;
  transition: background-color .2s, color .2s, transform .25s var(--ease-spring), box-shadow .2s;
}
.wd-opt input:checked + span { background: var(--grad-brand); color: #fff; transform: scale(1.04); box-shadow: 0 8px 16px -10px rgba(18, 183, 106, .9); }
.wd-presets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.wd-presets .pill { height: 30px; padding: 0 12px; font-size: 12.5px; }

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px 12px 16px;
  margin-bottom: 16px;
  border-radius: 16px;
  background: var(--surface-2);
  font-size: 15px;
  font-weight: 650;
  cursor: pointer;
}

.cat-preview {
  --c: var(--brand);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: 18px;
  border-radius: 18px;
  background: var(--c);
  color: #fff;
  font-size: 17px;
  font-weight: 800;
  box-shadow: 0 14px 28px -16px var(--c);
  transition: background-color .3s, box-shadow .3s;
}
.cat-preview-icon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; background: rgba(255, 255, 255, .22); font-size: 22px; }
.list-icon.emoji { font-size: 19px; }
.all-habits .section-title:first-child { margin-top: 0; }
.sheet-footer .btn.btn-square { flex: 0 0 56px; padding: 0; }

/* ---------- Fasting ---------- */

.fast-hero { display: flex; flex-direction: column; align-items: center; padding-top: 4px; }

.fast-ring {
  position: relative;
  width: min(272px, 72vw, 36vh);
  min-width: 210px;
  aspect-ratio: 1;
  margin-bottom: 14px;
  container-type: inline-size;
  transition: --p 1s linear;
}
.fast-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.fast-ring circle { fill: none; stroke-width: 9; }
.fast-ring-track { stroke: var(--surface-2); }
.fast-ring-bar {
  stroke: url(#fast-grad);
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: calc(100 - min(var(--p), 1) * 100);
  filter: drop-shadow(0 4px 10px rgba(255, 107, 74, .35));
}
.fast-ring:not(.running) .fast-ring-bar { opacity: 0; }
.fast-ring-inner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 20px;
}
.fast-label { font-size: 14px; font-weight: 700; color: var(--text-3); }
.fast-clock {
  margin: 6px 0 8px;
  font-family: var(--font-display);
  font-size: 13cqi;
  font-weight: 800;
  letter-spacing: -.03em;
  line-height: 1;
  color: var(--text);
}
.fast-clock.long { font-size: 11cqi; }
.fast-ring:not(.running) .fast-clock { color: var(--text-3); }
.fast-goal { min-height: 18px; font-size: 13px; font-weight: 700; color: var(--text-2); }
.fast-left { min-height: 18px; font-size: 13px; font-weight: 600; color: var(--text-3); font-variant-numeric: tabular-nums; }

.fast-record {
  min-height: 24px;
  font-size: 17px;
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.fast-record.muted { font-size: 15px; font-weight: 600; color: var(--text-3); }
.fast-record.beating {
  background: var(--grad-fire);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: recordPulse 1.6s ease-in-out infinite;
}
.fast-phase {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 11px;
  border-radius: 99px;
  background: rgba(255, 107, 74, .12);
  color: var(--coral);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.fast-btn { height: 64px; margin-top: 18px; font-size: 18px; border-radius: 22px; }
.fast-btn .icon { width: 20px; height: 20px; }
.fast-btn.stop {
  background: var(--grad-fire);
  color: #fff;
  box-shadow: 0 16px 30px -14px rgba(244, 63, 94, .85);
}
.fast-btn.stop:active { transform: scale(.97); }
.fast-btn-skeleton { width: 100%; height: 64px; margin-top: 18px; border-radius: 22px; }
.fast-started {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 8px 12px;
  border: 0;
  border-radius: 99px;
  background: none;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.fast-started .icon { width: 14px; height: 14px; }
.fast-started:active { background: var(--surface-2); }

.fast-history { margin-top: 28px; }
.fast-history-head { display: flex; align-items: center; justify-content: space-between; margin: 0 4px 12px; }
.fast-history-head h2 { font-size: 20px; font-weight: 800; }
.fast-history-head .link { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; font-weight: 700; color: var(--brand); }
.fast-history-head .link .icon { width: 16px; height: 16px; }

.fast-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.fast-stats > div {
  padding: 12px 10px;
  border-radius: 16px;
  background: var(--surface-grad);
  box-shadow: var(--shadow-sm), 0 0 0 1px var(--border);
  text-align: center;
}
.fast-stats strong { display: block; font-family: var(--font-display); font-size: 16px; font-weight: 800; white-space: nowrap; }
.fast-stats span { font-size: 12px; font-weight: 600; color: var(--text-3); }

.fast-list { overflow: hidden; border-radius: 22px; background: var(--surface-grad); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border); }
.fast-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 4px 12px;
  width: 100%;
  padding: 14px 16px 12px;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}
.fast-item + .fast-item { border-top: 1px solid var(--border); }
.fast-item:active { background: var(--surface-2); }
.fast-item.is-new { animation: fastIn .6s var(--ease-spring) both; }
.fast-item-text { display: flex; flex-direction: column; min-width: 0; }
.fast-item-date { font-weight: 700; }
.fast-item-range { font-size: 13px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.fast-item-dur { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-display); font-size: 17px; font-weight: 800; }
.fast-trophy { font-size: 15px; }
.fast-item-bar { grid-column: 1 / -1; height: 5px; margin-top: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.fast-item-bar > i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #FFC56B, #FF9A62); }
.fast-item.is-record .fast-item-bar > i { background: var(--grad-fire); }
.fast-more { margin-top: 12px; }

.fast-preview, .meal-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--surface-2);
  font-weight: 600;
  color: var(--text-2);
}
.fast-preview strong, .meal-total strong { font-family: var(--font-display); font-size: 18px; color: var(--text); }
.fast-preview strong.invalid { font-size: 14px; color: var(--danger); }

@keyframes recordPulse { 50% { opacity: .7; } }
@keyframes fastIn { from { opacity: 0; transform: translateY(-10px) scale(.97); } to { opacity: 1; transform: none; } }

/* ---------- Meals ---------- */

.day-switch { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.day-switch .icon-btn { width: 44px; height: 44px; }
.day-switch .icon-btn:disabled { opacity: .35; pointer-events: none; }
.day-switch-label {
  flex: 1;
  min-width: 0;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 12px;
  border: 0;
  border-radius: 15px;
  background: var(--surface-grad);
  box-shadow: var(--shadow-sm), 0 0 0 1px var(--border);
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .18s var(--ease-out);
}
.day-switch-label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.day-switch-label .icon { width: 17px; height: 17px; color: var(--brand); flex-shrink: 0; }
.day-switch-label:active { transform: scale(.97); }

.kcal-card {
  padding: 18px 20px 18px;
  border-radius: var(--radius-lg);
  background: var(--surface-grad);
  box-shadow: var(--shadow-sm), 0 0 0 1px var(--border);
  animation: fadeUp .45s var(--ease-out) both;
  transition: box-shadow .3s;
}
.kcal-top { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.kcal-text { flex: 1; min-width: 0; }
.kcal-label { font-size: 13px; font-weight: 700; color: var(--text-3); }
.kcal-value { margin-top: 2px; white-space: nowrap; }
.kcal-value strong { font-family: var(--font-display); font-size: 34px; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; }
.kcal-value span { font-size: 15px; font-weight: 700; color: var(--text-2); }
.kcal-mascot { flex-shrink: 0; margin: -6px -4px -6px 0; }
.kcal-progress { height: 12px; }
.kcal-status { display: flex; align-items: flex-start; gap: 7px; margin-top: 11px; font-size: 14px; color: var(--text-2); line-height: 1.35; }
.kcal-status .icon { width: 18px; height: 18px; flex-shrink: 0; color: var(--brand); }
.kcal-status strong { color: var(--text); }
.kcal-card.over {
  background: linear-gradient(180deg, rgba(240, 68, 56, .08), transparent 70%), var(--surface-grad);
  box-shadow: var(--shadow-sm), 0 0 0 1.5px rgba(240, 68, 56, .35);
}
.kcal-card.over .kcal-value strong { color: var(--danger); }
.kcal-card.over .kcal-progress > i { background: linear-gradient(90deg, #FF8A65, #F04438); }
.kcal-card.over .kcal-status, .kcal-card.over .kcal-status strong, .kcal-card.over .kcal-status .icon { color: var(--danger); }

.macro-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.macro {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 10px;
  border-radius: 99px;
  background: var(--surface-2);
  font-size: 13px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}
.macro i { width: 8px; height: 8px; border-radius: 50%; }
.macro small { font-size: 12px; font-weight: 600; color: var(--text-3); }
.macro.p i { background: var(--violet); }
.macro.c i { background: var(--sun); }
.macro.f i { background: var(--sky); }
.macro-row.small { margin-top: 10px; gap: 4px 14px; }
.kcal-card .macro-row.small { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.macro-row.small .macro { height: auto; padding: 0; background: none; font-size: 12.5px; }

.capture-card {
  position: relative;
  overflow: hidden;
  margin-top: 14px;
  padding: 20px;
  border-radius: 26px;
  background: var(--grad-brand);
  color: #fff;
  box-shadow: 0 20px 40px -22px rgba(18, 183, 106, .95);
  animation: fadeUp .45s .05s var(--ease-out) both;
}
.capture-glow {
  position: absolute;
  width: 220px;
  height: 220px;
  right: -70px;
  top: -110px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .14);
  pointer-events: none;
}
.capture-head { position: relative; display: flex; align-items: center; gap: 14px; }
.capture-icon { flex-shrink: 0; width: 48px; height: 48px; display: grid; place-items: center; border-radius: 16px; background: rgba(255, 255, 255, .2); }
.capture-icon .icon { width: 24px; height: 24px; }
.capture-head h2 { font-size: 19px; font-weight: 800; }
.capture-head p { margin-top: 2px; font-size: 13.5px; line-height: 1.35; opacity: .92; }
.capture-actions { position: relative; display: grid; grid-template-columns: 1.25fr 1fr; gap: 10px; margin-top: 16px; }
.capture-btn {
  position: relative;
  overflow: hidden;
  height: 52px;
  padding: 0 12px;
  border-radius: 18px;
  background: rgba(255, 255, 255, .2);
  color: #fff;
  font-size: 15px;
}
.capture-btn .icon { width: 20px; height: 20px; }
.capture-btn.main { background: #fff; color: var(--brand-700); box-shadow: 0 10px 20px -12px rgba(0, 0, 0, .4); }
.capture-btn input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; font-size: 0; }
.capture-btn.disabled { opacity: .5; pointer-events: none; }
.capture-foot { position: relative; display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 12px; font-size: 13px; font-weight: 600; }
.capture-quota { display: inline-flex; align-items: center; gap: 6px; opacity: .95; }
.capture-quota .icon { width: 15px; height: 15px; flex-shrink: 0; }
.capture-link { flex-shrink: 0; padding: 6px 0; border: 0; background: none; color: #fff; font-size: 13px; font-weight: 800; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.capture-card.off { background: var(--surface-grad); color: var(--text-2); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border); text-align: center; }
.capture-card.off p { margin-bottom: 14px; }
.capture-manual { background: var(--brand-50); color: var(--brand-700); }
[data-theme="dark"] .capture-manual { color: #6EE7B7; }

.meal-section { margin-top: 26px; }
.meal-list-head { display: flex; align-items: center; justify-content: space-between; margin: 0 4px 12px; }
.meal-list-head h2 { font-size: 20px; font-weight: 800; }
.meal-list-head .link { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; }
.meal-list-head .link .icon { width: 16px; height: 16px; }
.meal-list { display: flex; flex-direction: column; gap: 14px; }
.meal-empty p { max-width: 280px; margin: 0 auto; }

.meal-card {
  scroll-margin-top: calc(var(--safe-top) + 100px);
  overflow: hidden;
  border-radius: 24px;
  background: var(--surface-grad);
  box-shadow: var(--shadow-sm), 0 0 0 1px var(--border);
}
.meal-card.is-new { animation: mealIn .7s var(--ease-spring) both; }
.meal-photo {
  position: relative;
  display: block;
  width: 100%;
  height: 210px;
  padding: 0;
  border: 0;
  background: var(--surface-2);
  cursor: zoom-in;
}
.meal-photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.meal-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 26px;
  padding: 0 10px;
  border-radius: 99px;
  background: rgba(10, 15, 12, .5);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}
.meal-badge .icon { width: 13px; height: 13px; }
.meal-photo.removed {
  height: 84px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-3);
  font-size: 13px;
  font-weight: 600;
  cursor: default;
  background: repeating-linear-gradient(135deg, var(--surface-2) 0 12px, transparent 12px 24px), var(--bg);
}
.meal-photo.removed .icon { width: 20px; height: 20px; }
.meal-body { padding: 14px 16px 16px; }
.meal-head { display: flex; align-items: center; gap: 12px; width: 100%; padding: 0; border: 0; background: none; color: inherit; text-align: left; cursor: pointer; }
.meal-icon { flex-shrink: 0; width: 42px; height: 42px; display: grid; place-items: center; border-radius: 14px; background: var(--brand-50); color: var(--brand); }
.meal-icon .icon { width: 21px; height: 21px; }
.meal-title { flex: 1; min-width: 0; }
.meal-title strong { display: block; font-size: 17px; font-weight: 800; line-height: 1.25; }
.meal-title small { display: block; margin-top: 2px; font-size: 12.5px; font-weight: 600; color: var(--text-3); }
.meal-kcal { flex-shrink: 0; font-family: var(--font-display); font-size: 22px; font-weight: 800; white-space: nowrap; }
.meal-kcal small { font-size: 13px; font-weight: 700; color: var(--text-3); }
.meal-edit { flex-shrink: 0; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 10px; background: var(--surface-2); color: var(--text-2); transition: transform .18s var(--ease-out); }
.meal-edit .icon { width: 15px; height: 15px; }
.meal-head:active .meal-edit { transform: scale(.88); }
.meal-items { margin: 12px 0 0; padding: 0; list-style: none; border-top: 1px solid var(--border); }
.meal-items li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 0; }
.meal-items li + li { border-top: 1px solid var(--border); }
.mi-name { min-width: 0; font-size: 14.5px; font-weight: 650; }
.mi-name small { display: block; font-size: 12.5px; font-weight: 500; color: var(--text-3); }
.mi-kcal { flex-shrink: 0; font-size: 14px; font-weight: 700; color: var(--text-2); }
.meal-note { display: flex; gap: 8px; margin-top: 12px; padding: 10px 12px; border-radius: 14px; background: var(--surface-2); font-size: 13px; line-height: 1.4; color: var(--text-2); }
.meal-note .icon { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; color: var(--sky); }

/* Meal editor */
.meal-edit-thumb { display: block; width: 100%; height: 96px; margin-bottom: 16px; border-radius: 18px; object-fit: cover; background: var(--surface-2); }
.meal-when { display: grid; grid-template-columns: 1.25fr 1fr; gap: 10px; }
.meal-when .field { min-width: 0; }
.item-list { display: flex; flex-direction: column; gap: 10px; }
.item-row {
  display: grid;
  grid-template-columns: 1fr 96px 34px;
  gap: 6px;
  padding: 8px 4px 8px 8px;
  border-radius: 18px;
  box-shadow: inset 0 0 0 1px var(--border);
}
.item-row.is-new { animation: fadeUp .35s var(--ease-out) both; }
.item-row .input { height: 46px; padding: 0 12px; border-radius: 12px; }
.item-row .item-serving { grid-column: 1 / 3; height: 40px; color: var(--text-2); }
.item-kcal { position: relative; }
.item-kcal .input { padding-right: 38px; text-align: right; -moz-appearance: textfield; }
.item-kcal .input::-webkit-inner-spin-button, .item-kcal .input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.item-kcal span { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-size: 12px; font-weight: 700; color: var(--text-3); pointer-events: none; }
.item-remove { grid-row: 1 / 3; grid-column: 3; display: grid; place-items: center; padding: 0; border: 0; border-radius: 12px; background: none; color: var(--text-3); cursor: pointer; }
.item-remove .icon { width: 18px; height: 18px; }
.item-remove:active { background: var(--surface-2); }
.item-remove:disabled { opacity: .3; cursor: default; }
.item-list + .field-error { margin-top: 8px; }
.meal-total { margin-top: 14px; }
.label-row .link { display: inline-flex; align-items: center; gap: 4px; }
.label-row .link .icon { width: 15px; height: 15px; }

/* Month calendar */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.cal-head strong { font-size: 17px; font-weight: 800; }
.cal-head .icon-btn { width: 40px; height: 40px; border-radius: 13px; background: var(--surface-2); box-shadow: none; }
.cal-head .icon-btn:disabled { opacity: .3; pointer-events: none; }
.cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); margin-bottom: 6px; text-align: center; font-size: 12px; font-weight: 800; color: var(--text-3); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; transition: opacity .2s; }
.cal-day {
  height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: none;
  color: var(--text);
  cursor: pointer;
  transition: transform .18s var(--ease-out), background-color .2s;
}
.cal-day:active { transform: scale(.9); }
.cal-num { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.cal-kcal { min-height: 12px; font-size: 9.5px; font-weight: 750; line-height: 12px; color: var(--text-3); }
.cal-day.ok { background: rgba(18, 183, 106, .14); }
.cal-day.ok .cal-kcal { color: var(--brand-700); }
[data-theme="dark"] .cal-day.ok .cal-kcal { color: #6EE7B7; }
.cal-day.over { background: rgba(240, 68, 56, .13); }
.cal-day.over .cal-kcal { color: var(--danger); }
.cal-day.today .cal-num { color: var(--brand); font-weight: 900; }
.cal-day.selected { box-shadow: inset 0 0 0 2px var(--text); }
.cal-day.future { opacity: .35; cursor: default; }

/* Date picker (same month calendar, used by every date field) */
.cal-title { display: inline-flex; align-items: center; gap: 4px; padding: 8px 10px; border: 0; border-radius: 12px; background: none; color: var(--text); font: inherit; cursor: pointer; transition: background-color .2s; }
.cal-title:active { background: var(--surface-2); }
.cal-title .icon { width: 18px; height: 18px; color: var(--text-3); transition: transform .25s var(--ease-out); }
.date-picker:not([data-view="days"]) .cal-title .icon { transform: rotate(180deg); }
.date-picker[data-view="years"] [data-step] { visibility: hidden; }
.date-picker .cal-day { height: 46px; }
.date-picker .cal-day:disabled { opacity: .3; cursor: default; transform: none; }
.cal-picks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.cal-picks.years { grid-template-columns: repeat(4, 1fr); max-height: 316px; overflow-y: auto; overscroll-behavior: contain; padding: 2px; }
.cal-pick {
  height: 52px;
  border: 0;
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-transform: capitalize;
  cursor: pointer;
  transition: transform .18s var(--ease-out);
}
.cal-pick:active { transform: scale(.94); }
.cal-pick.current { color: var(--brand); font-weight: 900; }
.cal-pick.selected { box-shadow: inset 0 0 0 2px var(--text); }
.cal-pick:disabled { opacity: .3; cursor: default; transform: none; }
.cal-legend { display: flex; justify-content: center; gap: 16px; margin: 14px 0; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.cal-legend i { display: inline-block; width: 10px; height: 10px; margin-right: 6px; border-radius: 3px; vertical-align: -1px; }
.cal-legend i.ok { background: var(--brand); }
.cal-legend i.over { background: var(--danger); }
.cal-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 6px; }
.cal-stats > div { padding: 12px 8px; border-radius: 16px; background: var(--surface-2); text-align: center; }
.cal-stats strong { display: block; font-family: var(--font-display); font-size: 18px; font-weight: 800; }
.cal-stats strong.ok { color: var(--brand); }
.cal-stats span { font-size: 12px; font-weight: 600; color: var(--text-3); }
.cal-summary { padding: 10px 0 6px; text-align: center; font-size: 14px; color: var(--text-3); }

/* Photo viewer */
.lightbox {
  position: absolute;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: calc(var(--safe-top) + 60px) 12px calc(var(--safe-bottom) + 40px);
  background: rgba(0, 0, 0, .92);
  opacity: 0;
  transition: opacity .3s var(--ease-out);
  cursor: zoom-out;
}
.lightbox.open { opacity: 1; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 18px; object-fit: contain; transform: scale(.94); transition: transform .4s var(--ease-spring); }
.lightbox.open img { transform: none; }
.lightbox-close { position: absolute; top: calc(var(--safe-top) + 14px); right: 16px; background: rgba(255, 255, 255, .15); color: #fff; box-shadow: none; }

/* AI analysis overlay */
.analyze-overlay {
  position: absolute;
  inset: 0;
  z-index: 150;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(5, 10, 8, .55);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity .3s var(--ease-out);
}
.analyze-overlay.open { opacity: 1; }
.analyze-card {
  width: 100%;
  max-width: 330px;
  padding: 16px 16px 22px;
  border-radius: 30px;
  background: var(--surface-grad);
  box-shadow: var(--shadow-lg);
  text-align: center;
  transform: translateY(24px) scale(.96);
  transition: transform .5s var(--ease-spring);
}
.analyze-overlay.open .analyze-card { transform: none; }
.analyze-photo { position: relative; height: 250px; overflow: hidden; border-radius: 22px; background: var(--surface-2); }
.analyze-photo img { width: 100%; height: 100%; object-fit: cover; }
.analyze-photo::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(rgba(255, 255, 255, .14) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .14) 1px, transparent 1px);
  background-size: 26px 26px;
  transition: opacity .3s;
}
.analyze-scan {
  position: absolute;
  left: 0;
  right: 0;
  top: -70px;
  z-index: 1;
  height: 70px;
  border-bottom: 2px solid #3BE38B;
  background: linear-gradient(to bottom, transparent, rgba(59, 227, 139, .45));
  box-shadow: 0 8px 18px -6px rgba(59, 227, 139, .9);
  animation: scan 1.8s ease-in-out infinite alternate;
}
.analyze-done {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 2;
  width: 76px;
  height: 76px;
  margin: -38px 0 0 -38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--grad-brand);
  color: #fff;
  box-shadow: 0 14px 30px -10px rgba(18, 183, 106, .9);
  transform: scale(0);
  transition: transform .5s var(--ease-spring);
}
.analyze-done .icon { width: 38px; height: 38px; stroke-width: 3; }
.analyze-overlay.done .analyze-done { transform: scale(1); }
.analyze-overlay.done .analyze-scan, .analyze-overlay.done .analyze-photo::after { opacity: 0; animation: none; }
.analyze-title { margin-top: 16px; font-size: 19px; font-weight: 800; }
.analyze-step { min-height: 20px; margin-top: 4px; font-size: 14px; font-weight: 600; color: var(--text-2); }
.analyze-dots { display: flex; justify-content: center; gap: 6px; margin-top: 14px; }
.analyze-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); animation: dotBounce 1s ease-in-out infinite; }
.analyze-dots i:nth-child(2) { animation-delay: .15s; }
.analyze-dots i:nth-child(3) { animation-delay: .3s; }
.analyze-overlay.done .analyze-dots { visibility: hidden; }

@keyframes mealIn { from { opacity: 0; transform: translateY(-14px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes scan { to { top: 100%; } }
@keyframes dotBounce { 0%, 100% { transform: translateY(0); opacity: .5; } 50% { transform: translateY(-6px); opacity: 1; } }

/* ---------- Mascot ---------- */

.mascot { display: block; overflow: visible; }
.mascot .m-body { transform-origin: 50% 100%; transform-box: fill-box; }
.mascot.animated .m-bounce { animation: mascotBounce 2.6s ease-in-out infinite; transform-origin: 60px 108px; }
.mascot.animated .m-shadow { animation: mascotShadow 2.6s ease-in-out infinite; transform-origin: 60px 111px; }
.mascot.animated .m-eyes { animation: blink 4.5s infinite; transform-origin: 60px 66px; }
.mascot.animated .m-leaves { animation: sway 3.2s ease-in-out infinite; transform-origin: 61px 22px; }
.mascot.animated.mood-excited .m-bounce { animation-duration: 1.7s; }
.mascot.animated.mood-sleepy .m-bounce, .mascot.animated.mood-sad .m-bounce { animation-duration: 4.2s; }
.mascot.animated.tone-wilted .m-leaves { animation: droop 3.6s ease-in-out infinite; }
.mascot.animated.mood-queasy .m-bounce { animation: queasy 2.8s ease-in-out infinite; }
.mascot.animated.mood-queasy .m-sweat { animation: sweat 2.4s ease-in infinite; }
.mascot .m-sparkles path { transform-box: fill-box; transform-origin: center; animation: twinkle 1.8s ease-in-out infinite; }
.mascot .m-sparkles path:nth-child(2) { animation-delay: .6s; }
.mascot .m-sparkles path:nth-child(3) { animation-delay: 1.2s; }

/* ---------- Sheet (bottom modal) ---------- */

.overlay-root { position: absolute; inset: 0; z-index: 100; pointer-events: none; }
.overlay-root > * { pointer-events: auto; }

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 10, 8, .45);
  opacity: 0;
  transition: opacity .35s var(--ease-out);
}
.sheet-backdrop.open { opacity: 1; }

.sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 92%;
  display: flex;
  flex-direction: column;
  padding: 8px 20px calc(var(--safe-bottom) + 20px);
  border-radius: 30px 30px 0 0;
  background: var(--surface-grad);
  box-shadow: var(--shadow-lg);
  transform: translateY(105%);
  transition: transform .5s var(--ease-out);
}
.sheet.open { transform: translateY(0); }
.sheet.dragging { transition: none; }
.sheet-handle { width: 42px; height: 5px; margin: 4px auto 14px; border-radius: 3px; background: var(--surface-3); flex-shrink: 0; }
.sheet-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-shrink: 0; touch-action: none; }
.sheet-header h2 { font-size: 21px; font-weight: 800; }
.sheet-header .icon-btn { width: 36px; height: 36px; border-radius: 12px; box-shadow: none; background: var(--surface-2); }
.sheet-header .icon-btn .icon { width: 18px; height: 18px; }
.sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; margin: 0 -20px; padding: 2px 20px 4px; overscroll-behavior: contain; }
.sheet-footer { display: flex; gap: 10px; padding-top: 16px; flex-shrink: 0; }
.sheet-footer .btn { flex: 1; }

.dialog-text { color: var(--text-2); margin-bottom: 4px; }

/* ---------- Toasts ---------- */

.toast-root {
  position: absolute;
  top: calc(var(--safe-top) + 10px);
  left: 14px;
  right: 14px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  padding: 12px 16px;
  border-radius: 18px;
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  font-weight: 650;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toastIn .5s var(--ease-spring) both;
}
.toast.leaving { animation: toastOut .3s var(--ease-out) both; }
.toast .t-icon { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; flex-shrink: 0; color: #fff; background: var(--brand); }
.toast .t-icon .icon { width: 15px; height: 15px; stroke-width: 3; }
.toast.error .t-icon { background: var(--danger); }
.toast.info .t-icon { background: var(--sky); }

/* ---------- Confetti ---------- */

.confetti { position: absolute; inset: 0; z-index: 400; pointer-events: none; overflow: hidden; }
.confetti i { position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px; animation: confettiFall 1.8s cubic-bezier(.2, .6, .4, 1) forwards; }

/* ---------- Skeleton / misc ---------- */

.skeleton {
  border-radius: 14px;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--brand); border-right-color: transparent; animation: spin .7s linear infinite; }
.center { display: grid; place-items: center; min-height: 50vh; }

.stagger > * { animation: fadeUp .55s var(--ease-out) both; }
.stagger > *:nth-child(2) { animation-delay: .05s; }
.stagger > *:nth-child(3) { animation-delay: .1s; }
.stagger > *:nth-child(4) { animation-delay: .15s; }
.stagger > *:nth-child(5) { animation-delay: .2s; }
.stagger > *:nth-child(6) { animation-delay: .25s; }
.stagger > *:nth-child(7) { animation-delay: .3s; }
.stagger > *:nth-child(8) { animation-delay: .35s; }
.stagger > *:nth-child(n+9) { animation-delay: .4s; }

/* ---------- Keyframes ---------- */

@keyframes screenIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes screenInRight { from { opacity: 0; transform: translateX(28px); } to { opacity: 1; transform: none; } }
@keyframes screenInLeft { from { opacity: 0; transform: translateX(-28px); } to { opacity: 1; transform: none; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { transform: scale(.4); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes shake { 0%, 100% { transform: none; } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@keyframes float { 0%, 100% { transform: translate(0, 0) scale(1); } 33% { transform: translate(20px, -16px) scale(1.06); } 66% { transform: translate(-14px, 12px) scale(.96); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(-20px) scale(.9); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-16px) scale(.95); } }
@keyframes confettiFall {
  0% { transform: translate3d(0, 0, 0) rotate(0); opacity: 1; }
  100% { transform: translate3d(var(--dx, 0), 110vh, 0) rotate(var(--rot, 540deg)); opacity: .9; }
}
@keyframes habitPop { 0% { transform: scale(1); } 35% { transform: scale(.97); } 100% { transform: scale(1); } }
@keyframes checkBurst { 0% { transform: scale(.6); } 60% { transform: scale(1.2); } 100% { transform: scale(1); } }
@keyframes mascotBounce {
  0%, 100% { transform: translateY(0) scale(1, 1); }
  45% { transform: translateY(-7px) scale(.97, 1.03); }
  60% { transform: translateY(-5px) scale(.98, 1.02); }
}
@keyframes mascotShadow { 0%, 100% { transform: scale(1); opacity: .2; } 45% { transform: scale(.82); opacity: .12; } }
@keyframes blink { 0%, 90%, 100% { transform: scaleY(1); } 93% { transform: scaleY(.1); } }
@keyframes sway { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(5deg); } }
@keyframes queasy { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg) translateY(1px); } }
@keyframes sweat { 0% { opacity: 0; transform: translateY(-3px); } 30% { opacity: 1; } 100% { opacity: 0; transform: translateY(7px); } }
@keyframes twinkle { 0%, 100% { opacity: .15; transform: scale(.6); } 50% { opacity: 1; transform: scale(1.1); } }
@keyframes mascotPoke {
  0% { transform: none; }
  30% { transform: translateY(-16px) scale(.94, 1.07); }
  62% { transform: translateY(0) scale(1.1, .9); }
  100% { transform: none; }
}
@keyframes buddyChange { 0% { transform: scale(.7) rotate(-6deg); opacity: .4; } 100% { transform: none; opacity: 1; } }
@keyframes droop { 0%, 100% { transform: rotate(24deg) translateY(2px); } 50% { transform: rotate(30deg) translateY(3px); } }
@keyframes flicker { 0%, 100% { transform: scale(1) rotate(0); } 30% { transform: scale(1.08) rotate(-3deg); } 60% { transform: scale(.97) rotate(2deg); } }
@keyframes xpPop {
  0% { opacity: 0; transform: translate(-50%, 20px) scale(.6); }
  20% { opacity: 1; transform: translate(-50%, 0) scale(1.08); }
  35% { transform: translate(-50%, 0) scale(1); }
  80% { opacity: 1; transform: translate(-50%, -40px); }
  100% { opacity: 0; transform: translate(-50%, -70px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
