/* ============================================
   倪海厦知识图谱 — 设计系统
   ============================================ */

:root {
    /* 色彩 */
    --bg: #f6f0e6;
    --paper: #fffaf1;
    --paper-soft: #fbf5ea;
    --ink: #241f1a;
    --text: #342d25;
    --text-light: #776b5f;
    --muted: #a59684;
    --border: #e7d8c1;
    --accent: #b9362c;
    --accent-dark: #7f211c;
    --accent-gold: #c7892b;
    --accent-green: #2c705f;
    --accent-blue: #315d82;
    --card-bg: #fffaf1;
    --shadow: 0 18px 45px rgba(73, 43, 20, 0.09);
    --small-shadow: 0 8px 24px rgba(73, 43, 20, 0.08);

    /* 层级颜色 */
    --layer-cosmology: #b9362c;
    --layer-diagnosis: #315d82;
    --layer-treatment: #2c705f;
    --layer-cases: #c7892b;
    --layer-tianji: #7b5ea7;

    /* 尺寸 */
    --header-h: 56px;
    --sidebar-w: 260px;
    --sidebar-collapsed: 0px;
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

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

html, body { overflow-x: clip; width: 100%; }

body {
    font-family: "Songti SC", "Noto Serif SC", "STSong", "PingFang SC", "Hiragino Sans GB", serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    background-image:
        linear-gradient(90deg, rgba(185, 54, 44, 0.035) 1px, transparent 1px),
        linear-gradient(180deg, rgba(185, 54, 44, 0.035) 1px, transparent 1px);
    background-size: 44px 44px;
}

/* ============================================
   Header
   ============================================ */

.header {
    background: rgba(255, 250, 241, 0.92);
    border-bottom: 1px solid #e7d8c1;
    position: sticky;
    top: 0;
    z-index: 100;
    width: 100%;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    transition: box-shadow var(--transition-normal);
}

.header.scrolled {
    box-shadow: 0 2px 16px rgba(73, 43, 20, 0.08);
    -webkit-backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    transition: box-shadow var(--transition-normal);
}

.header-content {
    max-width: 100%;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    height: var(--header-h);
    gap: 16px;
    animation: fadeInUp var(--transition-slow);
}

.sidebar-toggle {
    display: flex;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--text);
    padding: 6px;
    border-radius: 4px;
    flex-shrink: 0;
}

.sidebar-toggle:hover { background: var(--bg); }

.logo {
    font-size: 17px;
    font-weight: 700;
    color: var(--accent);
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
}

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

.nav-btn {
    padding: 7px 14px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 14px;
    color: #999;
    border-radius: 6px;
    transition: all var(--transition-normal);
    white-space: nowrap;
    text-decoration: none;
    font-family: inherit;
    font-weight: 400;
}

.nav-btn:hover { color: #333; }
.nav-btn.active { background: var(--accent); color: #fff; font-weight: 500; }

.header-search {
    position: relative;
    flex: 1;
    max-width: 280px;
    margin-left: auto;
}

.header-search input {
    width: 100%;
    padding: 7px 14px;
    border: 1px solid #e7d8c1;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    background: #fbf5ea;
    color: var(--text);
}

.header-search input:focus {
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    border-color: #c7892b;
    background: #fffaf1;
}

.search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
    max-height: 400px;
    overflow-y: auto;
    display: none;
    z-index: 200;
}

.search-dropdown.show { display: block; }

.search-dropdown-item {
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}

.search-dropdown-item:last-child { border-bottom: none; }
.search-dropdown-item:hover { background: var(--bg); }
.search-dropdown-item-title { font-weight: 600; font-size: 14px; }
.search-dropdown-item-sub { font-size: 12px; color: var(--text-light); margin-top: 2px; }

.node-count {
    font-size: 12px;
    color: #bbb;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ============================================
   Sidebar（左侧目录栏）
   ============================================ */

.sidebar {
    position: fixed;
    left: 0;
    top: var(--header-h);
    bottom: 0;
    width: var(--sidebar-w);
    background: #fffaf1;
    border-right: 1px solid #e7d8c1;
    z-index: 90;
    overflow-y: auto;
    transition: transform var(--transition-slow);
}

/* 桌面端折叠状态 */
.sidebar.collapsed {
    transform: translateX(-100%);
}

.sidebar.collapsed ~ .main {
    margin-left: 0;
    width: 100%;
}

.sidebar.collapsed ~ .site-footer {
    left: 0;
}

.sidebar-header {
    padding: 20px 20px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: #fffaf1;
    z-index: 1;
}

.sidebar-title {
    font-size: 13px;
    font-weight: 600;
    color: #999;
}

.sidebar-count {
    font-size: 12px;
    color: #bbb;
}

.sidebar-nav {
    padding: 0 12px 20px;
}

.sidebar-group {
    margin-bottom: 2px;
}

.sidebar-group-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 8px;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.15s;
    user-select: none;
}

.sidebar-group-header:hover { background: transparent; }

.sidebar-group-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
    transition: transform var(--transition-fast);
    transition: transform var(--transition-fast);
    opacity: 0.7;
}

.sidebar-group-name {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    flex: 1;
}

.sidebar-group-count {
    font-size: 12px;
    color: #bbb;
    font-weight: 400;
}

.sidebar-group-arrow {
    font-size: 9px;
    color: #ccc;
    transition: transform 0.2s;
}

.sidebar-group.expanded .sidebar-group-arrow { transform: rotate(90deg); }

.sidebar-group-items {
    display: none;
    padding-left: 22px;
}

.sidebar-group.expanded .sidebar-group-items { display: block; }

.sidebar-item {
    display: block;
    padding: 5px 8px;
    font-size: 13px;
    color: #888;
    text-decoration: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all var(--transition-fast);
    border-left: 2px solid transparent;
    line-height: 1.5;
}

.sidebar-item:hover {
    background: #f3e3ca;
    color: #333;
}

.sidebar-item.active {
    color: var(--accent);
    border-left-color: var(--accent);
    font-weight: 500;
}

.sidebar-item-type {
    display: none;
}

/* ============================================
   Main Content
   ============================================ */

.main {
    margin-left: var(--sidebar-w);
    padding: 24px 24px 72px;
    width: calc(100% - var(--sidebar-w));
    transition: margin-left 0.3s ease;
}

.view { display: none; }
.view.active { display: block; }

/* ============================================
   New Hero / Overview
   ============================================ */

.hero-new {
    text-align: center;
    padding: 48px 24px 32px;
    margin-bottom: 32px;
}

.hero-new .eyebrow {
    font-size: 12px;
    letter-spacing: 0.15em;
    color: var(--muted);
    margin-bottom: 16px;
}

.hero-title {
    font-size: 48px;
    font-weight: 300;
    line-height: 1.15;
    color: var(--ink);
    margin-bottom: 16px;
    letter-spacing: -0.02em;
}

.hero-title-accent {
    color: var(--accent);
    font-weight: 700;
}

.hero-subtitle {
    font-size: 16px;
    color: var(--text-light);
    max-width: 600px;
    margin: 0 auto 20px;
    line-height: 1.6;
}

.hero-stats {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-light);
}

.hero-stat strong {
    color: var(--text);
    font-weight: 600;
}

.hero-stat-sep { color: var(--muted); }

/* 阶段卡片 */
.stages-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    margin-bottom: 32px;
}

.stage-card {
    padding: 20px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition-normal);
    text-align: left;
    background: var(--paper);
    text-decoration: none;
    color: var(--text);
}

.stage-card:hover {
    border-color: var(--accent);
    box-shadow: var(--small-shadow);
}

.stage-card.active {
    border-color: var(--accent);
    border-bottom: 2px solid var(--accent);
}

.stage-num {
    font-size: 12px;
    color: var(--accent);
    font-weight: 700;
    margin-bottom: 6px;
}

.stage-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 4px;
}

.stage-desc {
    font-size: 12px;
    color: var(--text-light);
    line-height: 1.4;
}

.stage-content {
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 32px;
    display: none;
}

.stage-content.active { display: block; }

.stage-content-text {
    font-size: 14px;
    color: var(--text-light);
    line-height: 1.7;
    margin-bottom: 16px;
    padding-left: 16px;
    border-left: 2px solid var(--accent);
}

.stage-nodes {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.stage-node {
    padding: 5px 14px;
    background: var(--bg);
    border-radius: 4px;
    font-size: 13px;
    text-decoration: none;
    color: var(--text);
    transition: all var(--transition-fast);
}

.stage-node:hover {
    background: var(--accent);
    color: #fff;
}

/* 路径卡片（新版） */
.route-cards-new {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    animation: fadeInUp var(--transition-slow);
    margin-bottom: 32px;
}

.route-card-new {
    display: grid;
    gap: 8px;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--paper);
    text-decoration: none;
    color: var(--text);
    transition: all var(--transition-normal);
}

.route-card-new:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: var(--small-shadow);
}

.route-card-num {
    font-size: 12px;
    color: var(--accent);
    font-weight: 700;
}

.route-card-new strong {
    font-size: 17px;
    color: var(--ink);
}

.route-card-new span:last-child {
    font-size: 13px;
    color: var(--text-light);
    line-height: 1.5;
}

.overview-footer {
    text-align: center;
    padding: 20px;
    font-size: 12px;
    color: var(--muted);
}

/* ============================================
   Path View（学习路径）
   ============================================ */

.path-view {
    background: var(--card-bg);
    padding: 28px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    border: 1px solid rgba(145, 107, 66, 0.2);
}

.path-view h2 { font-size: 22px; margin-bottom: 8px; }
.path-desc { color: var(--text-light); margin-bottom: 20px; }

.path-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0;
}

.path-tab {
    padding: 10px 20px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 15px;
    font-weight: 700;
    color: var(--text-light);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all var(--transition-normal);
    font-family: inherit;
}

.path-tab:hover { color: var(--text); }
.path-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.path-content { display: none; }
.path-content.active { display: block; }

.path-stages { display: flex; flex-direction: column; gap: 16px;
    animation: fadeInUp var(--transition-slow); }

.path-stage {
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.path-stage-header {
    background: var(--bg);
    padding: 12px 16px;
    font-weight: 700;
    font-size: 15px;
}

.path-stage-content { padding: 14px 16px; }

.path-node-list { display: flex; flex-wrap: wrap; gap: 8px; }

.path-node {
    padding: 6px 14px;
    background: var(--bg);
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: all var(--transition-normal);
    text-decoration: none;
    color: var(--text);
}

.path-node:hover { background: var(--accent); color: #fff; }

/* ============================================
   Graph View（知识图谱）
   ============================================ */

.graph-view {
    background: #fffaf1;
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--header-h) - 72px);
    margin: -24px -24px -72px;
    padding: 0;
}


.graph-container {
    position: relative;
    flex: 1;
    min-height: 0;
    background: #f6f0e6;
}

.graph-canvas {
    position: absolute;
    inset: 0 0 40px 0;
    background: #f6f0e6;
    touch-action: none;
}

.graph-canvas svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* 图例卡 */
.graph-legend {
    position: absolute;
    bottom: 56px;
    left: 16px;
    background: rgba(255, 250, 241, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 8px;
    padding: 14px 16px;
    box-shadow: 0 2px 12px rgba(73, 43, 20, 0.1);
    z-index: 5;
    width: 150px;
}

.graph-legend-title {
    font-size: 11px;
    font-weight: 700;
    color: #a59684;
    margin-bottom: 8px;
    letter-spacing: 0.05em;
}

.graph-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 0;
    font-size: 12px;
    color: #342d25;
    line-height: 1.4;
}

.graph-legend-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
    transition: transform var(--transition-fast);
    transition: transform var(--transition-fast);
}

.graph-legend-dot--core {
    width: 14px;
    height: 14px;
    background: var(--on-surface-faint, #999);
}

.graph-legend-dot--standard {
    width: 7px;
    height: 7px;
    background: var(--on-surface-faint, #999);
}

.route-notice {
    margin: 0 0 16px;
    padding: 10px 14px;
    border-radius: 8px;
    background: rgba(192, 57, 43, 0.08);
    border: 1px solid rgba(192, 57, 43, 0.2);
    color: var(--accent, #b9362c);
    font-size: 14px;
    text-align: center;
}

.graph-legend-divider {
    height: 1px;
    background: #e7d8c1;
    margin: 6px 0;
}

.graph-legend-hint {
    font-size: 11px;
    color: #a59684;
    margin-top: 2px;
    line-height: 1.4;
}

.graph-detail-panel {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 340px;
    border-left: 1px solid var(--border);
    padding: 20px;
    overflow-y: auto;
    background: var(--paper);
    box-shadow: -6px 0 24px rgba(0,0,0,0.06);
    transform: translateX(100%);
    transition: transform var(--transition-slow);
    z-index: 10;
}

.graph-detail-panel.open {
    transform: translateX(0);
}

.graph-detail-panel .placeholder {
    color: var(--text-light);
    text-align: center;
    padding: 40px 20px;
    font-size: 14px;
}

.detail-link-item {
    display: inline-block;
    padding: 3px 10px;
    background: var(--bg);
    border: 1px solid transparent;
    border-radius: 4px;
    font-size: 12px;
    text-decoration: none;
    color: var(--text);
    margin: 2px;
    cursor: pointer;
    transition: border-color var(--transition-fast), background var(--transition-fast);
}

.detail-link-item:hover {
    border-color: var(--accent);
    background: #f3e3ca;
}

/* ============================================
   图谱节点样式 — 分层标签策略
   ============================================ */
.graph-node {
    cursor: pointer;
    outline: none;
}
.graph-node circle {
    transition: opacity 0.25s, stroke-width 0.18s, fill-opacity 0.18s;
}
.graph-node:hover circle {
    opacity: 1;
    fill-opacity: 0.95;
}

/* 文本基础（pointer-events:none 让 hover 命中圆点而非文字） */
.graph-node text {
    pointer-events: none;
    font-family: inherit;
    transition: opacity 0.18s ease;
}

/* —— 核心节点：标签常显 —— */
.graph-node.tier-core text {
    font-size: 13px;
    font-weight: 700;
    fill: #2d2520;
    opacity: 1;
}
.graph-node.tier-core circle {
    stroke: #fff;
    stroke-width: 2;
    fill-opacity: 0.95;
}

/* —— 普通节点：标签默认隐藏 —— */
.graph-node.tier-standard text {
    font-size: 9px;
    font-weight: 400;
    fill: #9a9289;
    opacity: 0;
}
.graph-node.tier-standard circle {
    stroke: rgba(255, 255, 255, 0.2);
    stroke-width: 0.5;
    fill-opacity: 0.65;
}

/* 普通节点标签的触发显示 */
.graph-node.tier-standard.hovered text,
.graph-node.tier-standard.selected text,
.graph-node.tier-standard.search-match text,
.graph-node.tier-standard.concept-match text {
    opacity: 1;
}

/* 放大到阈值后，所有普通节点标签显示 */
.viewport.zoomed-in .graph-node.tier-standard text {
    opacity: 1;
}

/* —— 选中节点视觉 —— */
.graph-node.selected circle {
    stroke: var(--accent-gold);
    stroke-width: 3;
}

/* —— 键盘焦点状态 —— */
.graph-node:focus-visible {
    outline: 2px solid var(--accent-gold);
    outline-offset: 4px;
    border-radius: 4px;
}
.graph-node:focus-visible circle {
    stroke: var(--accent-gold);
    stroke-width: 3;
}
/* SVG 元素 outline 在某些浏览器不渲染，补一个等价的视觉环 */
.graph-node.focused circle {
    stroke: var(--accent-gold);
    stroke-width: 3;
}

/* —— 搜索命中 —— */
.graph-node.search-match circle {
    stroke: var(--accent-gold);
    stroke-width: 2.5;
}
.graph-node.search-match text {
    fill: var(--accent-dark);
    font-weight: 600;
}

/* —— 概念筛选：命中 / 暗化 —— */
.graph-node.concept-match circle {
    stroke: var(--accent);
    stroke-width: 2.2;
    fill-opacity: 0.95;
}
.graph-node.concept-dim {
    opacity: 0.12;
}
.graph-link.concept-match {
    stroke: var(--accent);
    stroke-opacity: 0.55;
    stroke-width: 1;
}
.graph-link.concept-dim {
    stroke-opacity: 0.04;
}

/* 边 */
.graph-link {
    stroke: #ccc;
    stroke-opacity: 0.25;
    stroke-width: 0.5;
    fill: none;
    transition: stroke-opacity 0.18s, stroke 0.18s;
}
.graph-link.highlighted {
    stroke: var(--accent);
    stroke-opacity: 0.6;
    stroke-width: 1;
}
.graph-node.dimmed { opacity: 0.1; }
.graph-link.dimmed { opacity: 0.02; }

/* ============================================
   顶部大概念框 — 视觉锚点 + 筛选入口
   ============================================ */
.graph-concepts {
    position: absolute;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    padding: 6px;
    background: rgba(255, 250, 241, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(73, 43, 20, 0.1);
    z-index: 6;
    max-width: calc(100% - 32px);
    overflow-x: auto;
    scrollbar-width: thin;
}
.graph-concepts::-webkit-scrollbar { height: 4px; }
.graph-concepts::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.graph-concept-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 64px;
    padding: 7px 12px 6px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: var(--paper-soft);
    cursor: pointer;
    font-family: inherit;
    transition: all var(--transition-normal);
    -webkit-tap-highlight-color: transparent;
}
.graph-concept-box:hover {
    border-color: var(--accent);
    background: #f3e3ca;
    transform: translateY(-1px);
}
.graph-concept-box.active {
    border-color: var(--accent);
    background: var(--accent);
    box-shadow: 0 4px 12px rgba(185, 54, 44, 0.24);
}
.graph-concept-box.active .graph-concept-label,
.graph-concept-box.active .graph-concept-desc {
    color: #fff;
}
.graph-concept-label {
    font-size: 15px;
    font-weight: 700;
    color: var(--ink);
    line-height: 1.2;
    letter-spacing: 0.02em;
}
.graph-concept-desc {
    font-size: 10px;
    color: var(--text-light);
    margin-top: 2px;
    line-height: 1.2;
    white-space: nowrap;
}
.graph-concept-box:focus-visible {
    outline: 2px solid var(--accent-gold);
    outline-offset: 2px;
}

/* ============================================
   Note View（概念详情页）
   ============================================ */

.note-view {
    max-width: 800px;
    margin: 0 auto;
    background: var(--paper);
    border: 1px solid rgba(145, 107, 66, 0.2);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    padding: 40px 48px;
    animation: fadeInUp var(--transition-slow);
}

.note-breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
    font-size: 13px;
}

.note-back {
    color: var(--text-light);
    text-decoration: none;
    cursor: pointer;
    transition: color 0.15s;
}

.note-back:hover { color: var(--accent); }

.note-breadcrumb-sep { color: var(--muted); }

.note-breadcrumb-current { color: var(--text); font-weight: 600; }

.note-meta {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.note-tag {
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid var(--border);
    color: var(--text-light);
    background: var(--paper-soft);
}

.note-tag.layer { border-color: var(--accent); color: var(--accent); }

.note-title {
    font-size: 32px;
    font-weight: 800;
    color: var(--ink);
    margin-bottom: 16px;
    line-height: 1.2;
}

.note-definition {
    font-size: 18px;
    color: var(--text-light);
    line-height: 1.6;
    padding: 16px 20px;
    border-left: 3px solid var(--accent);
    background: var(--paper-soft);
    border-radius: 0 8px 8px 0;
    margin-bottom: 32px;
}

.note-section {
    margin-bottom: 32px;
}

.note-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 18px;
    font-weight: 700;
    color: var(--ink);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.note-section-icon {
    font-size: 20px;
}

.note-section-content {
    font-size: 15px;
    line-height: 1.9;
    color: var(--text);
}

.note-section-content p { margin-bottom: 12px; }
.note-section-content ul, .note-section-content ol { padding-left: 24px; margin-bottom: 12px; }
.note-section-content li { margin-bottom: 6px; }

/* 核心理解中的内链 */
.note-link {
    color: var(--accent);
    text-decoration: none;
    cursor: pointer;
    border-bottom: 1px solid rgba(185, 54, 44, 0.3);
    transition: border-color 0.15s;
}

.note-link:hover { border-bottom-color: var(--accent); }

/* 原文金句 */
.note-quotes {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.note-quote {
    padding: 14px 18px;
    border-left: 3px solid var(--accent);
    background: var(--paper-soft);
    border-radius: 0 8px 8px 0;
}

.note-quote-text {
    font-size: 14px;
    line-height: 1.7;
    color: var(--text);
    font-style: italic;
}

.note-quote-source {
    display: block;
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-light);
}

/* 常见误区 */
.note-misconception {
    padding: 14px 18px;
    background: #fff8f0;
    border: 1px solid #f0d0a0;
    border-radius: 8px;
    margin-bottom: 12px;
}

.note-misconception-wrong {
    font-weight: 700;
    color: var(--accent-dark);
    margin-bottom: 6px;
    font-size: 14px;
}

.note-misconception-wrong::before {
    content: "✗ ";
    color: var(--accent);
}

.note-misconception-correction {
    font-size: 14px;
    color: var(--text);
    line-height: 1.6;
}

/* 关联节点 */
.note-related {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    animation: fadeInUp var(--transition-slow);
}

.note-related-group h4 {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}

.note-related-group-desc {
    font-size: 12px;
    color: var(--text-light);
    margin-bottom: 8px;
}

.note-related-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.note-related-node {
    padding: 5px 12px;
    background: var(--bg);
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    color: var(--text);
    border: 1px solid transparent;
}

.note-related-node:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* ============================================
   Prompts View（提示词工具包）
   ============================================ */

.prompts-view {
    background: var(--card-bg);
    padding: 28px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    border: 1px solid rgba(145, 107, 66, 0.2);
}

.prompt-notice {
    background: #fdf6e3;
    border: 1px solid #e7d8c1;
    border-left: 3px solid #8e44ad;
    padding: 14px 18px;
    border-radius: 0 8px 8px 0;
    font-size: 13px;
    color: var(--text-light);
    line-height: 1.6;
    margin-bottom: 20px;
}

.prompt-notice strong {
    color: var(--text);
}

.prompt-skill-card {
    display: grid;
    grid-template-columns: minmax(240px, 0.8fr) minmax(0, 1.2fr);
    gap: 20px;
    align-items: center;
    background: #f7f0fb;
    border: 1px solid #d5b8e8;
    border-left: 4px solid #8e44ad;
    border-radius: 0 8px 8px 0;
    padding: 18px 20px;
    margin-bottom: 20px;
}

.prompt-skill-kicker {
    font-size: 11px;
    font-weight: 700;
    color: #8e44ad;
    letter-spacing: 0.08em;
    margin-bottom: 6px;
}

.prompt-skill-copy h2 {
    font-size: 18px;
    color: var(--ink);
    margin-bottom: 8px;
}

.prompt-skill-copy p {
    font-size: 13px;
    color: var(--text-light);
    line-height: 1.6;
}

.prompt-skill-install {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
}

.prompt-terminal {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid #d5b8e8;
    border-radius: 6px;
    background: #fffaf1;
    color: var(--text);
}

.prompt-terminal-mark {
    color: #8e44ad;
    font-family: "SF Mono", "Menlo", "Consolas", "Liberation Mono", monospace;
    font-size: 12px;
    font-weight: 700;
}

.prompt-terminal code {
    display: block;
    min-width: 0;
    overflow-x: auto;
    padding-bottom: 1px;
    font-family: "SF Mono", "Menlo", "Consolas", "Liberation Mono", monospace;
    font-size: 11px;
    line-height: 1.5;
    white-space: nowrap;
    scrollbar-width: thin;
}

.prompt-skill-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.prompt-skill-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 7px 16px;
    border: 1px solid #8e44ad;
    border-radius: 6px;
    color: #8e44ad;
    background: rgba(255, 250, 241, 0.72);
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
    transition: all var(--transition-normal);
}

.prompt-skill-link:hover {
    background: #8e44ad;
    color: #fff;
}

.prompt-toolbar {
    display: flex;
    gap: 6px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.prompt-filter {
    padding: 7px 16px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--paper);
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    color: var(--text-light);
    transition: all var(--transition-normal);
}

.prompt-filter:hover {
    border-color: #8e44ad;
    color: var(--text);
}

.prompt-filter.active {
    background: #8e44ad;
    border-color: #8e44ad;
    color: #fff;
    font-weight: 500;
}

.prompt-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    animation: fadeInUp var(--transition-slow);
}

.prompt-empty {
    text-align: center;
    color: var(--muted);
    padding: 40px 20px;
    font-size: 14px;
}

.prompt-card {
    border: 1px solid var(--border);
    border-left: 4px solid #8e44ad;
    border-radius: 0 8px 8px 0;
    background: var(--paper);
    overflow: hidden;
}

.prompt-card-header {
    padding: 18px 20px 14px;
    border-bottom: 1px solid var(--border);
}

.prompt-card-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--ink);
    margin-bottom: 4px;
}

.prompt-card-subtitle {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 10px;
}

.prompt-card-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.prompt-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    background: #f0e6f6;
    color: #8e44ad;
    border: 1px solid #d5b8e8;
}

.prompt-card-body {
    padding: 16px 20px 20px;
}

.prompt-card-meta {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}

.prompt-meta-item {
    display: flex;
    gap: 10px;
    font-size: 13px;
    line-height: 1.5;
}

.prompt-meta-label {
    flex-shrink: 0;
    min-width: 64px;
    font-weight: 600;
    color: var(--text-light);
}

.prompt-meta-value {
    color: var(--text);
}

.prompt-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.prompt-tab {
    padding: 8px 16px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-light);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all var(--transition-normal);
    font-family: inherit;
}

.prompt-tab:hover {
    color: var(--text);
}

.prompt-tab.active {
    color: #8e44ad;
    border-bottom-color: #8e44ad;
}

.prompt-content {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 2px 0 0;
    margin-bottom: 4px;
}

.prompt-content pre {
    font-family: inherit;
    font-size: 13px;
    line-height: 1.75;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
    max-height: 420px;
    overflow-y: auto;
    padding: 10px 4px 8px 14px;
    border-left: 2px solid rgba(123, 94, 167, 0.28);
    background: transparent;
}

.prompt-template-section {
    margin-bottom: 4px;
}

.prompt-template-label {
    font-size: 12px;
    font-weight: 600;
    color: #8e44ad;
    margin-bottom: 6px;
}

.prompt-copy-row {
    text-align: left;
}

.prompt-copy-btn {
    padding: 7px 16px;
    border: 1px solid #8e44ad;
    border-radius: 6px;
    background: #8e44ad;
    color: #fff;
    cursor: pointer;
    font-size: 12px;
    font-family: inherit;
    font-weight: 500;
    transition: all var(--transition-normal);
}

.prompt-copy-btn:hover {
    background: #7d3c98;
    border-color: #7d3c98;
}

.prompt-copy-btn.copied {
    background: #27ae60;
    border-color: #27ae60;
}

.prompt-copy-btn.copy-failed {
    background: #e74c3c;
    border-color: #e74c3c;
}

/* 天纪路径 CTA */
.path-cta {
    padding: 16px 0;
    text-align: center;
}

.path-cta-link {
    display: inline-block;
    padding: 10px 24px;
    border: 1px solid #8e44ad;
    border-radius: 6px;
    background: rgba(142, 68, 173, 0.08);
    color: #8e44ad;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: all var(--transition-normal);
}

.path-cta-link:hover {
    background: #8e44ad;
    color: #fff;
}

/* ============================================
   AI QA View
   ============================================ */

.qa-view {
    max-width: 1180px;
    margin: 0 auto;
    padding: 28px 0 64px;
}

.qa-hero {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: flex-end;
    margin-bottom: 18px;
    padding: 24px 28px;
    background: rgba(255, 250, 241, 0.82);
    border: 1px solid rgba(145, 107, 66, 0.18);
    border-radius: 8px;
    box-shadow: 0 10px 28px rgba(73, 43, 20, 0.06);
}

.qa-hero h2 {
    margin: 4px 0 8px;
    color: var(--ink);
    font-size: 28px;
    line-height: 1.25;
}

.qa-hero p {
    margin: 0;
    color: var(--text-light);
    font-size: 14px;
}

/* 站内知识库问答状态标签（非点击式） */
.qa-status-tag {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0 14px;
    min-height: 30px;
    border-radius: 16px;
    background: rgba(85, 119, 108, 0.08);
    color: #55776C;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.02em;
    border: 1px solid rgba(85, 119, 108, 0.16);
}

.qa-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #55776C;
    box-shadow: 0 0 0 3px rgba(85, 119, 108, 0.18);
    flex-shrink: 0;
}

.qa-notice {
    margin-bottom: 18px;
    padding: 12px 16px;
    border: 1px solid rgba(212, 160, 23, 0.35);
    border-radius: 6px;
    background: rgba(255, 246, 211, 0.72);
    color: #6f5212;
    font-size: 13px;
}

.qa-questions {
    margin-bottom: 18px;
}

.qa-section-heading {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 10px;
}

.qa-section-heading span {
    color: var(--ink);
    font-size: 16px;
    font-weight: 700;
}

.qa-section-heading small {
    color: var(--muted);
    font-size: 12px;
}

.qa-question-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.qa-question-card {
    min-height: 76px;
    padding: 12px 14px;
    border: 1px solid rgba(145, 107, 66, 0.18);
    border-radius: 8px;
    background: rgba(255, 250, 241, 0.78);
    color: var(--text);
    text-align: left;
    font: inherit;
    font-size: 13px;
    line-height: 1.5;
    cursor: pointer;
    transition: border-color 0.16s, box-shadow 0.16s, transform 0.16s;
}

.qa-question-card:hover {
    border-color: rgba(185, 54, 44, 0.36);
    box-shadow: 0 6px 18px rgba(73, 43, 20, 0.08);
    transform: translateY(-1px);
}

.qa-copy-toast {
    min-height: 22px;
    margin-top: 8px;
    color: var(--accent);
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.16s;
}

.qa-copy-toast.show {
    opacity: 1;
}

/* ============================================
   QA Chat — 原生问答框
   ============================================ */

.qa-chat {
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(145, 107, 66, 0.2);
    border-radius: 8px;
    background: #fffaf1;
    box-shadow: 0 12px 32px rgba(73, 43, 20, 0.08);
    overflow: hidden;
}

.qa-chat-messages {
    flex: 1;
    min-height: 420px;
    max-height: calc(100vh - 480px);
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    animation: fadeInUp var(--transition-slow);
    scroll-behavior: smooth;
}

.qa-chat-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-height: 380px;
    text-align: center;
    color: var(--text-light);
}

.qa-chat-empty p {
    margin: 0 0 6px;
    font-size: 15px;
    line-height: 1.6;
}

.qa-chat-empty-hint {
    color: var(--muted);
    font-size: 13px;
}

.qa-chat-message {
    display: flex;
    flex-direction: column;
    max-width: 82%;
    animation: qaMsgIn 0.28s ease-out;
}

@keyframes qaMsgIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.qa-chat-message.user {
    align-self: flex-end;
}

.qa-chat-message.assistant {
    align-self: flex-start;
}

.qa-chat-role {
    font-size: 11px;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--muted);
    letter-spacing: 0.04em;
}

.qa-chat-message.user .qa-chat-role {
    text-align: right;
}

.qa-chat-bubble {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.65;
    word-break: break-word;
}

.qa-chat-message.user .qa-chat-bubble {
    background: var(--accent);
    color: #fff;
    border-bottom-right-radius: 2px;
}

.qa-chat-message.assistant .qa-chat-bubble {
    background: rgba(231, 216, 193, 0.35);
    color: var(--text);
    border-bottom-left-radius: 2px;
    border: 1px solid rgba(231, 216, 193, 0.45);
}

.qa-chat-bubble p { margin: 0 0 8px; }
.qa-chat-bubble p:last-child { margin-bottom: 0; }
.qa-chat-bubble ul, .qa-chat-bubble ol { margin: 6px 0; padding-left: 20px; }
.qa-chat-bubble li { margin-bottom: 4px; }
.qa-chat-bubble .qa-md-heading {
    font-weight: 700;
    font-size: 15px;
    color: var(--ink);
    margin: 12px 0 6px;
    padding-bottom: 3px;
    border-bottom: 1px solid rgba(231, 216, 193, 0.5);
}
.qa-chat-bubble .qa-md-heading:first-child { margin-top: 0; }
.qa-chat-bubble a {
    color: var(--accent-blue);
    text-decoration: underline;
}
.qa-chat-bubble code {
    background: rgba(0,0,0,0.06);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 13px;
}
.qa-chat-bubble pre {
    background: rgba(0,0,0,0.04);
    padding: 10px 14px;
    border-radius: 6px;
    overflow-x: auto;
    font-size: 12px;
    margin: 8px 0;
}

/* ============================================
   引用资料卡片（hybrid RAG knowledge_sources）
   ============================================ */
.qa-sources {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px dashed rgba(145, 107, 66, 0.3);
}

.qa-sources-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 8px;
    letter-spacing: 0.3px;
}

.qa-source-item {
    background: rgba(255, 250, 241, 0.6);
    border: 1px solid rgba(231, 216, 193, 0.6);
    border-left: 3px solid var(--accent-gold);
    border-radius: 6px;
    padding: 8px 12px;
    margin-bottom: 6px;
    font-size: 13px;
    line-height: 1.5;
    overflow-wrap: break-word;
    word-break: break-word;
}

.qa-source-item:last-child {
    margin-bottom: 0;
}

.qa-source-title {
    font-weight: 600;
    color: var(--ink);
    font-size: 13px;
    margin-bottom: 4px;
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 6px;
}

.qa-source-score {
    font-size: 11px;
    font-weight: 500;
    color: var(--accent-green);
    background: rgba(44, 112, 95, 0.08);
    padding: 1px 6px;
    border-radius: 10px;
    white-space: nowrap;
}

.qa-evidence {
    font-size: 12px;
    color: var(--text-light);
    line-height: 1.55;
    padding: 4px 0 0;
    border-top: 1px dotted rgba(165, 150, 132, 0.25);
    margin-top: 4px;
    /* 防止证据摘要过长造成横向溢出 */
    max-height: 6em;
    overflow-y: auto;
    overflow-x: hidden;
}

/* 移动端适配：证据摘要更紧凑 */
@media (max-width: 480px) {
    .qa-source-item {
        padding: 6px 10px;
        font-size: 12px;
    }
    .qa-source-title {
        font-size: 12px;
    }
    .qa-evidence {
        font-size: 11px;
        max-height: 5em;
    }
}

.qa-chat-input-row {
    display: flex;
    gap: 10px;
    padding: 14px 16px;
    border-top: 1px solid rgba(231, 216, 193, 0.72);
    background: rgba(255, 250, 241, 0.96);
    align-items: flex-end;
}

.qa-chat-input {
    flex: 1;
    min-height: 42px;
    max-height: 120px;
    padding: 10px 14px;
    border: 1px solid rgba(145, 107, 66, 0.25);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    font: inherit;
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    outline: none;
    transition: border-color 0.16s, box-shadow 0.16s;
}

.qa-chat-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(185, 54, 44, 0.1);
}

.qa-chat-input::placeholder {
    color: var(--muted);
}

.qa-chat-send {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    transition: background 0.16s, opacity 0.16s;
}

.qa-chat-send:hover {
    background: #a92f27;
}

.qa-chat-send:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.qa-chat-status {
    min-height: 0;
    padding: 0 16px 8px;
    color: var(--muted);
    font-size: 12px;
    text-align: center;
}

/* 清空对话 & 操作区 */
.qa-chat-actions {
    display: flex;
    justify-content: center;
    padding: 0 16px 8px;
}

.qa-chat-clear {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 12px;
    color: var(--muted);
    font-size: 12px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.qa-chat-clear:hover {
    color: var(--text);
    border-color: var(--text-dim);
}

/* provider 标签 */
.qa-provider-tag {
    display: inline-block;
    font-size: 11px;
    font-weight: 500;
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 6px;
    vertical-align: middle;
    background: #e8f5e9;
    color: #2e7d32;
}

.qa-provider-tag.qa-provider-degraded {
    background: #fff3e0;
    color: #e65100;
}

.qa-chat-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    color: var(--muted);
    font-size: 13px;
}

.qa-chat-typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--muted);
    animation: qaDotPulse 1.2s infinite ease-in-out;
}

.qa-chat-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.qa-chat-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes qaDotPulse {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1); }
}

/* ============================================
   Site Footer
   ============================================ */

.site-footer {
    position: fixed;
    bottom: 0;
    left: var(--sidebar-w);
    right: 0;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 12px;
    color: #b0a89e;
    background: rgba(255, 250, 241, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid rgba(231, 216, 193, 0.5);
    z-index: 80;
}

.footer-brand {
    border: none;
    background: none;
    cursor: pointer;
    font-size: 12px;
    color: var(--accent);
    font-weight: 600;
    font-family: inherit;
    padding: 0;
    transition: opacity 0.15s;
}

.footer-brand:hover { opacity: 0.7; }

.footer-popover {
    position: fixed;
    bottom: 52px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    display: none;
}

.footer-popover.show { display: block; }

.footer-popover-card {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    text-align: center;
    min-width: 200px;
}

.footer-popover-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--ink);
    margin-bottom: 12px;
}

.footer-popover-qr {
    width: 160px;
    height: 160px;
    border-radius: 8px;
    object-fit: cover;
    margin-bottom: 10px;
}

.footer-popover-hint {
    font-size: 12px;
    color: var(--text-light);
}

#view-graph .graph-view { padding-bottom: 0; }

@media (max-width: 768px) {
    .site-footer { left: 0; font-size: 11px; height: 36px; }
    .footer-popover { bottom: 44px; left: 16px; right: 16px; transform: none; }
    .footer-popover-card { min-width: auto; }
    .footer-popover-qr { width: 140px; height: 140px; }
}

/* ============================================
   Sidebar Overlay（移动端遮罩）
   ============================================ */

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 89;
}

.sidebar-overlay.show { display: block; }

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 1024px) {
    .graph-container { grid-template-columns: 1fr; }
    .graph-detail-panel { border-left: none; border-top: 1px solid var(--border); max-height: 300px; }
    .stages-row { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
    .stages-row { grid-template-columns: repeat(2, 1fr); }
    .route-cards-new { grid-template-columns: 1fr; gap: 10px; }
}

@media (max-width: 768px) {
    .sidebar-toggle { display: flex; }
    .sidebar { width: 280px; transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0 !important; width: 100%; padding: 16px 12px; }

    .header-content { padding: 0 12px; gap: 6px; overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; }
    .nav { gap: 2px; flex-shrink: 0; }
    .nav-btn { padding: 6px 10px; font-size: 12px; white-space: nowrap; }
    .header-search { max-width: 140px; flex-shrink: 1; min-width: 0; }
    .header-search input { font-size: 12px; }
    .node-count { display: none; }


    .note-view { padding: 24px 20px; }
    .note-title { font-size: 26px; }
    .note-definition { font-size: 16px; padding: 12px 16px; }
    .note-related { grid-template-columns: 1fr; }

    .reader-layout { grid-template-columns: 1fr; }
    .reader-sidebar { max-height: 30vh; }
    .reader-content { max-height: 50vh; }

    .prompts-view { padding: 16px; }
    .prompt-skill-card { grid-template-columns: 1fr; padding: 14px 16px; }
    .prompt-toolbar { gap: 4px; }
    .prompt-filter { padding: 6px 12px; font-size: 12px; }
    .prompt-card-header { padding: 14px 16px 12px; }
    .prompt-card-body { padding: 12px 16px 16px; }
    .prompt-content pre { font-size: 11px; max-height: 300px; }
    .prompt-meta-item { flex-direction: column; gap: 2px; }
    .prompt-meta-label { min-width: auto; }

    .qa-view { padding: 16px 0 64px; }
    .qa-hero {
        display: block;
        padding: 18px 16px;
    }
    .qa-hero h2 { font-size: 22px; }
    .qa-status-tag {
        margin-top: 14px;
    }
    .qa-section-heading {
        display: block;
    }
    .qa-section-heading small {
        display: block;
        margin-top: 2px;
    }
    .qa-question-grid {
        grid-template-columns: 1fr;
    }
    .qa-question-card {
        min-height: 0;
    }
    .qa-chat-messages {
        min-height: 360px;
        max-height: 55vh;
        padding: 14px;
        gap: 12px;
    }
    .qa-chat-message {
        max-width: 90%;
    }
    .qa-chat-bubble {
        font-size: 13px;
        padding: 10px 14px;
    }
    .qa-chat-input-row {
        padding: 10px 12px;
        gap: 8px;
    }
    .qa-chat-input {
        font-size: 13px;
    }
}

@media (max-width: 390px) {
    .header-content { padding: 0 8px; gap: 4px; }
    .logo { font-size: 13px; }
    .nav { gap: 1px; }
    .nav-btn { padding: 5px 6px; font-size: 10px; }
    /* 保留紧凑搜索入口，不再整块隐藏 */
    .header-search {
        display: block;
        max-width: 108px;
        min-width: 72px;
        flex: 1 1 auto;
        margin-left: 4px;
    }
    .header-search input {
        font-size: 11px;
        padding: 5px 8px;
    }
    .main { padding: 8px 6px 72px; }
    .note-view { padding: 16px 14px; }
    .note-title { font-size: 22px; }

    .prompt-tabs { gap: 0; }
    .prompt-tab { padding: 6px 10px; font-size: 11px; }
    .prompt-content { padding: 10px 12px; }
}

/* ============================================
   Final interaction pass
   ============================================ */

.header-content,
.nav-btn,
.header-search input,
.qa-question-card,
.qa-chat-send,
.qa-chat-clear,
.qa-chat-retry,
.footer-brand {
    -webkit-tap-highlight-color: transparent;
}

.nav-btn:focus-visible,
.sidebar-toggle:focus-visible,
.qa-question-card:focus-visible,
.qa-chat-input:focus-visible,
.qa-chat-send:focus-visible,
.qa-chat-clear:focus-visible,
.qa-chat-retry:focus-visible,
.footer-brand:focus-visible {
    outline: 2px solid var(--accent-gold);
    outline-offset: 2px;
}

.qa-chat-empty {
    min-height: 260px;
    padding: 24px;
}

.qa-chat-messages {
    min-height: 260px;
    max-height: min(480px, calc(100vh - 420px));
}

.qa-question-card {
    display: flex;
    align-items: center;
}

.qa-chat-retry {
    align-self: center;
    margin: 0 0 8px;
    padding: 5px 14px;
    border: 1px solid rgba(185, 54, 44, 0.35);
    border-radius: 999px;
    background: rgba(185, 54, 44, 0.06);
    color: var(--accent);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.16s, border-color 0.16s;
}

.qa-chat-retry:hover {
    background: rgba(185, 54, 44, 0.12);
    border-color: var(--accent);
}

.qa-chat-retry[hidden] {
    display: none;
}

.graph-canvas,
.graph-canvas svg,
.graph-node,
.graph-node circle {
    user-select: none;
}

.graph-node circle {
    transition: opacity 0.18s, stroke-width 0.18s;
}

@media (max-width: 768px) {
    :root { --header-h: 90px; }

    .header-content {
        min-height: var(--header-h);
        height: auto;
        padding: 7px 12px 5px;
        display: flex;
        flex-wrap: wrap;
        align-content: center;
        row-gap: 4px;
        overflow: hidden;
    }

    .header-content .sidebar-toggle { order: 1; }
    .header-content .logo { order: 2; }
    .header-content .nav {
        order: 3;
        flex: 0 0 100%;
        width: 100%;
        min-width: 0;
        overflow-x: auto;
        scrollbar-width: none;
        padding: 1px 0 2px;
    }

    .header-content .nav::-webkit-scrollbar { display: none; }
    .header-content .nav-btn { padding: 5px 11px; font-size: 12px; }
    .header-content .header-search {
        display: block;
        max-width: 120px;
        min-width: 80px;
        flex: 1 1 auto;
    }
    .header-content .header-search input {
        font-size: 12px;
        padding: 5px 8px;
    }
    .header-content .node-count { display: none; }

    .qa-chat-messages {
        min-height: 240px;
        max-height: 46vh;
    }

    .qa-chat-empty { min-height: 220px; padding: 18px; }
    .main { padding-bottom: 62px; }
    .graph-view {
        height: calc(100vh - var(--header-h) - 62px);
        margin-bottom: -62px;
    }
    .graph-legend {
        left: 10px;
        bottom: 46px;
        width: 142px;
        padding: 10px 12px;
    }
    .graph-legend-item { font-size: 11px; }
    .graph-legend-hint { font-size: 10px; }

    /* 顶部大概念框：移动端紧凑可横滑 */
    .graph-concepts {
        top: 8px;
        gap: 5px;
        padding: 4px;
        border-radius: 10px;
        max-width: calc(100% - 16px);
    }
    .graph-concept-box {
        min-width: 52px;
        padding: 5px 9px 4px;
    }
    .graph-concept-label { font-size: 13px; }
    .graph-concept-desc { font-size: 9px; }

    /* 移动端普通节点标签字号略大，便于触屏阅读 */
    .graph-node.tier-core text { font-size: 12px; }
}

/* ============================================
   Animations
   ============================================ */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes messageIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes qaTyping {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1); }
}
