/* Mỗi màu giao diện chỉ đổi token ở đây. Nền, chữ và màu thương hiệu đổi theo; màu trạng thái giữ nghĩa cố định. */
:root {
  color-scheme: light;
  --paper: #f6f3ea;
  --card: #fffdf8;
  --hover: #fbf8ef;
  --ink: #1f2a24;
  --ink-2: #55615a;
  --ink-3: #66706a;
  --line: #e3dfd2;
  --input-line: #cfcabb;
  --track: #e9e5d8;
  --brand: #1f5f4a;
  --brand-hover: #18503e;
  --brand-ink: #fffdf8;
  --brand-soft: #dfeae2;
  --good: #2f7d5b;
  --good-soft: #e0efe6;
  --good-ink: #1f6246;
  --warn: #a86a00;
  --warn-soft: #f8ecd2;
  --warn-ink: #7d4f00;
  --bad: #a83824;
  --bad-soft: #f8e3dc;
  --neutral-soft: #eceadf;
  --bar-bg: #26332c;
  --bar-ink: #f1eee3;
  --bar-line: #55645b;
  --bar-hover: #33423a;
  --bar-accent: #9fd3b8;
  --radius: 16px;
  --radius-s: 10px;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%);
  --shadow-fab: 0 4px 12px rgb(0 0 0 / 25%);
}
:root[data-palette="grass"] {
  --paper: #f3f8e9; --card: #fcfef7; --hover: #f7fbef;
  --ink: #1f2b16; --ink-2: #4f5d43; --ink-3: #5f6c53;
  --line: #dfe8d0; --input-line: #c8d4b6; --track: #e4edd6;
  --brand: #3a7d1e; --brand-hover: #2f6918; --brand-ink: #fcfef7; --brand-soft: #e0f0cf;
  --neutral-soft: #e8efdb;
  --bar-bg: #24351a; --bar-ink: #f2f7e8; --bar-line: #56684a; --bar-hover: #324722; --bar-accent: #a9dc7d;
}
:root[data-palette="ocean"] {
  --paper: #eef3f7; --card: #fbfdff; --hover: #f3f7fa;
  --ink: #16242e; --ink-2: #4a5b67; --ink-3: #5e6e7a;
  --line: #d7e1e8; --input-line: #c3cfd8; --track: #dfe7ed;
  --brand: #1d5b8f; --brand-hover: #174c78; --brand-ink: #fbfdff; --brand-soft: #dbe8f3;
  --neutral-soft: #e5ebf0;
  --bar-bg: #1b2b38; --bar-ink: #eaf1f6; --bar-line: #4b5f6e; --bar-hover: #2a3d4c; --bar-accent: #9cc8ea;
}
:root[data-palette="plum"] {
  --paper: #f4f1f7; --card: #fdfbff; --hover: #f7f4fa;
  --ink: #241d2e; --ink-2: #5a5067; --ink-3: #6c627a;
  --line: #e3dcea; --input-line: #cfc6da; --track: #e9e3ef;
  --brand: #5e3a96; --brand-hover: #4e2f80; --brand-ink: #fdfbff; --brand-soft: #e7dff3;
  --neutral-soft: #ebe6f0;
  --bar-bg: #2a2038; --bar-ink: #f0ebf6; --bar-line: #5d4f70; --bar-hover: #3a2e4b; --bar-accent: #c5aeea;
}
:root[data-palette="lotus"] {
  --paper: #f9f1f5; --card: #fffbfd; --hover: #fbf4f8;
  --ink: #2e1c26; --ink-2: #67505c; --ink-3: #7a616e;
  --line: #ecdbe3; --input-line: #dcc7d2; --track: #f1e3ea;
  --brand: #a3246f; --brand-hover: #8a1d5e; --brand-ink: #fffbfd; --brand-soft: #f6dfec;
  --neutral-soft: #f0e5ea;
  --bar-bg: #361f2c; --bar-ink: #f8edf3; --bar-line: #6e4f60; --bar-hover: #492c3c; --bar-accent: #efa9cf;
}
:root[data-palette="night"] {
  color-scheme: dark;
  --paper: #14191b; --card: #1d2427; --hover: #232b2e;
  --ink: #edf1ee; --ink-2: #b1bbb6; --ink-3: #96a19b;
  --line: #30393d; --input-line: #445056; --track: #2e373a;
  --brand: #6fcfa6; --brand-hover: #86dab6; --brand-ink: #0f1a15; --brand-soft: #1f3a30;
  --good: #5cc596; --good-soft: #1c3a2d; --good-ink: #8fe0bb;
  --warn: #e0a93f; --warn-soft: #3b2f14; --warn-ink: #f0c56d;
  --bad: #f0806a; --bad-soft: #44221b;
  --neutral-soft: #283135;
  --bar-bg: #0c1113; --bar-ink: #e7ece9; --bar-line: #3d484d; --bar-hover: #222b2e; --bar-accent: #6fcfa6;
  --shadow: 0 1px 2px rgb(0 0 0 / 40%);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 15px/1.5 'Be Vietnam Pro', system-ui, 'Segoe UI', Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: 24px; line-height: 1.25; font-weight: 700; letter-spacing: -0.01em; text-wrap: balance; }
h2 { font-size: 16px; line-height: 1.35; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
img { display: block; max-width: 100%; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.shell { max-width: 480px; margin: 0 auto; min-height: 100dvh; padding-bottom: 96px; }
.page { padding-block: 16px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.page.plain { padding-top: 40px; }
.stack { display: grid; gap: 12px; }
.stack-s { display: grid; gap: 6px; }
.row { display: flex; align-items: center; gap: 8px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; line-height: 1.45; }
.tiny { font-size: 12px; line-height: 1.4; color: var(--ink-3); }
.strong { font-weight: 600; }
.grow { flex: 1; min-width: 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card.flush { padding: 0; overflow: hidden; }

/* Nút */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); font-weight: 600; text-decoration: none;
}
.btn:hover { background: var(--neutral-soft); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { background: var(--brand-hover); }
.btn.danger { color: var(--bad); }
.btn.block { width: 100%; }
.btn[disabled] { opacity: 0.55; cursor: default; }
.btn.small-btn { min-height: 38px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.icon-btn {
  width: 40px; height: 40px; display: inline-grid; place-items: center; flex: none;
  border-radius: 10px; border: 1px solid var(--line); background: var(--card); text-decoration: none;
}
.icon-btn[disabled], .icon-btn.off { opacity: 0.35; pointer-events: none; }
.link-btn { background: none; border: 0; padding: 0; color: var(--brand); font-weight: 600; text-decoration: none; font-size: 14px; }
.back { min-height: 44px; margin-block: -10px; justify-self: start; }
svg.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Biểu mẫu */
.field { display: grid; gap: 6px; }
.field > label, .legend { font-weight: 500; font-size: 14px; }
.input {
  width: 100%; min-height: 48px; padding: 0 14px; border-radius: 12px;
  border: 1px solid var(--input-line); background: var(--card);
}
textarea.input { padding: 12px 14px; min-height: 84px; resize: vertical; }
.input.invalid { border-color: var(--bad); }
.field-error { color: var(--bad); font-size: 13px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; background: var(--neutral-soft); border-radius: 12px; }
.segmented label { position: relative; display: block; }
.segmented input { position: absolute; opacity: 0; inset: 0; }
.segmented span { display: grid; place-items: center; min-height: 40px; border-radius: 9px; font-weight: 500; font-size: 14px; text-align: center; padding: 2px 6px; line-height: 1.25; }
.segmented input:checked + span { background: var(--card); font-weight: 600; box-shadow: var(--shadow); }
.segmented input:focus-visible + span { outline: 2px solid var(--brand); }
.checks { display: grid; gap: 2px; }
.check { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.check:last-child { border-bottom: 0; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--brand); flex: none; }

/* Dải demo */
.demo-bar { background: var(--bar-bg); color: var(--bar-ink); font-size: 13px; }
.demo-bar-inner { max-width: 480px; margin: 0 auto; padding-block: 8px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); display: grid; gap: 10px; }
.demo-toggle { background: none; border: 0; padding: 4px 0; color: inherit; width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 8px; text-align: left; }
.demo-tag { font-weight: 600; }
.demo-panel { display: grid; gap: 10px; padding-bottom: 8px; }
.demo-panel input[type=range] { width: 100%; accent-color: var(--bar-accent); }
.demo-panel .btn { background: transparent; color: inherit; border-color: var(--bar-line); }
.demo-panel .btn:hover { background: var(--bar-hover); }
.demo-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* Tab dưới */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}
.tabs-inner { max-width: 480px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); align-items: end; }
.tab { display: grid; justify-items: center; gap: 2px; padding: 8px 2px 10px; font-size: 11px; font-weight: 500; color: var(--ink-3); text-decoration: none; }
.tab.active { color: var(--brand); font-weight: 600; }
.tab-add { display: grid; justify-items: center; gap: 2px; padding-bottom: 10px; font-size: 11px; font-weight: 600; color: var(--brand); text-decoration: none; }
.tab-add span.fab { width: 52px; height: 52px; margin-top: -22px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; box-shadow: var(--shadow-fab); border: 3px solid var(--card); }

/* Tổng quan */
.hero { display: flex; align-items: center; gap: 16px; }
.ring { position: relative; width: 104px; height: 104px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .v { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring .v b { font-size: 26px; line-height: 1; font-weight: 700; }
.ring .v small { font-size: 11px; color: var(--ink-2); margin-top: 3px; }
.stat-line { display: grid; gap: 2px; }
.stat-pair { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 10px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; min-width: 0; }
.stat b { display: block; font-size: 20px; line-height: 1.2; font-weight: 700; }
.stat span { font-size: 12px; color: var(--ink-2); line-height: 1.3; display: block; margin-top: 2px; }

/* Cảnh báo */
.alert { display: flex; gap: 10px; padding: 8px 12px; border-radius: 12px; background: var(--bad-soft); }
.alert.warn { background: var(--warn-soft); }
.alert svg { color: var(--bad); margin-top: 1px; }
.alert.warn svg { color: var(--warn); }
.alert-ok { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: 14px; background: var(--good-soft); }
.alert-ok svg { color: var(--good); }
.notice { display: flex; gap: 10px; padding: 12px 14px; border-radius: 12px; background: var(--neutral-soft); font-size: 13px; line-height: 1.45; }
.notice svg { width: 18px; height: 18px; margin-top: 1px; color: var(--ink-2); }

/* Thanh vi chất */
.nutrient { padding: 12px 0; border-bottom: 1px solid var(--line); display: grid; gap: 6px; }
.nutrient:last-child { border-bottom: 0; padding-bottom: 0; }
.nutrient:first-child { padding-top: 0; }
.bar { position: relative; height: 8px; border-radius: 4px; background: var(--track); }
.bar i { display: block; height: 100%; border-radius: 4px; background: var(--brand); }
.bar.late i { background: var(--bad); }
.bar.soon i, .bar.near i { background: var(--warn); }
.bar.over i, .bar.overul i { background: var(--bad); }
.bar.monitor i { background: var(--ink-3); }
.bar em { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); border-radius: 1px; box-shadow: 0 0 0 1px var(--card); }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--neutral-soft); color: var(--ink-2); }
.badge svg { width: 13px; height: 13px; stroke-width: 2.5; }
.badge.late, .badge.over, .badge.overul { background: var(--bad-soft); color: var(--bad); }
.badge.soon, .badge.near, .badge.sample { background: var(--warn-soft); color: var(--warn-ink); }
.badge.done, .badge.ontrack, .badge.safe, .badge.ai, .badge.weekok { background: var(--good-soft); color: var(--good-ink); }

/* Bữa ăn */
.meal { display: flex; gap: 12px; align-items: center; padding: 10px; text-decoration: none; border-bottom: 1px solid var(--line); }
.meal:last-child { border-bottom: 0; }
.meal:hover { background: var(--hover); }
.thumb { width: 60px; height: 60px; border-radius: 12px; object-fit: cover; flex: none; background: var(--neutral-soft); }
.photo-preview { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: var(--radius); background: var(--neutral-soft); }
.pill-thumb { display: grid; place-items: center; color: var(--brand); background: var(--brand-soft); }
.supp { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.supp:last-child { border-bottom: 0; }
.supp:has(input:checked) { background: var(--brand-soft); }
.supp input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--brand); flex: none; }
.supp-name, .supp-tip { display: block; }
.supp-warn { display: flex; gap: 6px; align-items: flex-start; margin-top: 4px; color: var(--bad); }
.supp-warn svg { width: 15px; height: 15px; margin-top: 2px; }
.empty { text-align: center; padding: 24px 16px; color: var(--ink-2); display: grid; gap: 12px; justify-items: center; }

/* Thêm bữa */
.pick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pick { position: relative; display: grid; gap: 8px; justify-items: center; align-content: center; text-align: center; min-height: 128px; padding: 16px 10px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--card); font-weight: 600; cursor: pointer; }
.pick.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.pick small { font-weight: 400; font-size: 12px; opacity: 0.85; line-height: 1.35; }
.pick svg { width: 28px; height: 28px; }
.pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.pick:focus-within { outline: 2px solid var(--brand); outline-offset: 2px; }
.dish-grid { display: grid; gap: 8px; }
.dish { display: flex; align-items: center; gap: 12px; padding: 10px 12px; min-height: 52px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); text-align: left; width: 100%; font-weight: 500; }
.dish:hover { background: var(--neutral-soft); }
.dish .e { font-size: 22px; line-height: 1; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--track); border-top-color: var(--brand); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }
.chips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.chip { min-height: 44px; padding: 0 4px; font-size: 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); font-weight: 500; }
.chip.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
.ingredient { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; font-size: 14px; }
.contrib { display: grid; grid-template-columns: 108px 1fr 42px; gap: 10px; align-items: center; font-size: 13px; padding: 3px 0; }
.contrib .bar { height: 6px; }
.contrib b { text-align: right; font-weight: 600; }

/* Định mức, báo cáo */
.target-row { padding: 12px 0; border-bottom: 1px solid var(--line); display: grid; gap: 3px; }
.target-row:last-child { border-bottom: 0; padding-bottom: 0; }
.target-row:first-of-type { padding-top: 0; }
.amount { font-weight: 700; white-space: nowrap; }
.gap { padding: 12px 0; border-bottom: 1px solid var(--line); display: grid; gap: 6px; }
.gap:last-child { border-bottom: 0; padding-bottom: 0; }
.gap:first-of-type { padding-top: 0; }
.food-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 2px; font-size: 13px; color: var(--ink-2); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 600; color: var(--ink-2); padding: 6px 6px 8px 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 8px 6px 8px 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.n, th.n { text-align: right; }
.login-mark { width: 48px; height: 48px; border-radius: 14px; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; }
.themes { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.theme { display: grid; justify-items: center; gap: 4px; padding: 8px 2px; min-height: 64px; border-radius: 12px; border: 1px solid transparent; background: none; color: inherit; font-size: 12px; font-weight: 500; }
.theme[aria-pressed="true"] { border-color: currentColor; font-weight: 600; }
.theme:hover { background: color-mix(in srgb, currentColor 10%, transparent); }
.swatch { position: relative; width: 28px; height: 28px; border-radius: 50%; overflow: hidden; border: 1px solid color-mix(in srgb, currentColor 35%, transparent); }
.swatch i, .swatch b { position: absolute; inset: 0; display: block; }
.swatch b { clip-path: polygon(0 100%, 100% 0, 100% 100%); }
.pick-wide { min-height: 104px; }
details summary { cursor: pointer; min-height: 32px; }
details[open] summary { margin-bottom: 8px; }
.others > summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; padding: 6px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); list-style: none; }
.others > summary::-webkit-details-marker { display: none; }
.others > summary:hover { background: var(--hover); }
.others > summary:focus-visible, .nrow > summary:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.chev { display: inline-flex; color: var(--ink-3); transition: transform 0.15s; }
.chev svg.i { width: 16px; height: 16px; }
details[open] > summary .chev { transform: rotate(180deg); }
@media (prefers-reduced-motion: reduce) { .chev { transition: none; } }
/* Dòng vi chất một hàng */
.card.rows { padding: 2px 14px; }
.nrow { border-bottom: 1px solid var(--line); }
.nrow:last-child { border-bottom: 0; }
.nrow > summary { display: grid; grid-template-columns: 128px 1fr auto 16px; align-items: center; gap: 8px; min-height: 44px; margin: 0; list-style: none; }
.nrow > summary::-webkit-details-marker { display: none; }
.nrow-name { font-size: 14px; font-weight: 500; line-height: 1.2; padding-block: 4px; }
.nrow-name small { display: block; margin-top: 1px; font-size: 12px; font-weight: 400; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.nrow .bar { display: block; }
.nrow-value { display: inline-flex; align-items: center; justify-content: flex-end; gap: 3px; min-width: 42px; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.nrow-text { grid-column: 2 / 4; display: inline-flex; align-items: center; justify-content: flex-end; gap: 3px; font-size: 14px; font-weight: 600; }
.flag { display: inline-flex; color: var(--warn); }
.flag.late, .flag.over, .flag.overul { color: var(--bad); }
.flag svg.i { width: 15px; height: 15px; }
.nrow-more { display: grid; gap: 4px; justify-items: start; padding: 0 0 10px; }
/* Thuốc */
.hero-med { display: flex; align-items: center; gap: 10px; margin-top: 12px; padding-top: 10px; min-height: 34px; border-top: 1px solid var(--line); text-decoration: none; }
.hero-med .grow { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero-med svg.i { width: 18px; height: 18px; color: var(--ink-3); }
.hero-med svg.i:first-child { color: var(--brand); }
.soon-dose { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 52px; padding: 6px 0; background: none; border: 0; border-top: 1px solid var(--line); text-align: left; }
.soon-more { display: block; padding: 8px 0 0; border-top: 1px solid var(--line); color: var(--brand); font-weight: 600; text-decoration: none; }
.soon-dose .grow, .dose-alert .grow { min-width: 0; }
.soon-dose:focus-visible, .dose-alert:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.dose-alert { width: 100%; align-items: flex-start; border: 0; text-align: left; }
.dose-alert .dose-box { border-color: var(--bad); margin-top: 1px; background: var(--card); }
.toast { display: flex; align-items: center; gap: 12px; width: max-content; }
.toast-undo { flex: none; min-height: 32px; padding: 0 4px; background: none; border: 0; color: inherit; font-weight: 700; text-decoration: underline; }
.dose-wrap { display: flex; align-items: center; border-bottom: 1px solid var(--line); }
.dose-wrap:last-child { border-bottom: 0; }
.dose { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; min-height: 56px; padding: 8px 14px; background: none; border: 0; text-align: left; }
.dose-skip { flex: none; min-height: 44px; padding: 0 14px; font-size: 13px; }
.dose.skipped .dose-name { color: var(--ink-2); font-weight: 500; }
.dose:hover { background: var(--hover); }
.dose:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.dose-box { display: grid; place-items: center; width: 24px; height: 24px; flex: none; border: 2px solid var(--input-line); border-radius: 7px; }
.dose-box svg.i { width: 16px; height: 16px; stroke-width: 3; }
.dose.taken .dose-box { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.dose.late .dose-box { border-color: var(--bad); }
.dose.late .dose-sub { color: var(--bad); }
.dose-name, .dose-sub { display: block; }
.time-row { display: grid; grid-template-columns: 1fr 44px; gap: 8px; align-items: center; }
.time-row .icon-btn { width: 44px; height: 44px; }
.add-time { justify-self: start; min-height: 32px; }
.ingredient-row { display: grid; grid-template-columns: minmax(0, 1fr) 68px 62px 36px; gap: 6px; align-items: center; }
.ingredient-row .input { min-height: 44px; padding: 0 6px; font-size: 14px; }
.ingredient-row .icon-btn { width: 36px; height: 44px; }
.check-inline { display: flex; gap: 10px; align-items: center; min-height: 36px; }
.check-inline input { width: 20px; height: 20px; flex: none; accent-color: var(--brand); }
td.wrap { white-space: normal; }
.med-block { min-width: 0; }
/* Nhắc uống thuốc: quầng màu lan ra từ nút, nhịp 1,4 giây */
.med-fab { position: fixed; z-index: 6; right: max(16px, calc(50vw - 224px)); bottom: calc(env(safe-area-inset-bottom, 0px) + 84px); height: 52px; padding: 0 18px 0 14px; display: inline-flex; align-items: center; gap: 8px; border: 0; border-radius: 26px; background: var(--brand); color: var(--brand-ink); font-size: 14px; font-weight: 600; white-space: nowrap; box-shadow: var(--shadow-fab); }
.med-fab::before { content: ''; position: absolute; inset: 0; z-index: -1; border-radius: inherit; animation: med-pulse 1.4s ease-out infinite; }
.med-fab svg.i { width: 26px; height: 26px; }
.med-fab:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.med-fab-count { position: absolute; top: -4px; right: -4px; min-width: 22px; height: 22px; padding: 0 5px; display: grid; place-items: center; border-radius: 11px; border: 2px solid var(--card); background: var(--bad); color: var(--card); font-size: 12px; font-weight: 700; }
/* Nút giờ là hình viên dài, nên quầng lan đều bằng bóng thay vì phóng to làm méo theo chiều ngang. */
@keyframes med-pulse { from { box-shadow: 0 0 0 0 color-mix(in srgb, var(--brand) 60%, transparent); } to { box-shadow: 0 0 0 20px color-mix(in srgb, var(--brand) 0%, transparent); } }
/* Người đã tắt chuyển động vẫn thấy nút, chỉ không nhấp nháy. */
@media (prefers-reduced-motion: reduce) { .med-fab::before { animation: none; box-shadow: 0 0 0 6px color-mix(in srgb, var(--brand) 30%, transparent); } }
.sheet-backdrop { position: fixed; inset: 0; z-index: 20; background: rgb(0 0 0 / 45%); }
.sheet { position: fixed; z-index: 21; left: 50%; bottom: 0; transform: translateX(-50%); width: 100%; max-width: 480px; max-height: 80vh; overflow-y: auto; display: grid; gap: 12px; padding: 16px 16px calc(env(safe-area-inset-bottom, 0px) + 16px); background: var(--card); border-radius: var(--radius) var(--radius) 0 0; }
/* Đang mở bảng thì đưa thông báo lên trên để không che nút của thuốc còn lại. */
body:has(.sheet) .toast { bottom: auto; top: 16px; }
.sheet-dose { display: grid; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); }
.sheet-dose .btn { padding-inline: 8px; line-height: 1.25; }
/* Tổng quan gọn */
.hero.compact { gap: 14px; }
.hero.compact .ring { width: 72px; height: 72px; }
.hero.compact .ring .v b { font-size: 18px; }
.hero.compact .ring .v small { display: none; }
.hero.compact .link-btn { font-size: 13px; }
.bar.covered i { background: var(--ink-3); }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 92px; z-index: 30; background: var(--ink); color: var(--card); padding: 10px 16px; border-radius: 12px; font-size: 14px; max-width: calc(100vw - 32px); }

/* Khuyến nghị cố định và kiểm tra giờ uống */
.rec-time, .timing-ok, .timing-tip { display: flex; gap: 6px; align-items: flex-start; }
.rec-time svg, .timing-ok svg, .timing-tip svg { width: 15px; height: 15px; margin-top: 2px; flex: none; }
.timing-ok { color: var(--good-ink); margin-top: 4px; }
.timing-tip { color: var(--ink-2); margin-top: 4px; }
.supp-warn svg { flex: none; }
.rec-more > summary { list-style: none; cursor: pointer; padding: 4px 0; }
.rec-more > summary::-webkit-details-marker { display: none; }
.rec-more[open] > summary { margin-bottom: 4px; }
a.notice { color: inherit; text-decoration: none; }
a.notice:hover { background: var(--hover); }
.bar.gap { margin: 4px 0 2px; }
.bar.done i { background: var(--good); }
/* Phần viên đã lo: chưa đủ thì nhạt, đủ thì đậm màu tốt, vượt ngưỡng thì đỏ */
.bar.share i { opacity: 0.5; }
.bar.share.done i, .bar.share.overul i { opacity: 1; }
.google-btn { gap: 10px; }
.google-btn svg.i { width: 18px; height: 18px; }
