/* ===== 基础变量 ===== */
:root {
    --bg-deep: #0f0f12;
    --bg-card: #1a1a20;
    --bg-hover: #25252e;
    --border: #2e2e3a;
    --text-main: #e8e6e3;
    --text-dim: #9a9894;
    --text-muted: #6b6965;
    --accent-gold: #c9a84c;
    --accent-gold-light: #e0c878;
    --accent-red: #c85a5a;
    --accent-green: #5a9e6e;
    --accent-blue: #5a8ec8;
    --accent-purple: #8e5ac8;
    --radius: 10px;
    --shadow: 0 4px 20px rgba(0,0,0,0.4);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--bg-deep);
    color: var(--text-main);
    min-height: 100vh;
    overflow: hidden;
}

/* ===== 顶部导航 ===== */
.topbar {
    height: 56px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 32px;
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.logo-icon {
    font-size: 22px;
    color: var(--accent-gold);
}

.logo-text {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--text-main);
}

.logo-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(201,168,76,0.15);
    color: var(--accent-gold);
    border: 1px solid rgba(201,168,76,0.3);
}

/* 移动端汉堡菜单按钮 */
.mobile-menu-btn {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    margin-left: auto;
}

.mobile-menu-btn span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text-dim);
    border-radius: 1px;
    transition: all 0.25s;
}

.mobile-menu-btn.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}
.mobile-menu-btn.active span:nth-child(2) {
    opacity: 0;
}
.mobile-menu-btn.active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

.top-nav {
    display: flex;
    gap: 4px;
    flex: 1;
}

.top-nav a {
    padding: 7px 16px;
    border-radius: 6px;
    font-size: 14px;
    text-decoration: none;
    color: var(--text-dim);
    transition: all 0.2s;
    white-space: nowrap;
}

.top-nav a:hover:not(.disabled) {
    background: var(--bg-hover);
    color: var(--text-main);
}

.top-nav a.active {
    background: rgba(201,168,76,0.12);
    color: var(--accent-gold);
}

.top-nav a.disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.search-box {
    display: flex;
    gap: 6px;
    position: relative;
}

.search-box input {
    width: 220px;
    padding: 7px 12px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-deep);
    color: var(--text-main);
    font-size: 13px;
    outline: none;
}

.search-box input::placeholder { color: var(--text-muted); }

.search-box input:focus {
    border-color: var(--accent-gold);
}

.search-box button {
    padding: 7px 12px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-hover);
    color: var(--text-dim);
    cursor: pointer;
    font-size: 13px;
}

.search-box button:hover {
    border-color: var(--accent-gold);
    color: var(--accent-gold);
}

/* ===== 搜索结果下拉面板 ===== */
.search-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 420px;
    max-height: 520px;
    overflow-y: auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    z-index: 200;
    padding: 12px 0;
    display: none;
}

.search-dropdown.active {
    display: block;
}

.search-dropdown-header {
    padding: 0 16px 8px;
    font-size: 12px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}

.search-category {
    margin-bottom: 8px;
}

.search-category-title {
    padding: 6px 16px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--accent-gold);
    display: flex;
    align-items: center;
    gap: 6px;
}

.search-category-title::before {
    content: '';
    width: 3px;
    height: 12px;
    background: var(--accent-gold);
    border-radius: 2px;
}

.search-item {
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.15s;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.search-item:hover,
.search-item.selected {
    background: var(--bg-hover);
}

.search-item-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
    border: 1px solid;
}

.search-item-icon.star {
    background: rgba(201,168,76,0.12);
    color: var(--accent-gold);
    border-color: rgba(201,168,76,0.25);
}

.search-item-icon.aux {
    background: rgba(90,142,200,0.12);
    color: var(--accent-blue);
    border-color: rgba(90,142,200,0.25);
}

.search-item-icon.pattern {
    background: rgba(90,158,110,0.12);
    color: var(--accent-green);
    border-color: rgba(90,158,110,0.25);
}

.search-item-icon.sihua {
    background: rgba(142,90,200,0.12);
    color: var(--accent-purple);
    border-color: rgba(142,90,200,0.25);
}

.search-item-body {
    flex: 1;
    min-width: 0;
}

.search-item-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-item-desc {
    font-size: 12px;
    color: var(--text-dim);
    line-height: 1.5;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.search-item-tag {
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 3px;
    background: var(--bg-deep);
    color: var(--text-muted);
    margin-left: auto;
    flex-shrink: 0;
    white-space: nowrap;
}

.search-no-results {
    padding: 24px 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

.search-highlight {
    color: var(--accent-gold);
    font-weight: 700;
    background: rgba(201,168,76,0.15);
    padding: 0 2px;
    border-radius: 2px;
}

/* ===== 搜索结果页面 ===== */
.search-results-page .search-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.search-results-page .search-query {
    font-size: 22px;
    font-weight: 700;
    color: var(--accent-gold);
}

.search-results-page .search-count {
    font-size: 13px;
    color: var(--text-muted);
}

.search-result-card {
    cursor: pointer;
    transition: border-color 0.15s;
}

.search-result-card:hover {
    border-color: var(--accent-gold);
}

/* ===== 主布局 ===== */
.main-layout {
    display: flex;
    height: calc(100vh - 56px);
    margin-top: 56px;
}

/* ===== 左侧边栏 ===== */
.sidebar {
    width: 200px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    flex-shrink: 0;
    overflow-y: auto;
    padding: 16px 0;
    transition: transform 0.3s ease;
}

.sidebar-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 0 20px 12px;
}

.star-list {
    list-style: none;
}

.star-list li {
    padding: 10px 20px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.15s;
    border-left: 3px solid transparent;
}

.star-list li:hover {
    background: var(--bg-hover);
}

.star-list li.active {
    background: rgba(201,168,76,0.08);
    border-left-color: var(--accent-gold);
    color: var(--accent-gold);
}

.star-list li .star-tag {
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 3px;
    background: var(--bg-deep);
    color: var(--text-muted);
}

.star-list li.active .star-tag {
    background: rgba(201,168,76,0.15);
    color: var(--accent-gold);
}

.star-list li.no-data {
    opacity: 0.35;
    cursor: not-allowed;
}

/* ===== 右侧内容区 ===== */
.content {
    flex: 1;
    overflow-y: auto;
    padding: 28px 32px;
}

/* ===== 星曜头部 ===== */
.star-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.star-header .star-symbol {
    width: 64px; height: 64px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, rgba(201,168,76,0.2), rgba(201,168,76,0.05));
    border: 1px solid rgba(201,168,76,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: var(--accent-gold);
    flex-shrink: 0;
}

.star-header .star-info h1 {
    font-size: 26px;
    font-weight: 700;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.star-header .star-info .subtitle {
    font-size: 14px;
    color: var(--text-dim);
}

.star-header .star-tags {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.tag {
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 4px;
    font-weight: 500;
}

.tag-gold { background: rgba(201,168,76,0.15); color: var(--accent-gold); border: 1px solid rgba(201,168,76,0.25); }
.tag-blue { background: rgba(90,142,200,0.15); color: var(--accent-blue); border: 1px solid rgba(90,142,200,0.25); }
.tag-green { background: rgba(90,158,110,0.15); color: var(--accent-green); border: 1px solid rgba(90,158,110,0.25); }
.tag-red { background: rgba(200,90,90,0.15); color: var(--accent-red); border: 1px solid rgba(200,90,90,0.25); }

/* ===== 区块标题 ===== */
.section-title {
    font-size: 15px;
    font-weight: 700;
    margin: 28px 0 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-main);
}

.section-title .dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--accent-gold);
}

/* ===== 卡片 ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.card-item {
    background: var(--bg-deep);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 16px;
}

.card-item .label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.card-item .value {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-main);
}

/* ===== 象意区 ===== */
.meaning-box {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.meaning-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

.meaning-card .meaning-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.meaning-card .meaning-header h3 {
    font-size: 15px;
    font-weight: 700;
}

.meaning-card .meaning-header .school-tag {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    margin-left: auto;
}

.school-north { background: rgba(90,142,200,0.15); color: var(--accent-blue); }
.school-south { background: rgba(142,90,200,0.15); color: var(--accent-purple); }

.keywords {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 14px;
}

.keyword-tag {
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 4px;
    background: var(--bg-deep);
    border: 1px solid var(--border);
    color: var(--text-dim);
}

.meaning-body {
    font-size: 14px;
    line-height: 1.8;
    color: var(--text-dim);
}

.meaning-body strong {
    color: var(--text-main);
}

/* ===== 庙旺平陷表格 ===== */
.status-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    display: block;
    overflow-x: auto;
    white-space: nowrap;
}

.status-table th,
.status-table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.status-table th {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    background: var(--bg-deep);
}

.status-table tr:last-child td { border-bottom: none; }

.status-table tr:hover td { background: rgba(255,255,255,0.02); }

.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.status-miao { background: rgba(90,158,110,0.18); color: var(--accent-green); }
.status-wang { background: rgba(90,142,200,0.18); color: var(--accent-blue); }
.status-de { background: rgba(201,168,76,0.12); color: var(--accent-gold); }
.status-ping { background: rgba(154,152,148,0.12); color: var(--text-dim); }
.status-bude { background: rgba(200,120,60,0.15); color: #c8783c; }
.status-xian { background: rgba(200,90,90,0.15); color: var(--accent-red); }

/* ===== 四化 ===== */
.sihua-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
}

.sihua-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    text-align: center;
}

.sihua-card .sihua-icon {
    width: 48px; height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    font-size: 20px;
    font-weight: 700;
}

.sihua-lu .sihua-icon { background: rgba(201,168,76,0.15); color: var(--accent-gold); border: 1px solid rgba(201,168,76,0.3); }
.sihua-quan .sihua-icon { background: rgba(200,90,90,0.15); color: var(--accent-red); border: 1px solid rgba(200,90,90,0.3); }
.sihua-ke .sihua-icon { background: rgba(90,142,200,0.15); color: var(--accent-blue); border: 1px solid rgba(90,142,200,0.3); }
.sihua-ji .sihua-icon { background: rgba(154,152,148,0.12); color: var(--text-dim); border: 1px solid var(--border); }

.sihua-card h4 {
    font-size: 15px;
    margin-bottom: 8px;
}

.sihua-card p {
    font-size: 13px;
    color: var(--text-dim);
    line-height: 1.7;
}

/* ===== 组合 ===== */
.combo-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.combo-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 20px;
    align-items: start;
}

.combo-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--accent-gold);
}

.combo-model {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.combo-desc {
    font-size: 14px;
    color: var(--text-dim);
    line-height: 1.7;
}

/* ===== AI 断语 ===== */
.ai-box {
    background: linear-gradient(135deg, rgba(201,168,76,0.08), rgba(90,142,200,0.05));
    border: 1px solid rgba(201,168,76,0.2);
    border-radius: var(--radius);
    padding: 20px;
}

.ai-input {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.ai-chip {
    font-size: 12px;
    padding: 5px 12px;
    border-radius: 20px;
    background: var(--bg-deep);
    border: 1px solid var(--border);
    color: var(--text-dim);
}

.ai-output {
    font-size: 14px;
    line-height: 1.9;
    color: var(--text-main);
    padding: 14px 16px;
    background: var(--bg-deep);
    border-radius: 8px;
    border-left: 3px solid var(--accent-gold);
}

/* ===== 十二宫快速查看 ===== */
.palace-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.palace-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}

.palace-card h4 {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.palace-card .palace-status {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    margin-left: auto;
}

.palace-card .good { background: rgba(90,158,110,0.15); color: var(--accent-green); }
.palace-card .bad { background: rgba(200,90,90,0.15); color: var(--accent-red); }

.palace-card p {
    font-size: 13px;
    color: var(--text-dim);
    line-height: 1.7;
}

/* ===== 响应式 ===== */
@media (max-width: 900px) {
    .meaning-box { grid-template-columns: 1fr; }
    .sihua-grid { grid-template-columns: repeat(2, 1fr); }
    .palace-grid { grid-template-columns: 1fr; }
    .combo-item { grid-template-columns: 1fr; }
    .sidebar { width: 160px; }
    .search-dropdown { width: 340px; right: -40px; }
}

@media (max-width: 640px) {
    .search-box input { width: 140px; }
    .search-dropdown { width: 300px; right: -20px; }
}

/* ===== 新增模块样式 ===== */

/* 财富双栏响应式 */
@media (max-width: 900px) {
    .card > div[style*="grid-template-columns:1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
}

/* 性别比例条形图 */
.gender-bar {
    height: 8px;
    border-radius: 4px;
    background: var(--bg-deep);
    overflow: hidden;
    display: flex;
    margin-top: 6px;
}

.gender-bar-boy {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-blue), rgba(90,142,200,0.6));
    border-radius: 4px 0 0 4px;
}

.gender-bar-girl {
    height: 100%;
    background: linear-gradient(90deg, rgba(142,90,200,0.6), var(--accent-purple));
    border-radius: 0 4px 4px 0;
}

/* 就业方向分类卡片 */
.career-category {
    transition: transform 0.15s, box-shadow 0.15s;
}

.career-category:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

/* 性格状态列表 */
.personality-status {
    transition: background 0.15s;
}

.personality-status:hover {
    background: var(--bg-hover) !important;
}

/* 财富提示框 */
.wealth-tip {
    transition: border-color 0.2s;
}

.wealth-tip:hover {
    border-color: var(--accent-gold) !important;
}

/* 免责声明 */
.disclaimer-box {
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 滚动条美化 */
.content::-webkit-scrollbar,
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.content::-webkit-scrollbar-track,
.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.content::-webkit-scrollbar-thumb,
.sidebar::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.content::-webkit-scrollbar-thumb:hover,
.sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* 格局高亮动画 */
@keyframes highlight {
    0% { box-shadow: 0 0 0 0 rgba(201,168,76,0.4); }
    50% { box-shadow: 0 0 0 8px rgba(201,168,76,0.1); }
    100% { box-shadow: 0 0 0 0 rgba(201,168,76,0); }
}

/* ===== 收藏功能样式 ===== */
button[id^="favBtn-"]:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(200,90,90,0.2);
}

button[id^="favBtn-"]:active {
    transform: scale(0.95);
}

#content .card:has(button[onclick^="gotoFavorite"]) {
    transition: border-color 0.2s, transform 0.15s;
}
#content .card:has(button[onclick^="gotoFavorite"]):hover {
    border-color: var(--accent-gold);
    transform: translateX(4px);
}

@keyframes favPop {
    0% { transform: scale(1); }
    30% { transform: scale(1.2); }
    100% { transform: scale(1); }
}
.fav-pop {
    animation: favPop 0.3s ease;
}

#content .card:has(> div[style*="font-size:48px"]) {
    animation: fadeIn 0.5s ease;
}

/* =================================================================
   ========================= 移动端全面适配 =========================
   ================================================================= */

/* ===== 移动端底部导航栏 ===== */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    z-index: 200;
    justify-content: space-around;
    align-items: center;
    padding: 0 4px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.mobile-bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 8px;
    min-width: 56px;
    min-height: 44px;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.mobile-bottom-nav a .mb-icon {
    font-size: 18px;
    line-height: 1;
}

.mobile-bottom-nav a .mb-label {
    font-size: 10px;
}

.mobile-bottom-nav a.active {
    color: var(--accent-gold);
}

.mobile-bottom-nav a:active {
    background: var(--bg-hover);
}

/* ===== 移动端侧边栏浮动按钮 ===== */
.mobile-sidebar-fab {
    display: none;
    position: fixed;
    bottom: 72px;
    right: 16px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--accent-gold);
    color: var(--bg-deep);
    border: none;
    box-shadow: 0 4px 16px rgba(201,168,76,0.35);
    z-index: 85;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.mobile-sidebar-fab span {
    font-size: 18px;
    line-height: 1;
}

.mobile-sidebar-fab small {
    font-size: 9px;
    font-weight: 600;
}

.mobile-sidebar-fab:active {
    transform: scale(0.92);
    box-shadow: 0 2px 8px rgba(201,168,76,0.25);
}

/* ===== 侧边栏遮罩层 ===== */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 90;
    opacity: 0;
    transition: opacity 0.3s;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* ===== 手机端全面适配 ===== */
@media (max-width: 768px) {
    /* --- 基础调整 --- */
    html, body {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        height: auto;
    }


    /* --- 顶部导航栏 --- */
    .topbar {
        height: 52px;
        padding: 0 12px;
        gap: 8px;
    }

    .logo {
        gap: 6px;
    }

    .logo-icon {
        font-size: 20px;
    }

    .logo-text {
        font-size: 14px;
        letter-spacing: 0.5px;
    }

    .logo-badge {
        display: none;
    }

    /* 汉堡菜单按钮 */
    .mobile-menu-btn {
        display: flex;
    }

    /* 顶部导航变为下拉菜单 */
    .top-nav {
        position: fixed;
        top: 52px;
        left: 12px;
        right: 12px;
        background: var(--bg-card);
        border: 1px solid var(--border);
        border-radius: 12px;
        padding: 8px;
        flex-direction: column;
        gap: 2px;
        box-shadow: 0 8px 32px rgba(0,0,0,0.5);
        z-index: 150;
        display: none;
        max-height: 70vh;
        overflow-y: auto;
    }

    .top-nav.active {
        display: flex;
    }

    .top-nav a {
        padding: 12px 16px;
        font-size: 15px;
        border-radius: 8px;
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    /* 搜索框 */
    .search-box {
        display: none;
    }

    /* --- 主布局 --- */
    .main-layout {
        display: block;
        height: auto;
        min-height: auto;
        margin-top: 52px;
        margin-bottom: 56px;
    }

    /* --- 左侧边栏 → 抽屉式 --- */
    .sidebar {
        position: fixed;
        top: 52px;
        left: 0;
        bottom: 56px;
        width: 75vw;
        max-width: 280px;
        z-index: 95;
        transform: translateX(-100%);
        border-right: 1px solid var(--border);
        box-shadow: 4px 0 20px rgba(0,0,0,0.5);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .sidebar-title {
        padding: 16px 16px 12px;
        font-size: 12px;
    }

    .star-list li {
        padding: 14px 16px;
        font-size: 15px;
        min-height: 44px;
    }

    /* --- 内容区 --- */
    .content {
        padding: 16px;
        width: 100%;
        flex: none;
        display: block;
        overflow-y: visible;
    }

    /* --- 星曜头部 --- */
    .star-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 14px;
        margin-bottom: 16px;
        padding-bottom: 16px;
    }

    .star-header .star-symbol {
        width: 52px;
        height: 52px;
        font-size: 24px;
    }

    .star-header .star-info h1 {
        font-size: 22px;
        gap: 8px;
    }

    .star-header .star-info .subtitle {
        font-size: 13px;
    }

    /* --- 区块标题 --- */
    .section-title {
        font-size: 14px;
        margin: 20px 0 10px;
    }

    /* --- 卡片 --- */
    .card {
        padding: 14px;
        margin-bottom: 12px;
        border-radius: 10px;
    }

    .card-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .card-item {
        padding: 12px 14px;
    }

    .card-item .value {
        font-size: 14px;
    }

    /* --- 象意区 --- */
    .meaning-box {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .meaning-card {
        padding: 14px;
    }

    .meaning-card .meaning-header {
        padding-bottom: 10px;
        margin-bottom: 10px;
    }

    .meaning-card .meaning-header h3 {
        font-size: 14px;
    }

    .meaning-body {
        font-size: 13px;
        line-height: 1.7;
    }

    /* --- 表格 --- */
    .status-table {
        font-size: 12px;
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 8px;
    }

    .status-table th,
    .status-table td {
        padding: 10px 12px;
        white-space: nowrap;
    }

    .status-badge {
        font-size: 11px;
        padding: 2px 8px;
    }

    /* --- 四化 --- */
    .sihua-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .sihua-card {
        padding: 14px;
    }

    .sihua-card .sihua-icon {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }

    .sihua-card h4 {
        font-size: 14px;
    }

    .sihua-card p {
        font-size: 12px;
    }

    /* --- 组合 --- */
    .combo-item {
        grid-template-columns: 1fr;
        padding: 14px;
        gap: 10px;
    }

    .combo-name {
        font-size: 14px;
    }

    .combo-desc {
        font-size: 13px;
    }

    /* --- AI 断语 --- */
    .ai-box {
        padding: 14px;
    }

    .ai-chip {
        font-size: 11px;
        padding: 4px 10px;
    }

    .ai-output {
        font-size: 13px;
        padding: 12px;
    }

    /* --- 十二宫 --- */
    .palace-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .palace-card {
        padding: 12px;
    }

    .palace-card h4 {
        font-size: 13px;
    }

    .palace-card p {
        font-size: 12px;
    }

    /* --- 标签 --- */
    .tag {
        font-size: 11px;
        padding: 3px 8px;
    }

    /* --- 关键词 --- */
    .keyword-tag {
        font-size: 11px;
        padding: 3px 8px;
    }

    /* --- 收藏按钮 --- */
    button[id^="favBtn-"] {
        min-height: 40px;
        padding: 8px 16px !important;
        font-size: 14px !important;
    }

    /* --- 搜索结果下拉 --- */
    .search-dropdown {
        position: fixed;
        top: 52px;
        left: 8px;
        right: 8px;
        width: auto;
        max-height: calc(100vh - 120px);
        border-radius: 12px;
    }

    .search-item {
        padding: 12px 14px;
    }

    .search-item-icon {
        width: 36px;
        height: 36px;
    }

    /* --- 侧边栏浮动按钮显示 --- */
    .mobile-sidebar-fab {
        display: flex;
    }

    /* --- 底部导航栏显示 --- */
    .mobile-bottom-nav {
        display: flex;
    }

    /* --- 搜索页面移动端优化 --- */
    .search-results-page .search-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        margin-bottom: 16px;
        padding-bottom: 12px;
    }

    .search-results-page .search-query {
        font-size: 18px;
    }

    /* --- FAQ页面移动端 --- */
    .faq-card {
        padding: 14px;
    }

    .faq-question {
        font-size: 15px;
    }

    .faq-answer {
        font-size: 13px;
    }

    /* --- 人话总结卡片 --- */
    .card[style*="border-left:3px solid var(--accent-gold)"] > div[style*="display:grid"] {
        grid-template-columns: 1fr !important;
    }

    /* --- 性别比例条 --- */
    .gender-bar {
        height: 6px;
    }

    /* --- 格局卡片 --- */
    .card[id^="pattern-"] > div[style*="display:flex"] {
        flex-direction: column !important;
        gap: 10px !important;
    }

    .card[id^="pattern-"] > div[style*="display:grid"] {
        grid-template-columns: 1fr !important;
    }

    /* --- 触摸优化 --- */
    a, button, .star-list li, .search-item {
        -webkit-tap-highlight-color: transparent;
    }

    /* 移除 hover 效果（移动端不需要） */
    .star-list li:hover,
    .search-item:hover,
    .search-result-card:hover,
    .career-category:hover,
    .personality-status:hover {
        background: none;
        transform: none;
        box-shadow: none;
    }

    /* 激活态替代 hover */
    .star-list li:active,
    .search-item:active,
    .card:active {
        background: var(--bg-hover);
    }
}

/* ===== 超小屏手机（< 380px）额外优化 ===== */
@media (max-width: 380px) {
    .logo-text {
        font-size: 12px;
    }

    .mobile-bottom-nav a .mb-label {
        font-size: 9px;
    }

    .mobile-bottom-nav a .mb-icon {
        font-size: 16px;
    }

    .content {
        padding: 12px;
    }

    .star-header .star-info h1 {
        font-size: 20px;
    }

    .section-title {
        font-size: 13px;
    }

    .card {
        padding: 12px;
    }

    .status-table th,
    .status-table td {
        padding: 8px 10px;
        font-size: 11px;
    }
}
