/* ============================================================================
   Willow — Health & Training
   Identity: calm, minimal, roomy. Cool sage-mist paper, muted eucalyptus accent,
   a soft optical serif (Fraunces) reserved for the wordmark and big numbers.
   Deliberately distinct from the sibling apps (warm cream/serif Diet,
   dark-slate/cyan Strength). Retheme by editing the tokens on :root.
   ========================================================================== */

:root {
  /* surfaces */
  --bg:        #E9ECE7;   /* cool sage-mist paper */
  --surface:   #FBFCFA;   /* card */
  --surface-2: #F1F3EE;   /* raised/inset */
  --line:      #DBE0D9;   /* hairline */

  /* ink */
  --ink:       #2C352F;   /* deep muted forest */
  --ink-soft:  #64716A;   /* secondary text */
  --ink-faint: #97A199;   /* captions */

  /* accent + supporting */
  --accent:      #6F8C7D; /* muted eucalyptus */
  --accent-deep: #50695B;
  --accent-soft: #DCE6DF; /* tint for tracks/fills */
  --clay:        #BF8871; /* warm secondary, used sparingly (streaks/goal-met) */
  --clay-soft:   #EEDFD7;

  --good: #6F8C7D;
  --warn: #C0904F;
  --bad:  #B96A5B;

  /* muscle-group / category colours (all muted) */
  --cat-legs:   #7E9AA6;
  --cat-push:   #BF8871;
  --cat-pull:   #8E86A8;
  --cat-core:   #B39A5C;
  --cat-cardio: #6F8C7D;
  --cat-other:  #99A29A;

  --radius:    16px;
  --radius-sm: 10px;
  --shadow:    0 1px 2px rgba(44,53,47,.04), 0 10px 30px rgba(44,53,47,.06);
  --shadow-sm: 0 1px 2px rgba(44,53,47,.06);

  --rail: 232px;
  --maxw: 1080px;

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Hanken Grotesk", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
}
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
a { color: var(--accent-deep); }
button { font-family: inherit; }

/* ---- layout --------------------------------------------------------------- */
.app { display: flex; min-height: 100vh; }

.rail {
  width: var(--rail);
  flex: 0 0 var(--rail);
  padding: 26px 18px;
  border-right: 1px solid var(--line);
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px;
  background: var(--bg);
}
.wordmark {
  font-family: var(--font-display);
  font-size: 25px; font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--ink);
  padding: 4px 10px 22px;
  display: flex; align-items: baseline; gap: 8px;
}
.wordmark .leaf { color: var(--accent); font-size: 20px; }
.wordmark small { font-family: var(--font-body); font-size: 11px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--ink-faint); font-weight: 600; }

.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: var(--radius-sm);
  color: var(--ink-soft); text-decoration: none; font-weight: 500;
  cursor: pointer; border: none; background: none; width: 100%; text-align: left;
  font-size: 14.5px; transition: background .15s, color .15s;
}
.nav-link .ico { width: 18px; height: 18px; opacity: .8; flex: 0 0 18px; }
.nav-link:hover { background: var(--surface-2); color: var(--ink); }
.nav-link.active { background: var(--accent-soft); color: var(--accent-deep); font-weight: 600; }
.rail-foot { margin-top: auto; font-size: 12px; color: var(--ink-faint); padding: 12px 10px 0; }
.rail-foot a { display: block; color: var(--ink-soft); text-decoration: none; margin-top: 6px; }
.rail-foot a:hover { color: var(--accent-deep); }

.main { flex: 1; min-width: 0; }
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 40px 34px 96px; }

.page { display: none; }
.page.active { display: block; animation: fade .3s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.page-head { margin-bottom: 26px; }
.page-head h1 { font-family: var(--font-display); font-size: 32px; font-weight: 500; }
.page-head p { margin: 6px 0 0; color: var(--ink-soft); }
.head-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

/* ---- buttons -------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  padding: 10px 16px; border-radius: 999px; border: 1px solid transparent;
  font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none;
  background: var(--surface-2); color: var(--ink); transition: transform .06s, background .15s, box-shadow .15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--accent-deep); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink-soft); }
.btn-ghost:hover { color: var(--ink); border-color: var(--ink-faint); }
.btn-danger { background: transparent; color: var(--bad); border-color: transparent; }
.btn-danger:hover { background: #F3E7E4; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-icon { padding: 8px; border-radius: 10px; background: transparent; border: 1px solid transparent; }
.btn-icon:hover { background: var(--surface-2); }

/* ---- cards ---------------------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px;
}
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-hero { grid-template-columns: 1.1fr 1fr; align-items: stretch; }

.card-title { font-size: 12px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-faint); font-weight: 700; margin-bottom: 14px; }

/* ---- today: steps hero + ring -------------------------------------------- */
.steps-hero { display: flex; align-items: center; gap: 26px; }
.big-steps { font-family: var(--font-display); font-weight: 500; font-size: 58px;
  line-height: .95; letter-spacing: -0.02em; color: var(--ink); }
.big-steps small { font-family: var(--font-body); font-size: 14px; font-weight: 600;
  letter-spacing: .04em; color: var(--ink-faint); display: block; text-transform: uppercase; margin-top: 8px; }
.ring { flex: 0 0 132px; }
.ring .track { fill: none; stroke: var(--accent-soft); stroke-width: 12; }
.ring .val { fill: none; stroke: var(--accent); stroke-width: 12; stroke-linecap: round;
  transform: rotate(-90deg); transform-origin: center; transition: stroke-dashoffset .6s ease; }
.ring.met .val { stroke: var(--clay); }
.ring-label { font-family: var(--font-display); font-size: 20px; fill: var(--ink); }
.ring-sub { font-size: 9px; fill: var(--ink-faint); letter-spacing: .12em; text-transform: uppercase; font-weight: 700; }

/* ---- signature: week ribbon ---------------------------------------------- */
.ribbon { display: flex; gap: 10px; align-items: flex-end; }
.day {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px;
  text-decoration: none; color: inherit;
}
.day .bar-wrap { width: 100%; height: 90px; background: var(--surface-2);
  border-radius: 12px; display: flex; align-items: flex-end; overflow: hidden; }
.day .bar { width: 100%; background: var(--accent-soft); border-radius: 12px 12px 0 0;
  transition: height .5s ease; min-height: 3px; }
.day.met .bar { background: var(--clay); }
.day.today .bar-wrap { outline: 2px solid var(--accent); outline-offset: 2px; }
.day .dlabel { font-size: 11px; color: var(--ink-faint); font-weight: 600; }
.day .dval { font-size: 12px; color: var(--ink-soft); font-weight: 600; }

/* ---- stat tiles ----------------------------------------------------------- */
.stat { display: flex; flex-direction: column; gap: 3px; }
.stat .n { font-family: var(--font-display); font-size: 27px; font-weight: 500; color: var(--ink); }
.stat .k { font-size: 12px; color: var(--ink-faint); letter-spacing: .04em; text-transform: uppercase; font-weight: 600; }

/* ---- monthly challenge: progress bar ------------------------------------- */
.challenge-meta { font-size: 13px; text-align: right; line-height: 1.7; }
.pbar { position: relative; height: 12px; background: var(--accent-soft); border-radius: 999px; overflow: hidden; }
.pbar-fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width .6s ease; }
.pbar-fill.met { background: var(--clay); }
.pbar-mark { position: absolute; top: -3px; width: 2px; height: 18px; background: var(--ink-soft); opacity: .5; border-radius: 2px; }
@media (max-width: 480px) { .challenge-meta { text-align: left; } }

/* ---- lists / tables ------------------------------------------------------- */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { text-align: left; font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-faint); font-weight: 700; padding: 0 10px 10px; }
.data-table td { padding: 12px 10px; border-top: 1px solid var(--line); vertical-align: middle; }
.data-table tr:hover td { background: var(--surface-2); }

.item {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface);
  margin-bottom: 10px;
}
.item .grow { flex: 1; min-width: 0; }
.item h3 { font-size: 16px; font-weight: 600; }
.item .sub { color: var(--ink-soft); font-size: 13px; margin-top: 2px; }
.item .row-actions { display: flex; gap: 4px; opacity: .0; transition: opacity .15s; }
.item:hover .row-actions { opacity: 1; }

.prog-card { cursor: pointer; }
.prog-card:hover { border-color: var(--accent); box-shadow: var(--shadow); }

/* ---- chips / badges ------------------------------------------------------- */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--ink-soft); }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--cat-other); }
.dot.legs { background: var(--cat-legs); } .dot.push { background: var(--cat-push); }
.dot.pull { background: var(--cat-pull); } .dot.core { background: var(--cat-core); }
.dot.cardio { background: var(--cat-cardio); } .dot.other { background: var(--cat-other); }
.badge { font-size: 11px; font-weight: 700; letter-spacing: .04em; padding: 2px 8px; border-radius: 6px;
  background: var(--accent-soft); color: var(--accent-deep); text-transform: uppercase; }
.badge.clay { background: var(--clay-soft); color: #92543C; }

/* ---- forms / modal -------------------------------------------------------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-soft);
  margin-bottom: 6px; letter-spacing: .02em; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 14px; background: var(--surface); color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.field textarea { resize: vertical; min-height: 64px; }
.field-row { display: flex; gap: 12px; } .field-row .field { flex: 1; }

.modal-back { position: fixed; inset: 0; background: rgba(44,53,47,.34); backdrop-filter: blur(2px);
  display: none; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 50; }
.modal-back.open { display: flex; }
.modal { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  width: 100%; max-width: 560px; max-height: 88vh; overflow: auto; }
.modal.wide { max-width: 760px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px;
  border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); }
.modal-head h2 { font-family: var(--font-display); font-size: 21px; font-weight: 500; }
.modal-body { padding: 22px 24px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px;
  border-top: 1px solid var(--line); position: sticky; bottom: 0; background: var(--surface); }

/* ---- set editor rows ------------------------------------------------------ */
.set-row { display: grid; grid-template-columns: 1fr 64px 78px 40px; gap: 8px; align-items: center;
  padding: 6px 0; }
.set-row.head { color: var(--ink-faint); font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  font-weight: 700; }
.ex-block { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; margin-bottom: 12px; }
.ex-block .ex-name { font-weight: 600; display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }

/* ---- states / alerts ------------------------------------------------------ */
.empty { text-align: center; padding: 46px 20px; color: var(--ink-soft); }
.empty .leaf { font-size: 30px; color: var(--accent-soft); }
.empty h3 { font-family: var(--font-display); font-weight: 500; font-size: 19px; margin: 10px 0 4px; color: var(--ink); }
.loading { padding: 40px; text-align: center; color: var(--ink-faint); }
.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 16px; }
.alert-error { background: #F5E7E4; color: #8E4636; }
.alert-info { background: var(--accent-soft); color: var(--accent-deep); }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 999px; font-size: 14px;
  font-weight: 500; opacity: 0; pointer-events: none; transition: all .28s; z-index: 90; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.text-muted { color: var(--ink-soft); }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.flex { display: flex; } .between { justify-content: space-between; } .center { align-items: center; }
.gap-8 { gap: 8px; } .gap-16 { gap: 16px; } .wrap-gap { flex-wrap: wrap; gap: 10px; }
.hide { display: none !important; }

/* ---- mobile: rail becomes a bottom bar ------------------------------------ */
@media (max-width: 768px) {
  .app { flex-direction: column; }
  .rail {
    position: fixed; bottom: 0; top: auto; left: 0; right: 0; width: auto; height: auto;
    flex-direction: row; padding: 8px 6px; border-right: none; border-top: 1px solid var(--line);
    z-index: 40; justify-content: space-around; gap: 0;
    background: var(--surface);
  }
  .wordmark, .rail-foot { display: none; }
  .nav-link { flex-direction: column; gap: 3px; font-size: 10.5px; padding: 6px 4px; text-align: center; }
  .nav-link .ico { width: 21px; height: 21px; }
  .nav-link.active { background: none; color: var(--accent-deep); }
  .wrap { padding: 26px 18px 96px; }
  .page-head h1 { font-size: 26px; }
  .grid-2, .grid-3, .grid-hero { grid-template-columns: 1fr; }
  .steps-hero { flex-direction: row; }
  .big-steps { font-size: 46px; }
}
@media (max-width: 480px) {
  .day .bar-wrap { height: 66px; }
  .set-row { grid-template-columns: 1fr 52px 64px 34px; }
}

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