/* Pausas: paleta de pinar (liquen, pino, resina) y numerales condensados de cronómetro */
:root {
  --bg: #e9ece6;
  --surface: #f7f8f4;
  --ink: #1c2b24;
  --ink-2: #53635a;
  --line: #cfd6ce;
  --accent: #b5701a;      /* resina */
  --accent-soft: #f1e2c8;
  --pine: #2e5a47;
  --pine-soft: #d6e3da;
  --facil: #3f7396;
  --duro: #9a6a12;
  --problema: #b4432f;
  --font: 'Barlow', 'Avenir Next', 'Segoe UI', system-ui, sans-serif;
  --cond: 'Barlow Condensed', 'Avenir Next Condensed', 'Arial Narrow', 'Roboto Condensed', system-ui, sans-serif;
  --r-sm: 6px;
  --r-lg: 14px;
  --tab-h: 64px;
  color-scheme: light dark;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141c18; --surface: #1c2621; --ink: #e3e8e1; --ink-2: #9aa89f; --line: #2e3b34;
    --accent: #e3a24c; --accent-soft: #3a2f1f; --pine: #74b393; --pine-soft: #22362c;
    --facil: #7fb2d6; --duro: #d9a84a; --problema: #e58067;
  }
}
:root[data-theme="dark"] {
  --bg: #141c18; --surface: #1c2621; --ink: #e3e8e1; --ink-2: #9aa89f; --line: #2e3b34;
  --accent: #e3a24c; --accent-soft: #3a2f1f; --pine: #74b393; --pine-soft: #22362c;
  --facil: #7fb2d6; --duro: #d9a84a; --problema: #e58067;
}
*, *::before, *::after { box-sizing: inherit; }
html { height: 100%; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100%; background: var(--bg); color: var(--ink);
  font: 400 16px/1.45 var(--font); -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px) + 24px);
}
body.sheet-open { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--cond); font-weight: 600; letter-spacing: 0.01em; margin: 0; line-height: 1.1; }
p { margin: 0; }
.muted { color: var(--ink-2); }
.small { font-size: 0.85rem; }
.error { color: var(--problema); }

main { max-width: 640px; margin: 0 auto; padding: 8px 16px 16px; }
.page-title { font-size: 2.2rem; margin: 14px 0 12px; }

/* ── Navegación inferior ── */
#tabs {
  position: fixed; inset: auto 0 0 0; z-index: 20; display: flex; justify-content: center;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
#tabs a {
  flex: 1; max-width: 160px; height: var(--tab-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--ink-2); text-decoration: none; font-size: 0.75rem; font-weight: 500;
}
#tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
#tabs a[aria-current="page"] { color: var(--ink); }
#tabs a[aria-current="page"] svg { stroke: var(--accent); stroke-width: 2; }

/* ── Navegación de fecha ── */
.date-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 6px -6px 4px; }
.date-label { background: none; border: 0; padding: 6px; text-align: center; font-weight: 500; color: var(--ink-2); display: flex; flex-direction: column; }
.date-label small { color: var(--accent); font-size: 0.75rem; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 0; background: transparent; color: var(--ink);
  font-size: 1.5rem; line-height: 1; display: inline-grid; place-items: center; flex: none;
}
.icon-btn:hover { background: var(--line); }
.icon-btn.small { width: 34px; height: 34px; font-size: 0.95rem; color: var(--ink-2); }

/* ── Cabecera del día ── */
.day-title { display: flex; align-items: baseline; justify-content: space-between; margin: 2px 0 8px; }
.day-title h1 { font-size: 2.4rem; }
.day-count { white-space: nowrap; font-family: var(--cond); font-size: 1.15rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.day-count b { color: var(--ink); font-size: 1.6rem; }
.meter { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--pine); border-radius: 3px; transition: width 0.4s ease; }
.meter.big { height: 10px; border-radius: 5px; }
.meter.big span { background: var(--accent); }

/* ── Héroe: el próximo descanso ── */
.hero { margin: 22px 0 10px; padding: 0 0 18px; border-bottom: 1px solid var(--line); }
.hero-kicker { color: var(--ink-2); font-weight: 500; font-size: 0.95rem; }
.hero-big {
  font-family: var(--cond); font-weight: 700; font-size: clamp(5.2rem, 26vw, 7.5rem); line-height: 0.88;
  color: var(--accent); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; margin: 4px 0 6px;
}
.hero.done .hero-big, .hero.rest .hero-big { color: var(--pine); }
.hero-sub { font-size: 1.05rem; font-weight: 500; }
.hero-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 4px; }
.hero-list li { display: flex; justify-content: space-between; gap: 12px; color: var(--ink-2); }
.hero-list b { font-family: var(--cond); font-weight: 600; font-size: 1.1rem; color: var(--ink); font-variant-numeric: tabular-nums; }

/* ── Línea temporal del día ── */
.timeline { list-style: none; margin: 14px 0 0; padding: 0; }
.block { display: grid; grid-template-columns: 58px 1fr; gap: 10px; position: relative; padding-bottom: 6px; }
.block::before { content: ''; position: absolute; left: 22px; top: 30px; bottom: 0; width: 1px; background: var(--line); }
.block:last-child::before { display: none; }
.block-time { font-family: var(--cond); font-weight: 600; font-size: 1.25rem; padding-top: 10px; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.block.is-done .block-time { color: var(--pine); }
.block.is-late .block-time { color: var(--accent); }
.block-main { min-width: 0; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; padding: 12px 0 4px; }
.block-head h3 { font-size: 1.2rem; }
.block-head span { font-size: 0.85rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.block.habit .block-head h3, .block.optional .block-head h3 { color: var(--ink-2); font-weight: 500; }

.items { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: var(--r-lg); border: 1px solid var(--line); }
.item + .item { border-top: 1px solid var(--line); }
.item-row { display: flex; align-items: center; gap: 4px; min-height: 60px; padding: 4px 4px 4px 8px; }
.check {
  flex: none; width: 44px; height: 44px; border: 0; background: none; display: grid; place-items: center; padding: 0;
}
.check svg {
  width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--line); padding: 4px;
  fill: none; stroke: transparent; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round;
  transition: background 0.15s, border-color 0.15s;
}
.check:hover svg { border-color: var(--ink-2); }
.item.done .check svg { background: var(--pine); border-color: var(--pine); stroke: var(--surface); }
.item.f-facil .check svg { background: var(--facil); border-color: var(--facil); }
.item.f-duro .check svg { background: var(--duro); border-color: var(--duro); }
.item.f-problema .check svg { background: var(--problema); border-color: var(--problema); }
.item-text { flex: 1; min-width: 0; text-align: left; background: none; border: 0; padding: 8px 4px; display: flex; flex-direction: column; gap: 1px; }
.item-name { font-weight: 500; }
.item.done .item-name { color: var(--ink-2); }
.item-target { font-family: var(--cond); font-weight: 600; font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.item-target em { font-family: var(--font); font-style: normal; font-weight: 400; font-size: 0.85rem; color: var(--ink-2); }
.item.done .item-target { font-weight: 500; color: var(--ink-2); }
.item-extra { font-size: 0.85rem; color: var(--accent); font-weight: 500; }
.item-feel { font-size: 0.85rem; color: var(--ink-2); }
.item.f-problema .item-feel { color: var(--problema); }
.info {
  flex: none; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: none;
  color: var(--ink-2); font-weight: 600; margin-right: 4px;
}

.feel-picker { padding: 4px 12px 14px 56px; display: grid; gap: 8px; animation: drop 0.18s ease; }
.feel-picker > p { font-weight: 500; font-size: 0.9rem; color: var(--ink-2); }
@keyframes drop { from { opacity: 0; transform: translateY(-4px); } }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: var(--bg); border-radius: var(--r-sm); padding: 8px 10px;
  display: flex; flex-direction: column; align-items: flex-start; text-align: left; min-width: 0; flex: 1 1 120px;
}
.chip b { font-weight: 600; }
.chip small { font-size: 0.75rem; color: var(--ink-2); }
.chip.small { flex: 0 1 auto; padding: 6px 10px; font-size: 0.85rem; }
.chip.f-facil b { color: var(--facil); }
.chip.f-bien b { color: var(--pine); }
.chip.f-duro b { color: var(--duro); }
.chip.f-problema b { color: var(--problema); }
.chip[aria-pressed="true"] { border-color: currentColor; box-shadow: inset 0 0 0 1px var(--ink); background: var(--surface); }
.link { background: none; border: 0; padding: 4px 0; color: var(--accent); font-weight: 500; text-align: left; text-decoration: underline; text-underline-offset: 3px; }

/* ── Botones y formularios ── */
.btn {
  border: 1px solid var(--ink); background: var(--ink); color: var(--surface); border-radius: var(--r-sm);
  padding: 11px 16px; font-weight: 600; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; text-decoration: none;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.small { padding: 7px 12px; min-height: 38px; font-size: 0.9rem; }
.btn:disabled { opacity: 0.4; cursor: default; }
.actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 6px; }
.actions.left { justify-content: flex-start; }
.form { display: grid; gap: 14px; }
.field { display: grid; gap: 4px; }
.field > span, .label { font-size: 0.85rem; font-weight: 500; color: var(--ink-2); }
.field small { color: var(--ink-2); font-size: 0.75rem; }
input, textarea, select {
  width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-sm);
  padding: 10px 12px; font-size: 16px; min-height: 44px;
}
textarea { resize: vertical; line-height: 1.4; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; }
.inline-form input { flex: 1; }
.sets { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 10px; }
.sets label { display: grid; gap: 2px; font-size: 0.8rem; color: var(--ink-2); }
.sets input { font-family: var(--cond); font-size: 1.4rem; font-weight: 600; text-align: center; padding: 6px; }

/* ── Hoja inferior ── */
.overlay {
  position: fixed; inset: 0; z-index: 50; background: rgb(10 16 13 / 0); display: flex; align-items: flex-end; justify-content: center;
  transition: background 0.2s;
}
.overlay.open { background: rgb(10 16 13 / 0.45); }
.sheet {
  width: 100%; max-width: 600px; max-height: 92dvh; background: var(--surface); border-radius: 18px 18px 0 0;
  display: flex; flex-direction: column; transform: translateY(100%); transition: transform 0.22s ease;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.overlay.open .sheet { transform: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 8px 4px 18px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { font-size: 1.5rem; }
.sheet-body { overflow-y: auto; padding: 14px 18px 22px; overscroll-behavior: contain; }
@media (min-width: 700px) {
  .overlay { align-items: center; }
  .sheet { border-radius: 18px; transform: translateY(16px); opacity: 0; transition: transform 0.2s, opacity 0.2s; }
  .overlay.open .sheet { opacity: 1; }
}

/* ── Ficha de ejercicio ── */
.ex-detail { display: grid; gap: 14px; }
.group-tag { font-size: 0.85rem; color: var(--accent); font-weight: 600; }
.how { font-size: 1.05rem; }
.cues { margin: 0; padding-left: 1.1em; color: var(--ink-2); display: grid; gap: 3px; }
.video { aspect-ratio: 16 / 9; border-radius: var(--r-lg); overflow: hidden; background: #000; }
.video iframe { width: 100%; height: 100%; border: 0; }
.video-tools { display: grid; gap: 8px; }
.level { border-top: 1px solid var(--line); padding-top: 12px; }
.level h3, .ex-detail section h3 { font-size: 1.15rem; margin-bottom: 6px; }
.level-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.level-row .icon-btn { border: 1px solid var(--line); }
.level-row div { text-align: center; display: grid; }
.level-row b { font-family: var(--cond); font-size: 1.8rem; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.level-row small { color: var(--ink-2); font-size: 0.8rem; }
.hist { list-style: none; margin: 0; padding: 0; }
.hist li { display: grid; grid-template-columns: 64px 1fr auto; gap: 2px 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 0.92rem; }
.hist li small { grid-column: 2 / -1; color: var(--ink-2); }
.hist li > span:first-child { color: var(--ink-2); }
.f-facil { color: var(--facil); } .f-bien { color: var(--pine); } .f-duro { color: var(--duro); } .f-problema { color: var(--problema); }
.item.f-facil, .item.f-bien, .item.f-duro, .item.f-problema { color: inherit; }

/* ── Comida ── */
.macro-hero { margin: 16px 0 6px; display: grid; grid-template-columns: 1.4fr 1fr; gap: 10px 20px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.macro-hero .hero-big { font-size: clamp(3.6rem, 17vw, 5rem); }
.macro-hero .hero-big span, .mid span { font-size: 1.1rem; font-weight: 500; color: var(--ink-2); letter-spacing: 0; }
.mid { font-family: var(--cond); font-weight: 700; font-size: 2.2rem; line-height: 1; margin: 6px 0 8px; font-variant-numeric: tabular-nums; }
.kcal { align-self: end; }
.kcal .meter { margin-bottom: 6px; }
.macros { grid-column: 1 / -1; display: flex; gap: 22px; margin: 4px 0 0; flex-wrap: wrap; }
.macros div { display: grid; }
.macros dt { font-size: 0.8rem; color: var(--ink-2); }
.macros dd { margin: 0; font-family: var(--cond); font-weight: 600; font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.hint { grid-column: 1 / -1; background: var(--accent-soft); border-radius: var(--r-sm); padding: 10px 12px; font-weight: 500; }
.meals { display: grid; gap: 10px; margin-top: 14px; }
.meal { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 12px 14px; }
.meal-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.meal-head h3 { font-size: 1.3rem; }
.meal-head small { color: var(--ink-2); font-size: 0.8rem; }
.meal-sum { font-size: 0.85rem; color: var(--ink-2); text-align: right; }
.meal-sum b { font-family: var(--cond); font-size: 1.15rem; color: var(--ink); }
.entries { list-style: none; margin: 8px 0 0; padding: 0; }
.entries li { display: flex; gap: 8px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.entries li > div { flex: 1; min-width: 0; }
.entries p { font-weight: 500; overflow-wrap: anywhere; }
.entries small { color: var(--ink-2); font-size: 0.78rem; display: block; }
.entry-num { font-family: var(--cond); font-weight: 600; font-size: 1.1rem; text-align: right; font-variant-numeric: tabular-nums; }
.entry-num small { font-family: var(--font); font-weight: 400; }
.meal-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.foot { margin-top: 16px; }
.parsed { display: grid; gap: 8px; }
.prow { display: grid; grid-template-columns: 1fr 84px auto; grid-template-areas: 'food grams x' 'vals vals vals'; gap: 2px 8px; align-items: center; padding: 8px 0 6px; border-bottom: 1px solid var(--line); }
.prow-food { grid-area: food; text-align: left; background: none; border: 0; padding: 4px 0; min-width: 0; }
.prow-food small { display: block; color: var(--ink-2); font-size: 0.78rem; }
.prow.unsure .prow-food small { color: var(--duro); }
.prow.missing .prow-food b { color: var(--problema); }
.prow .grams { grid-area: grams; display: flex; align-items: center; gap: 4px; color: var(--ink-2); }
.prow .grams input { padding: 6px 8px; min-height: 38px; text-align: right; }
.prow .vals { grid-area: vals; font-size: 0.82rem; color: var(--ink-2); }
.prow .icon-btn { grid-area: x; }
.parsed-total { font-size: 0.95rem; }
.parsed-total b { font-family: var(--cond); font-size: 1.2rem; }
.parsed-total em { color: var(--problema); font-style: normal; font-size: 0.85rem; }
.recent { align-items: center; }
.food-list { list-style: none; margin: 0; padding: 0; }
.food-list li { border-bottom: 1px solid var(--line); }
.food-list li.muted { padding: 10px 0; border: 0; }
.food-list button { width: 100%; text-align: left; background: none; border: 0; padding: 10px 2px; }
.food-list b, .food-list small { display: block; }
.food-list small { color: var(--ink-2); font-size: 0.8rem; }
.food-list li.row { display: flex; align-items: center; gap: 8px; padding: 8px 0; }
.food-list li.row > div { flex: 1; }
.picker h3 { font-size: 1.15rem; margin-top: 4px; }

/* ── Progreso ── */
.card-sec { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px 16px 16px; margin-bottom: 12px; display: grid; gap: 10px; }
.card-sec h2 { font-size: 1.45rem; }
.card-sec h3 { font-size: 1.05rem; margin-top: 6px; display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.card-sec h3 small { font-family: var(--font); font-weight: 500; font-size: 0.8rem; color: var(--pine); }
.sec-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.stat { font-family: var(--cond); font-weight: 700; font-size: 2rem; color: var(--accent); line-height: 1; }
.week { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.wday { position: relative; height: 86px; border-radius: var(--r-sm); background: var(--bg); overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 6px 0; }
.wday.now { box-shadow: inset 0 0 0 2px var(--accent); }
.wday.future { opacity: 0.55; }
.wfill { position: absolute; left: 0; right: 0; bottom: 0; background: var(--pine-soft); }
.wday b, .wday small { position: relative; font-variant-numeric: tabular-nums; }
.wday b { font-family: var(--cond); font-size: 1.1rem; }
.wday small { font-size: 0.75rem; color: var(--ink-2); }
.seg { display: flex; background: var(--bg); border-radius: var(--r-sm); padding: 3px; gap: 2px; }
.seg button { flex: 1; border: 0; background: none; padding: 7px 4px; border-radius: 4px; font-size: 0.88rem; font-weight: 500; color: var(--ink-2); }
.seg button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--line); }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .bar { fill: var(--line); }
.chart .bar-now { fill: var(--accent); }
.chart .bar-hit { fill: var(--pine); }
.chart .bar-hit.bar-now { fill: var(--accent); }
.chart .axis { fill: var(--ink-2); font: 500 9px var(--font); }
.chart .target { stroke: var(--accent); stroke-dasharray: 3 3; stroke-width: 1; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .line { fill: none; stroke: var(--ink-2); stroke-width: 1.5; stroke-linejoin: round; }
.chart .line.accent { stroke: var(--accent); stroke-width: 2.2; }
.chart .line.faint { stroke: var(--line); }
.chart .dot { fill: var(--ink-2); }
.chart .dot.accent { fill: var(--accent); }
.chart .dot.faint { fill: var(--ink-2); opacity: 0.5; }
.ex-now { font-size: 0.92rem; }
.feel-counts { list-style: none; margin: 0; padding: 0; display: flex; gap: 16px; flex-wrap: wrap; font-size: 0.85rem; }
.feel-counts b { font-family: var(--cond); font-size: 1.3rem; margin-right: 4px; }
.body-form label { display: grid; gap: 2px; font-size: 0.8rem; color: var(--ink-2); flex: 1; }
.body-form input { font-family: var(--cond); font-size: 1.3rem; font-weight: 600; }
.issues { list-style: none; margin: 0; padding: 0; }
.issues li { display: grid; grid-template-columns: 56px 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); color: var(--ink); }
.issues li > span { color: var(--ink-2); font-size: 0.85rem; padding-top: 2px; }
.issues li p { color: var(--ink-2); font-size: 0.9rem; }
.issues li.f-problema p { color: var(--problema); }
.prose p { color: var(--ink-2); max-width: 62ch; }

/* ── Varios ── */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px) + 14px); z-index: 60;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: 0.2s ease;
  background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: var(--r-sm); font-weight: 500;
  max-width: calc(100vw - 32px); width: max-content;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.up { background: var(--pine); color: var(--surface); }
.toast.down, .toast.error { background: var(--problema); color: var(--surface); }
.empty { text-align: center; padding: 60px 16px; display: grid; gap: 12px; justify-items: center; }
body.login { padding-bottom: 0; }
.login-box { max-width: 380px; margin: 12vh auto 0; display: grid; gap: 14px; }
.login-box h1 { font-size: 4rem; color: var(--accent); font-weight: 700; line-height: 0.9; }

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