:root {
  --bg: #070a09;
  --card: #101614;
  --card-2: #141c19;
  --line: rgba(255,255,255,0.07);
  --text: #f5f8f6;
  --muted: #7d8c85;
  --accent: #6dffb0;
  --accent-dim: rgba(109,255,176,0.14);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

#app {
  min-height: 100%;
  max-width: 430px;
  margin: 0 auto;
  padding: calc(14px + var(--safe-t)) 18px calc(100px + var(--safe-b));
}

.top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 22px;
}
.brand { display: flex; gap: 12px; align-items: center; min-width: 0; }
.mark {
  flex: 0 0 auto;
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--accent);
  color: #04140c;
  font-weight: 900; font-size: 14px; letter-spacing: -0.04em;
}
.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
h1 {
  margin: 3px 0 0;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.045em;
  line-height: 1;
}

.chip, .btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 650;
}
.chip:active, .btn:active { opacity: 0.85; }
.btn.ghost { width: 100%; background: transparent; margin-top: 10px; }

/* HOME HERO — bold */
.hero {
  padding: 8px 2px 4px;
}
.hero-kicker {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.hero-lost {
  margin: 0;
  font-size: clamp(64px, 20vw, 84px);
  font-weight: 900;
  letter-spacing: -0.06em;
  line-height: 0.9;
}
.hero-lost em {
  font-style: normal;
  color: var(--accent);
  font-size: 0.38em;
  font-weight: 800;
  margin-left: 6px;
  letter-spacing: -0.02em;
  vertical-align: 0.35em;
}
.hero-goal {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 15px;
  font-weight: 550;
}
.progress-track {
  margin-top: 22px;
  height: 8px;
  border-radius: 99px;
  background: #1a2420;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #3ddc97, var(--accent));
  min-width: 2px;
  transition: width 0.5s ease;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 18px;
}
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px 12px;
  text-align: left;
  color: inherit;
  font: inherit;
  cursor: pointer;
  position: relative;
}
.stat .k {
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.stat .v {
  margin-top: 6px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.03em;
}
.stat .hint {
  display: none;
  margin-top: 6px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.3;
}
.stat.open .hint,
.stat:focus-visible .hint { display: block; }
.stat.open { border-color: rgba(109,255,176,0.35); background: #132019; }

.section { margin-top: 26px; }
.section-title {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

/* CHARTS */
.chart-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 16px 14px 12px;
  margin-bottom: 12px;
  position: relative;
}
.chart-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}
.chart-head h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 750;
  letter-spacing: -0.02em;
}
.chart-head .meta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.chart-stage {
  position: relative;
  touch-action: manipulation;
}
svg.chart {
  width: 100%;
  height: 168px;
  display: block;
  overflow: visible;
}
.chart .grid { stroke: rgba(255,255,255,0.05); stroke-width: 1; }
.chart .line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.chart .area { fill: url(#areaGrad); opacity: 0.28; }
.chart .bar { fill: rgba(109,255,176,0.22); }
.chart .bar.hot { fill: var(--accent); }
.chart .range { stroke: rgba(109,255,176,0.55); stroke-width: 4; stroke-linecap: round; }
.chart .dot { fill: var(--accent); }
.chart .dot.ghost { fill: transparent; stroke: transparent; }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .label { fill: var(--muted); font-size: 10px; font-weight: 600; }
.chart .crosshair {
  stroke: rgba(255,255,255,0.18);
  stroke-width: 1;
  stroke-dasharray: 3 3;
  display: none;
}
.chart-stage.active .crosshair { display: block; }

.callout {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 10px));
  background: #0c1210;
  border: 1px solid rgba(109,255,176,0.35);
  color: var(--text);
  border-radius: 12px;
  padding: 8px 11px;
  min-width: 88px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.45);
  opacity: 0;
  transition: opacity 0.12s ease;
}
.callout.show { opacity: 1; }
.callout .c-date {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  margin-bottom: 2px;
}
.callout .c-val {
  display: block;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--accent);
}
.callout::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -5px;
  width: 8px; height: 8px;
  background: #0c1210;
  border-right: 1px solid rgba(109,255,176,0.35);
  border-bottom: 1px solid rgba(109,255,176,0.35);
  transform: translateX(-50%) rotate(45deg);
}

/* DAY LIST */
.day-list { display: grid; gap: 8px; }
.day-row {
  display: grid;
  grid-template-columns: 58px 1fr auto;
  gap: 12px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 13px 14px;
  color: inherit;
  text-decoration: none;
  width: 100%;
  text-align: left;
  font: inherit;
  cursor: pointer;
}
.day-row .dow { font-weight: 800; font-size: 14px; letter-spacing: -0.02em; }
.day-row .date { color: var(--muted); font-size: 12px; margin-top: 1px; }
.day-row .mid { color: var(--muted); font-size: 13px; font-weight: 550; }
.day-row .right { font-weight: 800; font-size: 18px; letter-spacing: -0.03em; }
.day-row:active { background: var(--card-2); }

.day-nav { display: flex; gap: 8px; margin-bottom: 14px; }
.day-nav .btn { flex: 1; }

.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.metric {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  text-align: left;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.metric .k { color: var(--muted); font-size: 12px; font-weight: 650; }
.metric .v {
  margin-top: 8px;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.03em;
}
.metric .u { color: var(--muted); font-size: 12px; font-weight: 650; }
.metric .detail {
  display: none;
  margin-top: 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
}
.metric.open {
  border-color: rgba(109,255,176,0.35);
  background: #132019;
}
.metric.open .detail { display: block; }

.sprint-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 16px;
}
.sprint-card p { margin: 0; }
.sprint-card .big {
  font-size: 18px;
  font-weight: 750;
  letter-spacing: -0.02em;
}
.sprint-card .sub {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.empty {
  padding: 28px 14px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 18px;
  font-size: 14px;
}
.loading { color: var(--muted); padding: 48px 0; text-align: center; font-weight: 600; }

.tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(12px + var(--safe-b));
  width: min(400px, calc(100% - 24px));
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  background: rgba(10, 14, 12, 0.9);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 6px;
  z-index: 20;
}
.tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 14px;
  padding: 10px 6px 8px;
  display: grid;
  place-items: center;
  gap: 2px;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
}
.tab svg { width: 20px; height: 20px; fill: currentColor; }
.tab.active {
  color: #04140c;
  background: var(--accent);
}

.sheet {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 40;
  display: grid;
  align-items: end;
}
.sheet.hidden { display: none; }
.sheet-card {
  background: #0e1412;
  border-radius: 24px 24px 0 0;
  padding: 12px 16px calc(20px + var(--safe-b));
  border: 1px solid var(--line);
  max-width: 430px;
  margin: 0 auto;
  width: 100%;
}
.sheet-handle {
  width: 40px; height: 4px; border-radius: 99px;
  background: #2a3831; margin: 4px auto 14px;
}
.sheet-card h2 { margin: 0 0 12px; font-size: 20px; font-weight: 800; letter-spacing: -0.03em; }
.week-list { display: grid; gap: 8px; margin-bottom: 8px; max-height: 50vh; overflow: auto; }
.week-item {
  appearance: none; width: 100%; text-align: left;
  border: 1px solid var(--line); background: var(--card);
  color: var(--text); border-radius: 16px; padding: 14px; font: inherit;
}
.week-item.active {
  border-color: rgba(109,255,176,0.4);
  background: var(--accent-dim);
}
.week-item .w { font-weight: 800; }
.week-item .r { color: var(--muted); font-size: 12px; margin-top: 3px; }

/* Week flipper */
.week-flip {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  gap: 8px;
  align-items: center;
  margin: -6px 0 18px;
}
.week-flip[hidden] { display: none !important; }
.week-nav {
  appearance: none;
  width: 44px; height: 44px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  font-size: 26px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
}
.week-nav:disabled {
  opacity: 0.28;
  cursor: not-allowed;
}
.week-center {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: 16px;
  padding: 10px 12px;
  text-align: center;
  font: inherit;
  cursor: pointer;
}
.week-label {
  display: block;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.week-range {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.sync-line {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.sync-line strong { color: var(--text); font-weight: 700; }

.weight-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
}
.weight-toggle-row span {
  font-size: 13px;
  font-weight: 650;
  color: var(--muted);
}
.toggle {
  appearance: none;
  width: 48px; height: 28px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #1a2420;
  position: relative;
  cursor: pointer;
  padding: 0;
  flex: 0 0 auto;
}
.toggle::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #8b9a93;
  transition: transform 0.18s ease, background 0.18s ease;
}
.toggle.on {
  background: var(--accent-dim);
  border-color: rgba(109,255,176,0.4);
}
.toggle.on::after {
  transform: translateX(20px);
  background: var(--accent);
}
.weight-chart-panel {
  margin-top: 12px;
}
.weight-chart-panel[hidden] { display: none !important; }

.metric-block { margin-bottom: 12px; }
