:root {
    --background: #f4f6f3;
    --surface: #ffffff;
    --surface-soft: #f8faf7;
    --border: #dfe5dc;
    --border-strong: #cbd5c8;
    --text: #1d291f;
    --muted: #6d786f;
    --primary: #287a4b;
    --primary-dark: #1f633d;
    --primary-soft: #e9f5ed;
    --danger: #b84444;
    --danger-soft: #fff0f0;
    --shadow: 0 16px 36px rgba(36, 57, 42, 0.08);
    font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
    color: var(--text);
    background: var(--background);
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    min-width: 320px;
    height: 100%;
    margin: 0;
}

body.drawer-open,
body.login-open,
body.mobile-nav-open {
    overflow: hidden;
}

button,
input,
textarea,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.48;
}

.app-shell {
    display: grid;
    grid-template-columns: clamp(220px, 18vw, 280px) minmax(0, 1fr);
    width: 100%;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

.sidebar,
.chat-panel {
    min-width: 0;
    min-height: 0;
    height: 100%;
}

.sidebar {
    background: var(--surface-soft);
}

.sidebar {
    display: flex;
    flex-direction: column;
    padding: clamp(16px, 1.6vw, 22px) clamp(12px, 1.2vw, 16px) 16px;
    overflow: hidden;
    border-right: 1px solid var(--border);
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    margin-bottom: 22px;
}

.brand-copy {
    flex: 1;
    min-width: 0;
}

.brand-copy strong {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.mobile-sidebar-button,
.mobile-sidebar-close,
.mobile-sidebar-backdrop {
    display: none;
}

.brand-mark {
    display: grid;
    width: 40px;
    height: 40px;
    place-items: center;
    border-radius: 13px;
    color: #fff;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.08em;
    background: linear-gradient(145deg, #348d5a, #1f633d);
    box-shadow: 0 7px 18px rgba(40, 122, 75, 0.22);
}

.brand strong,
.brand span {
    display: block;
}

.brand strong {
    font-size: 15px;
}

.brand span {
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
}

.primary-button,
.secondary-button,
.danger-ghost-button,
.tool-button,
.token-input-row button {
    min-height: 38px;
    padding: 0 15px;
    border: 1px solid transparent;
    border-radius: 10px;
    font-weight: 650;
    transition: 0.16s ease;
}

.primary-button,
.token-input-row button {
    color: #fff;
    background: var(--primary);
}

.primary-button:hover:not(:disabled),
.token-input-row button:hover {
    background: var(--primary-dark);
}

#sessionFilesButton {
    display: none !important;
}

.secondary-button,
.tool-button {
    color: var(--text);
    border-color: var(--border-strong);
    background: var(--surface);
}

.secondary-button:hover:not(:disabled),
.tool-button:hover:not(:disabled) {
    border-color: #9fb2a3;
    background: #f5f9f5;
}

.danger-ghost-button {
    color: var(--danger);
    border-color: #efcccc;
    background: var(--danger-soft);
}

.wide-button {
    width: 100%;
}

#primaryNavigation,
.primary-navigation {
    display: none !important;
}

.primary-navigation-item {
    display: flex;
    width: auto;
    min-height: 40px;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 6px 10px;
    border: 1px solid transparent;
    border-radius: 10px;
    color: var(--text);
    text-align: center;
    text-decoration: none;
    background: transparent;
    transition: 0.16s ease;
}

.primary-navigation-item:hover,
.primary-navigation-item:focus-visible {
    outline: none;
    border-color: #c6dfcc;
    background: var(--primary-soft);
}

.primary-navigation-item strong {
    font-size: 12px;
    line-height: 1;
    white-space: nowrap;
}

.primary-navigation-icon {
    display: grid;
    width: 28px;
    height: 28px;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 8px;
    color: var(--primary);
    background: #dff0e4;
}

.primary-navigation-icon svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 36px;
    margin-top: 16px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.icon-button,
.text-button {
    padding: 4px 6px;
    border: 0;
    color: var(--muted);
    background: transparent;
}

.icon-button {
    font-size: 18px;
}

.session-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    scrollbar-gutter: stable;
}

.session-row {
    position: relative;
    width: 100%;
    margin-bottom: 5px;
    border: 1px solid transparent;
    border-radius: 11px;
}

.session-item {
    width: 100%;
    min-height: 58px;
    padding: 11px 42px 11px 12px;
    border: 0;
    border-radius: 10px;
    color: var(--text);
    text-align: left;
    background: transparent;
}

.session-row:hover {
    background: #edf2ec;
}

.session-row.active {
    border-color: #c6dfcc;
    background: var(--primary-soft);
}

.session-row.generating .session-item strong::after {
    content: "";
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-left: 7px;
    border-radius: 50%;
    vertical-align: 1px;
    background: var(--primary);
    animation: session-generating-pulse 1.2s ease-in-out infinite;
}

@keyframes session-generating-pulse {
    50% {
        opacity: 0.32;
        transform: scale(0.82);
    }
}

.session-item strong,
.session-item span {
    display: block;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.session-item strong {
    font-size: 13px;
}

.session-item span {
    margin-top: 5px;
    color: var(--muted);
    font-size: 11px;
}

.session-more-button {
    position: absolute;
    top: 50%;
    right: 7px;
    display: grid;
    width: 30px;
    height: 30px;
    padding: 0;
    place-items: center;
    border: 0;
    border-radius: 8px;
    color: var(--muted);
    font-size: 12px;
    letter-spacing: -1px;
    background: transparent;
    opacity: 0.48;
    touch-action: manipulation;
    transform: translateY(-50%);
    transition: 0.15s ease;
}

.session-row:hover .session-more-button,
.session-row.active .session-more-button,
.session-more-button:focus-visible {
    color: var(--text);
    background: rgba(255, 255, 255, 0.72);
    opacity: 1;
}

.session-context-menu {
    position: fixed;
    /*
     * 手机端侧栏的层级为 60。菜单必须位于侧栏之上，否则点击“三个点”
     * 后菜单虽然已经打开，视觉上仍会像没有响应。
     */
    z-index: 70;
    display: grid;
    min-width: 132px;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: 0 12px 30px rgba(36, 57, 42, 0.18);
}

.session-context-menu button {
    min-height: 34px;
    padding: 0 10px;
    border: 0;
    border-radius: 7px;
    color: var(--text);
    text-align: left;
    background: transparent;
}

.session-context-menu button:hover,
.session-context-menu button:focus-visible {
    outline: none;
    background: #edf2ec;
}

.session-context-menu button.danger {
    color: var(--danger);
}

.session-context-menu button.danger:hover,
.session-context-menu button.danger:focus-visible {
    background: var(--danger-soft);
}

.account-area {
    position: relative;
    flex: none;
}

.header-actions {
    display: flex;
    flex: none;
    align-items: center;
    gap: 9px;
}

.reminder-inbox-area {
    position: relative;
    flex: none;
}

.header-icon-action {
    position: relative;
    display: grid;
    width: 44px;
    height: 44px;
    padding: 0;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 13px;
    color: var(--primary-dark);
    text-decoration: none;
    background: var(--surface);
    transition: 0.16s ease;
}

.header-icon-action:hover,
.header-icon-action:focus-visible,
.reminder-inbox-button[aria-expanded="true"] {
    outline: none;
    border-color: #b8c9bb;
    background: var(--primary-soft);
}

.header-icon-action:active {
    transform: translateY(1px);
}

.header-icon-action svg {
    width: 21px;
    height: 21px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.reminder-inbox-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    display: grid;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    place-items: center;
    border: 2px solid var(--surface);
    border-radius: 999px;
    color: #fff;
    font-size: 9px;
    font-weight: 800;
    background: var(--danger);
}

.reminder-inbox-popover {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 40;
    display: grid;
    width: min(380px, calc(100vw - 28px));
    max-height: min(620px, calc(100dvh - 96px));
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: 0 20px 50px rgba(31, 69, 43, 0.17);
}

.reminder-inbox-popover > header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 15px 16px 13px;
    border-bottom: 1px solid var(--border);
}

.reminder-inbox-popover > header strong,
.reminder-inbox-popover > header span {
    display: block;
}

.reminder-inbox-popover > header strong {
    font-size: 14px;
}

.reminder-inbox-popover > header span {
    margin-top: 3px;
    color: var(--muted);
    font-size: 10px;
}

.reminder-inbox-popover > header button {
    min-height: 30px;
    padding: 0 8px;
    border: 0;
    border-radius: 8px;
    color: var(--primary-dark);
    font-size: 10px;
    font-weight: 700;
    background: var(--primary-soft);
}

.reminder-inbox-list {
    min-height: 100px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.reminder-inbox-item {
    position: relative;
    display: grid;
    gap: 6px;
    padding: 13px 16px;
    border-bottom: 1px solid #edf1ed;
    background: var(--surface);
}

.reminder-inbox-item.unread {
    padding-left: 25px;
    background: #f4faf6;
}

.reminder-inbox-item.unread::before {
    position: absolute;
    top: 19px;
    left: 13px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--primary);
    content: "";
}

.reminder-inbox-item-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.reminder-inbox-item-heading strong {
    min-width: 0;
    font-size: 12px;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.reminder-inbox-item-heading time {
    flex: none;
    color: var(--muted);
    font-size: 9px;
    white-space: nowrap;
}

.reminder-inbox-item p {
    margin: 0;
    color: #556158;
    font-size: 11px;
    line-height: 1.55;
    overflow-wrap: anywhere;
}

.reminder-inbox-item-actions {
    display: flex;
    justify-content: flex-end;
    gap: 7px;
}

.reminder-inbox-item-actions button {
    min-height: 29px;
    padding: 0 9px;
    border: 1px solid #c9ddcf;
    border-radius: 8px;
    color: var(--primary-dark);
    font-size: 10px;
    font-weight: 700;
    background: #fff;
}

.reminder-inbox-item-actions button.primary {
    border-color: var(--primary);
    color: #fff;
    background: var(--primary);
}

.reminder-inbox-manage-link {
    display: block;
    padding: 11px 16px;
    color: var(--primary-dark);
    text-align: center;
    text-decoration: none;
    font-size: 11px;
    font-weight: 750;
    background: var(--surface-soft);
}

.token-editor {
    padding: 13px;
    border: 1px solid var(--border);
    border-radius: 13px;
    background: var(--surface);
    box-shadow: 0 8px 24px rgba(36, 57, 42, 0.08);
}

.account-menu {
    display: grid;
    gap: 5px;
    margin: -5px -5px 10px;
}

.account-menu button,
.account-menu a {
    display: flex;
    min-height: 52px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 10px;
    border: 0;
    border-radius: 9px;
    color: var(--text);
    text-align: left;
    text-decoration: none;
    background: transparent;
}

.account-menu button:hover,
.account-menu button:focus-visible,
.account-menu a:hover,
.account-menu a:focus-visible {
    outline: none;
    background: var(--primary-soft);
}

.account-menu button > span:first-child,
.account-menu a > span:first-child {
    min-width: 0;
}

.account-menu strong {
    display: block;
    font-size: 12px;
}

.account-menu small,
.token-editor .account-menu small {
    display: block;
    margin: 3px 0 0;
    color: var(--muted);
    font-size: 10px;
    line-height: 1.4;
}

.account-menu button > span:last-child,
.account-menu a > span:last-child {
    color: var(--muted);
    font-size: 22px;
}

.account-menu-divider {
    height: 1px;
    margin: 0 -2px 11px;
    background: var(--border);
}

.account-logout-button {
    width: 100%;
    min-height: 38px;
    padding: 0 10px;
    border: 0;
    border-radius: 9px;
    color: var(--danger);
    text-align: left;
    font-weight: 650;
    background: transparent;
}

.account-logout-button:hover,
.account-logout-button:focus-visible {
    outline: none;
    background: var(--danger-soft);
}

.token-editor label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
}

.account-button {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr) 18px;
    align-items: center;
    gap: 10px;
    width: clamp(176px, 16vw, 210px);
    min-height: 56px;
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: 13px;
    color: var(--text);
    text-align: left;
    background: var(--surface);
    transition: 0.16s ease;
}

.account-popover {
    position: absolute;
    top: calc(100% + 9px);
    right: 0;
    z-index: 30;
    width: min(340px, calc(100vw - 28px));
}

.account-button:hover,
.account-button[aria-expanded="true"] {
    border-color: #b8c9bb;
    background: #f5f9f5;
}

.account-avatar {
    display: grid;
    width: 36px;
    height: 36px;
    place-items: center;
    border-radius: 11px;
    color: var(--muted);
    background: #edf1ed;
}

.account-avatar svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

.account-button.configured .account-avatar {
    color: #fff;
    background: var(--primary);
}

.account-copy {
    min-width: 0;
}

.account-copy strong,
.account-status {
    display: flex;
    align-items: center;
}

.account-copy strong {
    margin-bottom: 4px;
    font-size: 12px;
}

.account-status {
    gap: 7px;
    color: var(--muted);
    font-size: 10px;
}

.account-chevron {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: var(--muted);
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2;
    transition: transform 0.16s ease;
}

.account-button[aria-expanded="true"] .account-chevron {
    transform: rotate(180deg);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #a8aea9;
}

.status-dot.connected {
    background: #38a463;
    box-shadow: 0 0 0 4px #e4f5e9;
}

.token-input-row {
    display: flex;
    gap: 6px;
}

.token-input-row input {
    min-width: 0;
    flex: 1;
}

.token-input-row button {
    min-height: 34px;
    padding: 0 10px;
}

.token-editor small {
    display: block;
    margin-top: 7px;
    color: #899189;
    font-size: 10px;
    line-height: 1.45;
}

html.dsh-handoff,
html.dsh-handoff body {
    background: #f4f7f3;
}

html.dsh-handoff .app-shell {
    visibility: hidden !important;
    pointer-events: none;
}

html.dsh-handoff body::before {
    content: "正在进入助手…";
    position: fixed;
    inset: 0;
    z-index: 90;
    display: grid;
    place-items: center;
    background:
            radial-gradient(circle at 20% 15%, rgba(53, 143, 91, 0.14), transparent 34%),
            rgba(244, 247, 243, 0.98);
    color: #1d291f;
    font-size: 16px;
    font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

.login-modal {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: grid;
    padding: 20px;
    place-items: center;
    overflow: auto;
    background:
            radial-gradient(circle at 20% 15%, rgba(53, 143, 91, 0.14), transparent 34%),
            rgba(244, 247, 243, 0.96);
    backdrop-filter: blur(7px);
}

.login-dialog {
    width: min(420px, 100%);
    padding: clamp(24px, 5vw, 36px);
    border: 1px solid var(--border);
    border-radius: 22px;
    background: var(--surface);
    box-shadow: 0 24px 70px rgba(31, 69, 43, 0.15);
}

.login-brand {
    display: grid;
    width: 52px;
    height: 52px;
    margin-bottom: 22px;
    place-items: center;
    border-radius: 16px;
    color: #fff;
    font-weight: 800;
    letter-spacing: 0.08em;
    background: linear-gradient(145deg, #348d5a, #1f633d);
    box-shadow: 0 10px 24px rgba(40, 122, 75, 0.24);
}

.login-dialog h2 {
    margin: 8px 0 10px;
    font-size: clamp(22px, 4vw, 28px);
}

.login-dialog > p,
.login-dialog > small {
    color: var(--muted);
    line-height: 1.7;
}

.login-form {
    display: grid;
    gap: 16px;
    margin: 25px 0 14px;
}

.login-form label {
    display: grid;
    gap: 7px;
    color: var(--text);
    font-size: 13px;
    font-weight: 650;
}

.login-form input {
    min-height: 46px;
    padding: 0 13px;
}

.login-form input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(40, 122, 75, 0.1);
}

.login-form .login-remember {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    font-weight: 550;
    cursor: pointer;
    user-select: none;
}

.login-form input[type="checkbox"] {
    width: 16px;
    height: 16px;
    min-height: 0;
    margin: 0;
    accent-color: var(--primary);
    cursor: pointer;
}

.login-form .primary-button {
    min-height: 46px;
    margin-top: 2px;
}

.login-error {
    margin: -3px 0 0;
    padding: 9px 11px;
    border-radius: 9px;
    color: var(--danger);
    font-size: 12px;
    line-height: 1.5;
    background: var(--danger-soft);
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid var(--border-strong);
    border-radius: 9px;
    color: var(--text);
    outline: none;
    background: var(--surface);
}

input,
select {
    min-height: 36px;
    padding: 0 10px;
}

textarea {
    padding: 13px 14px;
    line-height: 1.55;
    resize: none;
}

input:focus,
textarea:focus,
select:focus {
    border-color: #74a986;
    box-shadow: 0 0 0 3px rgba(40, 122, 75, 0.1);
}

.chat-panel {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    overflow: hidden;
    background: var(--surface);
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 72px;
    gap: 16px;
    padding: 14px clamp(16px, 2.4vw, 32px);
    border-bottom: 1px solid var(--border);
}

.conversation-heading {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.conversation-heading h1 {
    width: 100%;
    max-width: 720px;
    margin: 0;
    overflow: hidden;
    font-size: 18px;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.composer-actions,
.composer-tools {
    display: flex;
    align-items: center;
    gap: 8px;
}

.composer-tools {
    min-width: 0;
    flex: 1 1 520px;
    flex-wrap: wrap;
}

.composer-actions {
    flex: 0 0 auto;
}

.message-list {
    width: 100%;
    min-height: 0;
    padding: clamp(18px, 3vw, 32px)
        max(clamp(16px, 2.4vw, 40px), calc((100% - 1480px) / 2));
    overflow-x: hidden;
    overflow-y: scroll;
    scrollbar-gutter: stable;
    scroll-behavior: smooth;
}

.welcome-card {
    max-width: 520px;
    min-height: 180px;
    display: grid;
    place-content: center;
    justify-items: center;
    margin: 9vh auto 0;
    padding: 30px;
    border: 1px solid var(--border);
    border-radius: 20px;
    text-align: center;
    background: linear-gradient(145deg, #fff, #f6faf6);
    box-shadow: var(--shadow);
}

.eyebrow {
    color: var(--primary);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.13em;
}

.welcome-card h2 {
    margin: 10px 0 0;
    font-size: 27px;
}

.message-row {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    display: flex;
    margin-bottom: 22px;
}

.message-row > * {
    min-width: 0;
    max-width: 100%;
}

.message-row.user {
    justify-content: flex-end;
}

.message-content {
    width: min(94%, 1320px);
    min-width: 0;
    max-width: 100%;
}

.message-row.user .message-content {
    display: flex;
    align-items: flex-end;
    flex-direction: column;
}

.message-bubble {
    width: fit-content;
    max-width: 100%;
    padding: 13px 16px;
    border-radius: 16px;
    line-height: 1.72;
    white-space: pre-wrap;
    word-break: break-word;
}

.message-row.user .message-bubble {
    color: #fff;
    border-bottom-right-radius: 5px;
    background: var(--primary);
}

.message-row.assistant .message-bubble {
    border: 1px solid var(--border);
    border-bottom-left-radius: 5px;
    background: var(--surface-soft);
}

.message-footer {
    display: flex;
    min-height: 24px;
    align-items: center;
    gap: 8px;
    margin-top: 5px;
}

.message-row.user .message-footer {
    justify-content: flex-end;
}

.message-footer .message-meta {
    margin-top: 0;
}

.message-copy-button {
    min-height: 0;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 6px;
    border: 0;
    border-radius: 6px;
    color: var(--muted);
    font-size: 10px;
    background: transparent;
    opacity: 0;
    transition: color 0.16s ease, background 0.16s ease, opacity 0.16s ease;
}

.message-copy-button svg {
    width: 13px;
    height: 13px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

.message-row:hover .message-copy-button,
.message-copy-button:focus-visible,
.message-copy-button.copied {
    opacity: 1;
}

.message-copy-button:hover,
.message-copy-button.copied {
    color: var(--primary);
    background: var(--primary-soft);
}

.message-edit-button:hover {
    color: var(--primary-dark);
    background: var(--primary-soft);
}

.message-remember-button:hover {
    color: var(--primary-dark);
}

.message-copy-button:disabled {
    cursor: default;
}

.clipboard-fallback {
    position: fixed;
    top: -1000px;
    left: -1000px;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.message-task {
    min-width: 0;
    max-width: min(82%, 760px);
}

.message-task-bubble {
    max-width: 100%;
}

.message-task.thinking {
    width: max-content;
    min-width: min(180px, 100%);
}

.message-bubble.typing,
.message-task-bubble.thinking {
    display: flex;
    min-width: 0;
    align-items: center;
    white-space: nowrap;
}

.message-task-bubble.thinking {
    width: 100%;
}

.message-thinking-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-task-bubble.failed,
.message-task-bubble.cancelled {
    border-color: #efcccc;
    color: var(--danger);
    background: var(--danger-soft);
}

.message-task-actions {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 7px 0 0 4px;
}

.message-task-actions button {
    min-height: 0;
    padding: 4px 8px;
    border: 0;
    border-radius: 7px;
    font-size: 11px;
    background: transparent;
}

.message-task-confirm {
    color: var(--primary);
    font-weight: 700;
}

.message-task-stop {
    color: var(--muted);
}

.message-task-confirm:hover {
    background: var(--primary-soft);
}

.message-task-stop:hover {
    color: var(--danger);
    background: var(--danger-soft);
}

.message-thinking-dots {
    display: inline-flex;
    flex: none;
    align-items: center;
    gap: 3px;
    margin-left: 6px;
}

.message-thinking-dots i {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--primary);
    animation: message-thinking 1.2s infinite ease-in-out;
}

.message-thinking-dots i:nth-child(2) {
    animation-delay: 0.15s;
}

.message-thinking-dots i:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes message-thinking {
    0%,
    60%,
    100% {
        opacity: 0.28;
        transform: translateY(0);
    }

    30% {
        opacity: 1;
        transform: translateY(-2px);
    }
}

.message-file-result {
    width: min(100%, 430px);
    max-width: 100%;
    margin-top: 14px;
}

.message-attachments {
    width: min(100%, 430px);
    max-width: 100%;
    margin-left: auto;
}

.message-attachments .message-file-result {
    margin-top: 8px;
}

.message-attachments .message-file-card {
    margin-top: 0;
}

.message-image-preview-button {
    width: 100%;
    display: block;
    overflow: hidden;
    padding: 0;
    border: 1px solid #c9ddcf;
    border-radius: 14px;
    background: #edf6f0;
}

.message-image-preview-button:hover {
    border-color: var(--primary);
    box-shadow: 0 9px 22px rgba(42, 132, 83, 0.14);
}

.message-image-preview {
    width: 100%;
    max-height: 520px;
    display: block;
    object-fit: contain;
}

.image-preview-open {
    overflow: hidden;
}

.image-preview-modal {
    position: fixed;
    inset: 0;
    z-index: 55;
    display: grid;
    padding: clamp(12px, 3vw, 32px);
    place-items: center;
    background: rgba(8, 14, 10, 0.84);
    backdrop-filter: blur(4px);
}

.image-preview-dialog {
    width: min(1180px, 96vw);
    max-height: 94vh;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 16px;
    background: #172119;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
}

.image-preview-header {
    display: flex;
    min-width: 0;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 14px 12px 18px;
    color: #fff;
    background: rgba(255, 255, 255, 0.06);
}

.image-preview-header h2 {
    min-width: 0;
    margin: 0;
    overflow: hidden;
    font-size: 14px;
    font-weight: 650;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.image-preview-actions {
    display: flex;
    flex: none;
    align-items: center;
    gap: 8px;
}

.image-preview-actions button {
    min-height: 34px;
    padding: 7px 11px;
    border: 1px solid rgba(255, 255, 255, 0.24);
    border-radius: 9px;
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.image-preview-actions button:hover {
    border-color: rgba(255, 255, 255, 0.48);
    background: rgba(255, 255, 255, 0.14);
}

.image-preview-actions .image-preview-close {
    width: 34px;
    padding: 0;
    font-size: 22px;
    line-height: 1;
}

.image-preview-stage {
    position: relative;
    min-height: min(68vh, 680px);
    display: grid;
    overflow: auto;
    padding: 16px;
    place-items: center;
    color: rgba(255, 255, 255, 0.7);
}

.image-preview-stage img {
    max-width: 100%;
    max-height: calc(94vh - 90px);
    display: none;
    object-fit: contain;
}

.image-preview-stage img.loaded {
    display: block;
}

.message-file-card {
    width: 100%;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
    padding: 12px;
    border: 1px solid #c9ddcf;
    border-radius: 12px;
    color: var(--text);
    text-align: left;
    background: #fff;
}

.message-file-card:hover {
    border-color: var(--primary);
    box-shadow: 0 7px 18px rgba(42, 132, 83, 0.12);
}

.message-file-icon {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    background: var(--primary);
}

.message-file-info {
    min-width: 0;
    display: grid;
    gap: 2px;
}

.message-file-info strong,
.message-file-info span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-file-info span {
    color: var(--muted);
    font-size: 12px;
}

.message-file-download {
    color: var(--primary);
    font-size: 13px;
    font-weight: 700;
}

.markdown-body {
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
    white-space: normal;
}

.markdown-body > :first-child {
    margin-top: 0;
}

.markdown-body > :last-child {
    margin-bottom: 0;
}

.markdown-body p,
.markdown-body ul,
.markdown-body ol,
.markdown-body blockquote,
.markdown-body pre,
.markdown-body .markdown-table-wrap {
    margin: 10px 0;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
    margin: 18px 0 8px;
    line-height: 1.35;
}

.markdown-body h1 {
    font-size: 20px;
}

.markdown-body h2 {
    font-size: 18px;
}

.markdown-body h3 {
    font-size: 17px;
}

.markdown-body h4 {
    font-size: 15px;
    font-weight: 650;
}

.markdown-body ul,
.markdown-body ol {
    padding-left: 24px;
}

.markdown-body li + li {
    margin-top: 4px;
}

.markdown-body blockquote {
    padding: 7px 12px;
    color: #536058;
    border-left: 3px solid #79a989;
    background: rgba(40, 122, 75, 0.06);
}

.markdown-body code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.markdown-body :not(pre) > code {
    padding: 2px 5px;
    border: 1px solid #d9e1da;
    border-radius: 5px;
    color: #b13b3b;
    background: #f4f6f3;
}

.markdown-body pre {
    position: relative;
    max-width: 100%;
    padding: 16px;
    overflow: auto;
    border: 1px solid #27382e;
    border-radius: 10px;
    color: #e8f2eb;
    line-height: 1.6;
    white-space: pre;
    background: #17241c;
}

.markdown-body pre[data-language] {
    padding-top: 30px;
}

.markdown-body pre[data-language]::before {
    content: attr(data-language);
    position: absolute;
    top: 7px;
    right: 10px;
    color: #91aa99;
    font-size: 10px;
    text-transform: uppercase;
}

.markdown-body a {
    color: #176d42;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.markdown-body hr {
    height: 1px;
    margin: 16px 0;
    border: 0;
    background: var(--border);
}

.markdown-table-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
}

.markdown-body table {
    width: 100%;
    min-width: 420px;
    border-collapse: collapse;
    font-size: 12px;
}

.markdown-body th,
.markdown-body td {
    padding: 8px 10px;
    border: 1px solid #d4ddd5;
    text-align: left;
    vertical-align: top;
}

.markdown-body th {
    background: #eaf2ec;
}

/* Reuse the巡店 record table shell for compact talent-inventory comparisons. */
.markdown-body table.talent-inventory-table {
    min-width: 820px;
    table-layout: fixed;
}

.markdown-body table.talent-inventory-table th,
.markdown-body table.talent-inventory-table td {
    min-width: 96px;
    max-width: 320px;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.markdown-body table.talent-inventory-table th:first-child,
.markdown-body table.talent-inventory-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    width: 112px;
    min-width: 112px;
    background: #f6faf7;
    box-shadow: 2px 0 0 rgba(46, 76, 57, 0.12);
}

.markdown-body table.talent-inventory-table th:first-child {
    z-index: 3;
    background: #eaf2ec;
}

.markdown-body table.talent-inventory-table th:nth-child(2),
.markdown-body table.talent-inventory-table td:nth-child(2) {
    width: 120px;
}

.markdown-body table.talent-inventory-table th:nth-child(3),
.markdown-body table.talent-inventory-table td:nth-child(3) {
    width: 130px;
}

.markdown-body table.talent-inventory-table th:nth-child(4),
.markdown-body table.talent-inventory-table td:nth-child(4) {
    width: 280px;
}

.markdown-body table.talent-inventory-table th:nth-child(5),
.markdown-body table.talent-inventory-table td:nth-child(5) {
    width: 180px;
}

.message-meta {
    margin-top: 6px;
    color: var(--muted);
    font-size: 10px;
}

.composer {
    position: relative;
    padding: 12px clamp(16px, 2.4vw, 32px) clamp(14px, 2vw, 22px);
    border-top: 1px solid var(--border);
    background: var(--surface);
}

.composer > * {
    width: min(100%, 1480px);
    margin-right: auto;
    margin-left: auto;
}

.message-input-shell {
    overflow: hidden;
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    background: var(--surface);
    transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.message-input-shell:focus-within {
    border-color: #74a986;
    box-shadow: 0 0 0 3px rgba(40, 122, 75, 0.1);
}

.composer textarea {
    min-height: 76px;
    max-height: 180px;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.composer textarea:focus {
    border: 0;
    box-shadow: none;
}

.composer-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 9px;
}

.composer-tools span {
    color: var(--muted);
    font-size: 11px;
}

.request-tags-bar,
.selected-files-bar {
    display: flex;
    align-items: center;
    gap: 6px;
}

.request-tags-bar {
    max-width: 100%;
    padding: 10px 12px 0;
    overflow-x: auto;
}

.selected-files-bar {
    flex: 0 1 auto;
}

.file-chip {
    display: inline-flex;
    min-width: 0;
    max-width: min(360px, calc(100vw - 64px));
    flex: 0 1 auto;
    align-items: center;
    gap: 7px;
    min-height: 38px;
    padding: 5px 6px;
    border-radius: 8px;
    color: var(--primary-dark);
    font-size: 11px;
    background: var(--primary-soft);
}

.file-chip-preview,
.file-chip-type {
    width: 28px;
    height: 28px;
    flex: none;
    border-radius: 6px;
}

.file-chip-preview {
    object-fit: cover;
    background: #dfe9e1;
}

.file-chip-type {
    display: grid;
    place-items: center;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    background: var(--primary);
}

.file-chip-name {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.message-edit-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--primary-dark);
    font-size: 11px;
    background: var(--primary-soft);
}

.message-edit-bar button {
    min-height: 26px;
    padding: 0 8px;
    border: 0;
    border-radius: 6px;
    color: var(--primary-dark);
    background: rgba(255, 255, 255, 0.72);
}

.file-chip-remove {
    display: grid;
    width: 20px;
    height: 20px;
    flex: none;
    padding: 0;
    place-items: center;
    border: 0;
    border-radius: 6px;
    color: #5f7565;
    background: rgba(255, 255, 255, 0.72);
}

.file-chip-remove:hover {
    color: #fff;
    background: var(--danger);
}

.drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(21, 31, 24, 0.24);
    backdrop-filter: blur(1px);
}

.session-files-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 41;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    width: min(clamp(340px, 36vw, 460px), 94vw);
    padding: clamp(16px, 2vw, 22px);
    border-left: 1px solid var(--border);
    background: var(--surface);
    box-shadow: -18px 0 48px rgba(31, 55, 38, 0.16);
}

.drawer-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.drawer-header h2 {
    margin: 0;
    font-size: 17px;
}

.drawer-header p {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.55;
}

.drawer-actions {
    display: flex;
    gap: 5px;
}

.drawer-file-list {
    max-height: none;
    padding-top: 16px;
    overflow-y: auto;
}

.settings-drawer {
    width: min(clamp(360px, 40vw, 520px), 96vw);
}

.compact-button {
    min-height: 32px;
    padding: 0 10px;
    font-size: 11px;
}

.drawer-form,
.memory-drawer-content {
    min-height: 0;
    overflow-y: auto;
}

.drawer-form {
    display: grid;
    align-content: start;
    gap: 20px;
    padding: 20px 2px 2px;
}

.preference-fieldset {
    min-width: 0;
    padding: 0;
    margin: 0;
    border: 0;
}

.preference-fieldset legend,
.form-field > span {
    display: block;
    margin-bottom: 8px;
    color: var(--text);
    font-size: 12px;
    font-weight: 700;
}

.segmented-options {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
}

.segmented-options label {
    min-width: 0;
}

.segmented-options input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.segmented-options span {
    display: grid;
    min-height: 38px;
    padding: 6px;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 9px;
    color: var(--muted);
    font-size: 11px;
    text-align: center;
    background: var(--surface-soft);
    cursor: pointer;
}

.segmented-options input:checked + span {
    border-color: #8db99a;
    color: var(--primary-dark);
    font-weight: 700;
    background: var(--primary-soft);
}

.segmented-options input:focus-visible + span {
    outline: 2px solid rgba(40, 122, 75, 0.28);
    outline-offset: 2px;
}

.form-field {
    display: block;
}

.form-field small {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 10px;
}

.preference-switches {
    display: grid;
    gap: 2px;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.preference-switches label {
    display: flex;
    min-height: 64px;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 10px 2px;
}

.preference-switches label + label {
    border-top: 1px solid var(--border);
}

.preference-switches strong,
.preference-switches small {
    display: block;
}

.preference-switches strong {
    font-size: 12px;
}

.preference-switches small {
    margin-top: 4px;
    color: var(--muted);
    font-size: 10px;
}

.preference-switches input[role="switch"] {
    width: 38px;
    min-height: 22px;
    height: 22px;
    flex: none;
    padding: 0;
    appearance: none;
    border: 0;
    border-radius: 999px;
    background: #c8d0c9;
    transition: 0.18s ease;
}

.preference-switches input[role="switch"]::before {
    display: block;
    width: 18px;
    height: 18px;
    margin: 2px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 4px rgba(20, 37, 25, 0.18);
    transition: transform 0.18s ease;
    content: "";
}

.preference-switches input[role="switch"]:checked {
    background: var(--primary);
}

.preference-switches input[role="switch"]:checked::before {
    transform: translateX(16px);
}

.drawer-form-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding-top: 4px;
}

.memory-drawer-content {
    padding-top: 16px;
}

.memory-form {
    display: grid;
    gap: 15px;
    padding: 15px;
    margin-bottom: 16px;
    border: 1px solid #bcd4c2;
    border-radius: 12px;
    background: #f5faf6;
}

.memory-form-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.memory-form-heading strong {
    font-size: 13px;
}

.memory-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.form-hint {
    margin: -5px 0 0;
    color: var(--muted);
    font-size: 10px;
    line-height: 1.5;
}

.memory-form textarea {
    resize: vertical;
}

.memory-list {
    display: grid;
    gap: 10px;
}

.memory-card {
    display: grid;
    gap: 11px;
    padding: 13px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--surface-soft);
}

.memory-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.memory-tags,
.memory-card-actions {
    display: flex;
    align-items: center;
    gap: 5px;
}

.memory-tags {
    min-width: 0;
    flex-wrap: wrap;
}

.memory-tag {
    padding: 4px 7px;
    border-radius: 999px;
    font-size: 9px;
    white-space: nowrap;
}

.memory-tag.type {
    color: var(--primary-dark);
    background: var(--primary-soft);
}

.memory-tag.scope {
    color: #5e6a61;
    background: #edf0ed;
}

.memory-card-actions button {
    min-height: 26px;
    padding: 0 5px;
    border: 0;
    color: var(--muted);
    font-size: 10px;
    background: transparent;
}

.memory-card-actions button:hover {
    color: var(--primary);
}

.memory-card-actions button.danger:hover {
    color: var(--danger);
}

.memory-content {
    margin: 0;
    color: var(--text);
    font-size: 12px;
    line-height: 1.65;
    overflow-wrap: anywhere;
}

.memory-meta {
    color: var(--muted);
    font-size: 9px;
}

.memory-empty {
    padding: 34px 18px;
    border: 1px dashed var(--border-strong);
    border-radius: 12px;
    text-align: center;
}

.memory-empty strong {
    font-size: 13px;
}

.memory-empty p {
    margin: 8px auto 14px;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.55;
}

.knowledge-drawer-content {
    min-height: 0;
    padding-top: 16px;
    overflow-y: auto;
}

.knowledge-upload-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 14px;
    padding: 14px;
    margin-bottom: 16px;
    border: 1px solid #bcd4c2;
    border-radius: 12px;
    background: #f5faf6;
}

.knowledge-upload-panel strong {
    font-size: 13px;
}

.knowledge-upload-panel p {
    margin: 5px 0 0;
    color: var(--muted);
    font-size: 10px;
    line-height: 1.55;
}

.knowledge-upload-panel .primary-button {
    min-height: 36px;
    padding: 0 12px;
    white-space: nowrap;
}

.knowledge-list {
    display: grid;
    gap: 10px;
}

.knowledge-card {
    display: grid;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-soft);
}

.knowledge-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.knowledge-card-heading {
    display: grid;
    min-width: 0;
    gap: 4px;
}

.knowledge-card-heading strong {
    font-size: 12px;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.knowledge-card-heading span {
    color: var(--muted);
    font-size: 9px;
}

.knowledge-status {
    flex: none;
    padding: 4px 7px;
    border-radius: 999px;
    color: #5e6a61;
    font-size: 9px;
    font-weight: 700;
    background: #edf0ed;
}

.knowledge-status.ready {
    color: var(--primary-dark);
    background: var(--primary-soft);
}

.knowledge-status.failed {
    color: var(--danger);
    background: #fff0ef;
}

.knowledge-status.processing {
    color: #8a6518;
    background: #fff6da;
}

.knowledge-details summary {
    color: var(--primary-dark);
    font-size: 10px;
    cursor: pointer;
}

.knowledge-details p,
.knowledge-error,
.knowledge-processing {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 10px;
    line-height: 1.6;
}

.knowledge-error {
    color: var(--danger);
}

.knowledge-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding-top: 2px;
}

.knowledge-card-actions button {
    min-height: 26px;
    padding: 0;
    border: 0;
    color: var(--muted);
    font-size: 10px;
    background: transparent;
}

.knowledge-card-actions button:hover {
    color: var(--primary);
}

.knowledge-card-actions button.primary-text {
    color: var(--primary-dark);
    font-weight: 700;
}

.knowledge-card-actions button.danger {
    color: var(--danger);
}

.knowledge-empty {
    padding: 34px 18px;
    border: 1px dashed var(--border-strong);
    border-radius: 12px;
    text-align: center;
}

.knowledge-empty strong {
    font-size: 13px;
}

.knowledge-empty p {
    margin: 8px auto 14px;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.6;
}

.memory-danger-zone {
    display: flex;
    justify-content: center;
    padding: 18px 0 4px;
    margin-top: 18px;
    border-top: 1px solid var(--border);
}

.danger-text-button {
    color: var(--danger);
}

.danger-text-button:hover:not(:disabled) {
    background: var(--danger-soft);
}

.file-check {
    width: 15px;
    min-height: auto;
    height: 15px;
}

.file-list {
    display: grid;
    max-height: 280px;
    gap: 8px;
    overflow-y: auto;
}

.file-card {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 9px;
    padding: 9px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-soft);
}

.file-card.selected {
    border-color: #9bc3a6;
    background: var(--primary-soft);
}

.file-info {
    min-width: 0;
}

.file-info strong,
.file-info span {
    display: block;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.file-info strong {
    font-size: 12px;
}

.file-info span {
    margin-top: 4px;
    color: var(--muted);
    font-size: 10px;
}

.file-actions {
    display: flex;
    gap: 3px;
}

.file-actions button {
    min-width: 25px;
    height: 25px;
    padding: 0;
    border: 0;
    border-radius: 7px;
    color: var(--muted);
    background: transparent;
}

.file-actions button:hover {
    color: var(--text);
    background: #e5ebe4;
}

.file-actions .file-delete-button {
    width: auto;
    padding: 0 6px;
    color: var(--danger);
    font-size: 10px;
}

.file-actions .file-delete-button:hover {
    color: #fff;
    background: var(--danger);
}

.session-list,
.message-list,
.request-tags-bar,
.file-list {
    scrollbar-width: thin;
    scrollbar-color: #aab8ad #edf1ed;
}

.session-list::-webkit-scrollbar,
.message-list::-webkit-scrollbar,
.request-tags-bar::-webkit-scrollbar,
.file-list::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.session-list::-webkit-scrollbar-track,
.message-list::-webkit-scrollbar-track,
.request-tags-bar::-webkit-scrollbar-track,
.file-list::-webkit-scrollbar-track {
    border-radius: 999px;
    background: #edf1ed;
}

.session-list::-webkit-scrollbar-thumb,
.message-list::-webkit-scrollbar-thumb,
.request-tags-bar::-webkit-scrollbar-thumb,
.file-list::-webkit-scrollbar-thumb {
    border: 2px solid #edf1ed;
    border-radius: 999px;
    background: #aab8ad;
}

.session-list::-webkit-scrollbar-thumb:hover,
.message-list::-webkit-scrollbar-thumb:hover,
.request-tags-bar::-webkit-scrollbar-thumb:hover,
.file-list::-webkit-scrollbar-thumb:hover {
    background: #819485;
}

.muted-placeholder {
    margin: 12px 2px;
    color: #929a93;
    font-size: 11px;
    line-height: 1.55;
}

.toast {
    position: fixed;
    top: max(18px, env(safe-area-inset-top));
    left: 50%;
    z-index: 60;
    max-width: min(680px, calc(100vw - 32px));
    padding: 12px 16px;
    border-radius: 11px;
    color: #fff;
    font-size: 13px;
    line-height: 1.5;
    text-align: center;
    overflow-wrap: anywhere;
    background: #26352a;
    box-shadow: var(--shadow);
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -10px);
    transition: 0.2s ease;
}

.toast.visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

.toast.error {
    background: #9f3d3d;
}

.hidden {
    display: none !important;
}

.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;
}

@media (max-width: 1120px) {
    .app-shell {
        grid-template-columns: clamp(210px, 24vw, 230px) minmax(0, 1fr);
    }

    .composer-footer {
        align-items: stretch;
        flex-direction: column;
    }

    .composer-actions {
        justify-content: flex-end;
    }

    .primary-navigation-item {
        padding-inline: 7px;
    }

    .primary-navigation-item strong {
        font-size: 11px;
    }
}

@media (max-width: 860px) {
    html,
    body {
        height: 100%;
        min-height: 0;
        overflow: hidden;
    }

    .app-shell {
        position: fixed;
        top: var(--mobile-viewport-offset-top, 0);
        left: var(--mobile-viewport-offset-left, 0);
        display: block;
        width: var(--mobile-viewport-width, 100vw);
        min-height: 0;
        height: var(--mobile-viewport-height, 100dvh);
        overflow: hidden;
    }

    .login-modal {
        top: var(--mobile-viewport-offset-top, 0);
        right: auto;
        bottom: auto;
        left: var(--mobile-viewport-offset-left, 0);
        width: var(--mobile-viewport-width, 100vw);
        height: var(--mobile-viewport-height, 100dvh);
        padding:
            max(14px, env(safe-area-inset-top))
            14px
            max(14px, env(safe-area-inset-bottom));
        align-items: start;
        justify-items: center;
        overscroll-behavior: contain;
        scroll-padding-block: 14px;
    }

    .login-dialog {
        margin-block: auto;
    }

    .sidebar {
        position: fixed;
        z-index: 70;
        top: var(--mobile-viewport-offset-top, 0);
        bottom: auto;
        left: -110%;
        display: flex;
        flex-direction: column;
        width: min(72vw, 300px);
        max-height: none;
        height: var(--mobile-viewport-height, 100dvh);
        padding-top: max(16px, env(safe-area-inset-top));
        padding-bottom: max(16px, env(safe-area-inset-bottom));
        border-right: 1px solid var(--border);
        border-bottom: 0;
        background: #f8faf7;
        box-shadow: 18px 0 44px rgba(28, 44, 32, 0.18);
        transform: none;
        transition: left 0.2s ease;
        overflow: hidden;
        overscroll-behavior: contain;
        pointer-events: none;
        isolation: isolate;
        -webkit-font-smoothing: antialiased;
    }

    body.mobile-nav-open .sidebar {
        left: 0;
        transform: none;
        pointer-events: auto;
    }

    .sidebar .wide-button,
    .sidebar .section-heading {
        flex-shrink: 0;
    }

    .mobile-sidebar-close {
        display: grid;
        width: 38px;
        height: 38px;
        flex: 0 0 auto;
        margin-left: auto;
        padding: 0;
        place-items: center;
        border: 0;
        border-radius: 10px;
        color: var(--muted);
        font-size: 26px;
        line-height: 1;
        background: transparent;
    }

    .mobile-sidebar-button {
        display: grid;
        width: 42px;
        height: 42px;
        flex: 0 0 auto;
        padding: 0;
        place-items: center;
        border: 1px solid var(--border);
        border-radius: 11px;
        color: var(--text);
        background: var(--surface);
    }

    .mobile-sidebar-button svg {
        width: 22px;
        height: 22px;
        fill: none;
        stroke: currentColor;
        stroke-width: 1.8;
        stroke-linecap: round;
    }

    .mobile-sidebar-backdrop {
        position: fixed;
        z-index: 65;
        top: var(--mobile-viewport-offset-top, 0);
        left: calc(
            var(--mobile-viewport-offset-left, 0px)
            + min(72vw, 300px)
        );
        width: calc(
            var(--mobile-viewport-width, 100vw)
            - min(72vw, 300px)
        );
        height: var(--mobile-viewport-height, 100dvh);
        display: block;
        background: rgba(17, 28, 20, 0.4);
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    .session-list {
        flex: 1 1 auto;
        min-height: 0;
        max-height: none;
        -webkit-overflow-scrolling: touch;
    }

    .session-item {
        padding-right: 56px;
    }

    .session-more-button {
        right: 4px;
        width: 44px;
        height: 44px;
        color: var(--text);
        font-size: 14px;
        background: rgba(255, 255, 255, 0.72);
        opacity: 1;
    }

    .session-context-menu button {
        min-height: 44px;
    }

    .chat-panel {
        width: 100%;
        height: 100%;
        min-height: 0;
    }

    .message-list {
        min-height: 0;
        max-width: 100%;
    }

    .composer {
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }

    .composer-footer {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        flex-direction: initial;
    }

    .composer-tools {
        min-width: 0;
        flex: 0 1 auto;
    }

    .composer-actions {
        align-items: center;
        flex-direction: row;
    }

    .message-copy-button {
        opacity: 1;
    }
}

@media (hover: none), (pointer: coarse) {
    .message-copy-button {
        opacity: 1;
    }
}

@media (max-width: 560px) {
    .settings-drawer,
    .session-files-drawer {
        width: 100vw;
        padding: max(16px, env(safe-area-inset-top)) 14px
            max(16px, env(safe-area-inset-bottom));
        border-left: 0;
    }

    .memory-form-grid {
        grid-template-columns: 1fr;
    }

    .knowledge-upload-panel {
        grid-template-columns: 1fr;
    }

    .knowledge-upload-panel .primary-button {
        width: 100%;
    }

    .segmented-options {
        gap: 5px;
    }

    .drawer-header {
        gap: 10px;
    }

    .drawer-actions {
        align-items: center;
    }

    .chat-header,
    .composer {
        padding-right: 14px;
        padding-left: 14px;
    }

    .login-dialog {
        width: 100%;
        padding: 22px 18px;
        border-radius: 16px;
    }

    .login-brand {
        width: 44px;
        height: 44px;
        margin-bottom: 14px;
        border-radius: 13px;
    }

    .login-dialog h2 {
        margin: 6px 0 8px;
        font-size: 23px;
    }

    .login-dialog > p {
        margin: 0;
        line-height: 1.55;
    }

    .login-form {
        gap: 12px;
        margin: 18px 0 10px;
    }

    .login-form input,
    .login-form .primary-button {
        min-height: 48px;
        font-size: 16px;
    }

    /*
     * 手机软键盘打开后优先保留登录操作本身。品牌图形和说明文字在键盘
     * 收起后仍会正常显示，不占用宝贵的可视高度。
     */
    body.mobile-keyboard-open .login-modal {
        align-items: start;
        padding-top: 8px;
        padding-bottom: 8px;
    }

    body.mobile-keyboard-open .login-dialog {
        margin-block: 0;
        padding-top: 14px;
        padding-bottom: 14px;
    }

    body.mobile-keyboard-open .login-brand,
    body.mobile-keyboard-open .login-dialog > .eyebrow,
    body.mobile-keyboard-open .login-dialog > p,
    body.mobile-keyboard-open .login-dialog > small {
        display: none;
    }

    body.mobile-keyboard-open .login-dialog h2 {
        margin-top: 0;
        font-size: 19px;
    }

    body.mobile-keyboard-open .login-form {
        gap: 10px;
        margin: 10px 0 0;
    }

    .chat-header {
        align-items: center;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 10px;
        min-height: 58px;
        padding-top: max(8px, env(safe-area-inset-top));
        padding-bottom: 8px;
    }

    .conversation-heading {
        flex: 1;
        max-width: 100%;
    }

    .primary-navigation {
        display: none;
    }

    .account-button {
        grid-template-columns: 34px 16px;
        width: auto;
        min-height: 44px;
        padding: 5px 8px;
    }

    .account-copy {
        display: none;
    }

    .account-popover {
        position: fixed;
        top: calc(58px + env(safe-area-inset-top));
        right: 14px;
        max-width: calc(100vw - 28px);
    }

    .header-actions {
        margin-left: auto;
        gap: 6px;
    }

    .header-icon-action {
        width: 42px;
        height: 42px;
    }

    .reminder-inbox-popover {
        position: fixed;
        top: calc(58px + env(safe-area-inset-top));
        right: 14px;
        left: 14px;
        width: auto;
        max-height: calc(100dvh - 78px - env(safe-area-inset-top));
    }

    .composer {
        padding-top: 9px;
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }

    .composer textarea {
        min-height: 52px;
        max-height: min(32dvh, 160px);
        padding: 11px 12px;
        font-size: 16px;
    }

    .composer-footer {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        gap: 8px;
        margin-top: 8px;
    }

    .composer-tools {
        min-width: 0;
        flex: 0 0 auto;
        flex-wrap: nowrap;
        gap: 6px;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .composer-tools::-webkit-scrollbar {
        display: none;
    }

    .composer-tools > span {
        display: none;
    }

    .composer-tools .tool-button,
    .composer-actions .primary-button,
    .composer-actions .danger-ghost-button {
        min-height: 44px;
        padding: 0 12px;
        white-space: nowrap;
    }

    .message-list {
        padding: 14px;
        overscroll-behavior: contain;
    }

    .message-content {
        width: 94%;
    }

    .message-bubble {
        max-width: 100%;
    }

    .message-task {
        max-width: 94%;
    }

    .image-preview-modal {
        padding: 0;
    }

    .image-preview-dialog {
        width: 100vw;
        max-height: 100dvh;
        height: 100dvh;
        border: 0;
        border-radius: 0;
    }

    .image-preview-stage {
        min-height: 0;
        padding: 10px;
    }

    .image-preview-stage img {
        max-height: calc(100dvh - 70px);
    }

    .composer-actions {
        align-items: center;
        flex-direction: row;
        gap: 6px;
    }

    .welcome-card {
        margin-top: 4vh;
        padding: 22px 18px;
        border-radius: 16px;
    }

    .welcome-card h2 {
        font-size: 23px;
    }
}

@media (max-width: 370px) {
    .composer-footer {
        grid-template-columns: 1fr;
    }

    .composer-actions .primary-button {
        flex: 1;
    }
}
