:root {
    --qh-ink: #252018;
    --qh-muted: #8d8985;
    --qh-line: #e8e4df;
    --qh-panel: #fbfaf8;
    --qh-side: #f5f8fb;
    --qh-shell-sidebar-width: 260px;
    --qh-blue-soft: #e7f3ff;
    --qh-blue: #1683e8;
    --qh-cream: #f5f1eb;
    --qh-lilac: #f6f0ff;
    --qh-shadow: 0 10px 34px rgba(31, 35, 40, 0.08);
    --medical-blue: #0067c8;
    --secondary-blue: #5b9fe8;
}

* { box-sizing: border-box; }

body.chat-page {
    margin: 0;
    height: 100vh;
    overflow: hidden;
    color: var(--qh-ink);
    background: #fffdfb;
    font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
}

.qihuang-shell {
    display: grid;
    grid-template-columns: var(--qh-shell-sidebar-width) minmax(0, 1fr);
    height: 100vh;
    background: #fff;
    transition: grid-template-columns 0.3s ease;
    position: relative;
}

.sidebar-scrim {
    display: none;
}

body.sidebar-collapsed {
    --qh-shell-sidebar-width: 72px;
}

body.sidebar-collapsed .sidebar-header {
    padding: 20px 10px 14px;
}

body.sidebar-collapsed .brand-lockup,
body.sidebar-collapsed .search-section,
body.sidebar-collapsed .new-chat-section,
body.sidebar-collapsed .chat-history,
body.sidebar-collapsed .back-home-section {
    display: none;
}

body.sidebar-collapsed .icon-button {
    width: 44px;
    height: 44px;
    margin: 0 auto;
}

.sidebar {
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    background: var(--qh-side);
    border-right: 1px solid #dde4eb;
}

.sidebar-header {
    height: 72px;
    padding: 20px 20px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
}



.brand-lockup {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 0;
    display: grid;
    place-items: center;
    background: transparent;
    border: 0;
    box-shadow: none;
    position: relative;
    overflow: visible;
    font-size: 0;
}

.brand-mark::after {
    display: none;
}

.brand-icon {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    border-radius: inherit;
}

.brand-mark i {
    display: none;
}

.brand-title {
    font-size: 19px;
    line-height: 1;
    font-weight: 500;
    letter-spacing: 0;
    white-space: nowrap;
}

.icon-button {
    width: 40px;
    height: 40px;
    border: 1px solid #dfe5eb;
    background: #fff;
    color: #7c848c;
    border-radius: 12px;
    display: inline-grid;
    place-items: center;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}

.icon-button:hover {
    background: #f7fbff;
    color: #20242a;
    box-shadow: 0 4px 12px rgba(31, 35, 40, 0.08);
}

.mobile-menu-btn {
    display: none;
}

.search-section {
    padding: 8px 14px 18px;
    border-bottom: 1px solid #e9edf2;
}

.search-wrapper {
    height: 46px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 15px;
    background: #fff;
    border: 1px solid #dfe5ea;
    border-radius: 10px;
}

.search-icon { color: #8b949e; font-size: 18px; }
.search-input {
    width: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    color: #555f68;
    font-size: 16px;
}
.search-input::placeholder { color: #b6bdc5; }
.search-clear {
    display: none;
    border: 0;
    background: transparent;
    color: #9aa3ad;
    cursor: pointer;
}

.new-chat-section { padding: 20px 16px 12px; }

.new-chat-button,
.back-home-button {
    width: 100%;
    min-height: 78px;
    border: 1px solid #dfe4ea;
    background: #fff;
    border-radius: 13px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 15px 18px;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(31, 35, 40, 0.05);
    transition: transform 0.2s, box-shadow 0.2s;
}

.new-chat-button:hover,
.back-home-button:hover {
    transform: translateY(-1px);
    box-shadow: var(--qh-shadow);
}

.button-content {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.button-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: #f1f0ee;
    display: grid;
    place-items: center;
    color: #111;
    font-size: 21px;
    flex: 0 0 auto;
}

.button-text {
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
    text-align: left;
}

.main-text {
    font-size: 15px;
    font-weight: 500;
    color: #2c2b2a;
}

.sub-text {
    color: #96918d;
    font-size: 14px;
    white-space: nowrap;
}

.button-arrow { color: #6b6b6b; font-size: 20px; }

.new-chat-button {
    min-height: 66px;
    padding: 12px 16px;
}

.new-chat-button .button-content,
.back-home-button .button-content {
    gap: 12px;
}

.new-chat-button .button-icon,
.back-home-button .button-icon {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    font-size: 18px;
}

.new-chat-button .button-text,
.back-home-button .button-text {
    gap: 3px;
}

.new-chat-button .main-text,
.back-home-button .main-text {
    font-size: 14px;
    font-weight: 500;
}

.new-chat-button .sub-text,
.back-home-button .sub-text {
    font-size: 12px;
}

.new-chat-button .button-arrow,
.back-home-button .button-arrow {
    font-size: 17px;
}

.back-home-button {
    min-height: 66px;
    padding: 12px 16px;
}

.chat-history {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 16px;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
}

.chat-history::-webkit-scrollbar {
    width: 0;
}

.chat-history::-webkit-scrollbar-track {
    background: transparent;
}

.chat-history::-webkit-scrollbar-thumb {
    background: transparent;
    border-radius: 999px;
}

.chat-history:hover {
    scrollbar-color: #c9d6e4 transparent;
}

.chat-history:hover::-webkit-scrollbar {
    width: 5px;
}

.chat-history:hover::-webkit-scrollbar-thumb {
    background: #c9d6e4;
}

.chat-history::-webkit-scrollbar-thumb:hover {
    background: #9fb4c9;
}

.history-section { margin: 16px 0 26px; }
.history-title {
    color: #9a9692;
    font-size: 15px;
    margin: 0 0 12px;
}

.history-item {
    min-height: 42px;
    display: flex;
    align-items: center;
    padding: 0 16px;
    border-radius: 7px;
    color: #575f67;
    cursor: pointer;
    transition: background 0.18s, color 0.18s;
}

.history-item:hover { background: #ecf5ff; }
.history-item.active {
    background: #e1f1ff;
    color: #1683e8;
}

.history-item-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 14px;
}

.back-home-section {
    flex: 0 0 auto;
    padding: 12px 16px 70px;
    border-top: 1px solid #e8edf2;
    margin: 0;
    background: var(--qh-side);
}

.main-content {
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 30px minmax(0, 1fr) auto;
    grid-template-areas:
        "top"
        "chat"
        "input";
    background: #fff;
    position: relative;
    height: 100vh;
    overflow: hidden;
}

body.graph-visible .main-content {
    grid-template-columns:
        minmax(360px, var(--chat-pane-size, 1fr))
        10px
        minmax(360px, var(--graph-pane-size, 1fr));
    grid-template-areas:
        "top top top"
        "chat resize graph"
        "input resize graph";
}

.top-toolbar {
    grid-area: top;
    height: 30px;
    border-bottom: 1px solid #efefef;
}

.chat-area {
    grid-area: chat;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

body:not(.conversation-started) .chat-area {
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

.knowledge-graph-panel {
    grid-area: graph;
    min-width: 0;
    min-height: 0;
    margin: 12px 24px 24px 12px;
    border: 1px solid #e2e8ef;
    border-radius: 14px;
    background:
        radial-gradient(circle, rgba(22, 131, 232, 0.12) 1px, transparent 1.4px) 0 0 / 24px 24px,
        linear-gradient(180deg, rgba(255,255,255,0.96), rgba(248,252,255,0.96));
    box-shadow: 0 18px 44px rgba(20, 48, 78, 0.12);
    display: none;
    flex-direction: column;
    overflow: hidden;
}

body.graph-visible .knowledge-graph-panel {
    display: flex;
}

.graph-resizer {
    grid-area: resize;
    display: none;
    position: relative;
    align-items: center;
    justify-content: center;
    min-width: 10px;
    cursor: col-resize;
    user-select: none;
    touch-action: none;
    z-index: 8;
}

body.graph-visible .graph-resizer {
    display: flex;
}

.graph-resizer::before {
    content: "";
    width: 1px;
    height: calc(100% - 48px);
    border-radius: 999px;
    background: linear-gradient(180deg, transparent, rgba(0, 122, 255, 0.18), rgba(22, 131, 232, 0.5), rgba(0, 122, 255, 0.18), transparent);
}

.graph-resizer span {
    position: absolute;
    width: 6px;
    height: 48px;
    border-radius: 999px;
    background: #fff;
    border: 1px solid rgba(22, 131, 232, 0.22);
    box-shadow: 0 8px 20px rgba(20, 48, 78, 0.14);
}

.graph-resizer span::before {
    content: "";
    position: absolute;
    left: 2px;
    width: 2px;
    height: 2px;
    border-radius: 50%;
    background: rgba(22, 131, 232, 0.55);
    top: 15px;
    box-shadow: 0 8px 0 rgba(22, 131, 232, 0.55), 0 16px 0 rgba(22, 131, 232, 0.55);
}

body.graph-resizing,
body.graph-resizing * {
    cursor: col-resize !important;
}

.kg-panel-header {
    min-height: 54px;
    padding: 8px 12px 7px;
    display: grid;
    grid-template-columns: 84px minmax(0, 1fr) 40px;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid rgba(216, 226, 236, 0.9);
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(12px);
}

.kg-title-block {
    min-width: 0;
    text-align: center;
}

.kg-eyebrow {
    color: #1683e8;
    font-family: "Segoe UI", Arial, sans-serif;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

.kg-panel-header h2 {
    margin: 2px 0 0;
    color: #1e2936;
    font-size: 16px;
    line-height: 1.2;
    font-weight: 700;
}

.kg-panel-actions {
    display: flex;
    gap: 6px;
    flex: 0 0 auto;
}

.kg-panel-actions-left {
    justify-self: start;
}

.kg-panel-actions-right {
    justify-self: end;
}

.kg-icon-btn {
    width: 32px;
    height: 32px;
    border: 1px solid #dbe7f3;
    border-radius: 8px;
    background: #fff;
    color: #607182;
    display: inline-grid;
    place-items: center;
    cursor: pointer;
    transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.kg-close-btn {
    color: #596878;
}

.kg-close-btn:hover {
    color: #c24141;
    background: #fff4f4;
    border-color: #ffd7d7;
}

.kg-icon-btn:hover,
.kg-icon-btn.active {
    color: #0878dd;
    background: #edf7ff;
    box-shadow: 0 8px 18px rgba(22, 131, 232, 0.12);
}

.kg-close-btn:hover {
    color: #c24141;
    background: #fff4f4;
    border-color: #ffd7d7;
}

.kg-icon-btn:active {
    transform: scale(0.96);
}

.kg-canvas-shell {
    min-height: 0;
    flex: 1;
    position: relative;
    overflow: hidden;
}

#knowledgeGraphSvg {
    width: 100%;
    height: 100%;
    display: block;
    cursor: grab;
}

#knowledgeGraphSvg:active {
    cursor: grabbing;
}

.kg-empty-state {
    position: absolute;
    inset: 0;
    display: grid;
    place-content: center;
    gap: 10px;
    text-align: center;
    color: #7a8897;
    font-size: 14px;
    pointer-events: none;
}

.kg-empty-state i {
    color: #1683e8;
    font-size: 28px;
}

.kg-link {
    stroke: rgba(91, 109, 128, 0.36);
    stroke-width: 1.2px;
    marker-end: url(#kgArrow);
    transition: stroke 180ms ease, stroke-width 180ms ease, opacity 180ms ease;
}

.kg-link:hover {
    stroke: #1683e8;
    stroke-width: 2px;
}

.kg-link.evidence {
    stroke: rgba(52, 91, 133, 0.54);
}

.kg-link.evidence-path {
    stroke: rgba(18, 131, 146, 0.72);
    stroke-width: 2px;
}

.kg-node {
    cursor: pointer;
}

.kg-node circle {
    stroke: rgba(255, 255, 255, 0.96);
    stroke-width: 1.8px;
    filter: drop-shadow(0 8px 14px rgba(34, 56, 76, 0.15));
    transition: stroke 180ms ease, stroke-width 180ms ease, filter 180ms ease;
}

.kg-node.matched circle {
    stroke: rgba(244, 250, 255, 0.98);
    stroke-width: 2.8px;
    filter: drop-shadow(0 10px 18px rgba(22, 131, 232, 0.22));
}

.kg-node.evidence-path circle {
    stroke: rgba(18, 131, 146, 0.62);
    stroke-width: 2.4px;
}

.kg-node text {
    font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
    font-size: 12px;
    fill: #2b3643;
    paint-order: stroke;
    stroke: rgba(255,255,255,0.92);
    stroke-width: 4px;
    stroke-linejoin: round;
    pointer-events: none;
}

.kg-edge-label {
    font-family: "Segoe UI", Arial, sans-serif;
    font-size: 10px;
    fill: #6d7886;
    opacity: 0.84;
    paint-order: stroke;
    stroke: rgba(255,255,255,0.86);
    stroke-width: 4px;
    stroke-linejoin: round;
    pointer-events: none;
}

.kg-legend {
    min-height: 45px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    border-top: 1px solid rgba(216, 226, 236, 0.9);
    background: rgba(255,255,255,0.88);
}

.kg-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #697685;
    font-size: 12px;
    white-space: nowrap;
}

.kg-legend-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
}

.kg-detail {
    max-height: 138px;
    padding: 12px 15px 14px;
    border-top: 1px solid rgba(216, 226, 236, 0.9);
    background: rgba(255,255,255,0.94);
    color: #4c5a68;
    overflow-y: auto;
    font-size: 13px;
    line-height: 1.55;
    text-align: center;
}

.kg-detail-title {
    margin-bottom: 5px;
    color: #1f2b3a;
    font-size: 14px;
    font-weight: 700;
}

.kg-detail p {
    margin: 0;
}

.kg-detail-meta {
    margin-top: 5px;
    color: #1683e8;
    font-size: 12px;
    font-family: "Segoe UI", Arial, sans-serif;
}

.thinking-indicator {
    width: min(100%, 1000px) !important;
    max-width: min(100%, 1000px);
    margin-left: auto !important;
    margin-right: auto !important;
}

body.graph-visible .thinking-indicator {
    width: 100% !important;
    max-width: 100%;
    margin-left: 8px;
    margin-right: auto;
}

.thinking-card {
    display: inline-grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    width: max-content;
    max-width: 100%;
    padding: 13px 16px;
    border: 1px solid rgba(194, 220, 242, 0.9);
    border-radius: 14px;
    background:
        linear-gradient(135deg, rgba(241, 248, 255, 0.96), rgba(255, 255, 255, 0.98)),
        #fff;
    box-shadow: 0 14px 34px rgba(33, 88, 132, 0.12);
}

.thinking-copy {
    min-width: 0;
    display: grid;
    gap: 3px;
}

.thinking-copy strong {
    color: #243343;
    font-size: 14px;
    line-height: 1.2;
}

.thinking-copy span {
    color: #657487;
    font-size: 13px;
    line-height: 1.35;
}

.thinking-dots {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding-left: 6px;
}

.thinking-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #1683e8;
    animation: thinkingPulse 1.05s ease-in-out infinite;
}

.thinking-dots span:nth-child(2) {
    animation-delay: 0.14s;
}

.thinking-dots span:nth-child(3) {
    animation-delay: 0.28s;
}

@keyframes thinkingPulse {
    0%, 80%, 100% {
        opacity: 0.3;
        transform: translateY(0);
    }
    40% {
        opacity: 1;
        transform: translateY(-4px);
    }
}

body.graph-visible #chat-window {
    padding: 26px 28px 28px 34px;
}

body.graph-visible .message {
    width: 100%;
}

body.graph-visible .input-section {
    grid-area: input;
    padding: 12px 32px 24px 42px;
}

body.graph-visible .input-container {
    width: 100%;
}

.welcome-screen {
    flex: none;
    max-width: 1000px;
    width: min(66vw, 1000px);
    margin: 48px auto 0;
    padding-bottom: 24px;
    display: flex;
    flex-direction: column;
}

.welcome-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
    margin-bottom: 24px;
}

.welcome-content {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.welcome-avatar {
    width: 84px;
    height: 84px;
    display: grid;
    place-items: center;
    color: #4c4a47;
    font-size: 72px;
    flex: 0 0 auto;
    margin-top: -6px;
}

.welcome-icon {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    border-radius: 0;
    filter: none;
}

.welcome-avatar i {
    display: none;
}

.welcome-title {
    margin: 0 0 8px;
    font-family: inherit;
    font-size: 32px;
    line-height: 1.12;
    font-weight: 500;
    letter-spacing: 0;
}

.welcome-subtitle {
    margin: 0;
    color: #9a918b;
    font-size: 17px;
    line-height: 1.45;
    font-family: inherit;
}

.capabilities-intro {
    margin-top: 22px;
    color: #99928d;
    font-size: 16px;
}

.header-actions {
    display: flex;
    gap: 10px;
    padding-top: 2px;
}

.header-btn {
    width: 42px;
    height: 42px;
    border: 1px solid #e1e4e8;
    border-radius: 8px;
    background: #fff;
    color: #8e8e8e;
    cursor: pointer;
    font-size: 16px;
}

.capabilities-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    align-items: stretch;
}

.capability-card,
.capability-card-column {
    border-radius: 12px;
}

.capability-card {
    background: linear-gradient(180deg, #f5f1ff 0%, #f1ebff 100%);
    border: 1px solid #e6dff2;
    padding: 18px 18px;
    min-height: 146px;
}

.capability-card-column {
    display: grid;
    grid-template-rows: 1fr 1fr;
    gap: 12px;
}

.capability-title {
    font-size: 18px;
    font-weight: 500;
    color: #211c18;
    margin-bottom: 10px;
}

.capability-description {
    color: #9b928c;
    font-size: 15px;
    margin-bottom: 16px;
}

.topic-list {
    display: grid;
    gap: 18px;
}

.topic-item {
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr);
    align-items: center;
    gap: 9px;
    color: #77716e;
    font-size: 16px;
}

.topic-number {
    width: 24px;
    height: 24px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: white;
    font-size: 13px;
    font-weight: 600;
}
.topic-item:nth-child(1) .topic-number { background: #ff4b54; }
.topic-item:nth-child(2) .topic-number,
.topic-item:nth-child(3) .topic-number { background: #ff931a; }
.topic-item:nth-child(4) .topic-number,
.topic-item:nth-child(5) .topic-number { background: #43c92f; }

.guide-list-circular {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1.15fr));
    gap: 10px;
}

.guide-item-circular {
    min-height: 96px;
    background: #fff;
    border-radius: 15px;
    display: grid;
    place-items: center;
    text-align: center;
    box-shadow: 0 8px 18px rgba(81, 72, 64, 0.06);
}

.guide-icon-circular {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    margin: 0 auto 10px;
    color: #fff;
    font-size: 20px;
}
.guide-icon-circular.intention { background: #ff951f; }
.guide-icon-circular.angle { background: #777; }
.guide-icon-circular.dialog { background: #3294ff; }
.guide-icon-circular.boundary { background: #53ca22; }

.guide-title-circular {
    font-size: 15px;
    font-weight: 500;
    margin-bottom: 4px;
}

.guide-desc-circular {
    font-size: 12px;
    color: #9a928b;
}

.action-item {
    height: 40px;
    border: 1px solid #ddd8d5;
    border-radius: 8px;
    background: rgba(255,255,255,0.78);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 13px;
    color: #8b8783;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s, background 0.2s;
    font-size: 13px;
}

.action-item:hover {
    color: #1d1b19;
    border-color: #cfc7be;
    background: #fff;
}

.action-item-display {
    height: 40px;
    border: 1px solid #ddd8d5;
    border-radius: 8px;
    background: rgba(255,255,255,0.78);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 13px;
    color: #8b8783;
    cursor: default;
    font-size: 13px;
}

#chat-window {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 26px 34px 28px;
    background: #fff;
    scroll-behavior: smooth;
    overscroll-behavior: contain;
}

body:not(.conversation-started) #chat-window { display: none; }
body.conversation-started .welcome-screen { display: none; }

.message {
    width: min(100%, 1560px);
    margin: 0 auto 18px;
    font-size: 15px;
    line-height: 1.62;
}

.user-message {
    display: flex;
    justify-content: flex-end;
}

.user-message p {
    margin: 0;
    max-width: min(82%, 1380px);
    padding: 12px 22px;
    background: #e4f2ff;
    color: #181818;
    border-radius: 18px 18px 5px 18px;
    box-shadow: 0 7px 18px rgba(43, 125, 205, 0.11);
}

.ai-message {
    max-width: min(94%, 1560px);
}

.ai-message:not(.structured-message) {
    color: #222;
}

.ai-message:not(.structured-message) > p,
.ai-message .formatted-text {
    background: #fff;
    border: 1px solid #eceff2;
    border-radius: 14px;
    padding: 18px 22px;
    box-shadow: 0 8px 22px rgba(31, 35, 40, 0.05);
}

.report-ready-message .report-ready-card {
    border-color: #cfe6ff;
    background: linear-gradient(180deg, #ffffff 0%, #f7fbff 100%);
}

.report-ready-card p {
    margin: 0 0 12px;
}

.report-ready-card p:last-of-type {
    margin-bottom: 0;
}

.report-ready-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 16px;
}

.report-ready-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 16px;
    border-radius: 10px;
    border: 1px solid #d6e3ef;
    background: #fff;
    color: #273546;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.report-ready-btn.primary {
    border-color: #1683e8;
    background: #1683e8;
    color: #fff;
    box-shadow: 0 10px 22px rgba(22, 131, 232, 0.2);
}

.report-ready-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(31, 35, 40, 0.1);
}

.report-ready-btn:disabled {
    cursor: default;
    opacity: 0.58;
}

.intake-form-message .intake-form-card {
    border-color: #cfe6ff;
    background: linear-gradient(180deg, #ffffff 0%, #f8fcff 100%);
}

.intake-form-title {
    margin: 0 0 6px;
    font-size: 18px;
    font-weight: 700;
    color: #12324f;
}

.intake-form-intro {
    margin: 0 0 16px;
    color: #56697c;
}

.intake-question-list {
    display: grid;
    gap: 14px;
}

.intake-question-block {
    padding: 14px;
    border: 1px solid #e2edf8;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.78);
}

.intake-question-block.missing {
    border-color: #ef8b8b;
    box-shadow: 0 0 0 3px rgba(239, 139, 139, 0.16);
}

.intake-question-title {
    margin-bottom: 10px;
    font-weight: 650;
    color: #1e2f42;
}

.intake-options {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.intake-option {
    min-height: 44px;
    border: 1px solid #d9e6f3;
    border-radius: 10px;
    background: #fff;
    color: #2c3b4b;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.16s, background 0.16s, box-shadow 0.16s, transform 0.16s;
}

.intake-option:hover:not(:disabled),
.intake-option.selected {
    border-color: #1683e8;
    background: #eef7ff;
    box-shadow: 0 8px 18px rgba(22, 131, 232, 0.12);
}

.intake-option.selected {
    transform: translateY(-1px);
}

.intake-option-label {
    width: 24px;
    height: 24px;
    flex: 0 0 auto;
    border-radius: 999px;
    display: inline-grid;
    place-items: center;
    background: #e9f3ff;
    color: #1683e8;
    font-weight: 700;
    font-size: 13px;
}

.intake-form-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 18px;
}

.intake-nav-btn {
    min-width: 132px;
    height: 40px;
    border: 1px solid #d9e6f3;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 14px;
    font-size: 14px;
    font-weight: 650;
    transition: border-color 0.16s, background 0.16s, color 0.16s, box-shadow 0.16s, transform 0.16s;
}

.intake-nav-btn.secondary {
    background: #fff;
    color: #5d6f82;
}

.intake-nav-btn.primary {
    background: linear-gradient(135deg, #1f8cff 0%, #47b1ff 100%);
    color: #fff;
    border-color: #1f8cff;
    box-shadow: 0 8px 18px rgba(31, 140, 255, 0.2);
}

.intake-nav-btn:hover:not(:disabled) {
    transform: translateY(-1px);
}

.intake-nav-btn.secondary:hover:not(:disabled) {
    border-color: #b9d7f4;
    background: #f7fbff;
    color: #12324f;
}

.intake-nav-btn.primary:hover:not(:disabled) {
    box-shadow: 0 10px 22px rgba(31, 140, 255, 0.24);
}

.intake-nav-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.intake-question-progress {
    flex: 1;
    text-align: center;
    color: #5c7084;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.04em;
}

.intake-form-actions .intake-question-progress {
    order: 2;
}

.intake-form-actions .intake-nav-btn.secondary {
    order: 1;
}

.intake-form-actions .intake-nav-btn.primary {
    order: 3;
}

.report-ready-btn.shake {
    animation: qhShake 0.38s ease;
}

.intake-nav-btn.shake {
    animation: qhShake 0.38s ease;
}

@keyframes qhShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    50% { transform: translateX(4px); }
    75% { transform: translateX(-2px); }
}

@media (max-width: 860px) {
    .intake-options {
        grid-template-columns: 1fr;
    }

    .intake-form-actions {
        flex-wrap: wrap;
    }

    .intake-nav-btn {
        flex: 1 1 160px;
    }

    .intake-question-progress {
        order: 3;
        flex-basis: 100%;
    }
}

.structured-message {
    background: #eff8ff !important;
    border: 1px solid #dbefff;
    border-left: 5px solid var(--medical-blue);
    border-radius: 12px;
    padding: 18px 28px;
    box-shadow: 0 10px 24px rgba(23, 104, 178, 0.08);
}

.structured-content h4 {
    margin-top: 0;
    min-height: 46px;
    padding: 11px 17px;
    background: #d9ecff;
    border-left: 0;
    color: #0067c8;
    font-size: 17px;
    font-weight: 800;
}

.structured-content p,
.structured-content ul,
.structured-content ol {
    padding: 10px 17px;
    font-size: 15px;
    line-height: 1.68;
}

.structured-content strong,
.diagnosis-name {
    color: #0067c8;
    font-weight: 800;
}

.diagnosis-name,
.syndrome-type {
    border-radius: 6px;
    padding: 3px 8px;
}

.confidence-bar {
    height: 5px;
    margin: 12px 17px;
    background: #eef0f2;
}

.reference-sources {
    margin-top: 14px;
    padding: 18px 17px;
    background: rgba(255,255,255,0.54);
    border-top: 1px solid #e6eef6;
    border-radius: 0 0 10px 10px;
}

.hallucination-check-container {
    padding: 12px;
    background: #fbfcfe;
    border-radius: 10px;
    box-shadow: 0 8px 18px rgba(31,35,40,0.06);
}

.hallucination-warning,
.hallucination-success,
.hallucination-info {
    min-height: 40px;
    border-radius: 8px;
    padding: 12px 18px;
    font-size: 15px;
}

.alert-danger,
.alert-warning,
.alert-success,
.alert-info {
    border-left-width: 0;
}

.source-info,
.confidence-indicator,
.citation-detail summary {
    font-size: 14px !important;
}

.view-mindmap-btn {
    min-height: 38px;
    padding: 0 18px;
    border-radius: 19px;
    font-size: 14px;
    background: #19b99d;
    box-shadow: 0 8px 17px rgba(25, 185, 157, 0.28);
}

.citation-detail {
    border-radius: 7px;
    margin-bottom: 14px;
}

.citation-content {
    font-size: 14px;
}

.input-section {
    grid-area: input;
    position: relative;
    padding: 12px 42px 24px;
    background: #fff;
    border-top: 1px solid transparent;
    pointer-events: auto;
    z-index: 4;
}

.input-container {
    width: min(100%, 1425px);
    margin: 0 auto;
}

.input-wrapper {
    min-height: 112px;
    border: 1px solid #d9d9d9;
    border-radius: 24px;
    background: #fff;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 16px rgba(31, 35, 40, 0.04);
    overflow: visible;
    position: relative;
}

#user-input {
    width: 100%;
    min-height: 54px;
    max-height: 96px;
    resize: none;
    border: 0;
    outline: 0;
    padding: 20px 24px 4px;
    color: #27211d;
    font-size: 16px;
    line-height: 1.5;
    font-family: inherit;
    background: transparent;
}

#user-input::placeholder { color: #b7b3af; }

.input-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    padding: 8px 22px 14px;
}

.left-buttons,
.right-buttons {
    display: flex;
    align-items: center;
    gap: 17px;
}

.left-buttons {
    position: relative;
}

.input-btn {
    border: 0;
    background: transparent;
    color: #050505;
    display: inline-grid;
    place-items: center;
    cursor: pointer;
    font-size: 19px;
    padding: 0;
}

.selected-mode-pill {
    position: absolute;
    left: 24px;
    top: 15px;
    color: #0878dd;
    font-size: 16px;
    line-height: 1.5;
    padding: 0;
    border-radius: 999px;
    background: transparent;
    border: 0;
    white-space: nowrap;
    cursor: text;
    z-index: 1;
}

.selected-mode-pill[hidden] {
    display: none;
}

.input-wrapper.has-mode #user-input {
    padding-left: var(--mode-pill-offset, 96px);
}

#send-button {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #050505;
    color: white;
    transition: transform 0.18s, background 0.18s;
}

#send-button:hover { transform: translateY(-1px); background: #202020; }

.mode-menu {
    position: absolute;
    left: 48px;
    bottom: 36px;
    width: 178px;
    max-width: calc(100vw - 190px);
    padding: 6px;
    border-radius: 14px;
    border: 1px solid #e4e0dc;
    background: #fff;
    box-shadow: var(--qh-shadow);
    display: block;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translate(8px, 8px) scale(0.98);
    transform-origin: left bottom;
    transition: opacity 0.22s cubic-bezier(0.22, 1, 0.36, 1),
                transform 0.22s cubic-bezier(0.22, 1, 0.36, 1),
                visibility 0.22s;
    z-index: 5;
}

.mode-menu.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translate(8px, 0) scale(1);
}

.mode-item {
    width: 100%;
    border: 0;
    background: transparent;
    border-radius: 10px;
    padding: 9px 11px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #4b4642;
    cursor: pointer;
    font-size: 14px;
    text-align: left;
    white-space: nowrap;
    transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.mode-item:hover,
.mode-item.active {
    background: #e8f4ff;
    color: #0878dd;
}

.mode-item:hover {
    transform: translateX(2px);
}

.service-sync {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
}

.history-empty {
    padding: 18px 12px;
    color: #9a9692;
    font-size: 13px;
    line-height: 1.6;
}

.history-meta {
    margin-left: auto;
    color: #a7a29d;
    font-size: 12px;
}

.attachment-tray {
    display: none;
    gap: 8px;
    flex-wrap: wrap;
    padding: 0 22px 8px;
}

.attachment-tray.show { display: flex; }

.attachment-chip {
    max-width: 230px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border: 1px solid #e2ded9;
    border-radius: 999px;
    background: #faf8f5;
    color: #5f5a55;
    font-size: 13px;
}

.attachment-chip span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attachment-chip button {
    border: 0;
    background: transparent;
    color: #999;
    cursor: pointer;
    padding: 0;
}

.user-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.user-attachment-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 9px;
    border-radius: 999px;
    background: rgba(255,255,255,0.72);
    color: #3f5368;
    font-size: 13px;
}

.voice-recording {
    color: #d44848 !important;
}

.voice-recording::after {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #d44848;
    position: absolute;
    transform: translate(10px, -10px);
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 154px;
    transform: translateX(-50%);
    z-index: 60;
    max-width: min(520px, calc(100vw - 32px));
    padding: 10px 14px;
    border-radius: 10px;
    background: rgba(32, 28, 24, 0.92);
    color: #fff;
    font-size: 14px;
    box-shadow: 0 10px 26px rgba(0,0,0,0.18);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s, transform 0.18s;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(-4px);
}

/* Scale calibration: closer to the reference UI, about 20% denser on desktop. */
body.chat-page {
    font-family: "Noto Serif Simplified Chinese", "Noto Serif SC", "Source Han Serif SC", "Songti SC", "SimSun", serif;
}

.main-content {
    font-family: "Noto Serif Simplified Chinese", "Noto Serif SC", "Source Han Serif SC", "Songti SC", "SimSun", serif;
}

.welcome-screen {
    max-width: 1000px;
    width: min(66vw, 1000px);
    margin-top: 36px;
}

.welcome-header {
    margin-bottom: 18px;
}

.welcome-avatar {
    width: 82px;
    height: 82px;
    font-size: 54px;
    margin-top: -3px;
}

.welcome-header {
    margin-bottom: 12px;
}

.welcome-title {
    font-size: 30px;
    font-weight: 500;
}

.welcome-subtitle {
    font-size: 17px;
}

.capabilities-grid {
    gap: 12px;
}

.capability-card {
    min-height: 118px;
    padding: 16px 18px;
    border-radius: 12px;
}

.rich-guide {
    padding-left: 10px;
    padding-right: 10px;
}

.capability-title {
    font-size: 18px;
    margin-bottom: 10px;
    font-weight: 500;
}

.capability-description {
    font-size: 14px;
    margin-bottom: 13px;
}

.topic-list {
    gap: 15px;
}

.topic-item {
    grid-template-columns: 22px minmax(0, 1fr);
    gap: 8px;
    font-size: 16px;
}

.topic-number {
    width: 22px;
    height: 22px;
    font-size: 12px;
    font-weight: 600;
}

.guide-list-circular {
    gap: 6px;
}

.guide-item-circular {
    min-height: 88px;
    border-radius: 12px;
}

.guide-icon-circular {
    width: 32px;
    height: 32px;
    margin-bottom: 6px;
    font-size: 15px;
}

.guide-title-circular {
    font-size: 14px;
    font-weight: 500;
}

.guide-desc-circular {
    font-size: 12px;
}

.rich-guide .guide-list-circular {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.rich-guide .guide-item-circular {
    min-height: 88px;
    width: 100%;
}

.capability-card-column {
    gap: 12px;
}

.capability-card-column .capability-card {
    min-height: 110px;
}

.action-item {
    height: 36px;
    font-size: 13px;
}

.action-item-display {
    height: 36px;
    font-size: 13px;
}

.input-container {
    width: min(100%, 1000px);
}

.input-wrapper {
    min-height: 102px;
    border-radius: 22px;
}

#user-input {
    min-height: 48px;
    max-height: 86px;
    padding: 16px 24px 2px;
    font-size: 15px;
}

.input-actions {
    padding: 7px 22px 12px;
}

.history-item {
    gap: 8px;
    padding-right: 10px;
}

.history-actions {
    display: none;
    align-items: center;
    gap: 2px;
    margin-left: 4px;
    flex: 0 0 auto;
}

.history-item:hover .history-actions,
.history-item.active .history-actions {
    display: inline-flex;
}

.history-action {
    width: 22px;
    height: 22px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #8f9aa4;
    cursor: pointer;
    display: inline-grid;
    place-items: center;
    font-size: 11px;
}

.history-action:hover {
    background: rgba(22, 131, 232, 0.1);
    color: #1683e8;
}

.history-item.pinned .history-item-text::before {
    content: "置顶 ";
    color: #1683e8;
    font-size: 12px;
    font-weight: 700;
}

@media (max-width: 1100px) {
    .qihuang-shell { grid-template-columns: var(--qh-shell-sidebar-width) minmax(0, 1fr); }
    .welcome-screen {
        margin-bottom: 24px;
    }
    .rich-guide,
    .capability-card-column {
        display: none;
    }
    body.graph-visible .main-content {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas:
            "top"
            "chat"
            "input";
    }
    body.graph-visible .knowledge-graph-panel,
    body.graph-visible .graph-resizer { display: none; }
    .welcome-screen { width: min(88vw, 980px); }
    .capabilities-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
    body.chat-page {
        overflow: hidden;
        background: #f6f9fc;
    }

    body.sidebar-collapsed {
        --qh-shell-sidebar-width: 260px;
    }

    body.sidebar-collapsed .brand-lockup,
    body.sidebar-collapsed .search-section,
    body.sidebar-collapsed .new-chat-section,
    body.sidebar-collapsed .chat-history,
    body.sidebar-collapsed .back-home-section {
        display: block;
    }

    body.sidebar-collapsed .chat-history {
        display: block;
    }

    .qihuang-shell {
        grid-template-columns: 1fr;
        width: 100vw;
        max-width: 100vw;
        height: 100dvh;
        overflow: hidden;
    }

    .sidebar-scrim {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 29;
        background: rgba(15, 23, 42, 0.26);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.22s ease;
    }

    body.sidebar-open .sidebar-scrim {
        opacity: 1;
        pointer-events: auto;
    }

    .sidebar {
        position: fixed;
        z-index: 30;
        inset: 0 auto 0 0;
        width: min(84vw, 320px);
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: var(--qh-shadow);
        border-right: 1px solid #d7e2ec;
        overflow: hidden;
    }

    .sidebar-header {
        height: 66px;
        padding: 16px 18px 12px;
    }

    body.sidebar-collapsed .sidebar-header {
        padding: 16px 18px 12px;
    }

    .sidebar .icon-button,
    body.sidebar-collapsed .icon-button {
        width: 44px;
        height: 44px;
        margin: 0;
    }

    .sidebar.open { transform: translateX(0); }

    .top-toolbar {
        height: 54px;
        padding: 8px 14px;
        border-bottom: 1px solid #eef2f6;
        background: rgba(255, 255, 255, 0.94);
        backdrop-filter: blur(10px);
    }

    .mobile-menu-btn { display: inline-grid !important; }

    .main-content {
        grid-template-rows: 54px minmax(0, 1fr) auto;
        width: 100vw;
        max-width: 100vw;
        min-width: 0;
        height: 100dvh;
        overflow: hidden;
    }

    .chat-area {
        width: 100%;
        max-width: 100vw;
        min-width: 0;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 6px;
    }

    .welcome-screen {
        flex: none;
        margin: 16px auto 0;
        width: calc(100% - 18px);
        padding-bottom: 150px;
    }

    .welcome-header {
        flex-direction: row;
        align-items: flex-start;
        gap: 10px;
        margin-bottom: 16px;
    }

    .welcome-content {
        gap: 10px;
        align-items: center;
        flex: 1 1 auto;
        min-width: 0;
    }

    .welcome-avatar {
        width: 52px;
        height: 52px;
        font-size: 40px;
        margin-top: 0;
    }

    .welcome-title {
        font-size: 24px;
        line-height: 1.18;
    }

    .welcome-subtitle {
        font-size: 15px;
        line-height: 1.55;
        max-width: 100%;
    }

    .header-actions {
        flex: 0 0 auto;
        gap: 8px;
        padding-top: 0;
    }

    .header-btn {
        width: 44px;
        height: 44px;
    }

    .rich-guide,
    .capability-card-column {
        display: none;
    }

    .capability-card {
        min-height: auto;
        padding: 16px;
    }

    .capability-title {
        font-size: 19px;
        line-height: 1.25;
    }

    .capability-description {
        font-size: 14px;
        line-height: 1.55;
    }

    .capabilities-grid,
    .guide-list-circular,
    .capability-card-column { grid-template-columns: 1fr; }

    .guide-item-circular {
        min-height: 78px;
    }

    .input-section {
        width: 100vw;
        max-width: 100vw;
        min-width: 0;
        padding: 8px 0 calc(10px + env(safe-area-inset-bottom));
        background: linear-gradient(180deg, rgba(255,255,255,0.82), #fff 28%);
    }

    .input-container {
        width: 100%;
        max-width: none;
        min-width: 0;
    }

    .input-wrapper {
        width: 100%;
        max-width: 100%;
        min-height: 96px;
        border-radius: 16px;
        box-shadow: 0 12px 34px rgba(31, 35, 40, 0.09);
    }

    #user-input {
        font-size: 15px;
        min-height: 48px;
        max-height: 84px;
        padding: 16px 12px 4px;
        line-height: 1.45;
    }

    .left-buttons { gap: 12px; }
    .selected-mode-pill { left: 18px; top: 15px; font-size: 16px; }
    .mode-menu {
        left: 38px;
        bottom: 38px;
        width: 166px;
        max-width: calc(100vw - 70px);
        transform: translateY(8px) scale(0.98);
        transform-origin: left bottom;
    }
    .mode-menu.show { transform: translate(4px, 0) scale(1); }
    .mode-item { font-size: 13px; padding: 8px 10px; }
    #chat-window { padding: 18px 12px 132px; }
    .message { font-size: 15px; }
    .structured-message { padding: 14px 12px; }
    .structured-content h4 { font-size: 16px; min-height: 44px; }
    .structured-content p,
    .structured-content ul,
    .structured-content ol { font-size: 15px; padding: 10px 12px; }
}

/* Mindmap modal styles required by chat_functions.js */
.mindmap-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.8);
}

.mindmap-modal-content {
    position: relative;
    margin: 2% auto;
    width: 95%;
    height: 95%;
    background-color: white;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.mindmap-modal-header {
    background: linear-gradient(135deg, var(--medical-blue), var(--secondary-blue));
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.mindmap-modal-header h3 {
    margin: 0;
    font-size: 18px;
    flex: 1;
    text-align: center;
    font-weight: 500;
}

.close-mindmap {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s;
    position: absolute;
    right: 20px;
}

.close-mindmap:hover {
    background-color: rgba(255,255,255,0.2);
}

.mindmap-container {
    flex: 1;
    position: relative;
    background-color: #fff;
    overflow: hidden;
}

.markmap {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.markmap svg {
    width: 100% !important;
    height: 100% !important;
    display: block;
    position: relative !important;
    min-width: 800px;
    min-height: 600px;
}

.mindmap-fallback-text {
    padding: 20px;
    margin: 0;
    white-space: pre-wrap;
    color: #5f656c;
    font-family: inherit;
    line-height: 1.7;
}

/* 解决缩放问题 */
.markmap-foreign {
    font-size: 14px; 
    text-align: center;
}

/* 确保各层级节点字体大小合理 */
.markmap-foreign .markmap-foreign-head-1 { font-size: 18px; font-weight: bold; }
.markmap-foreign .markmap-foreign-head-2 { font-size: 16px; font-weight: bold; }
.markmap-foreign .markmap-foreign-head-3 { font-size: 14px; font-weight: normal; }

.markmap-controls {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid rgba(0, 103, 200, 0.12);
    border-radius: 999px;
    box-shadow: 0 10px 28px rgba(15, 45, 74, 0.12);
    padding: 8px;
    display: flex;
    gap: 6px;
    z-index: 100;
}

.markmap-controls button {
    width: 34px;
    height: 34px;
    background: #fff;
    border: 1px solid #d8e9f9;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    color: #0a6fcf;
    outline: none;
    transition: transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.markmap-controls button:hover {
    background: #e8f4ff;
    box-shadow: 0 6px 14px rgba(0,103,200,0.12);
    transform: translateY(-1px);
}

.markmap-controls button:active {
    transform: translateY(0) scale(0.96);
}

.markmap-controls button:focus-visible {
    box-shadow: 0 0 0 3px rgba(0,103,200,0.18);
}

/* Health-management response styles required by chat_functions.js */
.wellness-card {
    border-radius: 10px;
    padding: 12px 16px;
    background-color: #f8fbff;
    box-shadow: 0 2px 10px rgba(0, 86, 179, 0.08);
    border-left: 4px solid var(--medical-blue);
    margin-bottom: 15px;
}

.wellness-section {
    margin-bottom: 12px;
}

.wellness-section h5 {
    margin: 0 0 6px 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--medical-blue);
    display: flex;
    align-items: center;
}

.wellness-section.caution h5 {
    color: #c0392b;
}

.wellness-section p {
    margin: 6px 0 8px;
    line-height: 1.6;
    font-size: 0.95em;
}

.wellness-section ul,
.wellness-section ol {
    margin: 6px 0 8px 20px;
}

.wellness-section li {
    margin-bottom: 4px;
}

.wellness-label {
    display: inline-block;
    min-width: 6em;
    color: #1a73e8;
    font-weight: 600;
}

.wellness-sublist {
    margin: 4px 0 6px 0;
    padding: 8px 12px;
    background: rgba(0,86,179,0.04);
    border-left: 3px solid rgba(0,86,179,0.25);
    border-radius: 4px;
}

/* Diagnosis output compatibility styles for structured medical cards. Keep after page styles. */
.structured-message {
    border-radius: 10px;
    padding: 15px 20px;
    background-color: #f0f7ff !important;
    box-shadow: 0 2px 10px rgba(0, 86, 179, 0.1);
    border-left: 4px solid var(--medical-blue);
    margin-bottom: 15px;
    position: relative;
}

/* 普通文本的格式化显示样式 */
.formatted-text {
    padding: 10px 0;
    line-height: 1.5;
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
}

.formatted-text p {
    margin: 0 0 15px 0;
    padding: 0;
}

.formatted-text p:last-child {
    margin-bottom: 0;
}

.formatted-text .list-container {
    margin-bottom: 15px;
}

.formatted-text ul, .formatted-text ol {
    margin: 0 0 15px 0;
    padding-left: 25px;
}

.formatted-text li {
    margin-bottom: 5px;
}

.formatted-text li:last-child {
    margin-bottom: 0;
}

.structured-message h4 {
    color: var(--medical-blue);
    font-size: 16px;
    margin: 10px 0 5px;
    font-weight: 600;
}

.structured-message p {
    margin: 5px 0 15px;
    line-height: 1.5;
}


.structured-content {
    padding: 0;
    overflow: visible;
}

.report-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
    padding: 6px 6px 14px;
    border-bottom: 1px solid rgba(0, 86, 179, 0.12);
}

.report-toolbar-title,
.report-title {
    display: inline-flex;
    align-items: flex-start;
    gap: 10px;
    color: var(--medical-blue);
}

.report-toolbar-title i,
.report-title i {
    margin-top: 2px;
    font-size: 17px;
}

.report-title-copy {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.report-title-main {
    font-size: 20px;
    font-weight: 700;
    line-height: 1.15;
    color: var(--medical-blue);
}

.report-number {
    font-size: 12px;
    font-weight: 600;
    line-height: 1.35;
    color: var(--medical-green);
}

.report-title-subtitle {
    font-size: 12px;
    font-weight: 500;
    line-height: 1.45;
    color: rgba(18, 50, 79, 0.7);
}

.report-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.report-share {
    position: relative;
}

.report-share-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    border: 0;
    border-radius: 999px;
    padding: 10px 16px;
    background: linear-gradient(135deg, #1069e8, #43b2ff);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 8px 18px rgba(31, 140, 255, 0.25);
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease, opacity 0.2s ease;
}

.report-share-btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.02);
    box-shadow: 0 10px 20px rgba(31, 140, 255, 0.24);
}

.report-share-btn[aria-expanded="true"] {
    background: linear-gradient(135deg, #136fe0, #1f8cff);
}

.report-share-btn i {
    font-size: 13px;
}

.report-share-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    min-width: 176px;
    padding: 8px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(0, 86, 179, 0.16);
    box-shadow: 0 18px 42px rgba(31, 35, 40, 0.18);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 25;
}

.report-share-menu button {
    width: 100%;
    border: 0;
    background: transparent;
    border-radius: 12px;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #27496d;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.report-share-menu button:hover {
    background: rgba(0, 86, 179, 0.08);
    color: var(--medical-blue);
    transform: translateX(2px);
}

.report-share-menu button i {
    width: 18px;
    text-align: center;
    font-size: 14px;
}

.structured-report-body {
    display: block;
}

.json-report-summary {
    margin: 16px 18px 18px;
    padding: 16px;
    border: 1px solid rgba(0, 122, 255, 0.14);
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(232, 245, 255, 0.9), rgba(255, 255, 255, 0.96));
}

.json-report-summary-main {
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.25fr);
    gap: 28px;
}

.json-report-field {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.json-report-label {
    font-size: 12px;
    letter-spacing: 0;
    color: #6d7f91;
}

.json-report-analysis {
    margin-top: 12px !important;
    padding: 0 !important;
    color: #273849;
}

.report-entity-chip,
.report-confidence-pill {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    max-width: 100%;
    padding: 4px 10px;
    border-radius: 999px;
    font-weight: 650;
    line-height: 1.35;
    word-break: break-word;
}

.entity-disease {
    color: #006fce;
    background: rgba(0, 122, 255, 0.11);
}

.entity-syndrome {
    color: #078579;
    background: rgba(0, 151, 136, 0.12);
}

.entity-formula {
    color: #996500;
    background: rgba(245, 166, 35, 0.16);
}

.entity-herb {
    color: #0e7b48;
    background: rgba(46, 204, 113, 0.14);
}

.entity-symptom,
.entity-other {
    color: #526272;
    background: rgba(82, 98, 114, 0.12);
}

.report-confidence-pill {
    color: #245176;
    background: rgba(36, 81, 118, 0.1);
}

.json-evidence-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    padding: 14px 18px 18px;
}

.json-evidence-card {
    padding: 13px 14px;
    border: 1px solid rgba(0, 86, 179, 0.1);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.78);
}

.json-evidence-card strong {
    display: block;
    margin-bottom: 8px;
}

.json-evidence-card ul,
.json-caution-list {
    padding: 0 0 0 18px !important;
}

.json-evidence-card li,
.json-caution-list li {
    margin-bottom: 6px;
}

.json-prescription-panel,
.json-confidence-panel,
.json-differential-list {
    margin: 14px 18px 18px;
    padding: 14px 16px;
    border-radius: 10px;
    background: rgba(247, 251, 255, 0.86);
    border: 1px solid rgba(0, 86, 179, 0.1);
}

.json-prescription-panel p,
.json-confidence-panel p,
.json-differential-list p {
    padding: 6px 0 !important;
}

.json-confidence-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.json-confidence-head strong {
    color: #245176;
    font-size: 18px;
}

.json-confidence-head span {
    color: #6d7f91;
    font-size: 13px;
    text-align: right;
}

.json-confidence-breakdown {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.confidence-subscore {
    min-width: 0;
    padding: 10px;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(0, 86, 179, 0.08);
}

.confidence-subscore-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    color: #31566f;
    font-size: 13px;
    font-weight: 700;
}

.confidence-subscore-head span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.confidence-subscore-bar {
    height: 6px;
    margin-top: 8px;
    border-radius: 999px;
    background: #e7edf2;
    overflow: hidden;
}

.confidence-subscore-fill {
    height: 100%;
    border-radius: inherit;
}

.confidence-subscore p {
    margin: 7px 0 0 !important;
    padding: 0 !important;
    color: #6f8191;
    font-size: 12px;
    line-height: 1.45;
}

.json-prescription-panel p span:first-child,
.json-herb-list > span,
.json-modifications > span {
    display: inline-block;
    min-width: 44px;
    margin-right: 8px;
    color: #6d7f91;
    font-weight: 600;
}

.json-herb-list,
.json-modifications {
    display: flex;
    gap: 8px;
    padding: 6px 0;
}

.json-herb-list > div {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.json-modifications ul {
    padding: 0 0 0 18px !important;
}

.json-caution-list {
    margin: 14px 18px 18px !important;
}

@media (max-width: 720px) {
    .json-report-summary {
        margin: 12px;
        padding: 12px;
    }

    .json-report-summary-main,
    .json-evidence-grid {
        grid-template-columns: 1fr;
    }

    .json-confidence-breakdown {
        grid-template-columns: 1fr;
    }

    .json-evidence-grid {
        padding: 12px;
    }

    .json-prescription-panel,
    .json-confidence-panel,
    .json-differential-list {
        margin: 12px;
        padding: 12px;
    }

    .json-herb-list,
    .json-modifications {
        flex-direction: column;
    }
}

.structured-report-toolbar .report-title-main {
    font-size: 21px;
}

.structured-report-toolbar .report-title-subtitle {
    max-width: 100%;
}

/* 诊断标题样式 */
.structured-content h4 {
    margin: 0;
    padding: 12px 15px;
    font-size: 16px;
    font-weight: 600;
    background-color: rgba(0, 86, 179, 0.08);
    border-left: 4px solid var(--medical-blue);
    color: var(--medical-blue);
    display: flex;
    align-items: center;
}

/* 添加标题图标 */
.structured-content h4::before {
    margin-right: 8px;
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    font-size: 14px;
}

.structured-content h4:nth-of-type(1)::before { content: "\f0f1"; } /* 诊断建议 - 医生图标 */
.structured-content h4:nth-of-type(2)::before { content: "\f0eb"; } /* 证据来源 - 灯泡图标 */
.structured-content h4:nth-of-type(3)::before { content: "\f484"; } /* 处方建议 - 药丸图标 */
.structured-content h4:nth-of-type(4)::before { content: "\f201"; } /* 置信度 - 图表图标 */
.structured-content h4:nth-of-type(5)::before { content: "\f074"; } /* 备选方案 - 随机图标 */

/* 诊断内容区域 */
.structured-content p, 
.structured-content ul {
    padding: 10px 15px;
    margin: 0;
    line-height: 1.6;
    font-size: 0.95em;
}

.structured-content ul {
    padding-left: 35px;
    margin: 0;
}

.structured-report-body .reference-sources {
    margin-top: 10px;
}

.structured-report-body .view-mindmap-btn {
    margin-top: 14px;
}

.structured-content li {
    margin-bottom: 6px;
    position: relative;
}

/* 强调关键字 */
.structured-content strong {
    color: var(--medical-blue);
}

/* 疾病名称突出显示 */
.diagnosis-name {
    font-weight: 600;
    font-size: 1.05em;
    color: var(--medical-blue);
    background: rgba(0, 86, 179, 0.08);
    padding: 2px 8px;
    border-radius: 4px;
}

/* 证型样式 */
.syndrome-type {
    color: #2a9d8f;
    font-weight: 600;
    padding: 2px 8px;
    background-color: rgba(42, 157, 143, 0.1);
    border-radius: 4px;
}

/* 中医体质样式 */
.constitution-type {
    color: #6c5ce7;
    font-weight: 600;
    padding: 2px 8px;
    background-color: rgba(108, 92, 231, 0.1);
    border-radius: 4px;
}

/* 中医证候样式 */
.tcm-syndrome {
    color: #fd79a8;
    font-weight: 600;
    padding: 2px 8px;
    background-color: rgba(253, 121, 168, 0.1);
    border-radius: 4px;
}

/* 处方药物样式 */
.prescription-item {
    display: inline-block;
    margin: 2px;
    padding: 2px 6px;
    background-color: #f0f7ff;
    border-radius: 12px;
    border: 1px solid #d0e1f9;
    font-size: 0.9em;
}

/* 处方分组样式 */
.prescription-group {
    margin: 10px 0;
    padding: 10px 15px;
    background-color: rgba(0, 86, 179, 0.03);
    border-radius: 6px;
    border-left: 3px solid var(--medical-blue);
}

.prescription-group p {
    margin: 5px 0 !important;
    padding: 0 !important;
}

/* 置信度条 */
.confidence-bar {
    height: 6px;
    background-color: #eee;
    border-radius: 3px;
    margin: 10px 15px;
    overflow: hidden;
}

.confidence-level {
    height: 100%;
    border-radius: 3px;
    transition: width 1.5s cubic-bezier(0.19, 1, 0.22, 1);
}

/* 置信度颜色 - 根据实际百分比动态显示 */
.confidence-high { background-color: #2a9d8f;; }  /* 绿色 - 高置信度 */
.confidence-medium { background-color: #d4b97a; }  /* 橙色 - 中等置信度 */
.confidence-low { background-color: #e76f51; }  /* 红色 - 低置信度 */

.confidence-90, .confidence-95, .confidence-99, .confidence-98, .confidence-97 {
    color: #2a9d8f;  /* 绿色 - 高置信度 */
    font-weight: bold;
}

.confidence-80, .confidence-85, .confidence-89, .confidence-70, .confidence-75, .confidence-87 {
    color: #f4a261;  /* 橙色 - 中等置信度 */
    font-weight: bold;
}

.confidence-50, .confidence-60, .confidence-65 {
    color: #e76f51;  /* 红色 - 低置信度 */
    font-weight: bold;
}

/* 高亮匹配 */
.highlight-match {
    background-color: rgba(42, 157, 143, 0.2);
    padding: 0 3px;
    border-radius: 3px;
}

/* ============= 引用样式 ============= */
/* 参考来源样式 */
.reference-sources {
    background:
        linear-gradient(180deg, rgba(247, 251, 255, 0.96), rgba(255, 255, 255, 0.98));
    margin: 18px 0 0;
    padding: 16px 18px 18px;
    border-top: 1px solid #dfeaf5;
    border-radius: 0 0 12px 12px;
}

.source-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.92em;
    color: #43627c;
    font-weight: 600;
}

.reference-header-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: center;
    gap: 16px;
    margin-bottom: 12px;
}

.reference-header-row .source-info {
    margin: 0;
    color: #245176;
    font-size: 18px !important;
    font-weight: 700;
    line-height: 1.35;
}

.reference-header-row .view-mindmap-btn {
    justify-self: start;
    margin: 0 !important;
}

.reference-header-row + .hallucination-check-container {
    margin-top: 0;
    margin-bottom: 12px;
}

.confidence-indicator {
    text-align: right;
    margin: 0 !important;
    padding: 5px 0 !important;
    font-size: 0.9em !important;
}

.ai-note {
    font-size: 0.8em;
    color: #666;
    font-style: italic;
    text-align: center;
    margin-top: 5px;
}

/* 知识图谱引用样式 */
.knowledge-citations {
    display: grid;
    gap: 10px;
    margin-top: 12px;
    border-top: 1px dashed #d8e5f1;
    padding-top: 12px;
}

/* 引用详情样式 */
.citation-detail {
    margin-bottom: 0;
    border: 1px solid #dbe8f4;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 8px 20px rgba(36, 81, 118, 0.06);
}

.citation-detail summary {
    padding: 11px 14px;
    background: linear-gradient(90deg, #f4f9ff, #ffffff);
    font-weight: 650;
    color: #27496d;
    cursor: pointer;
    transition: background-color 0.2s;
}

.citation-detail summary:hover {
    background-color: #e8f0fe;
}

.citation-content {
    padding: 14px 16px;
    border-top: 1px solid #e4edf6;
    background-color: #ffffff;
    color: #33475b;
    font-size: 14px;
    line-height: 1.75;
    max-height: none;
    overflow-y: auto;
    word-wrap: break-word;
    word-break: break-word;
    white-space: pre-wrap;
}

/* 引用内容中的HTML格式化 */
.citation-content strong {
    color: #1a73e8;
    font-weight: 600;
}

.citation-content br {
    margin-bottom: 5px;
    display: block;
    content: "";
}


/* 幻觉检测相关样式 - 集成自hallucination_check.css */
.hallucination-check-container {
    margin: 12px 0;
    border-radius: 8px;
    background: #ffffff;
    border: 1px solid var(--qh-line);
    padding: 12px;
    box-shadow: 0 8px 20px rgba(36, 81, 118, 0.06);
}

.hallucination-warning,
.hallucination-success {
    padding: 10px 12px;
    border-radius: 6px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 650;
    line-height: 1.45;
}

.hallucination-warning i,
.hallucination-success i {
    font-size: 18px;
}

.alert-danger {
    background-color: #fff4f2;
    color: #8a2d27;
    border-left: 4px solid #c2413b;
}

.alert-warning {
    background-color: #fff8e8;
    color: #7a4b00;
    border-left: 4px solid #d98717;
}

.alert-success {
    background-color: #eefaf4;
    color: #176342;
    border-left: 4px solid #1f9d66;
}

.alert-info {
    background-color: #f1f8ff;
    color: #245176;
    border-left: 4px solid var(--secondary-blue);
}

.hallucination-info {
    padding: 10px 12px;
    border-radius: 6px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 650;
    line-height: 1.45;
}

.hallucination-info i {
    font-size: 18px;
}

.hallucination-details {
    margin-top: 10px;
}

.hallucination-details summary {
    cursor: pointer;
    color: #294b67;
    font-weight: 650;
    padding: 6px 0;
}

.hallucination-conflicts {
    margin-top: 8px;
    padding-left: 25px;
    font-size: 0.95em;
}

.hallucination-conflicts li {
    margin-bottom: 5px;
    line-height: 1.55;
    color: #51433e;
}

.partial-match-details {
    margin-top: 10px;
}

.partial-match-details summary {
    cursor: pointer;
    color: #245176;
    font-weight: 650;
    padding: 6px 0;
}

.partial-match-suggestions {
    margin-top: 8px;
    padding-left: 25px;
    font-size: 0.95em;
}

.partial-match-suggestions li {
    margin-bottom: 5px;
    line-height: 1.55;
    color: var(--medical-blue);
}

/* 单独的幻觉检测组件样式 */
.hallucination-check {
    margin: 15px 0;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

.hallucination-check h4 {
    margin-top: 0;
    margin-bottom: 12px;
    color: #343a40;
    font-size: 16px;
    border-bottom: 1px solid #e9ecef;
    padding-bottom: 8px;
}

.hallucination-status {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    border-radius: 6px;
    font-weight: 500;
    margin-bottom: 12px;
}

.hallucination-status i {
    margin-right: 8px;
    font-size: 18px;
}

.hallucination-status.danger {
    background-color: #f8d7da;
    color: #721c24;
}

.hallucination-status.warning {
    background-color: #fff3cd;
    color: #856404;
}

.hallucination-status.success {
    background-color: #d4edda;
    color: #155724;
}

.badge {
    display: inline-block;
    padding: 3px 7px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 10px;
    margin-left: 8px;
}

.badge-danger {
    background-color: #dc3545;
    color: #fff;
}

.badge-warning {
    background-color: #ffc107;
    color: #212529;
}

.conflict-list {
    margin-top: 10px;
    padding-left: 20px;
}

.conflict-list li {
    margin-bottom: 6px;
    line-height: 1.5;
    color: #495057;
}

.hallucination-error {
    color: #721c24;
    font-style: italic;
}


.view-mindmap-btn {
    background: linear-gradient(135deg, #1abc9c, #16a085);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    margin-top: 10px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(26, 188, 156, 0.3);
}

.view-mindmap-btn:hover {
    background: linear-gradient(135deg, #16a085, #138d75);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(26, 188, 156, 0.4);
}

.view-mindmap-btn i {
    font-size: 14px;
}
