@font-face {
  font-family: 'Berkeley Mono';
  src: url('fonts/BerkeleyMono-Regular.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Berkeley Mono';
  src: url('fonts/BerkeleyMono-Bold.otf') format('opentype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Berkeley Mono';
  src: url('fonts/BerkeleyMono-Oblique.otf') format('opentype');
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: 'Berkeley Mono';
  src: url('fonts/BerkeleyMono-Bold-Oblique.otf') format('opentype');
  font-weight: 700;
  font-style: italic;
  font-display: swap;
}

:root {
  --bg: #221c1c;
  --surface: #342a2a;
  --surface-2: #443535;
  --border: #9a7a7a;
  --fg: #f0e4d8;
  --muted: #c4a8a0;
  --dim: #8a6e6e;
  --bright: #fff6ea;
  --accent: #e85a9a;
  --accent-dim: rgba(232, 90, 154, 0.18);
  --good: #b0b57a;
  --warn: #ff8a55;
  --bad: #c41822;
  --info: #ff8a55;
  --protein: #e85a9a;
  --carbs: #ff8a55;
  --fat: #5b8fbf;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --nav-h: 4.5rem;
  --radius: 14px;
}

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

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: 'Berkeley Mono', ui-monospace, monospace;
  overscroll-behavior: none;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

.mono { font-family: 'Berkeley Mono', ui-monospace, monospace; }
.hidden { display: none !important; }

/* ─── Lock ─── */
html.has-session #lock-screen { display: none !important; }
html.has-session #app { display: block; }

#lock-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(232, 90, 154, 0.14), transparent),
    var(--bg);
}

.lock-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2rem 1.5rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}

.lock-mark {
  display: flex;
  justify-content: center;
  margin-bottom: 1rem;
}

.lock-card h1 {
  margin: 0 0 0.35rem;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  text-align: center;
}

.lock-card .sub {
  color: var(--muted);
  font-size: 0.92rem;
  margin: 0 0 1.5rem;
  text-align: center;
}

.lock-card label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.4rem;
  font-weight: 500;
}

.lock-card input[type='password'] {
  width: 100%;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  margin-bottom: 1rem;
  outline: none;
}

.lock-card input:focus { border-color: var(--accent); }

.lock-card .btn-primary { width: 100%; }

.lock-error {
  color: var(--bad);
  font-size: 0.85rem;
  margin: 0 0 0.75rem;
  min-height: 1.2em;
}

/* ─── App shell ─── */
#app {
  display: none;
  min-height: 100dvh;
  padding-bottom: calc(var(--nav-h) + var(--safe-b) + 1.25rem);
}

#app.ready { display: block; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(34, 28, 28, 0.94);
  backdrop-filter: blur(12px);
  border-bottom: none;
  padding: 0;
}

.pix-week {
  display: flex;
  gap: 5px;
  align-items: stretch;
  width: 100%;
  border: none;
  border-bottom: 2px solid var(--border);
  border-radius: 0;
  background: #1a1515;
  padding: calc(6px + var(--safe-t)) 8px 6px;
  cursor: pointer;
  image-rendering: pixelated;
  box-shadow: inset 0 -1px 0 #140f0f;
  touch-action: manipulation;
  user-select: none;
}

.pix-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 3px;
  min-width: 0;
  padding: 0;
  transform: translateY(0);
  transition: transform 0.06s steps(1);
}

.pix-col.press {
  transform: translateY(2px);
  filter: brightness(1.18);
}

.pix-over {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.pix-goal {
  height: 0;
  border-top: 1px dashed var(--border);
  width: 100%;
}

.pix-stack,
.pix-over {
  width: 100%;
}

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

.pix-stack i,
.pix-over i {
  width: 100%;
  height: 4px;
  display: block;
  background: #342a2a;
}

.pix-stack i.ok,
.pix-over i.ok { background: var(--good); }
.pix-stack i.near { background: var(--warn); }
.pix-stack i.hot,
.pix-over i.hot { background: var(--bad); }

.pix-lab {
  font-family: 'Berkeley Mono', ui-monospace, monospace;
  font-size: 0.62rem;
  line-height: 1;
  color: var(--muted);
  font-weight: 600;
  text-align: center;
}

.pix-col.today .pix-lab { color: var(--accent); }
.pix-col.today .pix-stack i:not(.ok):not(.near):not(.hot),
.pix-col.today .pix-over i:not(.hot) { background: #4a3838; }
.pix-col.future { opacity: 0.42; }

main {
  padding: 1rem;
  max-width: 720px;
  margin: 0 auto;
}

.page { display: none; }
.page.active { display: block; }

/* ─── Date strip ─── */
.date-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.1rem;
  gap: 0.5rem;
}

.date-strip .when {
  text-align: center;
  flex: 1;
}

.date-strip .dow {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.date-strip .day {
  font-size: 1.05rem;
  font-weight: 700;
  margin-top: 0.1rem;
}

.date-strip .hint {
  font-size: 0.72rem;
  color: var(--dim);
  margin-top: 0.1rem;
}

/* ─── Rings ─── */
.rings {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0.2rem 0 1.25rem;
}

.kcal-ring {
  --p: 0;
  --c: var(--good);
  width: 11.6rem;
  height: 11.6rem;
  border-radius: 50%;
  background: conic-gradient(var(--c) calc(min(var(--p), 1) * 360deg), var(--surface-2) 0);
  display: grid;
  place-items: center;
  position: relative;
}

.kcal-ring.over {
  --c: var(--bad);
  background: conic-gradient(var(--bad) 360deg, var(--bad) 0);
}

.kcal-hole {
  width: 8.7rem;
  height: 8.7rem;
  border-radius: 50%;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  box-shadow: inset 0 0 0 1px var(--border);
}

.kcal-num {
  font-family: 'Berkeley Mono', ui-monospace, monospace;
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1;
}

.kcal-num.neg { color: var(--bad); }

.kcal-lbl {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  margin-top: 0.28rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.kcal-sub {
  font-size: 0.72rem;
  color: var(--dim);
  margin-top: 0.12rem;
  font-family: 'Berkeley Mono', ui-monospace, monospace;
}

.macro-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1rem;
  width: min(22rem, 100%);
  margin-top: 1.15rem;
}

.macro {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

.mini-ring {
  --p: 0;
  --c: var(--good);
  width: 4.4rem;
  height: 4.4rem;
  border-radius: 50%;
  background: conic-gradient(var(--c) calc(min(var(--p), 1) * 360deg), var(--surface-2) 0);
  display: grid;
  place-items: center;
}

.mini-ring.over { background: conic-gradient(var(--bad) 360deg, var(--bad) 0); }

.mini-hole {
  width: 3.15rem;
  height: 3.15rem;
  border-radius: 50%;
  background: var(--bg);
  display: grid;
  place-items: center;
  font-family: 'Berkeley Mono', ui-monospace, monospace;
  font-size: 0.72rem;
  font-weight: 600;
}

.macro .tag {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.macro .left {
  font-size: 0.72rem;
  color: var(--dim);
  font-family: 'Berkeley Mono', ui-monospace, monospace;
}

.macro .left.neg { color: var(--bad); }

/* ─── Cards / lists ─── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.75rem;
}

.card h2 {
  margin: 0 0 0.75rem;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0.4rem 0 0.65rem;
  gap: 0.5rem;
}

.list-head h2 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  text-transform: none;
  letter-spacing: -0.02em;
  color: var(--fg);
}

.row-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem 0.9rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
}

.row-card .row-body { min-width: 0; flex: 1; }

.star-btn {
  flex-shrink: 0;
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--dim);
  font-size: 1.15rem;
  cursor: pointer;
  line-height: 1;
}

.star-btn.on { color: var(--warn); border-color: rgba(251, 191, 36, 0.45); }

.star-btn.spacer {
  border: none;
  background: transparent;
  pointer-events: none;
}

.qty-presets {
  display: flex;
  gap: 0.35rem;
  margin: 0.35rem 0 0.55rem;
}

.undo-toast {
  position: fixed;
  left: 0.85rem;
  right: 0.85rem;
  bottom: calc(var(--nav-h) + var(--safe-b) + 0.65rem);
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
}

.undo-toast[hidden] { display: none !important; }

.undo-toast #btn-undo {
  border: none;
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 700;
  border-radius: 9px;
  padding: 0.4rem 0.7rem;
  cursor: pointer;
}

.row-card:active { border-color: var(--accent); }

.row-card .title {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.2rem;
}

.row-card .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.65rem;
  font-size: 0.78rem;
  color: var(--muted);
  font-family: 'Berkeley Mono', ui-monospace, monospace;
}

.badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.12rem 0.42rem;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
  font-family: 'Berkeley Mono', ui-monospace, monospace;
  letter-spacing: 0.02em;
}

.empty {
  text-align: center;
  color: var(--dim);
  padding: 1.6rem 1rem;
  font-size: 0.9rem;
}

.section-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--dim);
  margin: 0.85rem 0 0.45rem;
}

/* ─── Buttons ─── */
.btn-primary, .btn-secondary, .btn-ghost, .btn-danger {
  border: none;
  border-radius: 11px;
  padding: 0.7rem 1rem;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}

.btn-primary {
  background: var(--accent);
  color: #221c1c;
}

.btn-primary:disabled {
  opacity: 0.55;
  cursor: wait;
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--fg);
  border: 1px solid var(--border);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
}

.btn-danger {
  background: rgba(248, 113, 113, 0.15);
  color: var(--bad);
  border: 1px solid rgba(248, 113, 113, 0.3);
}

.btn-sm {
  padding: 0.45rem 0.75rem;
  font-size: 0.8rem;
  border-radius: 9px;
}

.btn-icon {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--fg);
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:disabled { opacity: 0.4; }

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.chip {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--fg);
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.chip.active {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
}

.action-list button {
  width: 100%;
  text-align: left;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  margin-bottom: 0.45rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
}

.action-list button span {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.82rem;
}

.fab { display: none !important; }

.log-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin: 0.15rem 0 0.35rem;
}

.log-actions button {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 14px;
  min-height: 4.6rem;
  padding: 1rem 0.5rem 0.85rem;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.log-actions button:active { border-color: var(--accent); background: var(--accent-dim); }

.log-actions .act-ico { font-size: 1.5rem; line-height: 1; }
.log-actions .act-ico svg {
  display: block;
  width: 1.45rem;
  height: 1.45rem;
}

.log-hint {
  margin: 0 0 0.85rem;
  font-size: 0.75rem;
  color: var(--dim);
  text-align: center;
  line-height: 1.35;
}

/* ─── Bottom nav ─── */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: flex;
  background: rgba(52, 42, 42, 0.96);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  padding: 0.35rem 0.4rem calc(0.35rem + var(--safe-b));
}

.bottom-nav button {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--dim);
  padding: 0.4rem 0.2rem;
  cursor: pointer;
  font-size: 0.65rem;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
}

.bottom-nav button .ico { font-size: 1.15rem; line-height: 1; }
.bottom-nav button.active { color: var(--accent); }

/* ─── Modal ─── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, 0.55);
  display: none;
  align-items: flex-end;
  justify-content: center;
}

.modal-backdrop.open { display: flex; }

.modal {
  width: 100%;
  max-width: 560px;
  max-height: min(92dvh, 900px);
  overflow: auto;
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  border: 1px solid var(--border);
  border-bottom: none;
  padding: 1rem 1rem calc(1.25rem + var(--safe-b));
  animation: slideUp 0.2s ease;
}

@keyframes slideUp {
  from { transform: translateY(24px); opacity: 0.6; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  gap: 0.5rem;
}

.modal-head h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}

.form-grid { display: grid; gap: 0.75rem; }

.form-grid label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.3rem;
}

.form-grid input,
.form-grid select,
.form-grid textarea {
  width: 100%;
  padding: 0.7rem 0.8rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  outline: none;
}

.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus { border-color: var(--accent); }

.form-grid textarea { min-height: 72px; resize: vertical; }

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.5rem;
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1.1rem;
  flex-wrap: wrap;
}

.modal-actions .btn-primary,
.modal-actions .btn-secondary,
.modal-actions .btn-danger {
  flex: 1;
  min-width: 100px;
}

/* ─── Confirm items ─── */
.preview {
  width: 100%;
  max-height: 160px;
  object-fit: cover;
  border-radius: 12px;
  margin-bottom: 0.75rem;
  border: 1px solid var(--border);
}

.summary {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 0.9rem;
  line-height: 1.4;
}

.item-card {
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 12px;
  padding: 0.8rem;
  margin-bottom: 0.55rem;
}

.item-card .name { font-weight: 600; margin-bottom: 0.15rem; }
.item-card .brand { font-size: 0.78rem; color: var(--muted); margin-bottom: 0.45rem; }

.stepper {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.stepper button {
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
  font-size: 1.1rem;
}

.stepper .qty {
  font-family: 'Berkeley Mono', ui-monospace, monospace;
  font-weight: 600;
  min-width: 2.4rem;
  text-align: center;
}

.item-macros {
  font-family: 'Berkeley Mono', ui-monospace, monospace;
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.45rem;
}

.scan-video {
  width: 100%;
  border-radius: 12px;
  background: #000;
  max-height: 52dvh;
  object-fit: cover;
}

.week-strip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.week-day {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.4rem 0.15rem 0.5rem;
  text-align: center;
  cursor: pointer;
}

.week-day.active { border-color: var(--accent); }
.week-day.today .d { color: var(--accent); }
.week-day .d {
  font-size: 0.62rem;
  color: var(--dim);
  font-weight: 700;
  letter-spacing: 0.04em;
}

.week-mini {
  --p: 0;
  --c: var(--good);
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 50%;
  background: conic-gradient(var(--c) calc(min(var(--p), 1) * 360deg), var(--surface-2) 0);
  margin: 0.3rem auto 0.2rem;
}

.week-mini.over { background: conic-gradient(var(--bad) 360deg, var(--bad) 0); }

.week-day .n {
  font-size: 0.68rem;
  font-family: 'Berkeley Mono', ui-monospace, monospace;
  color: var(--muted);
}

.week-dots {
  display: flex;
  justify-content: center;
  gap: 3px;
  margin-top: 0.22rem;
  min-height: 4px;
}

.week-dots i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: transparent;
}

.week-dots i.ok:nth-child(1) { background: var(--protein); opacity: 0.4; }
.week-dots i.ok:nth-child(2) { background: var(--carbs); opacity: 0.4; }
.week-dots i.ok:nth-child(3) { background: var(--fat); opacity: 0.4; }
.week-dots i.hot { background: var(--bad); opacity: 1; }

.week-hero {
  display: flex;
  align-items: center;
  gap: 0.95rem;
  margin-bottom: 0.85rem;
}

.week-hero-ring {
  --p: 0;
  --c: var(--good);
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  background: conic-gradient(var(--c) calc(min(var(--p), 1) * 360deg), var(--bg) 0);
  position: relative;
  flex-shrink: 0;
}

.week-hero-ring::after {
  content: '';
  position: absolute;
  inset: 0.52rem;
  border-radius: 50%;
  background: var(--surface);
}

.week-hero-ring.over { background: conic-gradient(var(--bad) 360deg, var(--bad) 0); }

.week-hero .kcal-num { font-size: 1.55rem; text-align: left; }
.week-hero .kcal-lbl { text-align: left; }
.week-hero .kcal-sub { text-align: left; }

.pace-row {
  display: grid;
  grid-template-columns: 4.5rem 1fr auto;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.48rem;
}

.pace-lab {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.pace-track {
  height: 0.42rem;
  background: var(--bg);
  border-radius: 99px;
  overflow: hidden;
}

.pace-track i {
  display: block;
  height: 100%;
  border-radius: 99px;
  min-width: 0;
}

.pace-val {
  font-family: 'Berkeley Mono', ui-monospace, monospace;
  font-size: 0.72rem;
  color: var(--dim);
  min-width: 4.8rem;
  text-align: right;
}

.pace-val.neg { color: var(--bad); }

.even-list {
  margin: 0;
  padding-left: 1.15rem;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.even-list li { margin: 0.4rem 0; }
.even-list .neg { color: var(--fg); }
.even-list .neg strong { color: var(--bad); }

.week-tap-hint {
  text-align: center;
  color: var(--dim);
  font-size: 0.82rem;
  margin: 0 0 1rem;
}

.week-day-macros {
  font-family: 'Berkeley Mono', ui-monospace, monospace;
  font-size: 0.78rem;
  color: var(--muted);
  margin: -0.2rem 0 0.75rem;
}

.week-log .row-card {
  padding: 0.65rem 0.75rem;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.stat {
  background: var(--surface-2);
  border-radius: 12px;
  padding: 0.75rem;
}

.stat.wide { grid-column: 1 / -1; }

.stat .label {
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.stat .value {
  font-size: 1.1rem;
  font-weight: 700;
  font-family: 'Berkeley Mono', ui-monospace, monospace;
  letter-spacing: -0.02em;
}

.weight-card {
  padding: 0.7rem 0.85rem 0.75rem;
}

.weight-card h2 {
  margin: 0 0 0.4rem;
}

.weight-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.weight-latest {
  font-family: 'Berkeley Mono', ui-monospace, monospace;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.weight-row .btn-primary {
  flex: 0 0 auto;
  padding: 0.45rem 0.85rem;
  font-size: 0.82rem;
}

.weight-avgs {
  margin-top: 0.35rem;
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}

#w-avgs .weight-avgs {
  margin: 0.85rem 0 0;
}

.w-hist-row {
  display: grid;
  grid-template-columns: 1fr auto 3.2rem;
  gap: 0.65rem;
  align-items: center;
  padding: 0.42rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}

.w-hist-row:last-child { border-bottom: none; }

.w-hist-date { color: var(--muted); }
.w-hist-lb {
  font-weight: 700;
  text-align: right;
}
.w-delta {
  text-align: right;
  font-size: 0.78rem;
  color: var(--dim);
}
.w-delta.down { color: var(--good); }
.w-delta.up { color: var(--warn); }

#w-more {
  width: 100%;
  margin-top: 0.35rem;
}

.busy-note {
  text-align: center;
  color: var(--muted);
  padding: 1.5rem 0.5rem;
}

.busy-note .spin {
  width: 1.6rem;
  height: 1.6rem;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 0.75rem;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 720px) {
  .modal-backdrop { align-items: center; padding: 1rem; }
  .modal {
    border-radius: 18px;
    border-bottom: 1px solid var(--border);
    max-height: 90dvh;
  }
}
