/* Entreno Trail: pensado primero para el móvil. */
:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --text: #1d2420;
  --muted: #5f6b64;
  --line: #dfe3dc;
  --brand: #1f6f50;
  --brand-ink: #ffffff;
  --brand-soft: #e3f0e9;
  --strava: #fc4c02;
  --ok: #1f7a4a;
  --warn: #a35a00;
  --bad: #b3261e;
  --radius: 14px;
  --tabbar-h: 60px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121614;
    --surface: #1b211e;
    --text: #e8ece9;
    --muted: #9aa69f;
    --line: #2c3530;
    --brand: #3fa57a;
    --brand-ink: #0d1411;
    --brand-soft: #1e3329;
    --ok: #5cc48c;
    --warn: #e0a24a;
    --bad: #f08a80;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

body.with-nav { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 8px); }

main {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

h1 { font-size: 1.6rem; line-height: 1.2; margin: 4px 0 0; }
h2 { font-size: 1.05rem; margin: 0 0 8px; }
p { margin: 0; }
a { color: var(--brand); }
section { display: flex; flex-direction: column; gap: 8px; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.row label { flex: 1 1 180px; }

/* Botones: al menos 44 px de alto para el dedo. */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 10px 18px;
  border: 0; border-radius: 12px;
  background: var(--brand); color: var(--brand-ink);
  font: inherit; font-weight: 600; text-decoration: none; text-align: center;
  cursor: pointer; width: 100%;
}
.btn:active { transform: translateY(1px); }
.btn-ghost { background: transparent; color: var(--brand); border: 1.5px solid var(--brand); }
.btn-ghost.selected { background: var(--brand-soft); }
.btn-strava { background: var(--strava); color: #fff; }
.btn-danger { background: transparent; color: var(--bad); border: 1.5px solid var(--bad); }

.hero { padding: 24px 0 8px; }
.hero h1 { font-size: 2rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.card h2 { font-size: .95rem; color: var(--muted); font-weight: 600; }
.card.rest { color: var(--muted); }

a.card.session {
  display: flex; gap: 12px; align-items: flex-start;
  color: inherit; text-decoration: none;
}
.session .body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mark {
  flex: none; display: inline-grid; place-items: center;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand); font-weight: 700;
}
.status-done .mark, .status-manual_done .mark { background: var(--ok); color: var(--surface); }
.status-short .mark, .status-over .mark { background: var(--warn); color: var(--surface); }
.status-skipped .mark { background: var(--bad); color: var(--surface); }

.notice, .flash {
  background: var(--brand-soft); border-radius: var(--radius); padding: 12px 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.error {
  border: 1.5px solid var(--bad); color: var(--bad);
  border-radius: var(--radius); padding: 12px 14px; font-weight: 600;
}

.week-strip {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px;
}
.week-strip li {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  display: flex; flex-direction: column; align-items: center; padding: 6px 0; min-height: 52px;
}
.week-strip li.today { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }

.warnings, .adjustments { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
.links a { display: block; padding: 10px 0; min-height: 44px; }

details {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
details.past { opacity: .7; }
summary {
  cursor: pointer; padding: 14px 16px; min-height: 48px; font-weight: 600;
  list-style-position: inside;
}
details > .stack { padding: 0 12px 14px; }
details .card { border-color: var(--line); background: var(--bg); }

/* Formularios */
form { margin: 0; }
fieldset {
  border: 1px solid var(--line); border-radius: var(--radius);
  margin: 0; padding: 14px; background: var(--surface); min-width: 0;
}
/* La leyenda dentro de la caja (si ocupa dos líneas no pisa el borde). */
legend { float: left; width: 100%; padding: 0; margin-bottom: 6px; font-weight: 600; }
legend + * { clear: both; }
fieldset > * + * { margin-top: 10px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: .95rem; }
label.choice { flex-direction: row; align-items: center; gap: 10px; min-height: 44px; }
input[type="text"], input[type="date"], select {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px;
  min-height: 44px; padding: 8px 10px; width: 100%; min-width: 0;
}
input[type="radio"], input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--brand); flex: none; }
select:disabled { opacity: .5; }
.days { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.race-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.race-fields label:first-child { grid-column: 1 / -1; }
form:has(input[name="goalKind"][value="fitness"]:checked) .race-fields { display: none; }

.danger { border-top: 1px solid var(--line); padding-top: 16px; }

/* Navegación inferior fija */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: grid; grid-template-columns: repeat(3, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--line);
}
.tabbar a {
  display: grid; place-items: center; text-decoration: none;
  color: var(--muted); font-weight: 600;
}
.tabbar a[aria-current="page"] { color: var(--brand); box-shadow: inset 0 3px 0 var(--brand); }

.powered {
  text-align: center; color: var(--muted); font-size: .75rem;
  padding: 0 16px 12px;
}
