button, [role="button"], select, summary, input:not([type="checkbox"], [type="radio"]) { min-height: 2.25rem; }

      :root {
        --bg: #f7f3ec;
        --surface: #fffdf8;
        --surface-2: #efe8da;
        --ink: #22302a;
        --ink-soft: #4c5a53;
        --line: #ddd2bd;
        --accent: #0e5c4c;
        --accent-ink: #ffffff;
        --gold: #a97b1f;
        --gold-soft: #f3e7c8;
        --danger: #a33327;
        --shadow: 0 10px 30px rgba(46, 38, 18, 0.10);
        --radius: 14px;
      }
      @media (prefers-color-scheme: dark) {
        :root {
          --bg: #131816;
          --surface: #1c2421;
          --surface-2: #242e2a;
          --ink: #ece7db;
          --ink-soft: #b3bcb4;
          --line: #39443e;
          --accent: #3fae94;
          --accent-ink: #0c1714;
          --gold: #d9ab4a;
          --gold-soft: #33301f;
          --danger: #e08a7d;
          --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
        }
      }

      * { box-sizing: border-box; }
      html { scroll-behavior: smooth; }
      body {
        margin: 0;
        background: var(--bg);
        color: var(--ink);
        font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
        line-height: 1.55;
        -webkit-font-smoothing: antialiased;
      }
      .wrap { max-width: 1060px; margin: 0 auto; padding: 20px 16px 56px; }
      h1, h2, h3, .serif { font-family: Georgia, "Noto Serif", "Times New Roman", serif; }
      h1 { font-size: clamp(1.7rem, 4.5vw, 2.5rem); line-height: 1.15; margin: 0 0 10px; font-weight: 700; }
      h2 { font-size: 1.35rem; margin: 0 0 12px; }
      h3 { font-size: 1.05rem; margin: 0 0 8px; }
      p { margin: 0 0 10px; }
      .lede { color: var(--ink-soft); max-width: 62ch; font-size: 1.02rem; }
      .offline-note {
        display: inline-flex; align-items: center; gap: 8px;
        background: var(--gold-soft); color: var(--ink);
        border: 1px solid var(--line); border-radius: 999px;
        padding: 6px 14px; font-size: 0.88rem; margin-top: 6px;
      }
      .offline-note svg { flex: none; }

      .layout { display: grid; grid-template-columns: 1fr; gap: 20px; margin-top: 24px; }
      @media (min-width: 880px) {
        .layout { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); align-items: start; }
        .sticky { position: sticky; top: 16px; }
      }

      .card {
        background: var(--surface);
        border: 1px solid var(--line);
        border-radius: var(--radius);
        box-shadow: var(--shadow);
        padding: 20px;
      }
      .card + .card { margin-top: 20px; }

      label.field { display: block; margin-bottom: 16px; }
      label.field > span { display: block; font-weight: 600; margin-bottom: 6px; font-size: 0.95rem; }
      label.field small { display: block; color: var(--ink-soft); font-weight: 400; margin-top: 4px; }
      input[type="text"], input[type="date"], input[type="search"] {
        width: 100%; padding: 10px 12px; font-size: 1rem;
        border: 1px solid var(--line); border-radius: 10px;
        background: var(--surface); color: var(--ink);
        font-family: inherit;
      }
      input:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
      .error { color: var(--danger); font-weight: 600; margin: 4px 0 12px; display: none; }
      .error.show { display: block; }

      .btn {
        display: inline-flex; align-items: center; justify-content: center; gap: 8px;
        border: 1px solid transparent; border-radius: 10px;
        padding: 10px 18px; font-size: 1rem; font-weight: 600;
        cursor: pointer; font-family: inherit; min-height: 44px;
        background: var(--surface-2); color: var(--ink);
      }
      .btn-primary { background: var(--accent); color: var(--accent-ink); width: 100%; }
      .btn-primary:active { transform: translateY(1px); }
      .btn-ghost { background: transparent; border-color: var(--line); }
      .btn-small { padding: 6px 12px; font-size: 0.9rem; min-height: 36px; }
      .btn-danger { color: var(--danger); }

      /* ---------- Kết quả ---------- */
      #result { display: none; margin-top: 24px; }
      #result.show { display: block; }
      .result-head { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
      .big-number {
        flex: none; width: 128px; height: 128px; border-radius: 50%;
        border: 3px solid var(--gold);
        background: var(--gold-soft);
        display: flex; flex-direction: column; align-items: center; justify-content: center;
        text-align: center;
      }
      .big-number .num { font-family: Georgia, "Noto Serif", serif; font-size: 3rem; line-height: 1; font-weight: 700; color: var(--accent); }
      .big-number .cap { font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); margin-top: 4px; padding: 0 8px; }
      .result-head .who { min-width: 220px; flex: 1; }
      .result-head .who .name { font-size: 1.5rem; font-weight: 700; font-family: Georgia, "Noto Serif", serif; }
      .result-head .who .dob { color: var(--ink-soft); }
      .archetype { font-size: 1.08rem; color: var(--accent); font-weight: 600; margin-top: 2px; }

      .num-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 12px; margin-top: 20px; }
      .num-cell {
        border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
        background: var(--surface); text-align: left; cursor: pointer; width: 100%;
        font-family: inherit; color: var(--ink);
      }
      .num-cell .n { font-family: Georgia, serif; font-size: 1.9rem; font-weight: 700; color: var(--accent); line-height: 1.1; }
      .num-cell .t { font-size: 0.85rem; color: var(--ink-soft); font-weight: 600; }
      .num-cell.active { border-color: var(--gold); background: var(--gold-soft); }
      .num-detail {
        margin-top: 14px; border: 1px solid var(--gold); border-radius: 12px;
        background: var(--gold-soft); padding: 16px; display: none;
      }
      .num-detail.show { display: block; }
      .num-detail .calc { font-size: 0.9rem; color: var(--ink-soft); margin-top: 8px; word-break: break-word; }

      .detail-section { margin-top: 26px; }
      .detail-section h3 { display: flex; align-items: center; gap: 8px; color: var(--accent); }
      .cols { display: grid; grid-template-columns: 1fr; gap: 16px; }
      @media (min-width: 700px) { .cols { grid-template-columns: 1fr 1fr; } }
      ul.tight { margin: 0; padding-left: 20px; }
      ul.tight li { margin-bottom: 5px; }
      .tag-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
      .tag { background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-size: 0.88rem; }

      .chart-wrap { display: flex; gap: 20px; flex-wrap: wrap; align-items: flex-start; }
      .birth-chart { display: grid; grid-template-columns: repeat(3, 56px); gap: 6px; }
      .birth-chart .cell {
        height: 56px; border: 1px solid var(--line); border-radius: 10px;
        display: flex; flex-direction: column; align-items: center; justify-content: center;
        background: var(--surface-2); color: var(--ink-soft);
      }
      .birth-chart .cell.present { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
      .birth-chart .cell .d { font-family: Georgia, serif; font-size: 1.25rem; font-weight: 700; line-height: 1; }
      .birth-chart .cell .c { font-size: 0.7rem; }
      .chart-notes { flex: 1; min-width: 240px; font-size: 0.95rem; }

      .calc-box {
        background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px;
        padding: 14px 16px; font-size: 0.93rem; margin-top: 10px;
      }
      .calc-box p { margin-bottom: 6px; }
      .calc-box p:last-child { margin-bottom: 0; }
      .calc-box b { color: var(--accent); }

      /* ---------- Lịch sử ---------- */
      .history-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
      .history-list { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
      .history-item {
        display: flex; align-items: center; gap: 12px; width: 100%;
        border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
        padding: 10px 12px; text-align: left; cursor: pointer; font-family: inherit; color: var(--ink);
      }
      .history-item:active { background: var(--surface-2); }
      .history-item .badge {
        flex: none; width: 46px; height: 46px; border-radius: 50%;
        border: 2px solid var(--gold); background: var(--gold-soft);
        display: flex; align-items: center; justify-content: center;
        font-family: Georgia, serif; font-weight: 700; font-size: 1.05rem; color: var(--accent);
      }
      .history-item .meta { flex: 1; min-width: 0; }
      .history-item .meta .nm { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
      .history-item .meta .sub { font-size: 0.85rem; color: var(--ink-soft); }
      .del-btn {
        flex: none; border: none; background: transparent; color: var(--danger);
        cursor: pointer; border-radius: 8px; padding: 8px; min-width: 40px; min-height: 40px;
        display: flex; align-items: center; justify-content: center;
      }
      .empty { color: var(--ink-soft); text-align: center; padding: 18px 8px; border: 1px dashed var(--line); border-radius: 12px; margin-top: 14px; }
      .confirm-bar {
        display: none; margin-top: 12px; border: 1px solid var(--danger); border-radius: 12px;
        padding: 12px 14px; align-items: center; gap: 10px; flex-wrap: wrap;
      }
      .confirm-bar.show { display: flex; }
      .confirm-bar span { flex: 1; min-width: 180px; }

      /* ---------- Tra cứu nhanh ---------- */
      .quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 10px; }
      .quick-btn {
        border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
        padding: 12px 6px; cursor: pointer; font-family: inherit; color: var(--ink); text-align: center;
      }
      .quick-btn .n { font-family: Georgia, serif; font-size: 1.6rem; font-weight: 700; color: var(--accent); display: block; line-height: 1.1; }
      .quick-btn .t { font-size: 0.78rem; color: var(--ink-soft); display: block; }
      .quick-btn.active { border-color: var(--gold); background: var(--gold-soft); }
      .quick-detail { margin-top: 16px; display: none; }
      .quick-detail.show { display: block; }

      table.letters { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
      table.letters th, table.letters td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; }
      table.letters th { background: var(--surface-2); font-family: Georgia, serif; color: var(--accent); }
      .table-scroll { overflow-x: auto; }

      /* ---------- Số trưởng thành & Tháp đỉnh cao ---------- */
      .maturity-box {
        display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap;
        border: 1px solid var(--gold); border-radius: 12px; background: var(--gold-soft); padding: 16px;
      }
      .maturity-box .m-num {
        flex: none; width: 72px; height: 72px; border-radius: 50%;
        border: 2px solid var(--gold); background: var(--surface);
        display: flex; align-items: center; justify-content: center;
        font-family: Georgia, serif; font-size: 1.9rem; font-weight: 700; color: var(--accent);
      }
      .maturity-box .m-body { flex: 1; min-width: 240px; }
      .maturity-box .calc { font-size: 0.9rem; color: var(--ink-soft); margin-top: 6px; }

      .pinnacle-grid { display: grid; grid-template-columns: 1fr; gap: 12px; margin-top: 14px; }
      @media (min-width: 700px) { .pinnacle-grid { grid-template-columns: 1fr 1fr; } }
      .pinnacle-card {
        border: 1px solid var(--line); border-radius: 12px; background: var(--surface); padding: 16px;
      }
      .pinnacle-card .p-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
      .pinnacle-card .p-num {
        flex: none; width: 58px; height: 58px; border-radius: 50%;
        border: 2px solid var(--gold); background: var(--gold-soft);
        display: flex; align-items: center; justify-content: center;
        font-family: Georgia, serif; font-size: 1.55rem; font-weight: 700; color: var(--accent);
      }
      .pinnacle-card .p-title { font-weight: 700; font-family: Georgia, "Noto Serif", serif; font-size: 1.02rem; line-height: 1.3; }
      .pinnacle-card .p-period { font-size: 0.86rem; color: var(--ink-soft); }
      .pinnacle-card .p-calc { font-size: 0.88rem; color: var(--ink-soft); margin-top: 8px; border-top: 1px dashed var(--line); padding-top: 8px; }
      .pinnacle-flow { display: flex; align-items: stretch; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
      .pinnacle-flow .step {
        flex: 1 1 120px; text-align: center; border: 1px solid var(--line); border-radius: 10px;
        background: var(--surface-2); padding: 8px 6px; font-size: 0.85rem;
      }
      .pinnacle-flow .step b { display: block; font-family: Georgia, serif; font-size: 1.25rem; color: var(--accent); }

      footer.note { margin-top: 28px; color: var(--ink-soft); font-size: 0.9rem; max-width: 70ch; }
      .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

      /* ---------- Bản online: ghi chú, banner cấu hình, đăng nhập ---------- */
      .online-note {
        display: inline-flex; align-items: center; gap: 8px;
        background: var(--gold-soft); color: var(--ink);
        border: 1px solid var(--line); border-radius: 999px;
        padding: 6px 14px; font-size: 0.88rem; margin-top: 6px;
      }
      .setup-banner {
        border: 1px solid var(--danger); border-radius: 12px;
        background: var(--gold-soft); padding: 14px 16px;
        margin-top: 16px; font-size: 0.95rem;
      }
      input[type="email"], input[type="password"] {
        width: 100%; padding: 10px 12px; font-size: 1rem;
        border: 1px solid var(--line); border-radius: 10px;
        background: var(--surface); color: var(--ink);
        font-family: inherit;
      }
      .auth-msg { color: var(--accent); font-weight: 600; margin: 4px 0 12px; }
      .auth-user { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
      .auth-user span { flex: 1; min-width: 180px; overflow-wrap: anywhere; }
