:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-2: #f0f3f2;
  --border: #e1e7e4;
  --text: #15201b;
  --muted: #5d6b65;
  --track: #e6ebe9;
  --accent: #0f9f6e;
  --accent-ink: #ffffff;
  --accent-soft: #e2f5ee;
  --kcal: #f08a24;
  --protein: #7c5cff;
  --water: #1c8fd6;
  --move: #0f9f6e;
  --sleep: #4b5bd6;
  --good: #128a5a;
  --warn: #c27a00;
  --danger: #d6453d;
  --danger-soft: #fdecea;
  --shadow: 0 1px 2px rgba(16, 32, 24, .06), 0 4px 16px rgba(16, 32, 24, .05);
  --radius: 16px;
  --font: 'Be Vietnam Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1412;
    --surface: #161e1b;
    --surface-2: #1d2724;
    --border: #2a3632;
    --text: #e8efec;
    --muted: #93a39c;
    --track: #2a3632;
    --accent: #2cc28c;
    --accent-ink: #062016;
    --accent-soft: #163a2d;
    --kcal: #ff9f45;
    --protein: #9d86ff;
    --water: #4cb2f0;
    --move: #2cc28c;
    --sleep: #8592ff;
    --good: #45d19c;
    --warn: #f0b545;
    --danger: #ff6b62;
    --danger-soft: #3a1d1b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  display: grid;
  grid-template-columns: 236px 1fr;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
body.onboarding { grid-template-columns: 1fr; }
body.onboarding .sidebar { display: none; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5rem; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; font-weight: 800; }
h2 { font-size: 1.15rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 700; }
p { margin: 0 0 .6rem; }
a { color: var(--accent); }
small, .muted { color: var(--muted); }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---- Khung trang ---- */
.sidebar {
  position: sticky; top: 0; height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex; flex-direction: column; gap: 18px;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 0 8px; }
.brand strong { display: block; font-size: 1.05rem; }
.brand small { font-size: .78rem; }
#nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 12px;
  color: var(--text); text-decoration: none; font-weight: 500;
}
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.nav-icon { width: 22px; text-align: center; }
.nav-short { display: none; }

main { padding: 28px clamp(16px, 3vw, 40px) 80px; max-width: 1180px; width: 100%; outline: none; }
.loading { color: var(--muted); padding: 40px 0; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head p { margin: 0; color: var(--muted); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border);
  font-size: .84rem; color: var(--muted); white-space: nowrap;
}
.chip.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; font-weight: 600; }
button.chip { cursor: pointer; }
button.chip:hover { border-color: var(--accent); color: var(--accent); }
button.chip.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.card > h2:first-child, .card > h3:first-child { margin-bottom: .75rem; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-head h2, .card-head h3 { margin: 0; }
.card.hero {
  background: linear-gradient(135deg, var(--accent) 0%, #0b7d57 100%);
  color: #fff; border: none;
}
.card.hero small, .card.hero .muted { color: rgba(255, 255, 255, .82); }
.card.hero .btn.ghost { color: #fff; border-color: rgba(255, 255, 255, .45); }
.card.hero .btn.ghost:hover { background: rgba(255, 255, 255, .12); }
.card.hero .btn.primary { background: #fff; color: #0b6a4a; }
.card.hero { display: flex; flex-direction: column; }
.hero-tip { margin-top: auto; padding: 12px 14px; border-radius: 12px; background: rgba(255, 255, 255, .14); font-size: .92rem; }
.card.hero .row + .hero-tip { margin-top: 18px; }

/* ---- Nút & form ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); background: var(--surface);
  padding: 9px 16px; border-radius: 12px; cursor: pointer;
  font-weight: 600; text-decoration: none; color: var(--text);
  transition: transform .06s ease, background .15s ease;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.05); background: var(--accent); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.small { padding: 5px 11px; font-size: .85rem; border-radius: 10px; }
.btn.big { padding: 13px 22px; font-size: 1.02rem; }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn {
  border: none; background: transparent; cursor: pointer; color: var(--muted);
  width: 32px; height: 32px; border-radius: 10px; font-size: 1.2rem; line-height: 1;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.field { display: flex; flex-direction: column; gap: 5px; font-size: .9rem; }
.field > span { font-weight: 600; }
.field small { font-size: .8rem; }
input[type=text], input[type=password], input[type=number], input[type=time], input[type=search], input[type=date], select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface);
  outline: none; transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; min-height: 44px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 2px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.seg span { display: block; padding: 7px 14px; border-radius: 10px; font-weight: 600; font-size: .9rem; color: var(--muted); }
.seg input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.tone-option { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border: 1px solid var(--border); border-radius: 12px; cursor: pointer; }
.tone-option:hover { border-color: var(--accent); }
.tone-option.active { border-color: var(--accent); background: var(--accent-soft); }
.tone-option input { margin-top: 4px; accent-color: var(--accent); }
.tone-option small { display: block; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.switch:last-child { border-bottom: none; }
.switch input { width: 42px; height: 24px; appearance: none; background: var(--track); border-radius: 999px; position: relative; cursor: pointer; flex: none; transition: background .2s; }
.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(18px); }

/* ---- Thanh & vòng tiến độ ---- */
.bar { height: 8px; background: var(--track); border-radius: 999px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width .4s ease; }
.bar.kcal span { background: var(--kcal); }
.bar.protein span { background: var(--protein); }
.bar.water span { background: var(--water); }
.bar.sleep span { background: var(--sleep); }
.bar.over span { background: var(--danger); }
.ring { position: relative; flex: none; }
.ring svg circle { transition: stroke-dashoffset .5s ease; }
.ring-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.ring-text strong { font-size: 1.35rem; font-weight: 800; line-height: 1.1; }
.ring-text small { font-size: .75rem; }

.metric { display: flex; flex-direction: column; gap: 8px; }
.metric-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.metric-label { font-size: .85rem; color: var(--muted); font-weight: 600; display: flex; gap: 6px; align-items: center; }
.metric-value { font-size: 1.35rem; font-weight: 800; }
.metric-value small { font-size: .8rem; font-weight: 500; }
.metric-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.kcal-summary { display: flex; gap: 20px; align-items: center; }
.kcal-summary .numbers { display: grid; gap: 10px; flex: 1; min-width: 0; }
.kv { display: flex; justify-content: space-between; gap: 10px; font-size: .92rem; }
.kv b { font-weight: 700; }

/* ---- Danh sách ---- */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: none; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; }
.list-item small { display: block; }
.empty { color: var(--muted); padding: 10px 0; font-size: .92rem; }
.tag { font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.tag.xanh { background: #dcf5e8; color: #0f7a4d; }
.tag.vang { background: #fff2d6; color: #966000; }
.tag.do { background: var(--danger-soft); color: var(--danger); }
@media (prefers-color-scheme: dark) {
  .tag.xanh { background: #143a29; color: #5fdaa7; }
  .tag.vang { background: #3a2e14; color: #f3c364; }
}

.habit { display: flex; gap: 10px; align-items: center; padding: 8px 0; cursor: pointer; }
.habit input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.habit.auto { cursor: default; }
.habit .check { width: 20px; text-align: center; flex: none; }

.timeline { position: relative; display: flex; flex-direction: column; gap: 2px; max-height: 280px; overflow: auto; padding-right: 4px; }
.timeline .t { display: grid; grid-template-columns: 52px 1fr; gap: 10px; padding: 6px 8px; border-radius: 10px; font-size: .9rem; }
.timeline .t.past { color: var(--muted); opacity: .6; }
.timeline .t.next { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.timeline .time { font-variant-numeric: tabular-nums; font-weight: 600; }

.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.week .d { border: 1px solid var(--border); border-radius: 12px; padding: 10px 8px; text-align: center; background: var(--surface); min-width: 0; }
.week .d b { display: block; font-size: .8rem; color: var(--muted); }
.week .d span { display: block; font-size: .78rem; line-height: 1.3; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; }
.week .d.today { border-color: var(--accent); background: var(--accent-soft); }
.week .d.done { position: relative; }
.week .d.done::after { content: '✓'; position: absolute; top: 4px; right: 7px; color: var(--accent); font-weight: 800; font-size: .8rem; }

.ex { display: grid; grid-template-columns: 34px 1fr auto; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); align-items: start; }
.ex:last-child { border-bottom: none; }
.ex .num { width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 800; font-size: .85rem; }
.ex p { margin: 2px 0 0; font-size: .9rem; color: var(--muted); }
.ex .alt { font-size: .82rem; margin-top: 4px; }

/* ---- Thông báo nổi ---- */
#toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 60; max-width: min(420px, calc(100vw - 32px)); }
.toast {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.18);
  padding: 12px 40px 12px 14px; position: relative;
  transform: translateY(12px); opacity: 0; transition: all .25s ease;
}
.toast.show { transform: none; opacity: 1; }
.toast.good { border-left: 4px solid var(--good); }
.toast.bad { border-left: 4px solid var(--danger); }
.toast.reminder { border-left: 4px solid var(--accent); }
.toast-body { display: flex; flex-direction: column; gap: 2px; font-size: .92rem; }
.toast-body strong { font-size: .98rem; }
.toast-actions { display: flex; gap: 8px; margin-top: 10px; }
.toast-close { position: absolute; top: 6px; right: 6px; border: none; background: none; font-size: 1.2rem; cursor: pointer; color: var(--muted); width: 28px; height: 28px; border-radius: 8px; }

/* ---- Hộp thoại ---- */
.modal-wrap { position: fixed; inset: 0; background: rgba(8, 16, 12, .45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--surface); border-radius: 18px; width: min(520px, 100%); max-height: 90vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px 0; }
.modal header h3 { margin: 0; }
.modal-body { padding: 14px 18px; display: flex; flex-direction: column; gap: 12px; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 0 18px 16px; }

/* ---- Trình phát bài tập ---- */
.player {
  position: fixed; inset: 0; z-index: 40; background: var(--bg);
  display: grid; grid-template-rows: auto 1fr auto; padding: 20px clamp(16px, 4vw, 48px);
}
.player-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.player-top .bar { flex: 1; max-width: 520px; }
.player-main { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 14px; }
.player-part { text-transform: uppercase; letter-spacing: .08em; font-size: .8rem; font-weight: 700; color: var(--accent); }
.player-name { font-size: clamp(1.6rem, 4.5vw, 2.6rem); font-weight: 800; margin: 0; }
.player.rest .player-name { color: var(--water); }
.player-cue { max-width: 620px; color: var(--muted); font-size: 1.05rem; }
.player-alt { font-size: .9rem; color: var(--muted); }
.player-timer .ring-text strong { font-size: 3.2rem; font-variant-numeric: tabular-nums; }
.player-next { font-size: .95rem; color: var(--muted); }
.player-controls { display: flex; justify-content: center; gap: 12px; padding-bottom: 8px; }
.player-controls .btn { min-width: 64px; }

/* ---- Chat ---- */
.chat > * { min-width: 0; }
.chat { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; height: calc(100vh - 150px); min-height: 480px; }
.chat-main { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-height: 0; }
.messages { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 82%; padding: 10px 14px; border-radius: 16px; font-size: .95rem; }
.msg p:last-child { margin-bottom: 0; }
.msg ul, .msg ol { margin: .2rem 0 .5rem; padding-left: 1.2rem; }
.msg-row { display: flex; gap: 8px; align-items: flex-end; align-self: flex-start; max-width: 88%; }
.msg-row .msg { max-width: none; min-width: 0; }
.avatar { width: 30px; height: 30px; border-radius: 10px; flex: none; }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 6px; }
.msg.assistant { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 6px; }
.msg.error { align-self: flex-start; background: var(--danger-soft); color: var(--danger); }
.msg .actions { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.msg .action { font-size: .82rem; color: var(--accent); background: var(--accent-soft); padding: 4px 9px; border-radius: 8px; align-self: flex-start; }
.msg time { display: block; font-size: .72rem; opacity: .6; margin-top: 4px; }
.typing span { display: inline-block; width: 7px; height: 7px; margin: 0 2px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.composer { border-top: 1px solid var(--border); padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.composer form { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { max-height: 160px; }
.quick { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.quick::-webkit-scrollbar { display: none; }
.chat-side { display: flex; flex-direction: column; gap: 16px; overflow-y: auto; min-height: 0; }
.banner { border-radius: 14px; padding: 12px 14px; background: #fff6e0; color: #6b4a00; font-size: .9rem; border: 1px solid #f3dda0; }
@media (prefers-color-scheme: dark) { .banner { background: #2f2610; color: #f3d38a; border-color: #4d3c14; } }
.banner code { font-size: .85rem; }

/* ---- Biểu đồ ---- */
.chart svg { width: 100%; height: auto; display: block; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .avg { fill: none; stroke: var(--protein); stroke-width: 2; stroke-dasharray: 5 4; }
.chart .goal { stroke: var(--kcal); stroke-width: 1.5; stroke-dasharray: 3 4; }
.chart .dot { fill: var(--surface); stroke: var(--accent); stroke-width: 2; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .82rem; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 5px; }
.stat-big { font-size: 1.8rem; font-weight: 800; line-height: 1.1; }
table.data { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.data th, table.data td { text-align: right; padding: 7px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data th { color: var(--muted); font-weight: 600; font-size: .8rem; }
.table-wrap { overflow-x: auto; }

/* ---- Kiến thức ---- */
.prose { max-width: 760px; }
.prose h1 { font-size: 1.5rem; }
.prose h2 { font-size: 1.2rem; margin-top: 1.8rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.prose h3 { margin-top: 1.2rem; }
.prose ul, .prose ol { padding-left: 1.3rem; }
.prose li { margin-bottom: .3rem; }
.prose blockquote { margin: 1rem 0; padding: 10px 14px; border-left: 4px solid var(--accent); background: var(--accent-soft); border-radius: 0 12px 12px 0; }
.prose table { border-collapse: collapse; width: 100%; font-size: .9rem; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.prose a { word-break: break-word; }

/* ---- Màn hình bắt đầu ---- */
.onboard { max-width: 760px; margin: 0 auto; }
.onboard-hero { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.onboard-duck { width: 150px; flex: none; animation: waddle 2.4s ease-in-out infinite; transform-origin: 50% 95%; }
@keyframes waddle { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg); } }
@media (prefers-reduced-motion: reduce) { .onboard-duck { animation: none; } }
@media (max-width: 520px) { .onboard-duck { width: 96px; } }
.onboard .hero-title { font-size: clamp(1.8rem, 4vw, 2.4rem); font-weight: 800; }
.feature-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; margin: 16px 0 24px; }
.feature-list div { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 12px; font-size: .9rem; }
.feature-list b { display: block; margin-bottom: 2px; }

/* ---- Màn hình nhỏ ---- */
@media (max-width: 1080px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chat { grid-template-columns: 1fr; height: auto; }
  .chat-main { height: calc(100vh - 170px); min-height: 460px; }
}
@media (max-width: 860px) {
  body { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; z-index: 30;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); border-right: none; border-top: 1px solid var(--border);
  }
  .brand { display: none; }
  #nav { flex-direction: row; justify-content: space-around; gap: 0; }
  .nav-item { flex-direction: column; gap: 1px; padding: 6px 2px; font-size: .68rem; flex: 1; text-align: center; border-radius: 10px; }
  .nav-item[data-view=knowledge] { display: none; }
  .nav-label { display: none; }
  .nav-short { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .nav-icon { width: auto; font-size: 1.15rem; }
  main { padding: 18px 16px 96px; }
  .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  #toasts { right: 16px; left: 16px; bottom: 84px; max-width: none; }
  .chat-main { height: calc(100vh - 200px); }
  .msg { max-width: 92%; }
}
@media (max-width: 520px) {
  .grid.cols-4 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .card { padding: 14px; }
  .kcal-summary { flex-direction: column; align-items: stretch; }
  .kcal-summary .ring { align-self: center; }
  .week { grid-template-columns: repeat(7, minmax(38px, 1fr)); overflow-x: auto; }
  .week .d span { display: none; }
  h1 { font-size: 1.35rem; }
}
