/* ==================== 全局变量 ==================== */
:root {
    --primary: #0ea5e9;
    --primary-dark: #0284c7;
    --primary-light: #e0f2fe;
    --primary-hover: #0369a1;
    --accent: #06b6d4;
    --text: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --bg: #f8fafc;
    --bg-card: #ffffff;
    --bg-elevated: #ffffff;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 25px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.05);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --header-h: 60px;
    --font-mono: 'JetBrains Mono', 'SF Mono', 'Monaco', monospace;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
}

[data-theme="dark"] {
    --primary: #38bdf8;
    --primary-dark: #0ea5e9;
    --primary-light: #0c4a6e;
    --primary-hover: #7dd3fc;
    --accent: #22d3ee;
    --text: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: #1e293b;
    --bg: #0f172a;
    --bg-card: #1e293b;
    --bg-elevated: #1e293b;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow: 0 1px 3px rgba(0,0,0,0.4);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.5);
}

/* ==================== 重置 ==================== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

#app { flex: 1; display: flex; flex-direction: column; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ==================== Header ==================== */
.header {
    height: var(--header-h);
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    background: color-mix(in srgb, var(--bg-elevated) 85%, transparent);
}

.header-inner {
    height: 100%;
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 24px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    flex-shrink: 0;
}

.logo-text { font-size: 19px; font-weight: 700; color: var(--text); letter-spacing: -0.3px; }
.logo-sub { font-weight: 400; color: var(--primary); font-size: 13px; margin-left: 2px; }

.header-nav { display: flex; gap: 4px; }

.header-nav a {
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    padding: 7px 14px;
    border-radius: var(--radius-xs);
    transition: all var(--transition);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.header-nav a:hover { background: var(--primary-light); color: var(--primary); text-decoration: none; }

.header-actions-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.theme-toggle {
    background: none;
    border: 0 solid var(--border);
    border-radius: var(--radius-xs);
    padding: 7px;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    transition: all var(--transition);
}
.theme-toggle:hover { border-color: var(--primary); color: var(--primary); }
.icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }

.user-section { position: relative; }
.login-link {
    font-size: 13px; color: var(--text-secondary); text-decoration: none;
    transition: color var(--transition); white-space: nowrap; padding: 4px 6px;
}
.login-link:hover { color: var(--primary); text-decoration: none; }
.user-info { display: flex; align-items: center; gap: 4px; cursor: pointer; position: relative; padding: 4px 8px; border-radius: var(--radius-xs); transition: background var(--transition); }
.user-info:hover { background: var(--primary-light); }
.user-info::after { content: ''; position: absolute; top: 100%; left: 0; right: 0; height: 4px; }
.user-avatar { width: 28px; height: 28px; margin-right: 4px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border); }
.user-name { font-size: 13px; color: var(--text-primary); max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-dropdown { display: none; position: absolute; top: 100%; right: 0; margin-top: 0; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: 0 4px 12px rgba(0,0,0,0.1); min-width: 100px; z-index: 100; }
.user-info:hover .user-dropdown { display: block; }
.user-dropdown a { display: block; padding: 8px 16px; font-size: 13px; color: var(--text-primary); text-decoration: none; transition: background var(--transition); }
.user-dropdown a:hover { background: var(--primary-light); color: var(--primary); }

.mobile-menu-btn {
    display: none;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    padding: 6px;
    cursor: pointer;
    color: var(--text-secondary);
}

.mobile-nav {
    display: none;
    position: fixed;
    top: var(--header-h);
    left: 0; right: 0;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    padding: 12px;
    z-index: 99;
    flex-direction: column;
    gap: 4px;
    box-shadow: var(--shadow-lg);
}
.mobile-nav.open { display: flex; }
.mobile-nav a {
    text-decoration: none;
    color: var(--text-secondary);
    padding: 10px 16px;
    border-radius: var(--radius-xs);
    font-weight: 500;
}
.mobile-nav a:hover { background: var(--primary-light); color: var(--primary); text-decoration: none; }

/* ==================== Pages ==================== */
.page { display: none; }
.page.active { display: block; }

.page.active#page-home {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
}

.footer.hidden { display: none; }

.container { max-width: 1200px; width: 100%; margin: 0 auto; padding: 24px; }

.page-header {
    display: flex;
    align-items: center;
    margin-bottom: 28px;
    flex-wrap: wrap;
}
.page-header h2 { font-size: 22px; font-weight: 700; letter-spacing: -0.3px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.header-actions { margin-left: auto; display: flex; gap: 8px; position: relative; flex-wrap: nowrap; flex-shrink: 0; }

.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 0;
    padding: 4px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    transition: color var(--transition);
}
.back-btn:hover { color: var(--primary); }
.back-btn svg { width: 18px; height: 18px; }

.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all var(--transition);
}
.action-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }

/* ==================== Hero ==================== */
.hero {
    max-width: 780px;
    width: 100%;
    padding: 0 24px;
    text-align: center;
}

.hero-title {
    font-size: 32px;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 8px;
    letter-spacing: -0.5px;
    line-height: 1.2;
}

.hero-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 24px;
    line-height: 1.5;
}

/* ==================== Search Box ==================== */
.search-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    padding: 20px;
}

.search-body {
    display: flex;
    align-items: center;
    padding: 0;
    gap: 0;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    overflow: hidden;
    transition: all var(--transition);
}
.search-body:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(14,165,233,0.12);
}

.search-input-group { flex: 1; position: relative; display: flex; align-items: center; }

.search-input-group input {
    width: 100%;
    padding: 14px 40px 14px 20px;
    border: none;
    border-radius: 0;
    font-size: 15px;
    font-family: inherit;
    color: var(--text);
    background: var(--bg);
    transition: all var(--transition);
}
.search-input-group input:focus { outline: none; }
.search-input-group input::placeholder { color: var(--text-muted); }

.search-clear {
    position: absolute;
    right: 12px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all var(--transition);
}
.search-clear:hover { color: var(--text); background: var(--border); }

.search-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 14px 32px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 0;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    flex-shrink: 0;
    height: 100%;
}
.search-btn:hover { background: var(--primary-dark); }
.search-btn:active { background: var(--primary-dark); }

.quick-links {
    margin-top: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.quick-label { font-size: 13px; color: var(--text-muted); font-weight: 500; }

.quick-chips {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

.quick-chips a {
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    padding: 6px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    cursor: pointer;
    transition: all var(--transition);
}

.quick-chips a:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
    transform: translateY(-1px);
}

/* ==================== Feature Cards ==================== */
.feature-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-top: 28px;
}

.feature-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 16px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
}

.feature-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.feature-icon { margin-bottom: 8px; }
.feature-icon svg { width: 34px; height: 34px; display: block; margin: 0 auto; }
.feature-title { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.feature-desc { font-size: 12px; color: var(--text-muted); line-height: 1.4; }

/* ==================== Results Grid ==================== */
.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
}

.result-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
}
.result-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
    transform: translateY(-2px);
}

.result-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.result-cid {
    font-size: 17px;
    font-weight: 700;
    color: var(--primary);
}

.result-formula {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    font-family: var(--font-mono);
}

.result-weight { font-size: 13px; color: var(--text-muted); margin-bottom: 10px; }

.result-smiles {
    font-size: 12px;
    font-family: var(--font-mono);
    color: var(--text-muted);
    background: var(--bg);
    padding: 8px 10px;
    border-radius: var(--radius-xs);
    word-break: break-all;
    line-height: 1.5;
    margin-bottom: 8px;
    border: 1px solid var(--border);
}

.result-inchikey {
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--text-muted);
}

.result-name {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
}

/* ==================== Pagination ==================== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    margin-top: 28px;
    flex-wrap: wrap;
}

.pagination button {
    padding: 8px 13px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    color: var(--text);
    transition: all var(--transition);
}
/* 悬停态需排除 .active：否则激活项悬停时文字被悬停色覆盖，蓝字配蓝底不可见 */
.pagination button:hover:not(:disabled):not(.active) { border-color: var(--primary); color: var(--primary); }
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination button:disabled { opacity: 0.35; cursor: not-allowed; }

.pagination-info { font-size: 13px; color: var(--text-muted); margin: 0 10px; }

/* ==================== Detail Page ==================== */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.detail-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
}

.detail-card.full-width { grid-column: 1 / -1; }

.detail-card h3 {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 9px 0;
    border-bottom: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
    gap: 12px;
}
.detail-row:last-child { border-bottom: none; }

.detail-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
    flex-shrink: 0;
    min-width: 110px;
}

.detail-value {
    font-size: 13px;
    color: var(--text);
    text-align: right;
    word-break: break-all;
    font-family: var(--font-mono);
    font-weight: 500;
}

.detail-value.copyable {
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all var(--transition);
}
.detail-value.copyable:hover { background: var(--primary-light); color: var(--primary); }

.structure-canvas-container {
    text-align: center;
    padding: 16px;
    background: #ffffff;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

#structure-canvas {
    /* 固定 400x300（原 canvas 尺寸）：加载前就占位防跳动，卡片高度与右侧信息卡匹配不空旷；
       源图 600x600 正方形，object-fit:contain 装入 4:3 框，居中不变形 */
    width: 400px;
    height: 300px;
    max-width: 100%;
    object-fit: contain;
}

/* 2D/3D 视图切换 */
.structure-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 8px;
    margin-bottom: 12px;
}
.structure-head h3 { margin: 0; border-bottom: none; padding-bottom: 0; }
.struct-tabs { display: flex; gap: 6px; }
.struct-tab {
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text-secondary);
    font-size: 13px; font-weight: 600;
    padding: 4px 14px;
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.15s;
}
/* 悬停态需排除 .active：否则激活的 2D/3D 标签悬停（含移动端点按后的粘滞悬停）时蓝字配蓝底不可见 */
.struct-tab:hover:not(:disabled):not(.active) { border-color: var(--primary); color: var(--primary); }
.struct-tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.struct-tab:disabled { opacity: 0.4; cursor: not-allowed; }

/* 3D 模型样式切换工具条（球棍/棒状/线框/空间填充 + 氢原子显隐） */
.struct-3d-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 18px;
    margin: 2px 0 8px;
    font-size: 13px;
}
/* 自绘 radio/checkbox（参考 Ant Design / Element 风格）：
   隐藏原生控件外观，未选=描边，选中=主题色（radio 内实心圆点 / checkbox 白色对勾） */
.struct-3d-toolbar label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    color: var(--text);
    user-select: none;
}
.struct-3d-toolbar label input {
    appearance: none;
    -webkit-appearance: none;
    position: relative;
    margin: 0;
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
    border: 1.5px solid var(--border);
    background: var(--bg-card);
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
.struct-3d-toolbar label:hover input:not(:checked) {
    border-color: var(--primary);
}
/* radio：圆形，选中=主题色描边 + 内实心圆点 */
.struct-3d-toolbar input[type="radio"] {
    border-radius: 50%;
}
.struct-3d-toolbar input[type="radio"]:checked {
    border-color: var(--primary);
}
.struct-3d-toolbar input[type="radio"]:checked::after {
    content: '';
    position: absolute;
    inset: 3px;
    border-radius: 50%;
    background: var(--primary);
}
/* checkbox：圆角方形，选中=主题色实底 + 白色对勾 */
.struct-3d-toolbar input[type="checkbox"] {
    border-radius: 4px;
}
.struct-3d-toolbar input[type="checkbox"]:checked {
    background: var(--primary);
    border-color: var(--primary);
}
.struct-3d-toolbar input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.structure-3d-container {
    /* 定位锚点：3Dmol 的 canvas 是 absolute 定位，必须让它锚定本容器而非外层
       （外层 structure-canvas-container 也是 relative，若此处不设，canvas 会盖住顶部工具条） */
    position: relative;
    width: 100%; height: 300px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    /* 加载中/失败提示在 3D 容器内居中显示 */
    display: flex;
    align-items: center;
    justify-content: center;
}
.struct-3d-retry {
    margin-top: 10px;
    border: none;
    background: var(--primary);
    color: #fff;
    font-size: 13px;
    padding: 6px 18px;
    border-radius: 999px;
    cursor: pointer;
}

.structure-placeholder {
    padding: 60px 20px;
    color: #64748b;
    font-size: 14px;
}

.cas-tags { display: flex; flex-wrap: wrap; gap: 8px; }

.cas-tag {
    display: inline-block;
    padding: 4px 12px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 6px;
    font-size: 13px;
    font-family: var(--font-mono);
    font-weight: 600;
}
.cas-tag-primary {
    background: var(--primary);
    color: #fff;
}

.cas-empty { color: var(--text-muted); font-size: 13px; }

/* ==================== Advanced Form ==================== */
.advanced-form {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.form-section {
    padding: 24px;
    border-bottom: 1px solid var(--border);
}
.form-section:last-of-type { border-bottom: none; }

.form-section h3 {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 18px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 14px;
}
.form-row:last-child { margin-bottom: 0; }

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: var(--bg);
    transition: all var(--transition);
}
.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(14,165,233,0.1);
}

.range-input {
    display: flex;
    align-items: center;
    gap: 8px;
}
.range-input input { flex: 1; }
.range-input span { color: var(--text-muted); font-size: 14px; flex-shrink: 0; }

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
}
.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.form-actions {
    padding: 20px 24px;
    display: flex;
    gap: 10px;
    border-top: 1px solid var(--border);
    background: var(--bg);
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 24px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-xs);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
    padding: 10px 24px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all var(--transition);
}
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }

/* ==================== Batch Page ==================== */
.batch-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.batch-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
}

.batch-tab {
    flex: 1;
    padding: 14px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    transition: all var(--transition);
}
.batch-tab:hover { color: var(--text-secondary); }
.batch-tab.active { color: var(--primary); border-bottom-color: var(--primary); background: var(--primary-light); }

.batch-body { padding: 20px; }

.batch-input-area textarea {
    width: 100%;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    font-size: 14px;
    font-family: var(--font-mono);
    color: var(--text);
    background: var(--bg);
    resize: vertical;
    transition: all var(--transition);
}
.batch-input-area textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(14,165,233,0.1);
}
.batch-input-area.hidden { display: none; }

.batch-count {
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

.batch-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 16px;
}

.batch-hint { font-size: 13px; color: var(--text-muted); }

.batch-results { padding: 0 20px 20px; }

/* ==================== Compare Page ==================== */
.compare-content {
    overflow-x: auto;
}

.compare-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    font-size: 13px;
}

.compare-table th {
    background: var(--bg);
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
}

.compare-table td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    font-family: var(--font-mono);
    font-size: 13px;
}

.compare-table tr:last-child td { border-bottom: none; }
.compare-table tr:hover td { background: var(--primary-light); }

.compare-structure {
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: #ffffff;
    overflow: hidden;
    margin: 0 auto;
}

.compare-structure img {
    display: block;
    width: 180px;
    height: 135px; /* 4:3 与详情页结构框一致，源方形图 contain 装入不变形 */
    max-width: 100%;
    object-fit: contain;
    margin: 0 auto;
}

.compare-empty {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-muted);
}
.compare-empty h3 { font-size: 18px; margin-bottom: 8px; color: var(--text-secondary); }

/* ==================== Stats Page ==================== */
.stats-content {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stats-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px 16px;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 110px;
}

.stats-card .stat-big {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 8px;
    line-height: 1.3;
}

.stats-card .stat-desc {
    font-size: 13px;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

.stats-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 16px;
}

.stats-section-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.stats-section-body {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.7;
}

.stats-section-body p { margin-bottom: 6px; }
.stats-section-body a { color: var(--primary); }

.stats-citation {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.6;
    padding: 8px 12px;
    background: var(--bg);
    border-radius: var(--radius-xs);
    margin-bottom: 8px !important;
}

/* ==================== Loading & Empty ==================== */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    min-height: 300px;
    color: var(--text-muted);
    font-size: 14px;
    text-align: center;
    grid-column: 1 / -1;
}

.loading-spinner {
    display: inline-block;
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin-bottom: 14px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ==================== 骨架屏 ==================== */
@keyframes shimmer {
    0% { background-position: -400px 0; }
    100% { background-position: 400px 0; }
}

.skeleton {
    background: linear-gradient(90deg, var(--border) 25%, #f1f5f9 37%, var(--border) 63%);
    background-size: 800px 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-xs);
}

.skeleton-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
}

.skeleton-line {
    height: 14px;
    margin-bottom: 10px;
    border-radius: 4px;
}

.skeleton-line.w60 { width: 60%; }
.skeleton-line.w40 { width: 40%; }
.skeleton-line.w80 { width: 80%; }
.skeleton-line.w30 { width: 30%; }
.skeleton-line.h20 { height: 20px; }

.skeleton-row {
    display: flex;
    gap: 12px;
    margin-bottom: 10px;
}

.skeleton-card + .skeleton-card { margin-top: 0; }

/* 详情页骨架屏 */
.skeleton-detail-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
}

.skeleton-detail-card h3 {
    height: 18px;
    width: 100px;
    margin-bottom: 16px;
}

.skeleton-canvas {
    width: 100%;
    height: 200px;
    border-radius: var(--radius-xs);
}

.skeleton-detail-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
}

.skeleton-detail-row:last-child { border-bottom: none; }

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    grid-column: 1 / -1;
}
.empty-state h3 { font-size: 17px; margin-bottom: 8px; color: var(--text-secondary); }

/* ==================== Toast ==================== */
.toast-container {
    position: fixed;
    top: 76px;
    right: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius-xs);
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
    max-width: 360px;
}
.toast.success { background: var(--success); color: #fff; }
.toast.error { background: var(--danger); color: #fff; }
.toast.info { background: var(--primary); color: #fff; }

@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ==================== Footer ==================== */
.footer {
    background: var(--bg-elevated);
    border-top: 1px solid var(--border);
    padding: 10px 24px;
    margin-top: auto;
}
.footer-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    /* 限定内容宽度并居中：避免超宽屏下两端贴边后中间出现大片空洞 */
    max-width: 750px;
    margin: 0 auto;
}
.footer-left { max-width: 600px; text-align: left; }
.footer p { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; line-height: 1.6; }
.footer a { color: var(--primary); text-decoration: none; }
.footer a:hover { text-decoration: underline; }
.footer-icp { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.footer-right { flex-shrink: 0; }
.footer-qrcode-group {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 20px;
}
.footer-qrcode {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}
.footer-qrcode img {
    border-radius: var(--radius-xs);
}
.footer-qrcode span {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}

/* ==================== User Profile Page ==================== */
.user-profile {
    max-width: 680px;
    margin: 0 auto;
}

.profile-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 16px;
}

.profile-card-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.profile-avatar-section {
    display: flex;
    align-items: center;
    gap: 20px;
}

.profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--primary-light);
    flex-shrink: 0;
    transition: opacity 0.2s;
}

.profile-avatar-wrap {
    position: relative;
    width: 80px;
    height: 80px;
    flex-shrink: 0;
    cursor: pointer;
    border-radius: 50%;
    overflow: hidden;
}

.profile-avatar-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.2s;
    color: #fff;
}

.profile-avatar-overlay span {
    font-size: 10px;
    white-space: nowrap;
}

.profile-avatar-wrap:hover .profile-avatar-overlay {
    opacity: 1;
}

.profile-avatar-wrap:hover .profile-avatar {
    transform: scale(1.05);
}

.profile-name-display {
    flex: 1;
}

.profile-nickname {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}

.profile-username {
    font-size: 14px;
    color: var(--text-muted);
}

.profile-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.profile-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.profile-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.profile-field-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.profile-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: var(--bg);
    transition: all var(--transition);
}
.profile-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(14,165,233,0.1);
}

.profile-save-btn {
    white-space: nowrap;
    flex-shrink: 0;
}

.profile-info-list {
    display: flex;
    flex-direction: column;
}

.profile-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
}
.profile-info-row:last-child { border-bottom: none; }

.profile-info-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

.profile-info-value {
    font-size: 13px;
    color: var(--text);
    font-weight: 500;
}

.status-active { color: var(--success); }
.status-disabled { color: var(--danger); }

.profile-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.btn-danger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 24px;
    background: var(--danger);
    color: #fff;
    border: none;
    border-radius: var(--radius-xs);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}
.btn-danger:hover { background: #dc2626; }

/* ==================== Profile Bind ==================== */
.profile-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
    gap: 12px;
}
.profile-info-row:last-child { border-bottom: none; }

.profile-bind-btn {
    white-space: nowrap;
    flex-shrink: 0;
    font-size: 12px;
    padding: 4px 12px;
}

.bind-dialog {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 28px;
    width: 400px;
    max-width: 90vw;
    box-shadow: var(--shadow-lg);
    transform: scale(0.9);
    transition: transform 0.25s;
}
.lightbox-overlay.active .bind-dialog { transform: scale(1); }

.bind-dialog-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 20px;
    text-align: center;
}

.bind-dialog-field {
    margin-bottom: 16px;
}

.bind-dialog-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* ==================== Responsive ==================== */
@media (max-width: 768px) {
    .header-inner { padding: 0 12px; gap: 12px; }
    .logo-sub { display: none; }
    .logo { min-width: 0; }
    .logo-text { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .header-nav { display: none; }
    .header-actions-right { margin-left: auto; }
    .mobile-menu-btn { display: flex; margin-left: 8px; }
    .user-section { display: none; }
    .hero { padding: 20px 16px; }
    .hero-title { font-size: 22px; }
    .hero-subtitle { font-size: 13px; margin-bottom: 20px; }
    .search-body { flex-direction: column; gap: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius-xs); overflow: hidden; }
    .search-input-group { width: 100%; }
    .search-input-group input { border-right: none; border-bottom: 1px solid var(--border); }
    .search-btn { width: 100%; justify-content: center; border-radius: 0; }
    .quick-links { gap: 8px; }
    .quick-chips { gap: 8px; }
    .quick-chips a { padding: 4px 10px; font-size: 12px; }
    .feature-cards { grid-template-columns: 1fr; gap: 10px; margin-top: 20px; }
    .feature-card { padding: 14px 12px; display: flex; align-items: center; gap: 12px; text-align: left; }
    .feature-icon { margin-bottom: 0; }
    .detail-grid { grid-template-columns: 1fr; }
    .results-grid { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .page-header { flex-wrap: nowrap; }
    .header-actions { width: auto; margin-left: auto; }
    .action-btn { padding: 6px 10px; font-size: 12px; }
    .footer-inner { flex-direction: column; text-align: center; gap: 16px; align-items: center; }
    .footer-left { text-align: center; max-width: 100%; }
    .footer p { font-size: 11px; }
    .footer-right { display: flex; flex-direction: column; align-items: center; gap: 8px; }
    .footer-qrcode img { width: 72px; height: 72px; }
    .compare-table { display: block; overflow-x: auto; }
    .compare-structure img { width: 120px; height: 90px; }
    .profile-avatar-section { flex-direction: column; text-align: center; }
    .profile-avatar { width: 64px; height: 64px; }
    .profile-avatar-wrap { width: 64px; height: 64px; }
    .profile-nickname { font-size: 18px; }
    .profile-field-row { flex-direction: column; align-items: stretch; }
    .profile-save-btn { align-self: flex-end; }
    .profile-actions { flex-direction: column; }
    .profile-actions a, .profile-actions button { text-align: center; }
}

@media (max-width: 480px) {
    .hero-title { font-size: 18px; }
    .hero-subtitle { font-size: 12px; }
    .search-input-group input { padding: 10px 12px; font-size: 14px; }
    .search-btn { padding: 10px 20px; font-size: 14px; }
}

/* ==================== Structure Lightbox ==================== */
.structure-canvas-container { cursor: pointer; position: relative; }
.structure-canvas-container::after {
    content: '查看大图';
    position: absolute; bottom: 6px; right: 8px;
    font-size: 11px; color: var(--text-muted); pointer-events: none;
    opacity: 0; transition: opacity 0.2s;
}
.structure-canvas-container:hover::after { opacity: 1; }
/* 3D 模式下点击放大已禁用（防拖拽旋转误触），隐藏提示并恢复默认光标 */
.structure-canvas-container.struct-3d-on { cursor: default; }
.structure-canvas-container.struct-3d-on::after { display: none; }

.lightbox-overlay {
    position: fixed; inset: 0; z-index: 9999;
    background: rgba(0,0,0,0.85);
    display: flex; align-items: center; justify-content: center;
    flex-direction: column; gap: 8px;
    opacity: 0; transition: opacity 0.25s;
    cursor: zoom-out;
}
.lightbox-overlay.active { opacity: 1; }
.lightbox-container {
    position: relative; max-width: 90vw; max-height: 85vh;
    background: var(--bg-card, #fff); border-radius: 12px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.4);
    overflow: hidden; display: flex; align-items: center; justify-content: center;
    transform: scale(0.9); transition: transform 0.25s;
}
.lightbox-overlay.active .lightbox-container { transform: scale(1); }
.lightbox-container img { display: block; max-width: 90vw; max-height: 85vh; object-fit: contain; }
.lightbox-info {
    color: #ccc; font-size: 13px; text-align: center;
    max-width: 90vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lightbox-close {
    position: absolute; top: 12px; right: 16px;
    width: 36px; height: 36px; border-radius: 50%;
    background: rgba(255,255,255,0.15); border: none;
    color: #fff; font-size: 20px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.2s; z-index: 10;
}
.lightbox-close:hover { background: rgba(255,255,255,0.3); }
.lightbox-actions {
    position: absolute; bottom: 12px; right: 16px;
    display: flex; gap: 8px; z-index: 10;
}
.lightbox-actions button {
    padding: 6px 14px; border-radius: 6px;
    background: rgba(255,255,255,0.15); border: 1px solid rgba(255,255,255,0.2);
    color: #fff; font-size: 12px; cursor: pointer;
    transition: background 0.2s;
}
.lightbox-actions button:hover { background: rgba(255,255,255,0.3); }

/* ==================== AI 解析入口 + AI 问答 ==================== */
/* 详情页右下角悬浮入口（仅图标，点击跳转 AI 问答预填解析问题） */
.ai-fab {
    position: fixed;
    right: 24px; bottom: 28px;
    display: inline-flex; align-items: center; justify-content: center;
    width: 52px; height: 52px;
    border: none; border-radius: 50%;
    background: var(--primary); color: #fff;
    box-shadow: 0 4px 16px rgba(14, 165, 233, 0.4);
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
    z-index: 50;
}
.ai-fab:hover { background: var(--primary-dark); transform: translateY(-2px); }

/* 助手气泡承载 Markdown 内容 */
.chat-bubble.md { white-space: normal; max-width: 92%; font-size: 14px; line-height: 1.7; }
.chat-quota-link { color: var(--primary); text-decoration: underline; cursor: pointer; }

/* 会员图标（toolbar：头像右侧、昵称左侧，与小程序 ic_vip 同资源，透明底）+ 个人信息页会员文字 */
.vip-badge { height: 12px; width: auto; vertical-align: middle; }
.vip-text { color: #d97706; font-weight: 600; }

/* ==================== 模态弹窗基础样式 ==================== */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex; align-items: center; justify-content: center;
    z-index: 200;
    padding: 20px;
}
.modal-content {
    background: var(--card-bg, #fff);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    /* 相对遮罩（inset:0 + 20px 内边距）的可视高度约束，规避移动端 86vh 按大视口计算导致弹窗超出屏幕、底部内容不可达 */
    max-height: 100%;
    overflow-y: auto;
    /* 移动端惯性滚动；滚动到边界时不 chained 到页面背景 */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    width: 100%;
    max-width: 640px;
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 22px 12px;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 17px; font-weight: 600; color: var(--text); }
.modal-close {
    border: none; background: none;
    font-size: 22px; line-height: 1;
    color: var(--text-muted); cursor: pointer;
    padding: 2px 6px;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 14px 22px 22px; }

/* 物质信息弹窗（结构简式 / 名称分类 / 本汇森物质） */
.modal-section { margin-bottom: 20px; }
.modal-section-title {
    display: flex; align-items: center; gap: 6px;
    font-size: 14px; font-weight: 600; color: var(--text);
    margin-bottom: 10px;
}
.modal-loading { padding: 30px 0; text-align: center; color: var(--text-muted); font-size: 13px; }
.modal-empty { padding: 0; color: var(--text-muted); font-size: 13px; }

.modal-structural-formula {
    font-family: var(--font-mono);
    font-size: 14px; color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    padding: 10px 12px;
}

/* 名称分类：问号 hover 说明浮层 */
.modal-section { position: relative; }
.modal-help {
    display: inline-flex; align-items: center; justify-content: center;
    width: 15px; height: 15px;
    border: 1.5px solid var(--text-muted); border-radius: 50%;
    font-size: 10px; font-weight: 900; color: var(--text-muted);
    cursor: help;
}
.modal-type-desc {
    display: none;
    position: fixed; top: 0; left: 0; z-index: 300;
    /* 手机上不宽于信息弹窗（弹窗宽 100vw-40px，这里再各收 8px） */
    width: min(420px, calc(100vw - 56px));
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    padding: 10px 12px;
}
/* 手机上水平居中（触屏没有悬停定位意义），垂直位置仍由 placeAt 按点击位置计算 */
@media (max-width: 480px) {
    .modal-type-desc { left: 50% !important; transform: translateX(-50%); }
}
.modal-type-item {
    display: block;
    font-size: 12px; line-height: 1.9; color: var(--text-secondary);
}
.modal-type-num {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 16px; height: 16px;
    background: var(--primary-light); color: var(--primary);
    border-radius: 4px;
    font-size: 10px; font-weight: 700;
    margin-right: 2px;
}
.modal-type-name { color: var(--text); font-weight: 600; }
.modal-type-example { color: var(--text-muted); margin-left: 4px; }

/* 各类名称列表 */
.modal-name-group { margin-bottom: 12px; }
.modal-name-type { font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.modal-name-list { display: flex; flex-wrap: wrap; gap: 6px; }
.modal-name-tag {
    font-size: 12px; color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    padding: 3px 8px;
    word-break: break-all;
}

/* 本汇森物质关联（紧凑行，与名称分类间用分隔线区隔） */
.modal-material-list {
    border-top: 1px solid var(--border);
    padding-top: 4px;
}
.modal-material-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 0;
}
.modal-material-label { flex-shrink: 0; font-size: 13px; color: var(--text-muted); }
.modal-material-name {
    flex: 1; min-width: 0;
    font-size: 13px; font-weight: 600; color: var(--text);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.modal-material-link {
    border: none; background: none;
    color: var(--primary);
    font-size: 13px; font-weight: 600;
    cursor: pointer;
    padding: 2px 0;
    white-space: nowrap;
}
.modal-material-link:hover { text-decoration: underline; }

/* 会员购买引导弹窗（按钮/二维码样式对齐 frontend MemberModal） */
.membership-modal-content { max-width: 380px; width: 88vw; }
.membership-modal-body { text-align: center; }
.membership-desc { font-size: 14px; line-height: 1.7; color: var(--text); margin-bottom: 16px; }
.membership-qrcode { display: block; width: 200px; height: 200px; padding: 8px; margin: 0 auto 12px; box-sizing: border-box; border: 1px solid var(--border); border-radius: 10px; }
.membership-hint { font-size: 12px; color: var(--text-muted); margin-bottom: 16px; }
.membership-actions .btn-primary, .membership-actions .btn-plain {
    display: block; width: 100%; padding: 12px;
    font-size: 15px; border: none; border-radius: 10px;
    cursor: pointer; transition: opacity 0.15s;
}
.membership-actions .btn-primary { background: var(--primary); color: #fff; }
.membership-actions .btn-plain { background: transparent; color: var(--text-secondary); margin-top: 10px; }
.membership-actions .btn-primary:hover, .membership-actions .btn-plain:hover { opacity: 0.88; }
.chat-bubble.md p { margin: 6px 0; }
.chat-bubble.md p:last-child { margin-bottom: 0; }
.chat-bubble.md h1, .chat-bubble.md h2, .chat-bubble.md h3 { color: var(--text); font-weight: 600; font-size: 15px; margin: 10px 0 6px; line-height: 1.4; }
.chat-bubble.md ul, .chat-bubble.md ol { padding-left: 18px; margin: 6px 0; }
.chat-bubble.md li { margin: 2px 0; }
.chat-bubble.md code { background: var(--bg); padding: 2px 8px; border-radius: 4px; font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 13px; color: #d63384; word-break: break-word; }
.chat-bubble.md pre { background: var(--bg); padding: 14px 16px; border-radius: 10px; overflow-x: auto; margin: 12px 0; }
.chat-bubble.md pre code { background: none; padding: 0; color: var(--text); }
.chat-bubble.md blockquote { border-left: 4px solid var(--primary); margin: 12px 0; padding: 10px 16px; background: var(--bg); border-radius: 0 8px 8px 0; color: var(--text-secondary); }
.chat-bubble.md table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 13px; }
.chat-bubble.md th, .chat-bubble.md td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.chat-bubble.md th { background: var(--bg); font-weight: 600; }
.chat-bubble.md tr:nth-child(even) { background: var(--bg); }
.chat-bubble.md mjx-container { font-size: 1.05em !important; }

/* 流式输出光标 */
.ai-cursor {
    display: inline-block; width: 8px; height: 16px;
    background: var(--primary);
    margin-left: 2px; vertical-align: -2px;
    animation: ai-blink 0.9s step-end infinite;
}
@keyframes ai-blink { 50% { opacity: 0; } }

.chat-container { max-width: 860px; }
.chat-quota-tag {
    display: inline-flex; align-items: center;
    padding: 4px 12px; border-radius: 999px;
    background: var(--primary-light); color: var(--primary);
    font-size: 12px; font-weight: 500; white-space: nowrap;
}
.chat-quota-tag.member { background: #fef3c7; color: #b45309; }
html[data-theme="dark"] .chat-quota-tag.member { background: #451a03; color: #fbbf24; }

.chat-box {
    display: flex; flex-direction: column;
    height: calc(100vh - 210px);
    min-height: 420px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.chat-messages {
    flex: 1; overflow-y: auto;
    padding: 20px;
    display: flex; flex-direction: column; gap: 14px;
}
.chat-msg { display: flex; }
.chat-msg.user { justify-content: flex-end; }
.chat-msg.assistant { justify-content: flex-start; }
.chat-bubble {
    max-width: 78%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px; line-height: 1.7;
    white-space: pre-wrap; word-break: break-word;
}
.chat-msg.user .chat-bubble { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.chat-msg.assistant .chat-bubble { background: var(--bg); color: var(--text); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.chat-bubble.chat-msg-error { color: #dc2626; }
html[data-theme="dark"] .chat-bubble.chat-msg-error { color: #f87171; }

.chat-input-bar {
    display: flex; align-items: flex-end; gap: 10px;
    padding: 12px 14px;
    border-top: 1px solid var(--border);
    background: var(--bg-elevated);
}
.chat-input-bar textarea {
    flex: 1; resize: none;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-card);
    color: var(--text);
    padding: 9px 12px;
    font-size: 14px; line-height: 1.5;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}
.chat-input-bar textarea:focus { border-color: var(--primary); }
.chat-send-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 16px;
    border: none; border-radius: 10px;
    background: var(--primary); color: #fff;
    font-size: 14px; font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s;
    white-space: nowrap;
}
.chat-send-btn:hover:not(:disabled) { background: var(--primary-dark); }
.chat-send-btn:disabled { opacity: 0.45; cursor: not-allowed; }

@media (max-width: 768px) {
    .chat-box { height: calc(100vh - 170px); }
    .chat-messages { padding: 14px; }
    .chat-bubble { max-width: 88%; }
}

/* ==================== 意见反馈弹窗 ==================== */
/* modal-content 兜底 #fff 不随主题切换，这里显式用主题变量保证深色模式兼容 */
.feedback-modal-content { max-width: 520px; background: var(--bg-card); }

.fb-nav-row {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 12px;
}
.fb-back-link {
    border: none; background: none; padding: 0;
    font-size: 13px; color: var(--primary); cursor: pointer;
}
.fb-back-link:hover { text-decoration: underline; }

.fb-textarea {
    width: 100%; min-height: 120px; resize: vertical;
    padding: 12px 14px;
    font-size: 15px; line-height: 1.6; font-family: inherit;
    color: var(--text); background: var(--bg);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    outline: none; transition: border-color var(--transition);
}
.fb-textarea:focus { border-color: var(--primary); }
.fb-count-row {
    display: flex; justify-content: flex-end;
    margin-top: 6px; font-size: 12px; color: var(--text-muted);
}

.fb-img-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.fb-img-item {
    position: relative; width: 72px; height: 72px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    overflow: hidden;
}
.fb-img-item img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.fb-img-uploading {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    text-align: center; padding: 0 4px; word-break: break-all;
    background: var(--bg); color: var(--text-muted); font-size: 12px;
}
.fb-img-remove {
    position: absolute; top: 2px; right: 2px;
    width: 18px; height: 18px; padding: 0;
    display: flex; align-items: center; justify-content: center;
    border: none; border-radius: 50%;
    background: rgba(0, 0, 0, 0.55); color: #fff;
    font-size: 13px; line-height: 1; cursor: pointer;
}
.fb-img-remove:hover { background: rgba(0, 0, 0, 0.8); }
.fb-add-btn {
    width: 72px; height: 72px;
    display: flex; align-items: center; justify-content: center;
    border: 1px dashed var(--border); border-radius: var(--radius-sm);
    background: none; color: var(--text-muted); font-size: 24px; cursor: pointer;
    transition: all var(--transition);
}
.fb-add-btn:hover { border-color: var(--primary); color: var(--primary); }
.fb-upload-hint { margin-top: 8px; font-size: 12px; color: var(--text-muted); }

.fb-submit-row { display: flex; justify-content: flex-end; margin-top: 16px; }
.fb-my-link { margin-top: 14px; text-align: center; }
.fb-my-link button {
    border: none; background: none; padding: 0;
    font-size: 13px; color: var(--primary); cursor: pointer;
}
.fb-my-link button:hover { text-decoration: underline; }

.fb-list-item {
    padding: 12px 2px; cursor: pointer;
    border-bottom: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
}
.fb-list-item:last-child { border-bottom: none; }
.fb-list-item:hover .fb-list-content { color: var(--primary); }
.fb-list-content {
    font-size: 14px; color: var(--text);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.fb-list-meta {
    display: flex; align-items: center; gap: 12px;
    margin-top: 6px; font-size: 12px; color: var(--text-muted);
}
.fb-empty-center { padding: 24px 0; text-align: center; }

/* 状态纯文字（无背景色块） */
.fb-status-pending { color: var(--warning); }
.fb-status-replied { color: var(--primary); }
.fb-status-resolved { color: var(--success); }
.fb-status-tag { font-size: 12px; }

.fb-main-card {
    padding: 12px 14px;
    background: var(--bg);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.fb-main-content { font-size: 14px; line-height: 1.7; color: var(--text); white-space: pre-wrap; word-break: break-word; }
.fb-main-meta { display: flex; gap: 12px; margin-top: 8px; font-size: 12px; color: var(--text-muted); }
.fb-img-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.fb-thumb {
    width: 64px; height: 64px; object-fit: cover; display: block;
    border: 1px solid var(--border); border-radius: var(--radius-xs);
    cursor: zoom-in;
}

.fb-chat-area {
    max-height: 50vh; overflow-y: auto;
    margin-top: 14px; padding-right: 2px;
    -webkit-overflow-scrolling: touch;
}
.fb-msg { display: flex; margin-bottom: 12px; }
.fb-msg.user { justify-content: flex-end; }
.fb-msg.admin { justify-content: flex-start; }
.fb-msg-col { max-width: 78%; display: flex; flex-direction: column; }
.fb-msg.user .fb-msg-col { align-items: flex-end; }
.fb-msg.admin .fb-msg-col { align-items: flex-start; }
.fb-msg-tag { margin-bottom: 3px; font-size: 11px; color: var(--text-muted); }
.fb-bubble {
    padding: 8px 12px;
    font-size: 14px; line-height: 1.7;
    white-space: pre-wrap; word-break: break-word;
    border-radius: var(--radius-sm);
}
.fb-msg.admin .fb-bubble { background: var(--bg); color: var(--text); border: 1px solid var(--border); border-top-left-radius: 4px; }
.fb-msg.user .fb-bubble { background: var(--primary); color: #fff; border-top-right-radius: 4px; }
.fb-msg-time { margin-top: 4px; font-size: 11px; color: var(--text-muted); }

.fb-reply-bar {
    display: flex; gap: 10px;
    margin-top: 14px; padding-top: 14px;
    border-top: 1px solid var(--border);
}
.fb-reply-input {
    flex: 1; min-width: 0; padding: 10px 14px;
    font-size: 14px; font-family: inherit;
    color: var(--text); background: var(--bg);
    border: 1px solid var(--border); border-radius: var(--radius-xs);
    outline: none; transition: border-color var(--transition);
}
.fb-reply-input:focus { border-color: var(--primary); }
.fb-send-btn { white-space: nowrap; }
.fb-attach-btn {
    display: flex; align-items: center; justify-content: center;
    width: 42px; height: 42px; flex-shrink: 0;
    color: var(--text-muted); background: var(--bg);
    border: 1px solid var(--border); border-radius: var(--radius-xs);
    cursor: pointer; transition: color var(--transition), border-color var(--transition);
}
.fb-attach-btn:hover { color: var(--primary); border-color: var(--primary); }
.fb-reopen-hint { margin-top: 8px; font-size: 12px; color: var(--text-muted); }

@media (max-width: 768px) {
    .fb-chat-area { max-height: 44vh; }
    .fb-msg-col { max-width: 88%; }
}

/* 详情页"报告数据问题"入口：顶部 action-btn（旗帜 icon），样式复用 .action-btn 无需额外规则 */
