/* ============================================================
   Type — Figtree, self-hosted so it works offline like the rest
   ============================================================ */
@font-face {
  font-family: 'Figtree';
  font-style: normal;
  font-weight: 400 800;   /* one variable file covers every weight used */
  font-display: swap;
  src: url('../assets/fonts/figtree-latin.woff2') format('woff2');
}

/* ============================================================
   Tokens — warm, pastel, light-first
   ============================================================ */
:root {
  color-scheme: light;

  /* Warm cream ground, olive ink. Nothing here is pure white or pure black. */
  --bg:        #f1eee1;
  --bg-2:      #f7f4ea;
  --surface:   #fcfaf1;
  --surface-2: #e9e5d5;
  --line:      #ddd8c5;
  --line-soft: #e7e3d2;

  --text:      #2b351c;
  --text-2:    #6b715a;
  --text-3:    #9b9c8a;

  --accent:      #626b3e;
  --accent-soft: #e4e5d3;
  --on-accent:   #fcfaf1;
  --good:        #626b3e;
  --danger:      #a85c2f;
  --danger-soft: #f1e3d6;

  /* Default face ink. Individual bubbles override it per fill via --ink. */
  --face: #242c1a;
  --mascot: #a5b18d;

  --radius:    22px;
  --radius-sm: 15px;
  --radius-lg: 30px;
  --pill:      999px;

  --tab-h: 62px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  --shadow:    0 2px 14px rgba(70, 82, 60, .07);
  --shadow-lg: 0 10px 34px rgba(50, 62, 42, .16);
  --font: 'Figtree', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
          system-ui, 'Helvetica Neue', sans-serif;
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --bg:        #1b1f16;
  --bg-2:      #22261a;
  --surface:   #292e1f;
  --surface-2: #343a26;
  --line:      #3d4430;
  --line-soft: #343a28;
  --text:      #edebdb;
  --text-2:    #a2a58f;
  --text-3:    #767963;
  --accent:      #a5b18d;
  --accent-soft: #2f3722;
  --on-accent:   #1b1f16;
  --good:        #a5b18d;
  --danger:      #c98455;
  --danger-soft: #38291d;
  --mascot: #8c9c70;
  --shadow:    0 2px 14px rgba(0, 0, 0, .3);
  --shadow-lg: 0 10px 34px rgba(0, 0, 0, .45);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --bg:        #1b1f16;
    --bg-2:      #22261a;
    --surface:   #292e1f;
    --surface-2: #343a26;
    --line:      #3d4430;
    --line-soft: #343a28;
    --text:      #edebdb;
    --text-2:    #a2a58f;
    --text-3:    #767963;
    --accent:      #a5b18d;
    --accent-soft: #2f3722;
    --on-accent:   #1b1f16;
    --good:        #a5b18d;
    --danger:      #c98455;
    --danger-soft: #38291d;
    --shadow:    0 2px 14px rgba(0, 0, 0, .3);
    --shadow-lg: 0 10px 34px rgba(0, 0, 0, .45);
  }
}

/* ============================================================
   Base
   ============================================================ */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; height: 100%; overscroll-behavior-y: none; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
  text-size-adjust: 100%;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
img { max-width: 100%; }
[hidden] { display: none !important; }

h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.015em; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001s !important; transition-duration: .001s !important; }
}

/* ============================================================
   App shell
   ============================================================ */
#app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(var(--tab-h) + var(--safe-bottom));
}

.appbar {
  position: sticky;
  top: 0;
  z-index: 30;
  padding: calc(var(--safe-top) + 12px) 18px 12px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(150%) blur(14px);
  -webkit-backdrop-filter: saturate(150%) blur(14px);
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
}

/* Mascot chip, left of the title */
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--surface);
  border-radius: var(--pill);
  padding: 5px 14px 5px 5px;
  box-shadow: var(--shadow);
  flex: 0 1 auto;
  min-width: 0;
}
.brand .bubble {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--mascot);
  color: var(--face);
  display: grid;
  place-items: center;
  flex: none;
}
.brand .bubble .face { width: 22px; height: 22px; }
.brand h1 { font-size: 16.5px; font-weight: 750; }

.appbar .sub {
  font-size: 12.5px;
  color: var(--text-2);
  font-weight: 600;
  white-space: nowrap;
  margin-left: auto;
}

.view {
  flex: 1;
  padding: 10px 16px 30px;
  max-width: 620px;
  width: 100%;
  margin: 0 auto;
  animation: fade .2s ease;
}
@keyframes fade { from { opacity: 0; transform: translateY(5px); } }

/* ============================================================
   Tab bar with a floating log button
   ============================================================ */
.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 40;
  display: flex;
  align-items: stretch;
  height: calc(var(--tab-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--surface);
  border-top: 1px solid var(--line-soft);
  box-shadow: 0 -2px 18px rgba(70, 82, 60, .06);
}

.tabbar .tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-3);
  font-size: 10.5px;
  font-weight: 700;
  transition: color .15s;
}
.tabbar .tab:nth-of-type(1),
.tabbar .tab:nth-of-type(2) { flex: 1; }
.tabbar .tab:nth-of-type(3) { flex: 2; }
.tabbar .notch { flex: 0 0 78px; }

.tabbar .tab svg { width: 23px; height: 23px; stroke-width: 1.9; }
.tabbar .tab[aria-current='page'] { color: var(--accent); }

.logbtn {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 12px);
  transform: translateX(-50%);
  z-index: 41;
  width: 62px; height: 62px;
  border-radius: 50%;
  background: var(--mascot);
  color: var(--face);
  display: grid;
  place-items: center;
  border: 4px solid var(--bg);
  box-shadow: 0 6px 18px rgba(80, 130, 70, .28);
  transition: transform .14s cubic-bezier(.34, 1.56, .64, 1);
}
.logbtn:active { transform: translateX(-50%) scale(.9); }
.logbtn .face { width: 34px; height: 34px; }
.logbtn .plus {
  position: absolute;
  right: -1px; bottom: -1px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  border: 2.5px solid var(--bg);
}
.logbtn .plus svg { width: 12px; height: 12px; stroke-width: 3.2; }

/* ============================================================
   Cards, buttons, pills
   ============================================================ */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.card-title {
  font-size: 12.5px;
  letter-spacing: .01em;
  color: var(--text-2);
  font-weight: 750;
  margin-bottom: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 46px;
  padding: 0 20px;
  border-radius: var(--pill);
  background: var(--surface-2);
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  transition: transform .1s, opacity .15s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn-primary { background: var(--accent); color: var(--on-accent); box-shadow: 0 3px 10px color-mix(in srgb, var(--accent) 30%, transparent); }
.btn-ghost { background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { display: flex; width: 100%; }
.btn-sm { min-height: 38px; padding: 0 15px; font-size: 13.5px; }
.btn svg { width: 18px; height: 18px; stroke-width: 2.2; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row > .btn { flex: 1 1 auto; }

.muted { color: var(--text-2); }
.tiny { font-size: 12.5px; line-height: 1.55; }
.empty {
  text-align: center;
  color: var(--text-2);
  padding: 26px 16px;
  font-size: 14.5px;
}

/* ============================================================
   Calendar — a face for every day
   ============================================================ */
.cal-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  margin: 4px 0 14px;
}
.cal-head .month {
  font-size: 19px;
  font-weight: 750;
  letter-spacing: -.01em;
  text-align: center;
  min-width: 152px;
}
.cal-head .month span { color: var(--text-3); font-weight: 600; }

.icon-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: var(--text-2);
  flex: none;
  transition: background .15s, transform .1s;
}
.icon-btn:active { background: var(--surface-2); transform: scale(.92); }
.icon-btn svg { width: 20px; height: 20px; stroke-width: 2.2; }

.cal-today-btn {
  position: absolute;
  right: 16px;
}
.cal-head-wrap { position: relative; display: flex; align-items: center; justify-content: center; }

.cal-dow {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 8px;
}
.cal-dow span {
  text-align: center;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-3);
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px 2px;
  touch-action: pan-y;
}

.day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 4px 0 6px;
  border-radius: 16px;
  transition: transform .12s cubic-bezier(.34, 1.56, .64, 1);
}
.day:active { transform: scale(.88); }
.day.is-out { opacity: .38; }
.day.is-blank { visibility: hidden; }

.day .bubble {
  position: relative;
  width: 100%;
  max-width: 44px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--fill, var(--surface-2));
  color: var(--ink, var(--face));
  display: grid;
  place-items: center;
}
.day .bubble .face { width: 74%; height: 74%; }

/* Nothing logged: a soft empty ring rather than a filled face. */
.day.is-empty .bubble {
  background: color-mix(in srgb, var(--line) 48%, transparent);
}
.day.is-future .bubble { background: color-mix(in srgb, var(--line) 24%, transparent); }

.day.is-today .bubble {
  box-shadow: 0 0 0 2.5px var(--bg), 0 0 0 5px var(--accent);
}


/* Second activity of the day, as a little companion dot. */
.day .extra {
  position: absolute;
  right: -1px; bottom: -1px;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--extra, var(--surface-2));
  border: 2.5px solid var(--bg);
  font-size: 8px;
  font-weight: 800;
  color: var(--face);
  display: grid;
  place-items: center;
  line-height: 1;
}

.day .num {
  font-size: 12px;
  font-weight: 650;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 3px;
}
.day.is-today .num { color: var(--accent); font-weight: 800; }
.day .num i {
  width: 3.5px; height: 3.5px;
  border-radius: 50%;
  background: var(--text-3);
  display: block;
}

.cal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 12px;
  margin: 18px 2px 4px;
  justify-content: center;
}
.cal-legend .lg {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-2);
  font-weight: 650;
}
.cal-legend .lg i { width: 9px; height: 9px; border-radius: 50%; }

/* ============================================================
   Stat tiles
   ============================================================ */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
  gap: 8px;
}
.stat {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 12px 6px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat .v {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -.02em;
  white-space: nowrap;
  overflow: hidden;
}
.stat .v.is-long { font-size: 14.5px; letter-spacing: -.02em; }
.stat .v small { font-size: 11px; font-weight: 700; color: var(--text-2); margin-left: 1px; }
.stat .k {
  font-size: 10px;
  color: var(--text-3);
  letter-spacing: .01em;
  font-weight: 700;
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================================
   Workout rows
   ============================================================ */
.wo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  margin-bottom: 8px;
  width: 100%;
  text-align: left;
  box-shadow: var(--shadow);
  transition: transform .1s;
}
.wo:active { transform: scale(.985); }
.wo .ic {
  width: 42px; height: 42px;
  flex: 0 0 42px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 20px;
}
.wo .body { flex: 1; min-width: 0; }
.wo .name {
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wo .meta {
  font-size: 12.5px;
  color: var(--text-2);
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
  margin-top: 1px;
  font-weight: 600;
}
.wo .src {
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: var(--pill);
  padding: 3px 7px;
}

/* ============================================================
   Sheets & dialogs
   ============================================================ */
.scrim {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(45, 55, 40, .34);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fade .16s ease;
}

.sheet {
  width: 100%;
  max-width: 620px;
  max-height: 100%;
  background: var(--bg);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  animation: slide-up .28s cubic-bezier(.22, 1, .36, 1);
}
@keyframes slide-up { from { transform: translateY(100%); } }

.sheet-grip {
  width: 42px; height: 4.5px;
  border-radius: var(--pill);
  background: var(--line);
  margin: 10px auto 2px;
  flex: none;
}
.sheet-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 18px 12px;
  flex: none;
}
.sheet-head h2 { font-size: 18px; flex: 1; min-width: 0; }
.sheet-head .date-sub { font-size: 12.5px; color: var(--text-2); font-weight: 600; }
.sheet-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 18px 18px;
}
.sheet-foot {
  flex: none;
  padding: 12px 18px max(14px, calc(14px + var(--safe-bottom)));
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: 0 -2px 16px rgba(70, 82, 60, .07);
  display: flex;
  gap: 8px;
}
.sheet-foot .btn { flex: 1; }

.dialog {
  align-self: center;
  margin: auto 20px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px;
  max-width: 360px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.dialog h3 { font-size: 17.5px; margin-bottom: 7px; }
.dialog p { color: var(--text-2); font-size: 14px; margin: 0 0 18px; }
.dialog-actions { display: flex; gap: 8px; }
.dialog-actions .btn { flex: 1; }

/* ============================================================
   Forms
   ============================================================ */
.field { margin-bottom: 15px; }
.field > label,
.field-label {
  display: block;
  font-size: 12.5px;
  font-weight: 750;
  color: var(--text-2);
  margin-bottom: 7px;
}

input[type='text'], input[type='number'], input[type='date'], input[type='time'],
input[type='password'], select, textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px 15px;
  background: var(--surface);
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 16px; /* keeps iOS from zooming on focus */
  font-weight: 600;
  outline: none;
  box-shadow: var(--shadow);
  transition: border-color .15s;
  appearance: none;
}
textarea { min-height: 88px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--text-3); font-weight: 500; }
select {
  background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%),
                    linear-gradient(135deg, var(--text-2) 50%, transparent 50%);
  background-position: calc(100% - 19px) 22px, calc(100% - 14px) 22px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 38px;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (max-width: 360px) { .grid-3 { grid-template-columns: repeat(2, 1fr); } }

.input-suffix { position: relative; }
.input-suffix span {
  position: absolute;
  right: 14px; top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  color: var(--text-3);
  font-weight: 700;
  pointer-events: none;
}
.input-suffix input { padding-right: 44px; }

/* Activity picker — pastel circles with a label underneath */
.type-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px 6px;
}
.type-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 650;
  color: var(--text-2);
  transition: transform .12s cubic-bezier(.34, 1.56, .64, 1);
}
.type-opt:active { transform: scale(.9); }
.type-opt .e {
  width: 54px; height: 54px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--pick) 30%, var(--surface));
  display: grid;
  place-items: center;
  font-size: 25px;
  line-height: 1;
  transition: box-shadow .15s, background .15s;
}
.type-opt[aria-pressed='true'] { color: var(--text); font-weight: 750; }
.type-opt[aria-pressed='true'] .e {
  background: var(--pick);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--pick) 34%, transparent);
}

/* Segmented control */
.seg {
  display: flex;
  background: var(--surface-2);
  border-radius: var(--pill);
  padding: 4px;
  gap: 3px;
}
.seg button {
  flex: 1;
  min-height: 38px;
  border-radius: var(--pill);
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-2);
  transition: background .15s, color .15s;
}
.seg button[aria-pressed='true'] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* Rating rows */
.rating { display: flex; gap: 5px; }
.rating button {
  flex: 1;
  min-height: 44px;
  border-radius: var(--pill);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-2);
  transition: transform .12s cubic-bezier(.34, 1.56, .64, 1), background .15s;
}
.rating button:active { transform: scale(.9); }
.rating button[aria-pressed='true'] {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 3px 9px color-mix(in srgb, var(--accent) 32%, transparent);
}
.rating-legend {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-3);
  margin-top: 6px;
  font-weight: 650;
  padding: 0 4px;
}

/* Settings rows */
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line-soft);
}
.row:last-child { border-bottom: none; }
.row .row-main { flex: 1; min-width: 0; }
.row .row-title { font-size: 15px; font-weight: 700; }
.row .row-sub { font-size: 12.5px; color: var(--text-2); margin-top: 1px; font-weight: 500; }
.row select, .row input[type='number'] { width: auto; min-width: 92px; min-height: 42px; }

/* Round pastel badge used down the left of settings & summary rows */
.emo {
  width: 40px; height: 40px;
  flex: none;
  border-radius: 50%;
  background: var(--accent-soft);
  display: grid;
  place-items: center;
  font-size: 19px;
}

.status-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--text-3);
  flex: none;
}
.status-dot.on { background: var(--good); box-shadow: 0 0 0 4px color-mix(in srgb, var(--good) 20%, transparent); }

/* ============================================================
   Charts
   ============================================================ */
.bars {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  height: 124px;
  padding-top: 6px;
}
.bars .bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  height: 100%;
}
.bars .bar {
  width: 100%;
  max-width: 24px;
  min-height: 4px;
  border-radius: var(--pill);
  background: var(--accent);
  transition: height .35s cubic-bezier(.22, 1, .36, 1);
}
.bars .bar.dim { background: var(--surface-2); }
.bars .bar-lbl { font-size: 9.5px; color: var(--text-3); font-weight: 650; }
.bars .bar-val { font-size: 10.5px; color: var(--text-2); font-weight: 750; }

.breakdown { display: flex; flex-direction: column; gap: 11px; }
.breakdown .bd { display: flex; align-items: center; gap: 10px; }
.breakdown .bd .e {
  width: 32px; height: 32px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 16px;
}
.breakdown .bd .nm { font-size: 13.5px; font-weight: 700; width: 66px; flex: none; }
.breakdown .bd .track {
  flex: 1;
  height: 9px;
  border-radius: var(--pill);
  background: var(--surface-2);
  overflow: hidden;
}
/* A span is inline by default, so width/height were being ignored entirely
   and every bar rendered as an empty track. */
.breakdown .bd .fill { display: block; height: 100%; border-radius: var(--pill); transition: width .35s ease; }
.breakdown .bd .n { font-size: 12.5px; color: var(--text-2); font-weight: 700; min-width: 52px; text-align: right; }

.dotgrid {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(7, 1fr);
  /* Without an explicit auto-column size these stretch to fill the card. */
  grid-auto-columns: minmax(0, 1fr);
  gap: 3px;
}
.dotgrid span {
  min-width: 0;
  aspect-ratio: 1;
  border-radius: 50%;
}

/* ============================================================
   Toast
   ============================================================ */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tab-h) + var(--safe-bottom) + 34px);
  transform: translate(-50%, 12px);
  z-index: 90;
  max-width: calc(100vw - 32px);
  padding: 12px 20px;
  border-radius: var(--pill);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  text-align: center;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast[data-kind='error'] { background: var(--danger-soft); color: var(--danger); }
.toast[data-kind='success'] { background: var(--accent-soft); color: var(--accent); }

/* ============================================================
   CSV import mapper
   ============================================================ */
.map-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--line-soft);
}
.map-row .col {
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.map-row .col small { display: block; font-weight: 500; color: var(--text-3); font-size: 11px; }
.map-row select { min-height: 42px; font-size: 14px; }

.spin {
  width: 15px; height: 15px;
  border: 2px solid color-mix(in srgb, currentColor 30%, transparent);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   Calendar lens switcher
   ============================================================ */
.lens-seg { margin-bottom: 14px; }
.lens-seg button { font-size: 12.5px; padding: 0 2px; }

/* Glyphs that stand in for a face on the non-workout lenses */
.day .bubble .glyph {
  font-weight: 800;
  color: var(--face);
  line-height: 1;
}
.day .bubble .glyph.e { font-size: 20px; }
.day .bubble .glyph.n { font-size: 14px; letter-spacing: -.02em; }

/* ============================================================
   Today's check-in card
   ============================================================ */
.checkin-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  transition: transform .1s;
}
.checkin-card:active { transform: scale(.985); }
.checkin-card .row-main { flex: 1; min-width: 0; display: block; }
.checkin-card .row-title,
.checkin-card .row-sub { display: block; }
.checkin-card .row-sub {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.checkin-card svg { width: 19px; height: 19px; stroke-width: 2.2; color: var(--text-3); flex: none; }

/* ============================================================
   Log chooser
   ============================================================ */
.choices { display: flex; flex-direction: column; gap: 10px; padding-bottom: 6px; }
.choice {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: transform .12s cubic-bezier(.34, 1.56, .64, 1);
}
.choice:active { transform: scale(.97); }
.choice-ic {
  width: 52px; height: 52px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 25px;
}
.choice-body { flex: 1; min-width: 0; }
.choice-title { display: block; font-size: 16px; font-weight: 750; }
.choice-sub { display: block; font-size: 12.5px; color: var(--text-2); font-weight: 550; margin-top: 1px; }

/* ============================================================
   Icon pick row (food)
   ============================================================ */
.pick-row { display: flex; gap: 6px; justify-content: space-between; }
.pick {
  /* aspect-ratio drives the height, so no max-height to squash it into an oval */
  flex: 1 1 0;
  max-width: 58px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: color-mix(in srgb, var(--pick) 26%, var(--surface));
  display: grid;
  place-items: center;
  transition: transform .12s cubic-bezier(.34, 1.56, .64, 1), box-shadow .15s, background .15s;
}
.pick:active { transform: scale(.9); }
.pick .e { font-size: 22px; line-height: 1; }
.pick[aria-pressed='true'] {
  background: var(--pick);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--pick) 34%, transparent);
}

/* ============================================================
   Line chart (weight)
   ============================================================ */
.linechart { width: 100%; height: 130px; display: block; overflow: visible; }
.linechart .ln { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.linechart .ar { fill: color-mix(in srgb, var(--accent) 14%, transparent); stroke: none; }
.linechart .pt { fill: var(--accent); }
.linechart .gl { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 4; }
.linechart text { font-size: 10px; font-weight: 700; fill: var(--text-3); }

/* ============================================================
   Tab bar with four tabs
   ============================================================ */
.tabbar .tab:nth-of-type(3) { flex: 1; }
.tabbar .tab:nth-of-type(4) { flex: 1; }

/* ============================================================
   Muscle / filter chips
   ============================================================ */
.chip-row {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }
.chip-wrap { flex-wrap: wrap; overflow: visible; gap: 6px; }
.chip-wrap .chip { min-height: 33px; padding: 0 11px; font-size: 12.5px; }
.chip-wrap .chip-n { font-size: 10px; padding: 1px 5px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  min-height: 36px;
  padding: 0 14px;
  border-radius: var(--pill);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 13.5px;
  font-weight: 650;
  color: var(--text-2);
  transition: transform .1s, background .15s, color .15s;
}
.chip:active { transform: scale(.94); }
.chip[aria-pressed='true'] {
  background: var(--pick, var(--accent));
  color: var(--ink, var(--face));
  font-weight: 750;
}
.chip-n {
  font-size: 11px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: var(--pill);
  background: color-mix(in srgb, var(--text) 10%, transparent);
}

/* ============================================================
   Exercise rows (picker, lift list, muscle view)
   ============================================================ */
.ex-list { display: flex; flex-direction: column; }

.ex-row {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  text-align: left;
  padding: 11px 4px;
  border-bottom: 1px solid var(--line-soft);
  transition: transform .1s;
}
.ex-row:active { transform: scale(.99); }
.ex-row:last-child { border-bottom: none; }
.ex-row.is-new .ex-name { color: var(--accent); }

.ex-dot {
  width: 12px; height: 12px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 800;
  color: var(--on-accent);
}
.ex-row.is-new .ex-dot { width: 20px; height: 20px; }

.ex-body { flex: 1; min-width: 0; }
.ex-name {
  display: block;
  font-size: 14.5px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ex-muscles {
  display: block;
  font-size: 12px;
  color: var(--text-2);
  font-weight: 550;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}
.ex-caret { color: var(--text-3); font-size: 13px; flex: none; }

/* ============================================================
   Lift: exercise cards and set rows
   ============================================================ */
.lift { display: flex; flex-direction: column; gap: 8px; }

.ex-card {
  background: var(--surface);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.ex-card.is-open { box-shadow: 0 0 0 1.5px var(--accent), var(--shadow); }

.ex-head {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  text-align: left;
  padding: 12px 13px;
}

.set-rows { padding: 0 13px; }
.set-row {
  display: grid;
  grid-template-columns: 22px 1fr 1fr 38px 28px;
  gap: 7px;
  align-items: center;
  margin-bottom: 7px;
}
.set-row input { min-height: 42px; padding: 8px 10px; text-align: center; box-shadow: none; border: 1.5px solid var(--line); }
.set-row .set-n { font-size: 12.5px; font-weight: 750; color: var(--text-3); text-align: center; }
.set-head span {
  font-size: 10.5px;
  font-weight: 750;
  color: var(--text-3);
  text-align: center;
}
.set-head { margin-bottom: 4px; }
.set-x {
  font-size: 19px;
  color: var(--text-3);
  line-height: 1;
  border-radius: 50%;
  height: 32px;
}
.set-x:active { background: var(--surface-2); }

.ex-actions { display: flex; gap: 8px; padding: 2px 13px 13px; }
.ex-actions .btn { flex: 1; }

.lift-total {
  text-align: center;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-2);
  padding: 8px 0 2px;
}

/* Marks an exercise that only assists the muscle being viewed. */
.src.assists {
  color: var(--text-3);
  background: var(--surface-2);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 700;
}

/* ============================================================
   Day score card
   ============================================================ */
.score-card { padding: 14px 16px 16px; }
.score-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.score-face {
  width: 46px; height: 46px;
  flex: none;
  border-radius: 50%;
  color: var(--ink, var(--face));
  display: grid;
  place-items: center;
}
.score-face .face { width: 34px; height: 34px; }
.score-card .bd .nm { color: var(--text-2); font-weight: 650; }
.score-card .bd .n { font-weight: 600; color: var(--text-2); text-align: right; }

/* A day scored from only one of the three components. */
.day.is-partial .bubble { opacity: .55; }

/* Bodyweight toggle inside a set row */
.set-bw {
  height: 42px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .02em;
  color: var(--text-3);
  border: 1.5px solid var(--line);
  transition: background .15s, color .15s;
}
.set-bw[aria-pressed='true'] {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
}

/* "Next time" nudge */
.next-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 13px 0;
}
.next-label {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  font-weight: 750;
  color: var(--text-3);
}
.next-btn {
  flex: none;
  min-height: 34px;
  padding: 0 11px;
  border-radius: var(--pill);
  font-size: 12.5px;
  font-weight: 750;
  color: var(--text-2);
  border: 1.5px solid var(--line);
  transition: background .15s, color .15s, border-color .15s;
}
.next-btn[aria-pressed='true'] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.next-hint {
  padding: 8px 13px 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}

/* The marker as it appears on a collapsed exercise */
.nextmark {
  flex: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 800;
  background: var(--accent-soft);
  color: var(--accent);
}

/* ============================================================
   Unfinished workout
   ============================================================ */
.draft-card { padding: 0; overflow: hidden; }
.draft-main {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  transition: transform .1s;
}
.draft-main:active { transform: scale(.985); }
.draft-main .row-main { flex: 1; min-width: 0; display: block; }
.draft-main .row-title,
.draft-main .row-sub { display: block; }
/* Wraps rather than truncates: the "left 20 minutes ago" is the half that matters. */
.draft-main .row-sub { line-height: 1.35; }
.draft-main svg { width: 19px; height: 19px; stroke-width: 2.2; color: var(--text-3); flex: none; }
.draft-discard {
  width: 100%;
  padding: 11px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-3);
  border-top: 1px solid var(--line-soft);
}
.draft-discard:active { background: var(--surface-2); }
