:root {
  --bg: #F5F4F8; --card: #fff; --ink: #17161D; --muted: #5F5E6B; --line: #E4E2EC; --line2: #EEECF3;
  --accent: #6D28D9; --accent-ink: #5B21B6; --accent-soft: #EDE7FB; --accent-mid: #B9A2EE; --on-accent: #fff;
  --tag: #F1E6D8; --tag-ink: #7A4510; --off: #E9E7EF; --border: #D6D3DF; --box-line: #B9B6C4;
  --good: #15803D; --bad: #B91C1C; --shadow: rgba(109, 40, 217, .35);
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #121117; --card: #1C1B23; --ink: #ECEAF2; --muted: #A3A1AE; --line: #2C2A36; --line2: #24222D;
  --accent: #8B5CF6; --accent-ink: #C4B5FD; --accent-soft: #2E2547; --accent-mid: #5B4A8C; --on-accent: #fff;
  --tag: #3A2C1C; --tag-ink: #E8C79A; --off: #2A2833; --border: #3A3745; --box-line: #4A4756;
  --good: #4ADE80; --bad: #F87171; --shadow: rgba(0, 0, 0, .45); color-scheme: dark;
} }
:root[data-theme="dark"] {
  --bg: #121117; --card: #1C1B23; --ink: #ECEAF2; --muted: #A3A1AE; --line: #2C2A36; --line2: #24222D;
  --accent: #8B5CF6; --accent-ink: #C4B5FD; --accent-soft: #2E2547; --accent-mid: #5B4A8C; --on-accent: #fff;
  --tag: #3A2C1C; --tag-ink: #E8C79A; --off: #2A2833; --border: #3A3745; --box-line: #4A4756;
  --good: #4ADE80; --bad: #F87171; --shadow: rgba(0, 0, 0, .45); color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink);
  font: 14px/1.4 Inter, system-ui, sans-serif; -webkit-tap-highlight-color: transparent; }
h1, h2, h3 { font-family: 'Space Grotesk', Inter, sans-serif; margin: 0; letter-spacing: -.01em; }
h1 { font-size: 26px; } h2 { font-size: 17px; }
a { color: var(--accent-ink); }
button, input, select { font: inherit; color: inherit; }

/* El marco queda fijo al área visible: solo .sc hace scroll y la barra de abajo nunca se sale de la pantalla */
html, body { overflow: hidden; overscroll-behavior: none; }
#app { position: fixed; top: 0; bottom: 0; left: 0; right: 0; margin: 0 auto; max-width: 560px; display: flex; flex-direction: column; }
.sc { overscroll-behavior: contain; }
.hd { padding: calc(16px + env(safe-area-inset-top)) 20px 10px; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.hd .col { display: flex; flex-direction: column; gap: 2px; }
.sc { flex: 1; overflow-y: auto; padding: 4px 16px 24px; display: flex; flex-direction: column; gap: 14px; }
.sc > * { flex-shrink: 0; }
.cd { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; text-decoration: none; color: var(--ink); }
.lb { font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.mt { color: var(--muted); } .sm { font-size: 12px; }
.big { font-family: 'Space Grotesk', Inter, sans-serif; font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.sb { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.rw { display: flex; align-items: center; gap: 10px; }
.g3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.g2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.g7 { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.tg { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--tag); color: var(--tag-ink); font-size: 11px; font-weight: 600; white-space: nowrap; }
.sep { border-top: 1px solid var(--line2); }
.empty { color: var(--muted); font-size: 13px; padding: 4px 0; }

.box { width: 28px; height: 28px; border-radius: 8px; border: 2px solid var(--box-line); background: var(--card); color: transparent;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; padding: 0; cursor: pointer; }
.box.on { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.task { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.task .txt { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.task.done .t { text-decoration: line-through; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; }
.chip { min-height: 40px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--card);
  font-weight: 500; font-size: 13px; cursor: pointer; white-space: nowrap; }
.chip.on { border-color: var(--accent); background: var(--accent); color: var(--on-accent); font-weight: 600; }
.chip.half { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }

.add { display: flex; gap: 6px; flex-wrap: wrap; }
.add input, .add select { min-height: 44px; border: 1px solid var(--border); border-radius: 10px; padding: 0 10px; background: var(--card); }
.add input[name=title], .add input[name=note] { flex: 1 1 160px; min-width: 0; }
.btn { min-height: 44px; padding: 0 16px; border-radius: 10px; border: 0; background: var(--accent); color: var(--on-accent); font-weight: 600; cursor: pointer; }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); }

.day { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0; min-height: 64px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); cursor: pointer; }
.day strong { font-size: 17px; font-family: 'Space Grotesk', sans-serif; }
.day.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.day.today:not(.on) { border-color: var(--accent); }
.wkhd { display: flex; align-items: center; justify-content: space-between; }
.arrow { min-width: 44px; min-height: 44px; border: 0; background: transparent; font-size: 20px; cursor: pointer; color: var(--muted); }

.hrow { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 6px 0; }
.wk { display: flex; gap: 3px; flex-shrink: 0; }
.sq { width: 22px; height: 22px; border-radius: 5px; border: 0; padding: 0; cursor: pointer; background: var(--off); }
.sq.on { background: var(--accent); } .sq.half { background: var(--accent-mid); }
.sq.free { background: var(--card); border: 1px dashed var(--box-line); }
.sq.today { outline: 2px solid var(--ink); outline-offset: 1px; }
.sqh { width: 22px; text-align: center; font-size: 10px; font-weight: 600; color: var(--muted); }
.sqh.on { color: var(--ink); }
span.sq { display: inline-block; flex-shrink: 0; }
.bar { height: 6px; border-radius: 3px; background: var(--off); overflow: hidden; }
.bar > div { height: 100%; background: var(--accent); }

.mic { display: flex; align-items: center; gap: 10px; background: var(--accent); color: var(--on-accent); border-radius: 16px; padding: 16px; text-decoration: none; }
.tile { display: flex; flex-direction: column; gap: 2px; min-height: 64px; padding: 12px 14px; border-radius: 14px; background: var(--card);
  border: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.tile span { font-size: 12px; color: var(--muted); }
.tile.soon { opacity: .55; }
.amt-in { color: var(--good); } .amt-out { color: var(--ink); }

.nv { display: flex; justify-content: space-around; align-items: center; height: calc(72px + env(safe-area-inset-bottom));
  padding: 0 8px env(safe-area-inset-bottom); background: var(--card); border-top: 1px solid var(--line); flex-shrink: 0; }
.nv a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 56px; min-height: 48px;
  font-size: 11px; color: var(--muted); text-decoration: none; }
.nv a.on { color: var(--accent-ink); font-weight: 600; }
.nv a.mc { width: 58px; height: 58px; min-width: 58px; border-radius: 50%; background: var(--accent); color: var(--on-accent); margin-top: -22px;
  box-shadow: 0 6px 16px var(--shadow); }
.banner { background: var(--tag); color: var(--tag-ink); font-size: 12px; padding: 8px 16px; text-align: center; }
.err { color: var(--bad); font-size: 13px; }
.tbtn { width: 40px; height: 40px; flex-shrink: 0; border-radius: 50%; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  display: flex; align-items: center; justify-content: center; padding: 0; cursor: pointer; }
.tbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
details > summary { cursor: pointer; color: var(--accent-ink); font-weight: 600; font-size: 13px; min-height: 36px; display: flex; align-items: center; }
select { min-height: 36px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); padding: 0 8px; }
.col { display: flex; flex-direction: column; gap: 2px; }
.tg.ok { background: var(--accent-soft); color: var(--accent-ink); }
.gbars { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; }
.gbars .col { display: flex; flex-direction: column; gap: 4px; }
.meal-log { padding: 4px 0; border-top: 1px solid var(--line2); }
.opts { display: flex; flex-direction: column; gap: 8px; padding-top: 6px; }
.opt { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--card); cursor: pointer; }
.opt:hover, .opt:focus-visible { border-color: var(--accent); outline: none; }
.meal-form { display: flex; flex-direction: column; gap: 10px; padding-top: 6px; }
.meal-form > input { min-height: 44px; border: 1px solid var(--border); border-radius: 10px; padding: 0 10px; background: var(--card); }
.gq { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.gq label { display: flex; flex-direction: column; gap: 2px; font-size: 11px; color: var(--muted); text-transform: capitalize; }
.gq input { min-height: 40px; border: 1px solid var(--border); border-radius: 8px; padding: 0 8px; background: var(--card); width: 100%; font-variant-numeric: tabular-nums; }
