:root {
  --bg:#f6f4ef; --card:#fff; --ink:#23221f; --mute:#7a766d; --line:#e6e2d9;
  --accent:#2f8f6b; --accent-soft:#e1f1ea; --gold:#d99a00; --danger:#c0392b; --shadow:0 2px 10px rgba(0,0,0,.07);
}
html.dark {
  --bg:#161614; --card:#222220; --ink:#f0eee8; --mute:#9a968c; --line:#383733;
  --accent:#4cc38a; --accent-soft:#1f3a2f; --danger:#e8695c; --shadow:0 2px 10px rgba(0,0,0,.4);
  color-scheme:dark;
}
* { box-sizing:border-box; }
[hidden] { display:none !important; }
body { margin:0; font:16px/1.45 system-ui, -apple-system, 'Segoe UI', sans-serif; background:var(--bg); color:var(--ink); }
button, select, input { font:inherit; color:inherit; }
button { cursor:pointer; border:1px solid var(--line); background:var(--card); border-radius:999px; padding:8px 16px; min-height:40px; }
button.primary { background:var(--accent); border-color:var(--accent); color:#fff; font-weight:600; }
button.ghost { border-color:transparent; background:transparent; color:var(--mute); }
button.danger { background:var(--danger); border-color:var(--danger); color:#fff; font-weight:600; }
select, input[type=text], input[type=number], input[type=date], input[type=time], textarea { border:1px solid var(--line); border-radius:10px; padding:8px 10px; background:var(--card); }

header { display:flex; align-items:center; gap:8px 10px; padding:12px 20px; max-width:980px; margin:0 auto; flex-wrap:wrap; }
.spacer { flex:1; }
.wrap { max-width:980px; margin:0 auto; padding:0 20px; }
nav { display:flex; gap:4px; background:var(--line); padding:4px; border-radius:999px; width:fit-content; max-width:100%; }
nav button, nav a { border:0; background:transparent; padding:6px 16px; color:var(--mute); border-radius:999px; text-decoration:none; font:inherit; white-space:nowrap; }
nav a { display:inline-flex; align-items:center; }
nav button.on, nav a.on { background:var(--card); color:var(--ink); box-shadow:var(--shadow); font-weight:600; }
nav.sub { overflow-x:auto; scrollbar-width:none; }
nav.sub::-webkit-scrollbar { display:none; }
header select { max-width:130px; text-overflow:ellipsis; }
.pf { position:relative; display:inline-flex; }
.pf .ini { display:none; }
.langbtn { font-weight:600; min-width:0; padding:8px 14px; }
@media (max-width:720px) {
  header { padding:10px 14px; }
  nav.sub { order:3; flex:1 1 100%; width:auto; }
  html dialog.appdlg, html dialog.sheet, html dialog.big { width:100%; max-width:none; margin:auto 0 0; border-radius:20px 20px 0 0; max-height:92vh; overflow-y:auto; }
  button, select, input[type=text], input[type=number], input[type=date], input[type=time] { min-height:44px; }
  nav button, nav a { min-height:40px; min-width:44px; justify-content:center; }
  summary { min-height:44px; display:flex; align-items:center; }
}
@media (max-width:520px) {
  .pf .ini { display:flex; width:44px; height:44px; border-radius:50%; align-items:center; justify-content:center; background:var(--accent-soft); color:var(--accent); font-weight:700; border:1px solid var(--line); }
  .pf select { position:absolute; inset:0; width:100%; height:100%; max-width:none; opacity:0; }
  .langbtn { width:44px; height:44px; padding:0; }
}
@media (max-width:420px) {
  header { gap:6px; }
  nav button, nav a { padding:6px 8px; font-size:15px; }
  nav { gap:2px; }
  .pf .ini, .langbtn { width:40px; height:40px; }
  nav button, nav a { min-width:40px; }
}
@media (max-width:380px) {
  nav button, nav a { padding:6px 7px; font-size:14px; }
}

.gearwrap { position:relative; display:inline-flex; }
.gear svg { display:block; margin:auto; }
.settings { position:absolute; right:0; top:calc(100% + 8px); z-index:30; width:min(300px, calc(100vw - 28px)); background:var(--card); border:1px solid var(--line); border-radius:16px; box-shadow:0 10px 30px rgba(0,0,0,.25); padding:6px 14px; }
.settings .srow { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:8px 0; }
.settings .srow + .srow { border-top:1px solid var(--line); }
.settings .sctl { display:inline-flex; align-items:center; gap:8px; }
.settings .sctl b { min-width:44px; text-align:center; font-variant-numeric:tabular-nums; }

main { max-width:980px; margin:0 auto; padding:4px 20px 60px; }
h2 { font-size:17px; margin:26px 0 10px; }
.hint { color:var(--mute); font-size:14px; }
.card { background:var(--card); border-radius:16px; box-shadow:var(--shadow); padding:16px; }

.seg { display:flex; flex-wrap:wrap; gap:6px; }
.seg button { padding:8px 14px; }
.seg button.on { background:var(--ink); color:var(--bg); border-color:var(--ink); }

.body-fig { display:flex; justify-content:center; gap:18px; }
.body-fig figure { margin:0; text-align:center; }
.body-fig figcaption { font-size:12px; color:var(--mute); }
.bd-base { fill:var(--line); stroke:var(--bg); stroke-width:1; }
.bd-off { fill:var(--mute); fill-opacity:.28; stroke:var(--bg); stroke-width:1; }
.bd-side { fill:var(--accent); fill-opacity:.4; stroke:var(--bg); stroke-width:1; }
.bd-main { fill:var(--accent); stroke:var(--bg); stroke-width:1; }
.legend { display:flex; gap:14px; justify-content:center; flex-wrap:wrap; font-size:13px; color:var(--mute); margin-top:6px; }
.legend i { display:inline-block; width:12px; height:12px; border-radius:3px; vertical-align:-1px; margin-right:5px; background:var(--accent); }
.legend i.side { opacity:.4; }

dialog.appdlg { border:0; border-radius:20px; padding:0; max-width:420px; width:calc(100% - 28px); background:var(--card); color:var(--ink); box-shadow:0 10px 40px rgba(0,0,0,.35); }
dialog.appdlg::backdrop { background:rgba(0,0,0,.5); }
.appdlg form { padding:20px; display:flex; flex-direction:column; gap:14px; }
.appdlg p { margin:0; white-space:pre-line; }
.appdlg input { width:100%; font-size:16px; }
.appdlg .actions { display:flex; gap:8px; justify-content:flex-end; flex-wrap:wrap; }

/* login on: what this person cannot change is hidden (the server refuses it anyway) */
body.guest a[href="/dieta"], body.guest #tabCasa { display:none; }
body.no-write .go, body.no-write #liveFinish { display:none; }
body.no-write:not(.guest) .plusbtn { display:none; }
body.ro-workout #planTools, body.ro-workout #dangerZone, body.ro-workout #pickArea, body.ro-workout #newEx,
body.ro-workout #daysLine button, body.ro-workout #dlgPlan, body.ro-workout #dlgPick { display:none !important; }
body.guest #balance, body.guest .card.diet { display:none; }
