  :root {
    color-scheme: light;
    /* Gradient thiệp mặc định (fallback CSS trước khi JS áp theme) — token hóa để dark mode
       đổi qua biến mà không ghi đè hex cứng (kiểm định 14/08/2026). */
    --quote-grad-from: #5f7566;
    --quote-grad-to: #33443a;
    --sage-900: #33443a;
    --sage-700: #4d6255;
    --sage-600: #5f7566;
    --sage-500: #7c9083;
    --sage-200: #c9d4cc;
    --sage-100: #e3e9e4;
    --sage-050: #f0f3ef;
    --beige-050: #faf8f2;
    --beige-100: #f3efe4;
    --beige-200: #e8e1d0;
    --gray-600: #6b6f66;
    --gray-400: #9aa095;
    --ink: #33372f;
    --ink-soft: #555a4f;
    --card: #ffffff;
    --topbar-bg: rgba(250, 248, 242, 0.86);
    --input-focus-bg: #ffffff;
    --card-label-color: var(--sage-600);
    --accent-ink: #ffffff;   /* chữ trên nút accent (--sage-600) — theme override bằng JS */
    --radius: 18px;
    --shadow: 0 2px 10px rgba(51, 68, 58, 0.07), 0 10px 30px rgba(51, 68, 58, 0.06);
    --shadow-lg: 0 8px 30px rgba(51, 68, 58, 0.16);
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-serif: "Times New Roman", Georgia, "Noto Serif", serif;  /* Georgia thiếu một số glyph Việt (VD: ố) nên để TNR lên đầu */
  }

  * { box-sizing: border-box; margin: 0; padding: 0; }
  html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
  button, a { touch-action: manipulation; } /* mobile: bỏ delay double-tap, không zoom khi chạm nhanh */
  body {
    font-family: var(--font-sans);
    color: var(--ink);
    background:
      radial-gradient(1200px 500px at 85% -10%, var(--sage-100) 0%, transparent 60%),
      radial-gradient(900px 400px at -10% 20%, var(--beige-200) 0%, transparent 55%),
      var(--beige-050);
    min-height: 100vh;
    line-height: 1.6;
  }

  /* ---------- Top bar ---------- */
  .topbar {
    position: sticky; top: 0; z-index: 50;
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 16px;
    padding-top: calc(16px + env(safe-area-inset-top));
    background: var(--topbar-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--beige-200);
  }
  .brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--sage-900); }
  .brand svg { width: 26px; height: 26px; flex: none; }
  .brand-name { font-weight: 700; font-size: 1.05rem; letter-spacing: 0.2px; }
  .brand-sub { display: none; font-size: 0.8rem; color: var(--gray-600); }
  .stop-btn {
    display: inline-flex; align-items: center; gap: 6px;
    font: inherit; font-size: 0.85rem; font-weight: 600; color: var(--sage-700);
    background: var(--sage-100); border: 1px solid var(--sage-200);
    padding: 12px 16px; border-radius: 999px; cursor: pointer;
    transition: background 0.15s, transform 0.05s;
  }
  .stop-btn:hover { background: var(--sage-200); }
  .stop-btn:active { transform: scale(0.97); }
  .stop-btn:disabled { opacity: 0.45; cursor: default; }
  .stop-btn svg { width: 14px; height: 14px; }
  .topbar-actions { display: flex; align-items: center; gap: 8px; }
  .theme-btn {
    display: inline-flex; align-items: center; gap: 6px;
    font: inherit; font-size: 0.85rem; font-weight: 600; color: var(--sage-700);
    background: var(--sage-100); border: 1px solid var(--sage-200);
    padding: 12px 16px; border-radius: 999px; cursor: pointer;
    transition: background 0.15s, transform 0.05s;
  }
  .theme-btn:hover { background: var(--sage-200); }
  .theme-btn:active { transform: scale(0.97); }
  .theme-emoji { font-size: 1rem; line-height: 1; }
  /* Nút đổi cỡ chữ nhanh (Aa) — cùng phong cách theme-btn */
  .font-btn {
    display: inline-flex; align-items: center; gap: 6px;
    font: inherit; font-size: 0.85rem; font-weight: 600; color: var(--sage-700);
    background: var(--sage-100); border: 1px solid var(--sage-200);
    padding: 12px 16px; border-radius: 999px; cursor: pointer;
    transition: background 0.15s, transform 0.05s;
  }
  .font-btn:hover { background: var(--sage-200); }
  .font-btn:active { transform: scale(0.97); }
  .font-btn-icon {
    font-size: 0.95rem; font-weight: 800; line-height: 1;
    letter-spacing: -0.5px;
  }
  .font-btn-label { font-weight: 700; }
  /* Màn hình hẹp: chỉ giữ biểu tượng (tránh tràn topbar trên mobile) */
  @media (max-width: 419px) {
    .theme-lbl { display: none; }
    .theme-btn { padding: 12px 13px; }
    .font-btn-label { display: none; }
    .font-btn { padding: 12px 13px; }
  }
  /* Màn hình RẤT hẹp (≤359px — 320px/SE cũ): 3 nút topbar tràn ngang khi cỡ
     chữ 140% (QX-17) — siết padding + gap. */
  @media (max-width: 359px) {
    .topbar { padding-left: 10px; padding-right: 10px; gap: 8px; }
    .topbar-actions { gap: 6px; }
    .theme-btn, .font-btn, .stop-btn { padding-left: 11px; padding-right: 11px; }
    .stop-btn { gap: 4px; }
  }
  main { max-width: 640px; margin: 0 auto; padding: 24px 16px 88px; }

  /* ---------- Home ---------- */
  .hero { text-align: left; margin: 8px 2px 26px; }
  .hero h1 { font-size: clamp(1.7rem, 6.5vw, 1.9rem); line-height: 1.25; font-weight: 800; color: var(--sage-900); letter-spacing: -0.3px; }
  .hero p { margin-top: 10px; color: var(--ink-soft); font-size: 1rem; }
  .open-line { margin-top: 8px; font-size: 0.9rem; color: var(--gray-600); font-style: italic; }

  .searchbox {
    display: flex; flex-direction: column; gap: 12px;
    background: var(--card); border: 1px solid var(--beige-200);
    border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
  }
  .searchbox label { font-size: 0.8rem; font-weight: 600; color: var(--gray-600); letter-spacing: 0.4px; text-transform: uppercase; }
  .searchbox textarea {
    width: 100%; font: inherit; font-size: 1rem; color: var(--ink);
    border: 1px solid var(--beige-200); border-radius: 12px;
    padding: 12px 16px; background: var(--beige-050);
    min-height: 96px; resize: vertical; line-height: 1.55;
  }
  .searchbox textarea:focus { outline: 2px solid var(--sage-500); outline-offset: 1px; background: var(--input-focus-bg); }
  .searchbox textarea::placeholder { color: var(--gray-600); }
  .searchbox-actions { display: flex; }
  .searchbox-actions .btn-primary { width: 100%; justify-content: center; }
  .name-field { display: flex; flex-direction: column; gap: 6px; }
  .name-field label { font-size: 0.8rem; font-weight: 600; color: var(--gray-600); letter-spacing: 0.4px; text-transform: uppercase; }
  .name-field .name-optional { font-weight: 400; text-transform: none; letter-spacing: 0; opacity: 0.75; }
  .name-field input {
    font: inherit; font-size: 0.95rem; color: var(--ink);
    border: 1px dashed var(--beige-200); border-radius: 10px;
    padding: 8px 14px; background: var(--beige-050);
  }
  .name-field input:focus { outline: 2px solid var(--sage-500); outline-offset: 1px; background: var(--input-focus-bg); border-style: solid; }
  .name-field input::placeholder { color: var(--gray-600); }
  .btn-primary {
    font: inherit; font-weight: 700; font-size: 0.95rem; color: var(--accent-ink);
    background: var(--sage-600); border: none; border-radius: 12px;
    padding: 12px 20px; cursor: pointer; white-space: nowrap;
    transition: background 0.15s, transform 0.05s;
  }
  .btn-primary:hover { background: var(--sage-700); }
  .btn-primary:active { transform: scale(0.98); }

  .privacy-note {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    font-size: 0.8rem; color: var(--gray-600); margin-top: 12px; padding: 0 4px;
  }
  .privacy-note b { color: var(--sage-700); font-weight: 600; }
  .privacy-ai { display: block; margin-top: 2px; opacity: 0.85; }
  .library-count {
    font-size: 0.78rem; color: var(--gray-600); margin: 12px 4px 0;
  }
  .library-count b { color: var(--sage-700); font-weight: 700; }

  /* Nút gửi nan đề (luôn sẵn trên trang chủ — vòng phản hồi nội dung tự duy trì) */
  .suggest-entry {
    display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
    margin: 16px 4px 0; padding: 12px 12px;
    background: var(--sage-050); border: 1px dashed var(--sage-200); border-radius: 12px;
  }
  .suggest-entry { gap: 12px; }
  .suggest-entry p { font-size: 0.8rem; color: var(--ink-soft); line-height: 1.5; }
  .suggest-link {
    font: inherit; font-size: 0.85rem; font-weight: 600; color: var(--sage-700);
    background: none; border: none; text-decoration: underline; text-underline-offset: 3px;
    cursor: pointer; padding: 12px 4px; min-height: 44px; white-space: nowrap;
    min-width: 0; /* flex item: cho phép co để wrap chữ trên màn hình rất hẹp (QX-17 140%) */
  }
  .suggest-link:hover { color: var(--sage-900); }
  /* Màn hình RẤT hẹp (≤359px — 320px/SE cũ): nút "Gửi nan đề" dài → cho chữ
     wrap xuống 2 dòng thay vì tràn ngang (QX-17 cỡ chữ 140%). */
  @media (max-width: 359px) {
    .suggest-link { white-space: normal; padding: 8px 2px; }
  }

  .suggest-desc { font-size: 0.85rem; color: var(--ink-soft); line-height: 1.55; margin-bottom: 14px; }
  .suggest-label {
    display: block; font-size: 0.8rem; font-weight: 600; color: var(--gray-600); margin-bottom: 6px;
  }
  .modal textarea {
    width: 100%; font: inherit; font-size: 0.95rem; color: var(--ink);
    border: 1px solid var(--beige-200); border-radius: 12px;
    padding: 12px 14px; background: var(--card); min-height: 96px; resize: vertical; line-height: 1.55;
  }
  .modal textarea:focus { outline: 2px solid var(--sage-500); outline-offset: 1px; }
  .modal textarea::placeholder { color: var(--gray-600); }

  section { margin-top: 30px; }
  .section-title { font-size: 0.8rem; font-weight: 700; color: var(--gray-600); letter-spacing: 0.6px; text-transform: uppercase; margin-bottom: 12px; }
  .chip-group { margin-bottom: 12px; }
  .chip-group-label { font-size: 0.85rem; font-weight: 600; color: var(--ink-soft); margin: 0 2px 8px; }
  .chips { display: flex; flex-wrap: wrap; gap: 8px; }
  .chip {
    display: inline-flex; align-items: center;
    font: inherit; font-size: 0.84rem; font-weight: 500; color: var(--sage-700);
    background: var(--card); border: 1px solid var(--beige-200);
    padding: 8px 12px; min-height: 44px; border-radius: 999px; cursor: pointer;
    transition: all 0.15s;
  }
  .chip:hover { border-color: var(--sage-500); background: var(--sage-050); }
  .chip:active { transform: scale(0.97); }
  .chip-count {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 20px; height: 20px; padding: 0 6px; margin-left: 6px;
    border-radius: 999px; background: var(--sage-100); color: var(--sage-700);
    font-size: 0.75rem; font-weight: 700; line-height: 1;
  }

  .journey-card {
    display: flex; align-items: center; gap: 16px;
    background: linear-gradient(135deg, var(--sage-100), var(--sage-050));
    border: 1px solid var(--sage-200); border-radius: var(--radius);
    padding: 16px; cursor: pointer; transition: box-shadow 0.15s;
  }
  .journey-card:hover { box-shadow: var(--shadow); }
  .journey-badge {
    flex: none; width: 48px; height: 48px; border-radius: 14px;
    background: var(--sage-600); color: var(--accent-ink); font-size: 0.8rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center; text-align: center; line-height: 1.25;
  }
  .journey-card h3 { font-size: 0.98rem; color: var(--sage-900); }
  .journey-card p { font-size: 0.8rem; color: var(--ink-soft); margin-top: 2px; }
  .journey-arrow { margin-left: auto; color: var(--sage-600); font-size: 1.2rem; }

  /* ---------- Results ---------- */
  .results-header { margin: 4px 2px 18px; }
  .results-nav { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
  .back-link {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 0.85rem; font-weight: 600; color: var(--sage-700);
    background: none; border: none; cursor: pointer; padding: 12px 8px; margin-left: -8px; font-family: inherit;
    min-height: 44px;
  }
  .ask-another {
    font: inherit; font-size: 0.85rem; font-weight: 700; color: var(--sage-700);
    background: var(--beige-050); border: 1px solid var(--beige-200); border-radius: 999px;
    padding: 8px 14px; cursor: pointer; white-space: nowrap;
  }
  .ask-another:hover { background: var(--beige-100); border-color: var(--sage-200); }
  .ask-another:active { transform: scale(0.98); }
  .results-header h2 { font-size: 1.35rem; font-weight: 800; color: var(--sage-900); margin-top: 6px; line-height: 1.3; }
  .results-header .count { font-size: 0.82rem; color: var(--gray-600); margin-top: 4px; }
  .results-header .ai-note { font-size: 0.8rem; color: var(--gray-600); margin-top: 6px; }

  .verse-card {
    background: var(--card); border: 1px solid var(--beige-200);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 24px 20px; margin-bottom: 16px;
    animation: rise 0.35s ease both;
  }
  @keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

  .verse-quote { border-left: 3px solid var(--sage-500); padding-left: 14px; }
  .verse-text { font-family: var(--font-serif); font-size: 1.22rem; line-height: 1.55; color: var(--sage-900); }
  .verse-ref { margin-top: 10px; font-size: 0.82rem; font-weight: 700; color: var(--gray-600); }
  .verse-credit { font-size: 0.8rem; color: var(--gray-600); margin-top: 2px; }
  .verse-credit-expert { font-size: 0.72rem; font-style: italic; opacity: 0.8; }

  .card-part { margin-top: 16px; }
  .card-part-label {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 0.8rem; font-weight: 700; color: var(--card-label-color);
    letter-spacing: 0.5px; text-transform: uppercase;
  }
  .card-part-label::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--sage-500); }
  .card-part p { margin-top: 5px; font-size: 0.93rem; color: var(--ink-soft); }
  .takeaway p { color: var(--ink); background: var(--sage-050); border-radius: 12px; padding: 12px 14px; }

  .card-validation {
    margin-top: 14px; padding: 12px 12px; border-radius: 12px;
    background: var(--sage-050); font-size: 0.9rem; color: var(--sage-700); line-height: 1.5;
  }
  .card-validation b { color: var(--sage-900); font-weight: 700; }
  .card-why {
    margin-top: 12px; font-size: 0.8rem; color: var(--gray-600); line-height: 1.5;
  }
  .card-why b { color: var(--ink-soft); font-weight: 700; } /* ink-soft: ≥7:1 cả light lẫn dark (sage-600 chỉ ~2.95:1 trên nền thẻ tối) */

  /* QX-14 — Lời khuyên cơ đốc của AI (trả lời trực tiếp, kèm câu gốc Kinh Thánh) */
  .ai-answer {
    margin-top: 14px; padding: 14px 16px; border-radius: 12px;
    background: var(--sage-050); border: 1px solid var(--sage-200);
    color: var(--ink-soft); font-size: 0.92rem; line-height: 1.55;
  }
  .ai-answer-head { font-weight: 800; color: var(--ink); margin-bottom: 6px; }
  .ai-answer-text { margin: 0; white-space: pre-wrap; }
  .ai-answer-verses { margin: 10px 0 0; padding: 0; list-style: none; }
  .ai-answer-verses li { padding: 6px 0; border-top: 1px dashed var(--sage-200); font-size: 0.88rem; }
  .ai-answer-verses .ai-verse-ref { color: var(--sage-900); }
  /* QX-15: lịch sử hội thoại phiên — hỏi tiếp KHÔNG mất câu trả lời trước */
  .ai-history { margin: 2px 0 12px; padding-bottom: 12px; border-bottom: 1px dashed var(--sage-200); }
  .ai-turn + .ai-turn { margin-top: 12px; }
  .ai-turn-prev { opacity: 0.8; }
  .ai-user-q { margin: 0 0 6px; font-size: 0.78rem; color: var(--gray-600); }
  .ai-user-q b { color: var(--sage-700); font-weight: 700; }
  .ai-history-hint { margin: 0 0 8px; font-size: 0.75rem; font-style: italic; color: var(--gray-600); }
  .ai-prev-answer { margin: 0; font-size: 0.88rem; line-height: 1.55; white-space: pre-wrap; }
  .ai-answer-actions { margin-top: 12px; }
  .copy-ai {
    font: inherit; font-size: 0.82rem; font-weight: 700; color: var(--sage-700);
    background: var(--beige-050); border: 1px solid var(--beige-200); border-radius: 999px;
    padding: 7px 14px; cursor: pointer; white-space: nowrap;
  }
  .copy-ai:hover { background: var(--beige-100); border-color: var(--sage-200); }
  .copy-ai:active { transform: scale(0.98); }
  .ai-turn-copy { margin-top: 8px; }
  .copy-ai-mini { padding: 4px 10px; font-size: 0.72rem; }
  .ai-answer-note { margin: 10px 0 0; font-size: 0.75rem; color: var(--gray-600); }
  .ai-sync-note { margin: 8px 2px 0; font-size: 0.78rem; font-style: italic; color: var(--gray-600); }

  /* QX-15 — "Hỏi tiếp": kể thêm → AI trả lời có ngữ cảnh (lịch sử chỉ trong bộ nhớ) */
  .follow-up {
    margin-top: 12px; padding: 14px 16px; border-radius: 12px;
    background: var(--beige-050); border: 1px dashed var(--beige-200);
  }
  .follow-up-label {
    display: block; font-size: 0.8rem; font-weight: 700; color: var(--ink-soft); margin-bottom: 8px;
  }
  .follow-up-row { display: flex; gap: 8px; align-items: stretch; }
  .follow-up-row textarea {
    flex: 1; font: inherit; font-size: 0.9rem; color: var(--ink); line-height: 1.5;
    border: 1px solid var(--beige-200); border-radius: 10px; padding: 10px 12px;
    background: var(--card); min-height: 48px; resize: vertical;
  }
  .follow-up-row textarea:focus { outline: 2px solid var(--sage-500); outline-offset: 1px; }
  .follow-up-row textarea::placeholder { color: var(--gray-600); }
  .follow-up-btn {
    font: inherit; font-size: 0.9rem; font-weight: 700; color: #fff;
    background: var(--sage-700); border: none; border-radius: 10px;
    padding: 0 18px; cursor: pointer; white-space: nowrap;
  }
  .follow-up-btn:disabled { opacity: 0.6; cursor: wait; }
  .follow-up-error { margin: 8px 0 0; font-size: 0.8rem; color: #b3261e; }
  .follow-up-note { margin: 8px 0 0; font-size: 0.72rem; color: var(--gray-600); line-height: 1.5; }
  @media (max-width: 560px) {
    .follow-up-row { flex-direction: column; }
    .follow-up-btn { width: 100%; padding: 10px; }
  }
  .card-boundary {
    margin-top: 16px; padding-top: 12px;
    border-top: 1px dashed var(--beige-200);
    font-size: 0.8rem; color: var(--gray-600); line-height: 1.5;
  }

  /* Mobile: lưới 2 cột gọn — nút Lưu cả dòng (khuyến khích bookmark), Tạo thiệp + Sao chép kế bên.
     Desktop (>=720px) quay lại hàng ngang (xem @media min-width: 720px). */
  .card-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 18px; }
  .card-actions .btn-ghost { width: 100%; justify-content: center; }
  .save-btn { grid-column: 1 / -1; }
  .btn-ghost {
    font: inherit; font-size: 0.85rem; font-weight: 600; color: var(--sage-700);
    background: var(--beige-050); border: 1px solid var(--beige-200);
    border-radius: 10px; padding: 12px 16px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  }
  .btn-ghost:hover { background: var(--beige-100); }
  .save-btn[aria-pressed="true"] {
    background: var(--sage-100); border-color: var(--sage-200); color: var(--sage-700);
  }

  .fallback {
    background: var(--card); border: 1px dashed var(--sage-200); border-radius: var(--radius);
    padding: 24px 20px; text-align: center; color: var(--ink-soft); box-shadow: var(--shadow);
  }
  .fallback .big { font-size: 2rem; margin-bottom: 8px; }
  .fallback p { font-size: 0.95rem; }

  .result-nav {
    display: flex; align-items: center; justify-content: center; gap: 12px;
    flex-wrap: wrap; margin-top: 4px;
  }
  .result-pos { font-size: 0.82rem; color: var(--gray-600); font-variant-numeric: tabular-nums; }

  .more-link { text-align: center; margin-top: 6px; }
  .more-link button {
    font: inherit; font-size: 0.9rem; font-weight: 700; color: var(--sage-700);
    background: none; border: none; cursor: pointer; padding: 12px 12px; text-decoration: underline; text-underline-offset: 3px;
  }

  /* ---------- Journey (Lộ trình 3 ngày) ---------- */
  .journey-progress {
    height: 6px; border-radius: 999px; background: var(--beige-200);
    margin-top: 14px; overflow: hidden;
  }
  .journey-progress-fill {
    height: 100%; width: 0; background: var(--sage-600); border-radius: 999px;
    transition: width 0.35s ease;
  }
  .practice-box {
    background: linear-gradient(135deg, var(--sage-100), var(--sage-050));
    border: 1px solid var(--sage-200); border-radius: 14px; padding: 16px;
  }
  .practice-box p { margin-top: 6px; font-size: 0.95rem; color: var(--ink); line-height: 1.55; }
  .practice-actions { display: flex; align-items: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
  .timer-text { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--sage-700); min-width: 44px; }
  .day-actions { display: flex; gap: 8px; margin-top: 18px; }
  .journey-done {
    text-align: center; background: var(--card); border: 1px solid var(--sage-200);
    border-radius: var(--radius); padding: 32px 20px; box-shadow: var(--shadow);
  }
  .journey-done .big { font-size: 2.2rem; margin-bottom: 8px; }
  .journey-done p { font-size: 0.95rem; color: var(--ink-soft); }
  .journey-done .btn-primary { margin-top: 16px; }

  /* ---------- Chế độ an toàn (khủng hoảng) ---------- */
  .safety-hero {
    background: var(--sage-050); border: 1px solid var(--beige-200);
    border-radius: var(--radius); padding: 20px 16px;
  }
  .safety-hero p { font-size: 1rem; color: var(--ink); line-height: 1.6; }
  .hotline {
    display: block; width: 100%; margin-top: 12px; padding: 16px 16px;
    border-radius: 14px; background: var(--sage-600); color: var(--accent-ink);
    font-weight: 700; font-size: 1.08rem; text-align: center; text-decoration: none;
  }
  .hotline small { display: block; font-weight: 500; font-size: 0.8rem; opacity: 0.9; margin-top: 3px; }
  .hotline-alt { background: transparent; border: 1px solid var(--beige-200); color: var(--sage-700); }
  .safety-steps { margin-top: 24px; }
  .safety-steps ol { list-style: none; }
  .safety-steps li {
    display: flex; gap: 12px; align-items: flex-start;
    padding: 12px 2px; border-bottom: 1px dashed var(--beige-200);
  }
  .safety-steps .num {
    flex: none; width: 28px; height: 28px; border-radius: 50%;
    background: var(--sage-100); color: var(--sage-700);
    display: flex; align-items: center; justify-content: center; font-weight: 700;
  }
  .safety-steps li b { color: var(--sage-900); }
  .safety-steps li div { font-size: 0.92rem; color: var(--ink-soft); line-height: 1.5; }
  .safety-comfort { margin-top: 24px; }
  .comfort-card { margin-top: 14px; }

  /* ---------- Thu mồi (nan đề chưa khớp) ---------- */
  .bait-note {
    margin-top: 16px; padding: 16px 16px;
    background: var(--sage-050); border: 1px dashed var(--sage-200);
    border-radius: 14px; font-size: 0.85rem; color: var(--ink-soft); line-height: 1.55;
  }
  .bait-note b { color: var(--sage-700); }
  .bait-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
  .bait-clear {
    font: inherit; font-size: 0.85rem; color: var(--gray-600);
    background: none; border: none; text-decoration: underline; cursor: pointer; padding: 12px;
  }

  /* ---------- Trang mồi nan đề (biên tập viên — #/bait) ---------- */
  .bait-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
  .bait-item {
    background: var(--card); border: 1px solid var(--beige-200);
    border-radius: 16px; padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow);
  }
  .bait-q { font-size: 0.95rem; color: var(--ink); line-height: 1.55; }
  .bait-meta { font-size: 0.78rem; color: var(--gray-600); margin-top: 6px; }
  .bait-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
  .bait-privacy { font-size: 0.78rem; color: var(--gray-600); line-height: 1.6; margin-top: 14px; }

  /* ---------- Quote modal ---------- */
  .modal-overlay {
    position: fixed; inset: 0; z-index: 100;
    background: rgba(51, 68, 58, 0.45); backdrop-filter: blur(3px);
    display: none; align-items: center; justify-content: center; padding: 20px;
  }
  .modal-overlay.open { display: flex; }
  .modal {
    background: var(--beige-050); border-radius: 24px; padding: 24px;
    width: 100%; max-width: 380px; box-shadow: var(--shadow-lg);
  }
  .modal h3 { font-size: 1rem; color: var(--sage-900); margin-bottom: 14px; }
  .quote-card {
    background: linear-gradient(160deg, var(--quote-grad-from), var(--quote-grad-to));
    border-radius: 16px; padding: 32px 24px; color: #fdfcf8; text-align: center;
  }
  .quote-card .qc-verse { font-family: var(--font-serif); font-size: 1.15rem; line-height: 1.6; }
  .quote-card .qc-ref { margin-top: 14px; font-size: 0.8rem; font-weight: 600; opacity: 0.9; }
  .quote-card .qc-credit { margin-top: 2px; font-size: 0.8rem; opacity: 0.85; }
  .qc-foot { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 12px; }
  #qrPreview { border-radius: 8px; background: #fff; }
  /* Modal chọn chủ đề (QX-13/14): lời khuyên AI hiện ĐẦY ĐỦ — vùng cuộn riêng,
     không cắt chữ giữa từ, nút chọn chủ đề luôn thấy. */
  .qc-url-wrap { text-align: left; }
  .qc-url { font-size: 0.82rem; font-weight: 700; letter-spacing: 0.3px; }
  .qc-url-hint { font-size: 0.75rem; opacity: 0.75; margin-top: 1px; }
  .theme-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
  .theme-swatch {
    width: 44px; height: 44px; border-radius: 50%; padding: 0;
    border: 2px solid transparent; cursor: pointer;
  }
  .theme-swatch[aria-checked="true"] { border-color: var(--sage-900); outline: 2px solid var(--sage-500); outline-offset: 2px; }

  .ai-stats { margin-top: 28px; }
  .stats-table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 0.9rem; }
  .stats-table th, .stats-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--sage-200); }
  .stats-table th { color: var(--gray-600); font-weight: 600; font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.4px; }
  .stats-table .num { text-align: right; font-variant-numeric: tabular-nums; }
  /* Thống kê chủ đề CÒN THIẾU (biên tập — #/bait): nhu cầu thật chưa có thẻ */
  .stats-missing { margin-top: 16px; padding: 12px 14px; border: 1px solid light-dark(#e5b3ae, #8c3a34); border-radius: 10px; background: light-dark(#fdf3f2, #221918); }
  .stats-missing-title { margin: 0 0 8px; font-size: 0.9rem; color: light-dark(#b3261e, #ffb4ab); }
  .stats-missing-list { list-style: none; margin: 0; padding: 0; }
  .stats-missing-list li { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px solid light-dark(#f0d5d2, #3a2a28); font-size: 0.88rem; }
  .stats-missing-list li:last-child { border-bottom: 0; }
  .stats-missing-list .num { color: light-dark(#8c3a34, #f0b9b2); font-variant-numeric: tabular-nums; }

  /* Hàng chip "đọc tiếp" — chủ đề AI gợi ý dưới thẻ kho (QX-13/14):
     chip đang xem được đánh dấu active; topic THẬT chưa có thẻ → đỏ (light-dark). */
  .suggested-topics { margin-top: 24px; }
  .suggested-topics-label { font-size: 0.85rem; color: var(--gray-600); margin: 0 2px 10px; }
  .suggested-topics-note { margin: 10px 2px 0; font-size: 0.78rem; color: light-dark(#8c3a34, #f0b9b2); }
  .suggested-topics .chip.active { border-color: var(--sage-500); background: var(--sage-050); outline: 2px solid var(--sage-500); outline-offset: 1px; }
  .suggested-topics .chip.missing {
    border-color: light-dark(#e5b3ae, #8c3a34);
    background: light-dark(#fdf3f2, #241c1b);
    color: light-dark(#b3261e, #ffb4ab);
  }
  .tc-missing-badge {
    background: light-dark(#fdeceb, #4a1f1c); color: light-dark(#b3261e, #ffb4ab);
    border: 1px solid light-dark(#e5b3ae, #8c3a34); white-space: nowrap; font-size: 0.72rem; font-weight: 600;
  }

  .modal-actions { display: flex; gap: 8px; margin-top: 16px; }
  .modal-actions .btn-ghost, .modal-actions .btn-primary { flex: 1; justify-content: center; text-align: center; font-size: 0.88rem; padding: 12px 12px; }
  .modal .hint { font-size: 0.8rem; color: var(--gray-600); margin-top: 10px; text-align: center; }

  /* ---------- Theme picker (20 tông màu theo tâm trạng) ---------- */
  .modal-theme { max-width: 460px; max-height: 86vh; overflow-y: auto; }
  .font-scale-row {
    display: flex; align-items: center; gap: 10px;
    margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--beige-200);
  }
  .font-scale-label { font-size: 0.8rem; font-weight: 700; color: var(--ink-soft); }
  .font-scale-btn {
    width: 46px; height: 46px; font: inherit; font-size: 1.05rem; font-weight: 800;
    color: var(--sage-700); background: var(--beige-050); border: 1px solid var(--beige-200);
    border-radius: 10px; cursor: pointer;
  }
  .font-scale-btn:hover { background: var(--beige-100); border-color: var(--sage-200); }
  .font-scale-btn:disabled { opacity: 0.4; cursor: default; }
  .font-scale-current { min-width: 74px; text-align: center; font-size: 0.88rem; font-weight: 700; color: var(--sage-700); }
  .theme-mode-row { display: flex; gap: 8px; margin: 4px 0 14px; }
  .theme-mode-btn {
    flex: 1; font: inherit; font-size: 0.85rem; font-weight: 600; color: var(--sage-700);
    background: var(--sage-100); border: 1px solid var(--sage-200);
    padding: 10px 6px; border-radius: 999px; cursor: pointer; min-height: 44px;
    transition: background 0.15s, transform 0.05s;
  }
  .theme-mode-btn:hover { background: var(--sage-050); }
  .theme-mode-btn:active { transform: scale(0.97); }
  .theme-mode-btn[aria-checked="true"] {
    background: var(--sage-600); color: var(--accent-ink); border-color: var(--sage-600);
  }
  .theme-grid {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
    max-height: 44vh; overflow-y: auto; padding: 2px;
  }
  @media (min-width: 430px) { .theme-grid { grid-template-columns: repeat(3, 1fr); } }
  .theme-option {
    display: flex; flex-direction: column; gap: 5px; align-items: flex-start;
    font: inherit; text-align: left; cursor: pointer;
    background: var(--card); border: 1px solid var(--beige-200); border-radius: 14px;
    padding: 12px; transition: border-color 0.15s, box-shadow 0.15s;
  }
  .theme-option:hover { border-color: var(--sage-500); }
  .theme-option[aria-checked="true"] {
    border-color: var(--sage-900); outline: 2px solid var(--sage-500); outline-offset: 1px;
  }
  .theme-option .t-emoji { font-size: 1.3rem; line-height: 1; }
  .theme-option .t-label { font-size: 0.88rem; font-weight: 700; color: var(--ink); }
  .theme-option .t-desc { font-size: 0.72rem; color: var(--gray-600); line-height: 1.35; }
  .theme-pair { display: flex; gap: 5px; margin-top: 2px; }
  .theme-pair span { width: 24px; height: 24px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, 0.14); }

  /* ---------- Footer ---------- */
  .foot { max-width: 640px; margin: 0 auto; padding: 0 18px 40px; }
  .foot p { font-size: 0.8rem; color: var(--gray-600); line-height: 1.7; border-top: 1px solid var(--beige-200); padding-top: 16px; }
  .foot p + .foot-contact { margin-top: 10px; padding-top: 0; border-top: 0; }
  .foot-contact a { color: var(--sage-600); font-weight: 600; word-break: break-all; }

  /* ---------- Màn hình rất nhỏ (<=400px) — siết padding cho vừa tay ---------- */
  @media (max-width: 400px) {
    main { padding: 20px 14px 90px; }
    .verse-card { padding: 16px 16px; }
    .searchbox { padding: 12px; }
    .btn-primary { padding: 12px 14px; }
  }

  /* ---------- Desktop ---------- */
  @media (min-width: 720px) {
    .hero h1 { font-size: 2.4rem; }
    .brand-sub { display: inline; }
    main { padding-top: 40px; }
    .verse-card { padding: 24px 24px; }
    .card-actions { display: flex; }
    .card-actions .btn-ghost { width: auto; justify-content: flex-start; }
    .save-btn { grid-column: auto; }
  }

  /* Reduced motion */
  @media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
  }

  /* ---------- Dark mode (theo hệ thống HOẶC người dùng ép tối) — đặt CUỐI FILE để override thắng cascade ----------
     Áp dụng khi: (a) hệ thống tối VÀ người dùng chưa ép sáng — media query bên dưới;
     (b) người dùng bấm nút giao diện trên topbar (ép tối) — :root[data-theme="dark"].
     Nút + localStorage "motloi.theme.v1" do app.js quản lý; script inline trong <head>
     set data-theme sớm để không nháy màu khi tải.
     ⚠️ HAI BLOCK TOKEN DƯỚI ĐÂY PHẢI GIỮ GIỐNG NHAU — sửa một chỗ phải sửa cả hai. */
  :root[data-theme="dark"] {
    color-scheme: dark;
    /* nền & bề mặt — đảo tối, giữ tông sage */
    --sage-900: #d9e4db;   /* chữ tiêu đề (hero, verse-text) */
    --sage-700: #b3c4b8;   /* chữ chip / link / icon */
    --sage-600: #5f7566;   /* giữ nguyên — nền nút primary + badge (trắng vẫn 4.97:1) */
    --sage-500: #8fa393;   /* border focus + label sáng hơn */
    --sage-200: #3c4a41;   /* border sage */
    --sage-100: #2c3730;   /* nền chip / stop-btn / practice */
    --sage-050: #242d27;   /* nền takeaway, hover */
    --beige-050: #1b211d;  /* nền trang */
    --beige-100: #262d28;  /* nền nút ghost */
    --beige-200: #333c35;  /* border chính */
    --gray-600: #a8b0a6;   /* text thứ cấp */
    --gray-400: #7e877d;
    --ink: #e8ece7;        /* text chính */
    --ink-soft: #c2cbc2;   /* text phụ */
    --card: #222a24;       /* thẻ */
    --topbar-bg: rgba(27, 33, 29, 0.88);
    --input-focus-bg: #2a332c;
    --card-label-color: var(--sage-500);
    --accent-ink: #ffffff;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.28), 0 10px 30px rgba(0, 0, 0, 0.22);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.5);
    /* gradient thiệp bản tối — qua token, không hex cứng */
    --quote-grad-from: #50685a;
    --quote-grad-to: #233028;
  }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      color-scheme: dark;
      /* nền & bề mặt — đảo tối, giữ tông sage (giống block [data-theme="dark"] — giữ đồng bộ) */
      --sage-900: #d9e4db;   /* chữ tiêu đề (hero, verse-text) */
      --sage-700: #b3c4b8;   /* chữ chip / link / icon */
      --sage-600: #5f7566;   /* giữ nguyên — nền nút primary + badge (trắng vẫn 4.97:1) */
      --sage-500: #8fa393;   /* border focus + label sáng hơn */
      --sage-200: #3c4a41;   /* border sage */
      --sage-100: #2c3730;   /* nền chip / stop-btn / practice */
      --sage-050: #242d27;   /* nền takeaway, hover */
      --beige-050: #1b211d;  /* nền trang */
      --beige-100: #262d28;  /* nền nút ghost */
      --beige-200: #333c35;  /* border chính */
      --gray-600: #a8b0a6;   /* text thứ cấp */
      --gray-400: #7e877d;
      --ink: #e8ece7;        /* text chính */
      --ink-soft: #c2cbc2;   /* text phụ */
      --card: #222a24;       /* thẻ */
      --topbar-bg: rgba(27, 33, 29, 0.88);
      --input-focus-bg: #2a332c;
      --card-label-color: var(--sage-500);
      --shadow: 0 2px 10px rgba(0, 0, 0, 0.28), 0 10px 30px rgba(0, 0, 0, 0.22);
      --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.5);
      /* gradient thiệp bản tối — qua token, không hex cứng */
      --quote-grad-from: #50685a;
      --quote-grad-to: #233028;
    }
  }

  /* Nút cuộn nhanh xuống lượt trả lời AI mới nhất — fixed góc phải dưới,
     hiện khi lượt cuối ngoài viewport (hội thoại dài). */
  .jump-latest {
    position: fixed; right: 16px; bottom: 20px; z-index: 40;
    display: inline-flex; align-items: center; justify-content: center;
    width: 48px; height: 48px; border-radius: 50%;
    color: var(--accent-ink); background: var(--sage-600);
    border: none; box-shadow: var(--shadow-lg); cursor: pointer;
    transition: transform 0.15s, background 0.15s;
  }
  .jump-latest[hidden] { display: none; }  /* [hidden] bị display:inline-flex override — phải khôi phục */
  .jump-latest:hover { background: var(--sage-700); }
  .jump-latest:active { transform: scale(0.94); }
  .jump-latest svg { width: 22px; height: 22px; }
  /* An toàn khi modal mở — nút nằm dưới overlay */
  .modal-overlay.open ~ .jump-latest, .jump-latest:has(~ .modal-overlay.open) { display: none; }

  /* Focus ring tùy chỉnh (:focus-visible) — kiểm định 14/08/2026:
     hiển thị rõ khi điều hướng bàn phím, không nhấp nháy khi bấm chuột.
     sage-500: light 3.4:1 · dark 6.1:1 so với nền — đạt chuẩn chỉ báo focus (≥3:1). */
  :focus-visible {
    outline: 2px solid var(--sage-500);
    outline-offset: 2px;
  }
