/* Sim Phong Thủy — 81数理 */
@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;600;700&family=Be+Vietnam+Pro:wght@400;500;600;700&display=swap');

:root {
    --bg: #0f1419;
    --surface: #1a222d;
    --surface2: #232d3b;
    --border: #2e3a4a;
    --text: #eef2f7;
    --muted: #8b9cb3;
    --red: #c41e3a;
    --red-light: rgba(196, 30, 58, 0.15);
    --gold: #d4a853;
    --gold-light: rgba(212, 168, 83, 0.12);
    --green: #34d399;
    --green-bg: rgba(52, 211, 153, 0.12);
    --amber: #fbbf24;
    --amber-bg: rgba(251, 191, 36, 0.12);
    --rose: #f87171;
    --rose-bg: rgba(248, 113, 113, 0.12);
    --radius: 16px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
    --font: 'Be Vietnam Pro', system-ui, sans-serif;
    --font-cn: 'Noto Serif SC', 'Songti SC', serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.65;
    min-height: 100vh;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 60% 45% at 15% 0%, rgba(196, 30, 58, 0.12), transparent),
        radial-gradient(ellipse 50% 40% at 90% 100%, rgba(212, 168, 83, 0.08), transparent);
    pointer-events: none;
    z-index: 0;
}

.app {
    max-width: 760px;
    margin: 0 auto;
    padding: 2rem 1.25rem 4rem;
    position: relative;
    z-index: 1;
}

/* Nav */
.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.top-nav a {
    color: var(--muted);
    text-decoration: none;
    font-size: 0.875rem;
    transition: color 0.2s;
}
.top-nav a:hover { color: var(--gold); }

/* Header */
.site-header {
    text-align: center;
    margin-bottom: 2rem;
}
.site-header .badge {
    display: inline-block;
    font-family: var(--font-cn);
    font-size: 0.8rem;
    letter-spacing: 0.15em;
    color: var(--gold);
    border: 1px solid rgba(212, 168, 83, 0.35);
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    margin-bottom: 0.75rem;
}
.site-header h1 {
    font-size: clamp(1.75rem, 5vw, 2.5rem);
    font-weight: 700;
    letter-spacing: -0.02em;
}
.site-header h1 em {
    font-style: normal;
    color: var(--red);
}
.site-header p {
    color: var(--muted);
    font-size: 0.925rem;
    margin-top: 0.4rem;
}

/* Input */
.input-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}
.input-row {
    display: flex;
    gap: 0.75rem;
}
.input-row input {
    flex: 1;
    padding: 0.95rem 1.1rem;
    font-size: 1.2rem;
    font-family: var(--font);
    letter-spacing: 0.06em;
    border: 2px solid var(--border);
    border-radius: 12px;
    background: var(--surface2);
    color: var(--text);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.input-row input::placeholder { color: #5a6a7e; letter-spacing: 0.03em; }
.input-row input:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 4px var(--gold-light);
}
.input-row input.error {
    border-color: var(--red);
    animation: shake 0.4s ease;
}
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}
.btn-primary {
    padding: 0.95rem 1.4rem;
    background: linear-gradient(135deg, var(--red), #9b1830);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-family: var(--font);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: transform 0.15s, box-shadow 0.2s;
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(196, 30, 58, 0.35);
}
.input-hint {
    color: var(--muted);
    font-size: 0.82rem;
    margin-top: 0.75rem;
    text-align: center;
}

/* Empty */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--muted);
}
.empty-icon {
    font-family: var(--font-cn);
    font-size: 3rem;
    color: var(--gold);
    opacity: 0.5;
    margin-bottom: 1rem;
}

.hidden { display: none !important; }

/* Result hero */
.hero-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.75rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.25rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}
.hero-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--red), var(--gold), var(--red));
}
.hero-phone {
    font-size: 1.05rem;
    color: var(--muted);
    letter-spacing: 0.08em;
    margin-bottom: 0.5rem;
}
.hero-last4 {
    font-size: 0.85rem;
    color: var(--gold);
    margin-bottom: 1rem;
}
.hero-number {
    font-size: 4rem;
    font-weight: 700;
    line-height: 1;
    font-family: var(--font-cn);
    color: var(--gold);
    margin: 0.25rem 0;
}
.hero-number small {
    font-size: 1.25rem;
    color: var(--muted);
    font-weight: 400;
}
.luck-badge {
    display: inline-block;
    padding: 0.35rem 1rem;
    border-radius: 999px;
    font-size: 0.875rem;
    font-weight: 600;
    margin: 0.75rem 0;
}
.luck-badge.luck-da-ji { background: var(--green-bg); color: var(--green); border: 1px solid rgba(52, 211, 153, 0.3); }
.luck-badge.luck-ji { background: var(--green-bg); color: #6ee7b7; border: 1px solid rgba(52, 211, 153, 0.2); }
.luck-badge.luck-ban { background: var(--amber-bg); color: var(--amber); border: 1px solid rgba(251, 191, 36, 0.3); }
.luck-badge.luck-xiong { background: var(--rose-bg); color: var(--rose); border: 1px solid rgba(248, 113, 113, 0.3); }

.hero-cn {
    font-family: var(--font-cn);
    font-size: 1.35rem;
    font-weight: 600;
    margin-top: 0.5rem;
}
.hero-vi {
    font-size: 1.05rem;
    color: var(--text);
    margin-top: 0.25rem;
}
.hero-tag {
    font-size: 0.85rem;
    color: var(--muted);
}

/* Sections */
.section-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.35rem 1.5rem;
    margin-bottom: 1rem;
}
.section-title {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--gold);
    margin-bottom: 1rem;
}

/* Calc steps */
.calc-steps {
    list-style: none;
    counter-reset: step;
}
.calc-steps li {
    counter-increment: step;
    padding: 0.65rem 0 0.65rem 2.25rem;
    position: relative;
    font-size: 0.925rem;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
}
.calc-steps li:last-child { border-bottom: none; }
.calc-steps li::before {
    content: counter(step);
    position: absolute;
    left: 0;
    top: 0.6rem;
    width: 1.5rem;
    height: 1.5rem;
    background: var(--gold-light);
    color: var(--gold);
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}
.calc-steps li strong { color: var(--text); }

/* Dual text */
.dual-block { margin-bottom: 1rem; }
.dual-block:last-child { margin-bottom: 0; }
.dual-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin-bottom: 0.35rem;
}
.dual-label.cn { color: var(--gold); font-family: var(--font-cn); text-transform: none; letter-spacing: 0.05em; }
.dual-text {
    font-size: 0.95rem;
    color: var(--text);
    line-height: 1.7;
}
.dual-text.cn {
    font-family: var(--font-cn);
    font-size: 1rem;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    overflow-x: auto;
    padding-bottom: 0.25rem;
}
.tab-btn {
    flex: 1;
    min-width: max-content;
    padding: 0.65rem 1rem;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--muted);
    font-family: var(--font);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}
.tab-btn.active {
    background: var(--red-light);
    border-color: rgba(196, 30, 58, 0.4);
    color: var(--text);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Table lookup */
.lookup-wrap {
    max-height: 420px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 12px;
}
.lookup-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}
.lookup-table th {
    position: sticky;
    top: 0;
    background: var(--surface2);
    padding: 0.65rem 0.75rem;
    text-align: left;
    font-weight: 600;
    color: var(--gold);
    border-bottom: 1px solid var(--border);
}
.lookup-table td {
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid rgba(46, 58, 74, 0.6);
    vertical-align: top;
}
.lookup-table tr {
    cursor: pointer;
    transition: background 0.15s;
}
.lookup-table tbody tr:hover { background: var(--surface2); }
.lookup-table tr.highlight { background: var(--gold-light); }
.lookup-table .num { font-weight: 700; color: var(--gold); width: 2.5rem; }
.lookup-table .luck-cell { white-space: nowrap; }

/* Method note */
.method-note {
    font-size: 0.85rem;
    color: var(--muted);
    line-height: 1.7;
    padding: 1rem;
    background: var(--surface2);
    border-radius: 12px;
    border-left: 3px solid var(--gold);
}
.method-note strong { color: var(--text); }

/* Detail from tailieu.txt */
.detail-card { min-height: 120px; }

.vi-detail.loading { min-height: 100px; }

.detail-skeleton {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    padding: 0.25rem 0;
}
.detail-skeleton span {
    display: block;
    height: 0.85rem;
    border-radius: 6px;
    background: linear-gradient(90deg, var(--surface2) 25%, #2a3544 50%, var(--surface2) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.2s infinite;
}
.detail-skeleton span:nth-child(1) { width: 92%; }
.detail-skeleton span:nth-child(2) { width: 100%; }
.detail-skeleton span:nth-child(3) { width: 78%; }

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.detail-fade-in {
    animation: detailIn 0.35s ease forwards;
}

@keyframes detailIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.detail-meta {
    margin-bottom: 1rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid var(--border);
}

.detail-que-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--gold);
    letter-spacing: 0.02em;
}

.detail-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-top: 0.55rem;
}

.detail-tag {
    display: inline-block;
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    background: var(--red-light);
    color: #fca5a5;
    border: 1px solid rgba(196, 30, 58, 0.25);
}

.detail-tag-sub {
    background: var(--gold-light);
    color: var(--gold);
    border-color: rgba(212, 168, 83, 0.3);
}

.detail-body p {
    font-size: 0.975rem;
    line-height: 1.85;
    color: var(--text);
    margin-bottom: 0.85rem;
    text-align: justify;
}
.detail-body p:last-child { margin-bottom: 0; }

.detail-placeholder {
    color: var(--muted);
    font-size: 0.9rem;
    font-style: italic;
}

/* Bát Cực Linh Số */
.magnetic-card {
    border-color: rgba(52, 211, 153, 0.2);
}

.mag-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.mag-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--green);
}

.mag-sub {
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 0.35rem;
    line-height: 1.5;
}

.mag-sub code {
    font-family: ui-monospace, monospace;
    color: var(--gold);
    font-size: 0.85em;
    word-break: break-all;
}

.mag-score-box {
    text-align: center;
    padding: 0.5rem 0.85rem;
    border-radius: 12px;
    min-width: 5rem;
    border: 1px solid var(--border);
}

.mag-score-box.mag-good { background: var(--green-bg); border-color: rgba(52, 211, 153, 0.35); }
.mag-score-box.mag-mid { background: var(--amber-bg); border-color: rgba(251, 191, 36, 0.35); }
.mag-score-box.mag-bad { background: var(--rose-bg); border-color: rgba(248, 113, 113, 0.35); }

.mag-score-num {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.1;
}

.mag-score-box.mag-good .mag-score-num { color: var(--green); }
.mag-score-box.mag-mid .mag-score-num { color: var(--amber); }
.mag-score-box.mag-bad .mag-score-num { color: var(--rose); }

.mag-score-label {
    font-size: 0.72rem;
    color: var(--muted);
    margin-top: 0.15rem;
}

.mag-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem 1.25rem;
    font-size: 0.82rem;
    color: var(--muted);
    margin-bottom: 1rem;
}

.mag-stats strong { color: var(--text); }

.mag-section { margin-bottom: 1.1rem; }

.mag-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--gold);
    margin-bottom: 0.55rem;
}

.mag-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.mag-chip {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    padding: 0.35rem 0.55rem;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.9rem;
    border: 1px solid var(--border);
    background: var(--surface2);
    min-width: 2.75rem;
}

.mag-chip small {
    font-size: 0.62rem;
    font-weight: 500;
    margin-top: 0.1rem;
    opacity: 0.85;
}

.mag-chip.mag-cat {
    background: var(--green-bg);
    border-color: rgba(52, 211, 153, 0.35);
    color: #6ee7b7;
}

.mag-chip.mag-hung {
    background: var(--rose-bg);
    border-color: rgba(248, 113, 113, 0.35);
    color: #fca5a5;
}

.mag-chip.mag-neutral {
    color: var(--muted);
    opacity: 0.7;
}

.mag-chip.mag-tail {
    box-shadow: 0 0 0 2px rgba(212, 168, 83, 0.35);
}

.mag-star-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(46, 58, 74, 0.5);
    font-size: 0.9rem;
}

.mag-star-row:last-child { border-bottom: none; }

.mag-star-name { font-weight: 600; }
.mag-cat-text { color: #6ee7b7; }
.mag-hung-text { color: #fca5a5; }

.mag-cn {
    font-family: var(--font-cn);
    font-weight: 400;
    color: var(--muted);
    font-size: 0.85em;
}

.mag-star-meta {
    font-size: 0.78rem;
    color: var(--muted);
    white-space: nowrap;
}

.mag-personality {
    font-size: 0.925rem;
    line-height: 1.75;
    color: var(--text);
}

.mag-warnings {
    list-style: none;
    margin: 0;
    padding: 0;
}

.mag-warnings li {
    font-size: 0.85rem;
    padding: 0.55rem 0.75rem;
    border-radius: 8px;
    margin-bottom: 0.45rem;
    line-height: 1.55;
}

.mag-note-good { background: var(--green-bg); color: #a7f3d0; }
.mag-note-warn { background: var(--rose-bg); color: #fecaca; }
.mag-note-info { background: var(--amber-bg); color: #fde68a; }

.mag-empty {
    color: var(--muted);
    font-size: 0.88rem;
}

.site-footer {
    text-align: center;
    margin-top: 2.5rem;
    font-size: 0.78rem;
    color: #5a6a7e;
    line-height: 1.6;
}

@media (max-width: 540px) {
    .input-row { flex-direction: column; }
    .btn-primary { width: 100%; }
    .hero-number { font-size: 3rem; }
}

/* Sim list page */
.app-wide { max-width: 920px; }

.list-intro { margin-bottom: 1.25rem; }

.criteria-list {
    list-style: none;
    margin-bottom: 0.85rem;
}
.criteria-list li {
    font-size: 0.88rem;
    color: var(--muted);
    padding: 0.2rem 0 0.2rem 1.1rem;
    position: relative;
}
.criteria-list li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: var(--green);
    font-size: 0.75rem;
}

.list-note {
    font-size: 0.9rem;
    color: var(--text);
    line-height: 1.7;
}
.list-note strong { color: var(--gold); }

.list-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    margin-bottom: 0.75rem;
    align-items: center;
}

.list-search {
    flex: 1 1 200px;
    min-width: 0;
    padding: 0.65rem 1rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.95rem;
}
.list-search:focus {
    outline: none;
    border-color: var(--gold);
}

.list-tabs {
    display: flex;
    gap: 0.35rem;
    background: var(--surface);
    padding: 0.25rem;
    border-radius: 10px;
    border: 1px solid var(--border);
}
.list-tab {
    border: none;
    background: transparent;
    color: var(--muted);
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.45rem 0.85rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.list-tab.active {
    background: var(--gold-light);
    color: var(--gold);
}
.list-tab:hover:not(.active) { color: var(--text); }

.list-select {
    padding: 0.55rem 0.75rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.85rem;
    cursor: pointer;
}

.list-count {
    font-size: 0.82rem;
    color: var(--muted);
    margin-bottom: 0.85rem;
}

.sim-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.sim-row {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.9rem 1rem;
    transition: border-color 0.2s;
}
.sim-row:hover { border-color: rgba(212, 168, 83, 0.35); }

.sim-row-top {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.35rem;
}
.sim-rank {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--muted);
    min-width: 1.8rem;
}
.sim-net {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    background: var(--surface2);
    color: var(--muted);
}
.sim-bcs {
    margin-left: auto;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
}
.sim-bcs-high { background: var(--green-bg); color: var(--green); }
.sim-bcs-mid { background: var(--amber-bg); color: var(--amber); }

.sim-number {
    display: block;
    width: 100%;
    text-align: left;
    border: none;
    background: none;
    font-family: var(--font);
    font-size: clamp(1.15rem, 4vw, 1.45rem);
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--gold);
    cursor: pointer;
    padding: 0.15rem 0;
    transition: opacity 0.2s;
}
.sim-number:hover { opacity: 0.85; }

.sim-row-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.75rem;
    margin-bottom: 0.35rem;
}
.sim-que {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text);
}
.sim-luck {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--green);
}

.sim-pairs {
    font-size: 0.8rem;
    color: var(--muted);
    margin-bottom: 0.5rem;
    line-height: 1.5;
}

.sim-row-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
}
.sim-tail {
    font-size: 0.78rem;
    color: var(--muted);
}
.sim-tail strong { color: var(--text); }

.sim-detail-link {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--gold);
    text-decoration: none;
}
.sim-detail-link:hover { text-decoration: underline; }

@media (max-width: 540px) {
    .list-toolbar { flex-direction: column; align-items: stretch; }
    .list-tabs { justify-content: center; }
    .sim-bcs { margin-left: 0; }
}
