:root {
    --bg: #f4f8fc;
    --bg-2: #e7eff8;
    --ink: #0e2a4e;
    --ink-2: #21456e;
    --muted: #5f7493;
    --muted-2: #97a8bd;
    --line: #dbe6f1;
    /* Bám theo brand/line của theme đang chọn (định nghĩa lại ở :root cam + html[data-theme]),
       KHÔNG hardcode navy cũ — tránh rò navy vào theme cam/tối. */
    --line-2: var(--line);
    --accent: var(--br);
    --iced: var(--brs);
    --danger: #8b2b2b;
    --success: #1f5f4a;
    --warn: #9a6b1f;
    --on-ink-line: rgba(255,255,255,0.38); /* viền nút phụ trên nền tối (.select-bar) */
    --display: 'Fraunces', Georgia, serif;
    --body: 'Inter Tight', system-ui, sans-serif;
    --mono: 'JetBrains Mono', monospace;
  }
  * { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
  html, body { background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 16px; line-height: 1.5; min-height: 100vh; -webkit-font-smoothing: antialiased; }
  body { padding: 0; }
  button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
  input, select { font-family: inherit; color: inherit; }

  /* PIN Screen */
  .pin-screen { position: fixed; inset: 0; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 24px; z-index: 100; }
  .pin-brand { font-family: var(--display); font-weight: 300; font-style: italic; font-size: clamp(48px, 12vw, 72px); letter-spacing: -0.04em; line-height: 0.9; margin-bottom: 8px; }
  .pin-sub { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.2em; color: var(--muted); margin-bottom: 48px; }
  .pin-prompt { font-family: var(--display); font-size: 22px; font-weight: 400; margin-bottom: 4px; color: var(--ink); text-align: center; }
  .pin-hint { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.18em; color: var(--muted); margin-bottom: 28px; min-height: 14px; }
  .pin-dots { display: flex; gap: 16px; margin-bottom: 36px; align-items: center; min-height: 18px; }
  .pin-dot { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--line-2); background: transparent; transition: all 0.18s ease-out; }
  .pin-dot.filled { background: var(--ink); border-color: var(--ink); transform: scale(1.15); }
  .pin-dot.error { border-color: var(--danger); background: var(--danger); animation: shake 0.4s; }
  @keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
  .pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 300px; width: 100%; }
  .pin-key { aspect-ratio: 1.3; border: 1px solid var(--line); border-radius: 16px; background: var(--bg); font-family: var(--display); font-weight: 400; font-size: 28px; transition: all 0.12s; display: flex; align-items: center; justify-content: center; user-select: none; }
  .pin-key:active { background: var(--ink); color: var(--bg); transform: scale(0.95); border-color: var(--ink); }
  .pin-key.action-del { font-size: 22px; color: var(--muted); }
  .pin-key.action-ok { background: var(--ink); color: var(--bg); border-color: var(--ink); font-size: 24px; }
  .pin-key.action-ok:active { background: var(--ink-2); transform: scale(0.95); }
  .pin-key.action-ok:disabled { background: var(--bg); color: var(--muted-2); border-color: var(--line); cursor: not-allowed; }
  .pin-key.action-ok:disabled:active { transform: none; }
  .pin-msg { margin-top: 20px; font-size: 13px; color: var(--muted); text-align: center; min-height: 18px; transition: color 0.15s; }
  .pin-msg.error { color: var(--danger); }

  /* App layout */
  .app { max-width: 720px; margin: 0 auto; padding: calc(24px + env(safe-area-inset-top, 0px)) calc(20px + env(safe-area-inset-right, 0px)) calc(100px + env(safe-area-inset-bottom, 0px)) calc(20px + env(safe-area-inset-left, 0px)); }
  .header { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 32px; padding-top: 8px; }
  .brand { font-family: var(--display); font-weight: 300; font-style: italic; font-size: 32px; letter-spacing: -0.03em; line-height: 1; }
  .brand-sub { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.2em; color: var(--muted); margin-top: 4px; }
  .header-meta { font-family: var(--mono); font-size: 11px; color: var(--muted); text-align: right; line-height: 1.6; }

  /* Stats grid */
  .stats { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); margin-bottom: 32px; }
  .stat { background: var(--bg); padding: 20px 18px; }
  .stat-label { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.18em; color: var(--muted); margin-bottom: 8px; }
  .stat-value { font-family: var(--display); font-size: 36px; font-weight: 400; line-height: 1; letter-spacing: -0.02em; }
  .stat-unit { font-family: var(--mono); font-size: 12px; color: var(--muted); margin-left: 4px; font-weight: 400; }
  .stat-meta { font-size: 12px; color: var(--muted); margin-top: 6px; }

  /* Streak special */
  .stat.streak { background: linear-gradient(140deg, var(--br) 0%, var(--br2) 100%); color: #fff; }
  .stat.streak .stat-value { color: #fff; }
  .stat.streak .stat-label { color: var(--muted-2); }
  .stat.streak .stat-meta { color: var(--muted-2); }

  /* Header tóm tắt: hero streak gọn nằm ngang + lưới mini-stat bên dưới.
     Mục tiêu: bớt chiều cao trên mobile, vẫn liếc thấy đủ số. */
  .stats-hero { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin-bottom: 12px; }
  .stats-hero .stat.streak {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; padding: 16px 20px;
  }
  .stats-hero .stat.streak .stat-label { margin-bottom: 0; }
  .stats-hero .stat.streak .stat-value { font-size: 40px; }
  /* Lưới 4 mini-stat: 2×2 trên mobile, 1 hàng 4 cột trên màn rộng */
  .stats-row.header-stats { margin-bottom: 32px; }
  @media (min-width: 620px) {
    .stats-row.header-stats { grid-template-columns: repeat(4, 1fr); }
  }

  /* Tabs */
  .tabs { display: flex; gap: 2px; margin-bottom: 24px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { padding: 12px 16px 14px; font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.15em; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; transition: all 0.15s; flex-shrink: 0; white-space: nowrap; }
  .tab.active { color: var(--ink); border-bottom-color: var(--ink); }
  .tab:hover:not(.active) { color: var(--ink-2); }

  /* Section */
  .section { display: none; animation: fadeIn 0.3s; }
  .section.active { display: block; }
  @keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

  .section-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
  .section-title { font-family: var(--display); font-size: 24px; font-weight: 400; letter-spacing: -0.02em; }
  .section-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
  .section-action { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.15em; color: var(--ink); padding: 8px 14px; border: 1px solid var(--ink); border-radius: 999px; transition: all 0.15s; white-space: nowrap; }
  .section-action:hover { background: var(--ink); color: var(--bg); }
  .section-action.ghost { color: var(--muted); border-color: var(--line-2); }
  .section-action.ghost:hover { background: var(--bg-2); color: var(--ink); border-color: var(--ink); }
  /* Trạng thái BẬT (vd nhắc nhở tối đang bật): nhấn xanh --success. */
  .section-action.on { color: var(--success); border-color: var(--success); }
  .section-action.on:hover { background: var(--success); color: var(--bg); border-color: var(--success); }

  /* Hàng cài đặt: nhãn + dòng phụ mono bên trái, nút pill bên phải. */
  .settings-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 0; border-top: 1px solid var(--line); }
  .settings-row-info { min-width: 0; }
  .settings-row-label { font-size: 15px; color: var(--ink); margin-bottom: 3px; }
  .settings-row-sub { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.13em; color: var(--muted); line-height: 1.5; }

  /* Form */
  [hidden] { display: none !important; }
  .form { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 20px; margin-bottom: 20px; display: none; }
  .form.open { display: block; animation: fadeIn 0.25s; }
  .form-row { display: grid; gap: 12px; margin-bottom: 14px; }
  .form-row.cols-2 { grid-template-columns: 1fr 1fr; }
  .form-label { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.18em; color: var(--muted); margin-bottom: 6px; display: block; }
  .form-input, .form-select { width: 100%; padding: 11px 14px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--bg); font-size: 15px; transition: border 0.15s; }
  .form-input:focus, .form-select:focus { outline: none; border-color: var(--ink); }
  .form-actions { display: flex; gap: 10px; margin-top: 18px; }
  .form-edit-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 8px; padding: 9px 12px; margin-bottom: 16px; }
  .form-edit-label { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.15em; color: var(--ink-2); }
  .form-edit-cancel { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); border-bottom: 1px dotted var(--line-2); padding: 0 0 1px; }
  .form-edit-cancel:hover { color: var(--danger); border-bottom-color: var(--danger); }
  .btn { padding: 11px 18px; border-radius: 8px; font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.15em; transition: all 0.15s; }
  /* Nền/chữ .btn-primary do block brand ở cuối file quyết định (gradient cam). Ở đây chỉ giữ layout. */
  .btn-primary { flex: 1; }
  .btn-ghost { color: var(--muted); }
  .btn-ghost:hover { color: var(--ink); }

  /* Workout category toggle + coach card */
  .workout-cat-toggle { display: flex; gap: 18px; padding: 8px 0; }
  .workout-cat-toggle label { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 14px; }
  .workout-cat-toggle input[type=radio] { accent-color: var(--ink); }

  .coach-card { background: linear-gradient(135deg, #f4f8fc 0%, #dceaf7 100%); border: 1px solid var(--ink); border-radius: 12px; padding: 16px 18px; margin-bottom: 20px; animation: fadeIn 0.3s; }
  .coach-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.15em; }
  .coach-icon { font-size: 18px; }
  .coach-close { margin-left: auto; background: none; border: none; color: var(--muted); font-size: 20px; cursor: pointer; padding: 0 4px; }
  .coach-close:hover { color: var(--ink); }
  .coach-body { font-size: 14px; line-height: 1.55; }
  .coach-loading { color: var(--muted); font-style: italic; }
  .coach-meta { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); margin-bottom: 8px; }
  .coach-hint { margin-bottom: 10px; }
  .coach-next { padding-top: 10px; border-top: 1px dashed var(--line-2); color: var(--ink); }
  .coach-next strong { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.15em; color: var(--muted); display: block; margin-bottom: 4px; }
  .coach-error { color: var(--muted); font-size: 13px; }

  /* List */
  .list { display: flex; flex-direction: column; gap: 0; border-top: 1px solid var(--line); }
  .list-item { display: grid; grid-template-columns: 50px 1fr auto auto; gap: 14px; align-items: center; padding: 14px 4px; border-bottom: 1px solid var(--line); transition: background 0.1s; }
  .list-item:hover { background: var(--bg-2); }
  .item-date { font-family: var(--mono); font-size: 11px; color: var(--muted); line-height: 1.3; }
  .item-date strong { display: block; font-family: var(--display); font-size: 22px; font-weight: 400; color: var(--ink); }
  .item-main { display: flex; flex-direction: column; gap: 2px; }
  .item-type { font-family: var(--display); font-size: 17px; font-weight: 600; }
  .item-detail { font-family: var(--mono); font-size: 11px; color: var(--muted); }
  .item-value { font-family: var(--display); font-size: 18px; text-align: right; }
  .item-value small { font-family: var(--mono); font-size: 10px; color: var(--muted); display: block; margin-top: 2px; }
  .item-del { color: var(--muted-2); padding: 6px; border-radius: 6px; transition: all 0.15s; font-size: 18px; line-height: 1; }
  .item-del:hover { color: var(--danger); background: var(--bg-2); }

  /* Item ví (Tài khoản): avatar tròn + tên + số dư — grid riêng, không mượn cột ngày */
  .list-item.acc { grid-template-columns: 40px 1fr auto; gap: 14px; cursor: pointer; }
  .acc-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--bg-2); border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; font-family: var(--display); font-size: 19px; font-weight: 600; color: var(--ink); }
  .list-item.acc .item-type { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .list-item.acc .item-value { font-size: 20px; font-weight: 500; }
  .list-item.acc .item-value small { display: inline; margin: 0; font-size: 13px; color: var(--muted-2); }

  /* Thẻ tín dụng: thanh hạn mức + nhãn vượt + nhãn màu viền/avatar */
  .acc-over { font-family: var(--mono); font-size: 9px; text-transform: uppercase; letter-spacing: 0.15em; color: var(--danger); margin-top: 2px; }
  .acc-bar { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: 6px; }
  .acc-bar-fill { height: 100%; background: var(--ink-2); transition: width 0.3s; }
  .acc-bar-fill.warn   { background: var(--warn); }
  .acc-bar-fill.danger { background: var(--danger); }
  .list-item.acc.acc-color-warn    { border-left: 3px solid var(--warn);    padding-left: 8px; }
  .list-item.acc.acc-color-danger  { border-left: 3px solid var(--danger);  padding-left: 8px; }
  .list-item.acc.acc-color-success { border-left: 3px solid var(--success); padding-left: 8px; }
  .list-item.acc.acc-color-warn    .acc-avatar { background: var(--warn);    color: var(--bg); border-color: var(--warn); }
  .list-item.acc.acc-color-danger  .acc-avatar { background: var(--danger);  color: var(--bg); border-color: var(--danger); }
  .list-item.acc.acc-color-success .acc-avatar { background: var(--success); color: var(--bg); border-color: var(--success); }
  .acc-swatch-row { display: flex; gap: 12px; }
  .acc-swatch { width: 32px; height: 32px; border-radius: 50%; background: var(--bg-2); border: 1px solid var(--line); cursor: pointer; transition: all 0.12s; }
  .acc-swatch.sw-warn { background: var(--warn); border-color: var(--warn); }
  .acc-swatch.sw-danger { background: var(--danger); border-color: var(--danger); }
  .acc-swatch.sw-success { background: var(--success); border-color: var(--success); }
  .acc-swatch.selected { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--ink); }

  /* ===== Nhắc nhở (reminders) ===== */
  /* List item riêng: [icon] [nhãn+ngày] [giờ] [switch] [xoá] — 5 cột. Tái dùng .item-* + .switch. */
  .list-item.rmd { grid-template-columns: 40px 1fr auto auto auto; gap: 12px; }
  .list-item.rmd .item-date { font-size: 22px; text-align: center; }
  .list-item.rmd .rmd-time { font-family: var(--mono); font-size: 16px; color: var(--ink); }
  .list-item.rmd.rmd-off { opacity: 0.5; }            /* đã tắt nhưng vẫn trong list, làm mờ */
  /* Hàng chip + nhãn mono + gợi ý cho form tạo. Tái dùng .meal-chip/.meal-chip-row. */
  .rmd-field { margin: 10px 0; }
  .rmd-field-label { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.15em; color: var(--muted); margin-bottom: 6px; }
  .rmd-hint { font-size: 12px; color: var(--muted-2); margin-top: 6px; }
  /* Ô nhập giờ trong pill quick-log: không viền riêng, font mono cho số. */
  .quick-log input[type="time"].form-input { flex: 0 0 auto; width: auto; font-family: var(--mono); }

  .empty { text-align: center; padding: 48px 20px; color: var(--muted); }
  .empty-mark { font-family: var(--display); font-size: 48px; font-style: italic; font-weight: 300; color: var(--line-2); margin-bottom: 8px; }
  .empty-text { font-size: 14px; }

  /* ===== Workout history: quick-log, sessions, metrics ===== */
  /* quick-log = pill liền khối, đồng bộ với .expense-input-wrap (tab Chi tiêu) */
  .quick-log { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; background: var(--bg); border: 1.5px solid var(--ink); border-radius: 14px; padding: 4px 4px 4px 16px; transition: all 0.15s; }
  .quick-log:focus-within { box-shadow: 0 0 0 3px rgba(10,10,10,0.08); }
  .quick-log .form-input { flex: 1; border: none; border-radius: 0; background: transparent; padding: 12px 0; min-width: 0; }
  .quick-log .form-input:focus { border: none; }
  .quick-log-go { width: 44px; height: 44px; padding: 0; flex-shrink: 0; border-radius: 10px; border: none; background: var(--ink); color: var(--bg); display: flex; align-items: center; justify-content: center; font-size: 18px; transition: transform 0.1s; }
  .quick-log-go:active { transform: scale(0.92); }
  .quick-log-go:disabled { background: var(--muted-2); cursor: not-allowed; }
  .quick-log-ai { width: 36px; height: 36px; flex-shrink: 0; border-radius: 10px; border: 1px solid var(--line); background: var(--bg-2); display: flex; align-items: center; justify-content: center; font-size: 16px; transition: all 0.15s; }
  .quick-log-ai:hover:not(:disabled) { border-color: var(--ink); background: var(--ink); color: var(--bg); }
  .quick-log-ai:disabled { opacity: 0.5; cursor: not-allowed; }
  .quick-log-ai.loading { animation: spin 1s linear infinite; }
  .quick-log-preview { font-size: 13px; padding: 8px 12px; border-radius: 8px; margin-bottom: 18px; background: var(--bg-2); color: var(--ink-2); }
  .quick-log-preview.ok { background: #eaf3ec; color: var(--success); }
  .quick-log-preview.dim { color: var(--muted); }
  .quick-log-preview .qp-check { font-weight: 700; }
  .quick-log-preview .qp-q { color: var(--muted-2); }
  .quick-log-preview .qp-note { color: var(--muted-2); font-size: 11px; }

  .last-hint { font-family: var(--mono); font-size: 11px; color: var(--success); margin-top: 6px; }
  .btn-secondary { background: var(--bg-2); color: var(--ink); border: 1px solid var(--line-2); }
  .btn-secondary:hover { border-color: var(--ink); }

  /* Thẻ buổi tập theo ngày (feed Strong/Hevy) — mỗi ngày là 1 card riêng */
  .wk-card { border: 1px solid var(--line); border-radius: 14px; background: var(--bg); margin-bottom: 14px; overflow: hidden; }
  .wk-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 13px 16px; background: var(--bg-2); border-bottom: 1px solid var(--line); }
  .wkc-day { display: flex; align-items: baseline; gap: 8px; }
  .wkc-weekday { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.14em; color: var(--muted); }
  .wkc-date { font-family: var(--display); font-size: 19px; font-weight: 400; color: var(--ink); letter-spacing: -0.01em; }
  .wkc-chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
  .wkc-chip { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.02em; color: var(--ink-2); background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; }
  .wk-card-body { padding: 4px 14px 10px; }
  .wk-card-body > .list-item:last-child,
  .wk-card-body > .strength-session:last-child .list-item:last-child { border-bottom: none; }

  /* Khối "buổi tạ" gom nhiều bài strength cùng ngày */
  .strength-session { border-left: 2px solid var(--line-2); padding-left: 12px; margin: 6px 0 4px; }
  .ss-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-2); padding: 8px 0 2px; }
  .ss-meta { font-size: 10px; letter-spacing: 0.04em; color: var(--muted); text-transform: none; }
  .strength-session .list-item.wk { padding-top: 10px; padding-bottom: 10px; }
  .strength-session.named { border-left-color: var(--ink); }
  .ss-name { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink); border-bottom: 1px dotted var(--line-2); padding: 0 0 1px; }
  .ss-name:hover { border-bottom-color: var(--ink); }

  /* Buổi đang ghi (gán khi ghi) */
  .session-current { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; font-family: var(--mono); font-size: 11px; }
  .sc-label { text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); }
  .sc-name { font-family: var(--mono); font-size: 11px; color: var(--ink); border: 1px solid var(--line-2); border-radius: 999px; padding: 5px 12px; transition: all 0.15s; }
  .sc-name.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
  .sc-name:hover { border-color: var(--ink); }
  .sc-clear { color: var(--muted); font-size: 16px; padding: 2px 6px; }
  .sc-clear:hover { color: var(--danger); }

  /* Chip tên gần đây trong picker */
  .sp-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 6px; }
  .sp-chip { font-family: var(--mono); font-size: 11px; color: var(--ink-2); background: var(--bg-2); border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px; transition: all 0.15s; }
  .sp-chip:hover { border-color: var(--ink); background: var(--bg); }

  /* Chế độ chọn nhiều */
  .list.selecting .list-item.wk { grid-template-columns: 26px 1fr auto auto; cursor: pointer; }
  .list.selecting .list-item.wk .item-del { display: none; }
  .list.selecting .ex-guide-inline { pointer-events: none; border-bottom: none; }
  .list-item.wk.selected { background: var(--bg-2); }
  .wk-check { width: 20px; height: 20px; border: 1.5px solid var(--line-2); border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 13px; color: var(--bg); }
  .list-item.wk.selected .wk-check { background: var(--ink); border-color: var(--ink); }

  /* Thanh hành động khi chọn */
  .select-bar { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); width: calc(100% - 40px); max-width: 680px; background: var(--ink); color: var(--bg); border-radius: 12px; padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; z-index: 200; box-shadow: 0 6px 24px rgba(10,20,40,0.25); }
  .select-bar span { font-family: var(--mono); font-size: 12px; letter-spacing: 0.04em; }
  .select-bar-actions { display: flex; gap: 8px; }
  .select-bar .btn { padding: 9px 14px; }
  .select-bar .btn-ghost { color: var(--muted-2); }
  .select-bar .btn-primary { background: var(--bg); color: var(--ink); }
  .select-bar .btn-primary:disabled { opacity: 0.5; }
  .select-bar .btn-secondary { background: transparent; color: var(--bg); border: 1px solid var(--on-ink-line); }
  .select-bar .btn-secondary:disabled { opacity: 0.45; }
  .select-date { font-family: var(--mono); font-size: 12px; color: var(--bg); background: rgba(255,255,255,0.10); border: 1px solid var(--on-ink-line); border-radius: 8px; padding: 8px 10px; color-scheme: dark; }

  /* Workout item variant (no date column) */
  .list-item.wk { grid-template-columns: 1fr auto auto; }
  .list-item.wk[data-edit-w] { cursor: pointer; }
  .list-item.wk.is-pr { background: linear-gradient(90deg, #fdf6e3 0%, transparent 65%); }
  .item-metrics { font-family: var(--mono); font-size: 10.5px; color: var(--muted); margin-top: 3px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
  .pr-badge { font-family: var(--mono); font-size: 9px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: #8a6d1a; background: #f6e8be; border-radius: 5px; padding: 2px 6px; margin-left: 8px; vertical-align: middle; }
  .delta { font-family: var(--mono); font-size: 10px; padding: 1px 6px; border-radius: 5px; }
  .delta.up { color: var(--success); background: #e7f1ea; }
  .delta.down { color: var(--danger); background: #f5e8e8; }
  .delta.flat { color: var(--muted-2); background: var(--bg-2); }

  /* Per-set detail + notes (dùng chung renderWorkoutItem) */
  .item-sets-detail { margin-top: 5px; display: flex; flex-direction: column; gap: 2px; }
  .set-line { font-family: var(--mono); font-size: 10.5px; color: var(--muted); }
  .set-tag { color: var(--muted-2); margin-right: 2px; }
  .item-notes { font-size: 12px; color: var(--muted); margin-top: 4px; font-style: italic; }
  .bw-tag { font-family: var(--mono); font-size: 13px; color: var(--muted); }

  /* ===== Exercise guide ===== */
  .ex-guide-inline { font-family: var(--display); font-size: 17px; font-weight: 500; color: var(--ink); border-bottom: 1px dotted var(--line-2); padding: 0; }
  .ex-guide-inline:hover { border-bottom-color: var(--ink); }
  .ex-guide-link { display: inline-block; margin-top: 8px; font-family: var(--mono); font-size: 11px; letter-spacing: 0.05em; color: var(--ink); border: 1px solid var(--line-2); border-radius: 999px; padding: 6px 12px; transition: all 0.15s; }
  .ex-guide-link:hover { border-color: var(--ink); background: var(--bg-2); }

  .guide-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
  .guide-head .modal-title { margin-bottom: 0; }
  .guide-loading { color: var(--muted); font-style: italic; padding: 24px 0; text-align: center; }
  .guide-media { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin-bottom: 12px; }
  .guide-frame { width: 100%; display: block; aspect-ratio: 4/3; object-fit: cover; background: var(--bg-2); }
  .guide-frame-hint { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); text-align: center; padding: 6px; border-top: 1px solid var(--line); }
  .guide-media-empty { padding: 18px; font-size: 13px; color: var(--muted); text-align: center; }
  .guide-video { display: block; text-align: center; background: var(--ink); color: var(--bg); border-radius: 8px; padding: 12px; font-family: var(--mono); font-size: 12px; letter-spacing: 0.04em; text-decoration: none; margin-bottom: 18px; }
  .guide-video:hover { background: var(--ink-2); }

  .guide-muscles { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; font-size: 13px; }
  .guide-ml { font-family: var(--mono); font-size: 9px; text-transform: uppercase; letter-spacing: 0.14em; color: var(--muted); margin-right: 6px; }
  .m-tag { display: inline-block; font-size: 12px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; margin: 2px 2px 0 0; }
  .m-tag.prim { background: var(--ink); color: var(--bg); border-color: var(--ink); }
  .guide-eq { font-size: 12px; color: var(--ink-2); text-transform: capitalize; }

  .guide-section { margin-bottom: 18px; }
  .guide-h { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.14em; color: var(--muted); margin-bottom: 8px; }
  .guide-en { font-family: var(--mono); font-size: 10px; color: var(--muted-2); }
  .guide-steps { margin: 0; padding-left: 20px; font-size: 13.5px; line-height: 1.6; color: var(--ink-2); }
  .guide-steps li { margin-bottom: 6px; }
  .guide-tips-wrap { margin-top: 10px; }
  .guide-tips { margin: 6px 0 14px; padding-left: 18px; font-size: 13.5px; line-height: 1.55; }
  .guide-tips li { margin-bottom: 5px; }
  .guide-tips.ok li { color: var(--success); }
  .guide-tips.bad li { color: var(--danger); }

  /* Cardio photo capture */
  .cardio-cam-btn { width: 100%; margin-bottom: 18px; padding: 11px; border: 1px dashed var(--line-2); border-radius: 8px; font-family: var(--mono); font-size: 12px; letter-spacing: 0.03em; color: var(--ink-2); background: var(--bg); transition: all 0.15s; }
  .cardio-cam-btn:hover { border-color: var(--ink); background: var(--bg-2); }
  .cc-photo { width: 100%; max-height: 200px; object-fit: contain; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; }
  .cc-raw { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-bottom: 16px; }

  /* Đơn vị tạ (kg / lb / mức) */
  .weight-unit-row { display: flex; gap: 6px; }
  .weight-unit-row .form-input { flex: 1; min-width: 0; }
  .weight-unit-row .form-select { width: 76px; flex: none; padding-left: 8px; padding-right: 4px; }
  /* Tự trọng (BW) — user tự chọn qua checkbox cạnh nhãn "Mức tạ" */
  .bw-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
  .bw-check { display: inline-flex; align-items: center; gap: 5px; font-family: var(--mono); font-size: 10px; text-transform: none; letter-spacing: 0.02em; color: var(--muted); cursor: pointer; }
  .bw-check input { vertical-align: middle; }
  .bw-note { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); border: 1px dashed var(--line-2); border-radius: 8px; padding: 11px 12px; }
  #formWorkout.bw-mode .set-kg { display: none; }

  /* Charts */
  .chart-wrap { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 20px; margin-bottom: 20px; }
  .chart-title { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.18em; color: var(--muted); margin-bottom: 16px; }
  .chart-toggle { display: flex; gap: 4px; margin-bottom: 16px; }
  .chart-toggle button { padding: 6px 12px; font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.15em; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; }
  .chart-toggle button.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
  .chart-svg { width: 100%; height: 200px; display: block; }

  /* Toast */
  .toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--bg); padding: 12px 20px; border-radius: 999px; font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.15em; opacity: 0; transition: all 0.3s; z-index: 200; pointer-events: none; }
  .toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

  /* Banner nhắc cập nhật — pill navy như toast nhưng tĩnh + bấm được */
  .update-banner { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); display: none; align-items: center; gap: 12px; background: var(--ink); color: var(--bg); padding: 8px 8px 8px 18px; border-radius: 999px; box-shadow: 0 8px 24px rgba(14,42,78,0.28); opacity: 0; transition: opacity 0.3s, transform 0.3s; z-index: 210; }
  .update-banner.show { display: flex; opacity: 1; transform: translateX(-50%) translateY(0); }
  .update-banner-text { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.15em; }
  .update-banner-btn { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; background: var(--bg); color: var(--ink); padding: 8px 16px; border-radius: 999px; font-weight: 600; }
  .update-banner-btn:disabled { opacity: 0.6; }

  /* Loading */
  .loading { position: fixed; inset: 0; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 50; transition: opacity 0.3s; }
  .loading.hidden { opacity: 0; pointer-events: none; }
  .loading-mark { font-family: var(--display); font-style: italic; font-size: 48px; font-weight: 300; }
  .loading-dot { display: inline-block; animation: blink 1.2s infinite; }
  @keyframes blink { 0%, 50%, 100% { opacity: 1; } 25%, 75% { opacity: 0.2; } }

  /* Footer */
  .footer { margin-top: 48px; padding: 20px 0; text-align: center; border-top: 1px solid var(--line); }
  .footer button { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.15em; color: var(--muted); margin: 0 8px; }
  .footer button:hover { color: var(--ink); }

  /* Toggle switch (bật/tắt mượt) — dùng cho nhắc nhở tối. Chỉ token, không hex. */
  .switch { width: 38px; height: 22px; border-radius: 999px; background: var(--line-2); position: relative; cursor: pointer; transition: background 0.18s; flex: none; vertical-align: middle; }
  .switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--bg); transition: transform 0.18s; box-shadow: 0 1px 3px rgba(14,42,78,0.25); }
  .switch.on { background: var(--success); }
  .switch.on::after { transform: translateX(16px); }
  .switch:disabled { opacity: 0.45; cursor: not-allowed; }
  /* Cụm nhãn + switch đặt trong footer (khu Công cụ). */
  .footer-toggle { display: inline-flex; align-items: center; gap: 8px; margin: 0 8px; font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.15em; color: var(--muted); }
  .footer-toggle.on { color: var(--success); }
  /* Nhãn tên Spotify đã kết nối trong footer (giữ nguyên hoa/thường của tên, không viết hoa). */
  .footer-spotify { font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em; color: var(--muted); margin: 0 8px; }

  /* Modal */
  .modal-overlay { position: fixed; inset: 0; background: rgba(10,10,10,0.4); backdrop-filter: blur(8px); display: none; align-items: center; justify-content: center; z-index: 200; padding: 20px; animation: fadeIn 0.2s; }
  .modal-overlay.open { display: flex; }
  .modal { background: var(--bg); border-radius: 16px; max-width: 480px; width: 100%; max-height: 90vh; overflow: auto; padding: 28px; }
  .modal-title { font-family: var(--display); font-size: 24px; font-weight: 400; margin-bottom: 6px; letter-spacing: -0.02em; }
  .modal-sub { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.18em; color: var(--muted); margin-bottom: 20px; }

  /* Sync indicator */
  .sync-indicator {
    display: inline-flex; align-items: center; gap: 6px;
    font-family: var(--mono); font-size: 9px; text-transform: uppercase; letter-spacing: 0.15em;
    padding: 4px 9px; border-radius: 999px; background: var(--bg-2); color: var(--muted);
    border: 1px solid var(--line); white-space: nowrap;
    transition: all 0.2s;
  }
  .sync-indicator.online { color: var(--success); }
  .sync-indicator.offline { background: #fff4e6; color: #b35900; border-color: #ffd9a8; }
  .sync-indicator.syncing { color: var(--ink); }
  .sync-indicator.pending { background: #fff4e6; color: #b35900; border-color: #ffd9a8; }
  .sync-dot {
    width: 6px; height: 6px; border-radius: 50%; background: currentColor;
  }
  .sync-indicator.syncing .sync-dot { animation: pulse 1.2s infinite; }
  .sync-indicator.offline .sync-dot { background: #b35900; }
  @keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
  }
  
  /* Stats groups (in Thống kê tab) */
  .stats-group { margin-bottom: 32px; }
  .stats-group-title { 
    font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.18em;
    color: var(--muted); margin-bottom: 12px; padding: 0 4px; font-weight: 500;
  }
  .stats-row {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px;
    background: var(--line); border: 1px solid var(--line); border-radius: 12px;
    overflow: hidden; margin-bottom: 16px;
  }
  .stats-row.cols-3 { grid-template-columns: repeat(3, 1fr); }
  .stats-row .mini-stat { background: var(--bg); padding: 14px 14px; }
  .stats-row .mini-stat-label { 
    font-family: var(--mono); font-size: 9px; text-transform: uppercase; letter-spacing: 0.18em;
    color: var(--muted); margin-bottom: 6px;
  }
  .stats-row .mini-stat-value {
    font-family: var(--display); font-size: 22px; font-weight: 500; line-height: 1;
    letter-spacing: -0.01em;
  }
  .stats-row .mini-stat-value small {
    font-family: var(--mono); font-size: 11px; color: var(--muted); margin-left: 3px; font-weight: 400;
  }
  .stats-row .mini-stat-meta {
    font-family: var(--mono); font-size: 9px; color: var(--muted); margin-top: 4px;
  }

  /* ============ Vocab (Từ vựng SRS) ============ */
  .vocab-card { border: 1px solid var(--line); border-radius: 12px; padding: 28px 22px; background: var(--bg); margin-bottom: 16px; text-align: center; }
  .vc-word { font-family: var(--display); font-size: clamp(32px, 9vw, 44px); color: var(--ink); letter-spacing: -0.02em; }
  .vc-meaning { font-family: var(--body); font-size: 18px; color: var(--ink); margin-top: 12px; }
  .vc-example { font-family: var(--body); font-style: italic; color: var(--muted); margin-top: 8px; }
  .vc-ipa { font-family: var(--mono); font-size: 13px; color: var(--muted); margin-top: 6px; }

  /* Confetti for completion */
  .celebrate { position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%); background: var(--ink); color: var(--bg); padding: 32px 48px; border-radius: 16px; font-family: var(--display); font-style: italic; font-size: 28px; z-index: 300; animation: pop 1.8s; pointer-events: none; }
  @keyframes pop { 0% { transform: translate(-50%,-50%) scale(0.5); opacity: 0; } 15% { transform: translate(-50%,-50%) scale(1.05); opacity: 1; } 25% { transform: translate(-50%,-50%) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; } }

  /* ============ Journal section ============ */
  .journal-quick-mood {
    background: var(--bg); border: 1px solid var(--line); border-radius: 14px;
    padding: 18px 20px; margin-bottom: 20px;
  }
  .journal-mood-label {
    font-family: var(--display); font-size: 16px; font-weight: 400;
    color: var(--ink); margin-bottom: 12px;
  }
  .journal-mood-row {
    display: flex; gap: 8px; justify-content: space-between;
  }
  .mood-chip {
    flex: 1; aspect-ratio: 1; max-width: 58px;
    border: 1.5px solid var(--line-2); border-radius: 14px;
    background: var(--bg); font-size: 26px; line-height: 1;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.12s; cursor: pointer;
  }
  .mood-chip:active { transform: scale(0.92); }
  .mood-chip.selected { 
    background: var(--ink); border-color: var(--ink); 
    transform: scale(1.05); box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  }
  .mood-row-modal { display: flex; gap: 8px; justify-content: space-between; }
  .mood-row-modal .mood-chip { font-size: 24px; }
  
  .journal-textarea {
    resize: vertical; min-height: 120px;
    font-family: var(--body); line-height: 1.55;
  }
  
  .journal-item {
    background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
    padding: 16px 18px; margin-bottom: 10px; cursor: pointer;
    transition: all 0.1s;
  }
  .journal-item:hover { border-color: var(--ink-2); transform: translateY(-1px); }
  .journal-item-head {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 8px;
  }
  .journal-item-time {
    font-family: var(--mono); font-size: 10px; text-transform: uppercase;
    letter-spacing: 0.15em; color: var(--muted);
  }
  .journal-item-mood { font-size: 22px; line-height: 1; }
  .journal-item-content {
    font-size: 14px; color: var(--ink-2); line-height: 1.55;
    white-space: pre-wrap; word-break: break-word;
  }
  .journal-item-content.empty { 
    font-style: italic; color: var(--muted-2); 
  }
  .journal-day-divider {
    font-family: var(--mono); font-size: 10px; text-transform: uppercase;
    letter-spacing: 0.18em; color: var(--muted);
    padding: 16px 4px 8px; margin-top: 8px;
  }

  /* ============ Meals tab ============ */
  .meal-chip-row {
    display: flex; flex-wrap: wrap; gap: 8px;
  }
  .meal-chip {
    flex: 1 1 auto; min-width: 0;
    padding: 10px 14px; border: 1.5px solid var(--line-2); border-radius: 999px;
    background: var(--bg); font-family: var(--body); font-size: 13px;
    color: var(--ink-2); line-height: 1.2;
    display: inline-flex; align-items: center; justify-content: center; gap: 4px;
    transition: all 0.12s; cursor: pointer; white-space: nowrap;
  }
  .meal-chip:active { transform: scale(0.96); }
  .meal-chip.selected {
    background: var(--ink); border-color: var(--ink); color: var(--bg);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  }
  .meal-item-badges {
    display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px;
  }
  .meal-badge {
    font-family: var(--body); font-size: 11px;
    padding: 3px 9px; border-radius: 999px;
    background: var(--line); color: var(--ink-2);
    display: inline-flex; align-items: center; gap: 3px;
    line-height: 1.4;
  }
  .meal-item-notes {
    font-family: var(--body); font-size: 12px; color: var(--muted);
    margin-top: 6px; font-style: italic;
  }

  /* ============ Meal/work shared hint ============ */
  .work-hint {
    font-family: var(--mono); font-size: 10px;
    text-transform: uppercase; letter-spacing: 0.15em;
    color: var(--muted-2); margin-bottom: 24px; padding: 0 4px;
    line-height: 1.5;
  }

  /* ============ Quick-add screen ============ */
  .quick-screen { 
    position: fixed; inset: 0; 
    background: var(--bg); 
    z-index: 90;
    display: none; flex-direction: column;
    padding: env(safe-area-inset-top, 20px) 20px env(safe-area-inset-bottom, 20px);
  }
  .quick-screen.active { display: flex; }
  .quick-top { 
    display: flex; justify-content: space-between; align-items: center; 
    padding: 8px 0 16px;
  }
  .quick-brand { 
    font-family: var(--display); font-style: italic; font-weight: 300; 
    font-size: 22px; letter-spacing: -0.02em;
  }
  .quick-brand small { font-family: var(--mono); font-size: 9px; text-transform: uppercase; letter-spacing: 0.18em; color: var(--muted); display:block; margin-top:2px; font-weight:400; }
  .quick-fullbtn { 
    font-family: var(--mono); font-size: 10px; text-transform: uppercase; 
    letter-spacing: 0.15em; color: var(--muted);
    padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px;
  }
  .quick-fullbtn:active { background: var(--bg-2); }
  
  .quick-time {
    font-family: var(--display); font-size: 56px; font-weight: 300; font-style: italic;
    line-height: 1; letter-spacing: -0.04em; color: var(--ink);
    margin: 24px 0 4px;
  }
  .quick-date {
    font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.2em;
    color: var(--muted); margin-bottom: 32px;
  }
  
  .quick-input-wrap {
    background: var(--bg); border: 2px solid var(--ink); border-radius: 16px;
    padding: 6px 6px 6px 18px; display: flex; align-items: center; gap: 6px;
    margin-bottom: 12px; box-shadow: 0 4px 12px rgba(0,0,0,0.04);
  }
  .quick-input {
    flex: 1; border: none; outline: none; background: transparent;
    padding: 16px 0; font-size: 17px; font-family: var(--body); color: var(--ink); min-width: 0;
    -webkit-appearance: none;
  }
  .quick-input::placeholder { color: var(--muted-2); }
  .quick-aibtn { 
    background: var(--bg-2); border: 1px solid var(--line); 
    width: 42px; height: 42px; border-radius: 12px; 
    display: flex; align-items: center; justify-content: center; 
    flex-shrink: 0; font-size: 18px;
  }
  .quick-aibtn:active { background: var(--ink); color: var(--bg); }
  .quick-aibtn.loading { animation: spin 0.8s linear infinite; }
  .quick-gobtn { 
    background: var(--ink); color: var(--bg); border: none; 
    width: 52px; height: 52px; border-radius: 12px; 
    display: flex; align-items: center; justify-content: center; 
    flex-shrink: 0; font-size: 22px; font-weight: 600;
  }
  .quick-gobtn:active { transform: scale(0.93); }
  .quick-gobtn:disabled { background: var(--muted-2); }
  
  .quick-hint { 
    font-family: var(--mono); font-size: 10px; text-transform: uppercase; 
    letter-spacing: 0.15em; color: var(--muted-2); padding: 0 4px; margin-bottom: 24px;
  }
  
  .quick-suggestions { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 24px; }
  .quick-chip {
    padding: 8px 12px; font-size: 12px;
    border: 1px solid var(--line); border-radius: 999px;
    background: var(--bg); color: var(--ink-2);
    transition: all 0.1s;
  }
  .quick-chip:active { background: var(--ink); color: var(--bg); border-color: var(--ink); transform: scale(0.97); }
  
  .quick-recent-title {
    font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.18em;
    color: var(--muted); margin-bottom: 8px; padding: 0 4px;
  }
  .quick-recent { flex: 1; overflow-y: auto; min-height: 0; }
  .quick-recent-item {
    display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center;
    padding: 12px 8px; border-bottom: 1px solid var(--line);
    cursor: pointer;
  }
  .quick-recent-item:active { background: var(--bg-2); }
  .quick-recent-time { font-family: var(--mono); font-size: 11px; color: var(--muted); }
  .quick-recent-desc { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .quick-recent-amt { font-family: var(--display); font-size: 16px; font-weight: 500; white-space: nowrap; }
  .quick-recent-amt.income { color: var(--success); }
  .quick-recent-amt.expense { color: var(--danger); }
  
  .quick-justsaved {
    position: fixed; bottom: calc(env(safe-area-inset-bottom, 20px) + 20px); left: 50%; 
    transform: translateX(-50%) translateY(80px);
    background: var(--success); color: white;
    padding: 14px 22px; border-radius: 999px;
    font-family: var(--mono); font-size: 12px; text-transform: uppercase; letter-spacing: 0.12em;
    box-shadow: 0 8px 24px rgba(31,95,58,0.3);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 95; pointer-events: none;
    display: flex; align-items: center; gap: 8px; max-width: 90%;
  }
  .quick-justsaved.show { transform: translateX(-50%) translateY(0); }
  .quick-justsaved .check { 
    width: 20px; height: 20px; border-radius: 50%; background: white; color: var(--success);
    display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700;
  }
  
  /* PWA install hint */
  .install-hint {
    background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px;
    padding: 14px 16px; margin-bottom: 16px; font-size: 12px; color: var(--ink-2);
    display: flex; gap: 12px; align-items: flex-start;
  }
  .install-hint-close { 
    background: none; border: none; font-size: 18px; color: var(--muted); 
    padding: 0 4px; cursor: pointer; line-height: 1;
  }
  .install-hint strong { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.15em; display: block; margin-bottom: 4px; }
  
  /* ============ Expense section ============ */
  .expense-input-wrap { background: var(--bg); border: 1.5px solid var(--ink); border-radius: 14px; padding: 4px 4px 4px 16px; display: flex; align-items: center; gap: 6px; margin-bottom: 8px; transition: all 0.15s; }
  .expense-input-wrap:focus-within { box-shadow: 0 0 0 3px rgba(10,10,10,0.08); }
  .expense-input { flex: 1; border: none; outline: none; background: transparent; padding: 12px 0; font-size: 15px; font-family: var(--body); color: var(--ink); min-width: 0; }
  .expense-input::placeholder { color: var(--muted-2); }
  .expense-btn-ai { background: var(--bg-2); border: 1px solid var(--line); width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: all 0.15s; font-size: 16px; }
  .expense-btn-ai:hover { background: var(--ink); color: var(--bg); border-color: var(--ink); }
  .expense-btn-ai:disabled { opacity: 0.5; cursor: not-allowed; }
  .expense-btn-ai.loading { animation: spin 1s linear infinite; }
  @keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
  .expense-btn-go { background: var(--ink); color: var(--bg); border: none; width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 18px; transition: transform 0.1s; }
  .expense-btn-go:active { transform: scale(0.92); }
  .expense-btn-go:disabled { background: var(--muted-2); cursor: not-allowed; }

  /* Dòng preview parse dưới ô nhập: gợi ý ngày đã quy đổi + nội dung trước khi lưu */
  .input-preview { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: -2px 4px 12px; font-family: var(--mono); font-size: 11px; color: var(--muted); line-height: 1.4; animation: previewIn 0.15s ease; }
  .input-preview[hidden] { display: none; }
  .input-preview .pv-date { color: var(--ink); }
  .input-preview .pv-sep { color: var(--line-2); }
  .input-preview .pv-money { margin-left: auto; font-weight: 600; }
  .input-preview .pv-money.income { color: var(--success); }
  .input-preview .pv-money.expense { color: var(--ink); }
  @keyframes previewIn { from { opacity: 0; transform: translateY(-2px); } to { opacity: 1; transform: none; } }
  .expense-hint { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.15em; color: var(--muted-2); margin-bottom: 24px; padding: 0 4px; }

  .expense-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin-bottom: 24px; }
  .expense-stat { background: var(--bg); padding: 14px 12px; }
  .expense-stat-label { font-family: var(--mono); font-size: 9px; text-transform: uppercase; letter-spacing: 0.15em; color: var(--muted); margin-bottom: 4px; }
  .expense-stat-value { font-family: var(--display); font-size: 20px; font-weight: 500; line-height: 1.1; letter-spacing: -0.01em; }
  .expense-stat-value.income { color: var(--success); }
  .expense-stat-value.expense { color: var(--danger); }
  .expense-stat-sub { font-family: var(--mono); font-size: 9px; color: var(--muted-2); margin-top: 3px; }

  /* Thanh tiến độ ngân sách (tổng + từng nhóm + quỹ). Màu theo trạng thái dùng:
     ok (--success) · warn (--warn) · over (--danger) · none (chưa đặt hạn mức). */
  .budget-bar { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; margin: 8px 0; }
  .budget-bar-fill { height: 100%; border-radius: 999px; transition: width .3s ease; }
  .budget-bar-fill.ok   { background: var(--success); }
  .budget-bar-fill.warn { background: var(--warn); }
  .budget-bar-fill.over { background: var(--danger); }
  .budget-bar-fill.none { background: var(--line-2); }

  /* Khu Ngân sách (#budgetSection) — tái dùng token + class chung, chỉ canh khoảng cách. */
  .budget-total { font-family: var(--display); font-size: 20px; font-weight: 500; line-height: 1.2; letter-spacing: -0.01em; }
  .budget-total.over { color: var(--danger); }
  .budget-pct { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.15em; color: var(--muted); }
  .budget-group { padding: 10px 0; border-bottom: 1px solid var(--line); }
  .budget-group-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
  .budget-group-name { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--ink); }
  .budget-group-detail { font-family: var(--body); font-size: 13px; color: var(--muted); }
  .budget-group-detail .over { color: var(--danger); }
  .budget-fund { padding: 14px 0 4px; }
  .budget-hint { font-family: var(--mono); font-size: 10px; color: var(--muted-2); margin-top: 2px; }

  /* Period filter dùng chung (Tập luyện/Nhật ký/Ăn uống/Cân nặng). Cùng look với
     expense/music toggle. Cuộn ngang được nếu hẹp. */
  .period-toggle { display: flex; gap: 4px; margin-bottom: 16px; flex-wrap: wrap; }
  .period-toggle button { padding: 6px 12px; font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.15em; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; }
  .period-toggle button.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }

  .expense-period-toggle { display: flex; gap: 4px; margin-bottom: 16px; }
  .expense-period-toggle button { padding: 6px 12px; font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.15em; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; }
  .expense-period-toggle button.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }

  .expense-day-group { margin-bottom: 24px; }
  .expense-day-head { display: flex; justify-content: space-between; align-items: baseline; padding: 8px 4px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
  .expense-day-date { font-family: var(--display); font-size: 16px; font-weight: 500; }
  .expense-day-date small { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.15em; color: var(--muted); margin-left: 8px; font-weight: 400; }
  .expense-day-totals { font-family: var(--mono); font-size: 11px; color: var(--muted); }
  .expense-day-totals .income { color: var(--success); }
  .expense-day-totals .expense { color: var(--danger); }

  .expense-item { display: grid; grid-template-columns: 50px 1fr auto; gap: 12px; align-items: center; padding: 10px 6px; border-bottom: 1px solid var(--line); cursor: pointer; transition: background 0.1s; }
  .expense-item:hover { background: var(--bg-2); }
  .expense-time { font-family: var(--mono); font-size: 11px; color: var(--muted); }
  .expense-desc { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
  .expense-desc-text { font-size: 15px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .meal-desc { font-weight: 600; color: var(--ink); }
  .expense-cat { font-family: var(--mono); font-size: 9px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); }
  .expense-cat::before { content: '· '; }
  .expense-amount { font-family: var(--display); font-size: 17px; font-weight: 500; text-align: right; white-space: nowrap; }
  .expense-amount.income { color: var(--success); }
  .expense-amount.expense { color: var(--danger); }
  .expense-amount small { font-family: var(--mono); font-size: 9px; font-weight: 400; color: var(--muted); margin-left: 3px; }

  /* Edit modal — reuse upload modal styles */
  .expense-type-toggle { display: flex; gap: 6px; margin-bottom: 14px; }
  .expense-type-btn { flex: 1; padding: 10px; border: 1px solid var(--line); border-radius: 10px; font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.15em; color: var(--muted); transition: all 0.15s; }
  .expense-type-btn.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
  .expense-type-btn[data-type="income"].active { background: var(--success); border-color: var(--success); }
  .expense-type-btn[data-type="expense"].active { background: var(--danger); border-color: var(--danger); }

  @media (max-width: 480px) {
    .stat-value { font-size: 30px; }
    .brand { font-size: 26px; }
    .list-item { grid-template-columns: 44px 1fr auto auto; gap: 10px; }
    .item-date strong { font-size: 19px; }
    .item-type { font-size: 15px; }
    .item-value { font-size: 16px; }
    /* Thanh chọn nhiều: count 1 hàng, ô ngày + nút xuống hàng dưới, cho wrap */
    .select-bar { flex-wrap: wrap; row-gap: 10px; }
    .select-bar-actions { flex: 1 1 100%; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
    .select-date { flex: 1 1 100%; }
    .select-bar .btn { flex: 1 1 auto; padding: 9px 10px; }
  }

/* ---- Khu "Chờ duyệt" (giao dịch tự động từ ngân hàng) ---- */
.review-box { border: 1px solid var(--line); border-radius: 10px; background: #fffdf7; margin: 10px 0 14px; overflow: hidden; }
.review-head { font-size: 12px; font-weight: 600; padding: 8px 12px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
.review-count { background: var(--ink); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 8px; }
.review-item { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.review-item:last-child { border-bottom: none; }
.review-item.dup { background: #fff8e6; }
.review-main { min-width: 0; cursor: pointer; }
.review-desc { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.review-dup { color: #92740a; font-weight: 600; font-size: 11px; }
.review-meta { font-size: 11px; color: var(--muted); margin-top: 1px; }
.review-amt { font-size: 13px; font-weight: 600; white-space: nowrap; }
.review-amt.expense { color: var(--danger); }
.review-amt.income { color: var(--success); }
.review-amt small { font-size: 9px; margin-left: 1px; opacity: .7; }
.review-actions { display: flex; gap: 6px; }
.review-ok, .review-no { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line); background: #fff; font-size: 14px; cursor: pointer; line-height: 1; }
.review-ok { color: var(--success); border-color: var(--success); }
.review-no { color: var(--danger); border-color: var(--danger); }

  /* ====== Tab Trợ lý: khung chat ====== */
  /* Vùng cuộn hội thoại — bong bóng user (navy) phải, assistant (nền phụ) trái. */
  .chat { display: flex; flex-direction: column; gap: 10px; min-height: 200px; max-height: 56vh; overflow-y: auto; padding: 4px 2px 8px; margin-bottom: 8px; }
  .chat-msg { max-width: 82%; padding: 11px 14px; border-radius: 14px; font-size: 14px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; animation: fadeIn 0.2s; }
  .chat-msg.user { align-self: flex-end; background: var(--ink); color: var(--bg); border-bottom-right-radius: 4px; }
  .chat-msg.assistant { align-self: flex-start; background: var(--bg-2); border: 1px solid var(--line); color: var(--ink); border-bottom-left-radius: 4px; }

  /* Đang trả lời: nhãn + 3 chấm nhấp nháy */
  .chat-typing { display: flex; align-items: center; gap: 8px; color: var(--muted); }
  .chat-typing-label { font-style: italic; }
  .chat-dots { display: inline-flex; gap: 4px; }
  .chat-dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--muted-2); animation: chatDot 1.2s infinite ease-in-out; }
  .chat-dots span:nth-child(2) { animation-delay: 0.2s; }
  .chat-dots span:nth-child(3) { animation-delay: 0.4s; }
  @keyframes chatDot { 0%, 60%, 100% { opacity: 0.3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

  /* Dòng lỗi + nút Thử lại */
  .chat-error { align-self: flex-start; max-width: 82%; display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 14px; border: 1px solid var(--danger); background: var(--bg-2); color: var(--danger); font-size: 13px; }
  .chat-retry { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--danger); border: 1px solid var(--danger); border-radius: 999px; padding: 5px 12px; white-space: nowrap; transition: all 0.15s; }
  .chat-retry:hover { background: var(--danger); color: var(--bg); }

  /* Trạng thái trống: lời chào + chips gợi ý */
  .chat-empty { padding: 24px 4px; }
  .chat-empty-title { font-family: var(--display); font-size: 22px; font-weight: 400; letter-spacing: -0.02em; margin-bottom: 8px; }
  .chat-empty-text { font-size: 14px; color: var(--muted); line-height: 1.55; max-width: 52ch; margin-bottom: 18px; }
  .chat-chips { display: flex; flex-wrap: wrap; gap: 8px; }
  .chat-chip { font-size: 13px; color: var(--ink); background: var(--bg); border: 1px solid var(--line-2); border-radius: 999px; padding: 8px 14px; transition: all 0.15s; text-align: left; }
  .chat-chip:hover { background: var(--ink); color: var(--bg); border-color: var(--ink); }

  /* Nhãn cắt lịch sử */
  .chat-trim { align-self: center; font-family: var(--mono); font-size: 9px; text-transform: uppercase; letter-spacing: 0.15em; color: var(--muted-2); padding: 4px 0 8px; }

  /* ============ Tab Âm nhạc ============ */
  /* Period toggle: CLASS RIÊNG (không dùng chung .expense-period-toggle) — copy 3 dòng
     CSS, đổi selector để listener nhạc bắt đúng, tránh đụng listener chi tiêu. */
  .music-period-toggle { display: flex; gap: 4px; margin-bottom: 16px; }
  .music-period-toggle button { padding: 6px 12px; font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.15em; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; }
  .music-period-toggle button.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }

  /* Bar bằng DOM/CSS (KHÔNG canvas): rank · main(title/sub/thanh) · meta(lượt nghe). */
  .music-bar-item { display: grid; grid-template-columns: 34px 1fr auto; gap: 12px; align-items: center; padding: 10px 4px; border-bottom: 1px solid var(--line); }
  .music-rank { font-family: var(--mono); font-size: 13px; color: var(--muted); }
  .music-bar-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
  .music-bar-title { font-family: var(--body); color: var(--ink); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .music-bar-sub { font-family: var(--body); font-size: 12px; color: var(--muted); }
  .music-bar { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; margin-top: 2px; }
  .music-bar-fill { height: 100%; background: var(--ink); border-radius: 999px; } /* opacity inline theo rank */
  .music-meta { font-family: var(--mono); font-size: 11px; color: var(--ink); text-align: right; white-space: nowrap; }

  /* Giờ vàng — heatmap 24h: cột dọc cao theo lượt nghe, đậm dần theo cường độ. */
  .music-hours { margin: 4px 0 8px; }
  .music-hours-chart { display: flex; align-items: flex-end; gap: 2px; height: 84px; margin: 10px 0 6px; }
  .music-hour-col { flex: 1; display: flex; align-items: flex-end; height: 100%; }
  .music-hour-bar { width: 100%; background: var(--ink); border-radius: 3px 3px 0 0; min-height: 2px; } /* height + opacity inline */
  .music-hours-axis { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 9px; color: var(--muted-2); letter-spacing: 0.05em; }
  .music-hours-peak { font-family: var(--body); font-size: 12px; color: var(--muted); margin-top: 6px; }
  .music-hours-peak b { font-weight: 600; color: var(--ink); }


  /* ============== Màn đăng nhập (auth.js) — thêm cho bản Chi tiêu đa người dùng ============== */
  /* Tái dùng .pin-screen làm khung canh giữa; thẻ form bám token, không hardcode màu. */
  .auth-card { width: 100%; max-width: 340px; margin-top: 8px; }
  .auth-card .form-row { margin-bottom: 14px; }
  .auth-card .pin-prompt { margin-bottom: 20px; }
  .auth-card .btn-primary { width: 100%; justify-content: center; margin-top: 4px; }
  .auth-switch { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.13em; color: var(--muted); text-align: center; margin-top: 18px; }
  .auth-switch-btn { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.13em; color: var(--ink); border-bottom: 1px solid var(--ink); padding-bottom: 1px; }
  .app-footer { display: flex; gap: 10px; justify-content: center; margin-top: 40px; }

/* ============================================================================
   DESIGN v2 — "Tasty" vibe app đồ ăn, theme-able. Lớp override đặt CUỐI file nên
   thắng các rule trước. Đổi vibe bằng <html data-theme="..."> (xem theme.js).
   ============================================================================ */
:root{
  --bg:#FFF4E8; --bg-2:#FFE7D4; --ink:#211A14; --ink-2:#5C4A3A;
  --muted:#9A8C7E; --muted-2:#B9AD9F; --line:#F0E6D8;
  --success:#11A86B; --danger:#E5484D;
  --br:#FF6A2C; --br2:#FF9D2E; --brs:#FFE7D4; --h1:#FF7A3D; --h2:#F0451E;
}
html[data-theme="midnight"]{--bg:#14110F;--bg-2:#211C18;--ink:#F6EEE6;--ink-2:#D8C9B8;--muted:#9A8C7E;--muted-2:#6E6258;--line:#2E2823;--success:#2BD18B;--danger:#FF6B6B;--br:#FF7A3D;--br2:#FF9D2E;--brs:#3A2A1E;--h1:#FF7A3D;--h2:#F0451E}
html[data-theme="matcha"]{--bg:#F1F6EC;--bg-2:#E4F1D8;--ink:#20281C;--ink-2:#46553B;--muted:#8A9A82;--muted-2:#A9B7A0;--line:#E2EAD8;--success:#2E9E5B;--danger:#E5644D;--br:#4FA744;--br2:#8BC34A;--brs:#E4F1D8;--h1:#5DB552;--h2:#2E8B57}
html[data-theme="grape"]{--bg:#F6F1FB;--bg-2:#EEE3FF;--ink:#241B33;--ink-2:#4A3B63;--muted:#9488A8;--muted-2:#B3A8C6;--line:#EADFF5;--success:#16B981;--danger:#F0506E;--br:#8B5CF6;--br2:#C264FF;--brs:#EEE3FF;--h1:#9C5BFF;--h2:#6C3FE0}
html[data-theme="sakura"]{--bg:#FFF1F4;--bg-2:#FFE2EC;--ink:#3A2230;--ink-2:#6E4357;--muted:#B08597;--muted-2:#CDA9B8;--line:#FBE0E8;--success:#18B894;--danger:#F0506E;--br:#FF6FA5;--br2:#FF9BC2;--brs:#FFE2EC;--h1:#FF8FB6;--h2:#FF5C93}
html[data-theme="ocean"]{--bg:#EEF6FB;--bg-2:#DCEFFB;--ink:#14283A;--ink-2:#39576E;--muted:#7C95A8;--muted-2:#9DB2C2;--line:#DCEAF3;--success:#14A88A;--danger:#EF5B6B;--br:#1E88E5;--br2:#25C0D6;--brs:#DCEFFB;--h1:#2E9BF0;--h2:#1463C4}
html[data-theme="mono"]{--bg:#F4F4F2;--bg-2:#EAEAE6;--ink:#1A1A1A;--ink-2:#4A4A4A;--muted:#8A8A88;--muted-2:#AEAEAB;--line:#E4E4E0;--success:#3C7A5A;--danger:#B5403F;--br:#1A1A1A;--br2:#4A4A4A;--brs:#EAEAE6;--h1:#3A3A3A;--h2:#111111}
html[data-theme="snow"]{--bg:#F7F8FA;--bg-2:#EDEFF3;--ink:#14161A;--ink-2:#383D44;--muted:#717784;--muted-2:#A2A8B3;--line:#E6E8EC;--line-2:#D7DAE0;--success:#18A06A;--danger:#E5484D;--br:#2F6BFF;--br2:#4F46E5;--brs:#EAF0FF;--h1:#2F6BFF;--h2:#1D4ED8}

html,body{background:var(--bg);color:var(--ink)}
/* Chừa chỗ cho thanh điều hướng dưới */
.app{padding-bottom:calc(108px + env(safe-area-inset-bottom,0px))}

/* Nút & accent → cam (thay navy cũ) */
.btn-primary{background:linear-gradient(140deg,var(--br),var(--br2));border:none;color:#fff}
.btn-primary:hover{filter:brightness(1.04)}
.tab.active{color:var(--br);border-bottom-color:var(--br)}
.section-action{border-color:var(--br);color:var(--br)}
.section-action:hover{background:var(--br);color:#fff;border-color:var(--br)}
.stat.streak{background:linear-gradient(140deg,var(--h1),var(--h2))}
.expense-btn-go{background:linear-gradient(140deg,var(--br),var(--br2))!important;color:#fff!important}
.expense-btn-ai{background:var(--brs)!important;color:var(--br)!important}
.expense-input-wrap:focus-within{border-color:var(--br);box-shadow:0 0 0 4px color-mix(in srgb,var(--br) 18%,transparent)}

/* Bo tròn ấm hơn cho card/list/modal */
.list-item,.expense-item,.review-box,.review-item,.coach-card,.mini-stat,.stat,.form-input,.form-select{border-radius:16px}
.modal{border-radius:28px}
.expense-input-wrap,.quick-log{border-radius:999px}

/* ===== Header lời chào + avatar ===== */
.greet-av{width:46px;height:46px;border-radius:15px;background:linear-gradient(140deg,var(--br),var(--br2));display:grid;place-items:center;color:#fff;font-family:var(--display);font-weight:700;font-size:20px;flex:0 0 auto}

/* ===== Hero số dư / ngân sách ===== */
.balance-hero{position:relative;overflow:hidden;border-radius:28px;padding:22px;color:#fff;background:linear-gradient(135deg,var(--h1),var(--h2));margin:4px 0 22px;box-shadow:0 20px 40px -22px var(--h2)}
.balance-hero .bh-label{font-family:var(--mono);font-size:11px;letter-spacing:.12em;text-transform:uppercase;opacity:.92}
.balance-hero .bh-amt{font-family:var(--display);font-weight:700;font-size:40px;line-height:1;margin:6px 0 4px;letter-spacing:-.02em}
.balance-hero .bh-amt small{font-size:20px;opacity:.85}
.balance-hero .bh-sub{font-size:12.5px;opacity:.95}
.balance-hero .bh-bar{height:8px;border-radius:999px;background:rgba(255,255,255,.28);margin-top:14px;overflow:hidden}
.balance-hero .bh-bar>i{display:block;height:100%;border-radius:999px;background:#fff}
.balance-hero .bh-blob{position:absolute;width:150px;height:150px;border-radius:50%;background:rgba(255,255,255,.13);top:-60px;right:-30px}

/* ===== Bottom nav + FAB ===== */
.appnav{position:fixed;left:50%;transform:translateX(-50%);bottom:0;width:100%;max-width:720px;background:var(--bg);border-top:1.5px solid var(--line);display:flex;align-items:flex-end;justify-content:space-around;padding:10px 12px calc(16px + env(safe-area-inset-bottom,0px));z-index:40}
.appnav a{display:flex;flex-direction:column;align-items:center;gap:3px;font-family:var(--mono);font-size:9.5px;letter-spacing:.06em;text-transform:uppercase;color:var(--muted);cursor:pointer;border:none;background:none}
.appnav a.active{color:var(--br)}
.appnav a .nv-ic{font-size:20px}
.appnav .nav-fab{width:58px;height:58px;border-radius:50%;background:linear-gradient(140deg,var(--br),var(--br2));color:#fff;display:grid;place-items:center;font-size:30px;font-weight:300;box-shadow:0 12px 22px -8px var(--br);margin-bottom:4px;border:none}

/* ===== Theme picker (trong footer) ===== */
.theme-row{display:flex;gap:10px;justify-content:center;flex-wrap:wrap;margin-top:18px}
.theme-dot{width:30px;height:30px;border-radius:50%;border:2px solid transparent;cursor:pointer}
.theme-dot.sel{border-color:var(--ink)}
.theme-dot[data-theme="snow"]{box-shadow:inset 0 0 0 1.5px var(--line-2)}

/* ============================================================================
   HOME v3 — dựng đúng mockup: category chips · thẻ ví ngang · thẻ giao dịch.
   ============================================================================ */
:root{ --sur:#FFFFFF }
html[data-theme="midnight"]{ --sur:#211C18 }
html[data-theme="snow"]{ --sur:#FFFFFF }

/* Ẩn 3 ô Thu/Chi/Còn (mockup dùng hero thay thế) */
#expenseStats{ display:none }

/* Category chips */
.cats{ display:flex; gap:12px; overflow-x:auto; padding:2px 2px 6px; margin-bottom:8px; scrollbar-width:none }
.cats::-webkit-scrollbar{ display:none }
.cat{ flex:0 0 auto; width:68px; text-align:center }
.cat .cic{ width:62px; height:62px; border-radius:22px; display:grid; place-items:center; font-size:26px; background:var(--sur); border:1.5px solid var(--line); margin-bottom:7px }
.cat b{ font-size:11.5px; font-weight:700; display:block; white-space:nowrap; overflow:hidden; text-overflow:ellipsis }
.cat small{ display:block; font-size:10.5px; color:var(--muted); font-weight:600 }

/* Ví — thẻ cuộn ngang nhiều màu */
.wallets{ display:flex; gap:14px; overflow-x:auto; padding:2px 2px 6px; scrollbar-width:none }
.wallets::-webkit-scrollbar{ display:none }
.wallet{ flex:0 0 auto; width:172px; border-radius:20px; padding:16px; color:#fff; position:relative; overflow:hidden; box-shadow:0 10px 24px -16px rgba(0,0,0,.5) }
.wallet .w-chip{ position:absolute; top:14px; right:14px; width:30px; height:22px; border-radius:6px; background:rgba(255,255,255,.3) }
.wallet .w-label{ font-size:11px; font-weight:700; letter-spacing:.04em; text-transform:uppercase; opacity:.85 }
.wallet .w-name{ font-family:var(--display); font-weight:700; font-size:16px; margin-top:2px }
.wallet .w-bal{ font-family:var(--display); font-weight:800; font-size:24px; margin-top:14px; letter-spacing:-.02em }
.wallet .w-bal span{ font-size:13px; opacity:.8 }
.wallet .w-note{ font-size:10.5px; opacity:.85; margin-top:3px; font-weight:600 }
.wallet-empty{ background:var(--sur); border:1.5px dashed var(--line); border-radius:18px; padding:20px; text-align:center; color:var(--muted) }

/* Giao dịch — thẻ có avatar icon + tag */
.txn-group{ margin-bottom:6px }
.txn-day{ display:flex; justify-content:space-between; font-size:12px; font-weight:700; color:var(--muted); text-transform:uppercase; letter-spacing:.04em; margin:14px 2px 10px }
.txn-day .td-amt .income{ color:var(--success) } .txn-day .td-amt .expense{ color:var(--danger) }
.txn{ display:flex; align-items:center; gap:13px; background:var(--sur); border:1.5px solid var(--line); border-radius:16px; padding:12px 14px; margin-bottom:10px; cursor:pointer }
.txn .tic{ width:46px; height:46px; border-radius:14px; display:grid; place-items:center; font-size:22px; flex:0 0 auto; background:var(--brs) }
.txn .tic.inc{ background:var(--incs) }
.txn .tm{ flex:1; min-width:0 }
.txn .tn{ font-weight:700; font-size:14.5px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis }
.txn .tmeta{ font-size:11.5px; color:var(--muted); font-weight:500; margin-top:2px; display:flex; align-items:center; gap:7px; flex-wrap:wrap }
.txn .tmeta .tag{ font-size:10px; font-weight:700; padding:2px 8px; border-radius:999px; background:var(--tagbg,var(--brs)); color:var(--tagc,var(--br)) }
.txn .ta{ font-family:var(--display); font-weight:800; font-size:16px; white-space:nowrap }
.txn .ta.income{ color:var(--success) }
.txn .ta small{ font-size:11px; font-weight:700; opacity:.65 }
/* token tag cho v3 */
:root{ --tagbg:var(--brs); --tagc:var(--br) }

/* Tiêu đề khu */
.home-head{ display:flex; align-items:center; justify-content:space-between; margin:6px 2px 12px }
.home-head h3{ font-family:var(--display); font-weight:800; font-size:18px }

/* ============================================================================
   VIEWS — nhiều màn điều khiển bằng bottom nav (home/stats/all/settings)
   ============================================================================ */
#app > .view{ display:none }
#app > .view.active{ display:block }
.sec-link{ font-size:12.5px; font-weight:700; color:var(--br); cursor:pointer }

.seg{ display:flex; background:var(--sur); border:1.5px solid var(--line); border-radius:999px; padding:4px; gap:4px; margin-bottom:16px }
.seg span{ flex:1; text-align:center; font-size:12.5px; font-weight:700; color:var(--muted); padding:9px; border-radius:999px; cursor:pointer }
.seg span.on{ background:var(--ink); color:var(--bg) }

.chips{ display:flex; gap:8px; flex-wrap:wrap; margin-bottom:14px }
.chips .chip{ font-size:12.5px; font-weight:700; padding:8px 14px; border-radius:999px; background:var(--sur); border:1.5px solid var(--line); color:var(--ink); cursor:pointer }
.chips .chip.on{ background:var(--ink); color:var(--bg); border-color:var(--ink) }

/* Thống kê */
.stat-card{ background:var(--sur); border:1.5px solid var(--line); border-radius:20px; padding:18px; margin-bottom:16px }
.donut{ width:170px; height:170px; border-radius:50%; margin:4px auto 14px; display:grid; place-items:center }
.donut .hole{ width:112px; height:112px; border-radius:50%; background:var(--sur); display:flex; flex-direction:column; align-items:center; justify-content:center; text-align:center }
.donut .hole b{ font-family:var(--display); font-weight:800; font-size:22px; display:block; line-height:1 }
.donut .hole small{ font-size:11px; color:var(--muted); font-weight:600 }
/* Nhiều đơn vị tiền: xếp dọc, số nhỏ lại cho vừa lỗ donut */
.donut .hole.multi{ gap:1px; padding:0 8px }
.donut .hole.multi b{ font-size:15px; line-height:1.2 }
.donut .hole.multi small{ order:-1; margin-bottom:1px }
.lg-row{ display:flex; align-items:center; gap:8px; font-size:12.5px; font-weight:600; margin-bottom:9px }
.lg-row .dot{ width:10px; height:10px; border-radius:3px; flex:0 0 auto }
.lg-row .amt{ margin-left:auto; color:var(--muted) }
.bars{ display:flex; align-items:flex-end; gap:8px; height:120px; padding:8px 2px 0 }
.bars .bcol{ flex:1; display:flex; flex-direction:column; align-items:center; gap:6px; justify-content:flex-end; height:100% }
.bars .bk{ width:100%; border-radius:7px 7px 4px 4px; background:linear-gradient(180deg,var(--br),var(--br2)); min-height:3px }
.bars .bl{ font-size:10px; color:var(--muted); font-weight:700 }
.cmp{ display:flex; gap:12px }
.cmp > div{ flex:1; border-radius:16px; padding:14px }
.cmp .down{ background:var(--incs) } .cmp .up{ background:var(--brs) }
.cmp b{ font-family:var(--display); font-size:22px; display:block; margin-top:2px }

/* Cài đặt */
.settings-profile{ text-align:center; margin:6px 0 20px }
.settings-profile #setEmail{ color:var(--muted); font-weight:600; font-size:13px }

/* ============================================================================
   Nhắc nhở & Tổng hợp hàng ngày
   ============================================================================ */
.summary-card{ display:flex; gap:13px; align-items:flex-start; background:var(--sur); border:1.5px solid var(--line); border-radius:18px; padding:14px 16px; margin:0 0 18px }
.summary-card .si{ width:42px; height:42px; border-radius:13px; background:var(--brs); display:grid; place-items:center; font-size:20px; flex:0 0 auto }
.summary-card .sb{ flex:1; min-width:0 }
.summary-card .sb b{ font-size:14px; font-weight:700 }
.summary-card .sb p{ font-size:12.5px; color:var(--muted); font-weight:500; margin-top:2px; line-height:1.45 }
.summary-card .sb p b{ color:var(--ink) }

.rc-row{ display:flex; align-items:center; gap:12px; padding:12px 2px }
.rc-row + .rc-row{ border-top:1.5px solid var(--line) }
.rc-row .m{ flex:1 } .rc-row .m b{ font-size:14px; font-weight:700 } .rc-row .m small{ display:block; color:var(--muted); font-size:11px; font-weight:600 }
.toggle{ width:46px; height:28px; border-radius:999px; background:var(--line); position:relative; flex:0 0 auto; cursor:pointer }
.toggle span{ position:absolute; top:3px; left:3px; width:22px; height:22px; border-radius:50%; background:#fff; box-shadow:0 1px 3px rgba(0,0,0,.25); transition:left .15s }
.toggle.on{ background:var(--br) } .toggle.on span{ left:21px }
.rc-prompt{ width:100%; border:1.5px solid var(--line); border-radius:14px; background:var(--sur); color:var(--ink); font-family:var(--body); font-size:14px; padding:12px 14px; min-height:74px; resize:vertical }

/* Danh mục — màn quản lý chi theo nhóm */
.catx{ display:flex; align-items:center; gap:13px; background:var(--sur); border:1.5px solid var(--line); border-radius:14px; padding:11px 14px; margin-bottom:10px; cursor:pointer }
.catx .cx-m{ flex:1; min-width:0 } .catx .cx-m b{ font-size:14.5px; font-weight:700 }
.catx .cx-bar{ height:6px; border-radius:999px; background:var(--line); overflow:hidden; margin-top:7px } .catx .cx-bar i{ display:block; height:100%; border-radius:999px }
.catx .cx-v{ font-family:var(--display); font-weight:800; font-size:15px; text-align:right; white-space:nowrap } .catx .cx-v small{ display:block; font-family:var(--body); font-size:11px; color:var(--muted); font-weight:600 }

/* ============================================================================
   Pill ghi nhanh — chuẩn hoá 3 nút (📷 / ✨ / ↵) thành nút tròn đều, gửi gọn gàng
   ============================================================================ */
.expense-input-wrap{ gap:8px; padding:7px 8px 7px 18px; align-items:center }
.expense-input-wrap .expense-input{ height:auto }
.expense-input-wrap .expense-btn-ai,
.expense-input-wrap .expense-btn-go{
  width:40px; height:40px; min-width:40px; padding:0; border:none; border-radius:50%;
  display:grid; place-items:center; flex:0 0 auto; font-size:17px; line-height:1;
  transition:transform .12s ease, filter .12s ease; cursor:pointer;
}
.expense-input-wrap .expense-btn-ai{ background:var(--brs); color:var(--br) }
.expense-input-wrap .expense-btn-ai:disabled{ opacity:.45 }
.expense-input-wrap .expense-btn-go{
  background:linear-gradient(140deg,var(--br),var(--br2)); color:#fff; font-size:18px; font-weight:700;
  box-shadow:0 8px 18px -8px var(--br);
}
.expense-input-wrap .expense-btn-ai:active,
.expense-input-wrap .expense-btn-go:active{ transform:scale(.92) }
.expense-input-wrap .expense-btn-go:hover{ filter:brightness(1.05) }

/* Thống kê — chi theo ngày: tuần này vs tuần trước + thẻ so sánh */
.bcol2{ flex:1; display:flex; flex-direction:column; align-items:center; gap:6px; justify-content:flex-end; height:100% }
.bpair{ display:flex; align-items:flex-end; gap:3px; height:100%; width:100%; justify-content:center }
.bk2{ width:10px; border-radius:5px 5px 3px 3px; min-height:3px }
.bk2.cur{ background:linear-gradient(180deg,var(--br),var(--br2)) }
.bk2.prev{ background:var(--line) }
.wk-legend{ display:flex; gap:16px; font-size:11.5px; color:var(--muted); font-weight:600; margin-bottom:8px }
.wk-legend i{ display:inline-block; width:10px; height:10px; border-radius:3px; vertical-align:middle; margin-right:5px }
.wk-legend i.cur{ background:var(--br) } .wk-legend i.prev{ background:var(--line) }
.cmp-grid{ display:flex; gap:12px }
.cmp-grid .cmp-card{ flex:1; background:var(--sur); border:1.5px solid var(--line); border-radius:18px; padding:14px }
.cmp-card .muted{ font-size:11.5px } .cmp-card b{ font-family:var(--display); font-size:24px; display:block; margin:4px 0 2px; line-height:1 }
.cmp-card .cmp-note{ font-size:11px; color:var(--muted); font-weight:600 }
.cmp-card .cmp-sub{ font-size:10.5px; color:var(--muted); margin-top:6px }

.summary-card .dbar{ height:7px; border-radius:999px; background:var(--line); overflow:hidden; margin:7px 0 }
.summary-card .dbar i{ display:block; height:100%; border-radius:999px }
