/* ═══════════════════════════════════════════════════════════════════════════
   ĐẶT TÊN CHO BÉ · Mobile PWA (iOS & Android · 60fps · Zero Auto-Zoom)
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
    /* Chủ đề mặc định: Tab 1 Ngọc Lục Bảo & Hồng Phấn */
    --bg-page: #010d0f;
    --bg-shell: #031518;
    --bg-card: #062126;
    --bg-card-hover: #092d34;
    --bg-input: #021114;
    --bg-nav: #04181c;
    --bg-sheet: #04191d;

    --pri-1: #d1fae5;
    --pri-2: #6ee7c7;
    --pri-3: #34d3af;
    --pri-4: #10b981;
    --pri-soft: rgba(52, 211, 175, 0.14);
    --pri-border: rgba(52, 211, 175, 0.34);
    --pri-border-strong: rgba(110, 231, 199, 0.58);

    --acc-1: #ffd2e6;
    --acc-2: #ff85b3;
    --acc-soft: rgba(255, 133, 179, 0.14);
    --acc-border: rgba(255, 133, 179, 0.42);

    --text-main: #f0fdf9;
    --text-sec: #a7d4cc;
    --text-muted: #6b9a94;
    --border-subtle: rgba(148, 226, 213, 0.14);

    /* Màu Ngũ Hành (Tab 1) */
    --elem-kim: #f8fafc;
    --elem-moc: #86efac;
    --elem-thuy: #7dd3fc;
    --elem-hoa: #fda4af;
    --elem-tho: #fcd34d;

    --nav-height: 62px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-top: env(safe-area-inset-top, 0px);
}

/* Chủ đề Tab 2: Hồng Ngọc Lưu Ly & Xanh Băng */
body[data-active-tab="hoan-vi"] {
    --bg-page: #0d0309;
    --bg-shell: #150610;
    --bg-card: #220b19;
    --bg-card-hover: #2d0f22;
    --bg-input: #12040d;
    --bg-nav: #190712;
    --bg-sheet: #1b0814;

    --pri-1: #fce7f3;
    --pri-2: #f9a8d4;
    --pri-3: #f472b6;
    --pri-4: #db2777;
    --pri-soft: rgba(244, 114, 182, 0.15);
    --pri-border: rgba(244, 114, 182, 0.36);
    --pri-border-strong: rgba(249, 168, 212, 0.62);

    --acc-1: #e0f2fe;
    --acc-2: #38bdf8;
    --acc-soft: rgba(56, 189, 248, 0.14);
    --acc-border: rgba(56, 189, 248, 0.42);

    --text-main: #fff5fa;
    --text-sec: #e2b8ce;
    --text-muted: #a67891;
    --border-subtle: rgba(249, 168, 212, 0.16);
}

/* ── Reset & Khung Ứng Dụng ── */

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html {
    background: var(--bg-page);
    color: var(--text-main);
    font-family: 'Be Vietnam Pro', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    min-height: 100dvh;
    background: var(--bg-page);
    color: var(--text-main);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

body.sheet-open {
    overflow: hidden;
}

button, input, select {
    font-family: inherit;
    touch-action: manipulation;
}

/* Giữ cỡ chữ input/select >= 16px để chặn iOS Safari tự zoom màn hình */
input[type="text"], select {
    font-size: 16px;
}

.app-shell {
    width: 100%;
    max-width: 520px;
    min-height: 100dvh;
    margin: 0 auto;
    background: var(--bg-shell);
    padding: calc(10px + var(--safe-top)) 14px calc(var(--nav-height) + var(--safe-bottom) + 26px);
    position: relative;
}

@media (min-width: 560px) {
    .app-shell {
        border-left: 1px solid var(--border-subtle);
        border-right: 1px solid var(--border-subtle);
        box-shadow: 0 0 60px rgba(0, 0, 0, 0.72);
    }
}

.tab-view[hidden] {
    display: none;
}

/* ── Thanh Tiêu Đề Gọn Trên Cùng ── */

.app-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 6px 2px 12px;
}

.topbar-brand {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.topbar-eyebrow {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--pri-3);
}

.topbar-title {
    font-family: 'Noto Sans', 'Be Vietnam Pro', sans-serif;
    font-size: 1.28rem;
    font-weight: 900;
    letter-spacing: 0.6px;
    color: #ffffff;
    line-height: 1.15;
}

.btn-icon-reset {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    border: 1px solid var(--pri-border);
    background: var(--bg-card);
    color: var(--pri-2);
    font-size: 1.2rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color 0.15s ease, transform 0.12s ease;
}

.btn-icon-reset:active {
    background: var(--pri-soft);
    transform: scale(0.94);
}

/* ── Thẻ Ngày Sinh & Tên Tự Đặt (Chuyển nhánh gọn) ── */

.panel-card {
    background: var(--bg-card);
    border: 1px solid var(--pri-border);
    border-radius: 18px;
    padding: 12px;
    margin-bottom: 14px;
}

.panel-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding: 4px;
    background: var(--bg-input);
    border-radius: 12px;
    border: 1px solid var(--border-subtle);
    margin-bottom: 12px;
}

.panel-tab {
    position: relative;
    height: 38px;
    border: 1px solid transparent;
    border-radius: 9px;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.84rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    transition: background-color 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.panel-tab.is-active {
    background: var(--pri-soft);
    border-color: var(--pri-border);
    color: var(--pri-1);
}

.panel-tab.tab-accent.is-active {
    background: var(--acc-soft);
    border-color: var(--acc-border);
    color: var(--acc-1);
}

.subtab-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--acc-2);
    display: none;
}

.subtab-dot.is-on {
    display: inline-block;
}

.panel-pane[hidden] {
    display: none;
}

/* Ô nhập dạng viên nang */
.input-capsule {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 46px;
    padding: 0 10px 0 14px;
    border-radius: 99px;
    background: var(--bg-input);
    border: 1px solid var(--pri-border);
    transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.input-capsule:focus-within {
    border-color: var(--pri-2);
    box-shadow: 0 0 0 3px var(--pri-soft);
}

.input-capsule.capsule-accent {
    border-color: var(--acc-border);
}

.input-capsule.capsule-accent:focus-within {
    border-color: var(--acc-2);
    box-shadow: 0 0 0 3px var(--acc-soft);
}

.capsule-icon {
    color: var(--pri-3);
    font-size: 0.95rem;
    flex-shrink: 0;
}

.capsule-icon.icon-accent {
    color: var(--acc-2);
}

.input-capsule input {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: none;
    outline: none;
    color: #ffffff;
    font-weight: 700;
    letter-spacing: 0.6px;
}

.input-capsule input::placeholder {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 14.5px;
    letter-spacing: 0.2px;
}

.btn-input-clear {
    visibility: hidden;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.10);
    color: var(--text-sec);
    font-size: 0.80rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.btn-input-clear:active {
    background: rgba(251, 113, 133, 0.30);
    color: #fff;
}

.dob-warning {
    display: none;
    margin-top: 8px;
    padding: 7px 11px;
    border-radius: 10px;
    background: rgba(251, 113, 133, 0.14);
    border: 1px solid rgba(251, 113, 133, 0.40);
    color: #fda4af;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.4;
}

/* Biểu đồ 3×3 + Chú thích song song */
.chart-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
}

.birth-chart-frame {
    padding: 6px;
    border-radius: 12px;
    background: var(--bg-input);
    border: 1px solid var(--pri-border);
    flex-shrink: 0;
}

.birth-chart-frame.frame-accent {
    border-color: var(--acc-border);
}

.birth-chart-grid {
    display: grid;
    grid-template-columns: repeat(3, 56px);
    gap: 4px;
}

.chart-cell {
    height: 38px;
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Noto Sans', sans-serif;
    font-size: 0.84rem;
    font-weight: 800;
    letter-spacing: 0.2px;
    overflow: hidden;
    white-space: nowrap;
}

.chart-cell.has-present {
    border-color: var(--pri-border);
    background: var(--pri-soft);
}

.chart-cell.has-missing {
    border-color: rgba(253, 224, 71, 0.38);
}

.chart-cell.has-custom {
    border-color: var(--acc-border);
    background: var(--acc-soft);
}

.chart-cell.cell-dense {
    font-size: 0.72rem;
    letter-spacing: -0.2px;
}

.chart-cell.cell-very-dense {
    font-size: 0.62rem;
    letter-spacing: -0.4px;
}

.chart-num-ghost {
    color: var(--text-muted);
    opacity: 0.32;
    font-weight: 700;
}

.chart-num-present {
    color: #ffffff;
}

.chart-num-missing {
    color: #fde047;
    margin-left: 1px;
}

.chart-num-custom {
    color: var(--acc-2);
    margin-left: 1px;
}

.chart-legend {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.78rem;
    color: var(--text-sec);
    line-height: 1.3;
}

.legend-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
}

.legend-dot.present { background: #ffffff; }
.legend-dot.missing { background: #fde047; }
.legend-dot.custom-name { background: var(--acc-2); }
.text-custom-accent { color: var(--acc-1); }

.legend-tip {
    font-size: 0.71rem;
    color: var(--text-muted);
    line-height: 1.38;
    padding-top: 2px;
}

/* Thông tin Tên Tự Đặt */
.custom-name-info {
    display: none;
    margin-top: 11px;
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--bg-input);
    border: 1px solid var(--acc-border);
}

.custom-info-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

.custom-source-tag {
    font-size: 0.82rem;
    color: var(--text-sec);
}

.custom-source-tag strong {
    color: #ffffff;
}

.custom-info-badges {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.custom-meta-pill {
    font-size: 0.71rem;
    font-weight: 600;
    color: var(--text-sec);
    background: rgba(255, 255, 255, 0.06);
    padding: 3px 8px;
    border-radius: 99px;
}

.btn-custom-fav {
    min-height: 32px;
    padding: 4px 11px;
    border-radius: 99px;
    border: 1px solid var(--acc-border);
    background: var(--acc-soft);
    color: var(--acc-1);
    font-size: 0.76rem;
    font-weight: 700;
    cursor: pointer;
}

.btn-custom-fav.is-saved {
    background: var(--acc-2);
    border-color: var(--acc-2);
    color: #160510;
}

.custom-meaning-text {
    margin-top: 7px;
    font-size: 0.80rem;
    line-height: 1.48;
    color: var(--text-sec);
}

/* ── Ma Trận 9 Ô Số Pythagoras (Lưới 3×3 Cảm Ứng) ── */

.matrix-section {
    margin-bottom: 14px;
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
    padding: 0 2px;
}

.section-title {
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: var(--pri-2);
}

.total-pill {
    font-size: 0.76rem;
    color: var(--text-sec);
    background: var(--bg-card);
    border: 1px solid var(--pri-border);
    padding: 3px 10px;
    border-radius: 99px;
}

.total-pill strong {
    color: #ffffff;
    font-weight: 800;
}

.matrix-grid-3x3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.m-box {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    padding: 8px 6px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    transition: border-color 0.16s ease, background-color 0.16s ease;
}

.m-box.has-value {
    border-color: var(--pri-border-strong);
    background: var(--bg-card-hover);
}

.m-box-head {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 5px;
    width: 100%;
}

.m-num {
    font-family: 'Noto Sans', sans-serif;
    font-size: 1.05rem;
    font-weight: 900;
    color: var(--pri-2);
    line-height: 1;
}

.m-letters {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.3px;
}

.m-box.has-value .m-letters {
    color: var(--pri-1);
}

.m-stepper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 2px;
}

.m-step {
    width: 34px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--border-subtle);
    background: var(--bg-input);
    color: var(--pri-1);
    font-size: 1.1rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.m-step:active {
    background: var(--pri-soft);
    border-color: var(--pri-3);
}

.m-freq-input {
    flex: 1;
    min-width: 0;
    width: 24px;
    height: 36px;
    background: transparent;
    border: none;
    outline: none;
    text-align: center;
    color: #ffffff;
    font-weight: 800;
}

.m-freq-input::placeholder {
    color: var(--text-muted);
    opacity: 0.45;
}

.limit-hint {
    display: none;
    margin-top: 9px;
    padding: 7px 11px;
    border-radius: 10px;
    background: rgba(252, 211, 77, 0.12);
    border: 1px solid rgba(252, 211, 77, 0.36);
    color: #fde68a;
    font-size: 0.76rem;
    font-weight: 600;
    text-align: center;
}

/* Nút hành động chính */
.action-row-dual {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 12px;
}

.action-row-single {
    margin-top: 12px;
}

.btn-primary {
    width: 100%;
    min-height: 48px;
    padding: 11px 14px;
    border-radius: 14px;
    border: 1px solid transparent;
    color: #ffffff;
    font-size: 0.92rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    cursor: pointer;
    transition: transform 0.12s ease, opacity 0.15s ease;
}

.btn-primary:active {
    transform: scale(0.97);
}

.btn-emerald {
    background: linear-gradient(135deg, #10b981, #047857);
    border-color: rgba(110, 231, 199, 0.55);
}

.btn-rose {
    background: linear-gradient(135deg, #ec4899, #be185d);
    border-color: rgba(255, 133, 179, 0.55);
}

.btn-ruby {
    background: linear-gradient(135deg, #f472b6, #be185d);
    border-color: rgba(249, 168, 212, 0.60);
}

.btn-primary.is-active {
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35);
}

/* ── Khu Vực Tải & Kết Quả ── */

.loading-box {
    display: none;
    text-align: center;
    padding: 20px 12px;
    color: var(--pri-2);
    font-size: 0.86rem;
    font-weight: 700;
}

.results-section[hidden] {
    display: none;
}

.stale-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 12px;
    margin-bottom: 10px;
    border-radius: 12px;
    background: rgba(252, 211, 77, 0.12);
    border: 1px solid rgba(252, 211, 77, 0.42);
    color: #fde68a;
    font-size: 0.80rem;
    font-weight: 600;
}

.stale-banner[hidden] {
    display: none;
}

.btn-stale {
    min-height: 34px;
    padding: 5px 12px;
    border-radius: 99px;
    border: none;
    background: #fbbf24;
    color: #1f1402;
    font-size: 0.78rem;
    font-weight: 800;
    cursor: pointer;
    flex-shrink: 0;
}

.result-stats {
    font-size: 0.86rem;
    color: var(--text-sec);
    margin-bottom: 10px;
    line-height: 1.45;
    padding: 0 2px;
}

.result-stats strong {
    color: #ffffff;
}

.stats-sub {
    color: var(--text-muted);
    font-size: 0.78rem;
}

.empty-result-hint {
    margin-top: 4px;
    font-size: 0.80rem;
    color: var(--text-muted);
}

/* Thanh lọc kết quả tối ưu vuốt ngang */
.filter-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    padding: 11px;
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.filter-panel[hidden] {
    display: none;
}

.search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 42px;
    padding: 0 8px 0 13px;
    border-radius: 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
}

.search-bar:focus-within {
    border-color: var(--pri-3);
}

.search-ico {
    color: var(--text-muted);
    font-size: 1rem;
    flex-shrink: 0;
}

.search-bar input {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: none;
    outline: none;
    color: #ffffff;
    font-weight: 600;
}

.search-bar input::placeholder {
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
}

.chip-strip {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
}

.chip-strip::-webkit-scrollbar {
    display: none;
}

.chip-btn {
    min-height: 34px;
    padding: 5px 11px;
    border-radius: 99px;
    border: 1px solid var(--border-subtle);
    background: var(--bg-input);
    color: var(--text-sec);
    font-size: 0.78rem;
    font-weight: 700;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    flex-shrink: 0;
}

.chip-btn.is-active {
    background: var(--pri-soft);
    border-color: var(--pri-2);
    color: #ffffff;
}

.chip-btn.is-empty {
    opacity: 0.42;
}

.chip-cnt {
    font-size: 0.70rem;
    color: var(--text-muted);
    font-weight: 700;
}

.chip-btn.is-active .chip-cnt {
    color: var(--pri-1);
}

.toolbar-split {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

.seg-group {
    display: inline-flex;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 3px;
    gap: 2px;
}

.seg-btn {
    min-height: 32px;
    padding: 4px 10px;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.76rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
}

.seg-btn.is-active {
    background: var(--pri-soft);
    color: #ffffff;
}

.export-pair {
    display: inline-flex;
    gap: 6px;
}

.btn-mini-export {
    min-height: 34px;
    padding: 4px 11px;
    border-radius: 9px;
    border: 1px solid var(--pri-border);
    background: var(--bg-input);
    color: var(--pri-1);
    font-size: 0.75rem;
    font-weight: 800;
    cursor: pointer;
}

.btn-mini-export:active {
    background: var(--pri-soft);
}

/* ── Lưới Thẻ Kết Quả Tab 1 & Tab 2 ── */

.gm-results-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.gm-results-grid.is-compact {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.result-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    padding: 12px 13px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.card-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.card-meta-left {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.card-syl-tag {
    font-size: 0.70rem;
    font-weight: 700;
    color: var(--text-muted);
}

.badge-element {
    font-size: 0.69rem;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.08);
}

.badge-Kim { color: var(--elem-kim); border: 1px solid rgba(248, 250, 252, 0.35); }
.badge-Mộc { color: var(--elem-moc); border: 1px solid rgba(134, 239, 172, 0.40); }
.badge-Thủy { color: var(--elem-thuy); border: 1px solid rgba(125, 211, 252, 0.40); }
.badge-Hỏa { color: var(--elem-hoa); border: 1px solid rgba(253, 164, 175, 0.40); }
.badge-Thổ { color: var(--elem-tho); border: 1px solid rgba(252, 211, 77, 0.40); }

.btn-fav-heart {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid var(--border-subtle);
    background: var(--bg-input);
    color: var(--text-muted);
    font-size: 1.05rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.btn-fav-heart.is-saved {
    background: var(--acc-soft);
    border-color: var(--acc-2);
    color: var(--acc-2);
}

.result-name {
    font-size: 1.12rem;
    font-weight: 800;
    color: #ffffff;
    line-height: 1.25;
}

.result-meaning {
    font-size: 0.82rem;
    line-height: 1.5;
    color: var(--text-sec);
}

.gm-results-grid.is-compact .result-card {
    padding: 10px 10px;
}

.gm-results-grid.is-compact .result-name {
    font-size: 0.98rem;
}

.gm-results-grid.is-compact .result-meaning {
    display: none;
}

/* Lưới thẻ kết quả Tab 2 (2 cột gọn đẹp) */
.hv-results-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.hv-results-grid.is-updating {
    opacity: 0.55;
}

.name-tile {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 13px;
    padding: 9px 9px 9px 11px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    min-width: 0;
}

.tile-main {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.tile-idx {
    font-size: 0.66rem;
    font-weight: 700;
    color: var(--text-muted);
}

.tile-text {
    font-size: 0.94rem;
    font-weight: 800;
    color: #ffffff;
    word-break: break-word;
    line-height: 1.25;
}

.empty-notice {
    grid-column: 1 / -1;
    text-align: center;
    padding: 24px 14px;
    border-radius: 14px;
    background: var(--bg-card);
    border: 1px dashed var(--border-subtle);
    color: var(--text-sec);
    font-size: 0.84rem;
    line-height: 1.55;
}

.empty-actions {
    margin-top: 12px;
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-empty-act {
    min-height: 38px;
    padding: 7px 14px;
    border-radius: 99px;
    border: 1px solid var(--pri-border);
    background: var(--pri-soft);
    color: #ffffff;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
}

/* Xem thêm & Phân trang */
.load-more-row {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.load-more-row[hidden] {
    display: none;
}

.btn-secondary, .btn-ghost {
    min-height: 44px;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.84rem;
    font-weight: 700;
    cursor: pointer;
}

.btn-secondary {
    flex: 1;
    border: 1px solid var(--pri-border);
    background: var(--pri-soft);
    color: #ffffff;
}

.btn-ghost {
    border: 1px solid var(--border-subtle);
    background: var(--bg-card);
    color: var(--text-sec);
}

.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-top: 14px;
    padding: 10px;
    border-radius: 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
}

.pagination-bar[hidden] {
    display: none;
}

.page-btn {
    min-height: 38px;
    padding: 6px 12px;
    border-radius: 10px;
    border: 1px solid var(--pri-border);
    background: var(--bg-input);
    color: #ffffff;
    font-size: 0.80rem;
    font-weight: 700;
    cursor: pointer;
}

.page-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.page-info {
    font-size: 0.80rem;
    font-weight: 700;
    color: var(--pri-1);
    text-align: center;
    white-space: nowrap;
}

.page-size-select {
    min-height: 38px;
    padding: 4px 8px;
    border-radius: 10px;
    border: 1px solid var(--border-subtle);
    background: var(--bg-input);
    color: var(--text-sec);
    font-weight: 700;
}

/* ── Nút Lên Đầu Trang ── */

.btn-scroll-top {
    position: fixed;
    right: 16px;
    bottom: calc(var(--nav-height) + var(--safe-bottom) + 14px);
    z-index: 60;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--pri-border-strong);
    background: var(--bg-card);
    color: var(--pri-1);
    font-size: 1.15rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.55);
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    cursor: pointer;
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.btn-scroll-top.is-visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* ── Thanh Điều Hướng Đáy (Bottom Tab Bar) ── */

.bottom-nav {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: 0;
    width: 100%;
    max-width: 520px;
    z-index: 80;
    background: var(--bg-nav);
    border-top: 1px solid var(--pri-border);
    padding: 6px 10px calc(6px + var(--safe-bottom));
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.55);
}

.bnav-item {
    position: relative;
    min-height: 48px;
    border: 1px solid transparent;
    border-radius: 13px;
    background: transparent;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.bnav-item.is-active {
    background: var(--pri-soft);
    border-color: var(--pri-border);
    color: var(--pri-1);
}

.bnav-item.bnav-fav.has-items {
    color: var(--acc-1);
}

.bnav-icon {
    font-size: 1.05rem;
    line-height: 1;
}

.bnav-label {
    font-size: 0.71rem;
    font-weight: 800;
    letter-spacing: 0.2px;
}

.bnav-badge {
    position: absolute;
    top: 4px;
    right: calc(50% - 28px);
    min-width: 19px;
    height: 19px;
    padding: 0 5px;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.12);
    color: var(--text-sec);
    font-size: 0.68rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.bnav-fav.has-items .bnav-badge {
    background: var(--acc-2);
    color: #160510;
}

/* ── Ngăn Yêu Thích Dạng Bottom Sheet ── */

.sheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(0, 0, 0, 0.65);
}

.sheet-backdrop[hidden] {
    display: none;
}

.fav-sheet {
    position: fixed;
    left: 50%;
    bottom: 0;
    width: 100%;
    max-width: 520px;
    max-height: 82dvh;
    z-index: 110;
    background: var(--bg-sheet);
    border-top: 1px solid var(--pri-border-strong);
    border-radius: 22px 22px 0 0;
    display: flex;
    flex-direction: column;
    transform: translate(-50%, 105%);
    transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: 0 -14px 42px rgba(0, 0, 0, 0.75);
}

.fav-sheet.is-open {
    transform: translate(-50%, 0);
}

.sheet-handle-wrap {
    display: flex;
    justify-content: center;
    padding: 9px 0 3px;
}

.sheet-handle {
    width: 40px;
    height: 4px;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.24);
}

.sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 16px 12px;
    border-bottom: 1px solid var(--border-subtle);
}

.sheet-title-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sheet-heart {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--acc-soft);
    border: 1px solid var(--acc-border);
    color: var(--acc-2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.sheet-title {
    font-size: 0.96rem;
    font-weight: 800;
    color: #ffffff;
}

.sheet-sub {
    font-size: 0.74rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.btn-sheet-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border-subtle);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-sec);
    font-size: 0.90rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.sheet-body {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.fav-empty {
    text-align: center;
    padding: 34px 16px;
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1.55;
}

.fav-empty-ico {
    font-size: 2rem;
    color: var(--acc-2);
    opacity: 0.45;
    margin-bottom: 6px;
}

.fav-item {
    padding: 11px 12px;
    border-radius: 13px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    cursor: pointer;
}

.fav-item.is-selected {
    border-color: var(--acc-2);
    background: var(--acc-soft);
}

.fav-item-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 5px;
}

.fav-item-name {
    font-size: 1.05rem;
    font-weight: 800;
    color: #ffffff;
}

.fav-item-btns {
    display: inline-flex;
    gap: 6px;
    flex-shrink: 0;
}

.btn-fav-mini {
    min-height: 30px;
    padding: 4px 10px;
    border-radius: 99px;
    border: 1px solid var(--border-subtle);
    background: var(--bg-input);
    color: var(--text-sec);
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
}

.btn-fav-mini.copied {
    background: rgba(134, 239, 172, 0.20);
    border-color: rgba(134, 239, 172, 0.50);
    color: #86efac;
}

.fav-item-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.fav-type-tag {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--pri-2);
    background: var(--pri-soft);
    border: 1px solid var(--pri-border);
    padding: 2px 8px;
    border-radius: 99px;
}

.fav-item-meaning {
    margin-top: 6px;
    font-size: 0.78rem;
    line-height: 1.45;
    color: var(--text-sec);
}

.sheet-footer {
    padding: 10px 14px calc(12px + var(--safe-bottom));
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-nav);
    display: flex;
    gap: 8px;
}

.btn-sheet-share, .btn-sheet-copy, .btn-sheet-clear {
    min-height: 44px;
    padding: 9px 12px;
    border-radius: 12px;
    font-size: 0.80rem;
    font-weight: 800;
    cursor: pointer;
}

.btn-sheet-share {
    flex: 1.15;
    border: 1px solid var(--pri-border-strong);
    background: linear-gradient(135deg, var(--pri-4), var(--pri-3));
    color: #ffffff;
}

.btn-sheet-copy {
    flex: 1;
    border: 1px solid var(--pri-border);
    background: var(--pri-soft);
    color: var(--pri-1);
}

.btn-sheet-clear {
    border: 1px solid var(--border-subtle);
    background: var(--bg-card);
    color: var(--text-sec);
    padding: 9px 13px;
}

.btn-sheet-clear.is-confirming {
    background: #e11d48;
    border-color: #fb7185;
    color: #ffffff;
}

.btn-sheet-share:disabled, .btn-sheet-copy:disabled, .btn-sheet-clear:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* ── Thông Báo Nổi (Toast) ── */

.toast-container {
    position: fixed;
    top: calc(12px + var(--safe-top));
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 28px);
    max-width: 460px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 7px;
    pointer-events: none;
}

.toast-item {
    padding: 10px 14px;
    border-radius: 12px;
    background: var(--bg-card);
    border: 1px solid var(--pri-2);
    color: #ffffff;
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1.38;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.65);
    display: flex;
    align-items: center;
    gap: 8px;
}

.toast-item.toast-warn {
    border-color: rgba(251, 113, 133, 0.78);
    color: #ffe4e6;
}

.toast-item.is-leaving {
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity 0.16s ease, transform 0.16s ease;
}
