/* cud-app.css: baseline + shared components. Mobile-first, one-handed. */
:root {
    --paper: #F3F5F7;
    --card: #FFFFFF;
    --ink: #14213D;
    --ink-2: #4A5568;
    --ink-3: #8A94A6;
    --line: #DDE3EA;
    --sky: #9CC9E8;
    --sky-deep: #2F6FA7;
    --kcal: #14213D;
    --protein: #1F6F8B;
    --carbs: #D9A441;
    --fat: #C8553D;
    --over: #C0392B;
    --good: #2E7D5B;
    --near: #B7791F;
    --font-display: 'Bricolage Grotesque', 'IBM Plex Sans', system-ui, sans-serif;
    --font-body: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-mono: 'IBM Plex Mono', ui-monospace, Menlo, Consolas, monospace;
    --radius: 14px;
    --nav-h: 64px;
    --tap: 48px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--sky-deep); }
h1, h2, h3 { margin: 0 0 8px; line-height: 1.15; font-weight: 600; }
h1 { font-size: 26px; }
h2 { font-size: 20px; }
h3 { font-size: 17px; }
p { margin: 0 0 10px; }
button, input { font: inherit; }
:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; }
[hidden] { display: none !important; }

.display {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 34px;
    letter-spacing: -0.02em;
    line-height: 1.05;
}
.eyebrow {
    margin: 0 0 6px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-3);
}
.lede { color: var(--ink-2); font-size: 17px; }
.hint { color: var(--ink-3); font-size: 13px; }
.mono { font-family: var(--font-mono); font-size: 14px; }
.section-title { font-size: 14px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); margin: 22px 0 10px; }
.empty { color: var(--ink-2); }
.center { text-align: center; }
.link-quiet { display: inline-block; margin-top: 6px; font-size: 14px; text-decoration: none; }
.link-btn { background: none; border: 0; padding: 0; color: var(--sky-deep); text-decoration: underline; cursor: pointer; }

/* Layout */
.wrapper { min-height: 100dvh; }
.main-content { max-width: 560px; margin: 0 auto; padding: 20px 16px calc(var(--nav-h) + 24px); }
.main-content.narrow { max-width: 440px; padding-top: 48px; }
.page-plain .hero { margin-bottom: 22px; }
.page-head { margin-bottom: 18px; }

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
    margin-bottom: 16px;
}
.form label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.form input { width: 100%; min-height: var(--tap); padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); margin-bottom: 12px; }
.form input:focus { border-color: var(--sky-deep); outline: none; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: var(--tap); padding: 10px 18px;
    border-radius: 12px; border: 1.5px solid transparent;
    font-weight: 600; font-size: 16px; text-decoration: none; cursor: pointer;
    transition: transform .08s ease, background .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: default; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #1c2c52; }
.btn-secondary { background: #fff; color: var(--ink); border-color: var(--ink); }
.btn-block { width: 100%; }
.btn-big { min-height: 56px; font-size: 18px; }

/* Chips */
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.chip {
    min-height: 40px; padding: 6px 14px;
    border-radius: 999px; border: 1.5px solid var(--line); background: #fff; color: var(--ink);
    font-weight: 500; cursor: pointer;
}
.chip.on { background: var(--sky); border-color: var(--sky); color: var(--ink); font-weight: 600; }

/* Banner + toasts */
.banner { background: #FFF4D6; color: #6B4E00; border: 1px solid #F1D98A; border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-bottom: 14px; }
#toast-host { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + 12px); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; z-index: 50; }
.toast { background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; transform: translateY(8px); transition: all .25s ease; max-width: 90%; }
.toast.show { opacity: 1; transform: none; }
.toast-error { background: var(--over); }
.toast-success { background: var(--good); }
.toast-actions { pointer-events: auto; display: flex; align-items: center; gap: 12px; }
.toast-actions button { background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.5); color: #fff; border-radius: 8px; padding: 4px 10px; font-weight: 600; cursor: pointer; }

/* Nav: bottom tab bar on phones */
.sidebar { position: fixed; left: 0; right: 0; bottom: 0; height: var(--nav-h); background: #fff; border-top: 1px solid var(--line); z-index: 40; padding-bottom: env(safe-area-inset-bottom); }
.sidebar .brand, .sidebar .sidebar-foot { display: none; }
.tabs { display: flex; height: 100%; }
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; color: var(--ink-3); font-size: 11px; font-weight: 600; letter-spacing: .02em; }
.tabs a .tab-ico { font-size: 20px; line-height: 1; }
.tabs a.active { color: var(--ink); }
.tabs a.active .tab-ico { color: var(--sky-deep); }

/* Macro colours */
.m-kcal { --c: var(--kcal); }
.m-protein { --c: var(--protein); }
.m-carbs { --c: var(--carbs); }
.m-fat { --c: var(--fat); }

/* Rings (Today) */
.rings { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.ring { --pct: 0%; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.ring-inner {
    width: 76px; height: 76px; border-radius: 50%;
    background: conic-gradient(var(--c) var(--pct), var(--line) 0);
    display: grid; place-items: center; position: relative;
}
.ring-inner::before { content: ''; position: absolute; inset: 7px; border-radius: 50%; background: var(--paper); }
.ring-inner > * { position: relative; }
.ring-value { font-family: var(--font-mono); font-weight: 500; font-size: 14px; }
.ring-target { font-size: 11px; color: var(--ink-3); }
.ring-label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.ring.over .ring-inner { background: conic-gradient(var(--over) 100%, var(--over) 0); }
.ring.over .ring-value { color: var(--over); }
.est-note { text-align: center; margin: 8px 0 18px; }
.explainer { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: -8px 0 16px; font-size: 14px; color: var(--ink-2); }
.explainer p { margin: 0; }

.next-up h2 { font-family: var(--font-display); font-weight: 800; font-size: 30px; }
.next-up .btn { margin-top: 12px; }
.meal-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.meal-buttons .btn { margin-top: 0; padding-left: 8px; padding-right: 8px; }

.hall-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hall-card { display: flex; flex-direction: column; gap: 4px; padding: 14px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--ink); min-height: 72px; }
.hall-card:hover { border-color: var(--sky-deep); }
.hall-name { font-family: var(--font-display); font-weight: 800; font-size: 19px; }
.hall-meals { font-size: 12px; color: var(--ink-3); }

.logged-list { display: flex; flex-direction: column; gap: 8px; }
.logged-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 14px; background: #fff; border: 1px solid var(--line); border-radius: 12px; text-decoration: none; color: var(--ink); }
.logged-meal { font-weight: 600; }
.logged-macros { font-size: 12px; color: var(--ink-3); white-space: nowrap; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* >= 768px: the same nav becomes a left sidebar */
@media (min-width: 768px) {
    .wrapper { display: grid; grid-template-columns: 220px 1fr; }
    .sidebar { position: sticky; top: 0; height: 100dvh; border-top: 0; border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; }
    .sidebar .brand { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
    .brand-mark { font-family: var(--font-display); font-weight: 800; background: var(--ink); color: #fff; border-radius: 8px; padding: 2px 7px; }
    .brand-name { font-weight: 600; }
    .tabs { flex-direction: column; height: auto; gap: 2px; }
    .tabs a { flex: 0 0 auto; flex-direction: row; justify-content: flex-start; gap: 10px; padding: 10px 10px; border-radius: 10px; font-size: 15px; }
    .tabs a.active { background: var(--paper); }
    .sidebar .sidebar-foot { display: flex; flex-direction: column; gap: 4px; margin-top: auto; font-size: 13px; color: var(--ink-3); }
    .main-content { padding-bottom: 40px; }
    #toast-host { bottom: 20px; }
    .ring-inner { width: 96px; height: 96px; }
}

.code-form { margin-top: 10px; }
.code-form input { font-family: var(--font-mono); font-size: 26px; letter-spacing: 8px; text-align: center; }
.welcome { border-left: 4px solid var(--sky); }
.welcome ol { margin: 6px 0 12px; padding-left: 20px; }
.welcome li { margin-bottom: 6px; }
.welcome .row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.welcome .dismiss { margin-top: 8px; }
