/* ── Tokens ───────────────────────────────────────────────
   Bold athletic: hard black and chalk white, one solid accent,
   heavy condensed type set big. Flat blocks, tight corners, no
   glow anywhere — emphasis comes from size and solid fills.  */
@font-face {
  font-family: "Barlow Condensed";
  src: url("fonts/BarlowCondensed-ExtraBold.ttf") format("truetype");
  font-weight: 800;
  font-display: swap;
}
@font-face {
  font-family: "Barlow Condensed";
  src: url("fonts/BarlowCondensed-SemiBold.ttf") format("truetype");
  font-weight: 600;
  font-display: swap;
}

:root {
  color-scheme: dark;

  --plane:        #0b0b0b;
  --surface:      #141414;
  --surface-2:    #1c1c1c;
  --surface-3:    #292929;
  --border:       rgba(255, 255, 255, 0.10);
  --border-2:     rgba(255, 255, 255, 0.22);

  --text:         #f5f5f0;
  --text-2:       #a6a6a0;
  --muted:        #72726d;

  /* Two accents with fixed jobs, never decoration:
     --accent   = the lifting itself (primary action, PRs, lift charts)
     --accent-2 = progression (level, XP, streak, bodyweight)
     Swapped as a pair by the theme picker; everything else derives. */
  --accent:       #ff5a1f;
  --accent-ink:   #0b0b0b;
  --accent-2:     #f5f5f0;
  --a2-ink:       #0b0b0b;

  --accent-soft:  color-mix(in srgb, var(--accent) 14%, transparent);
  --accent-line:  color-mix(in srgb, var(--accent) 45%, transparent);
  --a2-soft:      color-mix(in srgb, var(--accent-2) 12%, transparent);
  --a2-line:      color-mix(in srgb, var(--accent-2) 40%, transparent);

  --danger:       #ff4545;

  --grid:         #1f1f1f;
  --axis:         #333333;

  --r:    6px;
  --r-sm: 4px;
  --tap:  48px;

  --font:    system-ui, -apple-system, "Segoe UI Variable", "Segoe UI", sans-serif;
  --display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
}

/* Theme presets — each is an accent pair, picked in Settings. */
[data-theme="red"]    { --accent: #e8192c; --accent-ink: #ffffff; }
[data-theme="cobalt"] { --accent: #2d5bff; --accent-ink: #ffffff; }
[data-theme="gold"]   { --accent: #ffb400; --accent-ink: #0b0b0b; }
[data-theme="chalk"]  { --accent: #f5f5f0; --accent-ink: #0b0b0b; --accent-2: #ff5a1f; --a2-ink: #0b0b0b; }

/* The display face: big, condensed, uppercase. */
.wordmark, .section-head h2, .picker-btn, .group-head, .set-main b,
button.primary, button.ghost, button.danger, .tile-value, .hero-value,
.level-rank, .level-badge, .streak-n, .timer-value, .tab, .chip, .seg,
.status, .pr-badge, .toast, .chart-title, .sheet-item, input[type="number"] {
  font-family: var(--display);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--plane);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

body { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }

::selection { background: var(--accent); color: var(--accent-ink); }

/* ── Top bar ─────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) 18px 14px;
  background: var(--plane);
  border-bottom: 1px solid var(--border);
}
.wordmark {
  font-size: 1.625rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  line-height: 1;
  text-transform: uppercase;
}
.wordmark span { color: var(--accent); }
.topbar-right { display: flex; align-items: center; gap: 8px; }

.streak-chip {
  display: flex;
  align-items: baseline;
  gap: 3px;
  padding: 5px 10px;
  border-radius: var(--r-sm);
  background: var(--accent-2);
  color: var(--a2-ink);
  font-variant-numeric: tabular-nums;
}
.streak-n { font-size: 1.125rem; font-weight: 800; line-height: 1; }
.streak-w { font-size: 0.6875rem; font-weight: 700; text-transform: uppercase; }

.timer {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px 6px 10px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.timer-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
.timer-value { font-size: 1.125rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }

/* ── Layout ──────────────────────────────────────────────── */
main { max-width: 640px; margin: 0 auto; padding: 18px; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 34px 0 12px;
}
.section-head h2 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.005em;
  color: var(--text);
}
.section-meta {
  font-size: 0.8125rem;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.stack { display: flex; flex-direction: column; gap: 10px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px;
}

/* ── Exercise picker button ──────────────────────────────── */
.picker-btn {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 72px;
  padding: 12px 44px 12px 16px;
  margin-bottom: 16px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--r);
  color: var(--text);
  font-family: var(--display);
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
  text-align: left;
  cursor: pointer;
}
.picker-btn.chosen { border-color: var(--text); background: var(--surface); }
.picker-empty { flex: 1; }
.picker-btn:not(.chosen) .picker-empty { color: var(--muted); font-weight: 600; font-size: 1.5rem; }
.picker-group {
  font-size: 0.8125rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: var(--r-sm);
  padding: 4px 8px;
}
.picker-group:empty { display: none; }
.chev {
  position: absolute;
  right: 14px;
  width: 20px; height: 20px;
  fill: none; stroke: var(--muted);
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

/* ── Next-set suggestion ─────────────────────────────────── */
.suggest {
  margin: -4px 0 16px;
  padding: 13px 14px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
}
.suggest-last { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.suggest-last .tile-label { margin-bottom: 0; }
.suggest-sets { font-size: 0.8125rem; font-weight: 600; color: var(--text-2); font-variant-numeric: tabular-nums; }
.suggest-opts { display: flex; gap: 8px; margin-top: 11px; }
.suggest-opt {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.suggest-opt:active { border-color: var(--accent); }
.suggest-kind {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}
.suggest-num {
  font-family: var(--display);
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.suggest-sub {
  font-family: var(--display);
  font-size: 0.875rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
}
.suggest-note { margin: 10px 0 0; font-size: 0.8125rem; color: var(--text-2); }

/* ── Form ────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 14px; flex: 1; min-width: 0; }
.field label {
  font-family: var(--display);
  font-size: 0.9375rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-2);
}
.hint, .unit-label { letter-spacing: 0.06em; }

input, select {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font: inherit;
  font-variant-numeric: tabular-nums;
}
input[type="number"] { font-size: 1.875rem; font-weight: 800; line-height: 1; }
/* Tight side padding and narrower steppers so "202.5" fits a phone. */
.stepper input { min-height: 58px; padding: 6px 2px; font-size: 1.75rem; }
input:focus-visible, select:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
input::placeholder { color: #43484d; }

.row { display: flex; gap: 12px; }

.stepper { display: flex; gap: 7px; }
.stepper input { text-align: center; }
.step {
  flex: 0 0 42px;
  min-height: 58px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: 1.375rem;
  line-height: 1;
  cursor: pointer;
}
.step:active { background: var(--surface-3); color: var(--accent); }

.more { margin-bottom: 16px; }
.more summary {
  cursor: pointer;
  color: var(--text-2);
  font-size: 0.8125rem;
  padding: 8px 0;
  user-select: none;
}
.more[open] summary { margin-bottom: 8px; }

/* ── Buttons ─────────────────────────────────────────────── */
.actions { display: flex; gap: 10px; }
.actions.wrap { flex-wrap: wrap; margin-bottom: 10px; }
.actions > button { flex: 1; }

button.primary, button.ghost, button.danger {
  min-height: 56px;
  padding: 0 20px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  font-family: var(--display);
  font-size: 1.375rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  cursor: pointer;
}
button.primary { background: var(--accent); color: var(--accent-ink); }
button.primary:active { filter: brightness(0.88); }
button.ghost { background: var(--surface-2); color: var(--text); border-color: var(--border-2); }
button.danger { background: transparent; color: var(--danger); border-color: rgba(255, 95, 95, 0.4); }
button:disabled { opacity: 0.35; cursor: default; }

/* ── Set rows ────────────────────────────────────────────── */
.group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}
.group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 15px;
  font-size: 1.375rem;
  font-weight: 800;
  line-height: 1.05;
  text-transform: uppercase;
}
.group-head .meta {
  font-family: var(--font);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: none;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
summary.group-head { cursor: pointer; list-style: none; }
summary.group-head::-webkit-details-marker { display: none; }

.set-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 15px;
  border-top: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
.set-n { width: 1.4em; color: var(--muted); font-size: 0.75rem; font-weight: 600; }
.set-main { flex: 1; min-width: 0; font-weight: 600; }
.set-main b { font-size: 1.375rem; font-weight: 800; line-height: 1; }
.set-sub { font-size: 0.75rem; color: var(--muted); font-weight: 500; }
.set-e1rm { font-size: 0.75rem; color: var(--text-2); font-weight: 600; }

.pr-badge {
  font-size: 0.9375rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1;
  padding: 4px 8px;
  border-radius: var(--r-sm);
  background: var(--accent);
  color: var(--accent-ink);
}

.del {
  flex: 0 0 30px;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  background: transparent;
  border: 0; border-radius: 50%;
  color: var(--muted);
  font-size: 19px; line-height: 1;
  cursor: pointer;
}
.del:hover { background: var(--surface-3); color: var(--danger); }

.empty {
  padding: 34px 18px;
  text-align: center;
  color: var(--muted);
  font-size: 0.9375rem;
  border: 1px dashed var(--border-2);
  border-radius: var(--r);
}

/* ── Level card ──────────────────────────────────────────── */
.level-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 4px solid var(--accent-2);
  border-radius: var(--r);
  padding: 18px;
  margin-bottom: 12px;
}
.level-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.level-who {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-2);
  margin-bottom: 4px;
}
.level-rank { font-size: 2.75rem; font-weight: 800; line-height: 0.95; text-transform: uppercase; }
.level-sub {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-top: 3px;
}
.level-badge {
  flex: 0 0 auto;
  min-width: 60px; height: 60px;
  display: grid; place-items: center;
  padding: 0 10px;
  border-radius: var(--r-sm);
  background: var(--accent-2);
  color: var(--a2-ink);
  font-size: 2.25rem;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.xp-bar {
  height: 12px;
  border-radius: 2px;
  background: var(--surface-3);
  overflow: hidden;
}
.xp-fill {
  height: 100%;
  width: 0;
  background: var(--accent-2);
  transition: width 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}
.xp-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.xp-breakdown {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.xp-breakdown b { color: var(--text-2); font-weight: 700; }

/* ── Hero number ─────────────────────────────────────────── */
.hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 18px;
  margin-bottom: 12px;
}
.hero-label {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}
.hero-value {
  margin-top: 6px;
  font-size: clamp(3.5rem, 18vw, 5rem);
  font-weight: 800;
  line-height: 0.9;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.hero-unit { font-size: 1.5rem; font-weight: 800; text-transform: uppercase; color: var(--text-2); }
.hero-note { margin-top: 9px; font-size: 0.8125rem; color: var(--text-2); }
.hero-note:empty { display: none; }

/* ── The climb ───────────────────────────────────────────── */
.climb .next-bar { margin-top: 12px; }
.climb-next-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.climb-next-top .tile-label { margin-bottom: 0; }
.climb-name {
  font-family: var(--display);
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
}
.climb-name.mystery { color: var(--accent); letter-spacing: 0.08em; }
.climb-hint { margin: 0; font-size: 0.875rem; color: var(--text-2); }
.climb-row .set-main {
  font-family: var(--display);
  font-size: 1.375rem;
  font-weight: 800;
  line-height: 1.05;
  text-transform: uppercase;
}
.climb-row .set-sub { font-family: var(--font); text-transform: none; }
.climb-tag {
  flex: 0 0 auto;
  font-family: var(--display);
  font-size: 0.875rem;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 4px 7px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-2);
  color: var(--text-2);
}

/* Progress toward the next comparison — lifting, so --accent, no glow. */
.next-bar {
  height: 8px;
  margin-top: 16px;
  border-radius: 2px;
  background: var(--surface-3);
  overflow: hidden;
}
.next-fill { height: 100%; background: var(--accent); }
.next-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 7px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.session-note {
  margin: 2px 2px 0;
  font-size: 0.8125rem;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.session-note b { color: var(--text); font-weight: 800; }

/* On this day — the change since then, as a solid block. */
.otd-up, .otd-down, .otd-flat {
  flex: 0 0 auto;
  font-family: var(--display);
  font-size: 1.125rem;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.otd-up   { color: var(--accent); }
.otd-down { color: var(--danger); }
.otd-flat { color: var(--muted); text-transform: uppercase; }
#onThisDay .set-main {
  font-family: var(--display);
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1.05;
  text-transform: uppercase;
}
#onThisDay .set-sub { font-family: var(--font); text-transform: none; }

/* ── Tiles ───────────────────────────────────────────────── */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 4px; }
.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 13px 15px;
}
.tile-label {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 5px;
}
.tile-value {
  font-size: 2.25rem;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.tile-unit { font-size: 1rem; font-weight: 800; text-transform: uppercase; color: var(--text-2); }

/* ── Week grid ───────────────────────────────────────────── */
.weeks { display: flex; gap: 4px; flex-wrap: wrap; }
.week {
  flex: 1 0 14px;
  height: 26px;
  border-radius: 2px;
  background: var(--surface-3);
}
.week.on   { background: color-mix(in srgb, var(--accent-2) 50%, transparent); }
.week.hot  { background: var(--accent-2); }
.week-key {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  font-size: 0.6875rem;
  color: var(--muted);
}

/* ── Bodyweight ──────────────────────────────────────────── */
/* Two fields side by side, button beneath — a native date input
   needs ~140px and gets truncated in a single row on a phone. */
.bw-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.bw-form .field { margin-bottom: 0; }
.bw-submit { grid-column: 1 / -1; }

/* ── Plateaus ────────────────────────────────────────────── */
/* Solid blocks like everything else: progressing takes the lift
   accent, plateau takes danger red, stalling is a plain outline. */
.section-head-top { margin-top: 0; }
.watch { margin-bottom: 18px; }
.watch-row {
  width: 100%;
  background: none;
  border-left: 0; border-right: 0; border-bottom: 0;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.watch-row:first-child { border-top: 0; }
.watch-row:active { background: var(--surface-2); }
.watch-row .set-main {
  font-family: var(--display);
  font-size: 1.375rem;
  font-weight: 800;
  line-height: 1.05;
  text-transform: uppercase;
}
.watch-row .set-sub { font-family: var(--font); text-transform: none; }

.status {
  flex: 0 0 auto;
  font-size: 0.9375rem;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 4px 8px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  white-space: nowrap;
}
.status-progressing { background: var(--accent); color: var(--accent-ink); }
.status-stalling    { background: transparent; color: var(--text); border-color: var(--text); }
.status-plateau     { background: var(--danger); color: #0b0b0b; }
.status-dormant,
.status-new         { background: transparent; color: var(--muted); border-color: var(--border-2); }

.plateau-card { margin: 10px 0; }
.plateau-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.plateau-top .tile-label { margin-bottom: 0; }
.plateau-line { margin-top: 10px; font-size: 1.0625rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.plateau-tip { margin-top: 6px; font-size: 0.8125rem; color: var(--text-2); }

/* ── Table ───────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 9px 10px; text-align: right; font-size: 0.875rem; }
th:first-child, td:first-child { text-align: left; }
th {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
td { font-weight: 600; }
tbody tr { border-top: 1px solid var(--border); }

.table-toggle {
  background: none;
  border: 0;
  color: var(--text-2);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 10px 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ── Settings ────────────────────────────────────────────── */
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.field-label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 9px;
}
.themes { display: flex; gap: 10px; flex-wrap: wrap; }
.theme-swatch {
  position: relative;
  width: 48px; height: 48px;
  padding: 0;
  border: 2px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  cursor: pointer;
  overflow: hidden;
}
/* Each swatch shows the pair: primary fills it, secondary takes the corner. */
.theme-swatch i { position: absolute; inset: 0; background: var(--sw1); }
.theme-swatch i::after {
  content: '';
  position: absolute;
  right: 0; bottom: 0;
  width: 55%; height: 55%;
  background: var(--sw2);
  clip-path: polygon(100% 0, 100% 100%, 0 100%);
}
.theme-swatch[aria-pressed="true"] { border-color: var(--text); }
.segmented { display: flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 3px; }
.seg {
  min-width: 58px; min-height: 38px;
  border: 0; border-radius: 2px;
  background: transparent;
  color: var(--text-2);
  font-family: var(--display); font-size: 1.125rem; font-weight: 800;
  text-transform: uppercase;
  cursor: pointer;
}
.seg[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

.muted { color: var(--muted); }
.small { font-size: 0.8125rem; line-height: 1.5; }

/* ── Sheet ───────────────────────────────────────────────── */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(0, 0, 0, 0.65);
  animation: fade 0.18s ease;
}
@keyframes fade { from { opacity: 0; } }

.sheet {
  position: fixed;
  z-index: 41;
  left: 0; right: 0; bottom: 0;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-top: 4px solid var(--accent);
  border-radius: var(--r) var(--r) 0 0;
  animation: rise 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes rise { from { transform: translateY(100%); } }

.sheet-head { padding: 10px 16px 0; border-bottom: 1px solid var(--border); }
.sheet-grab { width: 38px; height: 4px; border-radius: 2px; background: var(--surface-3); margin: 0 auto 12px; }
.sheet-row { display: flex; gap: 10px; align-items: center; }
.sheet-row input { background: var(--surface-2); }
.sheet-close {
  flex: 0 0 var(--tap);
  height: var(--tap);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 22px; line-height: 1;
  cursor: pointer;
}

.chips { display: flex; gap: 7px; overflow-x: auto; padding: 12px 0; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  padding: 7px 13px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-2);
  background: transparent;
  color: var(--text-2);
  font-family: var(--display);
  font-size: 1.0625rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  cursor: pointer;
  white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.sheet-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 6px 16px calc(20px + env(safe-area-inset-bottom));
}
.sheet-group {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  padding: 16px 0 6px;
}
.sheet-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 54px;
  padding: 12px 2px;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-family: var(--display);
  font-size: 1.375rem;
  font-weight: 800;
  text-transform: uppercase;
  line-height: 1.05;
  text-align: left;
  cursor: pointer;
}
.sheet-item:active { color: var(--accent); }
.sheet-add { color: var(--accent); border-bottom: 0; }

.add-lift { padding-bottom: 6px; }
.add-lift input { background: var(--surface-2); }
.chips-wrap { flex-wrap: wrap; overflow: visible; padding: 0 0 18px; }
.sheet-item .recent {
  font-family: var(--font);
  text-transform: none;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ── Tab bar ─────────────────────────────────────────────── */
.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 30;
  display: flex;
  background: var(--plane);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 0 8px;
  background: none;
  border: 0;
  border-top: 4px solid transparent;
  margin-top: -1px;
  color: var(--muted);
  font-family: var(--display);
  font-size: 0.9375rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
}
.tab svg {
  width: 22px; height: 22px;
  fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.tab[aria-selected="true"] { color: var(--text); border-top-color: var(--accent); }
.tab[aria-selected="true"] svg { stroke: var(--accent); }

/* ── Toast ───────────────────────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(90px + env(safe-area-inset-bottom));
  transform: translate(-50%, 14px);
  z-index: 50;
  max-width: calc(100vw - 32px);
  padding: 10px 18px;
  border-radius: var(--r-sm);
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  font-size: 1.125rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.win {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

/* ── Chart ───────────────────────────────────────────────── */
.chart-wrap {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 15px 8px 8px;
}
.chart-title { padding: 0 8px 10px; font-size: 1.125rem; font-weight: 800; text-transform: uppercase; }
.chart-wrap svg { display: block; width: 100%; height: auto; touch-action: pan-y; }

.chart-tip {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  padding: 8px 11px;
  border-radius: var(--r-sm);
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.12s;
}
.chart-tip.show { opacity: 1; }
.chart-tip .tip-date { color: var(--muted); font-size: 0.6875rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.chart-tip .tip-value { font-weight: 700; margin-top: 2px; }

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

@media (min-width: 560px) {
  .tiles { grid-template-columns: repeat(4, 1fr); }
}
