/* ================================================================
   Gym Track — design system v3 (Anthropic design language)
   Warm oat light mode · warm charcoal dark mode · coral accent
   Flat surfaces, hairline borders, serif display, calm motion.
   Grid: 4px base · gutter 16px · radii 16/12/10 · targets ≥44px
   ================================================================ */

:root {
  color-scheme: light dark;

  /* Ink (light) */
  --ink: #141413;
  --ink-2: #5e5d59;
  --ink-3: #83827d;
  --ink-4: #a5a49e;

  /* Accent — Claude coral */
  --accent: #c15f3c;        /* buttons, active states (contrast-safe) */
  --accent-hi: #d97757;     /* decorative, icons, marks */
  --accent-soft: rgba(217, 119, 87, 0.13);
  --on-accent: #ffffff;
  --green: #5c8552;
  --red: #b3352c;
  --amber: #b98a1e;
  --violet: #7a70c9;

  /* Surfaces (light: oat + warm white) */
  --bg: #f0eee6;
  --surf: #faf9f5;
  --surf-2: rgba(20, 20, 19, 0.05);
  --surf-3: rgba(20, 20, 19, 0.09);
  --line: rgba(20, 20, 19, 0.10);
  --line-2: rgba(20, 20, 19, 0.16);
  --chrome: rgba(250, 249, 245, 0.96);
  --backdrop: rgba(20, 20, 19, 0.35);
  --input-bg: rgba(20, 20, 19, 0.04);
  --shadow-sm: 0 1px 2px rgba(20, 20, 19, 0.05), 0 2px 8px rgba(20, 20, 19, 0.04);
  --shadow-lg: 0 4px 12px rgba(20, 20, 19, 0.08), 0 12px 32px rgba(20, 20, 19, 0.10);

  --serif: ui-serif, "New York", Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", Roboto, sans-serif;

  --r-lg: 16px;
  --r-md: 12px;
  --r-sm: 10px;

  --spring: cubic-bezier(0.3, 1.15, 0.55, 1);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);

  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --tabbar-total: calc(52px + max(var(--sab), 8px));
  --kb: 0px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #f0eee6;
    --ink-2: #c9c7be;
    --ink-3: #98968c;
    --ink-4: #6e6c64;

    --accent: #d97757;
    --accent-hi: #e08a6d;
    --accent-soft: rgba(217, 119, 87, 0.16);
    --on-accent: #1f1e1d;
    --green: #79b26f;
    --red: #e5695f;
    --amber: #dcb75e;
    --violet: #9d94e0;

    --bg: #1f1e1d;
    --surf: #262624;
    --surf-2: rgba(255, 255, 255, 0.06);
    --surf-3: rgba(255, 255, 255, 0.11);
    --line: rgba(255, 255, 255, 0.09);
    --line-2: rgba(255, 255, 255, 0.17);
    --chrome: rgba(38, 38, 36, 0.97);
    --backdrop: rgba(0, 0, 0, 0.5);
    --input-bg: rgba(0, 0, 0, 0.22);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25), 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.35), 0 12px 32px rgba(0, 0, 0, 0.4);
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { height: 100%; }
body {
  height: 100vh;
  height: 100dvh;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}
input, textarea { -webkit-user-select: text; user-select: text; font-family: inherit; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; text-align: inherit; }
svg { display: block; }
[hidden] { display: none !important; }

/* ---------------- Background (flat, quiet) ---------------- */
.bg { position: fixed; inset: 0; z-index: 0; background: var(--bg); }
.bg-blob { display: none; }
@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* ---------------- Surfaces ---------------- */
.card {
  background: var(--surf);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  position: relative;
}
.glass { /* floating chrome: near-opaque warm surface, hairline, soft shadow */
  background: var(--chrome);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
}
.card-press { transition: transform 0.25s var(--ease-out), background 0.15s; }
.card-press:active { transform: scale(0.99); background: var(--surf-2); }

/* ---------------- Layout ---------------- */
#main { position: fixed; inset: 0; z-index: 1; }
.tab-panel {
  position: absolute; inset: 0;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: calc(var(--sat) + 6px) 16px calc(var(--tabbar-total) + 24px);
  animation: panel-in 0.3s var(--ease-out);
}
body.has-workout-bar .tab-panel { padding-bottom: calc(var(--tabbar-total) + 92px); }
@keyframes panel-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.h-page { font-family: var(--serif); font-size: 30px; font-weight: 600;
  letter-spacing: -0.01em; margin: 6px 0 2px; }
.h-sub { color: var(--ink-3); font-size: 13px; font-weight: 500; margin: 0 0 16px; }
.h-section { display: flex; align-items: baseline; justify-content: space-between;
  margin: 28px 2px 10px; }
.h-section h2 { font-size: 12.5px; font-weight: 650; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--ink-3); font-family: var(--sans); }
.h-section .link { color: var(--accent); font-size: 13px; font-weight: 600; }

/* ---------------- Tab bar (flush) ---------------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0;
  z-index: 40;
  border-radius: 0;
  border: none; border-top: 1px solid var(--line);
  box-shadow: none;
  display: grid; grid-template-columns: repeat(5, 1fr);
  align-items: stretch;
  padding: 0 8px max(var(--sab), 8px);
  height: var(--tabbar-total);
}
.tab-btn { display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--ink-3); font-size: 10px; font-weight: 600;
  transition: color 0.15s, transform 0.25s var(--ease-out); }
.tab-btn svg { width: 25px; height: 25px; fill: currentColor; }
.tab-btn svg [fill="none"] { fill: none; }
.tab-btn.active { color: var(--accent); }
.tab-btn:active { transform: scale(0.94); }
.start-orb {
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; color: var(--on-accent);
  background: var(--accent);
  box-shadow: var(--shadow-sm);
}
.start-orb svg { width: 22px; height: 22px; }
.tab-btn-start:active .start-orb { transform: scale(0.95); }

/* ---------------- Buttons / chips / inputs ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 44px; border-radius: var(--r-md); padding: 0 16px;
  font-size: 15px; font-weight: 600; letter-spacing: -0.01em;
  background: var(--surf); border: 1px solid var(--line-2);
  box-shadow: var(--shadow-sm);
  transition: transform 0.25s var(--ease-out), background 0.15s, opacity 0.15s;
}
.btn:active { transform: scale(0.98); background: var(--surf-2); }
.btn-primary {
  background: var(--accent);
  border-color: transparent; color: var(--on-accent);
}
.btn-primary:active { background: var(--accent); opacity: 0.88; }
.btn-danger { color: var(--red); }
.btn-block { display: flex; width: 100%; }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; gap: 5px; }
.btn:disabled { opacity: 0.4; pointer-events: none; }
.btn svg { width: 17px; height: 17px; }

.chip-row { display: flex; gap: 8px; overflow-x: auto; padding: 2px 16px; margin: 0 -16px 12px;
  scrollbar-width: none; }
.chip-row::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; height: 34px; display: inline-flex; align-items: center;
  padding: 0 14px; border-radius: 17px;
  font-size: 13px; font-weight: 600; color: var(--ink-2);
  background: var(--surf); border: 1px solid var(--line);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.chip.active { background: var(--accent-soft); border-color: var(--accent);
  color: var(--accent); }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; font-weight: 650; color: var(--ink-3);
  margin: 0 2px 6px; text-transform: uppercase; letter-spacing: 0.06em; }
.input, textarea.input {
  width: 100%; height: 44px; border-radius: var(--r-sm); padding: 0 14px;
  background: var(--input-bg); border: 1px solid var(--line);
  color: var(--ink); font-size: 16px; font-weight: 500; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus { border-color: var(--accent-hi); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { height: auto; min-height: 76px; padding: 12px 14px; resize: none; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px;
  background: var(--input-bg); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 3px; }
.seg button { height: 36px; border-radius: 8px; font-size: 13px; font-weight: 600;
  color: var(--ink-3); text-align: center; transition: background 0.15s, color 0.15s; }
.seg button.active { background: var(--surf); color: var(--ink); box-shadow: var(--shadow-sm); }

/* ---------------- Pushed screens ---------------- */
#screen-stack { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
.screen {
  position: absolute; inset: 0; pointer-events: auto;
  background: var(--bg);
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.35s var(--spring), opacity 0.25s;
}
.screen.sheet-style { transform: translateY(100%); border-radius: 16px 16px 0 0;
  top: max(var(--sat), 12px);
  box-shadow: var(--shadow-lg); border-top: 1px solid var(--line-2); }
.screen.shown { transform: none; }
.screen.leaving { transform: translateX(100%); opacity: 0.6; }
.screen.sheet-style.leaving { transform: translateY(100%); }
.screen-head {
  display: flex; align-items: center; gap: 8px;
  padding: calc(var(--sat) + 6px) 12px 8px;
  flex: 0 0 auto; min-height: 52px;
}
.screen.sheet-style .screen-head { padding-top: 8px; }
.screen-head .title { flex: 1; font-family: var(--serif); font-size: 18px; font-weight: 600;
  text-align: center; letter-spacing: -0.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; flex: 0 0 auto;
  display: grid; place-items: center; color: var(--ink-2);
  background: var(--surf); border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  transition: transform 0.25s var(--ease-out), background 0.15s;
}
.icon-btn:active { transform: scale(0.92); background: var(--surf-2); }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor;
  stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.accent { color: var(--accent); }
.screen-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 4px 16px calc(max(var(--sab), 16px) + 32px); }
.grabber { width: 36px; height: 5px; border-radius: 3px; background: var(--surf-3);
  margin: 8px auto 0; flex: 0 0 auto; }

/* ---------------- Bottom sheets / modals (flush, keyboard-aware) ---------------- */
#sheet-root { position: fixed; inset: 0; z-index: 90; pointer-events: none; }
.sheet-backdrop { position: absolute; inset: 0; background: var(--backdrop);
  opacity: 0; transition: opacity 0.25s; pointer-events: auto; }
.sheet-backdrop.shown { opacity: 1; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-height: calc(88dvh - var(--kb));
  display: flex; flex-direction: column;
  border-radius: 20px 20px 0 0; pointer-events: auto;
  background: var(--surf);
  border-top: 1px solid var(--line-2);
  box-shadow: var(--shadow-lg);
  transform: translateY(110%);
  transition: transform 0.35s var(--spring), margin-bottom 0.25s var(--ease-out);
  margin-bottom: var(--kb);
}
.sheet.shown { transform: none; }
.sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 4px 16px calc(max(var(--sab), 16px) + 4px); }
.sheet h3 { font-family: var(--serif); font-size: 19px; font-weight: 600; text-align: center;
  padding: 8px 16px 14px; letter-spacing: -0.01em; }
.modal {
  position: absolute; left: 50%; top: calc(46% - var(--kb) / 2);
  transform: translate(-50%, -50%) scale(0.9);
  width: min(300px, calc(100vw - 56px));
  border-radius: 16px; pointer-events: auto; opacity: 0;
  background: var(--surf);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow-lg);
  transition: transform 0.3s var(--spring), opacity 0.2s;
  padding: 20px 18px 14px; text-align: center;
}
.modal.shown { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.modal h3 { font-family: var(--serif); font-size: 17px; font-weight: 600; margin-bottom: 6px; }
.modal p { font-size: 13px; color: var(--ink-2); line-height: 1.45; margin-bottom: 16px; }
.modal .row { display: flex; gap: 8px; }
.modal .row .btn { flex: 1; }

/* ---------------- Toast ---------------- */
#toast-root { position: fixed; top: calc(var(--sat) + 6px); left: 0; right: 0;
  z-index: 120; display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 9px;
  height: 42px; padding: 0 18px; border-radius: 21px; max-width: calc(100vw - 32px);
  background: var(--surf);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow-lg);
  font-size: 13.5px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  animation: toast-in 0.35s var(--spring);
  transition: opacity 0.25s, transform 0.25s;
}
.toast.pr { background: var(--accent-soft); border-color: var(--accent-hi); }
.toast.hide { opacity: 0; transform: translateY(-14px) scale(0.94); }
.toast .t-ic { display: flex; flex: 0 0 auto; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-14px) scale(0.94); } }

/* ---------------- Home ---------------- */
.home-head { display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 14px; }
.hero-card { padding: 16px; margin-bottom: 12px; }
.hero-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.hero-stats { display: flex; gap: 24px; }
.hero-stat .v { font-family: var(--serif); font-size: 24px; font-weight: 600;
  letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.hero-stat .v small { font-family: var(--sans); font-size: 12px; font-weight: 600;
  color: var(--ink-3); margin-left: 3px; }
.hero-stat .l { font-size: 12px; color: var(--ink-3); font-weight: 550; margin-top: 2px; }
.ring-wrap { position: relative; width: 64px; height: 64px; flex: 0 0 auto; }
.ring-wrap svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track { stroke: var(--surf-3); }
.ring-fill { stroke: url(#ring-grad); stroke-linecap: round;
  transition: stroke-dashoffset 1s var(--ease-out); }
.ring-center { position: absolute; inset: 0; display: grid; place-items: center;
  font-family: var(--serif); font-size: 14px; font-weight: 600;
  font-variant-numeric: tabular-nums; }
.ring-center small { display: block; font-family: var(--sans); font-size: 8px;
  color: var(--ink-3); text-align: center; font-weight: 600; }

.tpl-scroll { display: flex; gap: 10px; overflow-x: auto; padding: 2px 16px 6px;
  margin: 0 -16px; scrollbar-width: none; }
.tpl-scroll::-webkit-scrollbar { display: none; }
.tpl-card { flex: 0 0 150px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.tpl-card .name { font-weight: 650; font-size: 14px; letter-spacing: -0.01em; }
.tpl-card .tpl-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.day-badge { flex: 0 0 auto; height: 20px; padding: 0 8px; border-radius: 10px;
  display: inline-flex; align-items: center;
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent-hi); }
.prog-note { font-size: 12.5px; color: var(--ink-2); font-weight: 500; line-height: 1.5;
  white-space: pre-line; padding: 12px 14px; margin-bottom: 12px; }
.tpl-card .meta { font-size: 11.5px; color: var(--ink-3); font-weight: 500; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 33px; }
.tpl-card .btn { margin-top: auto; }
.tpl-new { align-items: center; justify-content: center; color: var(--ink-3);
  border-style: dashed; min-height: 128px; font-weight: 600; font-size: 13px; gap: 6px;
  box-shadow: none; background: transparent; }
.tpl-new svg { width: 20px; height: 20px; stroke: currentColor; fill: none;
  stroke-width: 2.2; stroke-linecap: round; }

/* ---------------- List rows ---------------- */
.list { display: flex; flex-direction: column; gap: 8px; }
.row-card { padding: 12px 14px; display: flex; align-items: center; gap: 12px; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; font-size: 15px; letter-spacing: -0.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: 12.5px; color: var(--ink-3); font-weight: 500; margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-side { text-align: right; flex: 0 0 auto; }
.row-side .v { font-weight: 650; font-size: 14px; font-variant-numeric: tabular-nums; }
.row-side .l { font-size: 11px; color: var(--ink-4); font-weight: 550; }
.chevron { width: 15px; height: 15px; stroke: var(--ink-4); fill: none;
  stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
.muscle-dot { width: 36px; height: 36px; border-radius: 10px; flex: 0 0 auto;
  display: grid; place-items: center; font-size: 14px; font-weight: 700;
  background: var(--surf-2); border: 1px solid var(--line); }

.badge { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 8px;
  border-radius: 10px; font-size: 11px; font-weight: 700; letter-spacing: 0.02em; }
.badge-pr { background: var(--accent-soft); color: var(--accent);
  border: 1px solid var(--accent-hi); }
.badge-soft { background: var(--surf-2); color: var(--ink-2); border: 1px solid var(--line); }

.empty { text-align: center; padding: 40px 24px; color: var(--ink-3); }
.empty .big { display: flex; justify-content: center; margin-bottom: 14px; }
.empty p { font-size: 13.5px; font-weight: 500; line-height: 1.55; }

/* ---------------- Workout screen ---------------- */
.workout-bar {
  position: fixed; left: 12px; right: 12px;
  bottom: calc(var(--tabbar-total) + 8px);
  z-index: 39; border-radius: var(--r-lg); padding: 10px 14px;
  display: flex; align-items: center; gap: 11px;
  background: var(--chrome);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.35s var(--spring);
  transition: transform 0.25s var(--ease-out);
}
.workout-bar:active { transform: scale(0.99); }
.workout-bar .pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--green);
  box-shadow: 0 0 0 0 rgba(122, 178, 111, 0.5); animation: pulse 1.8s infinite; flex: 0 0 auto; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(122, 178, 111, 0.45); }
  70% { box-shadow: 0 0 0 8px rgba(122, 178, 111, 0); }
  100% { box-shadow: 0 0 0 0 rgba(122, 178, 111, 0); }
}
.workout-bar .wtitle { flex: 1; min-width: 0; }
.workout-bar .wtitle .t { font-weight: 600; font-size: 14px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.workout-bar .wtitle .s { font-size: 12px; color: var(--ink-3); font-weight: 550;
  font-variant-numeric: tabular-nums; }
.workout-bar .rest-inline { color: var(--accent); font-variant-numeric: tabular-nums; }

.wk-meta { display: flex; gap: 8px; margin: 2px 0 14px; }
.wk-meta .m { flex: 1; text-align: center; padding: 9px 4px; border-radius: 14px; }
.wk-meta .v { font-family: var(--serif); font-size: 17px; font-weight: 600;
  font-variant-numeric: tabular-nums; }
.wk-meta .l { font-size: 10px; color: var(--ink-3); font-weight: 650;
  text-transform: uppercase; letter-spacing: 0.06em; margin-top: 1px; }

.ex-block { margin-bottom: 12px; padding: 12px 12px 10px; }
.ex-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.ex-head .name { flex: 1; font-weight: 650; font-size: 15.5px; letter-spacing: -0.01em;
  color: var(--accent); min-width: 0; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; }
.ex-head .prev { font-size: 11px; color: var(--ink-3); font-weight: 550; flex: 0 0 auto; }
.ex-target { font-size: 11.5px; font-weight: 600; color: var(--accent);
  margin: -4px 0 8px; letter-spacing: 0.01em; }
.ex-head .icon-btn { width: 32px; height: 32px; box-shadow: none; }
.ex-head .icon-btn svg { width: 16px; height: 16px; }

.set-grid { display: grid; grid-template-columns: 38px 1fr 68px 68px 44px; gap: 6px;
  align-items: center; }
.set-grid .hd { font-size: 10px; font-weight: 650; color: var(--ink-4);
  text-transform: uppercase; letter-spacing: 0.06em; text-align: center; padding: 2px 0 3px; }
.set-tag { height: 44px; border-radius: var(--r-sm); display: grid; place-items: center;
  font-size: 13px; font-weight: 700; color: var(--ink-2); text-align: center;
  background: var(--surf-2); border: 1px solid var(--line);
  transition: transform 0.25s var(--ease-out); font-variant-numeric: tabular-nums; }
.set-tag:active { transform: scale(0.94); }
.set-tag.warm { color: var(--amber); }
.set-tag.drop { color: var(--violet); }
.set-tag.fail { color: var(--red); }
.set-prev { font-size: 12px; color: var(--ink-4); font-weight: 550; text-align: center;
  font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden;
  align-self: center; padding: 12px 0; }
.set-in { height: 44px; border-radius: var(--r-sm); text-align: center; width: 100%;
  background: var(--input-bg); border: 1px solid var(--line);
  color: var(--ink); font-size: 16px; font-weight: 650; outline: none;
  font-variant-numeric: tabular-nums; transition: border-color 0.15s, background 0.15s; }
.set-in:focus { border-color: var(--accent-hi); }
.set-in::placeholder { color: var(--ink-4); font-weight: 550; }
.set-check { width: 44px; height: 44px; border-radius: var(--r-sm); margin: 0 auto;
  display: grid; place-items: center;
  background: var(--input-bg); border: 1.5px solid var(--line-2);
  transition: background 0.25s var(--ease-out), border-color 0.2s, transform 0.25s var(--ease-out); }
.set-check:active { transform: scale(0.94); }
.set-check svg { width: 17px; height: 17px; stroke: var(--ink-4); fill: none;
  stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; transition: stroke 0.15s; }
.set-check.done { background: var(--green); border-color: transparent; }
.set-check.done svg { stroke: #fff; }
.set-in.set-done-row { background: rgba(92, 133, 82, 0.10);
  border-color: rgba(92, 133, 82, 0.35); }
@media (prefers-color-scheme: dark) {
  .set-in.set-done-row { background: rgba(121, 178, 111, 0.10);
    border-color: rgba(121, 178, 111, 0.35); }
}
.ex-actions { display: flex; gap: 6px; margin-top: 10px; }
.ex-actions .btn { flex: 1; box-shadow: none; background: var(--surf-2); border-color: var(--line); }

/* ---------------- Rest timer pill ---------------- */
.rest-pill {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-total) + 8px);
  z-index: 60; display: flex; align-items: center; gap: 9px;
  height: 52px; padding: 0 12px 0 9px; border-radius: 26px;
  /* the pill floats above pushed screens — never let its padding eat a tap
     meant for the set input underneath it */
  pointer-events: none;
  background: var(--chrome);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.35s var(--spring);
}
#workout-bar:not([hidden]) + .rest-pill { display: none; }
.rest-ring { position: relative; width: 32px; height: 32px; }
.rest-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.rest-time { font-family: var(--serif); font-size: 17px; font-weight: 600;
  font-variant-numeric: tabular-nums; min-width: 46px; }
.rest-pill .icon-btn { width: 34px; height: 34px; background: var(--surf-2); box-shadow: none;
  pointer-events: auto; }
.rest-pill .rest-ring, .rest-pill .rest-time { pointer-events: auto; }

/* A pushed screen covers the tab bar, so dock the pill to the screen's own
   bottom edge. Shrinking the scroll viewport (margin, not padding) is what
   guarantees no row can ever sit underneath the pill and swallow a tap. */
body.screen-open .rest-pill { bottom: max(var(--sab), 12px); }
body.screen-open.rest-open .screen-body { margin-bottom: calc(max(var(--sab), 12px) + 60px); }
body.rest-open:not(.screen-open) .tab-panel { padding-bottom: calc(var(--tabbar-total) + 92px); }

/* ---------------- Charts ---------------- */
.chart-card { padding: 14px 14px 12px; margin-bottom: 12px; }
.chart-title { font-size: 14px; font-weight: 650; margin-bottom: 1px; letter-spacing: -0.01em; }
.chart-sub { font-size: 12px; color: var(--ink-3); font-weight: 500; margin-bottom: 10px; }
.chart-wrap { position: relative; }
.chart-wrap svg { width: 100%; height: auto; overflow: visible; }
.chart-wrap text { font-family: var(--sans); }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 5;
  background: var(--surf); border: 1px solid var(--line-2);
  border-radius: 10px; padding: 6px 10px; font-size: 12px; font-weight: 600;
  box-shadow: var(--shadow-lg); white-space: nowrap;
  transform: translate(-50%, calc(-100% - 10px));
  transition: opacity 0.15s; opacity: 0;
}
.chart-tip .tl { color: var(--ink-3); font-size: 11px; font-weight: 550; }
.chart-tip .tv { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.chart-empty { padding: 28px 10px; text-align: center; color: var(--ink-4);
  font-size: 13px; font-weight: 500; }

.stat-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.stat-tile { padding: 13px 14px; }
.stat-tile .l { font-size: 12px; color: var(--ink-3); font-weight: 550; }
.stat-tile .v { font-family: var(--serif); font-size: 24px; font-weight: 600;
  letter-spacing: -0.01em; margin-top: 3px; font-variant-numeric: tabular-nums; }
.stat-tile .v small { font-family: var(--sans); font-size: 12px; color: var(--ink-3);
  font-weight: 600; }
.stat-tile .d { font-size: 12px; font-weight: 600; margin-top: 3px; }
.stat-tile .d.up { color: var(--green); }
.stat-tile .d.down { color: var(--ink-3); }
.stat-tile .spark { margin-top: 8px; }

.heat-wrap { overflow-x: auto; scrollbar-width: none; }
.heat-wrap::-webkit-scrollbar { display: none; }

/* ---------------- Exercise picker ---------------- */
.picker-search { position: sticky; top: 0; z-index: 2; padding: 2px 0 10px; }
.picker-list { display: flex; flex-direction: column; gap: 6px; }
.picker-row { display: flex; align-items: center; gap: 11px; min-height: 56px;
  padding: 8px 12px; text-align: left;
  border-radius: 14px; background: var(--surf-2); border: 1px solid var(--line);
  transition: transform 0.25s var(--ease-out), background 0.15s; }
.picker-row:active { transform: scale(0.99); background: var(--surf-3); }
.picker-row.selected { background: var(--accent-soft); border-color: var(--accent); }

/* ---------------- Plate calc ---------------- */
.plate-viz { display: flex; align-items: center; justify-content: center; gap: 3px;
  min-height: 110px; padding: 10px 0; }
.plate-bar { height: 9px; width: 32px; border-radius: 3px;
  background: linear-gradient(180deg, #a8a49a, #6e6a60); flex: 0 0 auto; }
.plate { border-radius: 4px; display: grid; place-items: center;
  font-size: 10px; font-weight: 700; color: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 2px 6px rgba(20, 20, 19, 0.3);
  animation: plate-in 0.3s var(--spring); flex: 0 0 auto; }
@keyframes plate-in { from { transform: scale(0.7) translateY(6px); opacity: 0; } }

.kbd-steppers { display: flex; gap: 8px; justify-content: center; margin-top: 12px; }

/* ---------------- Settings ---------------- */
.set-list { display: flex; flex-direction: column; border-radius: var(--r-lg); overflow: hidden; }
.set-row-item { display: flex; align-items: center; gap: 12px; min-height: 48px;
  padding: 6px 16px; text-align: left;
  border-bottom: 1px solid var(--line); }
.set-row-item:last-child { border-bottom: none; }
.set-row-item .lab { flex: 1; font-size: 15px; font-weight: 550; }
.set-row-item .val { color: var(--ink-3); font-size: 14px; font-weight: 500;
  max-width: 45%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.switch { width: 48px; height: 29px; border-radius: 15px; position: relative;
  background: var(--surf-3); border: 1px solid var(--line);
  transition: background 0.25s; flex: 0 0 auto; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px;
  width: 23px; height: 23px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 4px rgba(20, 20, 19, 0.3); transition: transform 0.25s var(--spring); }
.switch.on { background: var(--green); }
.switch.on::after { transform: translateX(19px); }

/* ---------------- Glyph tiles (flat, warm tint) ---------------- */
.glyph-tile {
  border-radius: 30%; flex: 0 0 auto;
  display: grid; place-items: center;
  border: 1px solid;
  position: relative; overflow: hidden;
}

/* ---------------- Misc ---------------- */
.divider { height: 1px; background: var(--line); margin: 16px 0; }
.center { text-align: center; }
.mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; } .mb8 { margin-bottom: 8px; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 200; overflow: hidden; }
.confetti i { position: absolute; width: 7px; height: 11px; border-radius: 2px; top: -20px;
  animation: confetti-fall 1.6s ease-in forwards; }
@keyframes confetti-fall {
  to { transform: translateY(110vh) rotate(720deg); opacity: 0.6; }
}
