:root {
  --bg: #0a0b0d;
  --surface: #121418;
  --surface-2: #181b21;
  --surface-3: #22262e;
  --line: rgba(255, 255, 255, .07);
  --text: #f3f5f7;
  --muted: #8d94a0;
  --dim: #5d6470;

  --lime: #c6f432;
  --lime-ink: #0f1400;
  --lime-soft: rgba(198, 244, 50, .12);
  --blue: #3b82f6;
  --blue-2: #60a5fa;
  --day-empty: #262a32;
  --orange: #ff8a3d;
  --red: #ff4d6d;
  --purple: #a78bfa;
  --teal: #2dd4bf;
  --yellow: #facc15;
  --cyan: #22d3ee;

  --r-lg: 22px;
  --r-md: 16px;
  --r-sm: 12px;
  --sidebar: 248px;
  --tabbar: 64px;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100dvh;
  overscroll-behavior-y: none;
}
body.noscroll { overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100dvh; }

.sidebar {
  position: sticky; top: 0; height: 100dvh;
  padding: 26px 18px 22px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, #0e1014, #0a0b0d);
  display: flex; flex-direction: column; gap: 26px;
}
.logo { display: flex; align-items: center; gap: 11px; font-weight: 800; font-size: 19px; letter-spacing: .08em; padding: 0 8px; }
.logo-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--lime); color: var(--lime-ink);
  display: grid; place-items: center;
  box-shadow: 0 0 24px rgba(198, 244, 50, .25);
}
.logo-mark .ic { width: 20px; height: 20px; stroke-width: 2.6; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px; border-radius: 14px;
  color: var(--muted); font-weight: 600; position: relative;
  transition: color .15s, background .15s;
}
.nav a:hover { color: var(--text); background: var(--surface); }
.nav a.active { color: var(--lime); background: linear-gradient(90deg, var(--lime-soft), rgba(198, 244, 50, .03)); }
.nav a.active::before { content: ""; position: absolute; left: -18px; top: 10px; bottom: 10px; width: 3px; border-radius: 3px; background: var(--lime); }

.side-card {
  margin-top: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 16px;
}
.side-card .flame { color: var(--orange); }
.side-card b { font-size: 26px; letter-spacing: -.03em; display: block; margin: 6px 0 2px; }
.side-card p { color: var(--muted); font-size: 13px; }

main { padding: 34px 40px 60px; width: 100%; max-width: 1320px; }
.mobile-top { display: none; }
.tabbar { display: none; }

.avatar {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--surface-3); border: 1px solid var(--line);
  display: grid; place-items: center; font-weight: 700; font-size: 14px; flex: none;
}

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 26px; flex-wrap: wrap; }
.eyebrow { color: var(--muted); font-size: 16px; margin-bottom: 4px; }
.eyebrow b { color: var(--text); font-weight: 600; }
.page-head h1 { font-size: clamp(30px, 4.4vw, 50px); font-weight: 800; letter-spacing: -.035em; line-height: 1.05; }
.head-actions { display: flex; gap: 10px; align-items: center; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 14px; padding: 12px 18px;
  font-weight: 700; cursor: pointer;
  background: var(--surface-3); color: var(--text);
  transition: transform .1s, filter .15s, background .15s;
  min-height: 44px;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--lime); color: var(--lime-ink); }
.btn.danger { background: rgba(255, 77, 109, .14); color: var(--red); }
.btn.block { width: 100%; }
.btn .ic { width: 18px; height: 18px; stroke-width: 2.4; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 0;
  background: var(--surface-2); color: var(--muted);
  display: grid; place-items: center; cursor: pointer;
}
.icon-btn:hover { color: var(--text); }
.link { color: var(--lime); font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; gap: 4px; }
.link .ic { width: 16px; height: 16px; }

/* ---------- Cards & grids ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 22px;
  min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-head h3 { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.card-head h3 .ic { color: var(--lime); }
.card-tools { display: flex; gap: 8px; flex-wrap: wrap; }

.grid { display: grid; gap: 18px; margin-bottom: 18px; }
.hero-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.row-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.row-1-1 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 18px; min-width: 0; }

.chip-icon {
  width: 42px; height: 42px; border-radius: 13px;
  display: grid; place-items: center; flex: none;
}
.chip-icon .ic { width: 22px; height: 22px; stroke-width: 2.3; }
.chip-icon.lime { background: var(--lime-soft); color: var(--lime); }
.chip-icon.orange { background: rgba(255, 138, 61, .13); color: var(--orange); }
.chip-icon.blue { background: rgba(59, 130, 246, .15); color: var(--blue-2); }
.chip-icon.purple { background: rgba(167, 139, 250, .15); color: var(--purple); }
.chip-icon.red { background: rgba(255, 77, 109, .14); color: var(--red); }

/* ---------- Hero stats ---------- */
.hero { display: flex; flex-direction: column; gap: 14px; position: relative; overflow: hidden; }
.hero::after {
  content: ""; position: absolute; inset: auto -40% -60% auto; width: 80%; aspect-ratio: 1;
  background: radial-gradient(circle, var(--glow, rgba(198, 244, 50, .08)), transparent 65%);
  pointer-events: none;
}
.hero-streak { --glow: rgba(255, 138, 61, .10); }
.hero-goal { --glow: rgba(59, 130, 246, .10); }
.hero-top { display: flex; align-items: center; gap: 12px; }
.label { text-transform: uppercase; letter-spacing: .09em; font-size: 12px; font-weight: 700; color: var(--muted); }
.hero-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.big {
  font-size: clamp(60px, 7vw, 96px); font-weight: 800; line-height: .9;
  letter-spacing: -.05em; font-variant-numeric: tabular-nums;
}
.big .unit { font-size: 20px; font-weight: 700; letter-spacing: 0; color: var(--muted); margin-left: 8px; }
.hero-days .big { color: var(--lime); }
.hero-sub { color: var(--muted); font-size: 14px; }
.up { color: var(--lime); font-weight: 700; }
.down { color: var(--orange); font-weight: 700; }
.spark { flex: none; margin-bottom: 4px; }

.goal-body { display: flex; align-items: center; gap: 18px; }
.goal-num { font-size: clamp(36px, 4vw, 52px); font-weight: 800; letter-spacing: -.04em; line-height: 1; font-variant-numeric: tabular-nums; }
.goal-num span { font-size: .45em; color: var(--muted); font-weight: 700; letter-spacing: 0; margin-left: 4px; }
.goal-empty { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.goal-empty p { color: var(--muted); }

.ring { position: relative; width: var(--s); height: var(--s); flex: none; }
.ring svg { display: block; }
.ring-arc { transition: stroke-dashoffset .8s cubic-bezier(.2, .8, .2, 1); }
.ring-inner { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.ring-inner b { font-size: 26px; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.ring-inner small { color: var(--muted); font-size: 12px; margin-top: 3px; }

/* ---------- Segmented control ---------- */
.seg { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button {
  border: 0; background: none; padding: 7px 12px; border-radius: 9px;
  color: var(--muted); font-weight: 700; font-size: 13px; cursor: pointer;
}
.seg button.on { background: var(--surface-3); color: var(--lime); box-shadow: inset 0 0 0 1px rgba(198, 244, 50, .35); }

/* ---------- Charts ---------- */
.chart { position: relative; height: 250px; width: 100%; touch-action: pan-y; }
.chart.short { height: 220px; }
.chart svg { display: block; overflow: visible; }
.chart .gl { stroke: rgba(255, 255, 255, .06); }
.tick { fill: var(--dim); font-size: 11px; font-weight: 600; }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 2;
  background: var(--surface-3); border: 1px solid rgba(255, 255, 255, .1);
  padding: 6px 10px; border-radius: 10px; font-size: 12px;
  transform: translate(-50%, calc(-100% - 12px));
  white-space: nowrap; opacity: 0; transition: opacity .12s;
  display: flex; flex-direction: column; align-items: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
}
.chart-tip span { color: var(--muted); font-size: 11px; }
.chart-tip b { font-size: 14px; }
.chart-tip.show { opacity: 1; }

/* ---------- This week ---------- */
.week-big { display: flex; align-items: baseline; gap: 8px; margin-bottom: 12px; }
.week-big b { font-size: 52px; font-weight: 800; letter-spacing: -.04em; line-height: 1; }
.week-big span { color: var(--muted); font-weight: 600; }
.bar { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.bar > div { height: 100%; border-radius: 99px; background: var(--lime); transition: width .6s; }
.bar.blue > div { background: var(--blue); }
.week-dots { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 18px 0; }
.wd { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.wd .dot {
  width: 100%; max-width: 38px; aspect-ratio: 1; border-radius: 50%;
  background: var(--surface-3); display: grid; place-items: center; color: var(--lime-ink);
}
.wd .dot .ic { width: 16px; height: 16px; stroke-width: 3; }
.wd.on .dot { background: var(--lime); box-shadow: 0 0 16px rgba(198, 244, 50, .3); }
.wd.today .dot { outline: 2px solid var(--text); outline-offset: 2px; }
.wd.future .dot { opacity: .45; }
.wd small { color: var(--muted); font-size: 12px; font-weight: 700; }
.mini-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mini-stats > div { background: var(--surface-2); border-radius: var(--r-sm); padding: 12px; display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: center; }
.mini-stats .ic { grid-row: span 2; color: var(--muted); }
.mini-stats b { font-size: 18px; }
.mini-stats small { color: var(--muted); font-size: 12px; }
.week-msg { margin-top: 14px; color: var(--muted); font-size: 14px; display: flex; gap: 8px; align-items: center; }
.week-msg.good { color: var(--lime); }

/* ---------- Workout rows ---------- */
.wk-list { display: flex; flex-direction: column; }
.wk-row {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 8px; margin: 0 -8px; border-radius: 14px; cursor: pointer;
  border-bottom: 1px solid var(--line);
}
.wk-row:last-child { border-bottom: 0; }
.wk-row:hover { background: var(--surface-2); }
.thumb {
  width: 52px; height: 52px; border-radius: 12px; overflow: hidden; flex: none;
  background: var(--surface-3); display: grid; place-items: center; color: var(--dim);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.wk-main { flex: 1; min-width: 0; }
.wk-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wk-sub { color: var(--muted); font-size: 13px; }
.wk-stat { text-align: right; font-weight: 700; white-space: nowrap; }
.wk-stat small { display: block; color: var(--muted); font-weight: 500; font-size: 12px; }
.verified { color: var(--lime); }
.cat-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; vertical-align: 1px; }

.empty { text-align: center; padding: 30px 10px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty .chip-icon { width: 56px; height: 56px; border-radius: 18px; }

/* ---------- Milestone & banner ---------- */
.milestone .ms-top { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.milestone h4 { margin: 0; font-size: 17px; }
.milestone p { color: var(--muted); font-size: 13px; }
.ms-meta { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-top: 8px; }

.banner {
  position: relative; overflow: hidden;
  border-radius: var(--r-lg); padding: 24px;
  background:
    radial-gradient(120% 140% at 100% 0%, rgba(198, 244, 50, .22), transparent 55%),
    linear-gradient(135deg, #1a1f12, #101208 70%);
  border: 1px solid rgba(198, 244, 50, .18);
  min-height: 170px; display: flex; flex-direction: column; justify-content: flex-end; gap: 14px;
}
.banner h3 { font-size: 26px; font-weight: 800; letter-spacing: -.03em; line-height: 1.05; max-width: 70%; }
.banner .bg-ic { position: absolute; right: -24px; top: -10px; width: 170px; height: 170px; color: rgba(198, 244, 50, .14); stroke-width: 1.6; transform: rotate(-25deg); }
.banner-sub { color: var(--muted); font-size: 14px; margin-top: -6px; }

/* ---------- Calendar ---------- */
.year-switch { display: inline-flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 4px; }
.year-switch b { min-width: 64px; text-align: center; font-size: 17px; }
.year-switch .icon-btn { width: 36px; height: 36px; background: transparent; }

.cal-summary { display: flex; align-items: center; gap: 30px; flex-wrap: wrap; margin-bottom: 18px; }
.cal-summary .s b { font-size: 34px; font-weight: 800; letter-spacing: -.03em; display: block; line-height: 1.05; }
.cal-summary .s small { color: var(--muted); font-size: 13px; }
.cal-summary .s.blue b { color: var(--blue-2); }
.legend { margin-left: auto; display: flex; gap: 16px; align-items: center; color: var(--muted); font-size: 13px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; margin-right: 6px; }

.months { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.month { padding: 18px; scroll-margin-top: calc(env(safe-area-inset-top) + 12px); }
.month.current { border-color: rgba(59, 130, 246, .45); }
.month h3 { margin: 0 0 12px; font-size: 16px; display: flex; justify-content: space-between; align-items: baseline; }
.month h3 small { color: var(--muted); font-weight: 600; font-size: 13px; }
.month h3 small b { color: var(--blue-2); }
.dow, .days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.dow { font-size: 11px; color: var(--dim); text-align: center; margin-bottom: 6px; font-weight: 700; }
.day {
  aspect-ratio: 1; border-radius: 7px; border: 0; padding: 0;
  background: var(--day-empty); color: var(--muted);
  font-size: 11px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  transition: background .35s, transform .1s;
  cursor: pointer;
}
.day.blank { background: transparent; cursor: default; }
.day.future { opacity: .35; cursor: default; }
.day.done { background: var(--blue); color: #fff; font-weight: 800; box-shadow: 0 0 12px rgba(59, 130, 246, .35); }
.day:not(.blank):not(.future):hover { transform: scale(1.12); }
.day.done:hover { background: var(--blue-2); }
.day.today { outline: 2px solid var(--text); outline-offset: 1px; }

/* ---------- Progress ---------- */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; margin-bottom: 18px; }
.tile { display: flex; flex-direction: column; gap: 14px; }
.tile b { font-size: 34px; font-weight: 800; letter-spacing: -.03em; line-height: 1; display: block; }
.tile small { color: var(--muted); font-size: 13px; }

.donut-wrap { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; justify-content: center; }
.legend-list { flex: 1; min-width: 160px; display: flex; flex-direction: column; gap: 10px; }
.legend-list div { display: flex; align-items: center; justify-content: space-between; font-size: 14px; }
.legend-list span { display: flex; align-items: center; }
.legend-list b { font-variant-numeric: tabular-nums; }

.records { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.record { background: var(--surface-2); border-radius: var(--r-md); padding: 16px; display: flex; flex-direction: column; gap: 4px; }
.record .ic { color: var(--lime); margin-bottom: 6px; }
.record b { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.record small { color: var(--muted); font-size: 12px; }

.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.badge {
  background: var(--surface-2); border-radius: var(--r-md); padding: 16px 14px;
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px;
  border: 1px solid transparent;
}
.badge .medal {
  width: 52px; height: 52px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface-3); color: var(--dim); margin-bottom: 4px;
}
.badge .medal .ic { width: 24px; height: 24px; }
.badge.won { border-color: rgba(198, 244, 50, .25); }
.badge.won .medal { background: var(--lime); color: var(--lime-ink); box-shadow: 0 0 22px rgba(198, 244, 50, .3); }
.badge b { font-size: 14px; }
.badge small { color: var(--muted); font-size: 12px; }
.badge .bar { width: 100%; height: 5px; margin-top: 6px; }

/* ---------- Settings ---------- */
.form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--muted); font-weight: 600; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
input[type="text"], input[type="number"], input[type="date"], select {
  width: 100%;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; font-size: 16px; /* 16px stops iPhone zooming in */
  outline: none; min-height: 46px;
  -webkit-appearance: none; appearance: none;
}
input:focus, select:focus { border-color: rgba(198, 244, 50, .5); }
input:disabled { opacity: .7; }
select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
.hint { color: var(--muted); font-size: 13px; }
.steps { margin: 0; padding-left: 20px; color: var(--muted); display: flex; flex-direction: column; gap: 8px; }
.steps b { color: var(--text); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Sheet (modal / bottom sheet) ---------- */
.sheet-wrap {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, .6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.sheet-wrap.open { opacity: 1; pointer-events: auto; }
.sheet {
  background: var(--surface); border: 1px solid var(--line); border-radius: 24px;
  width: min(520px, calc(100% - 32px)); max-height: min(92dvh, 900px); overflow-y: auto;
  padding: 22px; transform: translateY(16px) scale(.98); transition: transform .25s cubic-bezier(.2, .8, .2, 1);
  -webkit-overflow-scrolling: touch;
}
.sheet-wrap.open .sheet { transform: none; }
.sheet-grip { display: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; }
.sheet-head h2 { font-size: 22px; letter-spacing: -.02em; }

.drop {
  border: 2px dashed rgba(255, 255, 255, .12); border-radius: 20px;
  min-height: 220px; padding: 24px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  text-align: center; cursor: pointer; transition: border-color .2s, background .2s;
}
.drop:hover, .drop.drag { border-color: var(--lime); background: var(--lime-soft); }
.drop .chip-icon { width: 60px; height: 60px; border-radius: 18px; }
.drop .chip-icon .ic { width: 28px; height: 28px; }
.drop strong { font-size: 17px; }
.howto { margin-top: 14px; background: var(--surface-2); border-radius: var(--r-md); padding: 14px 16px; }
.howto summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; justify-content: space-between; align-items: center; }
.howto summary::-webkit-details-marker { display: none; }
.howto[open] summary { margin-bottom: 10px; }

.shot { position: relative; border-radius: 16px; overflow: hidden; background: #000; }
.shot img { width: 100%; max-height: 46dvh; object-fit: contain; display: block; }
.shot.small img { max-height: 200px; object-fit: cover; object-position: top; }
.scan { position: absolute; inset: 0; background: linear-gradient(180deg, transparent, rgba(198, 244, 50, .35), transparent); height: 30%; animation: scan 1.4s ease-in-out infinite; }
@keyframes scan { 0% { transform: translateY(-100%); } 100% { transform: translateY(340%); } }

.status { display: flex; align-items: center; gap: 10px; margin: 16px 0; font-weight: 600; }
.status.ok { color: var(--lime); }
.status.bad { color: var(--red); align-items: flex-start; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid var(--surface-3); border-top-color: var(--lime); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.stat-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.stat-chip { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; display: flex; align-items: center; gap: 8px; font-weight: 700; }
.stat-chip .ic { width: 18px; height: 18px; color: var(--muted); }
.stat-chip small { color: var(--muted); font-weight: 500; }
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--lime); background: var(--lime-soft); padding: 5px 10px; border-radius: 99px; }
.tag .ic { width: 14px; height: 14px; }

/* ---------- Toasts ---------- */
#toasts { position: fixed; left: 50%; top: calc(16px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: calc(100% - 32px); }
.toast {
  background: var(--surface-3); border: 1px solid rgba(255, 255, 255, .1);
  padding: 12px 16px; border-radius: 14px; font-weight: 600;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .5);
  animation: toastIn .3s cubic-bezier(.2, .8, .2, 1);
}
.toast.good { border-color: rgba(198, 244, 50, .4); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } }

/* ---------- Tablet ---------- */
@media (max-width: 1180px) {
  .hero-grid { grid-template-columns: 1fr 1fr; }
  .hero-days { grid-column: 1 / -1; }
  .row-2-1 { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: 1fr 1fr; }
}

/* ---------- Phone ---------- */
@media (max-width: 860px) {
  /* No visible scrollbar at phone size (iPhones don't show one); scrolling still works */
  html, .sheet { scrollbar-width: none; }
  html::-webkit-scrollbar, .sheet::-webkit-scrollbar { display: none; }
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  main { padding: calc(env(safe-area-inset-top) + 12px) 16px calc(var(--tabbar) + env(safe-area-inset-bottom) + 28px); }
  .mobile-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
  .mobile-top .avatar { width: 38px; height: 38px; }
  .hide-sm { display: none !important; }
  .page-head { margin-bottom: 18px; }
  .eyebrow { font-size: 15px; }
  .grid { gap: 12px; margin-bottom: 12px; }
  .card { padding: 18px; border-radius: 20px; }
  .hero-grid { grid-template-columns: 1fr 1fr; }
  .hero { gap: 10px; }
  .hero-days { grid-column: 1 / -1; }
  .hero-streak .big, .hero-goal .goal-num { font-size: 52px; }
  .hero-streak .big .unit { display: block; margin: 6px 0 0; font-size: 15px; }
  .hero-streak .hero-row { align-items: flex-start; }
  .goal-body { flex-direction: column; align-items: flex-start; gap: 10px; }
  .hero-goal .ring { width: 84px; height: 84px; }
  .hero-goal .ring-inner b { font-size: 19px; }
  .hero-goal .ring-inner small { display: none; }
  .hero-goal .goal-num { font-size: 34px; }
  .chip-icon { width: 36px; height: 36px; border-radius: 11px; }
  .chip-icon .ic { width: 19px; height: 19px; }
  .label { font-size: 11px; }
  .chart { height: 210px; }
  .card-head { margin-bottom: 12px; }
  .card-tools { width: 100%; justify-content: space-between; }
  .tiles { gap: 12px; margin-bottom: 12px; }
  .tile b { font-size: 28px; }
  .records { grid-template-columns: 1fr 1fr; }
  .badges { grid-template-columns: repeat(2, 1fr); }
  .cal-summary { gap: 18px; }
  .cal-summary .s b { font-size: 28px; }
  .legend { margin-left: 0; }
  .months { grid-template-columns: 1fr; gap: 12px; }
  .day { font-size: 12px; border-radius: 8px; }
  .row-1-1 { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr 1fr; }

  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    height: calc(var(--tabbar) + env(safe-area-inset-bottom));
    padding: 0 6px env(safe-area-inset-bottom);
    background: rgba(14, 16, 20, .86);
    backdrop-filter: saturate(160%) blur(18px); -webkit-backdrop-filter: saturate(160%) blur(18px);
    border-top: 1px solid var(--line);
  }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--dim); font-size: 10.5px; font-weight: 600; padding: 6px 0; }
  .tabbar a .ic { width: 23px; height: 23px; }
  .tabbar a.active { color: var(--lime); }
  .tab-plus { justify-self: center; width: 54px; height: 54px; border-radius: 50%; border: 0; background: var(--lime); color: var(--lime-ink); display: grid; place-items: center; transform: translateY(-14px); box-shadow: 0 8px 26px rgba(198, 244, 50, .35), 0 0 0 5px var(--bg); cursor: pointer; }
  .tab-plus .ic { width: 26px; height: 26px; stroke-width: 2.8; }

  .sheet-wrap { align-items: flex-end; }
  .sheet {
    width: 100%; border-radius: 24px 24px 0 0; border-bottom: 0;
    max-height: calc(100dvh - env(safe-area-inset-top) - 24px);
    padding: 10px 18px calc(22px + env(safe-area-inset-bottom));
    transform: translateY(100%);
  }
  .sheet-grip { display: block; width: 40px; height: 5px; border-radius: 99px; background: var(--surface-3); margin: 0 auto 12px; }
  .drop { min-height: 190px; }
}

@media (max-width: 380px) {
  .hero-streak .big, .hero-goal .goal-num { font-size: 44px; }
  .seg button { padding: 7px 9px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Account & sync ---------- */
.sync-banner { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; padding: 16px 18px; border-color: rgba(59, 130, 246, .3); background: linear-gradient(90deg, rgba(59, 130, 246, .10), var(--surface) 60%); }
.sync-banner .sb-text { flex: 1; min-width: 0; }
.sync-banner .sb-text p { color: var(--muted); font-size: 14px; }
.sync-banner .icon-btn { background: transparent; }
.sync-pill { font-size: 13px; font-weight: 600; color: var(--lime); background: var(--lime-soft); padding: 5px 11px; border-radius: 99px; }
.sync-pill[data-state="syncing"] { color: var(--blue-2); background: rgba(59, 130, 246, .14); }
.sync-pill[data-state="offline"], .sync-pill[data-state="error"] { color: var(--orange); background: rgba(255, 138, 61, .13); }
.sync-line { margin-top: 8px !important; font-size: 12px !important; color: var(--lime) !important; }
.sync-line::before { content: "● "; }
.sync-line[data-state="syncing"] { color: var(--blue-2) !important; }
.sync-line[data-state="offline"], .sync-line[data-state="error"] { color: var(--orange) !important; }
.avatar { position: relative; }
.avatar.synced::after { content: ""; position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border-radius: 50%; background: var(--lime); border: 2px solid var(--bg); }
.form-msg { font-size: 14px; color: var(--muted); min-height: 20px; }
.form-msg.bad { color: var(--red); }
.form-msg.good { color: var(--lime); }
input[type="email"], input[type="password"] {
  width: 100%; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; font-size: 16px; outline: none; min-height: 46px; -webkit-appearance: none; appearance: none;
}
input[type="email"]:focus, input[type="password"]:focus { border-color: rgba(198, 244, 50, .5); }
.auth-links { margin-top: 16px; text-align: center; color: var(--muted); font-size: 14px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--lime); font-weight: 600; cursor: pointer; font-size: inherit; }
.confirm-box { display: flex; gap: 12px; background: var(--lime-soft); border-radius: var(--r-md); padding: 16px; margin-bottom: 4px; }
.confirm-box .ic { color: var(--lime); width: 24px; height: 24px; }
.confirm-box p { color: var(--muted); font-size: 14px; margin-top: 4px; }
@media (max-width: 860px) {
  .sync-banner { flex-wrap: wrap; margin-bottom: 12px; position: relative; padding-right: 48px; }
  .sync-banner .sb-text { flex-basis: calc(100% - 60px); }
  .sync-banner .btn.primary { width: calc(100% + 30px); }
  .sync-banner .icon-btn { position: absolute; top: 8px; right: 8px; }
}
