/* App-specific layout. Generic pieces live in assets/css/components.css. */
.app { max-width: 480px; margin: 0 auto; padding: 0 var(--imp-gutter) calc(40px + env(safe-area-inset-bottom)); }
.screen { display: grid; gap: var(--imp-gap); }

/* Header ("Week View"): date, week circles, weekly bar, light/dark switch */
.hud { padding: calc(env(safe-area-inset-top) + 14px) 0 18px; }
.hud__top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.hud__date { display: grid; gap: 2px; text-align: left; }
.hud__dow { font: 700 13px var(--imp-font-head); letter-spacing: .06em; text-transform: uppercase; color: var(--imp-accent); }
.hud__day { display: inline-flex; align-items: center; gap: 4px; font: 800 34px/1.05 var(--imp-font-head); letter-spacing: -.03em; }
.hud__chev { width: 20px; height: 20px; color: var(--imp-faint); margin-top: 4px; }
.hud__right { display: flex; align-items: center; gap: 8px; padding-top: 2px; min-width: 0; }
.hud__name { font: 600 15px var(--imp-font-head); color: var(--imp-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 120px; text-transform: capitalize; }
.hud__theme { flex: none; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; background: var(--imp-surface); border: 1px solid var(--imp-frame); color: var(--imp-text); box-shadow: var(--imp-shadow); transition: transform .25s var(--imp-ease); }
.hud__theme:active { transform: rotate(40deg) scale(.92); }
.hud__theme .imp-icon { width: 18px; height: 18px; }
.hud__dev { font: 800 10px var(--imp-font-head); letter-spacing: .08em; padding: 4px 7px; border-radius: 6px; background: var(--imp-warn); color: #111; }

/* Avatar: opens the You page */
.hud__me { flex: none; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font: 700 15px var(--imp-font-head); color: #fff; background: linear-gradient(135deg, var(--imp-accent), #f97316); }

/* Page header (a page opened from Home) */
.phead { position: sticky; top: 0; z-index: 30; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; margin: 0 calc(-1 * var(--imp-gutter)) 6px;
  padding: calc(env(safe-area-inset-top) + 10px) var(--imp-gutter) 10px; background: color-mix(in srgb, var(--imp-bg) 86%, transparent);
  backdrop-filter: saturate(1.5) blur(16px); -webkit-backdrop-filter: saturate(1.5) blur(16px); border-bottom: 1px solid color-mix(in srgb, var(--imp-frame) 60%, transparent); }
.phead__back { justify-self: start; display: inline-flex; align-items: center; gap: 1px; font: 600 16px var(--imp-font-head); color: var(--imp-accent); padding: 6px 6px 6px 0; }
.phead__back .imp-icon { width: 22px; height: 22px; }
.phead__title { font: 700 17px var(--imp-font-head); }

/* Home cards */
.home { gap: 14px; }
.hcard { display: grid; gap: 10px; padding: 16px; border-radius: 18px; background: var(--imp-surface); border: 1px solid var(--imp-frame); box-shadow: var(--imp-shadow); cursor: pointer; min-width: 0; }
.hcard:active { transform: scale(.99); }
.hcard__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.hcard__title { display: inline-flex; align-items: center; gap: 8px; font: 700 15px var(--imp-font-head); }
.hcard__title .imp-icon { width: 18px; height: 18px; color: var(--imp-accent); }
.hcard--water .hcard__title .imp-icon { color: var(--imp-water); }
.hcard__more { display: inline-flex; align-items: center; gap: 2px; font: 600 13px var(--imp-font-head); color: var(--imp-muted); white-space: nowrap; }
.hcard__more .imp-icon { width: 15px; height: 15px; }
.hcard__big { font: 800 28px/1.05 var(--imp-font-head); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.hcard__big small { font: 500 13px var(--imp-font-head); color: var(--imp-muted); letter-spacing: 0; margin-left: 5px; }
.hcard__big.is-over { color: var(--imp-danger); }
.hcard__big--sm { font-size: 21px; }
.hcard__sub { font: 500 13px var(--imp-font-head); color: var(--imp-muted); }
.hcard__row { display: flex; align-items: center; gap: 14px; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mini { display: grid; gap: 5px; }
.mini__top { display: flex; justify-content: space-between; gap: 6px; font: 500 12px var(--imp-font-head); color: var(--imp-muted); }
.mini__top b { color: var(--imp-text); font-weight: 600; }
.hring { --p: 0; flex: none; width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--imp-accent) calc(var(--p) * 1%), var(--imp-sunken) 0); }
.hring span { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--imp-surface); font: 700 12px var(--imp-font-head); font-variant-numeric: tabular-nums; }
.hring.is-perfect span { background: var(--imp-accent); color: #fff; }
.hq { display: grid; }
.hq__row { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--imp-divider); font-size: 15px; text-align: left; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: manipulation; }
.hq__row:last-child { border-bottom: 0; }
.hq__row small { color: var(--imp-muted); font-size: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; font: 500 13px var(--imp-font-head); color: var(--imp-muted); }
.chips > span { padding: 6px 10px; border-radius: 10px; background: var(--imp-sunken); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-btn { padding: 7px 12px; border-radius: 99px; background: var(--imp-sunken); font: 600 13px var(--imp-font-head); }
.chip-btn.is-water { color: var(--imp-water); }
.chip-btn:active { background: var(--imp-water); color: #fff; }
.jprompt { padding: 12px 14px; border-radius: 12px; border: 1px dashed var(--imp-frame); color: var(--imp-faint); font-size: 15px; line-height: 1.45; }
.jprompt.is-on { border-style: solid; color: var(--imp-text); background: var(--imp-surface-2); }

/* Day circles: the ring fills with daily habits done (--p %), a Perfect Day is solid */
.hud__week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 16px; }
.hday { display: grid; justify-items: center; gap: 6px; padding: 0; }
.hday__dow { font: 600 11px var(--imp-font-head); color: var(--imp-muted); }
.hday__ring { --size: 40px; width: var(--size); height: var(--size); border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--imp-accent) calc(var(--p) * 1%), var(--imp-sunken) 0); transition: transform .2s var(--imp-ease); }
.hday__num { width: calc(var(--size) - 8px); height: calc(var(--size) - 8px); border-radius: 50%; display: grid; place-items: center;
  background: var(--imp-bg); font: 700 14px var(--imp-font-head); font-variant-numeric: tabular-nums; }
.hday:active .hday__ring { transform: scale(.92); }
.hday.is-today .hday__dow { color: var(--imp-text); }
.hday.is-today .hday__num { background: var(--imp-text); color: var(--imp-bg); }
.hday.is-perfect .hday__ring { background: var(--imp-accent); box-shadow: 0 4px 12px color-mix(in srgb, var(--imp-accent) 35%, transparent); }
.hday.is-perfect .hday__num { background: var(--imp-accent); color: var(--imp-on-accent); }
.hday.is-blank { cursor: default; }
.hday.is-blank .hday__ring { background: transparent; }
.hday.is-blank .hday__num { color: var(--imp-faint); background: transparent; }

.hud__wbar { margin-top: 16px; display: grid; gap: 7px; }
.hud__wtop { display: flex; justify-content: space-between; font: 500 13px var(--imp-font-head); color: var(--imp-muted); }
.hud__wtop b { color: var(--imp-text); font-weight: 700; }

/* Month calendar sheet */
.cal { display: grid; gap: 12px; }
.cal__nav { display: flex; align-items: center; justify-content: space-between; }
.cal__title { font: 700 17px var(--imp-font-head); }
.cal__arrow { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; background: var(--imp-sunken); }
.cal__arrow:disabled { opacity: .3; }
.cal__arrow .imp-icon { width: 18px; height: 18px; }
.cal__grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px 4px; justify-items: center; }
.cal__wd { font: 600 11px var(--imp-font-head); color: var(--imp-faint); }
.hday--sm .hday__ring { --size: 38px; }
.hday--sm .hday__num { background: var(--imp-surface); font-size: 13px; }
.hday--sm.is-today .hday__num { background: var(--imp-text); color: var(--imp-surface); }
.hday--sm.is-perfect .hday__num { background: var(--imp-accent); color: var(--imp-on-accent); }
.hday--sm.is-blank .hday__num { background: transparent; }
.cal__legend { display: flex; justify-content: center; gap: 16px; font: 500 12px var(--imp-font-head); color: var(--imp-muted); }
.cal__legend span { display: inline-flex; align-items: center; gap: 6px; }
.cal__dot { width: 12px; height: 12px; border-radius: 50%; border: 3px solid var(--imp-accent); }
.cal__dot.is-solid { background: var(--imp-accent); }
.cal__sum { text-align: center; font: 500 14px var(--imp-font-head); color: var(--imp-muted); }
.cal__sum b { color: var(--imp-text); }

/* Day details sheet */
.dd { display: grid; gap: 6px; padding: 14px; border-radius: 14px; background: var(--imp-surface-2); border: 1px solid var(--imp-frame); }
.dd__head { display: flex; justify-content: space-between; align-items: baseline; }
.dd__head h3 { font: 700 12px var(--imp-font-head); letter-spacing: .06em; text-transform: uppercase; color: var(--imp-muted); }
.dd__head span { font: 600 13px var(--imp-font-head); color: var(--imp-muted); font-variant-numeric: tabular-nums; }
.dd__list { list-style: none; margin: 0; padding: 0; }
.dd__row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--imp-divider); font-size: 15px; }
.dd__row:last-child { border-bottom: 0; }
.dd__mark { flex: none; width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center; border: 2px solid var(--imp-faint); color: var(--imp-on-accent); font-weight: 700; }
.dd__row.is-done .dd__mark { background: var(--imp-accent); border-color: var(--imp-accent); }
.dd__row.is-off .dd__mark { border-style: dashed; color: var(--imp-faint); }
.dd__mark .imp-icon { width: 13px; height: 13px; stroke-width: 3; }
.dd__name { flex: 1; min-width: 0; display: grid; }
.dd__name small { font-size: 12px; color: var(--imp-muted); }
.dd__row:not(.is-done) .dd__mark ~ .dd__name { color: var(--imp-muted); }
.dd__val { flex: none; font: 500 13px var(--imp-font-head); color: var(--imp-muted); font-variant-numeric: tabular-nums; }
.dd__money { font-weight: 600; color: var(--imp-text); }
.dd__money.is-in { color: var(--imp-good); }
.dd__sub { margin-top: 6px; font: 600 12px var(--imp-font-head); color: var(--imp-faint); }
.dd__perfect { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; background: var(--imp-accent-dim); color: var(--imp-accent); font: 600 14px var(--imp-font-head); }
.dd__perfect .imp-icon { width: 16px; height: 16px; }
.dd__stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.dd__stats div { display: grid; gap: 2px; padding: 10px; border-radius: 10px; background: var(--imp-surface); border: 1px solid var(--imp-frame); }
.dd__stats b { font: 700 17px var(--imp-font-head); font-variant-numeric: tabular-nums; }
.dd__stats span { font-size: 12px; color: var(--imp-muted); }
.dd__journal { font-size: 15px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.dd__empty { text-align: center; color: var(--imp-muted); padding: 24px 0; }
.dd__back { justify-self: start; display: inline-flex; align-items: center; gap: 4px; font: 600 14px var(--imp-font-head); color: var(--imp-accent); }
.dd__back .imp-icon { width: 16px; height: 16px; }

/* Today */
.today-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.today-hint { margin-top: -8px; }
.today-stats { padding: 6px 0 2px; }
.today-note { margin-top: 8px; font-size: 13px; color: var(--imp-muted); }

/* Category editor */
.cat-list { display: grid; gap: 12px; }
.cat-item { display: grid; gap: 10px; }
.cat-row { display: flex; gap: 10px; align-items: center; }
.cat-icon { flex: none; width: 44px; height: 44px; display: grid; place-items: center; color: var(--imp-accent); background: var(--imp-sunken); border: 1px solid var(--imp-frame); border-radius: 12px; }
.cat-icon.is-on { box-shadow: 0 0 0 2px var(--imp-accent); border-radius: 12px; }
.cat-icon .imp-icon { width: 24px; height: 24px; }
.cat-del::before { content: none; }

/* Profile */
.profile-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; }
.profile-text { padding: 6px 0; line-height: 1.4; }
.profile-text a { text-decoration: underline; }

/* Profile (Phase 2) */
.prof-player { display: flex; gap: 16px; align-items: center; padding: 10px 0 14px; }
.prof-player__main { flex: 1; min-width: 0; }
.prof-player__top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.prof-rankname { font: 400 var(--imp-fs-sm) var(--imp-font-head); margin-top: 6px; }
.prof-note { margin-top: 8px; font-size: 14px; color: var(--imp-muted); }
.prof-warn { color: var(--imp-warn); }
.prof-totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0 4px; text-align: center; }
.prof-totals div { display: grid; gap: 2px; padding: 8px 4px; background: var(--imp-sunken); border-radius: 12px; }
.prof-totals b { font-weight: 600; font-size: 18px; color: var(--imp-text); }
.prof-totals span { font: 400 var(--imp-fs-xs) var(--imp-font-head); color: var(--imp-muted); }
.prof-streak, .prof-bonus { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--imp-divider); }
.prof-streak:last-child { border-bottom: 0; }
.prof-streak .imp-streak { flex: none; }
.prof-rank { display: grid; grid-template-columns: 72px 1fr; gap: 10px; padding: 6px 0; color: var(--imp-muted); }
.prof-rank.is-reached { color: var(--imp-text); }
.prof-rank.is-current { color: var(--imp-accent); }
.prof-rank.is-current span:last-child::after { content: "  \25C2 you"; }
.prof-rank__lv { font: 400 var(--imp-fs-xs) var(--imp-font-head); align-self: center; }
.prof-actions { margin-top: 12px; }
.rank-list { display: grid; gap: 12px; }
.rank-row { display: grid; grid-template-columns: 90px 1fr auto; gap: 10px; align-items: end; }
.rank-del { min-height: 44px; }
.rank-del::before { content: none; }
.imp-input:disabled { opacity: .5; }

/* Launch countdown (before the start date) */
.launch { min-height: calc(100vh - 40px); min-height: calc(100dvh - 40px); display: grid; place-items: center; padding: calc(env(safe-area-inset-top) + 24px) 0 24px; }
.launch__box { width: 100%; display: grid; justify-items: center; gap: 14px; text-align: center; padding: 28px 18px; background: var(--imp-surface);
  border: 1px solid var(--imp-frame); border-radius: 24px; box-shadow: var(--imp-shadow-lg); }
.launch__icon { width: 64px; height: 64px; color: var(--imp-accent); }
.launch__title { font: 700 26px var(--imp-font-head); color: var(--imp-accent); letter-spacing: .06em; }
.launch__sub { font: 400 var(--imp-fs-sm) var(--imp-font-head); line-height: 1.5; }
.launch__count { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; margin: 6px 0; }
.launch__count div { display: grid; gap: 4px; padding: 12px 4px; background: var(--imp-sunken); border: 1px solid var(--imp-divider); border-radius: 12px; }
.launch__count b { font: 400 38px/1 var(--imp-font-body); color: var(--imp-accent); }
.launch__count span { font: 400 var(--imp-fs-xs) var(--imp-font-head); color: var(--imp-muted); }
.launch__note { font-size: 15px; color: var(--imp-muted); max-width: 30ch; }
.launch__ready { font: 400 var(--imp-fs-xs) var(--imp-font-head); color: var(--imp-accent); }

/* Monthly habits before the first full habit month */
.imp-row.is-waiting { opacity: .55; }

/* Limit habits ("at most N"): the box shows uses so far */
.imp-limit-count { font-family: var(--imp-font-body, inherit); font-size: 14px; color: var(--imp-accent); }
.imp-limit-count.is-over { color: var(--imp-danger); border-color: var(--imp-danger); }
.imp-row.is-over .imp-row__sub { color: var(--imp-danger); }
.imp-row.is-over .imp-pip.is-on { background: var(--imp-danger); }
.phead__end { justify-self: end; }
.phead__more { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; color: var(--imp-text); background: var(--imp-sunken); }
.phead__more .imp-icon { width: 20px; height: 20px; }

/* Habits page: one list at a time (Daily / Weekly / Monthly), hold a habit to edit it */
.hab { gap: 12px; }
.hab-seg button { display: inline-flex; align-items: baseline; justify-content: center; gap: 6px; padding: 9px 4px; font-size: 14px; }
.hab-seg small { font: 600 11px var(--imp-font-head); color: var(--imp-faint); font-variant-numeric: tabular-nums; }
.hab-seg button.is-on small { color: var(--imp-accent); }
.hab-info { margin: -4px 4px 0; font: 500 13px var(--imp-font-head); color: var(--imp-muted); }
.hab-list .imp-panel__body { padding-top: 0; }
.hab-empty { text-align: center; color: var(--imp-muted); padding: 30px 0; }
.hab-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 2px 4px 8px; font: 500 12.5px var(--imp-font-head); color: var(--imp-faint); }
.hab-cats { font: 600 13px var(--imp-font-head); color: var(--imp-accent); }
.hab-undo { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--imp-sunken); font: 600 14px var(--imp-font-head); }
.imp-limit-box.is-over { border-color: var(--imp-danger); }
.imp-row.is-limit .imp-row__sub { flex-wrap: wrap; }

/* Grouped list: one card, thin lines between rows */
.group { padding: 0 0 0 14px; border-radius: 14px; background: var(--imp-surface); border: 1px solid var(--imp-frame); overflow: hidden; }
.g-row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 54px; padding: 9px 14px 9px 0; border-bottom: 1px solid var(--imp-divider); text-align: left; }
.g-row:last-child { border-bottom: 0; }
.g-row:active { background: var(--imp-sunken); }
.g-icon { width: 32px; height: 32px; flex: none; display: grid; place-items: center; border-radius: 9px; background: var(--imp-accent-dim); color: var(--imp-accent); }
.g-main { flex: 1; min-width: 0; display: grid; gap: 1px; }
.g-title { font: 600 15px/1.3 var(--imp-font-head); }
.g-sub { font: 500 12.5px/1.35 var(--imp-font-head); color: var(--imp-muted); }

.prof-me { display: flex; align-items: center; gap: 12px; width: 100%; padding: 4px 0; text-align: left; }
.prof-avatar { width: 48px; height: 48px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--imp-accent); color: var(--imp-on-accent); font: 700 20px var(--imp-font-head); }
.prof-me__name { flex: 1; min-width: 0; font: 700 22px var(--imp-font-head); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prof-go { width: 18px; height: 18px; flex: none; color: var(--imp-faint); }
.prof-group { margin-top: 4px; }
.prof-foot { margin: 6px var(--imp-px, 16px) 24px; font-size: 12.5px; line-height: 1.5; color: var(--imp-muted); text-align: center; }
.prof-foot a { color: inherit; text-decoration: underline; }

/* New-version pop-up */
.upd-pop { position: fixed; z-index: 200; left: 16px; right: 16px; top: calc(env(safe-area-inset-top) + 10px); display: grid; gap: 2px; padding: 12px 16px;
  text-align: left; border-radius: 14px; background: var(--imp-accent); color: var(--imp-on-accent); box-shadow: 0 8px 24px rgba(0,0,0,.25); animation: upd-in .25s var(--imp-ease); }
.upd-pop b { font: 700 15px var(--imp-font-head); }
.upd-pop span { font: 500 13px var(--imp-font-head); opacity: .9; }
.upd-pop.is-done { background: var(--imp-text); color: var(--imp-bg, #fff); pointer-events: none; }
@keyframes upd-in { from { transform: translateY(-12px); opacity: 0; } }

/* ---- Streaks: flame badge (4 levels), gold/silver rows, milestone popup -------------------- */
.imp-flame { position: relative; display: inline-block; flex: none; }
.imp-flame svg { display: block; overflow: visible; width: 15px; height: 19px; }
.imp-flame__o { transform-origin: 50% 95%; animation: imp-flick 1.6s ease-in-out infinite; }
.imp-flame__i { transform-origin: 50% 95%; animation: imp-flick2 .9s ease-in-out infinite; }
@keyframes imp-flick { 0%,100% { transform: none; } 25% { transform: scale(.95,1.07) skewX(-3deg); } 50% { transform: scale(1.04,.96) skewX(2deg); } 75% { transform: scale(.97,1.05) skewX(-1deg); } }
@keyframes imp-flick2 { 0%,100% { transform: none; } 50% { transform: scale(.88,1.12); } }
.imp-ember { position: absolute; left: 50%; bottom: 60%; width: 3px; height: 3px; border-radius: 50%; opacity: 0; animation: imp-rise 1.4s ease-out infinite; }
.imp-ember:nth-of-type(2) { animation-delay: .45s; --dx: 6px; }
.imp-ember:nth-of-type(3) { animation-delay: .9s; --dx: -5px; }
.imp-ember:nth-of-type(4) { animation-delay: .25s; --dx: -8px; }
.imp-ember:nth-of-type(5) { animation-delay: .7s; --dx: 9px; }
@keyframes imp-rise { 0% { opacity: 0; transform: translate(-50%, 0); } 15% { opacity: 1; } 100% { opacity: 0; transform: translate(calc(-50% + var(--dx, 2px)), -22px) scale(.4); } }
.t2 .imp-ember { background: #ffb020; }
.t3 .imp-ember { background: #8fd0ff; }
.t4 .imp-ember { background: #e3b4ff; box-shadow: 0 0 4px #c77dff; }

.imp-sbadge { flex: none; display: inline-flex; align-items: center; gap: 3px; padding: 3px 10px 3px 6px; border-radius: 999px; font: 800 15px var(--imp-font-head); font-variant-numeric: tabular-nums; }
.imp-sbadge small { font: 600 11px var(--imp-font-head); opacity: .8; margin-left: 1px; }
.imp-sbadge.t1 { color: #e07800; background: rgba(255, 149, 0, .13); }
.imp-sbadge.t2 { color: #e8380d; background: rgba(255, 77, 26, .14); font-size: 16px; }
.imp-sbadge.t2 .imp-flame svg { width: 19px; height: 24px; }
.imp-sbadge.t2 .imp-flame__o { animation-duration: 1.1s; }
.imp-sbadge.t3 { color: #1e6bff; background: rgba(47, 123, 255, .14); font-size: 17px; box-shadow: 0 0 14px rgba(58, 139, 255, .35); }
.imp-sbadge.t3 .imp-flame svg { width: 21px; height: 27px; filter: drop-shadow(0 0 4px rgba(60, 140, 255, .8)); }
.imp-sbadge.t3 .imp-flame__o { animation-duration: 1s; }
.imp-sbadge.t4 { color: #fff; background: linear-gradient(135deg, #2a0a5e, #12042a); font-size: 18px; box-shadow: 0 0 18px rgba(150, 60, 255, .7); animation: imp-pillglow 2.2s ease-in-out infinite; }
.imp-sbadge.t4 .imp-flame svg { width: 25px; height: 32px; filter: drop-shadow(0 0 6px rgba(190, 90, 255, .95)) drop-shadow(0 0 14px rgba(140, 40, 255, .6)); }
.imp-sbadge.t4 .imp-flame__o { animation-duration: .8s; }
.imp-sbadge.t4 .imp-flame__i { animation-duration: .55s; }
@keyframes imp-pillglow { 50% { box-shadow: 0 0 28px rgba(170, 80, 255, .95); } }
:root[data-theme="dark"] .imp-sbadge.t1:not(.is-risk) { color: #ffa53a; }
:root[data-theme="dark"] .imp-sbadge.t2:not(.is-risk) { color: #ff6a3d; }
:root[data-theme="dark"] .imp-sbadge.t3:not(.is-risk) { color: #6aa8ff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .imp-sbadge.t1:not(.is-risk) { color: #ffa53a; } :root:not([data-theme="light"]) .imp-sbadge.t2:not(.is-risk) { color: #ff6a3d; } :root:not([data-theme="light"]) .imp-sbadge.t3:not(.is-risk) { color: #6aa8ff; } }

/* Missed yesterday: gray, still flame + "do it today" */
.imp-sbadge.is-risk { flex-direction: column; align-items: flex-end; gap: 0; padding: 4px 10px; border-radius: 12px; color: var(--imp-muted); background: color-mix(in srgb, var(--imp-muted) 14%, transparent); box-shadow: none; animation: none; }
.imp-sbadge__top { display: inline-flex; align-items: center; gap: 3px; }
.imp-sbadge__warn { font: 700 11px var(--imp-font-head); color: var(--imp-danger); }
.imp-sbadge.is-risk .imp-flame svg { filter: grayscale(1) opacity(.55); }
.imp-sbadge.is-risk .imp-flame__o, .imp-sbadge.is-risk .imp-flame__i { animation-play-state: paused; }
.imp-sbadge.is-risk .imp-ember { display: none; }
.imp-missed { color: var(--imp-danger); font-weight: 600; }

/* Top flame level: the habit turns shiny gold (silver while at risk) */
.imp-row.is-gold, .imp-row.is-silver { margin: 0 calc(var(--imp-pad) * -1); padding-left: var(--imp-pad); padding-right: var(--imp-pad); width: calc(100% + var(--imp-pad) * 2); overflow: hidden; }
.imp-row.is-gold { background: linear-gradient(115deg, #b8860b 0%, #f5d061 22%, #fff4c2 38%, #e8b923 55%, #c99212 78%, #f7dc7a 100%); border-bottom-color: #c99a1e; }
.imp-row.is-gold::after { content: ""; position: absolute; inset: 0; background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, .75) 50%, transparent 65%); transform: translateX(-120%); animation: imp-sheen 3.2s ease-in-out infinite; pointer-events: none; }
@keyframes imp-sheen { 0%, 35% { transform: translateX(-120%); } 75%, 100% { transform: translateX(120%); } }
.imp-row.is-gold .imp-row__title, .imp-row.is-gold.is-done .imp-row__title { color: #4a3500; text-decoration-color: rgba(74, 53, 0, .45); }
.imp-row.is-gold .imp-row__sub, .imp-row.is-gold .imp-row__rule, .imp-row.is-gold .imp-row__note { color: #6b4e00; }
.imp-row.is-gold .imp-check { border-color: #6b4e00; }
.imp-row.is-gold .imp-check.is-on { background: #4a3500; border-color: #4a3500; color: #ffd75e; }
.imp-row.is-silver { background: linear-gradient(115deg, #b9bcc2, #e4e6ea 40%, #c9ccd2 70%, #dfe1e5); border-bottom-color: #b0b4ba; }
.imp-row.is-silver .imp-row__title, .imp-row.is-silver .imp-row__sub, .imp-row.is-silver .imp-row__rule, .imp-row.is-silver .imp-row__note { color: #2b2f36; }
.imp-row.is-silver .imp-missed { color: #c4262c; }
.imp-row.is-silver .imp-check { border-color: #8d929a; }
.imp-row.is-silver .imp-sbadge { color: #4b5058; background: rgba(255, 255, 255, .45); }
.imp-row.is-silver .imp-sbadge__warn { color: #c4262c; }
.prof-streak .imp-sbadge { flex: none; }
.prof-streak.is-gold, .prof-streak.is-silver { margin: 0 calc(var(--imp-pad) * -1); padding-left: var(--imp-pad); padding-right: var(--imp-pad); }
.prof-streak.is-gold { background: linear-gradient(115deg, #b8860b, #f5d061 30%, #fff4c2 45%, #e8b923 65%, #c99212); color: #4a3500; font-weight: 600; }
.prof-streak.is-silver { background: linear-gradient(115deg, #b9bcc2, #e4e6ea 40%, #c9ccd2 70%, #dfe1e5); color: #2b2f36; }
.prof-streak.is-silver .imp-sbadge { color: #4b5058; background: rgba(255, 255, 255, .45); }

/* Milestone popup */
.imp-sburst { position: relative; overflow: hidden; gap: 6px; padding-top: 24px; }
.imp-sburst__flame { position: relative; display: grid; place-items: center; width: 110px; height: 110px; }
.imp-sburst .imp-flame svg { width: 64px; height: 82px; animation: imp-grow .7s cubic-bezier(.2, 1.6, .4, 1) both; }
.imp-sburst.t3 .imp-flame svg { filter: drop-shadow(0 0 8px rgba(60, 140, 255, .8)); }
.imp-sburst.t4 .imp-flame svg { filter: drop-shadow(0 0 10px rgba(190, 90, 255, .95)) drop-shadow(0 0 22px rgba(140, 40, 255, .6)); }
.imp-sburst.t1 .imp-sburst__flame { color: #ff8a00; }
.imp-sburst.t2 .imp-sburst__flame { color: #ff4d1a; }
.imp-sburst.t3 .imp-sburst__flame { color: #2f8bff; }
.imp-sburst.t4 .imp-sburst__flame { color: #a53cff; }
.imp-sburst__ring { position: absolute; inset: 0; border-radius: 50%; border: 3px solid currentColor; opacity: 0; animation: imp-ring 1s ease-out .15s; }
.imp-spark { position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0; animation: imp-spark .9s ease-out .1s forwards; }
.imp-sburst__num { font: 800 52px/1 var(--imp-font-head); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.imp-sburst.is-gold { background: linear-gradient(135deg, #b8860b, #f5d061 30%, #fff4c2 45%, #e8b923 65%, #c99212); color: #4a3500; }
.imp-sburst.is-gold::after { content: ""; position: absolute; inset: 0; background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, .7) 50%, transparent 65%); animation: imp-sheen 2.4s ease-in-out infinite; pointer-events: none; }
.imp-sburst.is-gold .imp-burst__sub, .imp-sburst.is-gold .imp-burst__hint { color: #5c4300; }
@keyframes imp-grow { from { transform: scale(.2); opacity: 0; } }
@keyframes imp-ring { 0% { opacity: .8; transform: scale(.4); } 100% { opacity: 0; transform: scale(1.5); } }
@keyframes imp-spark { 0% { opacity: 1; transform: translate(-50%, -50%) rotate(var(--a)) translateY(0); } 100% { opacity: 0; transform: translate(-50%, -50%) rotate(var(--a)) translateY(var(--d, -78px)) scale(.3); } }
@media (prefers-reduced-motion: reduce) {
  .imp-flame__o, .imp-flame__i, .imp-ember, .imp-sbadge.t4, .imp-row.is-gold::after, .imp-sburst.is-gold::after { animation: none; }
}

/* ---- Perfect Day / Week / Month ------------------------------------------------------------- */
:root { --imp-gold: linear-gradient(135deg, #b8860b, #f5d061 30%, #fff4c2 45%, #e8b923 65%, #c99212); --imp-gold-ink: #4a3500; }
/* Perfect Week: the header's 7 circles turn gold */
.hud__week.is-gold .hday__ring { background: var(--imp-gold); box-shadow: 0 4px 14px rgba(201, 146, 18, .45); }
.hud__week.is-gold .hday__num { position: relative; overflow: hidden; background: var(--imp-gold); color: var(--imp-gold-ink); }
.hud__week.is-gold .hday__num::after { content: ""; position: absolute; inset: 0; background: linear-gradient(105deg, transparent 30%, rgba(255, 255, 255, .8) 50%, transparent 70%); transform: translateX(-130%); animation: imp-sheen2 3s ease-in-out infinite; animation-delay: calc(var(--i) * .08s); }
.hud__week.is-gold .hday__dow { color: #b8860b; }
.hud__week.is-gold .hday { animation: imp-flip .5s cubic-bezier(.2, 1.5, .4, 1) both; animation-delay: calc(var(--i) * .08s); }
.hud__pweek, .cal__pmonth { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; background: var(--imp-gold); color: var(--imp-gold-ink); font: 700 12px var(--imp-font-head); }
.hud__pweek { margin-top: 10px; }
.hud__pweek .imp-icon, .cal__pmonth .imp-icon { width: 13px; height: 13px; }
@keyframes imp-sheen2 { 0%, 40% { transform: translateX(-130%); } 80%, 100% { transform: translateX(130%); } }
@keyframes imp-flip { 0% { transform: scale(.6) rotateY(90deg); } 100% { transform: none; } }
/* Perfect Month: gold frame + label on the calendar */
.cal.is-gold { padding: 14px 10px; border-radius: 18px; border: 3px solid transparent; background: linear-gradient(var(--imp-surface), var(--imp-surface)) padding-box, linear-gradient(135deg, #b8860b, #f5d061 25%, #fff4c2 40%, #e8b923 60%, #c99212 80%, #f7dc7a) border-box; box-shadow: 0 0 22px rgba(232, 185, 35, .35); }
.cal__title { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; }
.cal__pmonth { letter-spacing: .02em; }
/* You tab totals: 5 boxes (Perfect Days/Weeks/Months, then Check-ins, Streaks) */
.prof-totals { grid-template-columns: repeat(6, 1fr); }
.prof-totals div { grid-column: span 2; }
.prof-totals div:nth-child(n+4) { grid-column: span 3; }
.prof-totals div.is-gold { background: var(--imp-gold); }
.prof-totals div.is-gold b { color: var(--imp-gold-ink); }
.prof-totals div.is-gold span { color: #5c4300; }
/* Popups */
.imp-pb { position: relative; overflow: hidden; gap: 6px; }
.imp-pb__star { position: relative; display: grid; place-items: center; width: 110px; height: 110px; color: var(--imp-accent); }
.imp-pb__star svg { width: 66px; height: 66px; animation: imp-spin-in .8s cubic-bezier(.2, 1.5, .4, 1) both; filter: drop-shadow(0 4px 10px rgba(0, 0, 0, .18)); }
.imp-pb__star svg path { fill: var(--imp-accent); }
.imp-pb__ring { position: absolute; inset: 0; border-radius: 50%; border: 3px solid currentColor; opacity: 0; animation: imp-ring 1s ease-out .2s; }
.imp-pb .imp-spark { animation-delay: .15s; }
.imp-pb--week .imp-pb__star { color: #e8b923; }
.imp-pb--week .imp-pb__star svg path { fill: url(#pgold); }
.imp-pb__seven { display: flex; gap: 6px; margin: 2px 0; }
.imp-pb__seven i { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font: 700 11px var(--imp-font-head); font-style: normal; background: var(--imp-sunken); color: var(--imp-faint); animation: imp-light-up .35s cubic-bezier(.2, 1.6, .4, 1) both; animation-delay: calc(.35s + var(--i) * .12s); }
@keyframes imp-light-up { 0% { transform: scale(.7); } 100% { background: var(--imp-accent); color: #fff; transform: none; } }
.imp-pb--month { background: var(--imp-gold); color: var(--imp-gold-ink); padding-top: 30px; }
.imp-pb--month::after { content: ""; position: absolute; inset: 0; background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, .7) 50%, transparent 65%); animation: imp-sheen 2.4s ease-in-out infinite; pointer-events: none; }
.imp-pb--month .imp-pb__star { width: 130px; height: 130px; color: #fff; }
.imp-pb--month .imp-pb__star svg { width: 84px; height: 84px; filter: drop-shadow(0 0 14px rgba(255, 255, 255, .9)); }
.imp-pb--month .imp-pb__star svg path { fill: #fffaf0; }
.imp-pb--month .imp-spark { width: 7px; height: 7px; background: #fff; box-shadow: 0 0 6px #fff; }
.imp-pb--month .imp-burst__title { font-size: 28px; }
.imp-pb--month .imp-burst__sub, .imp-pb--month .imp-burst__hint { color: #5c4300; }
.imp-pb__count { font: 800 54px/1 var(--imp-font-head); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.imp-confetti { position: fixed; top: -12px; width: 8px; height: 12px; border-radius: 2px; opacity: .95; animation: imp-fall linear forwards; pointer-events: none; }
@keyframes imp-fall { to { transform: translate(var(--dx), 110vh) rotate(var(--r)); } }
@keyframes imp-spin-in { from { transform: scale(.1) rotate(-160deg); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .hud__week.is-gold .hday, .hud__week.is-gold .hday__num::after, .imp-pb--month::after, .imp-pb__seven i { animation: none; }
  .imp-pb__seven i { background: var(--imp-accent); color: #fff; }
}

/* On/off switch (habit editor: grace day) */
.imp-switchrow { display: flex; align-items: center; gap: 12px; }
.imp-switchrow__text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.imp-switchrow__title { font: 600 15px var(--imp-font-head); color: var(--imp-text); }
.imp-switch { -webkit-appearance: none; appearance: none; flex: none; position: relative; width: 51px; height: 31px; margin: 0; border-radius: 999px; background: var(--imp-sunken); border: 1px solid var(--imp-frame); cursor: pointer; transition: background .2s; }
.imp-switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 25px; height: 25px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, .25); transition: transform .2s var(--imp-ease); }
.imp-switch:checked { background: var(--imp-accent); border-color: var(--imp-accent); }
.imp-switch:checked::after { transform: translateX(20px); }
.imp-switch:focus-visible { outline: 3px solid var(--imp-accent); outline-offset: 2px; }

/* ---- Habits (Nov 2026): 2-min / Full, cards, picker, completion bursts --------------------------- */
.hab-head { display: flex; justify-content: space-between; align-items: baseline; margin: 0 4px; font: 500 13px var(--imp-font-head); color: var(--imp-muted); }
.hab-head b { color: var(--imp-text); font-size: 15px; }
.hab-item { border-bottom: 1px solid var(--imp-divider); }
.hab-item:last-child { border-bottom: 0; }
.hab-item .imp-row { border-bottom: 0; cursor: pointer; }
.hab-box { flex: none; display: grid; place-items: center; width: 40px; height: 40px; margin: -8px -4px -8px -8px; border-radius: 12px; }
.hab-box:active { transform: scale(.92); }
.hab-box .imp-check { width: 26px; height: 26px; border-radius: 8px; }
/* 2-min (Minimum): soft fill and an accent tick; Full: solid */
.imp-check.is-min { border-color: var(--imp-accent); background: var(--imp-accent-dim); color: var(--imp-accent); }
.imp-check.is-min .imp-icon { visibility: visible; opacity: .9; animation: imp-tick .25s var(--imp-ease); }
.hab-row.is-min .imp-row__title { color: var(--imp-text); }
.hab-tag { display: inline-flex; padding: 1px 7px; border-radius: 999px; font: 700 11px var(--imp-font-head); color: var(--imp-accent); background: var(--imp-accent-dim); }
.hab-sub-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font: 500 12.5px var(--imp-font-head); color: var(--imp-muted); }
.hab-sub-line b { color: var(--imp-text); font-variant-numeric: tabular-nums; }
.hab-sub-line .imp-pips { margin-top: 0; }
.imp-pip.is-half { background: linear-gradient(90deg, var(--imp-accent) 50%, var(--imp-sunken) 50%); box-shadow: inset 0 0 0 1.5px var(--imp-accent); }
/* Fast food: Lift's look; the box shows today's meals in the app blue */
.hab-row.is-ff .imp-check.is-count { border-color: var(--imp-accent); background: var(--imp-accent-dim); }
.hab-row.is-ff .imp-check__count { color: var(--imp-accent); }
.hab-row.is-ff.is-over .imp-check.is-count { border-color: var(--imp-danger); }
.hab-row.is-ff.is-over .imp-check__count { color: var(--imp-danger); }
/* The card: cue / craving / response / reward / 2-min / full */
.hab-card { display: grid; gap: 8px; margin: 0 0 12px 40px; padding: 12px 14px; border-radius: 14px; background: var(--imp-sunken); animation: hab-card-in .22s var(--imp-ease); }
.hab-card[hidden] { display: none; }
.hab-card__row { display: grid; grid-template-columns: 74px 1fr; gap: 10px; }
.hab-card dt { font: 700 11px var(--imp-font-head); letter-spacing: .05em; text-transform: uppercase; color: var(--imp-accent); padding-top: 2px; }
.hab-card dd { margin: 0; font: 400 14px/1.4 var(--imp-font-body); color: var(--imp-text); }
@keyframes hab-card-in { from { opacity: 0; transform: translateY(-4px); } }
.hab-ta { min-height: 44px; resize: vertical; font: inherit; line-height: 1.35; }
/* Day details: a 2-min habit */
.dd__row.is-min .dd__mark { color: var(--imp-accent); background: var(--imp-accent-dim); border-color: var(--imp-accent); }

/* Completion bursts (several looks, picked at random) */
.tick-fx { position: fixed; z-index: 90; width: 0; height: 0; pointer-events: none; }
.tick-fx > * { position: absolute; left: 0; top: 0; }
.tick-fx__dot, .tick-fx__bit, .tick-fx__star { opacity: 0; animation: tick-fly var(--t) cubic-bezier(.15, .7, .3, 1) forwards; }
.tick-fx__dot { width: 7px; height: 7px; margin: -3.5px; border-radius: 50%; background: var(--c); }
.tick-fx__bit { width: 6px; height: 10px; margin: -5px -3px; border-radius: 2px; background: var(--c); }
.tick-fx__star { width: 11px; height: 11px; margin: -5.5px; background: var(--c); clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); }
.tick-fx__ring { width: 30px; height: 30px; margin: -15px; border-radius: 50%; border: 3px solid var(--c); opacity: 0; animation: tick-ring .55s ease-out forwards; }
.tick-fx__ring--2 { animation-delay: .12s; }
.tick-fx__word { left: 0; top: -30px; transform: translateX(-50%); white-space: nowrap; font: 800 15px var(--imp-font-head); color: var(--imp-accent); text-shadow: 0 1px 0 var(--imp-surface), 0 0 8px var(--imp-surface); animation: tick-word 1.3s ease-out forwards; }
@keyframes tick-fly { 0% { opacity: 1; transform: rotate(var(--a)) translateY(0) rotate(0); } 70% { opacity: 1; } 100% { opacity: 0; transform: rotate(var(--a)) translateY(calc(var(--d) * -1)) rotate(var(--r)); } }
@keyframes tick-ring { 0% { opacity: .9; transform: scale(.5); } 100% { opacity: 0; transform: scale(2.2); } }
@keyframes tick-word { 0% { opacity: 0; transform: translate(-50%, 6px) scale(.8); } 20% { opacity: 1; transform: translate(-50%, 0) scale(1.05); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -14px); } }
.is-popped .imp-check, .imp-check.is-popped { animation: tick-pop .35s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes tick-pop { 0% { transform: scale(.7); } 60% { transform: scale(1.18); } 100% { transform: none; } }
@media (prefers-reduced-motion: reduce) { .hab-card { animation: none; } }
