/* ── Design System ───────────────────────────────────────────── */
:root {
    --bg: #0a0a0f;
    --bg-card: #12121a;
    --bg-hover: #1a1a2e;
    --bg-input: #16161f;
    --border: #2a2a3e;
    --text: #e8e8f0;
    --text-dim: #8888a0;
    --text-muted: #555568;
    --accent: #6c5ce7;
    --accent-light: #a29bfe;
    --accent-glow: rgba(108, 92, 231, 0.3);
    --gradient: linear-gradient(135deg, #6c5ce7, #a29bfe, #74b9ff);
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Noto Sans SC', 'Inter', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ── Header ──────────────────────────────────────────────── */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(10, 10, 15, 0.85);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    font-size: 24px;
}

.logo-text {
    font-weight: 700;
    font-size: 18px;
    letter-spacing: -0.5px;
}

.logo-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    background: var(--accent);
    color: white;
    border-radius: 4px;
    letter-spacing: 1px;
}

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

.nav-btn {
    background: none;
    border: none;
    color: var(--text-dim);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    transition: var(--transition);
}

.nav-btn:hover {
    color: var(--text);
    background: var(--bg-hover);
}

.nav-btn.active {
    color: var(--accent-light);
    background: rgba(108, 92, 231, 0.15);
}

/* ── Views ───────────────────────────────────────────────── */
.view {
    display: none;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

.view.active {
    display: block;
}

/* ── Hero / Search ───────────────────────────────────────── */
.hero {
    text-align: center;
    padding: 80px 0 40px;
}

.hero h1 {
    font-size: 40px;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 12px;
}

.gradient-text {
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-sub {
    color: var(--text-dim);
    font-size: 16px;
    margin-bottom: 40px;
}

.search-box {
    display: flex;
    align-items: center;
    max-width: 640px;
    margin: 0 auto;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 4px 4px 4px 20px;
    transition: var(--transition);
}

.search-box:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-icon {
    font-size: 18px;
    margin-right: 8px;
}

.search-box input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text);
    font-size: 16px;
    padding: 12px 0;
    min-width: 0;
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.search-submit {
    background: var(--accent);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    transition: var(--transition);
    white-space: nowrap;
}

.search-submit:hover {
    background: #5a4bd4;
    transform: scale(1.02);
}

.quick-tags {
    margin-top: 20px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    align-items: center;
}

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

.quick-tag {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: 6px 14px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    transition: var(--transition);
}

.quick-tag:hover {
    border-color: var(--accent);
    color: var(--accent-light);
    background: rgba(108, 92, 231, 0.1);
}

/* ── Concept Carousel ─────────────────────────────────────── */
.concept-carousel {
    display: inline-flex;
    gap: 8px;
    transition: opacity 0.3s ease;
    min-height: 34px;
    align-items: center;
}

.concept-carousel.fading {
    opacity: 0;
}

/* ── Trending Searches ────────────────────────────────────── */
.trending-section {
    margin-top: 18px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 14px;
    animation: fadeIn 0.4s ease;
}

.trending-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
}

.trending-label {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    margin-right: 2px;
}

.trending-tag {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: 4px 12px;
    border-radius: 16px;
    cursor: pointer;
    font-size: 12px;
    transition: var(--transition);
    white-space: nowrap;
}

.trending-tag:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(108, 92, 231, 0.2);
}

.trending-tag.popular {
    background: linear-gradient(135deg, rgba(255, 107, 107, 0.1), rgba(255, 159, 67, 0.1));
    border-color: rgba(255, 107, 107, 0.3);
    color: #ff6b6b;
}

.trending-tag.popular:hover {
    border-color: #ff6b6b;
    background: linear-gradient(135deg, rgba(255, 107, 107, 0.2), rgba(255, 159, 67, 0.2));
}

.trending-tag.popular .freq {
    font-size: 10px;
    opacity: 0.6;
    margin-left: 2px;
}

.trending-tag.recent {
    background: rgba(108, 92, 231, 0.06);
    border-color: rgba(108, 92, 231, 0.2);
    color: var(--accent-light);
}

.trending-tag.recent:hover {
    border-color: var(--accent);
    background: rgba(108, 92, 231, 0.12);
}

/* ── Download Button (Gaokao) ───────────────────────────── */
.gk-download-link {
    text-align: center;
    padding: 32px 16px;
}

.download-btn {
    display: inline-block;
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    color: #fff;
    padding: 14px 32px;
    border-radius: 30px;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    transition: var(--transition);
    box-shadow: 0 4px 20px var(--accent-glow);
}

.download-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px var(--accent-glow);
    filter: brightness(1.1);
}

/* ── Stats Bar ───────────────────────────────────────────── */
.stats-bar {
    display: flex;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
    padding: 20px 0;
    margin-bottom: 16px;
}

.stats-bar.hidden {
    display: none;
}

.stat-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
}

.stat-chip .count {
    color: var(--accent-light);
    font-weight: 600;
}

/* ── Cross Hint ──────────────────────────────────────────── */
.cross-hint {
    background: linear-gradient(135deg, rgba(108, 92, 231, 0.15), rgba(116, 185, 255, 0.1));
    border: 1px solid rgba(108, 92, 231, 0.3);
    border-radius: var(--radius);
    padding: 16px 24px;
    text-align: center;
    font-size: 15px;
    margin-bottom: 24px;
    animation: fadeIn 0.3s ease;
}

.cross-hint.hidden {
    display: none;
}

/* ── AI Panel ────────────────────────────────────────────── */
.ai-panel {
    margin-bottom: 24px;
}

.ai-panel.hidden {
    display: none;
}

.ai-toolbar {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}

.ai-starters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 12px;
}

.ai-starters.hidden {
    display: none;
}

.ai-starter-chip {
    border: 1px solid rgba(108, 92, 231, 0.28);
    background: rgba(108, 92, 231, 0.08);
    color: var(--text-dim);
    border-radius: 999px;
    padding: 8px 14px;
    cursor: pointer;
    font-size: 12px;
    transition: var(--transition);
}

.ai-starter-chip:hover {
    border-color: rgba(162, 155, 254, 0.7);
    color: var(--text);
    background: rgba(108, 92, 231, 0.16);
}

.ai-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #6c5ce7, #a29bfe);
    color: white;
    border: none;
    padding: 12px 28px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    transition: var(--transition);
    margin: 0;
    box-shadow: 0 4px 20px rgba(108, 92, 231, 0.3);
}

.ai-copy-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(108, 92, 231, 0.35);
    background: rgba(108, 92, 231, 0.08);
    color: var(--accent-light);
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 12px;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    transition: var(--transition);
    flex: 0 0 auto;
}

.ai-copy-btn:hover {
    border-color: var(--accent-light);
    background: rgba(108, 92, 231, 0.2);
}

.ai-copy-btn.hidden {
    display: none;
}

.ai-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 28px rgba(108, 92, 231, 0.5);
}

.ai-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.ai-btn.loading .ai-sparkle {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.ai-result {
    background: linear-gradient(135deg, rgba(108, 92, 231, 0.08), rgba(116, 185, 255, 0.05));
    border: 1px solid rgba(108, 92, 231, 0.25);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-top: 16px;
    animation: fadeIn 0.4s ease;
}

.ai-result.hidden {
    display: none;
}

.ai-result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(108, 92, 231, 0.2);
    font-weight: 600;
    font-size: 15px;
}

.ai-model {
    font-size: 11px;
    color: var(--accent-light);
    background: rgba(108, 92, 231, 0.15);
    padding: 3px 10px;
    border-radius: 10px;
}

.ai-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
    font-size: 14px;
    line-height: 1.8;
    color: var(--text);
}

.ai-msg {
    border-radius: 12px;
    padding: 10px 12px;
    border: 1px solid var(--border);
}

.ai-msg.user {
    background: rgba(108, 92, 231, 0.08);
    border-color: rgba(108, 92, 231, 0.28);
}

.ai-msg.assistant {
    background: rgba(255, 255, 255, 0.03);
}

.ai-msg-role {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.ai-msg-text {
    white-space: pre-wrap;
}

.ai-msg-context {
    margin-bottom: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(116, 185, 255, 0.06);
    border: 1px solid rgba(116, 185, 255, 0.18);
}

.ai-context-line {
    font-size: 12px;
    color: #d7e9ff;
}

.ai-context-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.ai-context-tag {
    border-radius: 999px;
    padding: 4px 9px;
    font-size: 11px;
    color: #d7e9ff;
    background: rgba(116, 185, 255, 0.12);
}

.ai-context-tag.search {
    color: #ddf7cf;
    background: rgba(120, 201, 135, 0.16);
}

.ai-context-tag.retrieval {
    color: #ffe3c2;
    background: rgba(243, 156, 18, 0.16);
}

.ai-context-tag.relation {
    color: #eadcff;
    background: rgba(162, 155, 254, 0.18);
}

.ai-context-tag.exam {
    color: #ffeaa7;
    background: rgba(255, 234, 167, 0.14);
}

.ai-msg-sources {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.ai-source-chip {
    border: 1px solid rgba(116, 185, 255, 0.28);
    background: rgba(116, 185, 255, 0.08);
    color: #b9dcff;
    border-radius: 999px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 11px;
    transition: var(--transition);
}

.ai-source-chip:hover {
    border-color: rgba(116, 185, 255, 0.6);
    background: rgba(116, 185, 255, 0.16);
    color: #e4f3ff;
}

.ai-msg-followups {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.ai-followup-chip {
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-dim);
    border-radius: 999px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 11px;
    transition: var(--transition);
}

.ai-followup-chip:hover {
    border-color: rgba(108, 92, 231, 0.45);
    background: rgba(108, 92, 231, 0.12);
    color: var(--text);
}

.ai-compose {
    margin-top: 14px;
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.ai-followup-input {
    flex: 1;
    resize: vertical;
    min-height: 56px;
    max-height: 180px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-input);
    color: var(--text);
    padding: 10px 12px;
    font-size: 13px;
    font-family: inherit;
}

.ai-followup-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(108, 92, 231, 0.2);
}

.ai-send-btn {
    border: none;
    background: linear-gradient(135deg, #6c5ce7, #8d7cff);
    color: #fff;
    border-radius: 10px;
    padding: 8px 14px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.ai-send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.ai-content .ai-source {
    color: var(--accent-light);
    font-size: 12px;
    display: block;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

/* ── Subject Tabs ────────────────────────────────────────── */
.subject-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.subject-tabs.hidden {
    display: none;
}

.subject-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    transition: var(--transition);
}

.subject-tab:hover {
    border-color: var(--accent);
}

.subject-tab.active {
    background: rgba(108, 92, 231, 0.15);
    border-color: var(--accent);
    color: var(--accent-light);
}

.tab-count {
    color: var(--text-muted);
    font-size: 12px;
}

/* ── Results ─────────────────────────────────────────────── */
.results {
    padding-bottom: 80px;
}

.result-group {
    margin-bottom: 32px;
    animation: fadeIn 0.4s ease;
}

.group-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    font-size: 18px;
    font-weight: 600;
}

.group-icon {
    font-size: 22px;
}

.group-count {
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 400;
}

.group-bar {
    flex: 1;
    height: 2px;
    border-radius: 1px;
    opacity: 0.3;
}

.result-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: var(--transition);
    overflow: hidden;
    word-break: break-word;
    overflow-wrap: break-word;
}

.result-card:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

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

.result-snippet {
    font-size: 14px;
    line-height: 1.7;
    overflow: hidden;
    max-height: 4.2em;
    word-break: break-word;
    overflow-wrap: break-word;
}

.result-snippet mark {
    background: rgba(108, 92, 231, 0.3);
    color: var(--accent-light);
    border-radius: 2px;
    padding: 0 2px;
}

.result-text {
    font-size: 14px;
    color: var(--text-dim);
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    line-height: 1.8;
    word-break: break-word;
    overflow-wrap: break-word;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.35s ease, opacity 0.25s ease, margin 0.25s ease, padding 0.25s ease;
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.result-card.expanded .result-text {
    max-height: 500px;
    overflow-y: auto;
    opacity: 1;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.result-text::-webkit-scrollbar {
    width: 4px;
}

.result-text::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

.result-text::-webkit-scrollbar-track {
    background: transparent;
}

.result-img {
    max-width: 100%;
    height: auto;
    max-height: 400px;
    border-radius: 8px;
    margin: 12px 0;
    border: 1px solid var(--border);
    background: #1a1a2e;
    display: block;
}

/* ── Graph ────────────────────────────────────────────────── */
.graph-header {
    text-align: center;
    padding: 40px 0 20px;
}

.graph-header h2 {
    font-size: 28px;
    font-weight: 700;
}

.graph-header p {
    color: var(--text-dim);
    margin-top: 8px;
}

.graph-container {
    width: 100%;
    height: calc(100vh - 200px);
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    position: relative;
}

.graph-container svg {
    width: 100%;
    height: 100%;
}

.graph-node {
    cursor: pointer;
}

.graph-label {
    fill: var(--text);
    font-size: 12px;
    pointer-events: none;
    text-anchor: middle;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8), 0 -1px 3px rgba(0, 0, 0, 0.8), 1px 0 3px rgba(0, 0, 0, 0.8), -1px 0 3px rgba(0, 0, 0, 0.8);
}

.graph-tooltip-meta {
    margin: 4px 0 6px;
    color: #a29bfe;
    font-weight: 700;
}

/* ── Graph Controls ──────────────────────────────────────── */
.graph-controls {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.graph-mode {
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-dim);
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition);
}

.graph-mode.active,
.graph-mode:hover {
    background: linear-gradient(135deg, #6c5ce7, #a29bfe);
    color: #fff;
    border-color: transparent;
}

.graph-subject-select {
    padding: 6px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text);
    font-size: 12px;
    outline: none;
    cursor: pointer;
}

/* ── Data Insights View ──────────────────────────────────── */
.insights-header {
    text-align: center;
    padding: 30px 0 16px;
}

.insights-header h2 {
    font-size: 26px;
    font-weight: 700;
}

.insights-header p {
    color: var(--text-dim);
    margin-top: 6px;
    font-size: 14px;
}

.insights-tabs {
    display: flex;
    gap: 8px;
    justify-content: center;
    padding: 0 16px 16px;
    flex-wrap: wrap;
}

.insight-tab {
    padding: 8px 18px;
    border-radius: 24px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-dim);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.insight-tab:hover {
    border-color: var(--primary);
    color: var(--text);
}

.insight-tab.active {
    background: linear-gradient(135deg, rgba(108, 92, 231, 0.2), rgba(162, 155, 254, 0.15));
    border-color: var(--primary);
    color: #fff;
    font-weight: 600;
}

.insights-content {
    padding: 0 16px 32px;
    max-width: 750px;
    margin: 0 auto;
}

.insight-panel {
    display: none;
}

.insight-panel.active {
    display: block;
}

.chart-container {
    min-height: 200px;
    overflow-x: auto;
    padding: 12px 0;
}

.chart-container svg {
    display: block;
    margin: 0 auto;
}

/* Frequency controls */
.freq-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
}

.freq-controls select {
    padding: 8px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text);
    font-size: 13px;
    outline: none;
    cursor: pointer;
}

.freq-controls select:focus {
    border-color: var(--primary);
}

/* Coverage Analysis */
.coverage-section {
    margin-bottom: 28px;
}

.coverage-section h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text);
}

.coverage-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    margin-bottom: 6px;
    cursor: pointer;
    transition: var(--transition);
}

.coverage-item:hover {
    background: rgba(108, 92, 231, 0.08);
    border-color: var(--primary);
}

.coverage-term {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    min-width: 80px;
    white-space: nowrap;
}

.coverage-bars {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.cov-bar {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    white-space: nowrap;
    min-width: 50px;
}

.cov-textbook {
    background: rgba(52, 152, 219, 0.2);
    color: #74b9ff;
}

.cov-gaokao {
    background: rgba(231, 76, 60, 0.2);
    color: #ff7675;
}

.coverage-ratio {
    font-size: 14px;
    font-weight: 700;
    min-width: 55px;
    text-align: right;
}

.ratio-hot {
    color: #ff6b6b;
}

.ratio-cool {
    color: #74b9ff;
}

/* ── Search Result Concept Subgraph ──────────────────────── */
.search-graph-section {
    margin: 20px 0;
    padding: 16px;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.search-graph-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text);
}

.search-graph-container {
    width: 100%;
    overflow: hidden;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.15);
}

.search-graph-container svg {
    display: block;
    margin: 0 auto;
}

/* ── About ───────────────────────────────────────────────── */
.about-content {
    max-width: 980px;
    margin: 0 auto;
    padding: 40px 0 80px;
}

.about-intro {
    margin-bottom: 24px;
}

.about-content h2 {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 12px;
}

.about-lead {
    max-width: 760px;
    color: var(--text-dim);
    line-height: 1.8;
    font-size: 15px;
}

.about-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.about-card-wide {
    grid-column: 1 / -1;
}

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

.about-card h3 {
    font-size: 18px;
    margin-bottom: 12px;
}

.about-card p {
    color: var(--text-dim);
    margin-bottom: 8px;
    line-height: 1.8;
}

.about-card a {
    color: var(--accent-light);
    text-decoration: none;
}

.about-card a:hover {
    text-decoration: underline;
}

.about-feedback-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid rgba(108, 92, 231, 0.35);
    background: rgba(108, 92, 231, 0.1);
    color: var(--accent-light);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
}

.about-feedback-btn:hover {
    background: rgba(108, 92, 231, 0.18);
    text-decoration: none;
}

.about-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.about-metric-chip {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 5px 10px;
    font-size: 11px;
    color: #d7e9ff;
    background: rgba(116, 185, 255, 0.12);
    border: 1px solid rgba(116, 185, 255, 0.18);
}

.about-note {
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(255, 234, 167, 0.06);
    border: 1px solid rgba(255, 234, 167, 0.12);
}

.about-signoff {
    margin-top: 14px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    color: var(--text-dim);
}

.about-signoff strong {
    color: var(--text);
}

/* ── Footer ──────────────────────────────────────────────── */
.footer {
    text-align: center;
    padding: 24px;
    color: var(--text-muted);
    font-size: 13px;
    border-top: 1px solid var(--border);
}

.footer-meta {
    margin-top: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.footer-link {
    color: var(--text-dim);
    text-decoration: none;
    transition: var(--transition);
}

.footer-link:hover {
    color: var(--text);
}

/* ── Advanced Search Toggle ──────────────────────────────── */
.advanced-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    transition: var(--transition);
    line-height: 1;
}

.advanced-toggle:hover,
.advanced-toggle.active {
    color: var(--accent-light);
}

/* ── Advanced Panel ──────────────────────────────────────── */
.advanced-panel {
    max-width: 640px;
    margin: 12px auto 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    animation: fadeIn 0.2s ease;
}

.filter-row {
    display: flex;
    gap: 16px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.filter-group {
    flex: 1;
    min-width: 140px;
}

.filter-group label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 500;
}

.filter-group select {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
    appearance: auto;
}

.filter-group select:focus {
    border-color: var(--accent);
    outline: none;
}

.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 13px !important;
    color: var(--text-dim) !important;
    padding-bottom: 8px;
}

.checkbox-label input[type="checkbox"] {
    accent-color: var(--accent);
    width: 16px;
    height: 16px;
}

/* ── Query Analysis ──────────────────────────────────────── */
.query-analysis {
    margin: 0 0 16px;
    padding: 14px 16px;
    border-radius: var(--radius);
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: linear-gradient(135deg, rgba(108, 92, 231, 0.14), rgba(46, 204, 113, 0.08));
}

.query-analysis-header {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.query-analysis-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
}

.query-analysis-scope,
.query-analysis-flag {
    font-size: 12px;
    color: var(--text-muted);
}

.query-analysis-summary {
    color: var(--text-dim);
    font-size: 13px;
    line-height: 1.6;
}

.query-analysis-chips {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.query-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.query-chip.concept {
    color: #d8c3ff;
    background: rgba(108, 92, 231, 0.22);
}

.query-chip.fallback {
    color: #b9f7db;
    background: rgba(46, 204, 113, 0.18);
}

/* ── Related Concepts Bar ────────────────────────────────── */
.related-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    animation: fadeIn 0.3s ease;
}

.related-label {
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
}

.related-tag {
    background: rgba(108, 92, 231, 0.08);
    border: 1px solid rgba(108, 92, 231, 0.2);
    color: var(--accent-light);
    padding: 4px 12px;
    border-radius: 16px;
    cursor: pointer;
    font-size: 12px;
    transition: var(--transition);
    white-space: nowrap;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.related-tag:hover {
    background: rgba(108, 92, 231, 0.2);
    border-color: var(--accent);
    transform: translateY(-1px);
}

.related-count {
    font-size: 10px;
    opacity: 0.6;
}

/* ── Result Meta ─────────────────────────────────────────── */
.result-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}

.match-channel {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
    margin-left: 4px;
}

.match-channel.exact {
    color: #ffe08a;
    background: rgba(255, 224, 138, 0.12);
}

.match-channel.fts {
    color: #74b9ff;
    background: rgba(116, 185, 255, 0.13);
}

.match-channel.supplemental {
    color: #b9f7db;
    background: rgba(46, 204, 113, 0.18);
}

.result-trace {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    flex-wrap: wrap;
    margin: 6px 0 8px;
}

.evidence-chips {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.evidence-chip {
    border-radius: 999px;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 600;
}

.evidence-chip.strong {
    color: #55efc4;
    background: rgba(85, 239, 196, 0.14);
}

.evidence-chip.semantic {
    color: #74b9ff;
    background: rgba(116, 185, 255, 0.14);
}

.evidence-chip.page {
    color: #ffeaa7;
    background: rgba(255, 234, 167, 0.14);
}

.evidence-chip.exam {
    color: #c9b8ff;
    background: rgba(108, 92, 231, 0.18);
}

.evidence-chip.textbook {
    color: #81f7c9;
    background: rgba(46, 204, 113, 0.12);
}

.evidence-chip.media {
    color: #ffd0a8;
    background: rgba(230, 126, 34, 0.14);
}

.evidence-chip.neutral {
    color: #d1d7e0;
    background: rgba(255, 255, 255, 0.08);
}

.evidence-chip.supplemental {
    color: #b9f7db;
    background: rgba(46, 204, 113, 0.16);
}

.relation-path {
    color: var(--text-muted);
    font-size: 12px;
}

/* ── Image Count Badge ───────────────────────────────────── */
.img-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: rgba(46, 204, 113, 0.12);
    color: #2ecc71;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    margin-left: 8px;
    font-weight: 500;
}

/* ── Utility ─────────────────────────────────────────────── */
.hidden {
    display: none !important;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

/* ── Source Badge ─────────────────────────────────────────── */
.source-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
    margin-left: 4px;
}

.source-badge.textbook {
    background: rgba(46, 204, 113, 0.12);
    color: #2ecc71;
}

.source-badge.gaokao {
    background: rgba(108, 92, 231, 0.15);
    color: var(--accent-light);
}

/* ── Gaokao Hero ─────────────────────────────────────────── */
.gaokao-hero {
    text-align: center;
    padding: 60px 0 30px;
}

.gaokao-hero h2 {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #6c5ce7, #fd79a8, #f39c12);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.gaokao-hero-sub {
    color: var(--text-dim);
    font-size: 15px;
}

/* ── Gaokao Filters ──────────────────────────────────────── */
.gaokao-filters {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-end;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 20px;
}

.gaokao-filters .filter-group {
    flex: 1;
    min-width: 120px;
}

.gk-search-btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: var(--transition);
    white-space: nowrap;
    align-self: flex-end;
}

.gk-search-btn:hover {
    background: #5a4bd4;
    transform: scale(1.02);
}

/* ── Gaokao Count ────────────────────────────────────────── */
.gk-count {
    text-align: center;
    color: var(--text-dim);
    font-size: 14px;
    margin-bottom: 16px;
    padding: 8px;
    border-bottom: 1px solid var(--border);
}

/* ── Gaokao Results ──────────────────────────────────────── */
.gk-results {
    padding-bottom: 80px;
}

/* ── Gaokao Card ─────────────────────────────────────────── */
.gaokao-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 12px;
    overflow: hidden;
    transition: var(--transition);
}

.gaokao-card:hover {
    border-color: var(--accent);
    box-shadow: 0 2px 16px rgba(108, 92, 231, 0.1);
}

.gk-card-header {
    padding: 16px 20px;
    cursor: pointer;
    transition: var(--transition);
}

.gk-card-header:hover {
    background: var(--bg-hover);
}

.gk-card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.gk-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: white;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.gk-year,
.gk-category,
.gk-type {
    font-size: 12px;
    color: var(--text-muted);
    padding: 2px 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

.gk-score {
    font-size: 12px;
    color: #f39c12;
    font-weight: 600;
    padding: 2px 8px;
    background: rgba(243, 156, 18, 0.1);
    border-radius: 8px;
}

.gk-card-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text);
}

.gk-card-preview {
    font-size: 13px;
    color: var(--text-dim);
    max-height: 2.6em;
    overflow: hidden;
    line-height: 1.6;
}

/* Expanded state */
.gk-card-body {
    display: none;
    padding: 0 20px 20px;
    border-top: 1px solid var(--border);
}

.gaokao-card.expanded .gk-card-body {
    display: block;
    animation: fadeIn 0.3s ease;
}

.gaokao-card.expanded .gk-card-preview {
    display: none;
}

.gk-question {
    font-size: 14px;
    line-height: 1.8;
    color: var(--text);
    white-space: pre-wrap;
    padding: 16px 0;
    word-break: break-word;
}

.gk-analysis {
    margin: 12px 0;
}

.gk-analysis summary {
    cursor: pointer;
    color: var(--accent-light);
    font-size: 14px;
    padding: 8px 0;
    font-weight: 500;
}

.gk-analysis summary:hover {
    color: var(--text);
}

.gk-analysis-content {
    font-size: 13px;
    line-height: 1.8;
    color: var(--text-dim);
    padding: 12px;
    background: rgba(108, 92, 231, 0.05);
    border-radius: var(--radius-sm);
    white-space: pre-wrap;
    word-break: break-word;
}

.gk-answer {
    font-size: 14px;
    color: #2ecc71;
    font-weight: 600;
    padding: 8px 12px;
    background: rgba(46, 204, 113, 0.08);
    border-radius: var(--radius-sm);
    margin: 8px 0;
}

.gk-actions {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.gk-link-btn,
.gk-ai-btn {
    background: rgba(108, 92, 231, 0.1);
    border: 1px solid rgba(108, 92, 231, 0.3);
    color: var(--accent-light);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: var(--transition);
}

.gk-link-btn:hover,
.gk-ai-btn:hover {
    background: rgba(108, 92, 231, 0.2);
    border-color: var(--accent);
    transform: translateY(-1px);
}

.gk-link-btn:disabled,
.gk-ai-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* AI Result in card */
.gk-ai-result {
    margin-top: 12px;
}

.gk-ai-result.hidden {
    display: none;
}

.gk-ai-answer {
    background: linear-gradient(135deg, rgba(108, 92, 231, 0.08), rgba(116, 185, 255, 0.05));
    border: 1px solid rgba(108, 92, 231, 0.2);
    border-radius: var(--radius-sm);
    padding: 16px;
    animation: fadeIn 0.3s ease;
}

.gk-ai-header {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.gk-ai-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.gk-ai-meta-chip {
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 11px;
    color: #d7e9ff;
    background: rgba(116, 185, 255, 0.12);
}

.gk-ai-text {
    font-size: 13px;
    line-height: 1.8;
    color: var(--text);
    white-space: pre-wrap;
}

.gk-ai-sources {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.gk-ai-source-chip {
    font-size: 11px;
}

/* ── Gaokao Link Panel (overlay) ─────────────────────────── */
.gk-link-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 200;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.gk-link-panel.hidden {
    display: none !important;
}

.gk-link-inner {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-width: 800px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    padding: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.gk-link-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.gk-link-header h3 {
    font-size: 18px;
}

.gk-link-close {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: var(--transition);
}

.gk-link-close:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.gk-link-question {
    padding: 12px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
}

.gk-link-terms {
    display: block;
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-dim);
}

.term-tag {
    display: inline-block;
    background: rgba(108, 92, 231, 0.1);
    color: var(--accent-light);
    padding: 2px 8px;
    border-radius: 8px;
    font-size: 11px;
    margin: 2px;
}

.gk-link-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-bottom: 8px;
    transition: var(--transition);
}

.gk-link-card:hover {
    border-color: var(--accent);
}

.gk-link-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    flex-wrap: wrap;
    font-size: 13px;
    color: var(--text-dim);
}

.gk-link-snippet {
    font-size: 13px;
    line-height: 1.6;
    color: var(--text);
}

.gk-link-snippet mark {
    background: rgba(108, 92, 231, 0.3);
    color: var(--accent-light);
    border-radius: 2px;
}

/* ── Semantic Association UI Components ────────────────── */
.link-type-tag {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 8px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 500;
}

.link-type-tag.explicit {
    background: rgba(46, 204, 113, 0.12);
    color: #27ae60;
    border: 1px solid rgba(46, 204, 113, 0.2);
}

.link-type-tag.implicit {
    background: rgba(108, 92, 231, 0.12);
    color: var(--accent-light);
    border: 1px dashed rgba(108, 92, 231, 0.3);
}

.link-type-tag.precomputed {
    background: rgba(241, 196, 15, 0.14);
    color: #f1c40f;
    border: 1px solid rgba(241, 196, 15, 0.24);
}

.gk-precomputed-analysis {
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(241, 196, 15, 0.18);
    background: rgba(241, 196, 15, 0.06);
}

.gk-precomputed-summary,
.gk-precomputed-tags,
.gk-precomputed-refs {
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-dim);
}

.gk-precomputed-tags,
.gk-precomputed-refs {
    margin-top: 6px;
}

.gk-link-score-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 6px 0;
}

.gk-link-score-bar {
    flex: 1;
    height: 4px;
    background: var(--bg-hover);
    border-radius: 2px;
    overflow: hidden;
}

.gk-link-score-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.6s ease;
}

.gk-link-score-text {
    font-size: 12px;
    font-weight: 600;
    min-width: 36px;
    text-align: right;
}

.gk-concept-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 6px;
}

.concept-tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 8px;
    font-size: 11px;
    background: rgba(108, 92, 231, 0.1);
    color: var(--accent-light);
    font-weight: 500;
}

.gk-matched-concepts {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-dim);
}

.matched-concept {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px 10px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
    cursor: default;
}

.matched-concept.cross {
    background: rgba(46, 204, 113, 0.12);
    color: #27ae60;
    border: 1px solid rgba(46, 204, 113, 0.2);
}

.matched-concept.same {
    background: rgba(52, 152, 219, 0.12);
    color: #3498db;
    border: 1px solid rgba(52, 152, 219, 0.2);
}

.gk-expanded-terms {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-dim);
    padding: 6px 10px;
    background: rgba(108, 92, 231, 0.06);
    border-radius: 8px;
    border-left: 3px solid rgba(108, 92, 231, 0.3);
}

.expanded-term {
    display: inline-block;
    background: rgba(108, 92, 231, 0.08);
    color: var(--accent-light);
    padding: 1px 6px;
    border-radius: 6px;
    font-size: 11px;
    margin: 1px 2px;
}

/* ── Gaokao Question Images ──────────────────────────────── */
.gk-question-img {
    max-width: 100%;
    height: auto;
    max-height: 300px;
    border-radius: 8px;
    border: 1px solid var(--border);
    margin: 8px 0;
    display: block;
    background: #1a1a2e;
}

/* ── Link Panel Section Titles ───────────────────────────── */
.gk-section-title {
    font-size: 15px;
    font-weight: 600;
    margin: 16px 0 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

/* ══════════════════════════════════════════════════════════
   RESPONSIVE: TABLET (≤1024px)
   ══════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
    .view {
        padding: 0 16px;
    }

    .hero h1 {
        font-size: 32px;
    }

    .graph-container {
        height: calc(100vh - 180px);
    }

    .about-content {
        padding: 24px 0 60px;
    }

    .about-content h2 {
        font-size: 26px;
    }

    .about-grid {
        grid-template-columns: 1fr;
    }

    .about-card-wide {
        grid-column: auto;
    }

    .ai-result {
        padding: 16px 18px;
    }

    /* Gaokao filters: 2×2 grid on tablet */
    .gaokao-filters {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .gk-search-btn {
        grid-column: 1 / -1;
    }
}

/* ══════════════════════════════════════════════════════════
   RESPONSIVE: MOBILE (≤640px)
   Bottom tab bar, full-width layouts, 44px+ touch targets
   ══════════════════════════════════════════════════════════ */
@media (max-width: 640px) {

    /* ── Bottom Tab Bar Navigation ─────────────────────── */
    .header {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        z-index: 200;
        border-bottom: none;
        border-top: 1px solid var(--border);
        background: rgba(10, 10, 15, 0.95);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
    }

    .header-inner {
        padding: 0;
        height: auto;
        flex-direction: column;
        max-width: 100%;
    }

    .logo {
        display: none;
        /* hide logo in bottom bar */
    }

    .nav {
        width: 100%;
        display: flex;
        justify-content: space-around;
        gap: 0;
        padding: 0;
    }

    .nav-btn {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 1px;
        padding: 6px 2px 5px;
        font-size: 10px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        min-height: 44px;
        justify-content: center;
        border-radius: 0;
        position: relative;
        letter-spacing: -0.3px;
    }

    .nav-btn.active {
        background: rgba(108, 92, 231, 0.1);
    }

    .nav-btn.active::after {
        content: '';
        position: absolute;
        top: 0;
        left: 20%;
        right: 20%;
        height: 2px;
        background: var(--accent);
        border-radius: 0 0 2px 2px;
    }

    /* Body padding to offset bottom nav */
    body {
        padding-top: 0;
        padding-bottom: calc(54px + env(safe-area-inset-bottom, 0px));
    }

    /* ── Views ─────────────────────────────────────────── */
    .view {
        padding: 0 14px;
    }

    /* ── Hero / Search ────────────────────────────────── */
    .hero {
        padding: 20px 0 14px;
    }

    .hero h1 {
        font-size: 22px;
        line-height: 1.3;
        margin-bottom: 6px;
    }

    .hero-sub {
        font-size: 12px;
        margin-bottom: 16px;
        opacity: 0.8;
        padding: 0 8px;
        line-height: 1.5;
    }

    /* Search box: full width, larger touch targets */
    .search-box {
        border-radius: 12px;
        padding: 4px 4px 4px 14px;
    }

    .search-box input {
        font-size: 16px;
        /* prevents iOS zoom */
        padding: 10px 0;
    }

    .search-box input::placeholder {
        font-size: 14px;
    }

    .search-icon {
        font-size: 16px;
        margin-right: 6px;
    }

    .search-submit {
        padding: 10px 20px;
        font-size: 15px;
        border-radius: 10px;
        min-height: 44px;
        /* Apple HIG min touch target */
    }

    /* Quick Tags: carousel wrap */
    .quick-tags {
        margin-top: 12px;
        gap: 6px;
    }

    .quick-tag {
        padding: 8px 14px;
        font-size: 13px;
        min-height: 36px;
    }

    .tag-label {
        font-size: 12px;
    }

    /* Trending */
    .trending-section {
        margin-top: 12px;
        gap: 8px;
    }

    .trending-tag {
        padding: 6px 14px;
        font-size: 12px;
        min-height: 32px;
    }

    /* Stats Bar: 3-column grid */
    .stats-bar {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
        padding: 10px 0;
        margin-bottom: 10px;
    }

    .stat-chip {
        padding: 6px 8px;
        font-size: 11px;
        justify-content: center;
        gap: 4px;
    }

    /* Cross Hint */
    .cross-hint {
        font-size: 13px;
        padding: 12px 14px;
        margin-bottom: 14px;
    }

    /* ── AI Panel ──────────────────────────────────────── */
    .ai-toolbar {
        justify-content: space-between;
        align-items: center;
        gap: 8px;
        flex-wrap: nowrap;
    }

    .ai-starters {
        justify-content: flex-start;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 4px;
    }

    .ai-starters::-webkit-scrollbar {
        display: none;
    }

    .ai-starter-chip {
        white-space: nowrap;
        flex-shrink: 0;
    }

    .ai-btn {
        width: auto;
        flex: 1 1 auto;
        justify-content: center;
        padding: 12px 20px;
        font-size: 15px;
        min-height: 48px;
        min-width: 0;
    }

    .ai-copy-btn {
        width: 36px;
        height: 36px;
        min-height: 36px;
        padding: 0;
        font-size: 15px;
        margin-left: 0;
    }

    .ai-result {
        padding: 14px;
        margin-top: 12px;
    }

    .ai-result-header {
        font-size: 14px;
        margin-bottom: 10px;
        padding-bottom: 8px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .ai-content {
        font-size: 13px;
        line-height: 1.8;
    }

    .ai-compose {
        flex-direction: column;
        align-items: stretch;
    }

    .ai-followup-input {
        min-height: 64px;
    }

    .ai-send-btn {
        width: 100%;
        min-height: 42px;
    }

    /* ── Subject Tabs: horizontal scroll ───────────────── */
    .subject-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 6px;
        margin-bottom: 14px;
        padding-bottom: 10px;
    }

    .subject-tabs::-webkit-scrollbar {
        display: none;
    }

    .subject-tab {
        padding: 8px 14px;
        font-size: 13px;
        white-space: nowrap;
        flex-shrink: 0;
        min-height: 36px;
    }

    /* ── Related bar: horizontal scroll ────────────────── */
    .related-bar {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 4px;
    }

    .related-bar::-webkit-scrollbar {
        display: none;
    }

    .related-tag {
        padding: 6px 14px;
        min-height: 32px;
    }

    /* ── Advanced Panel ────────────────────────────────── */
    .advanced-panel {
        padding: 12px;
        margin-top: 8px;
    }

    .filter-row {
        flex-direction: column;
        gap: 10px;
    }

    .filter-group {
        min-width: 100%;
    }

    .filter-group select {
        padding: 10px 14px;
        font-size: 14px;
        min-height: 44px;
    }

    .checkbox-label {
        min-height: 44px;
    }

    /* ── Result Cards ──────────────────────────────────── */
    .result-group {
        margin-bottom: 18px;
    }

    .group-header {
        font-size: 16px;
        gap: 8px;
        margin-bottom: 10px;
    }

    .group-icon {
        font-size: 18px;
    }

    .group-count {
        font-size: 12px;
    }

    .result-card {
        padding: 14px;
        margin-bottom: 8px;
        border-radius: 10px;
    }

    .result-meta {
        gap: 6px;
    }

    .result-title {
        font-size: 12px;
    }

    .source-badge {
        font-size: 10px;
        padding: 2px 6px;
    }

    .match-channel {
        font-size: 10px;
        padding: 2px 6px;
    }

    .result-trace {
        gap: 6px;
        margin: 4px 0 6px;
    }

    .evidence-chip {
        font-size: 10px;
        padding: 2px 8px;
    }

    .relation-path {
        font-size: 11px;
    }

    .result-snippet {
        font-size: 14px;
        line-height: 1.6;
    }

    .result-text {
        font-size: 13px;
        line-height: 1.7;
        max-height: 350px;
    }

    .result-img {
        max-height: 240px;
        border-radius: 6px;
        margin: 8px 0;
    }

    /* ── Knowledge Graph ───────────────────────────────── */
    .graph-header {
        padding: 16px 0 10px;
    }

    .graph-header h2 {
        font-size: 22px;
    }

    .graph-header p {
        font-size: 12px;
    }

    .graph-controls {
        justify-content: center;
        margin-top: 8px;
    }

    .graph-mode {
        padding: 8px 16px;
        font-size: 13px;
        min-height: 36px;
    }

    .graph-subject-select {
        padding: 8px 14px;
        font-size: 13px;
        min-height: 36px;
    }

    .graph-container {
        height: calc(100vh - 210px);
        height: calc(100dvh - 210px);
        touch-action: none;
        /* allow D3 zoom/pan */
        border-radius: 10px;
    }

    /* Search subgraph */
    .search-graph-section {
        padding: 12px;
        margin: 14px 0;
    }

    .search-graph-title {
        font-size: 14px;
    }

    /* ── Data Insights ─────────────────────────────────── */
    .insights-header {
        padding: 16px 0 10px;
    }

    .insights-header h2 {
        font-size: 22px;
    }

    .insights-tabs {
        gap: 6px;
        padding: 0 8px 12px;
    }

    .insight-tab {
        padding: 8px 14px;
        font-size: 12px;
        min-height: 36px;
    }

    .insights-content {
        padding: 0 4px 32px;
    }

    .freq-controls {
        flex-wrap: wrap;
        gap: 6px;
    }

    .freq-controls select {
        flex: 1;
        min-width: 120px;
        min-height: 40px;
        font-size: 13px;
    }

    /* Coverage items */
    .coverage-item {
        padding: 8px 10px;
        gap: 8px;
        flex-wrap: wrap;
    }

    .coverage-term {
        min-width: 60px;
        font-size: 12px;
    }

    .coverage-ratio {
        font-size: 13px;
        min-width: 45px;
    }

    /* ── About ─────────────────────────────────────────── */
    .about-content {
        padding: 16px 0 80px;
        /* extra bottom for nav bar */
    }

    .about-content h2 {
        font-size: 22px;
        margin-bottom: 16px;
    }

    .about-card {
        padding: 14px;
        margin-bottom: 10px;
    }

    .about-card h3 {
        font-size: 15px;
        margin-bottom: 8px;
    }

    .about-card p {
        font-size: 13px;
    }

    /* Footer: above bottom nav */
    .footer {
        padding: 16px 12px;
        padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
        font-size: 12px;
    }

    .footer-meta {
        gap: 8px 12px;
    }

    /* Results: extra bottom padding for nav */
    .results {
        padding-bottom: 20px;
    }

    .gk-results {
        padding-bottom: 20px;
    }

    /* ── Gaokao ────────────────────────────────────────── */
    .gaokao-hero {
        padding: 16px 0 12px;
    }

    .gaokao-hero h2 {
        font-size: 22px;
    }

    .gaokao-hero-sub {
        font-size: 12px;
    }

    .gaokao-filters {
        flex-direction: column;
        gap: 8px;
        padding: 12px;
    }

    .gaokao-filters .filter-group {
        min-width: 100%;
    }

    .gaokao-filters .filter-group select {
        min-height: 44px;
        font-size: 14px;
    }

    .gk-search-btn {
        width: 100%;
        min-height: 44px;
        font-size: 15px;
    }

    .gk-card-header {
        padding: 12px 14px;
    }

    .gk-card-meta {
        gap: 4px;
    }

    .gk-badge {
        font-size: 11px;
        padding: 3px 8px;
    }

    .gk-card-title {
        font-size: 14px;
    }

    .gk-card-preview {
        font-size: 12px;
    }

    .gk-card-body {
        padding: 0 14px 14px;
    }

    .gk-question {
        font-size: 13px;
        line-height: 1.7;
    }

    .gk-actions {
        flex-direction: column;
        gap: 8px;
    }

    .gk-link-btn,
    .gk-ai-btn {
        width: 100%;
        text-align: center;
        min-height: 44px;
        font-size: 14px;
    }

    /* Link panel → bottom sheet */
    .gk-link-panel {
        padding: 0;
        align-items: flex-end;
    }

    .gk-link-inner {
        max-height: 90vh;
        max-height: 90dvh;
        border-radius: 16px 16px 0 0;
        padding: 16px;
        max-width: 100%;
    }

    .gk-link-header h3 {
        font-size: 16px;
    }

    .gk-link-close {
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .gk-link-card {
        padding: 10px 12px;
    }

    /* AI analysis */
    .gk-ai-answer {
        padding: 12px;
    }

    .gk-ai-meta {
        gap: 6px;
    }

    .gk-ai-text {
        font-size: 12px;
        line-height: 1.7;
    }

    .gk-question-img {
        max-height: 200px;
    }

    /* Semantic elements */
    .gk-matched-concepts {
        gap: 4px;
    }

    .matched-concept {
        font-size: 10px;
        padding: 2px 7px;
    }

    .link-type-tag {
        font-size: 10px;
        padding: 2px 6px;
    }

    .gk-link-score-text {
        font-size: 11px;
    }

    .gk-expanded-terms {
        font-size: 11px;
    }

    /* Download button */
    .gk-download-link {
        padding: 20px 12px;
    }

    .download-btn {
        padding: 14px 28px;
        font-size: 14px;
        min-height: 48px;
        width: 100%;
        text-align: center;
    }
}

/* ══════════════════════════════════════════════════════════
   RESPONSIVE: SMALL PHONES (≤380px)
   ══════════════════════════════════════════════════════════ */
@media (max-width: 380px) {
    .hero h1 {
        font-size: 19px;
    }

    .nav-btn {
        font-size: 10px;
        padding: 6px 2px;
    }

    .search-submit {
        padding: 10px 14px;
        font-size: 14px;
    }

    .concept-carousel {
        gap: 4px;
    }

    .quick-tag {
        padding: 6px 10px;
        font-size: 12px;
    }

    .stats-bar {
        grid-template-columns: repeat(2, 1fr);
    }

    .stat-chip {
        font-size: 10px;
        padding: 5px 6px;
    }

    .subject-tab {
        padding: 6px 10px;
        font-size: 12px;
    }

    .insight-tab {
        padding: 6px 10px;
        font-size: 11px;
    }

    .graph-container {
        height: calc(100vh - 190px);
        height: calc(100dvh - 190px);
    }
}

/* ══════════════════════════════════════════════════════════
   RESPONSIVE: LANDSCAPE PHONE
   ══════════════════════════════════════════════════════════ */
@media (max-width: 640px) and (orientation: landscape) {
    .hero {
        padding: 10px 0 8px;
    }

    .hero h1 {
        font-size: 18px;
    }

    .hero-sub {
        font-size: 11px;
        margin-bottom: 10px;
    }

    .graph-container {
        height: calc(100vh - 120px);
        height: calc(100dvh - 120px);
    }

    .nav-btn {
        flex-direction: row;
        gap: 4px;
        padding: 6px 8px;
        min-height: 40px;
    }
}

/* ══════════════════════════════════════════════════════════
   iOS Safe Areas (notch, home indicator)
   ══════════════════════════════════════════════════════════ */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    @media (max-width: 640px) {
        .header {
            padding-bottom: env(safe-area-inset-bottom);
        }

        body {
            padding-bottom: calc(54px + env(safe-area-inset-bottom));
        }
    }
}

/* ══════════════════════════════════════════════════════════
   Page Badge & Result Actions
   ══════════════════════════════════════════════════════════ */
.page-badge {
    font-size: 11px;
    background: rgba(116, 185, 255, 0.12);
    color: #74b9ff;
    padding: 2px 8px;
    border-radius: 10px;
    cursor: default;
}

.result-actions {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
}

.result-card.expanded .result-actions {
    display: flex;
}

.result-card:not(.expanded) .result-actions {
    display: none;
}

.view-page-btn {
    background: linear-gradient(135deg, rgba(108, 92, 231, 0.15), rgba(116, 185, 255, 0.1));
    border: 1px solid rgba(108, 92, 231, 0.3);
    color: var(--accent-light);
    padding: 8px 20px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: var(--transition);
}

.view-page-btn:hover {
    background: linear-gradient(135deg, rgba(108, 92, 231, 0.25), rgba(116, 185, 255, 0.2));
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(108, 92, 231, 0.2);
}

.view-page-note {
    background: rgba(255, 184, 108, 0.12);
    border: 1px solid rgba(255, 184, 108, 0.28);
    color: #ffcf85;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    cursor: default;
}

/* ══════════════════════════════════════════════════════════
   Rich Text: Tables & Paragraphs
   ══════════════════════════════════════════════════════════ */
.result-table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
    font-size: 13px;
}

.result-table th,
.result-table td {
    padding: 8px 12px;
    border: 1px solid var(--border);
    text-align: left;
}

.result-table th {
    background: rgba(108, 92, 231, 0.1);
    font-weight: 600;
    color: var(--accent-light);
}

.result-table td {
    background: rgba(255, 255, 255, 0.02);
}

.result-table tr:hover td {
    background: rgba(108, 92, 231, 0.04);
}

.result-para {
    margin-bottom: 8px;
    text-indent: 0;
}

.result-para:last-child {
    margin-bottom: 0;
}

/* KaTeX display math */
.katex-display {
    display: block;
    text-align: center;
    margin: 12px 0;
    overflow-x: auto;
}

.katex-inline {
    display: inline;
}

/* ══════════════════════════════════════════════════════════
   Page Image Viewer (Lightbox)
   ══════════════════════════════════════════════════════════ */
.page-viewer-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.page-viewer-overlay.closing {
    animation: fadeOut 0.2s ease forwards;
}

@keyframes fadeOut {
    to {
        opacity: 0;
    }
}

.page-viewer-modal {
    display: flex;
    flex-direction: column;
    width: min(95vw, 900px);
    height: min(92vh, 850px);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 20px 80px rgba(0, 0, 0, 0.6);
}

.page-viewer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: rgba(10, 10, 15, 0.6);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.page-viewer-title {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60%;
}

.page-viewer-page {
    font-size: 13px;
    color: var(--accent-light);
    background: rgba(108, 92, 231, 0.15);
    padding: 4px 12px;
    border-radius: 12px;
    font-weight: 600;
}

.page-viewer-close {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-dim);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.page-viewer-close:hover {
    color: #ff6b6b;
    border-color: #ff6b6b;
    background: rgba(255, 107, 107, 0.1);
}

.page-viewer-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    min-height: 0;
}

.page-viewer-image-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    overflow: auto;
    padding: 12px;
    position: relative;
}

.page-viewer-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
    transition: opacity 0.3s ease;
}

.page-viewer-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--text-muted);
    font-size: 13px;
    position: absolute;
    inset: 0;
}

.page-loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--accent-light);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.page-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(10, 10, 15, 0.7);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    color: var(--text);
    width: 44px;
    height: 64px;
    font-size: 28px;
    cursor: pointer;
    border-radius: 10px;
    transition: var(--transition);
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
}

.page-nav-btn.prev {
    left: 10px;
}

.page-nav-btn.next {
    right: 10px;
}

.page-nav-btn:hover:not(:disabled) {
    background: rgba(108, 92, 231, 0.3);
    border-color: var(--accent);
}

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

.page-viewer-thumbnails {
    display: flex;
    gap: 8px;
    padding: 10px 16px;
    background: rgba(10, 10, 15, 0.5);
    border-top: 1px solid var(--border);
    overflow-x: auto;
    flex-shrink: 0;
    justify-content: center;
}

.page-thumb {
    flex-shrink: 0;
    cursor: pointer;
    text-align: center;
    border-radius: 6px;
    border: 2px solid transparent;
    padding: 4px;
    transition: var(--transition);
}

.page-thumb:hover {
    border-color: var(--accent);
}

.page-thumb.active {
    border-color: var(--accent-light);
    background: rgba(108, 92, 231, 0.15);
}

.page-thumb img {
    width: 60px;
    height: 80px;
    object-fit: cover;
    border-radius: 3px;
    display: block;
}

.page-thumb span {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 2px;
    display: block;
}

.page-thumb.active span {
    color: var(--accent-light);
    font-weight: 600;
}

.page-viewer-footer {
    padding: 8px 20px;
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

/* ── Page Viewer Mobile ──────────────────────────────── */
@media (max-width: 640px) {
    .page-viewer-modal {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
    }

    .page-nav-btn {
        width: 36px;
        height: 48px;
        font-size: 22px;
    }

    .page-thumb img {
        width: 48px;
        height: 64px;
    }

    .page-viewer-title {
        max-width: 50%;
        font-size: 13px;
    }
}
