/* Layout idea: one narrow phone column, a bold calorie ring as the day's summary, bottom tab bar, bottom-sheet for adding food. */
:root{
  --bg:#F2F4F7; --surface:#FFFFFF; --ink:#141820; --muted:#5D6776; --line:#DFE3E9;
  --accent:#1F55F0; --accent-ink:#FFFFFF; --accent-soft:#E6ECFE;
  --fuel:#F2711C; --good:#11914A; --warn:#D93B40;
  --protein:#7357F6; --carbs:#E0A800; --fat:#0F9F8F;
  --display:'Archivo', 'Arial Narrow', system-ui, sans-serif;
  --body:'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --r:14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){
    --bg:#0E1116; --surface:#171B22; --ink:#EDF0F5; --muted:#99A3B2; --line:#2A303B;
    --accent:#6088FF; --accent-ink:#0B0F1A; --accent-soft:#1C2643;
    --fuel:#FF8B3D; --good:#3CCB7F; --warn:#FF6B6F;
    --protein:#9C87FF; --carbs:#F4C430; --fat:#2CCFBD;
    color-scheme: dark;
  }
}
:root[data-theme="dark"]{
  --bg:#0E1116; --surface:#171B22; --ink:#EDF0F5; --muted:#99A3B2; --line:#2A303B;
  --accent:#6088FF; --accent-ink:#0B0F1A; --accent-soft:#1C2643;
  --fuel:#FF8B3D; --good:#3CCB7F; --warn:#FF6B6F;
  --protein:#9C87FF; --carbs:#F4C430; --fat:#2CCFBD;
  color-scheme: dark;
}
*{box-sizing:border-box}
html,body{height:100%;margin:0}
body{background:var(--bg);color:var(--ink);font-family:var(--body);font-size:16px;line-height:1.45;-webkit-font-smoothing:antialiased}
button,input,select,textarea{font:inherit;color:inherit}
button{cursor:pointer}
:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.num{font-variant-numeric:tabular-nums}
.app{max-width:520px;margin:0 auto;min-height:100%;display:flex;flex-direction:column;padding:env(safe-area-inset-top) 0 0}
header.top{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:16px 18px 8px}
.brand{font-family:var(--display);font-weight:800;font-size:22px;letter-spacing:-.02em;display:flex;align-items:center;gap:8px}
.brand i{display:inline-block;width:10px;height:10px;border-radius:3px;background:var(--fuel);transform:rotate(45deg)}
.who{font-size:13px;color:var(--muted);text-align:right}
main{flex:1;padding:4px 16px calc(96px + env(safe-area-inset-bottom));display:flex;flex-direction:column;gap:16px}
h2{font-family:var(--display);font-weight:700;font-size:20px;margin:0;letter-spacing:-.01em;text-wrap:balance}
h3{font-size:13px;font-weight:600;text-transform:uppercase;letter-spacing:.06em;color:var(--muted);margin:0}
.panel{background:var(--surface);border:1px solid var(--line);border-radius:var(--r);padding:16px}
.muted{color:var(--muted)}
.small{font-size:13px}
.row{display:flex;align-items:center;gap:10px}
.between{justify-content:space-between}
.banner{font-size:13px;padding:10px 12px;border-radius:10px;background:var(--accent-soft);color:var(--ink)}
.banner.warn{background:color-mix(in srgb,var(--warn) 14%,var(--surface))}

/* buttons */
.btn{border:0;border-radius:12px;padding:12px 16px;font-weight:600;background:var(--accent);color:var(--accent-ink);display:inline-flex;align-items:center;justify-content:center;gap:8px;min-height:46px}
.btn.ghost{background:transparent;color:var(--ink);border:1px solid var(--line)}
.btn.soft{background:var(--accent-soft);color:var(--accent)}
.btn.block{width:100%}
.btn:disabled{opacity:.55;cursor:default}
.icon-btn{border:1px solid var(--line);background:var(--surface);width:40px;height:40px;border-radius:10px;display:inline-grid;place-items:center;padding:0}
.icon-btn svg{width:18px;height:18px}
.chips{display:flex;gap:8px;flex-wrap:wrap}
.chip{border:1px solid var(--line);background:var(--surface);border-radius:999px;padding:8px 14px;font-weight:600;font-size:14px}
.chip[aria-pressed="true"]{background:var(--ink);color:var(--bg);border-color:var(--ink)}
.seg{display:flex;background:var(--bg);border:1px solid var(--line);border-radius:12px;padding:3px;gap:3px}
.seg button{flex:1;border:0;background:transparent;border-radius:9px;padding:8px 6px;font-weight:600;font-size:14px;color:var(--muted)}
.seg button[aria-pressed="true"]{background:var(--surface);color:var(--ink);box-shadow:0 1px 2px rgba(0,0,0,.08)}

/* date nav */
.datenav{display:flex;align-items:center;justify-content:space-between}
.datenav strong{font-family:var(--display);font-size:20px;font-weight:700}

/* ring */
.summary{display:grid;grid-template-columns:150px 1fr;gap:18px;align-items:center}
.ringwrap{position:relative;width:150px;height:150px}
.ring{width:150px;height:150px}
.ring circle{fill:none;stroke-width:12}
.ring .bg{stroke:var(--line)}
.ring .fg{stroke:var(--fuel);stroke-linecap:round;transition:stroke-dasharray .5s ease}
.ring.over .fg{stroke:var(--warn)}
.ringtxt{position:absolute;inset:0;display:grid;place-content:center;text-align:center}
.ringtxt b{font-family:var(--display);font-size:32px;font-weight:800;line-height:1;letter-spacing:-.02em}
.ringtxt span{font-size:12px;color:var(--muted)}
.stat{display:flex;flex-direction:column;gap:2px}
.stat .big{font-family:var(--display);font-weight:700;font-size:22px;line-height:1.1}
.macros{display:flex;flex-direction:column;gap:8px;margin-top:10px}
.macro{display:grid;grid-template-columns:62px 1fr 44px;align-items:center;gap:8px;font-size:13px}
.bar{height:6px;border-radius:6px;background:var(--line);overflow:hidden}
.bar i{display:block;height:100%;border-radius:6px}
@media (max-width:380px){.summary{grid-template-columns:1fr;justify-items:center}.summary>div:last-child{width:100%}}

/* meals */
.meal{display:flex;flex-direction:column;gap:2px}
.meal-head{display:flex;justify-content:space-between;align-items:baseline;padding:4px 0 6px;border-bottom:1px solid var(--line)}
.meal-head b{font-weight:700}
.item{display:grid;grid-template-columns:1fr auto 32px;gap:8px;align-items:center;padding:10px 0;border-bottom:1px dashed var(--line)}
.item:last-child{border-bottom:0}
.item .nm{font-weight:500;overflow-wrap:anywhere}
.item .sub{font-size:12px;color:var(--muted)}
.item .kc{font-weight:700}
.x{border:0;background:transparent;color:var(--muted);width:32px;height:32px;border-radius:8px;display:grid;place-items:center;padding:0}
.x:hover{background:var(--bg);color:var(--warn)}
.x svg{width:16px;height:16px}
.empty{text-align:center;padding:22px 10px;color:var(--muted);font-size:14px}

.fab{position:fixed;left:50%;transform:translateX(-50%);bottom:calc(78px + env(safe-area-inset-bottom));z-index:5;box-shadow:0 8px 24px rgba(20,24,32,.25);border-radius:999px;padding:14px 24px}

/* tabs */
nav.tabs{position:fixed;left:0;right:0;bottom:0;z-index:6;background:var(--surface);border-top:1px solid var(--line);padding:6px 8px calc(6px + env(safe-area-inset-bottom))}
nav.tabs .in{max-width:520px;margin:0 auto;display:grid;grid-template-columns:repeat(5,1fr)}
nav.tabs button{border:0;background:transparent;display:flex;flex-direction:column;align-items:center;gap:2px;padding:6px 0;font-size:11px;font-weight:600;color:var(--muted)}
nav.tabs button svg{width:22px;height:22px}
nav.tabs button[aria-current="page"]{color:var(--accent)}

/* sheet */
.overlay{position:fixed;inset:0;background:rgba(10,12,16,.45);z-index:20;display:flex;align-items:flex-end;justify-content:center}
.overlay[hidden]{display:none}
.sheet{background:var(--surface);width:100%;max-width:520px;max-height:92%;overflow-y:auto;border-radius:20px 20px 0 0;padding:14px 16px calc(20px + env(safe-area-inset-bottom));display:flex;flex-direction:column;gap:14px}
.grab{width:40px;height:4px;border-radius:4px;background:var(--line);margin:0 auto}
label.f{display:flex;flex-direction:column;gap:6px;font-size:13px;font-weight:600;color:var(--muted)}
input.t,select.t,textarea.t{width:100%;border:1px solid var(--line);background:var(--bg);border-radius:10px;padding:11px 12px;font-size:16px;color:var(--ink);font-weight:400}
textarea.t{min-height:76px;resize:vertical}
.grid2{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.grid3{display:grid;grid-template-columns:repeat(3,1fr);gap:10px}
.photo-pick{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.photo-pick label{border:1.5px dashed var(--line);border-radius:12px;padding:16px 8px;text-align:center;font-weight:600;font-size:14px;cursor:pointer;display:flex;flex-direction:column;align-items:center;gap:6px;background:var(--bg)}
.photo-pick label svg{width:24px;height:24px;color:var(--accent)}
.photo-pick input{position:absolute;width:1px;height:1px;opacity:0}
.preview{width:100%;max-height:240px;object-fit:cover;border-radius:12px;display:block}
.res-row{display:grid;grid-template-columns:1fr 70px 76px 30px;gap:6px;align-items:center}
.res-row input{padding:8px;font-size:15px}
.res-head{font-size:11px;text-transform:uppercase;letter-spacing:.05em;color:var(--muted);font-weight:600}
.swap{border-left:3px solid var(--good);padding:6px 10px;background:color-mix(in srgb,var(--good) 8%,var(--surface));border-radius:0 8px 8px 0;font-size:14px}
.thinking{display:flex;align-items:center;gap:10px;color:var(--muted);font-size:14px}
.spin{width:18px;height:18px;border-radius:50%;border:2.5px solid var(--line);border-top-color:var(--accent);animation:sp 0.9s linear infinite}
@keyframes sp{to{transform:rotate(360deg)}}
@media (prefers-reduced-motion:reduce){.spin{animation-duration:3s}.ring .fg{transition:none}}

/* history */
.chart{width:100%;height:auto;display:block}
.chart text{fill:var(--muted);font-size:10px;font-family:var(--body)}
.chart .grid{stroke:var(--line);stroke-width:1}
.chart .goal{stroke:var(--fuel);stroke-width:1.5;stroke-dasharray:4 4}
.chart .goaltxt{fill:var(--fuel);font-weight:700}
.tiles{display:grid;grid-template-columns:repeat(3,1fr);gap:10px}
.tile{background:var(--surface);border:1px solid var(--line);border-radius:12px;padding:12px}
.tile b{display:block;font-family:var(--display);font-size:22px;font-weight:700;line-height:1.1}
.tile span{font-size:12px;color:var(--muted)}

/* workouts */
.steppers{display:flex;flex-direction:column}
.stepper{display:flex;align-items:center;justify-content:space-between;padding:8px 0;border-bottom:1px solid var(--line)}
.stepper:last-child{border-bottom:0}
.stepper .ctl{display:flex;align-items:center;gap:10px}
.stepper .ctl b{width:22px;text-align:center;font-size:17px}
.stepper .icon-btn{width:34px;height:34px;font-size:18px;font-weight:700}
.wgroup{display:flex;flex-direction:column}
.wgroup h4{margin:10px 0 4px;font-size:13px;font-weight:700;color:var(--accent);text-transform:uppercase;letter-spacing:.06em}
.ex{display:grid;grid-template-columns:24px 1fr auto;gap:10px;align-items:center;padding:10px 0;border-bottom:1px solid var(--line)}
.ex .n{font-family:var(--display);font-weight:700;color:var(--muted);font-size:14px}
.ex .nm{font-weight:600}
.ex .sc{font-size:13px;color:var(--muted)}
.tag{display:inline-block;font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:.05em;padding:2px 6px;border-radius:5px;background:var(--accent-soft);color:var(--accent);margin-left:6px;vertical-align:2px}
.swapbtn{border:1px solid var(--line);background:var(--surface);border-radius:8px;padding:6px 10px;font-size:13px;font-weight:600}
.routine{border-top:1px solid var(--line);padding:10px 0}
.routine:first-of-type{border-top:0}
.routine summary{cursor:pointer;display:flex;justify-content:space-between;align-items:center;list-style:none;gap:8px}
.routine summary::-webkit-details-marker{display:none}
.routine ol{margin:8px 0 4px;padding-left:22px;font-size:14px}

/* family */
.member{display:grid;grid-template-columns:40px 1fr auto;gap:12px;align-items:center;padding:12px 0;border-bottom:1px solid var(--line)}
.member:last-child{border-bottom:0}
.avatar{width:40px;height:40px;border-radius:50%;display:grid;place-items:center;font-family:var(--display);font-weight:800;color:#fff}
.streak{font-family:var(--display);font-weight:800;font-size:18px;text-align:right;line-height:1}
.streak span{display:block;font-family:var(--body);font-size:11px;font-weight:600;color:var(--muted)}
.me-tag{font-size:11px;color:var(--accent);font-weight:700;margin-left:6px}

.toast{position:fixed;left:50%;bottom:calc(140px + env(safe-area-inset-bottom));transform:translateX(-50%);background:var(--ink);color:var(--bg);padding:10px 16px;border-radius:10px;font-size:14px;font-weight:600;z-index:40;max-width:90%;text-align:center}
.toast[hidden]{display:none}
.loading{display:grid;place-items:center;gap:12px;padding:60px 0;color:var(--muted)}

/* ---- added for the hosted version ---- */
.login{min-height:100%;display:flex;flex-direction:column;justify-content:center;gap:22px;padding:32px 20px calc(32px + env(safe-area-inset-bottom));max-width:420px;margin:0 auto}
.login .brand{font-size:40px;justify-content:center}
.login .brand i{width:16px;height:16px;border-radius:4px}
.login p{text-align:center;margin:0}
.login input.t{font-size:20px;padding:14px}
.pin{letter-spacing:.4em;text-align:center}
.list{display:flex;flex-direction:column}
.food-row{display:grid;grid-template-columns:1fr auto;gap:10px;align-items:center;padding:12px 4px;border:0;border-bottom:1px solid var(--line);background:transparent;text-align:left;width:100%;border-radius:0}
.food-row:hover{background:var(--bg)}
.food-row .nm{font-weight:600;overflow-wrap:anywhere}
.food-row .sub{font-size:12px;color:var(--muted)}
.food-row .kc{font-weight:700;white-space:nowrap}
.list-title{font-size:12px;font-weight:700;letter-spacing:.06em;text-transform:uppercase;color:var(--muted);margin:10px 0 2px}
.sel-totals{display:grid;grid-template-columns:repeat(4,1fr);gap:8px;text-align:center}
.sel-totals div{background:var(--bg);border-radius:10px;padding:10px 4px}
.sel-totals b{display:block;font-family:var(--display);font-size:20px}
.sel-totals span{font-size:11px;color:var(--muted)}
.check{display:flex;align-items:center;gap:10px;font-size:15px}
.check input{width:20px;height:20px}
.mine-tag{font-size:10px;font-weight:700;color:var(--fuel);text-transform:uppercase;letter-spacing:.05em;margin-left:6px}
.datepick{position:relative;display:inline-flex;align-items:center;gap:8px;padding:6px 12px;border-radius:10px;cursor:pointer;color:var(--ink)}
.datepick:hover{background:var(--surface)}
.datepick svg{color:var(--accent)}
.datepick input{position:absolute;inset:0;width:100%;height:100%;opacity:0;cursor:pointer;border:0;padding:0}
section.meal{gap:2px;padding:12px 16px}
section.meal .meal-head{border-bottom:1px solid var(--line);padding:0 0 8px;align-items:center}

/* ---- color themes (chosen under Me > Colors) ---- */
:root[data-palette="blush"]{
  --bg:#FBF4EF; --surface:#FFFFFF; --ink:#3B2A30; --muted:#8C747A; --line:#F1DED7;
  --accent:#C2557A; --accent-ink:#FFFFFF; --accent-soft:#F9E3EB;
  --fuel:#EC8DA8; --good:#4E9F78; --warn:#C9443F;
  --protein:#A777C9; --carbs:#D9A54A; --fat:#5FAFA3; color-scheme: light;
}
:root[data-palette="forest"]{
  --bg:#F0F4EF; --surface:#FFFFFF; --ink:#1C2A21; --muted:#5D6F62; --line:#D8E2D7;
  --accent:#2F7D4F; --accent-ink:#FFFFFF; --accent-soft:#DDEFE3;
  --fuel:#E3A13B; --good:#2F7D4F; --warn:#C8463D;
  --protein:#6B5BD0; --carbs:#C99400; --fat:#1E9E8F; color-scheme: light;
}
:root[data-palette="sunset"]{
  --bg:#FFF5EE; --surface:#FFFFFF; --ink:#2B1D18; --muted:#7A6259; --line:#F2DED3;
  --accent:#D9472B; --accent-ink:#FFFFFF; --accent-soft:#FCE2D8;
  --fuel:#F29D38; --good:#2E9A5C; --warn:#B8302A;
  --protein:#8256D8; --carbs:#D69E00; --fat:#1A9C8C; color-scheme: light;
}
:root[data-palette="midnight"]{
  --bg:#0F1020; --surface:#1A1B33; --ink:#ECEBFA; --muted:#A3A2C2; --line:#2C2D4D;
  --accent:#8E7CFF; --accent-ink:#0F1020; --accent-soft:#262650;
  --fuel:#FF8A5B; --good:#46D19A; --warn:#FF6B7A;
  --protein:#B39DFF; --carbs:#F4C430; --fat:#34D1C1; color-scheme: dark;
}
.swatches{display:grid;grid-template-columns:repeat(5,1fr);gap:10px}
.swatch{border:2px solid var(--line);background:var(--surface);border-radius:14px;padding:8px 4px;display:flex;flex-direction:column;align-items:center;gap:6px;font-size:12px;font-weight:600;color:var(--ink)}
.swatch[aria-pressed="true"]{border-color:var(--accent);box-shadow:0 0 0 2px var(--accent-soft)}
.swatch .dots{display:flex}
.swatch .dots i{width:16px;height:16px;border-radius:50%;margin-left:-4px;border:2px solid var(--surface)}
.swatch .dots i:first-child{margin-left:0}

[hidden]{display:none !important}
