/* Phần riêng của app (NUT-34): vỏ trang, điều hướng, danh sách bữa, bảng ngày, form phụ.
   Màu, vòng kcal, dải macro, nút, form và biểu đồ nằm ở tokens/base/ring/macros/seg/form/trend.css (chép từ widget).
   Chỉ dùng token của tokens.css, không màu thô, trừ bóng đổ. */
:root {
  --nav-h: 60px;
}

body.app {
  min-height: 100vh;
}

.shell {
  display: block;
}

main#view {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: 12px 12px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom));
}
main#view:focus {
  outline: none;
}
@media (min-width: 560px) {
  main#view {
    padding: 16px 16px calc(var(--nav-h) + 28px + env(safe-area-inset-bottom));
  }
}

/* ---- Điều hướng: thanh tab dưới cùng trên điện thoại và máy tính bảng, cột bên từ 1100px ---- */
.app-nav {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 5;
  background: var(--panel);
  border-top: 1px solid var(--panel-border);
  padding-bottom: env(safe-area-inset-bottom);
}
.app-nav .brand {
  display: none;
}
.app-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
}
.app-nav li {
  flex: 1;
  min-width: 0;
}
.app-nav a[data-route] {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: var(--nav-h);
  color: var(--text-dim);
  text-decoration: none;
  font-size: 11px;
  font-weight: 600;
}
.app-nav a[data-route]:hover {
  color: var(--text);
}
.app-nav svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.app-nav a[aria-current="page"] {
  color: var(--text);
  box-shadow: inset 0 3px 0 var(--accent-text);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
}
.brand svg {
  width: 28px;
  height: 28px;
  flex: none;
}
.logo-bg {
  fill: var(--text);
}
.logo-plate {
  fill: var(--accent);
}
.logo-stroke {
  fill: none;
  stroke: var(--till-fg);
  stroke-width: 2.4;
  stroke-linecap: round;
}

@media (min-width: 1100px) {
  .shell {
    display: grid;
    grid-template-columns: 14rem minmax(0, 1fr);
    min-height: 100vh;
  }
  .app-nav {
    position: sticky;
    inset: 0 auto auto 0;
    top: 0;
    height: 100vh;
    border-top: 0;
    border-right: 1px solid var(--panel-border);
    padding: 22px 12px;
  }
  .app-nav .brand {
    display: inline-flex;
    margin: 0 8px 24px;
  }
  .app-nav ul {
    flex-direction: column;
    gap: 2px;
  }
  .app-nav a[data-route] {
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    min-height: 42px;
    padding: 0 12px;
    border-radius: 10px;
    font-size: 14px;
  }
  .app-nav a[data-route]:hover {
    background: var(--track);
  }
  .app-nav a[aria-current="page"] {
    background: var(--track);
    box-shadow: none;
  }
  main#view {
    padding: 24px 24px 48px;
  }
}

/* ---- Demo (NUT-32): banner cố định trên cùng, vỏ app lùi xuống đúng chiều cao banner ---- */
/* NUT-117: hai hàng dưới 900px (câu, rồi ba link), một hàng từ 900px. Link cao 24px (WCAG 2.2 target). */
body.demo {
  --banner-h: 56px;
  padding-top: var(--banner-h);
}
.demo-banner {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 8;
  height: var(--banner-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--panel-border);
  font-size: 12px;
  line-height: 16px;
  text-align: center;
}
.demo-banner p {
  margin: 0;
}
.demo-links {
  display: flex;
  justify-content: center;
  gap: 16px;
}
.demo-banner a {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  color: var(--text-dim);
}
.demo-banner a span {
  margin-right: 4px;
}
/* Link phụ không gạch chân (uma P2): chỉ CTA mang gạch accent; hover vẫn hiện gạch để biết là link. */
.demo-banner a:not(.demo-cta) {
  text-decoration: none;
}
.demo-banner a:not(.demo-cta):hover {
  text-decoration: underline;
  text-decoration-color: var(--text-dim);
}
.demo-banner a.demo-cta {
  color: var(--text);
  font-weight: 700;
}
@media (max-width: 379px) {
  body.demo {
    --banner-h: 72px;
  }
}
@media (min-width: 900px) {
  body.demo {
    --banner-h: 40px;
  }
  .demo-banner {
    flex-direction: row;
    gap: 32px;
    padding: 0 16px;
  }
}
@media (min-width: 1100px) {
  body.demo .shell {
    min-height: calc(100vh - var(--banner-h));
  }
  body.demo .app-nav {
    top: var(--banner-h);
    height: calc(100vh - var(--banner-h));
  }
}

/* ---- Tiêu đề section, chữ phụ ---- */
.stitle {
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.01em;
  margin-bottom: 6px;
}
.fine {
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-dim);
}
.small-print {
  font-size: var(--fs-small);
  line-height: 1.4;
  color: var(--text-dim);
}
.panel .empty {
  border: 0;
  box-shadow: none;
  background: none;
  padding: 24px 8px;
}
.empty .fine {
  margin-top: 4px;
}
.sub {
  display: block;
  font-size: var(--fs-small);
  color: var(--text-dim);
}
.email {
  overflow-wrap: anywhere;
}

/* ---- Chọn ngày ---- */
.day-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.day-pick {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
}
.day-pick .input {
  width: auto;
  min-height: 32px;
  padding: 3px 8px;
  font-size: 16px;
}
@media (min-width: 560px) {
  .day-pick .input {
    font-size: 13px;
  }
}

/* ---- Bữa ăn ---- */
.meal-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.meal-head .stitle {
  margin: 0;
  font-size: 13px;
}
.meal-head .time {
  margin-left: 8px;
  font-weight: 500;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.meal-kcal {
  font-size: 12.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.meal-macros,
.meal-source {
  margin-top: 2px;
  font-size: var(--fs-small);
  color: var(--text-dim);
}

details.item {
  border-top: 1px solid var(--panel-border);
  margin-top: 6px;
}
details.item:first-of-type {
  margin-top: 8px;
}
details.item summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 40px;
  list-style: none;
  cursor: pointer;
}
details.item summary::-webkit-details-marker {
  display: none;
}
details.item summary::after {
  content: "";
  flex: none;
  width: 6px;
  height: 6px;
  margin-left: 2px;
  border-right: 1.5px solid var(--text-dim);
  border-bottom: 1.5px solid var(--text-dim);
  transform: rotate(45deg);
}
details.item[open] summary::after {
  transform: rotate(-135deg);
}
.item-name {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  padding: 6px 0;
}
.item-title {
  font-weight: 600;
}
.item-kcal {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.item-body {
  padding: 0 0 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.item-body .nums {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 12px;
  font-size: 12.5px;
}
.item-body .typed {
  font-size: 12px;
  color: var(--text-dim);
}
.item .assumptions {
  margin: 0;
  padding-left: 1.1em;
}
/* ---- Nhãn nguồn (NUT-105, .jc-docs/design/NUT-105/design.md "He nhan nguon"): chữ mang nghĩa, hình dấu khác nhau theo hình dạng ---- */
.src-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-small);
  font-weight: 500;
  color: var(--text-dim);
}
.src-glyph {
  flex: none;
  width: 8px;
  height: 8px;
  box-sizing: border-box;
}
.src-checked {
  border-radius: 50%;
  background: var(--src-checked);
}
.src-ai {
  border-radius: 50%;
  border: 1.5px solid var(--src-ai);
}
.src-confirmed {
  width: 7px;
  height: 7px;
  margin: 0 0.5px;
  background: var(--src-confirmed);
  transform: rotate(45deg);
}
.src-usda,
.src-other {
  border: 1.5px solid var(--src-legacy);
}
.src-legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 12px;
  color: var(--text-dim);
}
.src-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
/* Câu giải thích thụt vào thẳng với chữ nhãn (glyph 8 px + gap 6 px). */
.src-why {
  margin: 2px 0 0 14px;
}
.src-legend .src-name {
  color: var(--text);
  font-weight: 600;
}
.src-legend .src-count {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}
/* NUT-111: dưới 600 px câu giải thích ẩn sau nút "Show details"; từ 600 px nút ẩn, câu luôn hiện như trước. */
.src-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.src-head .stitle {
  margin-bottom: 0;
}
@media (max-width: 599px) {
  .src-block:not(.open) .src-why {
    display: none;
  }
}
@media (min-width: 600px) {
  .src-toggle {
    display: none;
  }
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}

/* ---- Cặp nhãn / giá trị ---- */
.kv {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px 12px;
  margin: 0;
}
.kv dt {
  font-size: 11px;
  color: var(--text-dim);
}
.kv dd {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ---- Bảng ngày ---- */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
table {
  width: 100%;
  min-width: 480px;
  border-collapse: collapse;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
th,
td {
  padding: 6px 8px;
  text-align: right;
  white-space: nowrap;
  border-top: 1px solid var(--panel-border);
}
th:first-child,
td:first-child {
  text-align: left;
  padding-left: 0;
}
thead th {
  border-top: 0;
  font-size: var(--fs-label);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
}
tbody th {
  font-weight: 600;
}
td .sub {
  font-size: var(--fs-label);
}
/* NUT-105: dưới 480 px bảng ngày chỉ giữ ngày, kcal, protein, carbs, fat để không cột nào bị cắt; fiber, sugar, sodium có từ 480 px
   (và trong dải macro trung bình phía trên). */
@media (max-width: 479px) {
  .days-table {
    min-width: 0;
  }
  .days-table th:nth-child(n + 6),
  .days-table td:nth-child(n + 6) {
    display: none;
  }
  /* NUT-159: cột Water bị ẩn ở đây, nên ngày chỉ có nước hiện nhãn nằm đè qua bốn ô macro trống (luôn trống ở hàng này). */
  .days-table td.water-only {
    position: relative;
  }
  .days-table .water-only-label {
    display: block;
    position: absolute;
    top: 50%;
    left: 8px;
    transform: translateY(-50%);
    color: var(--text-dim);
  }
}
.water-only-label {
  display: none;
}
/* NUT-155: viewport 320-359px, năm cột với đệm 8px rộng hơn panel nên cột FAT bị cắt. Thu đệm ngang trước khi phải cuộn. */
@media (max-width: 359px) {
  .days-table th,
  .days-table td {
    padding-left: 4px;
    padding-right: 4px;
  }
  .days-table thead th {
    letter-spacing: 0.02em;
  }
}
.table-scroll + .btn {
  margin-top: 8px;
}

/* ---- Tìm món, danh sách hàng ---- */
.search-row {
  display: flex;
  gap: 8px;
  margin-top: 5px;
}
.search-row .input {
  flex: 1;
  min-width: 0;
}
.rows {
  list-style: none;
  margin: 0;
  padding: 0;
}
.rows > li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--panel-border);
}
.rows > li:first-child {
  border-top: 0;
}
.rows > li > div:first-child {
  min-width: 0;
}
.top-foods > li {
  flex-wrap: wrap;
}
.top-foods .sub {
  display: inline;
}
.sub-list {
  list-style: none;
  margin: 2px 0 0;
  padding: 0;
  font-size: var(--fs-small);
  color: var(--text-dim);
}
ul.plain {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 13px;
}
ul.plain li {
  padding: 4px 0;
}

/* ---- Form phụ ---- */
.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 10px;
}
.confirm {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.status {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
}
.status:empty {
  display: none;
}
.status.err {
  color: var(--over);
}
.confirm .status {
  flex-basis: 100%;
}
.psec > .status,
.psec > .actions + .status {
  margin-top: 8px;
}
.danger-zone .stitle {
  color: var(--over);
}
.danger-zone .btn {
  margin-top: 4px;
}
.psec > p + p,
.psec > p + .btn,
.psec > p + .confirm {
  margin-top: 8px;
}

/* ---- Khung chờ tải ---- */
.skeleton {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sk-title,
.sk-block {
  background: var(--track);
  border-radius: var(--radius);
}
.sk-title {
  height: 20px;
  width: 40%;
}
.sk-block {
  height: 70px;
}
.sk-block.tall {
  height: 150px;
}
@media (prefers-reduced-motion: no-preference) {
  .skeleton > div {
    animation: sk-pulse 1.2s ease-in-out infinite;
  }
}
@keyframes sk-pulse {
  50% {
    opacity: 0.55;
  }
}

/* Màn cảm ứng: nút lọc kỳ trong header cần vùng bấm lớn hơn cỡ chữ 11px của widget. */
@media (pointer: coarse) {
  .seg-sm .seg-btn {
    padding: 7px 11px;
  }
}

/* ---- Sửa bữa (NUT-134): spec ở .jc-docs/design/NUT-134-meal-edit/. Chỉ token của tokens.css. ---- */

/* Nút Edit trên đầu mỗi bữa ở màn Today: tên + giờ trái, kcal và Edit phải. */
.meal-head .meal-kcal {
  margin-left: auto;
}
.meal-edit {
  flex: none;
  align-self: center;
}

/* Chọn loại bữa: radio thật bọc trong .seg-btn (bàn phím mũi tên chạy sẵn trong nhóm radio). */
.mtype {
  border: 0;
  margin: 0 0 12px;
  padding: 0;
  min-width: 0;
}
.mtype legend {
  padding: 0;
  margin-bottom: 5px;
}
.seg-radio {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 0;
  border-radius: 12px;
}
.seg-radio .seg-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 6px 4px;
  border-radius: 10px;
  font-size: 12px;
}
.seg-radio input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}
.seg-radio .seg-btn:has(input:checked) {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: inset 0 0 0 1.5px var(--accent-text);
}
.seg-radio .seg-btn:has(input:focus-visible) {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-text) 35%, transparent);
}
.seg-radio .seg-btn:has(input:checked:focus-visible) {
  box-shadow: inset 0 0 0 1.5px var(--accent-text), 0 0 0 3px color-mix(in srgb, var(--accent-text) 35%, transparent);
}
@media (min-width: 560px) {
  .seg-radio {
    display: inline-grid;
    grid-template-columns: repeat(4, auto);
    border-radius: 999px;
  }
  .seg-radio .seg-btn {
    padding: 6px 15px;
    border-radius: 999px;
    font-size: 13px;
  }
}

/* Danh sách món: tổng bữa cập nhật khi gõ nằm cùng dòng tiêu đề. */
.mf-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}
.mf-head .stitle {
  margin: 0;
}
.mf-total {
  font-size: var(--fs-small);
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.mf-total strong {
  color: var(--text);
}

/* Một món = một fieldset: tên, rồi 5 ô số. 390: gram|kcal hai cột, protein|carbs|fat ba cột. Từ 560: 5 cột một hàng. */
.mitem {
  margin: 0;
  padding: 10px 0 12px;
  border: 0;
  border-top: 1px solid var(--panel-border);
  min-width: 0;
}
.mitem:first-of-type {
  border-top: 0;
  padding-top: 2px;
}
.mitem legend {
  float: left;
  width: 100%;
  padding: 0;
  margin-bottom: 6px;
  font-size: var(--fs-small);
  font-weight: 600;
  color: var(--text-dim);
}
.mitem legend + * {
  clear: both;
}
.mitem .field {
  margin-bottom: 8px;
}
.mitem-nums {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0 8px;
}
.mitem-nums .field {
  grid-column: span 2;
}
.mitem-nums .field:nth-child(-n + 2) {
  grid-column: span 3;
}
.mitem-nums .input {
  font-variant-numeric: tabular-nums;
}
@media (min-width: 560px) {
  .mitem-nums {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
  .mitem-nums .field,
  .mitem-nums .field:nth-child(-n + 2) {
    grid-column: auto;
  }
}
.mitem-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 10px;
}

/* Ô lỗi: viền --over + câu .field-error (form.css) nối bằng aria-describedby. */
.input[aria-invalid="true"] {
  border-color: var(--over);
}

/* Cảnh báo số lệch (cùng kiểm như đường ghi MCP): không chặn, chữ màu thường trên nền vàng nhạt để đạt 4.5:1. */
.mitem.flagged .input.flag {
  border-color: var(--warn);
  box-shadow: inset 0 0 0 1px var(--warn);
}
.mitem-warn {
  margin: 2px 0 8px;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--warn) 45%, var(--panel-border));
  background: color-mix(in srgb, var(--warn) 9%, var(--panel));
  font-size: var(--fs-small);
  line-height: 1.4;
}
.mitem-warn strong {
  display: block;
}

/* Form là MỘT con của .panel nên không nhận gap của panel: tự đặt cùng nhịp 9/10 px cho các .psec bên trong. */
.meal-form {
  display: flex;
  flex-direction: column;
  gap: 9px;
}
@media (min-width: 560px) {
  .meal-form {
    gap: 10px;
  }
}
.meal-form .actions {
  margin-top: 0;
}
.meal-form > .status {
  margin-top: 8px;
}

/* ---- NUT-139: màn chào lần đầu, bước kết nối Claude, dòng múi giờ ở Account (spec .jc-docs/design/NUT-139-first-run/first-run.css) ---- */

/* Đầu màn chào: lớn hơn .ptitle vì đây là màn onboarding (mật độ thấp hơn màn dữ liệu). */
.welcome {
  gap: 16px;
}
.welcome-head {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 0 4px;
}
/* font-weight như .ptitle/.stitle: Bowlby One chỉ có một nét, chữ dự phòng (font-display: optional) cần đậm để giữ thứ bậc. */
.welcome-title {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
.welcome-lede {
  max-width: 60ch;
  color: var(--text);
  text-wrap: pretty;
}

/* Danh sách bước: ol thật, số vẽ trong .step-mark (aria-hidden), vạch nối dọc giữa các số. */
.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}
.step {
  position: relative;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  column-gap: 12px;
  padding-bottom: 24px;
}
.step:last-child {
  padding-bottom: 0;
}
.step:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 13px;
  top: 32px;
  bottom: 4px;
  border-left: 2px dotted var(--panel-border);
}
.step-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--track);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.step-mark svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.step.is-current .step-mark {
  background: var(--accent);
  color: var(--on-accent);
}
.step.is-done .step-mark {
  background: var(--text);
  color: var(--panel);
}
.step-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  padding-top: 4px;
}
.step-title {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
}
.step.is-done .step-title {
  color: var(--text-dim);
}
.step-body p {
  max-width: 64ch;
}
.step-done-note {
  font-size: var(--fs-small);
  color: var(--text-dim);
}
/* Bước chưa tới: chữ phụ nhỏ hơn, vẫn đọc được đủ để biết trước việc cần làm. */
.step:not(.is-current):not(.is-done) .step-body > p:not(.say) {
  color: var(--text-dim);
}

/* URL connector + nút Copy: một hàng khi đủ rộng, xuống hàng khi hẹp. */
.url-row {
  max-width: 64ch;
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 8px;
}
.url {
  flex: 1 1 220px;
  min-width: 0;
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  font-family: inherit;
  font-size: 13px;
  white-space: nowrap;
  overflow-x: auto;
  user-select: all;
  -webkit-user-select: all;
}
.copy-btn {
  flex: none;
  gap: 8px;
  min-width: 112px;
}
.copy-btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.copy-btn .ic-done {
  display: none;
}
.copy-btn.is-copied .ic-copy {
  display: none;
}
.copy-btn.is-copied .ic-done {
  display: block;
}
.url-row + .status {
  margin-top: -4px;
}
.status.ok {
  color: var(--text);
}

/* Câu mẫu nói với Claude: giống .say của /connect (NUT-132) để web và app trông cùng một việc. */
.say {
  padding: 8px 12px;
  background: var(--bg);
  border-left: 3px solid var(--accent);
  border-radius: 0 10px 10px 0;
}

/* Dòng chờ: chấm accent nhịp chậm, tắt khi giảm chuyển động. */
.waiting {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-small);
  color: var(--text-dim);
}
.waiting-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-text);
}
@media (prefers-reduced-motion: no-preference) {
  .waiting-dot {
    animation: waiting-pulse 1.6s ease-in-out infinite;
  }
}
@keyframes waiting-pulse {
  50% {
    opacity: 0.3;
  }
}

.welcome-foot {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Account: dòng múi giờ, form đổi múi giờ. */
.tz-now {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
}
.tz-now strong {
  overflow-wrap: anywhere;
}
.tz-offset {
  font-size: var(--fs-small);
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.tz-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.tz-device {
  margin-top: 8px;
}
.tz-form {
  margin-top: 12px;
  max-width: 420px;
}
.tz-form .field {
  margin-bottom: 8px;
}
select.input {
  padding-right: 32px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%), linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}

@media (min-width: 560px) {
  .welcome {
    padding: 24px;
    gap: 24px;
  }
  .welcome-title {
    font-size: 24px;
  }
}

/* Khoảng cách đoạn văn và ô nhập trong section (sửa chỗ dính ở Delete account; NUT-182). */
.psec > p + .field,
.psec > .notice + .field,
.psec > p + .notice {
  margin-top: 8px;
}
/* Khối "đăng nhập lại" trong Delete account (NUT-182). */
.reauth .btn {
  margin-top: 2px;
}
.reauth form {
  margin: 0 0 6px;
}
.reauth:focus {
  outline: none;
}
.reauth:focus-visible {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-text) 35%, transparent);
}

/* Account: thiết bị đang đăng nhập (NUT-183). Hàng dùng .rows có sẵn; khối trái thêm icon thiết bị. */
.dev {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
}
.dev-ic {
  flex: none;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  color: var(--text-dim);
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.dev-name {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 8px;
  overflow-wrap: anywhere;
}
.dev-badge {
  font-size: var(--fs-label);
  font-weight: 700;
  line-height: 16px;
  padding: 0 7px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: var(--track);
  color: var(--text);
  white-space: nowrap;
}
/* Hàng thiết bị xuống dòng khi nút xác nhận hoặc lỗi không đủ chỗ; chữ không bị bóp thành cột hẹp. */
.dev-rows > li {
  flex-wrap: wrap;
}
.dev-rows .dev {
  flex: 1 1 220px;
}
.dev-rows .confirm {
  margin-left: auto;
  justify-content: flex-end;
}
.dev-rows .confirm .status {
  text-align: right;
}
.psec > .actions + .small-print,
.psec > .rows + .fine,
.psec > p + .dev-load {
  margin-top: 8px;
}
.dev-load {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

/* ---- NUT-159: nước uống và thông báo dữ liệu sức khoẻ ---- */
.water-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 10px;
}
.water-head .stitle {
  margin: 0;
}
.water-total {
  font-size: 12.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.water-total .wsub {
  margin-left: 6px;
  font-weight: 500;
  color: var(--text-dim);
}
.water-total.none {
  font-weight: 500;
  color: var(--text-dim);
}
.water .mbar {
  order: 3;
  flex: 1 1 100%;
  --c: var(--water);
}
.water .mcap {
  display: block;
  margin-top: 4px;
  white-space: normal;
}
.water .small-print {
  margin-top: 4px;
}
.water-list {
  margin-top: 6px;
}
/* Hàng: giờ (+ "Logged as") | lượng | nút Delete. Khi hỏi lại "Yes, delete / Cancel" mở ra, cụm xác nhận xuống hàng riêng,
   canh phải, câu lỗi nằm dưới nó: không bóp cột lượng. */
.water-list > li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  column-gap: 12px;
  row-gap: 6px;
}
.water-time {
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.water-list .confirm {
  justify-content: flex-end;
}
.water-list .confirm:has(.btn-danger) {
  grid-column: 1 / -1;
}
.water-list .confirm .status {
  text-align: right;
}
.water-amt {
  font-size: 12.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}
.water-amt .sub {
  font-weight: 400;
}

/* Goals: ô nước nằm một hàng riêng để câu lỗi trải hết chiều ngang (uma P2-3); ô nhập giữ bề rộng như một cột. */
.field-grid > .field-water {
  grid-column: 1 / -1;
}
.field-water .input {
  max-width: calc(50% - 5px);
}

/* Thông báo dữ liệu sức khoẻ cập nhật (người dùng cũ). Dùng .notice trung tính (không vàng, không đỏ): đây không phải cảnh báo. */
.health-notice .stitle {
  margin-bottom: 4px;
}
.health-notice .hn-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin-top: 8px;
}
.health-notice .status {
  margin-top: 6px;
}
.hn-done {
  font-weight: 600;
}
/* Account, Export: dòng "CSV has foods only..." không dính sát vào hàng nút (uma P2-5). */
.psec > .actions + .fine {
  margin-top: 6px;
}

@media (min-width: 560px) {
  .water-head.has-bar {
    flex-wrap: nowrap;
    align-items: center;
    gap: 12px;
  }
  .water .mbar {
    order: 0;
    flex: 1 1 auto;
  }
}

/* Toàn văn thông báo (Q5): <details> dùng lại kiểu mũi tên của details.item, chỉ token có sẵn. */
.hn-full {
  margin-top: 8px;
  border-top: 1px solid var(--panel-border);
}
.hn-full summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 40px;
  list-style: none;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
}
.hn-full summary::-webkit-details-marker {
  display: none;
}
.hn-full summary::after {
  content: "";
  flex: none;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid var(--text-dim);
  border-bottom: 1.5px solid var(--text-dim);
  transform: rotate(45deg);
}
.hn-full[open] summary::after {
  transform: rotate(-135deg);
}
.hn-text p {
  margin: 0 0 6px;
  font-size: 12.5px;
  line-height: 1.45;
}
.hn-checks {
  margin: 0 0 4px;
  padding-left: 18px;
  font-size: 12.5px;
  line-height: 1.45;
}
.hn-checks li + li {
  margin-top: 4px;
}

/* NUT-204: cân nặng. Token --weight nằm ở tokens.css (cả hai khối). Khối Today giống khối Water (NUT-159): dòng đầu tên | số, rồi các ô kv, rồi hàng nút. */
/* ---- Today: khối Weight ---- */
.weight-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 10px;
}
.weight-head .stitle {
  margin: 0;
}
.weight-now {
  font-size: 12.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  text-align: right;
}
.weight-now .wsub {
  margin-left: 6px;
  font-weight: 500;
  color: var(--text-dim);
}
.weight-now.none {
  font-weight: 500;
  color: var(--text-dim);
}
.weight .kv {
  margin-top: 8px;
}
.weight .kv dd .wsub {
  font-size: var(--fs-small);
  font-weight: 500;
  color: var(--text-dim);
}
.weight > .small-print {
  margin-top: 6px;
}
.weight-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
}

/* Form ghi cân (Today mở ngay trong khối; màn #/weight luôn mở). Ô số có hậu tố đơn vị ngay trong ô. */
.wform {
  margin-top: 10px;
}
.wform .field-grid {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}
.wform .wfield-num {
  grid-column: 1 / -1;
}
.wnum-wrap {
  position: relative;
  max-width: calc(50% - 5px);
}
.wnum-wrap .input {
  font-variant-numeric: tabular-nums;
}
.wform .actions {
  margin-top: 0;
}
.wform > .status {
  margin-top: 8px;
}
@media (min-width: 560px) {
  .wform .field-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
  }
  .wform .wfield-num {
    grid-column: auto;
  }
  .wnum-wrap {
    max-width: none;
  }
}

/* ---- History: biểu đồ cân. Trục theo khoảng dữ liệu (không từ 0), nhãn min/max ở cột trái. ---- */
.wplot {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 6px;
}
.wy {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 2px 0;
  font-size: var(--fs-label);
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.wplot .cplot {
  min-width: 0;
}
.wplot + .tdates {
  margin-left: var(--wy-w, 34px);
}
.wgoal-tag {
  position: absolute;
  right: 2px;
  top: var(--y);
  transform: translateY(calc(-100% - 2px));
  font-size: var(--fs-label);
  font-weight: 600;
  color: var(--text-dim);
  background: color-mix(in srgb, var(--panel) 85%, transparent);
  padding: 0 3px;
  border-radius: 4px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
}
.wgoal-tag.below {
  transform: translateY(2px);
}
.wlegend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
  font-size: var(--fs-label);
  color: var(--text-dim);
}
.wlegend li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.sw {
  flex: none;
  display: inline-block;
}
.sw-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--weight) 70%, var(--panel));
}
.sw-line {
  width: 16px;
  height: 2px;
  border-radius: 2px;
  background: var(--weight);
}
.sw-dash {
  width: 16px;
  height: 0;
  border-top: 1.5px dashed var(--text-dim);
}
.weight-block .kv {
  margin-top: 10px;
}
.weight-block .weight-actions {
  margin-top: 8px;
}
.weight-block > .small-print {
  margin-top: 4px;
}

/* ---- Màn #/weight: danh sách lần cân ---- */
.weight-list > li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  column-gap: 12px;
  row-gap: 6px;
}
.wl-day {
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.wl-val {
  font-size: 12.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}
.wl-acts {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}
.wl-acts .confirm {
  justify-content: flex-end;
}
/* Đang hỏi "Yes, delete / Cancel" thì cụm nút xuống hàng riêng, canh phải (như hàng nước). */
.weight-list > li.asking .wl-acts {
  grid-column: 1 / -1;
}
/* Hàng đang sửa: form chiếm cả hàng. */
.weight-list > li.editing {
  display: block;
}
.weight-list > li.editing .wform {
  margin-top: 6px;
}
.wl-group {
  font-family: inherit;
  margin: 10px 0 2px;
  font-size: var(--fs-label);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}
.wl-group:first-child {
  margin-top: 0;
}

/* ---- Goals: ô cân mục tiêu nằm một hàng riêng như ô nước ---- */
.field-grid > .field-weight {
  grid-column: 1 / -1;
}
.field-weight .wnum-wrap {
  max-width: calc(50% - 5px);
}

/* ---- Account: đơn vị cân, hai lựa chọn ---- */
.seg-radio.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-width: 220px;
}
@media (min-width: 560px) {
  .seg-radio.two {
    grid-template-columns: repeat(2, auto);
  }
}
.unit-set > .fine {
  margin-top: 8px;
}
.unit-set > .status {
  margin-top: 6px;
}

/* Uma P1: biểu đồ đọc được bằng bàn phím (mũi tên); vòng tròn đánh dấu ngày đang đọc. */
.wplot svg:focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 2px;
  border-radius: 6px;
}
.wcursor {
  display: none;
  stroke: var(--text);
  stroke-width: 1.5;
}
.wcursor.on {
  display: inline;
}
/* Uma P2: đường quay về Today ở đầu màn #/weight. */
.back {
  margin: 0 0 4px;
}
