/* ═══════════════════════════════════════════════════════════
   医学搜题系统 — 样式表 v1.0
   设计理念：专业医学感 + 现代清爽 + 精致细节
   ═══════════════════════════════════════════════════════════ */

/* ── CSS 变量 ──────────────────────────────────────────── */
:root {
    --color-primary: #0d6e6e;
    --color-primary-light: #14a3a3;
    --color-primary-dark: #094f4f;
    --color-primary-bg: rgba(13, 110, 110, 0.06);
    --color-accent: #f0883e;
    --color-accent-light: #fef0e3;

    --color-bg: #f0f4f5;
    --color-surface: #ffffff;
    --color-surface-hover: #f8fafa;

    --color-text: #1a2e2e;
    --color-text-secondary: #5a7272;
    --color-text-muted: #8fa5a5;
    --color-border: #d4e0e0;
    --color-border-light: #e8eded;

    --color-success: #1a8a5c;
    --color-success-bg: #e8f5ee;
    --color-warning: #c27a1a;
    --color-warning-bg: #fef4e6;
    --color-info: #1a6b9a;
    --color-info-bg: #e6f1f8;
    --color-error: #c0392b;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 999px;

    --shadow-sm: 0 1px 3px rgba(13, 110, 110, 0.06);
    --shadow-md: 0 4px 12px rgba(13, 110, 110, 0.08);
    --shadow-lg: 0 8px 30px rgba(13, 110, 110, 0.12);
    --shadow-xl: 0 16px 50px rgba(13, 110, 110, 0.15);
    --shadow-focus: 0 0 0 3px rgba(13, 110, 110, 0.12);

    --font-main: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: 0.15s ease;
}

/* ── 基础重置 ──────────────────────────────────────────── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-main);
    background: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
    position: relative;
}

/* ── 背景装饰 ──────────────────────────────────────────── */
.bg-decoration {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.bg-blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.3;
}

.bg-blob-1 {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, #0d6e6e22, transparent 70%);
    top: -200px;
    right: -100px;
}

.bg-blob-2 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, #f0883e18, transparent 70%);
    bottom: -100px;
    left: -100px;
}

.bg-blob-3 {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, #0d6e6e15, transparent 70%);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* ── 容器 ──────────────────────────────────────────────── */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 24px 20px 40px;
    position: relative;
}

/* ── Header ────────────────────────────────────────────── */
header {
    text-align: center;
    margin-bottom: 32px;
    padding-top: 16px;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 16px;
}

.logo-icon {
    font-size: 3rem;
    filter: drop-shadow(0 2px 8px rgba(13, 110, 110, 0.2));
    animation: pulse-soft 3s ease-in-out infinite;
}

@keyframes pulse-soft {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-primary-dark);
    letter-spacing: 0.02em;
}

.subtitle {
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    margin-top: 2px;
    font-weight: 400;
}

/* ── 搜索框 ────────────────────────────────────────────── */
.search-box {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 18px;
    width: 20px;
    height: 20px;
    color: var(--color-text-muted);
    pointer-events: none;
    transition: color var(--transition);
}

.search-input-wrapper:focus-within .search-icon {
    color: var(--color-primary);
}

#searchInput {
    width: 100%;
    padding: 16px 44px 16px 50px;
    font-size: 1rem;
    font-family: var(--font-main);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    color: var(--color-text);
    outline: none;
    transition: all var(--transition);
    box-shadow: var(--shadow-sm);
}

#searchInput:focus {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-md), var(--shadow-focus);
}

#searchInput::placeholder {
    color: var(--color-text-muted);
}

.clear-btn {
    position: absolute;
    right: 14px;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: var(--color-border);
    color: var(--color-text-secondary);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    padding: 0;
    box-shadow: none;
}

.clear-btn:hover {
    background: var(--color-text-muted);
    color: white;
    transform: none;
    box-shadow: none;
}

.search-actions {
    display: flex;
    gap: 10px;
}

/* ── 按钮 ──────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 0.95rem;
    font-family: var(--font-main);
    font-weight: 600;
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
}

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

.btn-primary {
    flex: 1;
    justify-content: center;
    background: var(--color-primary);
    color: white;
}

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

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.btn-secondary {
    flex: 1;
    justify-content: center;
    background: var(--color-surface);
    color: var(--color-primary);
    border-color: var(--color-border);
}

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

/* ── 控制栏 ────────────────────────────────────────────── */
.controls {
    background: var(--color-surface);
    padding: 14px 20px;
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
}

.control-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* 自定义 Toggle 开关 */
.toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    user-select: none;
}

.toggle-label input[type="checkbox"] {
    display: none;
}

.toggle-switch {
    position: relative;
    width: 40px;
    height: 22px;
    background: var(--color-border);
    border-radius: 11px;
    transition: background var(--transition);
    flex-shrink: 0;
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    transition: transform var(--transition);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.toggle-label input:checked+.toggle-switch {
    background: var(--color-primary);
}

.toggle-label input:checked+.toggle-switch::after {
    transform: translateX(18px);
}

/* 下拉选择器 */
.controls select {
    padding: 8px 36px 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-family: var(--font-main);
    color: var(--color-text);
    background: var(--color-surface);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235a7272' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    cursor: pointer;
    transition: all var(--transition-fast);
    min-width: 120px;
}

.controls select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: var(--shadow-focus);
}

.controls select:hover {
    border-color: var(--color-primary-light);
}

/* ── 搜索模式提示 ────────────────────────────────────── */
.search-mode-hint {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    margin-bottom: 12px;
    font-size: 0.82rem;
    color: var(--color-text-muted);
    background: var(--color-primary-bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border-light);
    transition: all var(--transition);
}

.hint-icon {
    font-size: 0.9rem;
    flex-shrink: 0;
}

/* ── 统计信息 ──────────────────────────────────────────── */
.stats {
    padding: 0;
    margin-bottom: 8px;
}

.stats p {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.stats strong {
    color: var(--color-text-secondary);
    font-weight: 600;
}

.stats-mode {
    display: inline-flex;
    padding: 2px 10px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--color-primary);
    color: white;
    letter-spacing: 0.03em;
}

/* ── Loading ──────────────────────────────────────────── */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 16px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading p {
    color: var(--color-text-muted);
    font-size: 0.95rem;
}

/* ── 结果列表 ──────────────────────────────────────────── */
.results {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ── 题目卡片 ──────────────────────────────────────────── */
.question-card {
    background: var(--color-surface);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
    transition: all var(--transition);
    animation: fadeInUp 0.35s ease both;
}

.question-card:hover {
    box-shadow: var(--shadow-lg);
    border-color: rgba(13, 110, 110, 0.2);
}

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

.question-card:nth-child(1) { animation-delay: 0s; }
.question-card:nth-child(2) { animation-delay: 0.04s; }
.question-card:nth-child(3) { animation-delay: 0.08s; }
.question-card:nth-child(4) { animation-delay: 0.12s; }
.question-card:nth-child(5) { animation-delay: 0.16s; }
.question-card:nth-child(6) { animation-delay: 0.20s; }
.question-card:nth-child(7) { animation-delay: 0.24s; }
.question-card:nth-child(8) { animation-delay: 0.28s; }
.question-card:nth-child(9) { animation-delay: 0.32s; }
.question-card:nth-child(10) { animation-delay: 0.36s; }

.question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    gap: 8px;
}

.question-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.question-type {
    display: inline-block;
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.03em;
}

/* 题型颜色编码 */
.type-单选题 { background: #e8f5ee; color: #1a8a5c; }
.type-多选题 { background: #e6f1f8; color: #1a6b9a; }
.type-判断题 { background: #ede8f5; color: #6b4fa0; }
.type-填空题 { background: #fef4e6; color: #c27a1a; }
.type-简答题 { background: #f3edf8; color: #7b52a0; }
.type-名词解释 { background: #fce8e8; color: #c0392b; }
.type-未知题型 { background: var(--color-bg); color: var(--color-text-muted); }

.question-index {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--color-primary);
    color: white;
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
    margin-right: 10px;
}

.question-score {
    color: var(--color-text-muted);
    font-size: 0.8rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.question-source {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.question-content {
    font-size: 1.05rem;
    line-height: 1.75;
    margin-bottom: 14px;
    color: var(--color-text);
    display: flex;
    align-items: flex-start;
}

.question-text {
    flex: 1;
}

/* ── 选项 ──────────────────────────────────────────────── */
.options {
    margin: 16px 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.option {
    padding: 12px 16px;
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--color-border);
    font-size: 0.95rem;
    line-height: 1.5;
    transition: all var(--transition);
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.option:hover {
    background: var(--color-surface-hover);
    border-left-color: var(--color-primary-light);
}

.option-letter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--color-primary-bg);
    color: var(--color-primary);
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
    border: 1.5px solid var(--color-border);
    transition: all var(--transition-fast);
}

.option:hover .option-letter {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

.option-text {
    flex: 1;
    padding-top: 1px;
}

/* ── 答案区域 ──────────────────────────────────────────── */
.answer-section {
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px dashed var(--color-border);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.answer-block {
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    line-height: 1.65;
}

.answer-block strong {
    display: block;
    margin-bottom: 6px;
    font-size: 0.85rem;
    letter-spacing: 0.02em;
}

.answer-content {
    font-size: 0.93rem;
    line-height: 1.7;
    word-break: break-word;
}

.answer-block.answer {
    background: var(--color-success-bg);
    border-left: 4px solid var(--color-success);
}

.answer-block.answer strong { color: var(--color-success); }

.answer-block.analysis {
    background: var(--color-warning-bg);
    border-left: 4px solid var(--color-warning);
}

.answer-block.analysis strong { color: var(--color-warning); }

.answer-block.reference {
    background: var(--color-info-bg);
    border-left: 4px solid var(--color-info);
    font-size: 0.9rem;
}

.answer-block.reference strong { color: var(--color-info); }

/* ── 空状态 / 欢迎 ────────────────────────────────────── */
.welcome-screen,
.no-results {
    background: var(--color-surface);
    padding: 60px 30px;
    border-radius: var(--radius-lg);
    text-align: center;
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
}

.welcome-icon {
    font-size: 3.5rem;
    margin-bottom: 16px;
    display: block;
}

.welcome-screen h2 {
    font-size: 1.5rem;
    color: var(--color-primary-dark);
    margin-bottom: 10px;
    font-weight: 700;
}

.welcome-screen p {
    color: var(--color-text-secondary);
    font-size: 1rem;
    line-height: 1.7;
}

.welcome-hint {
    margin-top: 24px;
    color: var(--color-text-muted) !important;
    font-size: 0.85rem !important;
}

.welcome-tags {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
}

.welcome-tag {
    padding: 6px 16px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 20px;
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

.welcome-tag:hover {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.welcome-features {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--color-border-light);
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.88rem;
    color: var(--color-text-secondary);
}

.feature-icon {
    font-size: 1.1rem;
}

.no-results {
    color: var(--color-text-secondary);
}

.error-message {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: var(--color-error);
    padding: 20px;
    border-radius: var(--radius-md);
    text-align: center;
    font-size: 0.95rem;
}

/* ── Footer ────────────────────────────────────────────── */
footer {
    text-align: center;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--color-border);
}

footer p {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

/* ══════════════════════════════════════════════════════════
   AI 助手悬浮球 + 对话框
   ══════════════════════════════════════════════════════════ */

/* ── 悬浮球 ──────────────────────────────────────────── */
.ai-bubble {
    position: fixed;
    right: 20px;
    bottom: 28px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(13, 110, 110, 0.35), 0 0 0 0 rgba(13, 110, 110, 0.2);
    z-index: 9998;
    transition: transform 0.3s ease, box-shadow 0.3s ease, left 0.3s ease, right 0.3s ease, top 0.3s ease;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    animation: bubble-breathe 3s ease-in-out infinite;
}

@keyframes bubble-breathe {
    0%, 100% { box-shadow: 0 4px 20px rgba(13, 110, 110, 0.35), 0 0 0 0 rgba(13, 110, 110, 0.15); }
    50% { box-shadow: 0 4px 20px rgba(13, 110, 110, 0.35), 0 0 0 8px rgba(13, 110, 110, 0); }
}

.ai-bubble:hover {
    transform: scale(1.08);
}

.ai-bubble-active {
    animation: none;
    box-shadow: 0 4px 20px rgba(13, 110, 110, 0.35);
}

/* ── 对话框 ──────────────────────────────────────────── */
.ai-chat {
    position: fixed;
    right: 20px;
    bottom: 96px;
    will-change: bottom, right, top, left;
    width: 380px;
    max-height: 560px;
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(13, 110, 110, 0.08);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: chatSlideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes chatSlideUp {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ── 对话框头部 ──────────────────────────────────────── */
.ai-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
    color: white;
    flex-shrink: 0;
}

.ai-chat-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 0.95rem;
}

.ai-chat-actions {
    display: flex;
    gap: 4px;
}

.ai-action-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    padding: 0;
    box-shadow: none;
}

.ai-action-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: none;
    box-shadow: none;
}

/* ── 选项区 ──────────────────────────────────────────── */
.ai-chat-options {
    padding: 8px 16px;
    border-bottom: 1px solid var(--color-border-light);
    flex-shrink: 0;
}

.ai-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    cursor: pointer;
    user-select: none;
}

.ai-toggle input {
    display: none;
}

.ai-toggle-slider {
    position: relative;
    width: 32px;
    height: 18px;
    background: var(--color-border);
    border-radius: 9px;
    transition: background 0.2s;
    flex-shrink: 0;
}

.ai-toggle-slider::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

.ai-toggle input:checked + .ai-toggle-slider {
    background: var(--color-primary);
}

.ai-toggle input:checked + .ai-toggle-slider::after {
    transform: translateX(14px);
}

/* ── 消息区域 ────────────────────────────────────────── */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 120px;
    max-height: 340px;
}

.ai-chat-messages::-webkit-scrollbar {
    width: 4px;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 2px;
}

.ai-welcome-msg {
    text-align: center;
    padding: 20px 10px;
    color: var(--color-text-secondary);
    font-size: 0.88rem;
    line-height: 1.6;
}

.ai-welcome-hint {
    font-size: 0.78rem;
    color: var(--color-text-muted);
    margin-top: 6px;
}

/* ── 消息气泡 ────────────────────────────────────────── */
.ai-msg {
    display: flex;
    animation: msgFadeIn 0.3s ease;
}

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

.ai-msg-user {
    justify-content: flex-end;
}

.ai-msg-assistant {
    justify-content: flex-start;
}

.ai-msg-bubble {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.88rem;
    line-height: 1.65;
    word-break: break-word;
}

.ai-msg-user .ai-msg-bubble {
    background: var(--color-primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.ai-msg-assistant .ai-msg-bubble {
    background: var(--color-bg);
    color: var(--color-text);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--color-border-light);
}

.ai-inline-code {
    background: rgba(0,0,0,0.06);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.85em;
    font-family: 'Menlo', 'Consolas', monospace;
}

.ai-typing {
    color: var(--color-text-muted);
    font-style: italic;
}

.ai-error {
    color: var(--color-error);
    font-size: 0.85rem;
}

/* ── 预加载提示 ──────────────────────────────────────── */
.ai-preload {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 16px;
    background: var(--color-primary-bg);
    border-top: 1px solid var(--color-border-light);
    flex-shrink: 0;
}

.ai-preload-label {
    font-size: 0.75rem;
    color: var(--color-primary);
}

.ai-preload-clear {
    width: 20px;
    height: 20px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--color-text-muted);
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    box-shadow: none;
    transition: color 0.15s;
}

.ai-preload-clear:hover {
    color: var(--color-error);
    transform: none;
    box-shadow: none;
}

/* ── 输入区域 ────────────────────────────────────────── */
.ai-chat-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--color-border-light);
    flex-shrink: 0;
}

.ai-chat-textarea {
    flex: 1;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 0.88rem;
    font-family: var(--font-main);
    color: var(--color-text);
    resize: none;
    outline: none;
    min-height: 40px;
    max-height: 120px;
    line-height: 1.5;
    transition: border-color 0.2s;
    background: var(--color-surface);
}

.ai-chat-textarea:focus {
    border-color: var(--color-primary);
}

.ai-chat-textarea::placeholder {
    color: var(--color-text-muted);
}

.ai-send-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: var(--color-primary);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, opacity 0.2s;
    padding: 0;
    box-shadow: none;
}

.ai-send-btn:hover {
    background: var(--color-primary-dark);
    transform: none;
    box-shadow: none;
}

.ai-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ai-send-loading {
    opacity: 0.6;
    pointer-events: none;
}

/* ── 对话框底部 ──────────────────────────────────────── */
.ai-chat-footer {
    padding: 4px 16px 8px;
    text-align: right;
    flex-shrink: 0;
}

.ai-chat-footer span {
    font-size: 0.7rem;
    color: var(--color-text-muted);
}

/* ── 响应式 ────────────────────────────────────────────── */
@media (max-width: 640px) {
    .container {
        padding: 16px 12px 32px;
    }

    header {
        margin-bottom: 24px;
    }

    .logo {
        flex-direction: column;
        gap: 8px;
    }

    .logo-icon {
        font-size: 2.5rem;
    }

    header h1 {
        font-size: 1.6rem;
    }

    .search-actions {
        flex-direction: column;
    }

    .btn {
        padding: 12px 20px;
    }

    .controls {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .control-group {
        justify-content: space-between;
    }

    .controls select {
        min-width: 0;
        flex: 1;
    }

    .question-card {
        padding: 18px 16px;
    }

    .question-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .question-content {
        font-size: 0.98rem;
    }

    .question-source {
        max-width: 150px;
    }

    .welcome-screen {
        padding: 40px 20px;
    }

    .welcome-tags {
        gap: 6px;
    }

    .welcome-features {
        flex-direction: column;
        gap: 12px;
        align-items: center;
    }

    .option {
        padding: 10px 14px;
    }

    /* AI 对话框移动端适配 */
    .ai-chat {
        right: 8px;
        left: 8px;
        bottom: 88px;
        width: auto;
        max-height: 70vh;
    }

    .ai-bubble {
        right: 14px;
        bottom: 20px;
        width: 50px;
        height: 50px;
    }

    .ai-bubble svg {
        width: 22px;
        height: 22px;
    }
}

@media (max-width: 400px) {
    .control-group {
        flex-direction: column;
        gap: 8px;
        align-items: stretch;
    }

    .controls select {
        width: 100%;
    }
}

/* ── 抖动动画 ──────────────────────────────────────────── */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}

.shake {
    animation: shake 0.4s ease;
}

.ai-code-block {
    display: block;
    background: rgba(0,0,0,0.06);
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 0.82em;
    font-family: 'Menlo', 'Consolas', monospace;
    white-space: pre-wrap;
    word-break: break-word;
    margin: 6px 0;
    overflow-x: auto;
}

/* ── 移动端触屏禁用 hover 特效（防止点击残留高亮） ──── */
@media (hover: none) and (pointer: coarse) {
    .option:hover {
        background: var(--color-bg);
        border-left-color: var(--color-border);
    }
    .option:hover .option-letter {
        background: var(--color-primary-bg);
        color: var(--color-primary);
        border-color: var(--color-border);
    }
    .welcome-tag:hover {
        background: var(--color-bg);
        color: var(--color-text-secondary);
        border-color: var(--color-border);
        transform: none;
        box-shadow: none;
    }
    .btn-primary:hover,
    .btn-secondary:hover {
        transform: none;
        box-shadow: var(--shadow-sm);
    }
}

/* ── 打印样式 ──────────────────────────────────────────── */
@media print {
    .bg-decoration,
    .search-box,
    .controls,
    .stats,
    .search-mode-hint,
    footer,
    .question-score,
    .question-source,
    .ai-bubble,
    .ai-chat {
        display: none !important;
    }

    body {
        background: white;
    }

    .container {
        max-width: 100%;
        padding: 0;
    }

    .question-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd;
        animation: none;
    }

    .option:hover {
        background: var(--color-bg);
        border-left-color: var(--color-border);
    }

    .option:hover .option-letter {
        background: var(--color-primary-bg);
        color: var(--color-primary);
        border-color: var(--color-border);
    }
}

/* AI复制按钮样式 */
.ai-msg {
  position: relative;
}
.ai-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255,255,255,0.1);
  border: none;
  border-radius: 4px;
  padding: 4px 6px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s, background 0.2s;
  color: #94a3b8;
}
.ai-msg:hover .ai-copy-btn {
  opacity: 1;
}
.ai-copy-btn:hover {
  background: rgba(255,255,255,0.2);
  color: #fff;
}
.ai-copy-btn.copied {
  color: #22c55e;
  opacity: 1;
}
