/* M4niatic · negro y champán. Oscuro por defecto; claro (marfil) con data-theme="light".
   Principios: líneas finas, mucho aire, tipografía serif en los títulos, cifras en trazo fino,
   el champán solo como acento. Sin brillos ni degradados llamativos. */
:root {
  color-scheme: dark;
  --page: #0b0b0a;
  --surface: #111110;
  --surface-2: #171715;
  --surface-3: #22211e;
  --line: rgba(236, 228, 214, 0.07);
  --line-2: rgba(236, 228, 214, 0.13);
  --ink: #ece6dc;
  --ink-2: #a39e94;
  --muted: #6e6a62;
  --grid: #1f1e1b;
  --axis: #2e2d29;
  --accent: #c9b37e;
  --accent-2: #e2d3ad;
  --accent-ink: #0b0b0a;
  --accent-soft: rgba(201, 179, 126, 0.09);
  --hero: #c9b37e;          /* serie única: champán */
  --series-1: #a8831f;      /* categórica (validada, oscuro): oro */
  --series-2: #5b8bd0;      /* azul acero */
  --series-3: #c0664a;      /* terracota */
  --good: #7fb77e;
  --warn: #d9b25c;
  --bad: #d9776a;
  --critical: #d9776a;
  --radius: 14px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  font-family: var(--sans);
}
:root[data-theme="light"] {
  color-scheme: light;
  --page: #f7f4ee;
  --surface: #fdfbf7;
  --surface-2: #f1ede5;
  --surface-3: #e6e0d4;
  --line: rgba(40, 32, 18, 0.08);
  --line-2: rgba(40, 32, 18, 0.15);
  --ink: #1b1915;
  --ink-2: #5d574c;
  --muted: #8d8578;
  --grid: #ebe6dc;
  --axis: #d3cbbb;
  --accent: #8f6b12;
  --accent-2: #6f520c;
  --accent-ink: #fdfbf7;
  --accent-soft: rgba(143, 107, 18, 0.08);
  --hero: #8f6b12;
  --series-1: #8f6b12;
  --series-2: #2f6db8;
  --series-3: #b4502f;
  --good: #3f7a3e;
  --warn: #8a6a12;
  --bad: #a8412f;
  --critical: #a8412f;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
/* iPhone: el texto no se reescala solo y el doble toque no hace zoom */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; touch-action: manipulation; }
body { background: var(--page); color: var(--ink); font-size: 14px; line-height: 1.55; -webkit-font-smoothing: antialiased; letter-spacing: 0.005em; }
h1 { font-family: var(--serif); font-size: 36px; line-height: 1.1; margin: 0; font-weight: 400; letter-spacing: -0.01em; }
h2 { font-family: var(--serif); font-size: 18px; margin: 0; font-weight: 400; letter-spacing: 0; }
h3 { font-size: 10.5px; margin: 0 0 10px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .16em; }
p { margin: 0 0 8px; }
a { color: var(--accent); }
.muted { color: var(--ink-2); }
.dim { color: var(--muted); }
.tiny { font-size: 12px; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }

/* ---------- estructura ---------- */
.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
/* Los hijos de una rejilla crecen con su contenido salvo que se les permita encoger:
   sin esto, una tabla o el menú de secciones ensanchaban la página y el iPhone reducía el zoom. */
.shell > *, main, .page-head > *, .card, .grid > * { min-width: 0; }
.nav { position: sticky; top: 0; height: 100vh; padding: 34px 20px 24px; display: flex; flex-direction: column; gap: 34px; border-right: 1px solid var(--line); background: var(--page); }
.brand { display: flex; gap: 12px; align-items: center; padding: 0 6px; }
.brand-mark { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line-2); }
.brand-title { font-family: var(--serif); font-size: 20px; letter-spacing: 0.02em; }
.brand-sub { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .16em; }
nav { display: flex; flex-direction: column; gap: 1px; overflow-y: auto; }
.nav-btn { display: flex; align-items: center; gap: 13px; text-align: left; background: none; border: 0; padding: 9px 10px; border-radius: 8px; cursor: pointer; color: var(--ink-2); font-weight: 400; font-size: 14px; position: relative; transition: color .15s ease; }
.nav-btn svg { width: 17px; height: 17px; flex: none; opacity: .7; }
.nav-btn:hover { color: var(--ink); }
.nav-btn.active { color: var(--ink); }
.nav-btn.active svg { color: var(--accent); opacity: 1; }
.nav-btn.active::before { content: ""; position: absolute; left: -20px; top: 50%; width: 2px; height: 18px; margin-top: -9px; background: var(--accent); }
.nav-sep { height: 1px; background: var(--line); margin: 14px 10px; }
.nav-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding: 0 6px; }

main { padding: 48px 56px 96px; max-width: 1320px; width: 100%; transition: opacity .15s ease; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 36px; flex-wrap: wrap; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.page-head .eyebrow { font-size: 10.5px; color: var(--accent); font-weight: 600; text-transform: uppercase; letter-spacing: .2em; margin-bottom: 12px; }
.page-head p { color: var(--ink-2); margin: 10px 0 0; max-width: 60ch; }

/* ---------- tarjetas ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px 28px; margin-bottom: 20px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.grid { display: grid; gap: 20px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid > .card { margin-bottom: 0; }
.grid + .grid, .grid + .card, .card + .grid { margin-top: 20px; }
.stack > * + * { margin-top: 20px; }

/* ---------- cifras (fila con separadores, estilo esfera de reloj) ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin-bottom: 20px; overflow: hidden; }
.tile { padding: 22px 24px 20px; min-width: 0; position: relative; border-left: 1px solid var(--line); margin-left: -1px; }
.tile .t-label { display: flex; align-items: center; gap: 8px; font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .16em; font-weight: 600; }
.tile .t-label svg { display: none; }
.tile .t-value { font-size: 34px; font-weight: 300; letter-spacing: -0.02em; margin-top: 12px; line-height: 1.05; color: var(--ink); }
.tile .t-value small { font-size: 13px; font-weight: 400; color: var(--ink-2); margin-left: 5px; letter-spacing: 0.02em; }
.tile .t-foot { font-size: 12px; color: var(--muted); margin-top: 10px; }
.tile.link { cursor: pointer; transition: background .15s ease; }
.tile.link:hover { background: var(--surface-2); }

.rings { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin-bottom: 20px; overflow: hidden; }
.ring-card { padding: 26px 12px 22px; text-align: center; cursor: pointer; border-left: 1px solid var(--line); margin-left: -1px; transition: background .15s ease; }
.ring-card:hover { background: var(--surface-2); }
.ring { position: relative; width: 104px; height: 104px; margin: 0 auto 14px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .track { stroke: var(--surface-3); }
.ring .bar { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .8s cubic-bezier(.2,.8,.2,1); }
.ring .center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring .center b { font-size: 21px; font-weight: 300; letter-spacing: -0.01em; }
.ring .center span { font-size: 10.5px; color: var(--muted); margin-top: 2px; }
.ring-card .r-label { font-size: 10.5px; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: .16em; }

.kv { display: grid; grid-template-columns: 1fr auto; gap: 12px 16px; }
.kv > div:nth-child(odd) { color: var(--ink-2); }
.kv > div:nth-child(even) { text-align: right; font-variant-numeric: tabular-nums; }

.status { display: inline-flex; align-items: center; gap: 7px; font-weight: 500; font-size: 11.5px; letter-spacing: .04em; color: var(--ink-2); }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status.good { color: var(--good); }
.status.warn { color: var(--warn); }
.status.bad { color: var(--bad); }
.status.info { color: var(--muted); }

.bar-line { height: 2px; background: var(--surface-3); overflow: hidden; }
.bar-line > span { display: block; height: 100%; background: var(--accent); }
.bar-line.over > span { background: var(--bad); }

/* ---------- controles ---------- */
button.primary { background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent); padding: 10px 22px; border-radius: 999px; font-weight: 600; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; cursor: pointer; transition: background .15s ease, color .15s ease; }
button.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
button.ghost { background: transparent; border: 1px solid var(--line-2); padding: 9px 18px; border-radius: 999px; cursor: pointer; color: var(--ink); font-size: 12.5px; letter-spacing: .03em; transition: border-color .15s ease; }
button.ghost:hover { border-color: var(--accent); }
button.small { padding: 6px 13px; font-size: 11.5px; }
/* Iconos dentro de botones con texto: tamaño fijo y alineados con la letra */
button.primary, button.ghost { display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; }
button.primary svg, button.ghost svg { width: 13px; height: 13px; flex: none; stroke-width: 1.8; }
button.small svg { width: 12px; height: 12px; }
button.danger { color: var(--bad); }
button.icon { background: transparent; border: 1px solid var(--line-2); width: 36px; height: 36px; border-radius: 50%; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; color: var(--ink-2); }
button.icon:hover { border-color: var(--accent); color: var(--ink); }
button.icon svg { width: 15px; height: 15px; }

.seg { display: inline-flex; gap: 2px; }
.seg button { border: 0; background: none; padding: 6px 12px; cursor: pointer; color: var(--muted); font-size: 12.5px; border-bottom: 1px solid transparent; }
.seg button.on { color: var(--ink); border-bottom-color: var(--accent); }

.datenav { display: inline-flex; align-items: center; gap: 10px; }
.datenav input { width: 156px; text-align: center; }

.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px 22px; }
.form-grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.field > span { font-size: 10.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .14em; }
.field > span .dim { text-transform: none; letter-spacing: 0; }
.field.wide { grid-column: 1 / -1; }
.field.half { grid-column: span 2; }
input, select, textarea { background: transparent; border: 0; border-bottom: 1px solid var(--line-2); border-radius: 0; padding: 8px 2px; min-width: 0; width: 100%; color: var(--ink); transition: border-color .15s ease; }
textarea { resize: vertical; line-height: 1.65; border: 1px solid var(--line-2); border-radius: 10px; padding: 12px 14px; }
select { cursor: pointer; }
select option { background: var(--surface); color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
button:focus-visible { outline: 1px solid var(--accent); outline-offset: 3px; }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }
input[type="date"], input[type="time"] { color-scheme: inherit; }
.form-actions { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin-top: 24px; flex-wrap: wrap; }
.form-actions .muted { margin-right: auto; font-size: 12.5px; }

/* escala 1-5 */
.scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.scale button { background: transparent; border: 1px solid var(--line-2); border-radius: 999px; padding: 7px 0; cursor: pointer; font-weight: 400; color: var(--ink-2); font-size: 13px; transition: all .15s ease; }
.scale button:hover { border-color: var(--accent); color: var(--ink); }
.scale button.on { border-color: var(--accent); color: var(--accent-ink); background: var(--accent); }

/* hábitos */
.habit-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); column-gap: 28px; }
.habit { display: flex; align-items: center; gap: 14px; padding: 13px 2px; border-bottom: 1px solid var(--line); cursor: pointer; user-select: none; }
.habit .check { width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--line-2); display: flex; align-items: center; justify-content: center; flex: none; transition: all .15s ease; }
.habit .check svg { width: 11px; height: 11px; opacity: 0; color: var(--accent-ink); }
.habit:hover .check { border-color: var(--accent); }
.habit.on .check { background: var(--accent); border-color: var(--accent); }
.habit.on .check svg { opacity: 1; }
.habit.on .h-name { color: var(--ink-2); }
.habit .h-name { font-size: 14px; }
.habit .h-group { font-size: 10.5px; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; margin-top: 1px; }
.habit.auto { cursor: default; }
.habit.auto .check { border-style: dashed; }
.habit.auto:hover .check { border-color: var(--line-2); }
.habit.auto.on .check { border-style: solid; }
.habit.auto .h-group { text-transform: none; letter-spacing: .02em; color: var(--accent); opacity: .8; }
.habit .h-streak { margin-left: auto; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 1fr); gap: 3px; overflow-x: auto; padding-bottom: 4px; }
.heat span { width: 12px; height: 12px; border-radius: 2px; background: var(--surface-3); }
.heat span.l1 { background: rgba(201,179,126,.22); }
.heat span.l2 { background: rgba(201,179,126,.45); }
.heat span.l3 { background: rgba(201,179,126,.7); }
.heat span.l4 { background: var(--accent); }
:root[data-theme="light"] .heat span.l1 { background: rgba(143,107,18,.18); }
:root[data-theme="light"] .heat span.l2 { background: rgba(143,107,18,.4); }
:root[data-theme="light"] .heat span.l3 { background: rgba(143,107,18,.65); }

/* tablas */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th { text-align: left; font-weight: 600; color: var(--muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: .14em; padding: 10px 12px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
table.data td { padding: 13px 12px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
table.data td.num, table.data th.num { text-align: right; white-space: nowrap; }
table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:hover td { background: var(--surface-2); }
table.data input, table.data select { padding: 6px 2px; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 99px; border: 1px solid var(--line-2); font-size: 11.5px; color: var(--ink-2); white-space: nowrap; }
.pill.accent { border-color: rgba(201,179,126,.45); color: var(--accent); }
.neg { color: var(--bad); }
.pos { color: var(--good); }

.chart-box { position: relative; height: 240px; }
.chart-box.tall { height: 320px; }
.empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; color: var(--muted); padding: 20px; font-family: var(--serif); font-style: italic; font-size: 15px; }

/* lanzador de apps */
.launcher { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.app-icon { display: flex; flex-direction: column; align-items: center; gap: 12px; cursor: pointer; background: none; border: 0; padding: 14px 6px; border-radius: 12px; transition: background .15s ease; }
.app-icon:hover { background: var(--surface-2); }
.app-icon .ai { width: 58px; height: 58px; border-radius: 50%; border: 1px solid var(--line-2); display: flex; align-items: center; justify-content: center; transition: border-color .15s ease; }
.app-icon .ai svg { width: 22px; height: 22px; color: var(--accent); }
.app-icon span { font-size: 12.5px; color: var(--ink-2); letter-spacing: .02em; }
.app-icon:hover .ai { border-color: var(--accent); }

/* diario */
.journal-entry { border-top: 1px solid var(--line); padding: 20px 0; }
.journal-entry:first-of-type { border-top: 0; padding-top: 0; }
.journal-entry .je-head { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.journal-entry .je-head b { font-family: var(--serif); font-weight: 400; font-size: 16px; }
.journal-entry p { white-space: pre-wrap; color: var(--ink-2); margin: 6px 0; line-height: 1.7; }
.journal-entry p i { font-family: var(--serif); color: var(--ink); font-size: 15px; }

/* proyectos (tablero) */
.board { display: grid; grid-template-columns: repeat(4, minmax(230px, 1fr)); gap: 20px; overflow-x: auto; }
.col { border-top: 1px solid var(--accent); padding-top: 14px; min-height: 120px; }
.col h3 { display: flex; justify-content: space-between; }
.pcard { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-top: 10px; cursor: pointer; transition: border-color .15s ease; }
.pcard:hover { border-color: var(--line-2); }
.pcard b { display: block; margin-bottom: 8px; font-family: var(--serif); font-weight: 400; font-size: 16px; }
.pcard .next { font-size: 12.5px; color: var(--ink-2); }

/* exámenes */
.exam { display: flex; align-items: center; gap: 18px; padding: 16px 0; border-top: 1px solid var(--line); }
.exam:first-of-type { border-top: 0; padding-top: 0; }
.exam .days { min-width: 56px; text-align: center; }
.exam .days b { display: block; font-size: 30px; font-weight: 300; color: var(--accent); line-height: 1; letter-spacing: -0.02em; }
.exam .days span { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .14em; }
.exam > div:nth-child(2) b { font-family: var(--serif); font-weight: 400; font-size: 16px; }

/* subnavegación de un módulo (Cuerpo) */
.subnav { display: flex; flex-direction: row; overflow-y: hidden; gap: 26px; margin: -14px 0 28px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.subnav::-webkit-scrollbar { display: none; }
.subnav a { color: var(--muted); text-decoration: none; padding: 0 0 12px; font-size: 13px; letter-spacing: .03em; white-space: nowrap; border-bottom: 1px solid transparent; margin-bottom: -1px; transition: color .15s ease; }
.subnav a:hover { color: var(--ink); }
.subnav a.on { color: var(--ink); border-bottom-color: var(--accent); }

/* entreno */
.week-strip { display: grid; grid-template-columns: repeat(7, 1fr); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 20px; background: var(--surface); }
.day-pill { padding: 14px 14px 12px; border-left: 1px solid var(--line); margin-left: -1px; font-size: 11px; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
.day-pill b { display: block; margin-top: 6px; font-family: var(--serif); font-weight: 400; font-size: 14px; color: var(--ink); text-transform: none; letter-spacing: 0; }
.day-pill.rest b { color: var(--muted); }
.day-pill.today { background: var(--accent-soft); }
.day-pill.today span { color: var(--accent); }
.session-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.session-tabs button { border: 1px solid var(--line-2); background: transparent; padding: 7px 15px; border-radius: 999px; cursor: pointer; font-size: 12.5px; color: var(--ink-2); transition: all .15s ease; }
.session-tabs button:hover { border-color: var(--accent); color: var(--ink); }
.session-tabs button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.ex { border-top: 1px solid var(--line); padding: 20px 0; }
.ex:first-of-type { border-top: 0; }
.ex-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: baseline; }
.ex-name { font-family: var(--serif); font-size: 17px; }
.ex-meta { color: var(--muted); font-size: 12px; letter-spacing: .03em; }
.ex-note { color: var(--ink-2); font-size: 12.5px; margin-top: 6px; }
.ex-note.warn { color: var(--warn); }
.ex-last { font-size: 12.5px; color: var(--muted); margin-top: 8px; font-style: italic; }
.sets { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.set { display: grid; grid-template-columns: auto 64px 10px 50px; align-items: center; gap: 6px; border: 1px solid var(--line-2); border-radius: 999px; padding: 4px 14px; font-size: 11px; color: var(--muted); }
.set input { border: 0; padding: 6px 2px; text-align: center; font-size: 14px; }
ul.rules { padding-left: 18px; margin: 10px 0 0; color: var(--ink-2); }
ul.rules li { margin: 8px 0; line-height: 1.6; }

/* constancia */
.streak-row { display: grid; grid-template-columns: 96px 1fr 44px; gap: 12px; align-items: center; margin: 10px 0; font-size: 13px; color: var(--ink-2); }
.streak-row .num { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); }
.streak-cells { display: grid; grid-template-columns: repeat(28, 1fr); gap: 2px; }
.streak-cells span { aspect-ratio: 1; border-radius: 2px; background: var(--surface-2); }
.streak-cells span.l4 { background: var(--accent); }
.streak-cells span.l0 { background: var(--surface-3); }

/* fotos */
.compare-controls { display: grid; grid-template-columns: repeat(3, minmax(0, 200px)); gap: 20px; margin: 28px 0 18px; }
.compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 24px; }
.compare-grid figure { margin: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface-2); }
.compare-grid img { width: 100%; height: 480px; object-fit: contain; display: block; }
.compare-grid figcaption { padding: 10px 14px; font-size: 12px; color: var(--ink-2); border-top: 1px solid var(--line); }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
.gallery figure { margin: 0; }
.gallery img { width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: 10px; display: block; border: 1px solid var(--line); }
.gallery figcaption { font-size: 11px; color: var(--muted); margin-top: 6px; display: flex; justify-content: space-between; }
.gallery button { border: 0; background: none; color: var(--bad); cursor: pointer; font-size: 11px; padding: 0; }

/* texto largo (guía) */
.prose { max-width: 820px; }
.prose h2 { margin: 28px 0 10px; font-size: 22px; }
.prose h2:first-child { margin-top: 0; }
.prose h3 { margin-top: 18px; }
.prose ul { padding-left: 20px; margin: 8px 0 12px; color: var(--ink-2); }
.prose li { margin: 7px 0; line-height: 1.65; }
.prose p { color: var(--ink-2); line-height: 1.7; }
.prose b { color: var(--ink); font-weight: 600; }

/* dieta */
.file-btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line-2); border-radius: 999px; padding: 6px 14px; font-size: 11.5px; color: var(--ink); cursor: pointer; letter-spacing: .03em; text-transform: none; font-weight: 400; transition: border-color .15s ease; }
.file-btn:hover { border-color: var(--accent); }
.file-btn svg { width: 12px; height: 12px; }
.scanner { width: 100%; min-height: 220px; border: 1px solid var(--line-2); border-radius: 14px; overflow: hidden; background: #000; }
.scanner video { width: 100% !important; display: block; }
.food-list { max-height: 52vh; overflow-y: auto; margin-top: 14px; border-top: 1px solid var(--line); }
.food-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line); padding: 13px 4px; cursor: pointer; color: var(--ink); }
.food-row:hover { background: var(--surface-2); }
.food-row b { font-weight: 500; }
.meal .card-head { margin-bottom: 8px; }
.meal-items { border-top: 1px solid var(--line); }
.meal-item { display: grid; grid-template-columns: 1fr 70px 14px 80px 56px 30px; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.meal-item b { font-weight: 500; }
.meal-item input { padding: 4px 2px; text-align: right; }
.meal-item .num { text-align: right; font-variant-numeric: tabular-nums; }
.meal-item button.icon { width: 28px; height: 28px; font-size: 11px; }

/* coach */
.coach { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); min-height: 62vh; }
.coach-threads { display: flex; gap: 10px; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.coach-threads select { max-width: 420px; }
.chat { flex: 1; overflow-y: auto; padding: 24px 22px; display: flex; flex-direction: column; gap: 16px; max-height: 64vh; }
.msg { max-width: 82%; line-height: 1.6; }
.msg p { margin: 0 0 8px; }
.msg p:last-child { margin-bottom: 0; }
.msg.user { align-self: flex-end; background: var(--surface-3); border-radius: 18px 18px 4px 18px; padding: 11px 16px; }
.msg.assistant { align-self: flex-start; padding: 2px 0; }
.msg.assistant .md h4 { font-family: var(--serif); font-weight: 400; font-size: 17px; margin: 14px 0 6px; }
.msg.assistant .md ul, .msg.assistant .md ol { margin: 6px 0 10px; padding-left: 20px; }
.msg.assistant .md li { margin: 4px 0; }
.msg.assistant .md b { color: var(--ink); font-weight: 600; }
.msg.assistant .md code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: 12.5px; }
.msg.thinking { display: flex; align-items: center; gap: 12px; }
.dots { display: inline-flex; gap: 5px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); opacity: .3; animation: blink 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; } .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.img-note { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.img-note svg { width: 12px; height: 12px; }
.acts { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.act { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-2); border-left: 2px solid var(--accent); padding: 2px 0 2px 10px; }
.act svg { width: 12px; height: 12px; color: var(--accent); flex: none; }
.proposal { display: flex; justify-content: space-between; align-items: center; gap: 14px; border: 1px solid rgba(201,179,126,.35); background: var(--accent-soft); border-radius: 12px; padding: 12px 14px; margin-top: 10px; flex-wrap: wrap; }
.proposal > div:first-child { flex: 1; min-width: 200px; }
.prop-actions { display: flex; gap: 8px; }
.proposals .proposal:first-of-type { margin-top: 0; }
.composer { border-top: 1px solid var(--line); padding: 14px 16px; }
.composer-row { display: flex; gap: 10px; align-items: flex-end; }
.level-row { display: flex; align-items: center; gap: 4px 12px; flex-wrap: wrap; margin: -4px 0 10px; }
.level-row .seg button { padding: 4px 10px; font-size: 12px; }
.level-row .dim { min-width: 0; }
.checkin-box { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 18px 0 6px; margin: 18px 0; }
.icon.mic.rec { color: var(--bad); border-color: var(--bad); animation: micPulse 1.2s ease-in-out infinite; }
@keyframes micPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(217, 119, 106, .45); } 50% { box-shadow: 0 0 0 7px rgba(217, 119, 106, 0); } }
.msg-meta { margin-top: 10px; font-size: 11px; color: var(--muted); letter-spacing: .04em; }
.composer textarea { flex: 1; min-width: 0; resize: none; min-height: 44px; max-height: 220px; border-radius: 22px; padding: 11px 16px; line-height: 1.45; }
.composer .attach, .composer .mic { cursor: pointer; width: 44px; height: 44px; flex: none; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line-2); border-radius: 50%; background: transparent; color: var(--ink-2); }
.composer .attach svg, .composer .mic svg { width: 17px; height: 17px; }
.composer .mic { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 55%, transparent); }
.composer .primary { height: 44px; }
.img-chip { position: relative; display: inline-block; margin-bottom: 10px; }
.img-chip img { height: 84px; border-radius: 10px; border: 1px solid var(--line-2); display: block; }
.img-chip button { position: absolute; top: -8px; right: -8px; width: 26px; height: 26px; background: var(--surface); font-size: 11px; }
.coach-empty { margin: auto; text-align: center; max-width: 560px; padding: 20px 6px; }
.coach-empty h2 { font-size: 24px; margin: 14px 0 8px; }
.coach-mark { width: 56px; height: 56px; margin: 0 auto; border-radius: 50%; border: 1px solid rgba(201,179,126,.45); display: flex; align-items: center; justify-content: center; }
.coach-mark svg { width: 24px; height: 24px; color: var(--accent); }
.prompt-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 22px; }
.chip { border: 1px solid var(--line-2); background: transparent; color: var(--ink-2); border-radius: 999px; padding: 8px 14px; font-size: 12.5px; cursor: pointer; transition: all .15s ease; }
.chip:hover { border-color: var(--accent); color: var(--ink); }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(5,5,4,.72); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; animation: fade .18s ease; }
.modal { background: var(--surface); border: 1px solid var(--line-2); border-radius: 18px; padding: 30px 32px; width: min(680px, 100%); max-height: 90vh; overflow-y: auto; box-shadow: 0 40px 100px rgba(0,0,0,.55); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.toast { position: fixed; bottom: calc(28px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%) translateY(16px); background: var(--surface-2); color: var(--ink); border: 1px solid rgba(201,179,126,.4); padding: 11px 22px; border-radius: 999px; opacity: 0; pointer-events: none; transition: all .25s ease; font-size: 12.5px; letter-spacing: .04em; z-index: 60; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- calendario ---------- */
.cal-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.cal-bar { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.cal-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-bottom: 18px; }
.leg { background: none; border: 0; padding: 4px 0; display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--ink-2); cursor: pointer; }
.leg i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.leg i.auto-dot { background: transparent; border: 1px dashed var(--ink-2); }
.leg.off { color: var(--muted); text-decoration: line-through; opacity: .55; }
.cal-body { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.ev { display: block; width: 100%; text-align: left; border: 0; cursor: pointer; font-size: 11.5px; line-height: 1.35; padding: 2px 7px; border-radius: 5px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); background: color-mix(in srgb, var(--c) 22%, transparent); border-left: 2px solid var(--c); }
.ev:hover { background: color-mix(in srgb, var(--c) 34%, transparent); }
.ev.auto { background: transparent; border: 1px dashed color-mix(in srgb, var(--c) 60%, transparent); border-left: 2px solid var(--c); color: var(--ink-2); }
.ev.done { opacity: .55; }
.ev .ev-t { color: var(--ink-2); font-variant-numeric: tabular-nums; }
/* mes */
.m-head, .m-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.m-head div { padding: 10px 8px; font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .14em; text-align: center; border-bottom: 1px solid var(--line); }
.m-cell { min-height: 118px; padding: 6px 6px 8px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); cursor: pointer; min-width: 0; transition: background .15s ease; }
.m-cell:nth-child(7n) { border-right: 0; }
.m-cell:nth-last-child(-n+7) { border-bottom: 0; }
.m-cell:hover { background: var(--surface-2); }
.m-cell.out { background: color-mix(in srgb, var(--page) 60%, transparent); }
.m-cell.out .m-day span { color: var(--muted); }
.m-day { text-align: center; margin-bottom: 3px; }
.m-day span { display: inline-flex; width: 26px; height: 26px; align-items: center; justify-content: center; border-radius: 50%; font-size: 12.5px; color: var(--ink-2); }
.m-day span:hover { background: var(--surface-3); }
.m-cell.today .m-day span { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.m-more { background: none; border: 0; font-size: 11px; color: var(--ink-2); padding: 2px 7px; cursor: pointer; }
.m-more:hover { color: var(--accent); }
.m-dots { display: none; }
/* semana y día */
.w-head, .w-allday, .w-grid { display: grid; grid-template-columns: 56px repeat(var(--n), minmax(0, 1fr)); }
.w-head { border-bottom: 1px solid var(--line); }
.w-head > div { padding: 10px 4px; text-align: center; cursor: pointer; }
.w-head span { display: block; font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .14em; }
.w-head b { display: inline-flex; width: 34px; height: 34px; align-items: center; justify-content: center; border-radius: 50%; font-weight: 300; font-size: 20px; margin-top: 2px; }
.w-head .today b { background: var(--accent); color: var(--accent-ink); font-weight: 500; }
.w-head .today span { color: var(--accent); }
.w-allday { border-bottom: 1px solid var(--line-2); }
.w-allday > div { padding: 4px 3px 6px; border-left: 1px solid var(--line); min-width: 0; min-height: 30px; cursor: pointer; }
.w-allday > .w-lbl { border-left: 0; font-size: 10px; color: var(--muted); text-align: right; padding: 8px 8px 0 0; cursor: default; }
.w-grid { max-height: min(68vh, 720px); overflow-y: auto; position: relative; }
.w-hours div { height: var(--h); font-size: 10.5px; color: var(--muted); text-align: right; padding-right: 8px; transform: translateY(-7px); font-variant-numeric: tabular-nums; }
.w-hours div:first-child { visibility: hidden; }
.w-col { position: relative; border-left: 1px solid var(--line); min-width: 0; }
.w-col.today { background: var(--accent-soft); }
.w-slot { height: var(--h); border-top: 1px solid var(--line); cursor: pointer; }
.w-slot:hover { background: var(--surface-2); }
.w-ev { position: absolute; margin: 0; padding: 4px 7px; border-radius: 6px; white-space: normal; display: flex; flex-direction: column; gap: 1px; overflow: hidden; z-index: 1; }
.w-ev b { font-weight: 500; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w-ev span { font-size: 11px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w-now { position: absolute; left: 0; right: 0; height: 2px; background: var(--bad); z-index: 2; pointer-events: none; }
.w-now::before { content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--bad); }
/* agenda */
.cal-agenda { padding: 6px 0; }
.ag-day { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 14px; padding: 12px 22px; border-bottom: 1px solid var(--line); }
.ag-day:last-child { border-bottom: 0; }
.ag-date { cursor: pointer; display: flex; align-items: baseline; gap: 8px; }
.ag-date b { font-size: 24px; font-weight: 300; min-width: 30px; }
.ag-date span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }
.ag-day.today .ag-date b, .ag-day.today .ag-date span { color: var(--accent); }
.ag-list { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ag-ev { display: grid; grid-template-columns: 10px 112px minmax(0, 1fr); gap: 12px; align-items: center; text-align: left; background: none; border: 0; padding: 7px 8px; border-radius: 8px; cursor: pointer; color: var(--ink); min-width: 0; }
.ag-ev:hover { background: var(--surface-2); }
.ag-ev i { width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.ag-ev.auto i { background: transparent; border: 2px solid var(--c); }
.ag-ev.auto { color: var(--ink-2); }
.ag-ev.done { opacity: .55; }
.ag-time { font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.ag-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* formulario y detalle */
.ev-title { width: 100%; background: transparent; border: 0; border-bottom: 1px solid var(--line-2); border-radius: 0; font-family: var(--serif); font-size: 24px; padding: 6px 0 10px; outline: none; }
.ev-title:focus { border-bottom-color: var(--accent); }
.ev-days .scale { grid-template-columns: repeat(7, 1fr); }
.ev-dot { width: 12px; height: 12px; border-radius: 4px; flex: none; }
.copy-row { display: flex; gap: 10px; margin-top: 6px; }
label.file-btn { display: inline-flex; align-items: center; cursor: pointer; border: 1px solid var(--line-2); border-radius: 999px; padding: 6px 13px; font-size: 11.5px; }
label.file-btn:hover { border-color: var(--accent); }
.bank-list { display: flex; flex-direction: column; }
.bank-row { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.bank-row:last-child { border-bottom: 0; }
.bank-row > div:first-child { min-width: 0; flex: 1 1 220px; }
.bank-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.src-tag { font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent); border-radius: 999px; padding: 1px 7px; margin-left: 6px; white-space: nowrap; }
tr.dim-row td { color: var(--muted); }
.ingest-kv { grid-template-columns: auto minmax(0, 1fr); }
.ingest-kv > div:nth-child(even) { text-align: left; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.ingest-kv code { word-break: break-all; font-size: 12px; }
.copy-row input { flex: 1; min-width: 0; font-size: 12px; }

/* entrar (versión del servidor) */
body.login-mode .nav, body.login-mode .tabbar { display: none !important; }
body.login-mode .shell { grid-template-columns: minmax(0, 1fr); }
.login-card { max-width: 380px; margin: 10vh auto 0; display: flex; flex-direction: column; gap: 16px; text-align: center; }
.login-card .field { text-align: left; }
.login-mark { width: 56px; height: 56px; border-radius: 12px; margin: 0 auto; border: 1px solid var(--line-2); }

/* barra inferior del iPhone */
.tabbar { display: none; }

@media (max-width: 1100px) {
  main { padding: 40px 32px 80px; }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.c3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  body { font-size: 15px; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  body { overflow-x: hidden; }
  .nav { display: none; }
  main { padding: calc(28px + env(safe-area-inset-top)) 18px calc(104px + env(safe-area-inset-bottom)); }
  h1 { font-size: 32px; }
  .page-head { margin-bottom: 24px; padding-bottom: 20px; }
  .grid.c2, .grid.c3 { grid-template-columns: 1fr; }
  .form-grid, .form-grid.c3 { grid-template-columns: 1fr 1fr; }
  .field.half { grid-column: 1 / -1; }
  .tiles, .rings { grid-template-columns: 1fr 1fr; }
  .tile, .ring-card { border-top: 1px solid var(--line); margin-top: -1px; }
  .tile { padding: 18px; }
  .tile .t-value { font-size: 28px; }
  .ring { width: 88px; height: 88px; }
  .card { padding: 22px 18px; }
  .board { grid-template-columns: repeat(4, 80vw); }
  .launcher { grid-template-columns: repeat(3, 1fr); }
  .subnav { gap: 20px; margin-top: -6px; }
  .week-strip { grid-template-columns: repeat(4, 1fr); }
  .day-pill { border-top: 1px solid var(--line); margin-top: -1px; }
  .compare-controls { grid-template-columns: 1fr 1fr; }
  .compare-controls .field:first-child { grid-column: 1 / -1; }
  .compare-grid img { height: 340px; }
  .streak-row { grid-template-columns: 76px 1fr 40px; }
  .meal-item { grid-template-columns: 1fr 58px 12px 64px 28px; }
  .coach { min-height: calc(100vh - 300px); border-radius: 16px; }
  .chat { max-height: none; padding: 18px 14px; }
  .msg { max-width: 92%; }
  .coach-threads { padding: 12px 14px; }
  .composer .composer-row { gap: 6px; }
  .composer button.primary { padding: 10px 14px; letter-spacing: .06em; }
  .composer textarea { padding: 11px 12px; }
  .composer textarea::placeholder { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .composer .attach, .composer .mic { width: 40px; height: 40px; margin-bottom: 2px; }
  .composer { padding: 10px; position: sticky; bottom: calc(68px + env(safe-area-inset-bottom)); background: var(--surface); border-radius: 0 0 16px 16px; }
  .meal-item .num.dim { display: none; }
  .cal-actions { width: 100%; }
  .cal-actions button { flex: 1; }
  .cal-body { margin: 0 -6px; }
  .m-cell { min-height: 62px; padding: 4px 2px 6px; }
  .m-cell .ev, .m-cell .m-more { display: none; }
  .m-dots { display: flex; justify-content: center; gap: 3px; flex-wrap: wrap; }
  .m-dots i { width: 5px; height: 5px; border-radius: 50%; }
  .m-head div { letter-spacing: .06em; padding: 8px 0; }
  .w-head, .w-allday, .w-grid { grid-template-columns: 38px repeat(var(--n), minmax(0, 1fr)); }
  .w-head b { width: 28px; height: 28px; font-size: 16px; }
  .w-head span { letter-spacing: .04em; font-size: 9.5px; }
  .w-allday > .w-lbl { font-size: 0; padding: 0; }
  .w-hours div { font-size: 9.5px; padding-right: 4px; }
  .w-ev { padding: 3px 4px; }
  .w-ev span { display: none; }
  .ag-day { grid-template-columns: 54px minmax(0, 1fr); gap: 8px; padding: 12px 12px; }
  .ag-date { flex-direction: column; gap: 0; }
  .ag-ev { grid-template-columns: 8px 78px minmax(0, 1fr); gap: 8px; padding: 7px 4px; }
  .ag-time { font-size: 11.5px; }
  input, select, textarea { font-size: 16px; } /* evita el zoom de iOS */
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: rgba(11,11,10,.86); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border-top: 1px solid var(--line); padding: 8px 6px calc(8px + env(safe-area-inset-bottom)); }
  :root[data-theme="light"] .tabbar { background: rgba(247,244,238,.88); }
  .tabbar button { background: none; border: 0; display: flex; flex-direction: column; align-items: center; gap: 5px; color: var(--muted); font-size: 10px; letter-spacing: .06em; padding: 4px 0; cursor: pointer; }
  .tabbar button svg { width: 21px; height: 21px; }
  .tabbar button.active { color: var(--accent); }
}
