/* ============ Macromic — 4 design languages as token sets ============ */
/* A·Midnight Diner  deep navy ground, cream ink, brass accent            */
/* B·Greengrocer     green-tinted paper, pine ink, sage accent            */
/* C·Butcher's Apron bone ground, oxblood accent, heavy grotesk           */
/* D·Slate & Mustard cool slate paper, charcoal ink, mustard accent       */

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font: 15px/1.45 -apple-system, "Segoe UI", Roboto, Inter, system-ui, sans-serif;
  background: var(--bg); color: var(--ink);
  min-height: 100dvh; max-width: 560px; margin: 0 auto;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
b { font-weight: 700; font-variant-numeric: tabular-nums; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input { font: inherit; }
h1, h2, h3 { margin: 0; font-weight: 750; letter-spacing: -0.015em; }
h1 { font-size: 26px; }
h2 { font-size: 19px; }
h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted); font-weight: 700; margin-bottom: 10px; }
.fine { font-size: 12px; color: var(--muted); margin: 8px 0 0; }
.fine.center, .center { text-align: center; }
.links a { color: var(--accent); text-decoration: none; }

/* ---- tokens ---- */
html[data-theme="midnight"] {
  --bg: #0F1B2D; --surface: #16243A; --surface2: #1C2C46;
  --ink: #F5EFE2; --muted: #94A5BB; --hairline: rgba(245,239,226,.13);
  --accent: #D9A441; --accent-ink: #14213A; --ok: #7FC98F; --warn: #D9A441;
  --shadow: 0 10px 30px rgba(0,0,0,.35); --r: 22px; --r-s: 14px;
}
html[data-theme="greengrocer"] {
  --bg: #F3F7F1; --surface: #FFFFFF; --surface2: #EDF4EA;
  --ink: #17352A; --muted: #6E8577; --hairline: rgba(23,53,42,.12);
  --accent: #4C7A5C; --accent-ink: #F3F7F1; --ok: #3F7D52; --warn: #A8712B;
  --shadow: 0 8px 24px rgba(23,53,42,.10); --r: 20px; --r-s: 13px;
}
html[data-theme="apron"] {
  --bg: #F5F1E9; --surface: #FDFBF7; --surface2: #EFE9DD;
  --ink: #26201B; --muted: #8B7F71; --hairline: rgba(38,32,27,.14);
  --accent: #8C2F2F; --accent-ink: #FDFBF7; --ok: #517A45; --warn: #A45A20;
  --shadow: 0 8px 22px rgba(38,32,27,.12); --r: 14px; --r-s: 9px;
}
html[data-theme="slate"] {
  --bg: #EEF2F6; --surface: #FFFFFF; --surface2: #E4EAF1;
  --ink: #1F2A37; --muted: #64748B; --hairline: rgba(31,42,55,.12);
  --accent: #C29200; --accent-ink: #241C00; --ok: #2E7D5B; --warn: #C29200;
  --shadow: 0 8px 22px rgba(31,42,55,.10); --r: 18px; --r-s: 12px;
}
/* per-language signatures */
html[data-theme="apron"] h1, html[data-theme="apron"] h2 { font-weight: 850; text-transform: uppercase; letter-spacing: .01em; }
html[data-theme="apron"] h3 { color: var(--accent); }
html[data-theme="apron"] .tabbar, html[data-theme="apron"] .card { border-width: 2px; }
html[data-theme="midnight"] .card { border: 1px solid var(--hairline); }
html[data-theme="greengrocer"] .ring-arc { stroke-linecap: round; }
html[data-theme="slate"] .btn.primary { border-radius: 999px; }

/* ---- views ---- */
.view { padding: 18px 18px 12px; animation: pop .18s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } }
#view-app[hidden], .view[hidden], [hidden] { display: none !important; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 14px; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.streak { background: var(--surface2); border-radius: 999px; padding: 7px 13px; font-size: 14px; }

/* ---- cards ---- */
.card { background: var(--surface); border-radius: var(--r); padding: 18px; margin-bottom: 14px; box-shadow: var(--shadow); }
.card .rowlink { display: flex; width: 100%; justify-content: space-between; align-items: center; padding: 11px 2px; border-bottom: 1px solid var(--hairline); font-weight: 600; }
.card .rowlink:last-of-type { border-bottom: 0; }
.chev { color: var(--muted); font-size: 18px; }
.rowlink.danger { color: #C0453B; }

/* ---- ring ---- */
.ringcard { display: flex; gap: 18px; align-items: center; }
.ringwrap { position: relative; width: 148px; height: 148px; flex: none; }
.ring { width: 148px; height: 148px; transform: rotate(-90deg); }
.ring-track, .ring-arc { fill: none; stroke-width: 13; }
.ring-track { stroke: var(--surface2); }
.ring-arc { stroke: var(--accent); stroke-dasharray: 528; stroke-dashoffset: 528; transition: stroke-dashoffset .6s ease; }
.ringlabel { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ringlabel b { font-size: 34px; font-weight: 800; letter-spacing: -0.03em; }
.ringlabel small { color: var(--muted); font-size: 11.5px; }
.macrorows { flex: 1; display: grid; gap: 11px; min-width: 0; }
.mrow { display: grid; grid-template-columns: 12px 62px 1fr auto; gap: 8px; align-items: center; font-size: 13px; }
.mrow b { font-size: 12.5px; color: var(--muted); font-weight: 650; }
.mbar { height: 7px; background: var(--surface2); border-radius: 99px; overflow: hidden; }
.mbar i { display: block; height: 100%; width: 0; border-radius: 99px; transition: width .5s ease; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.dot.p { background: var(--accent); } .dot.c { background: var(--ok); } .dot.f { background: var(--warn); }
.mbar .p { background: var(--accent); } .mbar .c { background: var(--ok); } .mbar .f { background: var(--warn); }

/* ---- meals ---- */
.meals .mhead { margin: 16px 4px 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.meal { display: flex; align-items: center; gap: 12px; background: var(--surface); border-radius: var(--r-s); padding: 13px 14px; margin-bottom: 8px; box-shadow: var(--shadow); }
.meal .mico { width: 40px; height: 40px; border-radius: 12px; background: var(--surface2); display: grid; place-content: center; font-size: 19px; flex: none; }
.meal .mname { font-weight: 650; }
.meal .msub { font-size: 12px; color: var(--muted); }
.meal .mkcal { margin-left: auto; text-align: right; }
.meal .mkcal b { font-size: 16px; }
.meal .mkcal small { display: block; font-size: 11px; color: var(--muted); }
.badge { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; border-radius: 6px; padding: 2px 6px; font-weight: 700; }
.badge.high { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.badge.medium { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.badge.low { background: color-mix(in srgb, #C0453B 16%, transparent); color: #C0453B; }

/* ---- history ---- */
.weekbars { display: flex; gap: 7px; align-items: flex-end; height: 110px; }
.wb { flex: 1; display: grid; gap: 6px; justify-items: center; }
.wb .bar { width: 100%; max-width: 30px; background: var(--accent); border-radius: 6px 6px 3px 3px; min-height: 3px; opacity: .9; }
.wb .bar.over { background: #C0453B; }
.wb .bar.zero { background: var(--surface2); }
.wb small { font-size: 10.5px; color: var(--muted); }
.day { cursor: pointer; }
.day .dmeals { display: none; margin-top: 8px; }
.day.open .dmeals { display: block; }

/* ---- tabbar + fab ---- */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 560px;
  background: var(--surface); border-top: 1px solid var(--hairline);
  display: flex; align-items: center; justify-content: space-around;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); z-index: 40;
}
.tab { display: grid; justify-items: center; gap: 3px; font-size: 10.5px; color: var(--muted); padding: 4px 14px; border-radius: 12px; }
.tab svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tab.on { color: var(--accent); }
.fab {
  width: 58px; height: 58px; border-radius: 50%; background: var(--accent); color: var(--accent-ink);
  display: grid; place-content: center; margin-top: -26px; box-shadow: 0 8px 22px color-mix(in srgb, var(--accent) 45%, transparent);
}
.fab svg { width: 27px; height: 27px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; }

/* ---- sheets ---- */
.sheet {
  position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column;
  background: var(--bg); padding: 10px 18px calc(18px + env(safe-area-inset-bottom));
  overflow-y: auto; animation: up .22s ease-out;
}
@keyframes up { from { transform: translateY(40px); opacity: .4; } }
.sheet[hidden] { display: none !important; }   /* author display beats the hidden attr — keep this */
.sheet-grab { width: 44px; height: 5px; border-radius: 99px; background: var(--hairline); margin: 2px auto 12px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.x { font-size: 16px; color: var(--muted); background: var(--surface2); width: 32px; height: 32px; border-radius: 50%; }
.scansleft { color: var(--muted); font-size: 12.5px; margin: 2px 0 14px; }

.seg { display: flex; background: var(--surface2); border-radius: 12px; padding: 4px; gap: 4px; margin-bottom: 14px; }
.seg button { flex: 1; padding: 9px 6px; border-radius: 9px; color: var(--muted); font-weight: 650; font-size: 13.5px; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.shutter { width: 100%; display: grid; place-content: center; justify-items: center; gap: 10px;
  padding: 34px 10px; border: 2px dashed color-mix(in srgb, var(--accent) 55%, transparent);
  border-radius: var(--r); color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, transparent); }
.shutter svg { width: 44px; height: 44px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.shutter span { font-weight: 750; font-size: 16px; }

.busyorb { width: 64px; height: 64px; margin: 40px auto 18px; border-radius: 50%;
  border: 4px solid var(--surface2); border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.busytext { text-align: center; font-weight: 700; font-size: 17px; }
.failtitle { text-align: center; font-weight: 750; font-size: 17px; margin: 30px 0 6px; }
.btnrow { display: flex; gap: 10px; margin-top: 18px; }
.btnrow .btn { flex: 1; }

.input { width: 100%; background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-s); padding: 12px 14px; color: var(--ink); margin-bottom: 10px; }
.results { max-height: 300px; overflow-y: auto; margin-bottom: 12px; }
.results .meal { cursor: pointer; }
.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: 12px; color: var(--muted); font-weight: 650; margin-bottom: 5px; }
.field.slim { margin-top: 4px; }
.field input { width: 100%; background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-s); padding: 12px 14px; color: var(--ink); }

/* confirm editor */
.thumb { width: 100%; height: 150px; object-fit: cover; border-radius: var(--r-s); margin-bottom: 10px; background: var(--surface2); }
.note { font-size: 12.5px; color: var(--muted); margin: 0 0 10px; }
.item { background: var(--surface); border-radius: var(--r-s); padding: 11px 12px; margin-bottom: 8px; box-shadow: var(--shadow); }
.item .top { display: flex; gap: 8px; align-items: center; }
.item input.iname { flex: 1; background: none; border: 0; color: var(--ink); font-weight: 650; padding: 2px; min-width: 0; }
.item .rm { color: var(--muted); width: 26px; height: 26px; border-radius: 50%; background: var(--surface2); flex: none; }
.item .qrow { display: flex; gap: 8px; align-items: center; margin-top: 7px; font-size: 12.5px; color: var(--muted); }
.item .qrow input { width: 64px; background: var(--surface2); border: 0; border-radius: 8px; padding: 5px 8px; color: var(--ink); text-align: right; }
.item .mac { margin-left: auto; font-size: 12px; color: var(--muted); white-space: nowrap; }
.chips { display: flex; gap: 7px; align-items: center; margin: 12px 0; flex-wrap: wrap; }
.chips .chiplabel { font-size: 12px; color: var(--muted); font-weight: 650; margin-right: 2px; }
.chips button { background: var(--surface); border: 1px solid var(--hairline); border-radius: 999px; padding: 7px 13px; font-weight: 650; font-size: 13px; color: var(--muted); }
.chips button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.totals { display: flex; gap: 10px; justify-content: space-between; background: var(--surface); border-radius: var(--r-s); padding: 13px 15px; margin-bottom: 10px; box-shadow: var(--shadow); }
.totals div { text-align: center; }
.totals b { display: block; font-size: 16.5px; }
.totals small { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }

/* ---- buttons ---- */
.btn { border-radius: var(--r-s); padding: 13px 18px; font-weight: 750; font-size: 15px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:active { transform: scale(.98); }
.btn.ghost { background: var(--surface2); color: var(--ink); }
.btn.big { width: 100%; padding: 15px; font-size: 16px; border-radius: var(--r-s); }
.linklike { display: block; margin: 12px auto 0; color: var(--muted); font-weight: 650; font-size: 13.5px; }

/* ---- paywall ---- */
.pw-reason { background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn); border-radius: var(--r-s); padding: 10px 13px; font-size: 13px; font-weight: 650; }
.pw-benefits { display: grid; gap: 10px; margin: 14px 0 20px; }
.pw { background: var(--surface); border-radius: var(--r-s); padding: 13px 15px; box-shadow: var(--shadow); }
.pw b { display: block; font-size: 14.5px; }
.pw small { color: var(--muted); font-size: 12.5px; }

/* ---- onboarding ---- */
#view-onboarding { display: flex; flex-direction: column; min-height: 100dvh; padding-top: 40px; }
.ob-hero { text-align: center; margin-bottom: 26px; }
.ob-mark { width: 68px; height: 68px; margin: 0 auto 16px; border-radius: 22px; background: var(--accent);
  box-shadow: 0 12px 30px color-mix(in srgb, var(--accent) 40%, transparent);
  background-image: radial-gradient(circle at 30% 28%, color-mix(in srgb, var(--accent-ink) 26%, transparent) 0 8px, transparent 9px),
                    radial-gradient(circle at 68% 62%, color-mix(in srgb, var(--accent-ink) 18%, transparent) 0 13px, transparent 14px); }
.ob-sub { color: var(--muted); max-width: 300px; margin: 10px auto 0; font-size: 14.5px; }
.ob-step h2 { margin-bottom: 12px; }
.pick { display: grid; gap: 8px; margin-bottom: 16px; }
.pick button { text-align: left; background: var(--surface); border-radius: var(--r-s); padding: 12px 14px; box-shadow: var(--shadow); border: 2px solid transparent; }
.pick button.on { border-color: var(--accent); }
.pick small { display: block; color: var(--muted); }
.ob-target { background: var(--surface); border-radius: var(--r); padding: 22px; text-align: center; box-shadow: var(--shadow); }
.ob-kcal b { font-size: 44px; font-weight: 800; letter-spacing: -0.03em; }
.ob-kcal small { display: block; color: var(--muted); }
.ob-macros { display: flex; justify-content: center; gap: 16px; margin-top: 14px; font-size: 13px; color: var(--muted); }
.ob-macros b { color: var(--ink); }
.ob-nav { display: flex; gap: 10px; margin-top: auto; padding: 18px 0 10px; }
.ob-nav .btn { flex: 1; }

#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 96px; z-index: 80;
  background: var(--ink); color: var(--bg); border-radius: 999px; padding: 10px 18px; font-size: 13.5px; font-weight: 650; }
