/* ============================================================
   RITUAL — design system
   Warm charcoal / graphite / cream / muted gold. Glass + bevel.
   ============================================================ */

:root {
  --bg0: #131110;
  --bg1: #1b1815;
  --bg2: #221e1a;
  --panel: rgba(34, 31, 27, 0.66);
  --panel-2: rgba(42, 38, 33, 0.55);
  --panel-solid: #211e1a;
  --line: rgba(242, 232, 210, 0.075);
  --line-2: rgba(242, 232, 210, 0.14);
  --text: #f0e9d9;
  --text-2: #b9ae99;
  --text-3: #8a8071;
  --gold: #d2ab6b;
  --gold-2: #a3803f;
  --gold-soft: rgba(210, 171, 107, 0.14);
  --gold-line: rgba(210, 171, 107, 0.35);
  --purple: #a294cb;
  --purple-soft: rgba(162, 148, 203, 0.13);
  --green: #a3bd8e;
  --green-soft: rgba(163, 189, 142, 0.13);
  --red: #cd8a6e;
  --red-soft: rgba(205, 138, 110, 0.13);
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.38);
  --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.28);
  --bevel: inset 0 1px 0 rgba(255, 250, 235, 0.055);
  --r-lg: 22px;
  --r-md: 16px;
  --r-sm: 11px;
  --tabbar-h: 88px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, Roboto, sans-serif;
  --serif: ui-serif, "New York", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { height: 100%; }
body {
  margin: 0; min-height: 100%;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg0);
  background-image:
    radial-gradient(1100px 600px at 15% -8%, rgba(210, 171, 107, 0.055), transparent 60%),
    radial-gradient(900px 700px at 110% 12%, rgba(162, 148, 203, 0.04), transparent 55%),
    linear-gradient(180deg, #171412 0%, #131110 45%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  font-size: 15.5px; line-height: 1.45;
  overscroll-behavior-y: none;
}
::selection { background: rgba(210,171,107,.3); }

h1,h2,h3,h4 { margin: 0; font-weight: 650; letter-spacing: -0.015em; }
p { margin: 0; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
svg { display: block; }
[hidden] { display: none !important; }

/* ---------- shell ---------- */
.app { max-width: 480px; margin: 0 auto; padding: calc(16px + env(safe-area-inset-top)) 16px calc(var(--tabbar-h) + 26px + env(safe-area-inset-bottom)); }
/* subtle sync status pinned to the very bottom of the page content */
.sync-foot { justify-content: center; width: fit-content; margin: 22px auto 4px; opacity: .5; border-color: transparent; background: transparent; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top)) 2px 10px;
  position: sticky; top: 0; z-index: 30;
  background: linear-gradient(180deg, rgba(19,17,16,.92) 65%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.wordmark { font-family: var(--serif); font-size: 21px; letter-spacing: .02em; color: var(--text); font-weight: 600; }
.wordmark em { font-style: normal; color: var(--gold); }
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.iconbtn {
  width: 38px; height: 38px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text-2); display: grid; place-items: center;
  box-shadow: var(--bevel); font-size: 16px;
}
.iconbtn span { display: flex; }
.iconbtn svg { width: 19px; height: 19px; }
.iconbtn:active { transform: scale(.95); }
.sync-pill { font-size: 11px; color: var(--text-3); display: flex; align-items: center; gap: 5px; padding: 4px 9px; border-radius: 99px; border: 1px solid var(--line); background: var(--panel); }
.sync-dot { width: 6px; height: 6px; border-radius: 99px; background: var(--green); }
.sync-pill.off .sync-dot { background: var(--text-3); }
.sync-pill.err .sync-dot { background: var(--red); }
.sync-pill.busy .sync-dot { background: var(--gold); animation: pulse 1.1s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* floating detached island — spans the full width with a small inset from the
   screen edges; tabs are distributed evenly across it. */
.tabbar {
  position: fixed; left: 12px; right: 12px;
  bottom: calc(14px + env(safe-area-inset-bottom)); z-index: 40;
  display: flex; align-items: center; justify-content: space-evenly;
  padding: 9px 8px;
  background: rgba(28, 24, 20, 0.9);
  backdrop-filter: blur(28px) saturate(1.5); -webkit-backdrop-filter: blur(28px) saturate(1.5);
  border: 1px solid rgba(242, 232, 210, 0.12);
  border-radius: 28px;
  box-shadow: 0 20px 52px -12px rgba(0, 0, 0, 0.82), 0 3px 12px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(242, 232, 210, 0.06);
}
/* fade the page content out beneath the floating nav so it stands clear */
.nav-scrim {
  position: fixed; left: 0; right: 0; bottom: 0; height: 168px; z-index: 39;
  pointer-events: none;
  background: linear-gradient(to top, var(--bg0) 30%, rgba(19, 17, 16, 0.72) 58%, transparent);
}
@media (min-width: 1024px) { .nav-scrim { display: none; } }
.tab {
  --acc: 210, 171, 107;
  flex: 0 0 auto; border: 0; background: transparent; color: var(--text-3);
  display: flex; flex-direction: row; align-items: center; justify-content: center;
  height: 54px; padding: 0 16px; border-radius: 99px; cursor: pointer;
  transition: background .3s cubic-bezier(.2,.8,.2,1), color .22s;
}
/* per-tab accent — each destination gets its own muted, on-brand glow */
.tab[data-view="today"],    .navbtn[data-view="today"]    { --acc: 214, 174, 104; } /* gold */
.tab[data-view="habits"],   .navbtn[data-view="habits"]   { --acc: 159, 183, 137; } /* sage */
.tab[data-view="progress"], .navbtn[data-view="progress"] { --acc: 143, 166, 204; } /* slate */
.tab[data-view="profile"],  .navbtn[data-view="profile"]  { --acc: 201, 161, 173; } /* rose */
.tab .tab-ic { display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.tab svg { width: 25px; height: 25px; }
.tab .tab-label {
  width: 0; opacity: 0; overflow: hidden; white-space: nowrap; text-align: center;
  font-size: 14px; font-weight: 650; letter-spacing: .01em;
  transition: width .32s cubic-bezier(.2,.8,.2,1), opacity .22s ease .04s, margin .32s cubic-bezier(.2,.8,.2,1);
}
/* unselected = bare icon only (no background, no border, no box). only the
   active tab becomes a tinted, glowing pill in its own accent color. */
.tab.active {
  color: rgb(var(--acc));
  background: radial-gradient(130% 150% at 28% 0%, rgba(var(--acc), 0.26), rgba(var(--acc), 0.11));
  box-shadow: inset 0 0 0 1px rgba(var(--acc), 0.42), 0 5px 16px -7px rgba(var(--acc), 0.5);
}
/* fixed label width => every active pill is the same size => the centered row's
   total width never changes, so tapping a tab glides the pill instead of shoving
   the whole bar around. */
.tab.active .tab-label { width: 74px; opacity: 1; margin-left: 8px; }
.tab.active svg { filter: drop-shadow(0 1px 4px rgba(var(--acc), 0.35)); }

/* desktop */
.sidebar { display: none; }
@media (min-width: 1024px) {
  body { font-size: 15px; }
  .app { max-width: 1160px; padding: 26px 32px 60px 272px; }
  .tabbar { display: none; }
  .sidebar {
    display: flex; flex-direction: column; gap: 4px;
    position: fixed; left: 0; top: 0; bottom: 0; width: 240px; z-index: 40;
    padding: 26px 18px; border-right: 1px solid var(--line);
    background: rgba(22, 19, 17, 0.75); backdrop-filter: blur(20px);
  }
  .sidebar .wordmark { font-size: 24px; padding: 2px 12px 22px; }
  .navbtn {
    --acc: 214, 174, 104;
    display: flex; align-items: center; gap: 12px; padding: 11px 14px;
    border: 0; background: transparent; color: var(--text-2); border-radius: 12px;
    font-size: 14.5px; text-align: left; transition: all .15s;
  }
  .navbtn svg { width: 19px; height: 19px; }
  .navbtn:hover { background: rgba(242,232,210,.045); color: var(--text); }
  .navbtn.active { background: rgba(var(--acc), 0.14); color: rgb(var(--acc)); }
  .sidebar-foot { margin-top: auto; padding: 10px 12px; font-size: 12px; color: var(--text-3); }
  .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
  .grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; align-items: start; }
  .desk-cols { display: grid; grid-template-columns: 5fr 4fr; gap: 18px; align-items: start; }
  /* uniform habit cards: equal height per row with the action row pinned to the bottom */
  .hgrid { align-items: stretch; }
}
@media (max-width: 1023.5px) {
  .grid-2, .grid-3, .desk-cols { display: flex; flex-direction: column; gap: 0; }
}
.hgrid > .card { display: flex; flex-direction: column; }
.hgrid > .card > .hcard-foot { margin-top: auto; }

/* ---------- cards ---------- */
.card {
  background: linear-gradient(160deg, var(--panel-2), var(--panel) 55%);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm), var(--bevel);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  padding: 18px;
  margin-bottom: 14px;
  position: relative;
}
.card.flat { box-shadow: var(--bevel); }
.card.hero {
  background:
    radial-gradient(420px 200px at 85% -30%, rgba(210,171,107,.13), transparent 65%),
    linear-gradient(160deg, #262119, var(--panel-solid) 60%);
  box-shadow: var(--shadow), var(--bevel);
}
.card.purple-tint {
  background:
    radial-gradient(400px 190px at 90% -25%, rgba(162,148,203,.12), transparent 65%),
    linear-gradient(160deg, var(--panel-2), var(--panel) 55%);
}
.label {
  font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--text-3); font-weight: 600; margin-bottom: 8px;
}
.label .lr { float: right; letter-spacing: .02em; text-transform: none; font-weight: 500; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.card-head .label { margin: 0; }
.link { background: none; border: 0; color: var(--gold); font-size: 13px; padding: 0; font-weight: 550; }

.num { font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.big { font-size: 34px; font-weight: 680; line-height: 1.05; }
.mid { font-size: 22px; font-weight: 650; }
.unit { font-size: .52em; color: var(--text-3); font-weight: 550; margin-left: 3px; }
.sub { color: var(--text-2); font-size: 13px; }
.tiny { color: var(--text-3); font-size: 12px; }
.gold { color: var(--gold); } .green { color: var(--green); } .red { color: var(--red); } .purple { color: var(--purple); }

.tile-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.tile-row.three { grid-template-columns: repeat(3, 1fr); }
.tile {
  background: linear-gradient(160deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: var(--bevel); padding: 13px 14px;
}
.tile .label { margin-bottom: 4px; }
.tile .big { font-size: 24px; }

.divider { height: 1px; background: var(--line); margin: 14px -18px; }
.divider.in { margin: 14px 0; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 14px; padding: 13px 20px; font-size: 15px; font-weight: 620;
  border: 1px solid transparent; transition: transform .12s, filter .15s;
  color: #241d12;
  background: linear-gradient(160deg, #e0bd80, #b8905018 130%), linear-gradient(160deg, #ddb97c, #a98545);
  box-shadow: 0 6px 18px rgba(190, 150, 85, 0.22), inset 0 1px 0 rgba(255,255,255,.25);
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn.ghost {
  background: var(--panel); color: var(--text); border-color: var(--line-2);
  box-shadow: var(--bevel);
}
.btn.soft { background: var(--gold-soft); color: var(--gold); border-color: var(--gold-line); box-shadow: none; }
.btn.danger { background: var(--red-soft); color: var(--red); border-color: rgba(205,138,110,.3); box-shadow: none; }
.btn.small { padding: 8px 14px; font-size: 13px; border-radius: 11px; }
.btn.block { width: 100%; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

/* ---------- forms ---------- */
.field { margin-bottom: 14px; }
.field > .flabel { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 7px; font-weight: 560; }
.field .fhint { font-size: 11.5px; color: var(--text-3); margin-top: 5px; }
/* compact spacing so the new-habit sheet fits without scrolling */
.habit-sheet .field { margin-bottom: 11px; }
.habit-sheet .field > .flabel { margin-bottom: 5px; }
.habit-sheet .field .fhint { margin-top: 3px; }
input[type=text], input[type=number], input[type=password], input[type=date], input[type=time], input[type=tel], select, textarea {
  width: 100%; padding: 13px 14px; border-radius: 13px;
  border: 1px solid var(--line-2); background: rgba(18, 16, 14, 0.55);
  color: var(--text); font-size: 16px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--gold-line); box-shadow: 0 0 0 3px rgba(210,171,107,.1); }
textarea { resize: vertical; min-height: 74px; line-height: 1.5; }
select { -webkit-appearance: none; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }

.inline-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.inline-fields.three { grid-template-columns: 1fr 1fr 1fr; }

/* stepper */
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper input { text-align: center; font-weight: 650; font-variant-numeric: tabular-nums; }
.step-btn {
  flex: 0 0 46px; height: 46px; border-radius: 13px; border: 1px solid var(--line-2);
  background: var(--panel); color: var(--text-2); font-size: 20px; font-weight: 500;
  box-shadow: var(--bevel);
}
.step-btn:active { transform: scale(.93); background: var(--gold-soft); color: var(--gold); }

/* segmented 1-5 scale */
.seg { display: flex; gap: 7px; }
.seg-opt {
  flex: 1; padding: 11px 4px; border-radius: 12px; border: 1px solid var(--line-2);
  background: rgba(18,16,14,.45); color: var(--text-2); text-align: center;
  font-size: 13px; font-weight: 560; transition: all .14s;
  display: flex; flex-direction: column; gap: 2px; align-items: center;
}
.seg-opt .e { font-size: 17px; line-height: 1; }
.seg-opt.sel { background: var(--gold-soft); border-color: var(--gold-line); color: var(--gold); }
.seg.purple .seg-opt.sel { background: var(--purple-soft); border-color: rgba(162,148,203,.4); color: var(--purple); }

/* toggle chips / checkable rows */
.check-row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 13px 14px; border-radius: 14px; border: 1px solid var(--line-2);
  background: rgba(18,16,14,.4); color: var(--text); margin-bottom: 9px;
  font-size: 14.5px; text-align: left; transition: all .15s;
}
.check-row .ck {
  width: 24px; height: 24px; border-radius: 9px; border: 1.5px solid var(--line-2);
  display: grid; place-items: center; flex: 0 0 24px; color: transparent; font-size: 13px;
  transition: all .15s;
}
.check-row.on { border-color: var(--gold-line); background: var(--gold-soft); }
.check-row.on .ck { background: linear-gradient(160deg, #ddb97c, #a98545); border-color: transparent; color: #241d12; }
.check-row .ck-sub { display: block; font-size: 11.5px; color: var(--text-3); margin-top: 1px; }
.check-row.on .ck-sub { color: rgba(210,171,107,.75); }

/* ---------- rings & bars ---------- */
.ring-wrap { position: relative; display: grid; place-items: center; }
.ring-center { position: absolute; text-align: center; }
.lvlbar { height: 7px; border-radius: 99px; background: rgba(18,16,14,.6); border: 1px solid var(--line); overflow: hidden; }
.lvlbar > div { height: 100%; border-radius: 99px; background: linear-gradient(90deg, #a98545, #ddb97c); transition: width .5s cubic-bezier(.2,.8,.2,1); }
.lvlbar.green > div { background: linear-gradient(90deg, #7e9a6c, #a3bd8e); }
.lvlbar.purple > div { background: linear-gradient(90deg, #7a6ba8, #a294cb); }

.target-row { display: flex; align-items: center; gap: 11px; margin-bottom: 11px; }
.target-row .t-ic { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; background: var(--gold-soft); font-size: 15px; flex: 0 0 34px; }
.target-row .t-body { flex: 1; min-width: 0; }
.target-row .t-top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; }
.target-row .t-name { color: var(--text-2); }
.target-row .t-val { font-variant-numeric: tabular-nums; color: var(--text); font-weight: 600; }
.target-row .t-val .of { color: var(--text-3); font-weight: 450; }

/* ---------- heatmap chain ---------- */
.heat { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.heat-cell {
  aspect-ratio: 1; border-radius: 7px; background: rgba(242,232,210,.05);
  border: 1px solid rgba(242,232,210,.045); position: relative;
}
.heat-cell.l1 { background: rgba(210,171,107,.22); border-color: rgba(210,171,107,.12); }
.heat-cell.l2 { background: rgba(210,171,107,.45); border-color: rgba(210,171,107,.25); }
.heat-cell.l3 { background: linear-gradient(160deg, #dcb87b, #b18a49); border-color: rgba(210,171,107,.4); }
.heat-cell.today { outline: 1.5px solid var(--gold); outline-offset: 1.5px; }
.heat-cell.future { opacity: .28; }
.heat-labels { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; margin-bottom: 6px; }
.heat-labels span { font-size: 9.5px; text-align: center; color: var(--text-3); letter-spacing: .08em; }
/* compact chain: short rounded tiles so 12 weeks fit in ~half the mobile height */
.heat.heat-sm { gap: 4px; }
.heat.heat-sm .heat-cell { aspect-ratio: auto; height: 24px; border-radius: 6px; }
.heat-labels.sm { gap: 4px; }
.heat-labels.sm span { font-size: 9px; letter-spacing: .01em; }
.heat-dd { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 600; color: rgba(242,232,210,.34); }
/* 30-day chain block — 6 columns of dated tiles */
.chain30 { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; }
.chain30 .heat-cell { aspect-ratio: auto; height: 34px; border-radius: 8px; }
.chain30 .heat-dd { font-size: 11px; }

/* ---------- lists ---------- */
.list-row {
  display: flex; align-items: center; gap: 13px; padding: 13px 2px;
  border-bottom: 1px solid var(--line);
}
.list-row:last-child { border-bottom: 0; }
.list-row .l-main { flex: 1; min-width: 0; }
.list-row .l-title { font-size: 14.5px; font-weight: 560; }
.list-row .l-sub { font-size: 12px; color: var(--text-3); margin-top: 1px; }
.list-row .l-end { text-align: right; font-variant-numeric: tabular-nums; }
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; padding: 4px 10px; border-radius: 99px; border: 1px solid var(--line-2); color: var(--text-2); background: rgba(18,16,14,.4); font-weight: 550; }
.pill.gold { background: var(--gold-soft); border-color: var(--gold-line); color: var(--gold); }
.pill.green { background: var(--green-soft); border-color: rgba(163,189,142,.3); color: var(--green); }
.pill.purple { background: var(--purple-soft); border-color: rgba(162,148,203,.3); color: var(--purple); }
.pill.red { background: var(--red-soft); border-color: rgba(205,138,110,.3); color: var(--red); }

/* ---------- badges ---------- */
.badge-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 11px; }
@media (min-width: 1024px) { .badge-grid { grid-template-columns: repeat(4, 1fr); } }
.badge-tile {
  border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px 8px 11px;
  text-align: center; background: linear-gradient(160deg, var(--panel-2), var(--panel));
  box-shadow: var(--bevel);
}
.badge-tile .b-ic {
  width: 46px; height: 46px; margin: 0 auto 8px; border-radius: 99px;
  display: grid; place-items: center; font-size: 21px;
  background: rgba(18,16,14,.5); border: 1px solid var(--line-2);
  filter: grayscale(1) opacity(.4);
}
.badge-tile.earned .b-ic {
  background: radial-gradient(circle at 35% 30%, rgba(238,206,152,.85), transparent 70%), linear-gradient(160deg, #dcb87b, #a3803f);
  border-color: rgba(210,171,107,.5); filter: none;
  box-shadow: 0 4px 14px rgba(190,150,85,.28);
}
.badge-tile .b-name { font-size: 11.5px; font-weight: 600; line-height: 1.25; }
.badge-tile .b-sub { font-size: 10px; color: var(--text-3); margin-top: 3px; }
.badge-tile:not(.earned) .b-name { color: var(--text-3); }

/* ---------- sheets / modals ---------- */
.sheet-veil {
  position: fixed; inset: 0; z-index: 60; background: rgba(10, 9, 8, 0.6);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  opacity: 0; transition: opacity .22s; display: flex; align-items: flex-end; justify-content: center;
}
.sheet-veil.show { opacity: 1; }
.sheet {
  width: 100%; max-width: 480px; max-height: 92dvh; overflow-y: auto;
  background: linear-gradient(175deg, #262220, #1c1916 30%);
  border: 1px solid var(--line-2); border-bottom: 0;
  border-radius: 26px 26px 0 0;
  padding: 10px 20px calc(24px + env(safe-area-inset-bottom));
  box-shadow: 0 -18px 50px rgba(0,0,0,.5), var(--bevel);
  transform: translateY(40px); transition: transform .26s cubic-bezier(.2,.8,.25,1);
}
.sheet-veil.show .sheet { transform: translateY(0); }
.sheet-grab { width: 40px; height: 4.5px; border-radius: 99px; background: var(--line-2); margin: 4px auto 14px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sheet-head h3 { font-size: 18px; }
@media (min-width: 1024px) {
  .sheet-veil { align-items: center; }
  .sheet { border-radius: 24px; border-bottom: 1px solid var(--line-2); max-height: 86vh; padding-bottom: 24px; transform: translateY(14px) scale(.98); }
  .sheet-veil.show .sheet { transform: none; }
}

/* wizard */
.wz-dots { display: flex; gap: 6px; justify-content: center; margin-bottom: 16px; }
.wz-dots span { width: 26px; height: 4px; border-radius: 99px; background: rgba(242,232,210,.1); transition: background .2s; }
.wz-dots span.on { background: var(--gold); }
.wz-title { font-size: 21px; font-weight: 660; margin-bottom: 3px; }
.wz-sub { color: var(--text-2); font-size: 13.5px; margin-bottom: 18px; }
.wz-foot { display: flex; gap: 10px; margin-top: 20px; }
.wz-foot .btn { flex: 1; }
.wz-foot .btn.back { flex: 0 0 30%; }

/* ---------- toast ---------- */
.toast-wrap { position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + 18px + env(safe-area-inset-bottom)); z-index: 80; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
@media (min-width: 1024px) { .toast-wrap { bottom: 30px; } }
.toast {
  background: linear-gradient(160deg, #2c2620, #211d18);
  border: 1px solid var(--gold-line); color: var(--text);
  border-radius: 14px; padding: 11px 18px; font-size: 14px; font-weight: 560;
  box-shadow: var(--shadow); display: flex; align-items: center; gap: 9px;
  animation: toast-in .3s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.96); } }
.toast .xp { color: var(--gold); font-weight: 700; font-variant-numeric: tabular-nums; }

/* xp float */
@keyframes rise { 0% { opacity: 0; transform: translateY(6px);} 15% {opacity:1;} 100% { opacity: 0; transform: translateY(-34px); } }

/* ---------- photos ---------- */
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.photo-cell { aspect-ratio: 3/4; border-radius: 13px; overflow: hidden; border: 1px solid var(--line-2); position: relative; background: rgba(18,16,14,.5); }
.photo-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-cell .p-tag { position: absolute; bottom: 6px; left: 6px; font-size: 9.5px; padding: 2.5px 7px; border-radius: 99px; background: rgba(15,13,11,.72); color: var(--text-2); backdrop-filter: blur(4px); }
.photo-add { display: grid; place-items: center; color: var(--text-3); font-size: 12px; gap: 4px; border-style: dashed; cursor: pointer; }
.photo-add .plus { font-size: 22px; color: var(--gold); }
.compare-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.compare-wrap .photo-cell { aspect-ratio: 3/4; }

/* ---------- charts ---------- */
.chart-card svg { width: 100%; height: auto; }
.chart-tabs { display: flex; gap: 7px; margin-bottom: 12px; flex-wrap: wrap; }
.chart-tab { padding: 7px 13px; border-radius: 99px; font-size: 12.5px; border: 1px solid var(--line-2); background: rgba(18,16,14,.4); color: var(--text-2); font-weight: 560; }
.chart-tab.sel { background: var(--gold-soft); border-color: var(--gold-line); color: var(--gold); }

/* ---------- misc ---------- */
.empty { text-align: center; padding: 26px 18px; color: var(--text-3); font-size: 13.5px; }
.empty .e-ic { font-size: 30px; margin-bottom: 8px; opacity: .8; }
.kv { display: flex; justify-content: space-between; padding: 9px 0; font-size: 14px; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--text-2); }
.kv .v { font-variant-numeric: tabular-nums; font-weight: 600; }
.delta { font-size: 12px; font-weight: 650; font-variant-numeric: tabular-nums; }
.delta.down { color: var(--green); }
.delta.up { color: var(--red); }
.delta.flat { color: var(--text-3); }

.streak-hero { display: flex; align-items: center; gap: 16px; }
.flame {
  width: 58px; height: 58px; border-radius: 18px; display: grid; place-items: center; font-size: 27px;
  background: radial-gradient(circle at 40% 30%, rgba(230,190,120,.28), transparent 70%), linear-gradient(160deg, #2b251d, #221e18);
  border: 1px solid var(--gold-line); box-shadow: 0 6px 20px rgba(190,150,85,.18), var(--bevel);
}
.flame.dim { filter: grayscale(.8) opacity(.55); border-color: var(--line-2); box-shadow: var(--bevel); }

.page-title { font-size: 26px; font-weight: 680; letter-spacing: -0.02em; margin: 10px 0 4px; }
.page-sub { color: var(--text-2); font-size: 14px; margin-bottom: 18px; }
.section-gap { height: 10px; }

.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 2px; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.settings-row:last-child { border-bottom: 0; }
.settings-row .s-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }

/* onboarding / pin */
.gate {
  min-height: 100dvh; display: flex; flex-direction: column; justify-content: center;
  max-width: 400px; margin: 0 auto; padding: 30px 24px;
}
.gate .wordmark { font-size: 34px; text-align: center; margin-bottom: 6px; }
.gate .g-sub { text-align: center; color: var(--text-2); font-size: 14px; margin-bottom: 30px; }
.pin-row { display: flex; gap: 10px; justify-content: center; margin: 8px 0 18px; }
.pin-dot { width: 16px; height: 16px; border-radius: 99px; border: 1.5px solid var(--line-2); background: rgba(18,16,14,.5); transition: all .15s; }
.pin-dot.fill { background: linear-gradient(160deg, #ddb97c, #a98545); border-color: transparent; box-shadow: 0 0 12px rgba(210,171,107,.35); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 300px; margin: 0 auto; }
.pin-key {
  height: 64px; border-radius: 18px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font-size: 22px; font-weight: 550;
  box-shadow: var(--bevel);
}
.pin-key:active { background: var(--gold-soft); transform: scale(.95); }
.pin-key.ghosty { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); font-size: 15px; }

.fade-in { animation: fadein .35s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(7px); } }

.reward-card { display: flex; align-items: center; gap: 13px; }
.reward-ic { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; font-size: 20px; background: var(--gold-soft); border: 1px solid var(--gold-line); flex: 0 0 44px; }
.reward-ic.locked { background: rgba(18,16,14,.5); border-color: var(--line-2); filter: grayscale(1) opacity(.6); }

.score-ring-row { display: flex; gap: 14px; align-items: center; }

/* week summary table (desktop) */
.wk-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.wk-table th { text-align: left; color: var(--text-3); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; padding: 8px 10px; border-bottom: 1px solid var(--line-2); }
.wk-table td { padding: 10px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }

/* scrollbar (desktop) */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(242,232,210,.12); border-radius: 99px; border: 2.5px solid var(--bg0); }
::-webkit-scrollbar-track { background: transparent; }

/* habit ready-to-evolve card */
.card.evolve-glow { border-color: var(--gold-line); box-shadow: 0 0 0 1px var(--gold-line), 0 0 26px -6px rgba(198,164,92,.4); animation: evolvePulse 3.4s ease-in-out infinite; }
@keyframes evolvePulse {
  0%, 100% { box-shadow: 0 0 0 1px var(--gold-line), 0 0 22px -8px rgba(198,164,92,.34); }
  50% { box-shadow: 0 0 0 1px var(--gold-line), 0 0 30px -4px rgba(198,164,92,.5); }
}

/* ---------- Today hero: dusk sky + streak ring ---------- */
.card.hero-new { position: relative; overflow: hidden; padding: 0; border: 1px solid rgba(180,150,190,.18); background: transparent; }
.hero-new .hero-sky { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hero-new .hero-body { position: relative; padding: 20px 18px 22px; text-align: center; }
.hero-new .hero-date { font-size: 11.5px; letter-spacing: .14em; color: #e8d9c4; }
.hero-new .hero-greet { font-family: var(--serif); font-size: 28px; font-weight: 700; line-height: 1.12; margin-top: 5px;
  background-clip: text; -webkit-background-clip: text; color: transparent; -webkit-text-fill-color: transparent; }
.hero-new .hero-greet .nm { -webkit-text-fill-color: #fbf2e2; color: #fbf2e2; }
.hero-new .hero-lvl { display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; font-size: 12px; font-weight: 500;
  padding: 5px 13px; border-radius: 99px; border: 1px solid rgba(233,196,132,.55); background: rgba(30,20,14,.4); color: #f0cf8c; }
.hero-new .hero-ringrow { display: flex; align-items: center; justify-content: center; gap: 4px; margin-top: 14px; }
.hero-new .hero-xp { flex: 1; min-width: 0; }
.hero-new .hero-xp.l { text-align: right; } .hero-new .hero-xp.r { text-align: left; }
.hero-new .hero-xp b { display: block; font-size: 22px; font-weight: 700; color: #fbf1df; }
.hero-new .hero-xp span { font-size: 11px; color: #d9c4b2; }
.hero-new .hero-ringwrap { position: relative; flex: 0 0 auto; width: 196px; height: 196px; }
.hero-new .hero-ring { position: relative; display: block; }
.hero-new .hero-halo { position: absolute; inset: 14px; border-radius: 50%; animation: heroGlow 3.4s ease-in-out infinite; }
/* flame + streak number are centered as a pair on the exact ring center; the
   "day streak" label is pinned just below so it doesn't drag the pair off-center */
/* streak number is drawn as SVG text with a central baseline, so the glyph itself
   (not just its box) sits on the ring's exact center point */
.hero-new .hero-ring text { font-family: var(--font); }
.hero-new .hero-streak-t { font-size: 50px; font-weight: 800; fill: #fbf1df; }
.hero-new .hero-streaklbl-t { font-size: 11px; fill: #d9c4b2; letter-spacing: .5px; }
.hero-new .hero-arc-glow { animation: heroFlicker 2.4s ease-in-out infinite; }
.hero-new .hero-score { margin-top: 16px; display: inline-block; font-size: 12px; color: #e6d8c2; padding: 5px 13px; border-radius: 99px; border: 1px solid rgba(242,232,210,.18); background: rgba(20,16,12,.35); }
@keyframes heroGlow { 0%,100% { opacity: .5; } 50% { opacity: .9; } }
@keyframes heroFlicker { 0%,100% { opacity: .7; } 45% { opacity: 1; } 70% { opacity: .82; } }
@media (min-width: 420px) { .hero-new .hero-ringwrap { width: 210px; height: 210px; } }

/* ---------- Habits page: category filter + tidy cards ---------- */
.hfilter { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px 18px; padding: 0 16px 2px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.hfilter::-webkit-scrollbar { display: none; }
.hchip {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  padding: 8px 13px; border-radius: 99px; font-size: 13px; font-weight: 560; cursor: pointer;
  border: 1px solid var(--line-2); background: rgba(18,16,14,.4); color: var(--text-2);
  transition: background .15s, border-color .15s, color .15s;
}
.hchip-n { opacity: .6; font-weight: 600; }
.hbadge { font-size: 11px; font-weight: 650; padding: 2px 8px; border-radius: 99px; border: 1px solid var(--line-2); background: rgba(18,16,14,.4); color: var(--text-3); }
@media (min-width: 1024px) { .hfilter { margin: 0 0 18px; padding: 0 0 2px; } }

/* daily motivational quote — matches the dark card aesthetic, understated */
.quote-pill { display: flex; gap: 12px; align-items: flex-start; margin: 14px 0; padding: 15px 17px;
  background: linear-gradient(160deg, var(--panel-2), var(--panel) 55%); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-sm), var(--bevel); }
.quote-pill .q-mark { font-family: var(--serif); font-size: 28px; line-height: .68; color: var(--gold-2); opacity: .85; flex: 0 0 auto; }
.quote-pill .q-mark-close { align-self: flex-start; }
.quote-pill .q-text { font-family: var(--serif); font-style: italic; font-size: 15px; line-height: 1.46; color: var(--text-2); }
.quote-pill .q-author { font-size: 11.5px; color: var(--text-3); margin-top: 6px; font-weight: 500; letter-spacing: .02em; }

/* ---------- check-in celebration ---------- */
.cel-veil { position: fixed; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: rgba(10, 8, 6, 0.72); backdrop-filter: blur(9px); -webkit-backdrop-filter: blur(9px); opacity: 0; transition: opacity .3s; }
.cel-veil.show { opacity: 1; }
.cel-card { width: 100%; max-width: 360px; border-radius: 26px; padding: 26px 22px 22px; text-align: center; position: relative; overflow: hidden;
  background: linear-gradient(160deg, #241f19, #17130f); border: 1px solid var(--gold-line);
  box-shadow: 0 26px 64px -14px rgba(0,0,0,.82), 0 0 46px -12px rgba(210,171,107,.28);
  transform: translateY(14px) scale(.95); transition: transform .38s cubic-bezier(.2,.9,.3,1.2); }
.cel-veil.show .cel-card { transform: none; }
.cel-ic { font-size: 46px; line-height: 1; animation: celPop .55s cubic-bezier(.2,.9,.3,1.5) .08s both; }
.cel-title { font-size: 14.5px; color: var(--text-2); margin-top: 8px; letter-spacing: .02em; }
.cel-xp { font-family: var(--serif); font-size: 42px; font-weight: 800; color: var(--gold); margin-top: 8px; line-height: 1; text-shadow: 0 0 24px rgba(210,171,107,.4); }
.cel-lvlrow { margin-top: 20px; text-align: left; }
.cel-lvl { font-size: 12px; color: var(--text-2); font-weight: 600; }
.cel-bar { height: 13px; border-radius: 99px; background: rgba(242,232,210,.08); overflow: hidden; margin-top: 8px; border: 1px solid rgba(242,232,210,.05); }
.cel-barfill { height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, #b98f4e, #e6bd77 60%, #f6d590); box-shadow: 0 0 14px -2px rgba(233,190,120,.75); transition: width 1s cubic-bezier(.2,.8,.2,1); }
.cel-tonext { font-size: 11px; color: var(--text-3); margin-top: 6px; text-align: right; }
.cel-streakrow { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 22px; }
.cel-flame { font-size: 32px; line-height: 1; }
.cel-flame.pop { animation: celFlame .6s cubic-bezier(.2,.9,.3,1.6); }
.cel-streak { font-size: 30px; font-weight: 800; color: #ffd79a; line-height: 1; }
.cel-streaklbl { font-size: 11px; color: var(--text-3); align-self: flex-end; padding-bottom: 3px; }
.cel-levelup { position: absolute; top: 14px; left: 0; right: 0; text-align: center; font-size: 12px; font-weight: 700; letter-spacing: .06em; color: var(--gold); animation: celUp .55s ease both; }
.cel-card.leveled { box-shadow: 0 26px 64px -14px rgba(0,0,0,.82), 0 0 60px -8px rgba(210,171,107,.5); }
@keyframes celPop { from { transform: scale(.35); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes celFlame { 0% { transform: scale(1); } 42% { transform: scale(1.42) rotate(-7deg); } 100% { transform: scale(1); } }
@keyframes celUp { from { transform: translateY(7px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* floating +XP when ticking a habit */
.xp-float { position: fixed; transform: translate(-50%, 0); z-index: 95; pointer-events: none;
  font-weight: 800; font-size: 15px; color: var(--gold); text-shadow: 0 1px 6px rgba(0,0,0,.6);
  opacity: 1; transition: transform .9s cubic-bezier(.2,.8,.2,1), opacity .9s ease; }
.xp-float.go { transform: translate(-50%, -38px); opacity: 0; }

/* Today's achievements card */
.ach-row { display: flex; gap: 6px; }
.ach-item { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; text-align: center; }
.ach-badge { position: relative; width: 46px; height: 46px; display: grid; place-items: center; }
.ach-badge .ring-wrap { position: absolute; inset: 0; }
.ach-ic { position: absolute; inset: 0; display: grid; place-items: center; font-size: 19px; opacity: .55; filter: grayscale(.4); transition: opacity .3s, filter .3s; }
.ach-badge.earned .ach-ic { opacity: 1; filter: none; }
.ach-name { margin-top: 7px; font-size: 11px; font-weight: 600; color: var(--text-2); line-height: 1.2;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ach-sub { font-size: 10px; color: var(--text-3); margin-top: 2px; font-variant-numeric: tabular-nums; }
.ach-sub.new { color: var(--gold); font-weight: 700; }
