/* LiveFit Trainer. Flat paper surfaces, hairline rules, one green accent. */
:root {
  --paper: #faf9f5;
  --paper-raised: #ffffff;
  --paper-deep: #f1efe8;
  --ink: #1d1a16;
  --text: #2b2721;
  --muted: #6f6a5e;
  --faint: #9a9484;
  --rule: rgba(29, 26, 22, 0.14);
  --accent: #2e6b34;
  --accent-deep: #245528;
  --accent-soft: #e7efe4;
  --warn: #8a5a12;
  --radius: 10px;
  --tabbar-h: 60px;
  --timer-h: 52px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--text);
  font-family: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.45;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { color: var(--ink); margin: 0; }
.num, input[type="number"], input[type="text"].num, .timer-display, .set-target {
  font-variant-numeric: tabular-nums;
}

/* ---------------- buttons ---------------- */
.btn-primary {
  width: 100%;
  min-height: 52px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.btn-primary:active { background: var(--accent-deep); }
.btn-primary:disabled { opacity: 0.55; cursor: default; }
.btn-ghost {
  width: 100%;
  min-height: 48px;
  margin-top: 14px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font-weight: 600;
}
.btn-small {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--paper-raised);
  font-weight: 600;
  font-size: 0.9rem;
}
.btn-accent {
  min-height: 48px;
  padding: 0 18px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}
.btn-accent.is-done { background: var(--paper-deep); color: var(--accent-deep); }

/* ---------------- login ---------------- */
.login {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 18px;
}
.login-card { width: 100%; max-width: 400px; }
.login-mark { width: 56px; height: 56px; margin-bottom: 16px; }
.login-card h1 { font-size: 2rem; font-weight: 800; letter-spacing: -0.01em; }
.login-sub { color: var(--muted); margin: 8px 0 26px; }
.login-card label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 6px; color: var(--ink); }
.login-card input[type="email"] {
  width: 100%;
  min-height: 52px;
  padding: 0 14px;
  margin-bottom: 12px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper-raised);
}
.login-message { min-height: 1.4em; margin: 12px 0 0; font-weight: 600; }
.login-message.is-error { color: #9c2b1d; }
.login-message.is-ok { color: var(--accent-deep); }
.login-note { color: var(--faint); font-size: 0.88rem; margin-top: 16px; }

/* ---------------- app frame ---------------- */
.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
}
.appbar-title { display: flex; align-items: center; gap: 9px; font-weight: 800; color: var(--ink); }
.appbar-mark { width: 28px; height: 28px; }
.appbar-user { display: flex; align-items: center; gap: 8px; }
.user-chip { font-size: 0.88rem; color: var(--muted); font-weight: 600; }
.dev-banner {
  margin: 0;
  padding: 8px 16px;
  background: #fdf3dd;
  color: var(--warn);
  font-size: 0.88rem;
  font-weight: 600;
  border-bottom: 1px solid var(--rule);
}
main { padding: 18px 16px calc(var(--tabbar-h) + var(--timer-h) + 30px); max-width: 760px; margin: 0 auto; }
.view > h2 { font-size: 1.45rem; font-weight: 800; margin-bottom: 4px; }
.view-sub { color: var(--muted); margin: 0 0 18px; }

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  height: var(--tabbar-h);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: var(--paper-raised);
  border-top: 1px solid var(--rule);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  border: 0;
  background: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}
.tab svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.tab.active { color: var(--accent); }

/* ---------------- timer ---------------- */
.timer-bar {
  position: fixed;
  left: 0; right: 0;
  bottom: var(--tabbar-h);
  z-index: 29;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  background: var(--paper-raised);
  border-top: 1px solid var(--rule);
}
.timer-bar.is-running { border-top: 2px solid var(--accent); }
.timer-display {
  border: 0;
  background: none;
  font-size: 30px;
  font-weight: 800;
  color: var(--ink);
  padding: 0 4px;
  min-width: 86px;
  text-align: left;
}
.timer-bar.is-done .timer-display { color: var(--accent); }
.timer-controls { display: flex; gap: 8px; margin-left: auto; }
.timer-presets {
  position: absolute;
  left: 0; right: 0;
  bottom: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 14px;
  background: var(--paper-raised);
  border-top: 1px solid var(--rule);
}
.timer-presets button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--paper);
  font-weight: 700;
}

/* ---------------- program view ---------------- */
.phase-block { margin-bottom: 30px; }
.phase-head { border-bottom: 2px solid var(--ink); padding-bottom: 8px; margin-bottom: 6px; }
.phase-head h3 { font-size: 1.15rem; font-weight: 800; }
.phase-head p { margin: 4px 0 0; color: var(--muted); font-size: 0.94rem; }
.week-block { margin-top: 16px; }
.week-block h4 { margin: 0 0 6px; font-size: 0.95rem; font-weight: 700; color: var(--ink); }
.week-intro { color: var(--muted); font-size: 0.92rem; margin: 0 0 10px; }
.day-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.day-chip {
  position: relative;
  text-align: left;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper-raised);
  padding: 10px 10px 9px;
  min-height: 74px;
}
.day-chip .d-num { font-weight: 800; color: var(--ink); font-size: 0.95rem; }
.day-chip .d-title { display: block; color: var(--muted); font-size: 0.8rem; line-height: 1.3; margin-top: 2px; }
.day-chip.is-rest { background: var(--paper-deep); }
.day-chip.is-done { border-color: var(--accent); }
.day-chip .d-check {
  position: absolute; top: 8px; right: 8px;
  width: 18px; height: 18px; color: var(--accent);
}
.carb-badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  vertical-align: middle;
}
.carb-low { background: var(--accent-soft); color: var(--accent-deep); }
.carb-high { background: #f6e3ba; color: var(--warn); }
.continue-card {
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent-soft);
  padding: 14px;
  margin-bottom: 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.continue-card p { margin: 0; font-weight: 700; color: var(--ink); }
.continue-card small { color: var(--muted); font-weight: 500; }

/* ---------------- day view ---------------- */
.day-head { margin-bottom: 14px; }
.day-head .back-link { border: 0; background: none; color: var(--accent); font-weight: 700; padding: 6px 0; }
.day-head h2 { font-size: 1.5rem; font-weight: 800; }
.day-meta { color: var(--muted); margin: 4px 0 0; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.day-note {
  border-left: 3px solid var(--accent);
  background: var(--paper-raised);
  padding: 10px 12px;
  margin: 0 0 12px;
  font-size: 0.94rem;
}
.progress-line { color: var(--muted); font-size: 0.9rem; font-weight: 600; margin: 10px 0 16px; }
.group-label {
  margin: 20px 0 8px;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--accent-deep);
}
.exercise {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper-raised);
  padding: 12px;
  margin-bottom: 10px;
}
.exercise-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.exercise-name { font-weight: 700; color: var(--ink); font-size: 1.02rem; }
.exercise-target { color: var(--muted); font-size: 0.9rem; margin-top: 1px; }
.exercise-note { color: var(--muted); font-size: 0.88rem; margin-top: 2px; }
.guide-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--paper);
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--accent-deep);
}
.guide-btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.last-time { color: var(--faint); font-size: 0.85rem; margin: 8px 0 0; }
.sets { margin-top: 10px; border-top: 1px solid var(--rule); }
.set-row {
  display: grid;
  grid-template-columns: 44px 1fr 1fr 64px;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--rule);
}
.set-row:last-child { border-bottom: 0; }
.set-label { font-weight: 700; color: var(--muted); font-size: 0.88rem; }
.set-row input {
  width: 100%;
  height: 48px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--paper);
  padding: 0 10px;
  font-size: 1.05rem;
}
.set-row input::placeholder { color: var(--faint); }
.set-done {
  height: 48px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--paper);
  font-weight: 700;
  color: var(--muted);
}
.set-done.is-done { background: var(--accent); border-color: var(--accent); color: #fff; }
.set-head {
  display: grid;
  grid-template-columns: 44px 1fr 1fr 64px;
  gap: 8px;
  padding: 8px 0 2px;
  color: var(--faint);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.cardio-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.day-actions { display: flex; gap: 10px; margin: 20px 0 8px; flex-wrap: wrap; }
.rest-card, .cardio-card {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper-raised);
  padding: 18px 14px;
  text-align: center;
}
.rest-card p, .cardio-card p { color: var(--muted); }

/* ---------------- guides ---------------- */
.search-input {
  width: 100%;
  min-height: 50px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper-raised);
  padding: 0 14px;
  margin-bottom: 12px;
}
.guide-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--rule);
  background: none;
  padding: 13px 2px;
  font-weight: 600;
  color: var(--ink);
}
.guide-row .g-kind { color: var(--faint); font-size: 0.82rem; font-weight: 600; flex: none; }

/* ---------------- sheet ---------------- */
.sheet { position: fixed; inset: 0; z-index: 50; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(20, 18, 15, 0.45); }
.sheet-panel {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  max-height: 88dvh;
  overflow: auto;
  background: var(--paper);
  border-radius: 16px 16px 0 0;
  padding: 16px 16px calc(20px + env(safe-area-inset-bottom));
}
@media (min-width: 700px) {
  .sheet-panel { left: 50%; right: auto; transform: translateX(-50%); width: 640px; }
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.sheet-head h2 { font-size: 1.2rem; font-weight: 800; }
.sheet-body video, .sheet-body iframe {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  border-radius: var(--radius);
  background: #111;
  display: block;
}
.guide-photos { display: flex; gap: 8px; margin-bottom: 12px; }
.guide-photos figure { margin: 0; flex: 1; }
.guide-photos img { width: 100%; border-radius: var(--radius); display: block; background: var(--paper-deep); }
.guide-photos figcaption { color: var(--muted); font-size: 0.82rem; margin-top: 4px; text-align: center; }
.guide-note { color: var(--muted); font-size: 0.92rem; }
.guide-fallback { margin-top: 12px; }
.guide-fallback a { color: var(--accent-deep); font-weight: 600; }

/* ---------------- nutrition ---------------- */
.brief-card {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper-raised);
  padding: 14px;
  margin-bottom: 12px;
}
.brief-card h3 { font-size: 1rem; font-weight: 800; margin-bottom: 6px; }
.brief-card p { margin: 0; color: var(--text); font-size: 0.95rem; }
.calc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.calc-grid label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--ink); }
.calc-grid input, .calc-grid select {
  width: 100%;
  height: 48px;
  margin-top: 4px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--paper-raised);
  padding: 0 10px;
}
.calc-results { border-top: 2px solid var(--ink); margin-top: 18px; padding-top: 12px; }
.calc-results h3 { font-size: 1rem; font-weight: 800; margin-bottom: 8px; }
.result-row {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 9px 0; border-bottom: 1px solid var(--rule);
}
.result-row span { color: var(--muted); }
.result-row strong { color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------------- resources ---------------- */
.resource-list { display: grid; gap: 12px; }
.resource-card {
  min-height: 76px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper-raised);
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: inherit;
  text-decoration: none;
}
.resource-card:hover, .resource-card:focus-visible { border-color: var(--accent); }
.resource-copy { display: flex; flex-direction: column; gap: 3px; }
.resource-copy strong { color: var(--ink); font-size: 1rem; font-weight: 800; }
.resource-copy small { color: var(--muted); font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.resource-open { color: var(--accent-deep); font-weight: 700; white-space: nowrap; }

/* ---------------- about / misc ---------------- */
.about-block { margin-bottom: 18px; }
.about-block p { margin: 0 0 10px; }
.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + var(--timer-h) + 16px);
  z-index: 60;
  background: var(--ink);
  color: var(--paper);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  max-width: 88vw;
  text-align: center;
}
[hidden] { display: none !important; }
