:root {
    --bg: #f7f7f5;
    --panel: #fff;
    --panel-glass: rgba(255, 255, 255, .88);
    --soft: #eeeeeb;
    --soft-hover: #e7e7e3;
    --ink: #1f1f1d;
    --ink-2: #696965;
    --ink-3: #9b9b95;
    --line: rgba(30, 30, 27, .1);
    --line-2: rgba(30, 30, 27, .16);
    --route: #ff6d4a;
    --retrieval-accent: #625d80;
    --retrieval-accent-soft: #efedf5;
    --sage: #315e4c;
    --sage-bg: #e5f1eb;
    --danger: #d74747;
    --content: 800px;
    --shadow-1: 0 8px 30px rgba(25, 25, 22, .06);
    --shadow-2: 0 24px 80px rgba(25, 25, 22, .12);
    --shadow-3: 0 40px 120px rgba(25, 25, 22, .18);
    --ease: cubic-bezier(.2, .85, .25, 1);
}

html[data-theme="dark"] {
    --bg: #171715;
    --panel: #21211f;
    --panel-glass: rgba(33, 33, 31, .9);
    --soft: #2b2b28;
    --soft-hover: #343430;
    --ink: #f1f1ed;
    --ink-2: #aaa9a3;
    --ink-3: #777771;
    --line: rgba(255, 255, 250, .09);
    --line-2: rgba(255, 255, 250, .15);
    --sage: #8fd1b6;
    --sage-bg: #203c32;
    --retrieval-accent: #b5aed4;
    --retrieval-accent-soft: #302d3d;
    --shadow-1: 0 8px 30px rgba(0, 0, 0, .18);
    --shadow-2: 0 24px 80px rgba(0, 0, 0, .34);
    --shadow-3: 0 40px 120px rgba(0, 0, 0, .5);
}

@media (prefers-color-scheme: dark) {
    html:not([data-theme]) {
        --bg: #171715;
        --panel: #21211f;
        --panel-glass: rgba(33, 33, 31, .9);
        --soft: #2b2b28;
        --soft-hover: #343430;
        --ink: #f1f1ed;
        --ink-2: #aaa9a3;
        --ink-3: #777771;
        --line: rgba(255, 255, 250, .09);
        --line-2: rgba(255, 255, 250, .15);
        --sage: #8fd1b6;
        --sage-bg: #203c32;
        --retrieval-accent: #b5aed4;
        --retrieval-accent-soft: #302d3d;
        --shadow-1: 0 8px 30px rgba(0, 0, 0, .18);
        --shadow-2: 0 24px 80px rgba(0, 0, 0, .34);
        --shadow-3: 0 40px 120px rgba(0, 0, 0, .5);
    }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { width: 100%; height: 100%; }

body {
    margin: 0;
    color: var(--ink);
    background: var(--bg);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    -webkit-font-smoothing: antialiased;
}

body.chat-page { overflow: hidden; }
button, textarea, input { color: inherit; font: inherit; }
button { border: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:focus-visible, textarea:focus-visible, input:focus-visible, summary:focus-visible {
    outline: 2px solid color-mix(in srgb, var(--route) 55%, transparent);
    outline-offset: 2px;
}
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-thumb { border-radius: 99px; background: var(--line-2); }

.icon-button {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 12px;
    color: var(--ink-2);
    background: transparent;
    display: grid;
    place-items: center;
    transition: color .18s ease, background .18s ease, transform .18s var(--ease);
}
.icon-button:hover { color: var(--ink); background: var(--soft); }
.icon-button:active { transform: scale(.94); }

.mini-logo,
.route-logo {
    position: relative;
    overflow: visible;
    color: var(--ink);
    background: transparent;
    display: grid;
    place-items: center;
}
.mini-logo {
    width: 34px;
    height: 22px;
}
.route-logo {
    width: 36px;
    height: 24px;
}
.mini-logo svg, .route-logo svg {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100%;
    overflow: visible;
}
.mini-logo path, .route-logo path,
.mini-logo circle, .route-logo circle {
    fill: none;
    stroke: currentColor;
    stroke-width: 6;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.mini-logo .brand-route-node,
.route-logo .brand-route-node { stroke: var(--route); }
.route-logo::after {
    content: "";
    position: absolute;
    inset: -10px;
    background: conic-gradient(from 180deg, transparent, var(--route), transparent 43%);
    opacity: 0;
    animation: logo-turn 2.2s linear infinite;
}
.route-logo.active::after { opacity: 1; }
@keyframes logo-turn { to { transform: rotate(1turn); } }

.app-shell {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.topbar {
    position: absolute;
    inset: 0 0 auto;
    z-index: 20;
    height: 64px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    pointer-events: none;
}
.topbar-group {
    display: flex;
    align-items: center;
    gap: 5px;
    pointer-events: auto;
}
.product-home {
    min-height: 40px;
    padding: 0 9px;
    border-radius: 12px;
    color: var(--ink);
    background: transparent;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 620;
    letter-spacing: -.025em;
}
.product-home:hover { background: var(--soft); }
.avatar-button {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 50%;
    color: #fff;
    background: #363632;
    font-size: 11px;
    font-weight: 650;
}

.screen {
    position: absolute;
    inset: 0;
    transition: opacity .38s ease, transform .5s var(--ease), visibility .38s;
}

.welcome-view {
    overflow-y: auto;
    padding: 88px 22px 64px;
    display: grid;
    place-items: center;
}
.welcome-inner {
    width: min(var(--content), 100%);
    margin: auto;
}
.route-intro {
    display: block;
    width: min(600px, 90vw);
    height: 104px;
    margin: 0 auto 12px;
    overflow: visible;
    user-select: none;
}
.route-intro .route-track {
    fill: none;
    stroke: color-mix(in srgb, var(--ink-3) 34%, transparent);
    stroke-width: 1.1;
    stroke-linecap: round;
    stroke-dasharray: 4 7;
    transition: stroke .3s ease, opacity .3s ease;
}
.route-intro .route-progress {
    fill: none;
    stroke: url(#route-progress-gradient);
    stroke-width: 1.7;
    stroke-linecap: round;
    opacity: 0;
}
.route-intro .route-gradient-tail { stop-color: var(--route); stop-opacity: .28; }
.route-intro .route-gradient-body { stop-color: var(--route); stop-opacity: .82; }
.route-intro .route-gradient-core { stop-color: #ff8668; stop-opacity: 1; }
.route-intro .route-gradient-head { stop-color: var(--route); stop-opacity: .48; }
.route-intro .route-origin,
.route-intro .route-destination {
    fill: var(--bg);
    stroke: var(--ink-3);
    stroke-width: 1.2;
    transition: fill .28s ease, stroke .28s ease, filter .28s ease;
}
.route-intro .traveller {
    fill: var(--route);
    stroke: color-mix(in srgb, var(--route) 25%, var(--bg));
    stroke-width: 5;
    filter: drop-shadow(0 4px 8px rgba(255, 109, 74, .28));
    opacity: 0;
    transform-box: fill-box;
    transform-origin: center;
    transition: filter .28s ease, transform .28s var(--ease);
}
.route-intro .route-hit-area {
    fill: none;
    stroke: transparent;
    stroke-width: 22;
    pointer-events: stroke;
    cursor: pointer;
}
.route-intro.is-interacting .route-track { stroke: color-mix(in srgb, var(--ink-3) 54%, transparent); }
.route-intro.is-interacting .traveller { transform: scale(1.3); filter: drop-shadow(0 5px 10px rgba(255, 109, 74, .38)); }
.route-intro.is-arrived .traveller { transform: scale(1.18); filter: drop-shadow(0 5px 12px rgba(255, 109, 74, .42)); }
.route-intro.is-arrived .route-destination {
    fill: color-mix(in srgb, var(--route) 18%, var(--bg));
    stroke: var(--route);
    filter: drop-shadow(0 0 5px rgba(255, 109, 74, .32));
}
.welcome-title {
    margin: 0;
    font-size: clamp(29px, 3.3vw, 40px);
    line-height: 1.18;
    letter-spacing: -.045em;
    font-weight: 610;
    text-align: center;
}
.welcome-title span {
    display: inline-block;
    margin-top: 5px;
    color: var(--ink-2);
    font-size: .7em;
    font-weight: 470;
    letter-spacing: -.035em;
}

.composer {
    position: relative;
    width: 100%;
    padding: 11px 11px 9px;
    border: 1px solid var(--line);
    border-radius: 28px;
    background: var(--panel);
    box-shadow: var(--shadow-2);
    transition: border-color .2s ease, box-shadow .25s ease, transform .25s var(--ease);
}
.welcome-composer { margin-top: 30px; }
.composer:focus-within {
    border-color: var(--line-2);
    box-shadow: 0 26px 90px rgba(25, 25, 22, .15);
    transform: translateY(-1px);
}
.composer textarea {
    width: 100%;
    min-height: 52px;
    max-height: 160px;
    padding: 10px 10px 8px;
    resize: none;
    border: 0;
    outline: 0;
    color: var(--ink);
    background: transparent;
    font-size: 15px;
    line-height: 1.55;
}
.composer textarea::placeholder { color: var(--ink-3); }
.composer-tools {
    min-height: 40px;
    padding: 0 1px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.retrieval-mode-control { position: relative; }
.retrieval-mode-trigger {
    height: 34px;
    padding: 0 10px;
    border: 1px solid transparent;
    border-radius: 10px;
    color: var(--ink-2);
    background: transparent;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 590;
    white-space: nowrap;
    transition: color .22s ease, border-color .22s ease, background-color .22s ease,
        box-shadow .24s ease, transform .18s var(--ease);
}
.retrieval-mode-trigger:hover,
.retrieval-mode-trigger[aria-expanded="true"] {
    color: var(--ink);
    background: var(--soft);
}
.retrieval-mode-trigger.is-enhanced {
    color: var(--retrieval-accent);
    border-color: color-mix(in srgb, var(--retrieval-accent) 20%, transparent);
    background: var(--retrieval-accent-soft);
    box-shadow: 0 5px 16px color-mix(in srgb, var(--retrieval-accent) 10%, transparent);
}
.retrieval-mode-trigger.is-newly-enhanced { animation: retrieval-mode-set .5s var(--ease); }
@keyframes retrieval-mode-set {
    0% { transform: scale(.97); box-shadow: 0 0 0 0 color-mix(in srgb, var(--retrieval-accent) 18%, transparent); }
    55% { transform: scale(1.015); box-shadow: 0 0 0 5px color-mix(in srgb, var(--retrieval-accent) 0%, transparent); }
    100% { transform: scale(1); }
}
.retrieval-mode-trigger:active { transform: scale(.97); }
.retrieval-mode-trigger:disabled { cursor: default; opacity: .5; }
.retrieval-mode-trigger > svg:first-child { transition: transform .3s var(--ease); }
.retrieval-mode-trigger.is-enhanced > svg:first-child { transform: rotate(-5deg) scale(1.04); }
.retrieval-mode-chevron { opacity: .7; transition: transform .25s var(--ease), opacity .2s ease; }
.retrieval-mode-trigger[aria-expanded="true"] .retrieval-mode-chevron { transform: rotate(180deg); }
.retrieval-mode-menu {
    position: absolute;
    z-index: 45;
    bottom: calc(100% + 9px);
    left: 0;
    width: min(390px, calc(100vw - 32px));
    padding: 5px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: color-mix(in srgb, var(--panel) 94%, transparent);
    box-shadow: 0 16px 48px rgba(25, 25, 22, .14), 0 2px 8px rgba(25, 25, 22, .05);
    backdrop-filter: blur(18px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(6px) scale(.975);
    transform-origin: left bottom;
    transition: opacity .2s ease, visibility .2s ease, transform .24s var(--ease);
}
.retrieval-mode-menu[hidden] { display: none; }
.retrieval-mode-menu.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}
.retrieval-mode-option {
    width: 100%;
    min-height: 40px;
    padding: 0 10px;
    border-radius: 10px;
    color: var(--ink-2);
    background: transparent;
    display: flex;
    align-items: center;
    gap: 8px;
    text-align: left;
    transition: color .18s ease, background-color .22s ease, transform .18s var(--ease);
}
.retrieval-mode-option:hover { color: var(--ink); }
.retrieval-mode-option:active { transform: scale(.985); }
.retrieval-mode-option[aria-checked="true"] { color: var(--ink); background: var(--soft); }
.retrieval-mode-option[data-retrieval-mode-option="enhanced"][aria-checked="true"] {
    color: var(--retrieval-accent);
    background: var(--retrieval-accent-soft);
}
.retrieval-mode-option > span:last-child {
    min-width: 0;
    display: flex;
    align-items: baseline;
    gap: 7px;
    white-space: nowrap;
}
.retrieval-mode-option strong { flex: 0 0 auto; font-size: 12px; line-height: 1.35; font-weight: 650; }
.retrieval-mode-option small {
    min-width: 0;
    overflow: hidden;
    color: var(--ink-3);
    font-size: 11px;
    line-height: 1.35;
    font-weight: 430;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.retrieval-mode-option > span:last-child small::before { content: "\00b7"; margin-right: 7px; }
.retrieval-mode-option[data-retrieval-mode-option="enhanced"][aria-checked="true"] small {
    color: color-mix(in srgb, var(--retrieval-accent) 68%, var(--ink-3));
}
.retrieval-option-mark {
    flex: 0 0 auto;
    width: 14px;
    height: 14px;
    border: 1.3px solid var(--line-2);
    border-radius: 50%;
    position: relative;
    transition: border-color .2s ease, background-color .2s ease, transform .25s var(--ease);
}
.retrieval-mode-option[aria-checked="true"] .retrieval-option-mark {
    border-color: var(--ink-2);
    background: var(--ink-2);
    transform: scale(1.04);
}
.retrieval-mode-option[data-retrieval-mode-option="enhanced"][aria-checked="true"] .retrieval-option-mark {
    border-color: var(--retrieval-accent);
    background: var(--retrieval-accent);
}
.retrieval-mode-option[aria-checked="true"] .retrieval-option-mark::after {
    content: "";
    position: absolute;
    width: 5px;
    height: 3px;
    top: 3px;
    left: 3px;
    border-left: 1.4px solid var(--panel);
    border-bottom: 1.4px solid var(--panel);
    transform: rotate(-45deg);
}
.composer-spacer { flex: 1; }
.composer-tool-btn.is-recording { color: var(--danger); background: var(--soft); }
.composer-tool-btn.is-recording svg { animation: pulse-rec 1.2s ease-in-out infinite; }
@keyframes pulse-rec { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.send-button {
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 50%;
    color: var(--bg);
    background: var(--ink);
    display: grid;
    place-items: center;
    transition: transform .18s var(--ease), opacity .18s ease;
}
.send-button:hover { transform: scale(1.04); }
.send-button:active { transform: scale(.93); }
.send-button:disabled { cursor: default; opacity: .35; transform: none; }
.send-button.is-running { cursor: pointer; }
.send-button.is-stopping { cursor: wait; opacity: .72; }

.prompt-rotator {
    width: min(560px, calc(100% - 28px));
    min-height: 44px;
    margin: 17px auto 0;
    padding: 0 13px;
    border-radius: 14px;
    color: var(--ink-2);
    background: transparent;
    display: flex;
    align-items: center;
    gap: 10px;
    text-align: left;
    font-size: 12px;
    transition: color .18s ease, background .18s ease;
}
.prompt-rotator:hover { color: var(--ink); background: var(--soft); }
.prompt-label {
    flex: 0 0 auto;
    color: var(--route);
    font-size: 11px;
    font-weight: 620;
}
.prompt-window { min-width: 0; flex: 1; overflow: hidden; }
.rotating-question {
    display: block;
    overflow: hidden;
    line-height: 1.5;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: opacity .28s ease, transform .42s var(--ease);
}
.rotating-question.is-leaving { opacity: 0; transform: translateY(-9px); }
.rotating-question.is-entering { opacity: 0; transform: translateY(9px); transition: none; }
.prompt-rotator svg { flex: 0 0 auto; color: var(--ink-3); }
.privacy-note {
    margin: 11px 0 0;
    color: var(--ink-3);
    font-size: 11px;
    text-align: center;
}

.conversation-view {
    padding: 64px 0 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px);
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
}
.app-shell[data-view="chat"] .welcome-view {
    opacity: 0;
    visibility: hidden;
    transform: translateY(-12px);
}
.app-shell[data-view="chat"] .conversation-view {
    opacity: 1;
    visibility: visible;
    transform: none;
}
.app-shell[data-view="knowledge"] .welcome-view,
.app-shell[data-view="knowledge"] .conversation-view {
    opacity: 0;
    visibility: hidden;
    transform: translateY(-12px);
}
.chat-messages {
    width: 100%;
    min-height: 0;
    margin: 0;
    padding: 38px max(18px, calc((100% - var(--content)) / 2)) 100px;
    overflow-y: auto;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: color-mix(in srgb, var(--ink) 18%, var(--panel)) transparent;
}
.chat-messages.is-scrolling,
.chat-messages:hover {
    scrollbar-color: color-mix(in srgb, var(--ink) 52%, var(--panel)) transparent;
}
.chat-messages::-webkit-scrollbar-thumb {
    border-radius: 99px;
    background: color-mix(in srgb, var(--ink) 18%, var(--panel));
}
.chat-messages.is-scrolling::-webkit-scrollbar-thumb,
.chat-messages:hover::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--ink) 52%, var(--panel));
}
.message-row {
    margin-bottom: 30px;
    animation: message-in .4s var(--ease) both;
}
@keyframes message-in { from { opacity: 0; transform: translateY(8px); } }
.message-row.user { display: flex; justify-content: flex-end; }
.message-row.ai { position: relative; display: block; }
.msg-avatar.user { display: none; }
.msg-avatar.ai {
    position: absolute;
    top: 0;
    right: calc(100% + 8px);
    width: 34px;
    height: 25px;
    background: center / 32px auto no-repeat url('/static/brand/hommey-mark.svg?v=20260811-safe-viewbox-v2');
}
.msg-avatar.ai img { display: none; }
.msg-avatar.ai::before { content: none; }
.message-row.ai:has(.answer-card) .msg-avatar.ai { display: none; }
html[data-theme="dark"] .msg-avatar.ai {
    background-image: url('/static/brand/hommey-mark-dark.svg?v=20260811-safe-viewbox-v2');
}
@media (prefers-color-scheme: dark) {
    html:not([data-theme]) .msg-avatar.ai {
        background-image: url('/static/brand/hommey-mark-dark.svg?v=20260811-safe-viewbox-v2');
    }
}
.msg-stack { min-width: 0; }
.message-row.user .msg-stack {
    width: min(100%, 640px);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}
.msg-bubble {
    font-size: 14px;
    line-height: 1.8;
    word-break: break-word;
}
.msg-bubble.user {
    width: fit-content;
    max-width: 100%;
    padding: 11px 15px;
    border-radius: 19px 19px 5px 19px;
    background: var(--soft);
    line-height: 1.65;
    white-space: pre-wrap;
    word-break: normal;
    overflow-wrap: anywhere;
}
.msg-bubble.ai { padding-top: 1px; }
.msg-bubble.ai.structured-result {
    padding: 17px 18px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: color-mix(in srgb, var(--panel) 92%, var(--soft));
    box-shadow: var(--shadow-1);
}
.msg-time {
    margin-top: 6px;
    color: var(--ink-3);
    font-size: 10px;
}
.message-row.user .msg-time { display: none; }
.option-list { margin-top: 11px; display: flex; flex-wrap: wrap; gap: 7px; }
.option-pill {
    min-height: 34px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--ink-2);
    background: var(--panel);
    font-size: 12px;
}
.option-pill:hover { color: var(--ink); border-color: var(--line-2); }
.option-pill:disabled { opacity: .45; cursor: default; }
.agent-indicator {
    min-height: 28px;
    color: var(--ink-2);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
}
.agent-tags { display: flex; gap: 5px; }
.agent-tag {
    padding: 4px 7px;
    border-radius: 999px;
    background: var(--soft);
    font-size: 10px;
}
.thinking-text {
    white-space: nowrap;
    transition: opacity .16s ease, transform .2s var(--ease);
}
.thinking-text.is-changing { opacity: 0; transform: translateY(3px); }
.typing-dots { display: flex; gap: 3px; }
.typing-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: currentColor;
    animation: thinking 1.2s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: .12s; }
.typing-dot:nth-child(3) { animation-delay: .24s; }
@keyframes thinking {
    0%, 70%, 100% { opacity: .25; transform: translateY(0); }
    35% { opacity: 1; transform: translateY(-2px); }
}

.chat-composer-shell {
    position: relative;
    z-index: 5;
    width: min(var(--content), calc(100% - 36px));
    margin: 0 auto;
    padding: 0 0 15px;
}
.chat-composer-shell .composer {
    box-shadow: 0 18px 55px rgba(25, 25, 22, .11);
}
.chat-composer-shell .composer textarea {
    min-height: 38px;
    padding-top: 5px;
}
.disclaimer {
    margin: 7px 0 0;
    color: var(--ink-3);
    font-size: 10px;
    text-align: center;
}

.scrim {
    position: fixed;
    inset: 0;
    z-index: 30;
    border: 0;
    background: rgba(15, 15, 13, .16);
    backdrop-filter: blur(1px);
    opacity: 0;
    visibility: hidden;
    transition: opacity .22s ease, visibility .22s;
}
.scrim.visible { opacity: 1; visibility: visible; }

.sidebar {
    position: fixed;
    top: 8px;
    bottom: 8px;
    left: 8px;
    z-index: 40;
    width: min(286px, calc(100vw - 16px));
    padding: 9px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: var(--panel-glass);
    box-shadow: var(--shadow-3);
    backdrop-filter: blur(28px) saturate(130%);
    opacity: 0;
    visibility: hidden;
    transform: translateX(-18px) scale(.985);
    transform-origin: left center;
    overflow: hidden;
    transition: opacity .24s ease, transform .32s var(--ease), visibility .24s;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
}
.sidebar.open { opacity: 1; visibility: visible; transform: none; }
.sidebar-head { padding: 3px 3px 9px; }
.sidebar-brand-row { display: flex; align-items: center; justify-content: space-between; }
.sidebar-brand {
    padding-left: 7px;
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 14px;
    font-weight: 620;
}
.sidebar-actions { min-width: 0; margin-top: 12px; display: grid; gap: 3px; }
.sidebar-search-group { min-width: 0; display: grid; }
.sidebar-action {
    min-width: 0;
    width: 100%;
    min-height: 40px;
    padding: 0 10px;
    border-radius: 11px;
    color: var(--ink);
    background: transparent;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    text-align: left;
}
.sidebar-action:hover { background: var(--soft); }
.sidebar-action svg { color: var(--ink-2); }
.sidebar-action.active { background: var(--soft); font-weight: 570; }
.sidebar-action-note {
    margin-left: auto;
    color: var(--ink-3);
    font-size: 10px;
    font-weight: 480;
}
.history-search {
    width: 100%;
    min-width: 0;
    height: 0;
    margin-top: 0;
    padding: 0 10px;
    border-radius: 11px;
    background: var(--soft);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-7px) scale(.985);
    transform-origin: top center;
    transition:
        height .34s var(--ease),
        margin-top .34s var(--ease),
        opacity .18s ease,
        transform .34s var(--ease),
        visibility 0s linear .34s;
    display: flex;
    align-items: center;
    gap: 8px;
}
.history-search.visible {
    height: 38px;
    margin-top: 2px;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: none;
    transition:
        height .34s var(--ease),
        margin-top .34s var(--ease),
        opacity .24s ease .06s,
        transform .34s var(--ease),
        visibility 0s;
}
.history-search svg { flex: 0 0 auto; }
.history-search input {
    width: 100%;
    min-width: 0;
    flex: 1;
    border: 0;
    outline: 0;
    background: transparent;
    font-size: 11px;
}
.history-list { min-width: 0; padding: 5px 3px; overflow-x: hidden; overflow-y: auto; }
.history-label { margin: 13px 8px 5px; color: var(--ink-3); font-size: 10px; }
.history-empty { padding: 20px 9px; color: var(--ink-3); font-size: 11px; line-height: 1.6; }
.session-row {
    position: relative;
    min-width: 0;
    min-height: 40px;
    border-radius: 10px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 28px;
    align-items: center;
}
.session-row:hover, .session-row.active { background: var(--soft); }
.session-open {
    min-width: 0;
    height: 40px;
    padding: 0 5px 0 9px;
    border-radius: 10px;
    color: var(--ink-2);
    background: transparent;
    overflow: hidden;
    text-align: left;
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.session-row.active .session-open { color: var(--ink); font-weight: 560; }
.session-more {
    width: 27px;
    height: 27px;
    padding: 0;
    border-radius: 8px;
    color: var(--ink-3);
    background: transparent;
    opacity: 0;
}
.session-row:hover .session-more, .session-more:focus { opacity: 1; }
.sidebar-foot { padding-top: 7px; border-top: 1px solid var(--line); }
.account-row {
    width: 100%;
    min-height: 48px;
    padding: 6px 8px;
    border-radius: 12px;
    color: var(--ink);
    background: transparent;
    display: flex;
    align-items: center;
    gap: 10px;
    text-align: left;
}
.account-row:hover { background: var(--soft); }
.account-avatar {
    width: 30px;
    height: 30px;
    flex: 0 0 auto;
    border-radius: 50%;
    color: #fff;
    background: #373733;
    display: grid;
    place-items: center;
    font-size: 10px;
    font-weight: 650;
}
.account-copy { min-width: 0; flex: 1; }
.account-copy strong, .account-copy span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.account-copy strong { font-size: 11px; font-weight: 590; }
.account-copy span { margin-top: 2px; color: var(--ink-3); font-size: 10px; }

.session-popover {
    position: fixed;
    z-index: 52;
    width: 130px;
    padding: 5px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel);
    box-shadow: var(--shadow-2);
}
.session-popover button {
    width: 100%;
    min-height: 34px;
    padding: 0 9px;
    border-radius: 8px;
    color: var(--ink);
    background: transparent;
    text-align: left;
    font-size: 10px;
}
.session-popover button:hover { background: var(--soft); }
.session-popover .danger { color: var(--danger); }

.modal-layer {
    position: fixed;
    inset: 0;
    z-index: 60;
    padding: 20px;
    background: rgba(15, 15, 13, .2);
    backdrop-filter: blur(8px);
    opacity: 0;
    visibility: hidden;
    display: grid;
    place-items: center;
    transition: opacity .24s ease, visibility .24s;
}
.modal-layer.open { opacity: 1; visibility: visible; }
.settings-modal, .small-modal {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: var(--panel);
    box-shadow: var(--shadow-3);
    transform: translateY(12px) scale(.985);
    transition: transform .32s var(--ease);
}
.modal-layer.open .settings-modal, .modal-layer.open .small-modal { transform: none; }
.settings-modal { width: min(500px, 100%); max-height: min(760px, calc(100vh - 40px)); }
.small-modal { width: min(380px, 100%); padding: 22px; }
.modal-head {
    min-height: 62px;
    padding: 0 14px 0 21px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-head h2, .small-modal h2 {
    margin: 0;
    font-size: 17px;
    letter-spacing: -.03em;
    font-weight: 620;
}
.attachments-modal {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: var(--panel);
    box-shadow: var(--shadow-3);
    width: min(560px, 100%);
    max-height: min(680px, calc(100vh - 40px));
    display: flex;
    flex-direction: column;
    transform: translateY(12px) scale(.985);
    transition: transform .32s var(--ease);
}
.modal-layer.open .attachments-modal { transform: none; }
.attachments-list {
    flex: 1;
    padding: 10px;
    overflow-y: auto;
}
.attachments-list .empty-state {
    padding: 42px 12px;
    text-align: center;
    color: var(--ink-3);
    font-size: 13px;
}
.attachment-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 13px;
    transition: background .18s ease;
}
.attachment-item:hover { background: var(--soft); }
.attachment-item + .attachment-item { margin-top: 2px; }
.attachment-item-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--soft);
    display: grid;
    place-items: center;
    font-size: 15px;
    flex: none;
}
.attachment-item-main {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.attachment-item-name {
    font-size: 13px;
    font-weight: 560;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.attachment-item-meta { color: var(--ink-3); font-size: 11px; }
.attachment-item-actions {
    display: flex;
    gap: 6px;
    flex: none;
}
.attachment-action {
    height: 30px;
    padding: 0 12px;
    border-radius: 9px;
    border: 1px solid var(--line);
    color: var(--ink-2);
    background: transparent;
    font-size: 12px;
    font-weight: 540;
    transition: color .18s ease, background .18s ease, border-color .18s ease;
}
.attachment-action:hover { color: var(--ink); background: var(--soft); }
.attachment-action.primary { color: var(--ink); border-color: var(--line-2); }
.attachment-action.danger { color: var(--danger); }
.attachment-action.danger:hover { background: var(--soft); }
.settings-body { max-height: calc(100vh - 102px); padding: 18px; overflow-y: auto; }
.settings-section + .settings-section { margin-top: 24px; }
.settings-label { margin: 0 3px 7px; color: var(--ink-3); font-size: 11px; }
.settings-card { overflow: hidden; border: 1px solid var(--line); border-radius: 15px; }
.setting-row {
    min-height: 53px;
    padding: 9px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}
.setting-row + .setting-row { border-top: 1px solid var(--line); }
.setting-title { font-size: 12px; font-weight: 560; }
.setting-note { margin-top: 3px; color: var(--ink-3); font-size: 10px; }
.theme-tabs { padding: 3px; border-radius: 10px; background: var(--soft); display: flex; }
.theme-tab {
    height: 27px;
    padding: 0 8px;
    border-radius: 8px;
    color: var(--ink-2);
    background: transparent;
    font-size: 10px;
}
.theme-tab.active { color: var(--ink); background: var(--panel); box-shadow: var(--shadow-1); }
.toggle {
    position: relative;
    width: 40px;
    height: 24px;
    padding: 0;
    border-radius: 99px;
    background: var(--ink-3);
}
.toggle::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 5px rgba(0, 0, 0, .2);
    transition: transform .22s var(--ease);
}
.toggle.on { background: var(--sage); }
.toggle.on::after { transform: translateX(16px); }
.settings-action {
    width: 100%;
    min-height: 47px;
    padding: 0 12px;
    color: var(--ink);
    background: transparent;
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    text-decoration: none;
}
.settings-action + .settings-action { border-top: 1px solid var(--line); }
.settings-action:hover { background: var(--soft); }
.settings-action.danger { color: var(--danger); }
.pref-list, .active-trip { padding: 4px 12px 11px; }
.info-row, .trip-row {
    padding: 7px 0;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--ink-2);
    font-size: 11px;
}
.empty-state, .meta { padding: 8px 0; color: var(--ink-3); font-size: 11px; line-height: 1.6; }
.settings-details summary {
    min-height: 45px;
    padding: 0 12px;
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
}
.settings-details summary::-webkit-details-marker { display: none; }
.small-modal p { margin: 9px 0 0; color: var(--ink-2); font-size: 11px; line-height: 1.6; }
.modal-input {
    width: 100%;
    height: 44px;
    margin-top: 17px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    outline: 0;
    background: var(--soft);
    font-size: 12px;
}
.modal-actions { margin-top: 18px; display: flex; justify-content: flex-end; gap: 8px; }
.secondary-button, .primary-button, .danger-button {
    min-height: 38px;
    padding: 0 14px;
    border-radius: 11px;
    font-size: 11px;
}
.secondary-button { color: var(--ink); background: var(--soft); }
.primary-button { color: var(--bg); background: var(--ink); }
.danger-button { color: #fff; background: var(--danger); }

.toast {
    position: fixed;
    left: 50%;
    bottom: 18px;
    z-index: 100;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: var(--panel-glass);
    box-shadow: var(--shadow-2);
    backdrop-filter: blur(18px);
    font-size: 12px;
    opacity: 0;
    transform: translate(-50%, 10px);
    pointer-events: none;
    transition: opacity .2s ease, transform .25s var(--ease);
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

.init-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: var(--bg);
    display: grid;
    place-items: center;
    transition: opacity .3s ease, visibility .3s;
}
.init-overlay.hidden { opacity: 0; visibility: hidden; }
.init-card { text-align: center; }
.init-card .mini-logo { width: 64px; height: 34px; margin: 0 auto 15px; }
.init-status { font-size: 13px; font-weight: 590; }
.init-sub { margin-top: 6px; color: var(--ink-3); font-size: 11px; }
.init-sub a { color: var(--ink); }

/* Authentication */
.auth-page {
    min-height: 100%;
    overflow-y: auto;
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(380px, .85fr);
}
.auth-visual {
    position: relative;
    min-height: 100vh;
    padding: 28px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.auth-brand {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 14px;
    font-weight: 620;
}
.auth-mobile-brand { display: none; }
.auth-story {
    width: min(620px, 90%);
    margin: auto;
}
.auth-route { width: 100%; height: 140px; margin-bottom: 18px; }
.auth-route path { fill: none; stroke: var(--line-2); stroke-width: 1; stroke-dasharray: 5 8; }
.auth-route .active {
    stroke: var(--route);
    stroke-width: 1.7;
    stroke-dasharray: 220 700;
    animation: auth-route-travel 7s ease-in-out infinite;
}
@keyframes auth-route-travel {
    0%, 9% { stroke-dashoffset: 220; opacity: 0; }
    20%, 78% { opacity: 1; }
    92%, 100% { stroke-dashoffset: -700; opacity: 0; }
}
.auth-story h1 {
    margin: 0;
    font-size: clamp(40px, 4.5vw, 64px);
    line-height: 1.02;
    letter-spacing: -.055em;
    font-weight: 620;
}
.auth-story h1 span { display: block; white-space: nowrap; }
.auth-story p { max-width: 470px; margin: 20px 0 0; color: var(--ink-2); font-size: 14px; line-height: 1.7; }
.auth-panel {
    min-height: 100vh;
    padding: 30px;
    border-left: 1px solid var(--line);
    background: var(--panel);
    display: grid;
    place-items: center;
}
.auth-box { width: min(360px, 100%); }
.auth-mode-copy { will-change: opacity, transform; }
.auth-mode-copy h2 { margin: 0; font-size: 26px; letter-spacing: -.04em; font-weight: 620; }
.auth-mode-copy p { margin: 8px 0 0; color: var(--ink-2); font-size: 12px; }
.auth-tabs {
    position: relative;
    margin-top: 25px;
    padding: 3px;
    border-radius: 12px;
    background: var(--soft);
    display: grid;
    grid-template-columns: 1fr 1fr;
}
.auth-tabs::before {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: calc(50% - 3px);
    height: 35px;
    border-radius: 9px;
    background: var(--panel);
    box-shadow: var(--shadow-1);
    transition: transform .34s var(--ease);
}
.auth-tabs[data-mode="register"]::before { transform: translateX(100%); }
.auth-tab {
    position: relative;
    z-index: 1;
    height: 35px;
    border-radius: 9px;
    color: var(--ink-2);
    background: transparent;
    font-size: 11px;
    transition: color .24s ease;
}
.auth-tab.active { color: var(--ink); }
.auth-form { margin-top: 17px; display: grid; gap: 2px; }
.auth-field { position: relative; padding-bottom: 8px; }
.auth-input {
    width: 100%;
    height: 49px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: 13px;
    outline: 0;
    background: var(--bg);
    font-size: 12px;
    transition: border-color .2s ease, background .2s ease, box-shadow .2s ease;
}
.auth-input:hover { border-color: var(--line-2); }
.auth-input:focus,
.auth-input:focus-visible {
    outline: 0;
    border-color: var(--line-2);
    background: var(--panel);
    box-shadow: 0 0 0 4px var(--soft);
}
.auth-field.has-error .auth-input {
    border-color: color-mix(in srgb, var(--danger) 68%, transparent);
    background: color-mix(in srgb, var(--danger) 3%, var(--bg));
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 9%, transparent);
}
.auth-field.has-error .auth-input:focus { box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 11%, transparent); }
.auth-field-error {
    min-height: 0;
    max-height: 0;
    margin: 0;
    padding: 0 3px;
    overflow: hidden;
    color: var(--danger);
    font-size: 11px;
    line-height: 1.45;
    opacity: 0;
    transform: translateY(-3px);
    transition: max-height .22s var(--ease), margin .22s var(--ease), opacity .18s ease, transform .22s var(--ease);
}
.auth-field.has-error .auth-field-error {
    max-height: 34px;
    margin-top: 6px;
    opacity: 1;
    transform: translateY(0);
}
.auth-submit {
    height: 49px;
    margin-top: 0;
    border-radius: 13px;
    color: var(--bg);
    background: var(--ink);
    font-size: 12px;
    font-weight: 610;
    transition: opacity .2s ease, transform .18s var(--ease), box-shadow .2s ease;
}
.auth-submit:hover:not(:disabled) { box-shadow: var(--shadow-1); transform: translateY(-1px); }
.auth-submit:active:not(:disabled) { transform: translateY(0) scale(.99); }
.auth-submit:disabled { opacity: .55; cursor: wait; }
.auth-error {
    min-height: 18px;
    margin-top: 8px;
    color: var(--danger);
    font-size: 11px;
    line-height: 1.5;
    text-align: center;
}
.auth-footnote { margin-top: 18px; color: var(--ink-3); font-size: 10px; line-height: 1.6; text-align: center; }

html[data-motion="off"] *,
html[data-motion="off"] *::before,
html[data-motion="off"] *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
        scroll-behavior: auto !important;
    }
}

@media (max-width: 760px) {
    .topbar { height: 58px; padding: 0 10px; }
    .product-home { padding-left: 5px; }
    .welcome-view { padding: 76px 16px 34px; align-items: start; }
    .welcome-inner { margin: auto 0; }
    .route-intro { width: min(340px, 85vw); height: 70px; margin-bottom: 11px; }
    .welcome-title { font-size: 28px; }
    .composer { border-radius: 24px; }
    .retrieval-mode-trigger { padding-right: 7px; padding-left: 7px; }
    .retrieval-mode-trigger > svg:first-child { display: none; }
    .welcome-composer { margin-top: 26px; }
    .prompt-rotator { width: calc(100% - 12px); padding-right: 9px; padding-left: 9px; }
    .conversation-view { padding-top: 58px; }
    .chat-messages { width: 100%; padding: 25px 13px 90px; }
    .msg-avatar.ai { display: none; }
    .message-row.user .msg-stack { width: 88%; }
    .chat-composer-shell { width: calc(100% - 26px); padding-right: 0; padding-left: 0; }
    .sidebar { top: 6px; bottom: 6px; left: 6px; width: min(286px, calc(100vw - 12px)); }
    .modal-layer { padding: 10px; }
    .settings-body { padding: 13px; }
    .auth-page { grid-template-columns: 1fr; }
    .auth-visual { display: none; }
    .auth-panel { min-height: 100vh; padding: 24px; border-left: 0; }
    .auth-mobile-brand {
        margin-bottom: 34px;
        display: flex;
        align-items: center;
        gap: 9px;
        font-size: 14px;
        font-weight: 620;
    }
}

/* ── 多模态附件（P0）────────────────────────────────────────── */
.pending-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px 2px 6px;
}
.pending-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 220px;
    padding: 4px 6px 4px 10px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--soft);
    color: var(--ink-2);
    font-size: 12px;
    line-height: 1.4;
    white-space: nowrap;
}
.pending-chip-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.pending-chip.failed { border-color: color-mix(in srgb, var(--danger) 45%, transparent); color: var(--danger); }
.pending-chip-remove {
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    padding: 0;
    border: 0;
    background: color-mix(in srgb, currentColor 7%, transparent);
    border-radius: 50%;
    color: currentColor;
    cursor: pointer;
    display: grid;
    place-items: center;
    font-size: 15px;
    line-height: 1;
    opacity: .7;
}
.pending-chip-remove:hover { background: color-mix(in srgb, currentColor 14%, transparent); opacity: 1; }

.attach-button { cursor: pointer; }
.attach-button input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.msg-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}
.attachment-card {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--soft);
    color: var(--ink-2);
    font-size: 12px;
    max-width: 240px;
}
.attachment-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-icon { font-size: 14px; }

/* ── RAG 知识库阅读器 ─────────────────────────────────────── */
.knowledge-view {
    padding: 64px 22px clamp(28px, 5vh, 52px);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateX(12px);
}
.app-shell[data-view="knowledge"] .knowledge-view {
    opacity: 1;
    visibility: visible;
    transform: none;
}
.knowledge-shell {
    width: min(1280px, 100%);
    height: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
}
.knowledge-overview {
    flex: 0 0 auto;
    padding: 8px 8px 11px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
}
.knowledge-nav {
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.knowledge-exit {
    height: 28px;
    padding: 0 9px 0 7px;
    border: 1px solid var(--line);
    border-radius: 9px;
    color: var(--ink-2);
    background: color-mix(in srgb, var(--panel) 72%, transparent);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 560;
    cursor: pointer;
    transition: color .18s ease, border-color .18s ease, background .18s ease, transform .24s var(--ease);
}
.knowledge-exit svg { transition: transform .24s var(--ease); }
.knowledge-exit:hover {
    color: var(--ink);
    border-color: var(--line-2);
    background: var(--panel);
    transform: translateX(-2px);
}
.knowledge-exit:hover svg { transform: translateX(-2px); }
.knowledge-exit:active { transform: translateX(-1px) scale(.97); }
.knowledge-eyebrow {
    margin-bottom: 0;
    color: var(--ink-3);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 10px;
    font-weight: 680;
    letter-spacing: .16em;
}
.knowledge-pulse {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--route);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--route) 12%, transparent);
}
.knowledge-overview h1 {
    margin: 0;
    font-size: clamp(25px, 3vw, 34px);
    line-height: 1.08;
    letter-spacing: -.045em;
    font-weight: 620;
}
.knowledge-overview p {
    margin: 5px 0 0;
    color: var(--ink-2);
    font-size: 13px;
    line-height: 1.55;
}
.knowledge-header-side {
    display: flex;
    align-items: center;
    gap: 18px;
}
.knowledge-summary {
    padding: 0 4px 2px 22px;
    border-left: 1px solid var(--line);
    display: grid;
    gap: 2px;
}
.knowledge-summary strong {
    font-size: 24px;
    line-height: 1;
    letter-spacing: -.04em;
    font-weight: 580;
}
.knowledge-summary span { color: var(--ink-3); font-size: 11px; white-space: nowrap; }
.knowledge-admin-actions { display: flex; align-items: center; gap: 7px; }
.knowledge-admin-button {
    height: 38px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 11px;
    color: var(--ink-2);
    background: var(--panel);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font-size: 12px;
    font-weight: 560;
    white-space: nowrap;
    cursor: pointer;
    transition: color .18s ease, border-color .18s ease, background .18s ease, transform .2s var(--ease);
}
.knowledge-admin-button:hover { color: var(--ink); border-color: var(--line-2); transform: translateY(-1px); }
.knowledge-admin-button:active { transform: scale(.97); }
.knowledge-admin-button.primary { color: var(--bg); border-color: var(--ink); background: var(--ink); }
.knowledge-admin-button.busy { pointer-events: none; opacity: .58; }
.knowledge-admin-button.busy svg { animation: logo-turn .8s linear infinite; }
.knowledge-admin-button input { display: none; }

.knowledge-sync-bar {
    position: relative;
    min-height: 44px;
    margin: 9px 0 0;
    padding: 6px 44px 7px 10px;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: color-mix(in srgb, var(--panel) 72%, var(--soft));
    overflow: hidden;
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    align-items: center;
    gap: 9px;
    animation: knowledge-status-in .32s var(--ease) both;
}
@keyframes knowledge-status-in { from { opacity: 0; transform: translateY(6px) scale(.995); } }
.knowledge-sync-icon {
    width: 28px;
    height: 28px;
    border-radius: 9px;
    color: var(--route);
    background: color-mix(in srgb, var(--route) 10%, var(--soft));
    display: grid;
    place-items: center;
}
.knowledge-sync-bar[data-status="running"] .knowledge-sync-icon svg { animation: logo-turn 1.1s linear infinite; }
.knowledge-sync-bar[data-status="success"] .knowledge-sync-icon { color: var(--sage); background: var(--sage-bg); }
.knowledge-sync-bar[data-status="error"] .knowledge-sync-icon { color: var(--danger); background: color-mix(in srgb, var(--danger) 9%, var(--soft)); }
.knowledge-sync-copy { min-width: 0; display: grid; gap: 3px; }
.knowledge-sync-copy strong { overflow: hidden; font-size: 12px; font-weight: 610; text-overflow: ellipsis; white-space: nowrap; }
.knowledge-sync-copy span { overflow: hidden; color: var(--ink-3); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.knowledge-sync-progress { position: absolute; inset: auto 0 0; height: 2px; background: var(--soft); }
.knowledge-sync-progress span {
    width: 0;
    height: 100%;
    border-radius: 2px;
    background: var(--route);
    display: block;
    transition: width .5s var(--ease);
}
.knowledge-sync-bar[data-status="success"] .knowledge-sync-progress span { background: var(--sage); }
.knowledge-sync-bar[data-status="error"] .knowledge-sync-progress span { background: var(--danger); }
.knowledge-sync-close {
    position: absolute;
    top: 6px;
    right: 7px;
    width: 29px;
    height: 29px;
    border-radius: 9px;
    color: var(--ink-3);
    background: transparent;
    display: grid;
    place-items: center;
}
.knowledge-sync-close:hover { color: var(--ink); background: var(--soft); }
.knowledge-sync-bar[data-status="running"] .knowledge-sync-close { display: none; }

.knowledge-workspace {
    min-height: 0;
    flex: 1;
    border: 1px solid var(--line);
    border-radius: 24px;
    background: var(--panel);
    box-shadow: var(--shadow-1);
    overflow: hidden;
    display: grid;
    grid-template-columns: minmax(270px, 330px) minmax(0, 1fr);
}
.knowledge-library {
    min-height: 0;
    padding: 17px 13px 12px;
    border-right: 1px solid var(--line);
    background: color-mix(in srgb, var(--soft) 44%, var(--panel));
    display: flex;
    flex-direction: column;
}
.knowledge-search {
    height: 42px;
    padding: 0 11px;
    border: 1px solid transparent;
    border-radius: 12px;
    background: var(--panel);
    box-shadow: 0 1px 0 var(--line);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: border-color .2s ease, box-shadow .2s ease;
}
.knowledge-search:focus-within {
    border-color: var(--line-2);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink) 5%, transparent);
}
.knowledge-search svg { flex: 0 0 auto; color: var(--ink-3); }
.knowledge-search input {
    min-width: 0;
    flex: 1;
    border: 0;
    outline: 0;
    background: transparent;
    font-size: 13px;
}
.knowledge-search input::placeholder { color: var(--ink-3); }
.knowledge-search kbd {
    min-width: 28px;
    padding: 3px 5px;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--ink-3);
    background: var(--soft);
    font-family: inherit;
    font-size: 10px;
    text-align: center;
}
.knowledge-filter-row {
    padding: 15px 7px 8px;
    color: var(--ink-3);
    display: flex;
    justify-content: space-between;
    font-size: 11px;
}
.knowledge-list {
    min-height: 0;
    padding: 0 2px 4px;
    overflow-y: auto;
    display: grid;
    align-content: start;
    gap: 4px;
}
.knowledge-card {
    width: 100%;
    padding: 13px 12px 12px;
    border: 1px solid transparent;
    border-radius: 13px;
    color: var(--ink);
    background: transparent;
    text-align: left;
    transition: background .18s ease, border-color .18s ease, transform .2s var(--ease);
}
.knowledge-card:hover { background: var(--panel); transform: translateX(2px); }
.knowledge-card.active {
    border-color: var(--line);
    background: var(--panel);
    box-shadow: 0 5px 18px rgba(25, 25, 22, .04);
}
.knowledge-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.knowledge-card-tags { display: flex; align-items: center; gap: 6px; }
.knowledge-category {
    color: var(--sage);
    font-size: 10px;
    font-weight: 650;
    letter-spacing: .04em;
}
.knowledge-file-type {
    color: var(--ink-3);
    font-size: 10px;
    text-transform: uppercase;
}
.knowledge-index-state {
    padding: 3px 5px;
    border-radius: 5px;
    color: var(--route);
    background: color-mix(in srgb, var(--route) 9%, transparent);
    font-size: 9px;
    font-weight: 640;
}
.knowledge-card h3 {
    margin: 8px 0 5px;
    overflow: hidden;
    font-size: 14px;
    font-weight: 610;
    line-height: 1.4;
    letter-spacing: -.015em;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.knowledge-card p {
    height: 40px;
    margin: 0;
    overflow: hidden;
    color: var(--ink-2);
    font-size: 11px;
    line-height: 1.65;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.knowledge-card-meta {
    margin-top: 10px;
    color: var(--ink-3);
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
}
.knowledge-card-meta i { width: 2px; height: 2px; border-radius: 50%; background: currentColor; }
.knowledge-list-loading { padding: 14px 10px; display: grid; gap: 10px; }
.knowledge-list-loading span {
    display: block;
    height: 72px;
    border-radius: 12px;
    background: linear-gradient(100deg, var(--soft) 25%, var(--panel) 45%, var(--soft) 65%);
    background-size: 220% 100%;
    animation: knowledge-shimmer 1.5s ease infinite;
}
@keyframes knowledge-shimmer { to { background-position: -220% 0; } }
.knowledge-list-state { padding: 28px 12px; color: var(--ink-3); font-size: 12px; line-height: 1.7; text-align: center; }

.knowledge-reader { min-width: 0; min-height: 0; overflow-y: auto; background: var(--panel); }
.knowledge-empty {
    min-height: 100%;
    padding: 50px 24px;
    display: grid;
    place-content: center;
    justify-items: center;
    text-align: center;
}
.knowledge-empty-mark {
    width: 68px;
    height: 68px;
    border: 1px solid var(--line);
    border-radius: 22px;
    color: var(--ink-3);
    background: var(--soft);
    display: grid;
    place-items: center;
    transform: rotate(-2deg);
}
.knowledge-empty h2 { margin: 20px 0 0; font-size: 16px; letter-spacing: -.025em; font-weight: 590; }
.knowledge-empty p { margin: 8px 0 0; color: var(--ink-3); font-size: 12px; }
.knowledge-document { width: min(800px, calc(100% - 48px)); margin: 0 auto; padding: 33px 0 58px; }
.knowledge-back {
    margin: -4px 0 19px;
    padding: 7px 8px 7px 5px;
    border-radius: 8px;
    color: var(--ink-2);
    background: transparent;
    display: none;
    align-items: center;
    gap: 4px;
    font-size: 12px;
}
.knowledge-back:hover { color: var(--ink); background: var(--soft); }
.document-head { padding-bottom: 25px; border-bottom: 1px solid var(--line); }
.document-kicker { color: var(--sage); display: flex; align-items: center; gap: 8px; font-size: 11px; font-weight: 620; }
.document-kicker span + span {
    padding: 3px 6px;
    border-radius: 6px;
    color: var(--ink-3);
    background: var(--soft);
    font-size: 10px;
    text-transform: uppercase;
}
.document-head h2 {
    max-width: 680px;
    margin: 13px 0 11px;
    font-size: clamp(26px, 3.2vw, 38px);
    line-height: 1.16;
    letter-spacing: -.047em;
    font-weight: 620;
}
.document-meta { color: var(--ink-3); display: flex; flex-wrap: wrap; align-items: center; gap: 7px; font-size: 11px; }
.document-meta i { width: 2px; height: 2px; border-radius: 50%; background: currentColor; }
.document-toc {
    margin: 22px 0 4px;
    padding: 14px 15px;
    border-left: 2px solid color-mix(in srgb, var(--route) 65%, transparent);
    border-radius: 0 12px 12px 0;
    background: color-mix(in srgb, var(--soft) 55%, transparent);
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
}
.document-toc::before {
    content: "本文目录";
    width: 100%;
    margin-bottom: 5px;
    color: var(--ink-3);
    font-size: 10px;
    font-weight: 650;
    letter-spacing: .08em;
}
.document-toc button {
    padding: 3px 0;
    color: var(--ink-2);
    background: transparent;
    font-size: 11px;
    text-align: left;
}
.document-toc button:hover { color: var(--route); }
.document-body { padding: 15px 1px 0; color: var(--ink-2); }
.document-body h2 {
    scroll-margin-top: 24px;
    margin: 38px 0 14px;
    color: var(--ink);
    font-size: 19px;
    line-height: 1.4;
    letter-spacing: -.025em;
    font-weight: 620;
}
.document-body h2::before {
    content: "";
    width: 18px;
    height: 2px;
    margin: 0 0 10px;
    border-radius: 2px;
    background: var(--route);
    display: block;
}
.document-body h3 { margin: 24px 0 9px; color: var(--ink); font-size: 13px; line-height: 1.5; font-weight: 620; }
.document-body p { margin: 8px 0; font-size: 13px; line-height: 1.85; }
.document-body ul { margin: 7px 0 13px; padding: 0; list-style: none; }
.document-body li {
    position: relative;
    margin: 5px 0;
    padding-left: 16px;
    font-size: 13px;
    line-height: 1.85;
}
.document-body li::before {
    content: "";
    position: absolute;
    top: .78em;
    left: 2px;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--sage) 72%, var(--ink-3));
}
.document-body .document-lead { color: var(--ink); font-weight: 570; }
.document-end { margin-top: 46px; color: var(--ink-3); display: flex; align-items: center; gap: 12px; }
.document-end span { height: 1px; flex: 1; background: var(--line); }
.document-end p { margin: 0; font-size: 10px; white-space: nowrap; }

@media (max-width: 900px) {
    .knowledge-workspace { grid-template-columns: minmax(250px, 290px) minmax(0, 1fr); }
    .knowledge-document { width: min(720px, calc(100% - 38px)); }
}

@media (max-height: 760px) and (min-width: 761px) {
    .knowledge-view { padding-bottom: 16px; }
}

@media (max-width: 760px) {
    .knowledge-view { padding: 58px 8px 8px; }
    .knowledge-overview { padding: 7px 6px 10px; align-items: flex-start; flex-wrap: wrap; gap: 8px; }
    .knowledge-overview h1 { font-size: 24px; }
    .knowledge-overview p { max-width: 290px; font-size: 12px; }
    .knowledge-header-side { width: 100%; justify-content: space-between; }
    .knowledge-summary { order: 2; padding-left: 14px; }
    .knowledge-summary strong { font-size: 20px; }
    .knowledge-admin-actions { min-width: 0; }
    .knowledge-admin-button { height: 36px; padding: 0 10px; }
    .knowledge-sync-bar { margin-top: 7px; }
    .knowledge-workspace { border-radius: 18px; display: block; }
    .knowledge-library { height: 100%; border-right: 0; }
    .knowledge-reader { display: none; height: 100%; }
    .knowledge-workspace.has-document .knowledge-library { display: none; }
    .knowledge-workspace.has-document .knowledge-reader { display: block; }
    .knowledge-document { width: calc(100% - 30px); padding-top: 21px; }
    .knowledge-back { display: inline-flex; }
    .document-head h2 { font-size: 28px; }
    .document-toc { display: none; }
    .document-body h2 { margin-top: 31px; }
    .knowledge-search kbd { display: none; }
}
