/* ============================================================
   Tsunami Tech — 样式表
   印尼出海法律AI助手
   设计理念：专业、信任、清晰、现代
   ============================================================ */

/* --- CSS 变量 / 设计令牌 --- */
.fact-editor { margin-top: 16px; width: 100%; }
.fact-editor label { display: block; margin-bottom: 12px; font-weight: 600; }
.fact-editor textarea { display: block; box-sizing: border-box; width: 100%; min-height: 80px; margin-top: 6px; padding: 10px; font: inherit; font-weight: 400; border: 1px solid #9baeb3; border-radius: 4px; resize: vertical; }
.fact-editor [role="alert"] { color: #a22626; overflow-wrap: anywhere; }
.fact-editor button { margin-right: 8px; }

:root {
    /* 主色调 — 深青色系，传达专业与信任 */
    --color-primary: #0D7377;
    --color-primary-light: #14A3A4;
    --color-primary-lighter: #1BC5BD;
    --color-primary-bg: #E6F7F8;
    --color-primary-bg-hover: #D0F0F2;

    /* 中性色 */
    --color-bg: #F5F6F8;
    --color-surface: #FFFFFF;
    --color-border: #E2E5EA;
    --color-border-light: #EDF0F3;
    --color-text: #1A1D23;
    --color-text-secondary: #5F666F;
    --color-text-muted: #939AA5;
    --color-text-placeholder: #B0B8C1;

    /* 语义色 */
    --color-success: #10B981;
    --color-warning: #F59E0B;
    --color-error: #EF4444;
    --color-info: #3B82F6;

    /* 用户气泡色 */
    --color-user-bubble: #0D7377;
    --color-user-bubble-text: #FFFFFF;
    --color-ai-bubble: #FFFFFF;
    --color-ai-bubble-border: #E8ECF0;
    --color-ai-bubble-text: #1A1D23;

    /* 间距 */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 12px;
    --space-lg: 16px;
    --space-xl: 20px;
    --space-2xl: 24px;
    --space-3xl: 32px;
    --space-4xl: 48px;

    /* 圆角 */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* 阴影 */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.08), 0 2px 8px rgba(0,0,0,0.04);
    --shadow-xl: 0 16px 48px rgba(0,0,0,0.12);

    /* 过渡 */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 350ms ease;

    /* 字体 */
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                   "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue",
                   Helvetica, Arial, sans-serif;
    --font-size-xs: 11px;
    --font-size-sm: 12px;
    --font-size-base: 14px;
    --font-size-md: 15px;
    --font-size-lg: 16px;
    --font-size-xl: 18px;
    --font-size-2xl: 22px;
    --font-size-3xl: 26px;

    --line-height: 1.6;

    /* 布局 */
    --sidebar-width: 300px;
    --header-height: 56px;
    --disclaimer-height: 40px;
    --input-min-height: 52px;
    --input-max-height: 120px;
}

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    line-height: var(--line-height);
    color: var(--color-text);
    background: var(--color-bg);
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
}

a {
    color: var(--color-primary-light);
    text-decoration: none;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    font-size: inherit;
    color: inherit;
    touch-action: manipulation;
}

input, textarea {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    border: none;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

ul, ol {
    list-style: none;
}

img {
    max-width: 100%;
    display: block;
}

/* --- 滚动条美化 --- */
::-webkit-scrollbar {
    width: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-muted);
}

/* ============================================================
   布局
   ============================================================ */

.app-container {
    display: flex;
    height: 100vh;
    height: 100dvh;
    max-width: 1200px;
    margin: 0 auto;
    background: var(--color-surface);
    box-shadow: var(--shadow-xl);
    position: relative;
    overflow: hidden;
}

/* --- 侧边栏 --- */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #FAFBFC;
    border-right: 1px solid var(--color-border-light);
    transition: transform var(--transition-base);
    z-index: 100;
}

.sidebar-header {
    padding: var(--space-lg) var(--space-xl);
    border-bottom: 1px solid var(--color-border-light);
    flex-shrink: 0;
}

.sidebar-header h2 {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: var(--space-md);
}

.btn-new-chat {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    width: 100%;
    padding: var(--space-md) var(--space-lg);
    background: var(--color-primary);
    color: #fff;
    border-radius: var(--radius-md);
    font-size: var(--font-size-base);
    font-weight: 500;
    transition: background var(--transition-fast), transform var(--transition-fast);
    white-space: nowrap;
}

.btn-new-chat:hover {
    background: var(--color-primary-light);
}

.btn-new-chat:active {
    transform: scale(0.98);
}

.btn-new-chat .icon {
    font-size: 18px;
    line-height: 1;
}

.conversation-list {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-sm);
}

.conversation-list:empty::after {
    content: '暂无对话记录';
    display: block;
    text-align: center;
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    padding: var(--space-3xl) var(--space-lg);
}

.conversation-item {
    display: flex;
    flex-direction: column;
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast);
    margin-bottom: 2px;
    position: relative;
}

.conversation-item:hover {
    background: var(--color-primary-bg);
}

.conversation-item.active {
    background: var(--color-primary-bg);
    border-left: 3px solid var(--color-primary);
    padding-left: calc(var(--space-lg) - 3px);
}

.conversation-item .conv-title {
    font-size: var(--font-size-base);
    font-weight: 500;
    color: var(--color-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 2px;
}

.conversation-item .conv-preview {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conversation-item .conv-time {
    font-size: 11px;
    color: var(--color-text-muted);
    margin-top: 2px;
}

.sidebar-footer {
    padding: var(--space-md) var(--space-xl);
    border-top: 1px solid var(--color-border-light);
    flex-shrink: 0;
}

.sidebar-footer .disclaimer-mini {
    font-size: 10px;
    color: var(--color-text-muted);
    line-height: 1.4;
}

/* --- 移动端侧边栏遮罩 --- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 99;
}

/* --- 主聊天区域 --- */
.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100%;
    position: relative;
}

/* --- 顶部栏 --- */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    padding: 0 var(--space-xl);
    border-bottom: 1px solid var(--color-border-light);
    flex-shrink: 0;
    background: var(--color-surface);
}

.top-bar .brand {
    display: flex;
    align-items: baseline;
    gap: var(--space-md);
}

.brand-name {
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--color-primary);
    letter-spacing: 0;
}

.brand-english {
    color: var(--color-text);
    font-size: var(--font-size-sm);
    font-weight: 600;
    letter-spacing: 0;
}

.brand-subtitle {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    font-weight: 400;
}

.top-bar .header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

/* Compact workspace header controls. */
.top-bar .header-actions { gap: 6px; }
.header-menu-wrap { position: relative; display: flex; align-items: center; }
.header-actions .header-icon-button {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; min-height: 36px; padding: 0;
    border: 0; border-radius: 10px; background: transparent;
    color: var(--color-text-secondary); cursor: pointer; flex: 0 0 36px;
}
.header-actions .header-icon-button:hover,
.header-actions .header-icon-button[aria-expanded="true"] { background: var(--color-bg-secondary, #f3f4f2); color: var(--color-text); }
.header-actions .header-icon-button:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.header-icon-button .ui-icon { width: 20px; height: 20px; }
.header-actions [hidden], .header-popover[hidden] { display: none !important; }
.header-popover {
    position: absolute; top: calc(100% + 6px); right: 0; z-index: 100;
    width: 290px; max-width: calc(100vw - 32px); padding: 6px;
    background: var(--color-bg, #fff); color: var(--color-text);
    border: 1px solid var(--color-border); border-radius: 14px;
    box-shadow: 0 8px 28px rgba(30, 40, 38, .12); text-align: left;
}
.header-popover-heading { padding: 8px 10px; font-size: 12px; color: var(--color-text-muted); font-weight: 600; }
.timezone-list { max-height: 240px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.timezone-option, .header-popover-item {
    display: flex; align-items: center; gap: 10px; width: 100%; min-height: 36px;
    padding: 8px 10px; border: 0; border-radius: 8px; background: transparent;
    color: inherit; font: inherit; font-size: 13px; line-height: 1.4; text-align: left; cursor: pointer;
}
.timezone-option:hover, .header-popover-item:hover,
.timezone-option:focus-visible, .header-popover-item:focus-visible { background: var(--color-bg-secondary, #f3f4f2); outline: none; box-shadow: inset 0 0 0 1px var(--color-border); }
.timezone-option[aria-selected="true"] { color: var(--color-primary); background: var(--color-primary-bg, #edf5f4); font-weight: 600; }
.language-popover { width: max-content; min-width: 136px; }
.language-popover .header-popover-item { white-space: nowrap; }
.language-popover .header-popover-item[aria-checked="true"] { color: var(--color-primary); background: var(--color-primary-bg, #edf5f4); font-weight: 600; }
.language-popover::before { content: ''; position: absolute; left: 0; right: 0; top: -7px; height: 7px; }
#langMenuWrap:hover > .header-icon-button,
#langMenuWrap:focus-within > .header-icon-button { background: var(--color-bg-secondary, #f3f4f2); color: var(--color-text); }
.timezone-option-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.timezone-option-offset { flex: 0 0 auto; font-size: 11px; font-weight: 500; font-variant-numeric: tabular-nums; color: var(--color-text-muted); }
.account-popover { width: 172px; }
@media (max-width: 480px) { .timezone-popover { right: -84px; width: 280px; } }

@media (max-width: 480px) {
    .top-bar .brand { flex: 1; min-width: 0; }
    .top-bar .workspace-breadcrumb { min-width: 0; }
    .top-bar .workspace-breadcrumb > span { display: none; }
    .top-bar .workspace-breadcrumb b {
        display: block;
        min-width: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* --- Language Switcher --- */
.btn-lang {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: var(--color-primary-bg);
    color: var(--color-primary);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    transition: all var(--transition-fast);
    border: 1px solid transparent;
}

.btn-lang:hover {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

.btn-lang:active {
    transform: scale(0.95);
}

.btn-menu {
    display: none;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    color: var(--color-text-secondary);
    font-size: 20px;
    transition: background var(--transition-fast);
}

.btn-menu:hover {
    background: var(--color-primary-bg);
}

/* --- 阶段进度指示器 --- */
.stage-progress {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: var(--space-md) var(--space-xl);
    background: var(--color-primary-bg);
    border-bottom: 1px solid var(--color-border-light);
    flex-shrink: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.stage-progress::-webkit-scrollbar {
    height: 0;
}

.stage-step {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-md);
    border-radius: var(--radius-full);
    white-space: nowrap;
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    transition: all var(--transition-base);
    position: relative;
}

.stage-step .step-icon {
    font-size: 14px;
    line-height: 1;
}

.stage-step .step-label {
    font-weight: 500;
}

.stage-step.completed {
    color: var(--color-primary);
}

.stage-step.active {
    background: var(--color-primary);
    color: #fff;
}

.stage-connector {
    width: 20px;
    height: 1px;
    background: var(--color-border);
    flex-shrink: 0;
}

.stage-connector.done {
    background: var(--color-primary);
}

/* --- 聊天消息区 --- */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--space-xl);
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.chat-messages:empty::after {
    content: '';
    display: block;
}

/* 欢迎界面 */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    padding: var(--space-3xl) var(--space-xl);
    text-align: center;
}

.welcome-logo {
    width: 72px;
    height: 72px;
    border-radius: var(--radius-xl);
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-lighter));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    color: #fff;
    margin-bottom: var(--space-xl);
    box-shadow: 0 8px 32px rgba(13, 115, 119, 0.25);
}

.welcome-screen h1 {
    font-size: var(--font-size-3xl);
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: var(--space-sm);
}

.welcome-screen .welcome-subtitle {
    font-size: var(--font-size-md);
    color: var(--color-text-secondary);
    margin-bottom: var(--space-3xl);
    max-width: 420px;
}

/* 话题选择 */
.topic-selector {
    width: 100%;
    max-width: 520px;
}

.topic-selector h3 {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-bottom: var(--space-md);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.topic-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-md);
}

.topic-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-lg) var(--space-sm);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    transition: all var(--transition-fast);
    cursor: pointer;
}

.topic-btn:hover {
    border-color: var(--color-primary-light);
    background: var(--color-primary-bg);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.topic-btn:active {
    transform: scale(0.97);
}

.topic-btn .topic-icon {
    font-size: 28px;
    line-height: 1;
}

.topic-btn .topic-label {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--color-text);
}

/* --- 消息气泡 --- */
.message-row {
    display: flex;
    margin-bottom: var(--space-xl);
    animation: messageSlideIn 0.35s ease;
}

.message-row.user {
    justify-content: flex-end;
}

.message-row.ai {
    justify-content: flex-start;
}

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

.message-bubble-wrapper {
    max-width: 75%;
    display: flex;
    flex-direction: column;
}

.message-row.user .message-bubble-wrapper {
    align-items: flex-end;
}

.message-row.ai .message-bubble-wrapper {
    align-items: flex-start;
}

/* AI消息的徽章 */
.message-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
    margin-bottom: var(--space-xs);
    padding: 2px 0;
    font-weight: 500;
}

.message-badge .badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-primary-lighter);
}

.message-bubble {
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-lg);
    font-size: var(--font-size-base);
    line-height: var(--line-height);
    word-break: break-word;
    position: relative;
}

.message-row.user .message-bubble {
    background: var(--color-user-bubble);
    color: var(--color-user-bubble-text);
    border-bottom-right-radius: var(--radius-sm);
}

.message-row.ai .message-bubble {
    background: var(--color-ai-bubble);
    color: var(--color-ai-bubble-text);
    border: 1px solid var(--color-ai-bubble-border);
    border-bottom-left-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
}

/* 消息中的段落和列表 */
.message-bubble p {
    margin-bottom: var(--space-sm);
}

.message-bubble p:last-child {
    margin-bottom: 0;
}

.message-bubble ul,
.message-bubble ol {
    margin: var(--space-sm) 0;
    padding-left: var(--space-xl);
}

.message-bubble ul {
    list-style: disc;
}

.message-bubble ol {
    list-style: decimal;
}

.message-bubble li {
    margin-bottom: var(--space-xs);
}

.message-bubble strong {
    font-weight: 600;
    color: inherit;
}

.message-bubble h1,
.message-bubble h2,
.message-bubble h3,
.message-bubble h4 {
    letter-spacing: 0;
    color: var(--color-text);
    line-height: 1.4;
}

.message-bubble h2 {
    margin: var(--space-2xl) 0 var(--space-md);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--color-border);
    font-size: var(--font-size-xl);
    font-weight: 700;
}

.message-bubble h2:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
}

.message-bubble h3 {
    margin: var(--space-lg) 0 var(--space-sm);
    font-size: var(--font-size-md);
    font-weight: 700;
    color: var(--color-primary);
}

.message-bubble h4 {
    margin: 0 0 var(--space-sm);
    font-size: var(--font-size-base);
    font-weight: 700;
}

.message-bubble hr {
    height: 1px;
    margin: var(--space-xl) 0;
    border: 0;
    background: var(--color-border);
}

.message-bubble code {
    background: rgba(0,0,0,0.06);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.9em;
    font-family: "SF Mono", "Fira Code", "Consolas", monospace;
}

.message-bubble pre {
    background: #1e1e1e;
    color: #e0e0e0;
    padding: var(--space-md);
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin: var(--space-sm) 0;
    font-size: var(--font-size-sm);
}

.message-bubble pre code {
    background: none;
    padding: 0;
}

/* 客户版法律依据：隐藏内部记录号和审核代码后，以摘要块展示。 */
.legal-basis-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-md);
    margin: var(--space-md) 0 var(--space-lg);
}

.legal-basis-card {
    min-width: 0;
    padding: var(--space-md) var(--space-lg);
    border: 1px solid var(--color-border);
    border-left: 3px solid var(--color-primary-light);
    border-radius: 8px;
    background: #FAFCFC;
}

.legal-basis-card h4 {
    margin: 0 0 var(--space-md);
    color: var(--color-text);
}

.legal-basis-detail {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: var(--space-sm);
    padding-top: var(--space-sm);
    border-top: 1px solid var(--color-border-light);
    font-size: var(--font-size-sm);
}

.legal-basis-detail span {
    color: var(--color-text-muted);
    font-weight: 600;
}

.legal-basis-detail p {
    min-width: 0;
    margin: 0;
    color: var(--color-text-secondary);
}

/* 旧回答中的办理路径表格改为紧凑的标签/内容列表。 */
.procedure-facts {
    position: relative;
    margin: var(--space-md) 0 var(--space-xl);
    padding-left: var(--space-xl);
    border-left: 2px solid #C9E5E6;
}

.procedure-fact {
    position: relative;
    display: block;
    padding: var(--space-md) 0;
    border-bottom: 1px solid var(--color-border);
}

.procedure-fact::before {
    content: "";
    position: absolute;
    top: 19px;
    left: -26px;
    width: 8px;
    height: 8px;
    border: 2px solid var(--color-surface);
    border-radius: 50%;
    background: var(--color-primary-light);
    box-shadow: 0 0 0 1px #C9E5E6;
}

.procedure-fact dt,
.procedure-fact dd {
    padding: 0;
}

.procedure-fact dt {
    color: var(--color-primary);
    font-weight: 700;
}

.procedure-fact dd {
    min-width: 0;
    margin-top: var(--space-xs);
    color: var(--color-text-secondary);
}

/* 表格仅用于适合横向比较的内容，例如主要风险。 */
.message-bubble table {
    width: 100%;
    border-collapse: collapse;
    margin: var(--space-md) 0;
    font-size: var(--font-size-sm);
    overflow-x: auto;
    display: block;
}

.message-bubble table thead,
.message-bubble table tbody,
.message-bubble table tfoot {
    display: table;
    width: 100%;
    table-layout: fixed;
}

.message-bubble table th,
.message-bubble table td {
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--color-border-light);
    text-align: left;
    vertical-align: top;
    word-break: break-word;
}

.message-bubble table th {
    background: var(--color-primary-bg);
    color: var(--color-primary);
    font-weight: 600;
    font-size: var(--font-size-xs);
    white-space: nowrap;
}

.message-bubble table td {
    color: var(--color-text);
    line-height: var(--line-height);
}

.message-bubble table tr:nth-child(even) td {
    background: #FAFBFC;
}

.message-bubble table tr:hover td {
    background: var(--color-primary-bg-hover);
}

/* 风险等级彩色标记 */
.message-bubble table td:first-child {
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
    width: 80px;
}

@media (max-width: 720px) {
    .legal-basis-list {
        grid-template-columns: 1fr;
    }

    .legal-basis-detail {
        grid-template-columns: 1fr;
    }

    .legal-basis-detail span {
        margin-bottom: -4px;
    }

    .procedure-facts {
        padding-left: var(--space-lg);
    }

    .procedure-fact::before {
        left: -22px;
    }
}

/* 消息中的阶段标记 */
.stage-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px var(--space-sm);
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: 500;
    background: var(--color-primary-bg);
    color: var(--color-primary);
    margin-top: var(--space-sm);
}

.message-row.user .stage-badge {
    background: rgba(255,255,255,0.2);
    color: rgba(255,255,255,0.9);
}

/* 时间戳 */
.message-time {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    margin-top: var(--space-xs);
    padding: 0 var(--space-xs);
}

/* Persisted HTML report download, independent of conversation actions. */
.report-export {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-xs) var(--space-sm);
    margin-top: var(--space-sm);
}
.report-export-button {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 7px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    background: var(--color-bg);
    color: var(--color-primary);
    font: inherit;
    font-size: var(--font-size-sm);
    cursor: pointer;
}
.report-export-button:hover { background: var(--color-primary-bg); }
.report-export-button:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.report-export-button:disabled { opacity: .6; cursor: wait; }
.report-export-error {
    flex-basis: 100%;
    margin: 0;
    font-size: var(--font-size-xs);
    color: var(--color-danger, #b42318);
    overflow-wrap: anywhere;
}

/* --- 律师复核状态 --- */
.review-status {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    font-weight: 500;
    margin-top: var(--space-md);
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.review-pending {
    background: #FFF8E1;
    color: #B45309;
    border: 1px solid #FDE68A;
}

.review-confirmed {
    background: #ECFDF5;
    color: #065F46;
    border: 1px solid #A7F3D0;
}

/* --- Structured follow-up choices --- */
#documentsNav[hidden] { display: none; }

.documents-screen { display: flex; flex: 1; min-height: 0; overflow: hidden; }
.documents-screen iframe { display: block; width: 100%; height: 100%; flex: 1; min-height: 0; border: 0; }
.intake-panel h3, .intake-receipt h3 { margin: 0 0 12px; font-size: 16px; letter-spacing: 0; }
.intake-panel fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.intake-panel legend { padding: 0; margin-bottom: 14px; font-weight: 600; line-height: 1.6; }
.intake-option { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-bottom: 1px solid #e1e7ea; cursor: pointer; line-height: 1.6; }
.intake-option input { appearance: auto; width: 18px; height: 18px; flex: 0 0 18px; margin-top: 4px; accent-color: #0d7377; }
.intake-option span { min-width: 0; overflow-wrap: anywhere; }
.intake-option:has(input:checked) { color: #0d7377; font-weight: 600; }
.intake-details { display: block; width: 100%; margin-top: 14px; padding: 12px; font: inherit; font-size: 16px; border: 1px solid #9eaeb7; border-radius: 4px; resize: vertical; }
.intake-submit { margin-top: 12px; min-height: 44px; padding: 10px 20px; color: white; background: #0d7377; border: 0; border-radius: 4px; font: inherit; }
.intake-submit:disabled { opacity: .5; cursor: default; }
.intake-error { color: #a12b25; font-size: 14px; }
.intake-error:empty { display: none; }
.intake-receipt { margin-top: 12px; padding: 14px 18px; border-left: 3px solid #0d7377; background: #f5f8fa; }
.intake-receipt p { margin: 0; white-space: pre-line; overflow-wrap: anywhere; line-height: 1.7; }
.intake-receipt [hidden], .intake-panel [hidden] { display: none !important; }
.choice-panel {
    /* Scoped tokens keep workspace compact-radius overrides out of consultation cards. */
    --choice-panel-radius: 24px;
    --choice-control-radius: 16px;
    width: 100%;
    margin-top: var(--space-md);
    padding: var(--space-2xl);
    background: #F8FBFB;
    border: 1px solid #CDE6E7;
    border-radius: var(--choice-panel-radius);
}

.choice-question {
    margin: 0 0 var(--space-xs);
    color: var(--color-text);
    font-size: var(--font-size-base);
    font-weight: 650;
}

.choice-hint {
    margin: 0 0 var(--space-md);
    color: var(--color-text-muted);
    font-size: var(--font-size-xs);
}

.choice-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-md);
}

.choice-button {
    min-height: 48px;
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    border: 1px solid var(--color-border);
    border-radius: var(--choice-control-radius);
    background: var(--color-surface);
    color: var(--color-text);
    text-align: left;
    line-height: 1.4;
    transition: border-color var(--transition-fast), background var(--transition-fast);
}

.choice-button:hover:not(:disabled),
.choice-button.selected {
    border-color: var(--color-primary);
    background: var(--color-primary-bg);
}

.choice-button:disabled {
    cursor: default;
    opacity: 0.58;
}

.choice-button.selected:disabled {
    opacity: 1;
}

.choice-letter {
    width: 25px;
    height: 25px;
    flex: 0 0 25px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--color-primary-bg);
    color: var(--color-primary);
    font-size: var(--font-size-sm);
    font-weight: 700;
}

.choice-label {
    min-width: 0;
    overflow-wrap: anywhere;
}

.choice-other-input {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: var(--space-md);
    margin-top: var(--space-lg);
}

.choice-other-input[hidden] {
    display: none;
}

.choice-other-input textarea {
    min-height: 64px;
    resize: vertical;
    padding: var(--space-md) var(--space-lg);
    border: 1px solid var(--color-border);
    border-radius: var(--choice-control-radius);
    background: var(--color-surface);
}

.choice-other-input button {
    align-self: stretch;
    padding: 0 var(--space-lg);
    border-radius: var(--choice-control-radius);
    background: var(--color-primary);
    color: #fff;
    font-weight: 600;
}

.choice-panel > .chat-source-open {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    margin: var(--space-lg) 0 0;
    padding: 10px var(--space-lg);
    border-radius: var(--choice-control-radius);
}

.choice-panel .intake-details,
.choice-panel .intake-submit,
.choice-panel .fact-editor textarea,
.choice-panel .fact-editor button {
    border-radius: var(--choice-control-radius);
}

.choice-panel .intake-details,
.choice-panel .intake-submit {
    margin-top: var(--space-lg);
}

.choice-button:focus-visible,
.choice-other-input button:focus-visible,
.intake-submit:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 3px;
}

@media (max-width: 600px) {
    .choice-panel { padding: var(--space-lg); }

    .choice-grid,
    .choice-other-input {
        grid-template-columns: 1fr;
    }

    .choice-other-input button {
        min-height: 42px;
    }
}

/* --- 联系CTA --- */
.contact-cta {
    margin-top: var(--space-lg);
    padding: var(--space-lg);
    background: linear-gradient(135deg, #F0F9FA, #FFFFFF);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    animation: fadeIn 0.5s ease;
}

.contact-cta p {
    font-size: var(--font-size-base);
    color: var(--color-text-secondary);
    margin-bottom: var(--space-md);
    line-height: var(--line-height);
}

/* --- Yes/No Confirmation Steps --- */
.review-confirm-step {
    animation: fadeIn 0.35s ease;
}

.review-confirm-question {
    font-size: var(--font-size-base);
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: var(--space-md) !important;
}

.review-confirm-buttons {
    display: flex;
    gap: var(--space-md);
    flex-wrap: wrap;
}

.btn-review-yes,
.btn-review-no {
    flex: 1;
    min-width: 140px;
    padding: var(--space-md) var(--space-xl);
    border-radius: var(--radius-md);
    font-size: var(--font-size-base);
    font-weight: 600;
    transition: all var(--transition-fast);
    text-align: center;
    cursor: pointer;
}

.btn-review-yes {
    background: var(--color-primary);
    color: #fff;
    border: 2px solid var(--color-primary);
}

.btn-review-yes:hover {
    background: var(--color-primary-light);
    border-color: var(--color-primary-light);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(13, 115, 119, 0.25);
}

.btn-review-yes:active {
    transform: scale(0.98);
}

.btn-review-no {
    background: var(--color-surface);
    color: var(--color-text-secondary);
    border: 2px solid var(--color-border);
}

.btn-review-no:hover {
    border-color: var(--color-text-muted);
    color: var(--color-text);
    transform: translateY(-1px);
}

.btn-review-no:active {
    transform: scale(0.98);
}

.review-no-thanks {
    padding: var(--space-md);
    background: #F9FAFB;
    border-radius: var(--radius-md);
    text-align: center;
}

.review-no-thanks p {
    margin-bottom: 0 !important;
    color: var(--color-text-muted);
}

/* --- Conclusion Section --- */
.conclusion-section {
    border-top: 2px solid var(--color-primary-lighter);
    padding-top: var(--space-lg);
    margin-top: var(--space-md);
}

.conclusion-heading {
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: var(--space-sm) !important;
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--color-border-light);
}

.conclusion-summary {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    line-height: var(--line-height);
    margin-bottom: var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.summary-section {
    padding: var(--space-sm) var(--space-md);
    background: var(--color-surface);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-sm);
}

.summary-section h4 {
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--color-primary);
    margin-bottom: var(--space-xs);
    letter-spacing: 0;
}

.summary-section p {
    margin: 0;
    color: var(--color-text-secondary);
    line-height: 1.75;
}

.summary-section p + ul {
    margin-top: var(--space-sm);
}

.summary-section ul,
.summary-section ol {
    margin: 0;
    padding-left: var(--space-lg);
}

.summary-section ul {
    list-style: disc;
}

.summary-section ol {
    list-style: decimal;
}

.summary-section li {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    margin-bottom: var(--space-xs);
    line-height: 1.65;
}

.summary-section li:last-child {
    margin-bottom: 0;
}

.summary-risks li {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    column-gap: var(--space-sm);
    align-items: start;
    list-style: none;
}

.summary-risks ul {
    padding-left: 0;
}

.summary-risk-level {
    min-width: 46px;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.5;
    text-align: center;
    color: #374151;
    background: #F3F4F6;
}

.summary-risk-high {
    color: #9F1239;
    background: #FFF1F2;
}

.summary-risk-medium {
    color: #92400E;
    background: #FFFBEB;
}

.summary-risk-low {
    color: #166534;
    background: #F0FDF4;
}

.summary-risk-impact {
    grid-column: 2;
    display: block;
    margin-top: 2px;
    color: var(--color-text-muted);
}

.conclusion-desc {
    font-size: var(--font-size-base);
    color: var(--color-text-secondary);
    line-height: var(--line-height);
    margin-bottom: var(--space-md) !important;
}

.review-timeline {
    font-size: var(--font-size-base);
    color: var(--color-primary);
    background: var(--color-primary-bg);
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-lg) !important;
    font-weight: 500;
    border-left: 3px solid var(--color-primary);
}

.review-decline-msg {
    font-size: var(--font-size-base);
    color: var(--color-text-secondary);
    padding: var(--space-md);
    background: #F9FAFB;
    border-radius: var(--radius-md);
    text-align: center;
    line-height: var(--line-height);
    margin-bottom: 0 !important;
}

.contact-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.contact-form-standalone {
    margin-top: var(--space-md);
    padding: var(--space-lg);
    background: linear-gradient(135deg, #F0F9FA, #FFFFFF);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    animation: fadeIn 0.5s ease;
}

.contact-form-prompt {
    font-size: var(--font-size-base);
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: var(--space-md);
    line-height: var(--line-height);
}

.contact-input {
    padding: var(--space-md) var(--space-lg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: var(--font-size-base);
    transition: border-color var(--transition-fast);
    background: var(--color-surface);
}

.contact-input::placeholder {
    color: var(--color-text-placeholder);
}

.contact-input:focus {
    border-color: var(--color-primary-light);
    box-shadow: 0 0 0 3px rgba(20, 163, 164, 0.1);
}

.contact-checkbox {
    width: 18px;
    height: 18px;
    min-width: 18px;
    cursor: pointer;
    accent-color: var(--color-primary);
    margin: 0;
    padding: 0;
    border: 2px solid var(--color-border);
    border-radius: 3px;
    background: #fff;
    outline: none;
    -webkit-appearance: checkbox;
    appearance: auto;
    position: relative;
    top: 0;
    flex-shrink: 0;
}

.contact-checkbox:checked {
    accent-color: var(--color-primary);
    border-color: var(--color-primary);
    background: var(--color-primary);
}

.contact-checkbox:focus-visible {
    outline: 2px solid var(--color-primary-light);
    outline-offset: 2px;
}

.contact-consent {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 12px;
    color: #666;
    margin: 8px 0 12px 0;
    cursor: pointer;
    user-select: none;
    line-height: 1.5;
    padding: var(--space-md);
    background: #F9FAFB;
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-md);
    transition: background var(--transition-fast), border-color var(--transition-fast);
}

.contact-consent:hover {
    background: var(--color-primary-bg);
    border-color: var(--color-primary-lighter);
}

.contact-consent:has(.contact-checkbox:checked) {
    background: #ECFDF5;
    border-color: #A7F3D0;
}

.btn-submit-contact {
    padding: var(--space-md) var(--space-xl);
    background: var(--color-primary);
    color: #fff;
    border-radius: var(--radius-md);
    font-size: var(--font-size-base);
    font-weight: 500;
    transition: all var(--transition-fast);
    align-self: flex-start;
}

.btn-submit-contact:hover {
    background: var(--color-primary-light);
}

.btn-submit-contact:active {
    transform: scale(0.98);
}

.btn-submit-contact:disabled {
    background: var(--color-border);
    color: var(--color-text-muted);
    cursor: not-allowed;
    transform: none;
}

.contact-success {
    display: none;
    align-items: center;
    gap: var(--space-sm);
    color: var(--color-success);
    font-weight: 500;
    font-size: var(--font-size-base);
    padding: var(--space-md) 0;
}

/* --- 输入区域 --- */
.input-area {
    flex-shrink: 0;
    padding: var(--space-md) var(--space-xl);
    border-top: 1px solid var(--color-border-light);
    background: var(--color-surface);
}

.attachment-tray {
    margin-bottom: var(--space-sm);
}

.pending-attachment-list,
.message-attachment-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    width: 100%;
}

.message-attachment-list {
    margin-top: var(--space-sm);
}

.attachment-card {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--space-sm);
    width: min(100%, 360px);
    min-height: 58px;
    padding: 8px 10px;
    background: #f8fafc;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    color: var(--color-text);
}

.message-row.user .attachment-card {
    background: #f0fdfa;
    border-color: #99d7d3;
}

.attachment-card.status-partial {
    border-color: #f3c86a;
    background: #fffaf0;
}

.attachment-card.status-failed {
    border-color: #efb4b4;
    background: #fff7f7;
}

.attachment-card.status-uploading {
    opacity: 0.72;
}

.attachment-type {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 6px;
    background: #dff3f2;
    color: var(--color-primary);
    font-size: 10px;
    font-weight: 700;
}

.attachment-card-body {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 2px;
}

.attachment-name {
    overflow: hidden;
    color: var(--color-text);
    font-size: var(--font-size-sm);
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attachment-meta {
    overflow: hidden;
    color: var(--color-text-muted);
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attachment-action {
    flex-shrink: 0;
    color: var(--color-primary);
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
}

.attachment-action:hover {
    color: var(--color-primary-light);
}

.attachment-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    color: var(--color-text-muted);
    font-size: 22px;
    line-height: 1;
}

.attachment-remove:hover {
    background: #fee2e2;
    color: #b91c1c;
}

.input-row {
    display: flex;
    align-items: flex-end;
    gap: var(--space-sm);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-sm);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.input-row:focus-within {
    border-color: var(--color-primary-light);
    box-shadow: 0 0 0 3px rgba(20, 163, 164, 0.1);
}

.btn-attach {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    min-width: 38px;
    border-radius: var(--radius-md);
    color: var(--color-text-secondary);
    font-size: 19px;
    transition: color var(--transition-fast), background var(--transition-fast);
}

.btn-attach:hover {
    background: #e8f5f4;
    color: var(--color-primary);
}

.btn-attach:disabled {
    color: var(--color-text-placeholder);
    cursor: not-allowed;
}

.chat-input {
    flex: 1;
    resize: none;
    padding: var(--space-sm) var(--space-md);
    min-height: 24px;
    max-height: var(--input-max-height);
    line-height: var(--line-height);
    background: transparent;
    overflow-y: auto;
}

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

.btn-send {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    min-width: 38px;
    border-radius: var(--radius-md);
    background: var(--color-primary);
    color: #fff;
    font-size: 18px;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.btn-send:hover {
    background: var(--color-primary-light);
}

.btn-send:active {
    transform: scale(0.95);
}

.btn-send:disabled {
    background: var(--color-border);
    color: var(--color-text-muted);
    cursor: not-allowed;
    transform: none;
}

/* 输入框下方提示 */
.input-hint {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    text-align: center;
    margin-top: var(--space-sm);
}

.attachment-hint {
    margin-top: 3px;
    color: var(--color-text-muted);
    font-size: 11px;
    line-height: 1.4;
    text-align: center;
}

/* --- 免责声明栏 --- */
.disclaimer-bar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-sm) var(--space-xl);
    background: #FFF8E1;
    border-top: 1px solid #FDE68A;
    font-size: var(--font-size-xs);
    color: #92400E;
    text-align: center;
    min-height: var(--disclaimer-height);
    line-height: 1.4;
}

/* --- 加载动画 --- */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: var(--space-md) var(--space-lg);
    background: var(--color-ai-bubble);
    border: 1px solid var(--color-ai-bubble-border);
    border-radius: var(--radius-lg);
    border-bottom-left-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    width: fit-content;
}

.typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--color-text-muted);
    animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.16s; }
.typing-dot:nth-child(3) { animation-delay: 0.32s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1.0); opacity: 1; }
}

/* --- 错误提示 --- */
.error-toast {
    position: fixed;
    top: var(--space-xl);
    left: 50%;
    transform: translateX(-50%);
    padding: var(--space-md) var(--space-xl);
    background: #FEF2F2;
    color: #991B1B;
    border: 1px solid #FECACA;
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    font-weight: 500;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease;
    max-width: 90vw;
}

.success-toast { background: #fff; color: var(--color-text, #37352f); border-color: var(--color-border, #deddd8); }

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* --- 连接状态 --- */
.connection-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    padding: 2px 0;
}

.connection-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-border);
}

.connection-dot.online {
    background: var(--color-success);
}

.connection-dot.offline {
    background: var(--color-error);
}

/* ============================================================
   响应式设计 — 移动端
   ============================================================ */

@media (max-width: 768px) {
    .app-container {
        max-width: 100%;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        transform: translateX(-100%);
        width: 280px;
        min-width: 280px;
        z-index: 101;
        box-shadow: var(--shadow-xl);
    }

    .sidebar.open {
        transform: translateX(0);
    }

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

    .btn-menu {
        display: flex;
    }

    .top-bar {
        padding: 0 var(--space-lg);
    }

    .brand-subtitle {
        display: none;
    }

    .brand-english {
        display: none;
    }

    .brand-name {
        font-size: var(--font-size-lg);
    }

    .stage-progress {
        padding: var(--space-sm) var(--space-md);
        gap: 0;
    }

    .stage-step {
        padding: var(--space-xs) var(--space-sm);
        font-size: 11px;
    }

    .stage-connector {
        width: 10px;
    }

    .chat-messages {
        padding: var(--space-lg) var(--space-md);
    }

    .message-bubble-wrapper {
        max-width: 88%;
    }

    .topic-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-sm);
    }

    .input-area {
        padding: var(--space-md);
    }

    .disclaimer-bar {
        padding: var(--space-sm) var(--space-md);
        font-size: 10px;
    }

    .welcome-screen h1 {
        font-size: var(--font-size-2xl);
    }
}

@media (max-width: 380px) {
    .topic-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .topic-btn {
        padding: var(--space-md) var(--space-xs);
    }

    .topic-btn .topic-icon {
        font-size: 24px;
    }

    .chat-messages {
        padding: var(--space-md) var(--space-sm);
    }

    .message-bubble-wrapper {
        max-width: 92%;
    }
}

/* ============================================================
   微信内置浏览器兼容
   ============================================================ */

/* 微信浏览器有时会覆盖字体大小，强制规范化 */
@media screen and (max-width: 768px) {
    body {
        -webkit-text-size-adjust: 100% !important;
    }
}

/* 修复微信内输入框聚焦时页面上移问题 */
@supports (-webkit-overflow-scrolling: touch) {
    .chat-input {
        font-size: 16px !important; /* 防止iOS缩放 */
    }

    .contact-input {
        font-size: 16px !important;
    }
}

/* ============================================================
   暗色模式增强（可选，针对系统偏好）
   ============================================================ */

@media (prefers-color-scheme: dark) {
    /* 保持亮色主题以符合法律专业形象 */
    /* 如需暗色模式可在此处添加 */
}

/* ============================================================
   打印样式
   ============================================================ */

@media print {
    .sidebar,
    .input-area,
    .disclaimer-bar,
    .top-bar,
    .btn-send,
    .btn-new-chat {
        display: none !important;
    }

    .chat-messages {
        overflow: visible;
    }

    .message-bubble {
        border: 1px solid #ccc;
        box-shadow: none;
    }
}
/* Inline citations open the existing reader without leaving the consultation. */
.chat-source-open {
    border: 1px solid #c9d8da;
    background: #fff;
    color: #0d7377;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    font: inherit;
}
.chat-source-open:focus-visible { outline: 2px solid #0d7377; outline-offset: 2px; }
.fact-conflict-form { margin-top: 16px; min-width: 0; }
.fact-conflict-form fieldset { padding: 0; border: 0; min-width: 0; }
.fact-conflict-form legend { font-size: 17px; font-weight: 700; line-height: 1.5; }
.fact-conflict-count { color: #68757d; font-size: 14px; margin: 8px 0 12px; }
.fact-conflict-option {
    display: flex; align-items: flex-start; gap: 10px; padding: 12px;
    border-bottom: 1px solid #d7e1e5; cursor: pointer; line-height: 1.65;
    background: #fff; overflow-wrap: anywhere;
}
.fact-conflict-option:has(input:checked) { background: #e9f6f7; }
.fact-conflict-option input[type="radio"] {
    appearance: auto; display: block; position: static; opacity: 1;
    width: 20px; height: 20px; flex: 0 0 20px; margin: 3px 0 0; accent-color: #0d7377;
}
.fact-conflict-option small { display: block; color: #6a757c; font-size: 13px; margin-top: 4px; }
.fact-conflict-form textarea { box-sizing: border-box; width: 100%; padding: 10px; margin-top: 12px; border: 1px solid #a8bbc1; border-radius: 4px; font: inherit; font-size: 16px; }
.fact-conflict-form [hidden] { display: none; }
.choice-panel [hidden] { display: none !important; }
.fact-conflict-form [role="alert"] { color: #a42828; }
.fact-conflict-form button { margin: 8px 8px 0 0; }
/* Consultation references remain separate from the client's stated facts. */
.consult-origin { font-size: 13px; line-height: 1.55; color: #456168; overflow-wrap: anywhere; padding: 8px 0; }
.consult-origin strong { display: block; color: #895921; font-size: 12px; font-weight: 600; margin-top: 4px; }
.consult-source-tray { display: flex; align-items: flex-start; gap: 12px; border-bottom: 1px solid #dce4e7; margin-bottom: 8px; }
.consult-source-tray[hidden] { display: none; }
.consult-source-tray .consult-origin { flex: 1; min-width: 0; }
.consult-source-remove { flex: 0 0 32px; width: 32px; height: 32px; border: 0; border-radius: 4px; background: transparent; color: #53646b; font-size: 22px; cursor: pointer; }
.consult-source-remove:hover { background: #eef3f4; }
.consult-source-remove:focus-visible { outline: 2px solid #08777c; outline-offset: 2px; }

/* Question coverage is an unframed reading list, separate from the answer. */
.issue-coverage {
    align-self: stretch;
    min-width: 0;
    max-width: 100%;
    margin-top: 16px;
    color: #35464d;
    font-size: 13px;
    line-height: 1.6;
    letter-spacing: 0;
    overflow-wrap: anywhere;
}
.issue-coverage-title { margin: 0 0 8px; font-size: 14px; font-weight: 600; }
.issue-coverage-list { list-style: decimal; margin: 0; padding-left: 28px; }
.issue-coverage-list > li { margin: 0 0 12px; padding-left: 2px; }
.issue-coverage-list > li::marker { color: #64747b; font-variant-numeric: tabular-nums; }
.issue-question { margin: 0; font-weight: 500; }
.issue-status { margin: 2px 0 0; color: #64747b; font-size: 12px; }
.issue-source-links { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 4px 14px; margin-top: 4px; min-width: 0; }
.issue-source-link {
    display: inline-block;
    min-width: 0;
    max-width: 100%;
    padding: 2px 0;
    border: 0;
    background: transparent;
    color: #0b7074;
    font: inherit;
    line-height: 1.6;
    text-align: left;
    text-decoration: underline;
    text-underline-offset: 3px;
    white-space: normal;
    overflow-wrap: anywhere;
    cursor: pointer;
}
.issue-source-link:hover { color: #074e52; }
.issue-source-link:focus-visible { outline: 2px solid #08777c; outline-offset: 3px; }
.issue-coverage-note, .issue-coverage-completeness {
    max-width: 100%;
    margin: 6px 0 8px;
    color: #64747b;
    font-size: 12px;
    line-height: 1.6;
    overflow-wrap: anywhere;
}
/* Structured recaps keep complete qualifications on compact, unframed sections. */
.analysis-recap { min-width: 0; overflow-wrap: anywhere; }
.analysis-recap .recap-issue { padding: 18px 0; border-bottom: 1px solid var(--border-color, #dce2e5); }
.analysis-recap .recap-issue h4 { margin: 0 0 12px; font-size: 16px; line-height: 1.6; }
.analysis-recap .recap-point { margin: 8px 0 14px; }
.analysis-recap .recap-point p { margin: 6px 0; line-height: 1.75; }
.analysis-recap .recap-label { color: #12666a; font-size: 14px; font-weight: 600; margin: 12px 0 6px; }
.analysis-recap .recap-qualifications { border-left: 2px solid #bdced0; padding-left: 12px; margin: 10px 0; }
.analysis-recap .recap-qualifications strong { font-size: 14px; }
.analysis-recap ul { padding-left: 22px; margin: 6px 0; }
.analysis-recap .recap-pending { color: #79551b; margin: 12px 0; line-height: 1.75; }
.analysis-recap .recap-boundary { color: #606c74; font-size: 13px; line-height: 1.6; }

/* Provider-reported process, also available on saved assistant messages. */
.chat-process { margin: 0 0 16px; max-width: 100%; color: var(--text-secondary, #666); }
.chat-process summary { padding: 4px 0 10px; cursor: pointer; color: var(--text-secondary, #666); font-size: 14px; }
.chat-process summary:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
.chat-process-body { max-height: 8.25em; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; font-size: 13px; line-height: 1.65; -webkit-mask-image: linear-gradient(to bottom, transparent, #000 5px, #000 calc(100% - 5px), transparent); mask-image: linear-gradient(to bottom, transparent, #000 5px, #000 calc(100% - 5px), transparent); }
.chat-process:not(.chat-process-live)[open] .chat-process-body { max-height: none; overflow: visible; -webkit-mask-image: none; mask-image: none; }
.chat-process-entry { padding: 0 0 6px; font-size: inherit; line-height: inherit; }
.chat-process-entry strong { display: block; font-size: 12px; color: var(--text-secondary, #666); }
.chat-process-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-process-interrupted { font-size: 12px; color: var(--text-secondary, #666); }
.chat-process-status { display: inline-block; font-size: 11px; padding: 0 6px; margin: 2px 0; border-radius: 4px; background: #f0f0ed; color: #555; }
.chat-process-status[data-status="failed"] { background: #fce8e6; color: #9a3026; }
.chat-process-status[data-status="completed"] { background: #e8f2eb; color: #285b38; }

/* Supplement fields stay stable as long text is entered. */
.choice-panel textarea { min-height: 96px; max-height: 240px; overflow-y: auto; overflow-wrap: anywhere; }
.choice-panel textarea[hidden], .choice-text-limit[hidden] { display: none; }
.choice-text-limit { margin: 6px 0 0; font-size: 12px; line-height: 1.6; color: var(--color-text-secondary); overflow-wrap: anywhere; }
.choice-text-limit[data-at-limit="true"] { color: #9a570e; }
.choice-other-input .choice-text-limit { grid-column: 1 / -1; order: 3; }

/* Latest pending question stays above the composer, outside the scrolling log. */
.choice-dock { margin: 0 0 10px; background: var(--color-bg); border: 1px solid var(--color-border); border-radius: 16px; overflow: hidden; }
.choice-dock[hidden] { display: none; }
.choice-dock-summary { width: 100%; border: 0; background: transparent; text-align: left; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; color: var(--color-text-secondary); font-size: 12px; font-weight: 600; cursor: pointer; list-style: none; }
.choice-dock-summary::-webkit-details-marker { display: none; }
.choice-dock-summary::after { content: '+'; font-size: 18px; line-height: 1; }
.choice-dock[data-expanded="true"] .choice-dock-summary::after { content: '−'; }
.choice-dock-summary:focus-visible { outline: 2px solid var(--color-primary); outline-offset: -3px; }
.choice-dock-body { max-height: min(40vh, 320px); max-height: min(40dvh, 320px); overflow-y: auto; overscroll-behavior: contain; padding: 0 14px 12px; scrollbar-width: thin; }
.choice-dock .choice-panel { margin: 0; padding: 0; border: 0; border-radius: 0; background: transparent; font-size: 14px; line-height: 1.5; }
.choice-dock .intake-panel > h3 { display: none; }
.choice-dock .intake-panel legend, .choice-dock .choice-question { margin: 0 0 8px; font-size: 14px; line-height: 1.5; }
.choice-dock .intake-option { gap: 9px; padding: 7px 0; line-height: 1.5; }
.choice-dock .intake-option input { width: 16px; height: 16px; flex-basis: 16px; margin-top: 2px; }
.choice-dock .choice-grid { gap: 6px; }
.choice-dock .choice-button { min-height: 36px; padding: 7px 10px; border-radius: 10px; font-size: 13px; line-height: 1.5; }
.choice-dock .intake-details, .choice-dock .choice-other-input textarea { min-height: 72px; max-height: 120px; margin-top: 8px; padding: 9px 11px; font-size: 14px; line-height: 1.5; background: var(--color-surface); border-radius: 10px; }
.choice-dock .choice-text-limit { margin-top: 4px; font-size: 11px; }
.choice-dock .intake-submit { min-height: 36px; margin-top: 9px; padding: 8px 14px; border-radius: 10px; font-size: 13px; }
.choice-dock .choice-hint { margin: 0 0 8px; font-size: 12px; }
.choice-dock .chat-source-open { margin-top: 8px; min-height: 36px; padding: 7px 12px; font-size: 13px; }
@media(max-width:600px) {
    .choice-dock-summary { padding: 9px 12px; }
    .choice-dock-body { padding: 0 12px 10px; max-height: min(36dvh, 280px); }
    .choice-dock textarea { font-size: 16px !important; } /* Prevent iOS focus zoom. */
}

.choice-dock-body[hidden] { display: none; }

/* History row context actions share the workspace's light menu treatment. */
.conversation-context-menu { position: fixed; z-index: 1200; min-width: 152px; padding: 5px; background: var(--color-surface, #fff); border: 1px solid var(--color-border); border-radius: 10px; box-shadow: 0 8px 24px rgba(30, 40, 38, .14); }
.conversation-context-menu[hidden] { display: none; }
.conversation-delete-button { display: block; width: 100%; padding: 9px 12px; border: 0; border-radius: 6px; background: transparent; color: #a83d39; font: inherit; font-size: 13px; text-align: left; cursor: pointer; }
.conversation-delete-button:hover, .conversation-delete-button:focus-visible { background: #faf0ee; outline: none; }
.conversation-delete-button:disabled { opacity: .45; cursor: wait; }
.conversation-item:focus-visible { outline: 2px solid var(--color-primary); outline-offset: -2px; }

.timezone-search { display: block; width: calc(100% - 12px); margin: 0 6px 6px; padding: 8px 10px; min-height: 34px; border: 1px solid var(--color-border); border-radius: 8px; background: var(--workspace-sidebar, #f7f7f5); color: var(--color-text); font: inherit; font-size: 13px; }
.timezone-search:focus { outline: 2px solid var(--color-primary); outline-offset: -1px; }
.timezone-empty { margin: 0; padding: 18px 10px; font-size: 13px; color: var(--color-text-muted); text-align: center; }
.timezone-option[hidden], .timezone-empty[hidden] { display: none !important; }
@media(max-width:480px) { .timezone-search { font-size: 16px; } }

.conversation-rename-button { display: block; width: 100%; padding: 9px 12px; border: 0; border-radius: 6px; background: transparent; color: var(--color-text); font: inherit; font-size: 13px; text-align: left; cursor: pointer; }
.conversation-rename-button:hover, .conversation-rename-button:focus-visible { background: var(--workspace-hover, #f1f1ee); outline: none; }
.conversation-rename-button:disabled { opacity: .45; cursor: wait; }
.conversation-rename-backdrop, .conversation-confirm-overlay { position: fixed; inset: 0; z-index: 1250; display: grid; place-items: center; padding: 20px; background: rgba(30, 32, 29, .24); }
.conversation-confirm-overlay[hidden] { display: none; }
.conversation-rename-dialog, .conversation-confirm-dialog { width: 100%; max-width: 400px; max-height: calc(100dvh - 40px); overflow-y: auto; padding: 24px; border: 1px solid var(--color-border); border-radius: 16px; background: var(--color-surface, #fff); color: var(--color-text); box-shadow: 0 16px 60px rgba(20, 30, 25, .15); }
.conversation-rename-dialog h2, .conversation-confirm-dialog h2 { margin: 0 0 20px; font-size: 18px; font-weight: 600; line-height: 1.5; }
.conversation-confirm-dialog p { margin: 0; color: var(--color-text-secondary); font-size: 14px; line-height: 1.8; overflow-wrap: anywhere; white-space: pre-wrap; }
.conversation-rename-dialog label { display: block; margin-bottom: 8px; font-size: 13px; color: var(--color-text-secondary); }
.conversation-rename-dialog input { width: 100%; padding: 10px 12px; border: 1px solid var(--color-border); border-radius: 8px; color: var(--color-text); background: transparent; font: inherit; font-size: 15px; }
.conversation-rename-dialog input:focus { outline: 2px solid var(--color-primary); outline-offset: -1px; }
.conversation-rename-error { color: #a83d39; font-size: 13px; margin: 8px 0; }
.conversation-rename-actions, .conversation-confirm-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.conversation-rename-actions button, .conversation-confirm-actions button { min-height: 38px; padding: 8px 18px; border: 1px solid var(--color-border); border-radius: 8px; background: transparent; color: var(--color-text); font: inherit; font-size: 13px; line-height: 1.5; cursor: pointer; }
.conversation-rename-actions .conversation-rename-save, .conversation-confirm-actions .conversation-confirm-accept { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.conversation-confirm-accept[data-danger="true"], .conversation-confirm-dialog[data-danger="true"] .conversation-confirm-accept { background: #a83d39; border-color: #a83d39; }
.conversation-rename-actions button:hover, .conversation-confirm-actions button:hover { filter: brightness(.95); }
.conversation-rename-actions button:focus-visible, .conversation-confirm-actions button:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 3px; }
.conversation-rename-actions button:disabled, .conversation-confirm-actions button:disabled { opacity: .45; cursor: wait; }
@media(max-width:480px) { .conversation-rename-dialog input { font-size: 16px; } }
