* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --primary: #1976D2;
  --primary-light: #E3F2FD;
  --primary-dark: #1565C0;
  --text: #1d1d1f;
  --text-secondary: #86868b;
  --bg: #ffffff;
  --bg-secondary: #f5f5f7;
  --border: #d2d2d7;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body { font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'PingFang SC', 'Helvetica Neue', sans-serif; background: var(--bg); color: var(--text); line-height: 1.6; -webkit-font-smoothing: antialiased; }

.hidden { display: none !important; }

/* Header */
.header { position: sticky; top: 0; z-index: 100; background: rgba(255,255,255,0.85); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-bottom: 1px solid var(--border); }
.header-inner { max-width: 720px; margin: 0 auto; padding: 12px 20px; display: flex; align-items: center; gap: 10px; }
.logo { font-size: 20px; font-weight: 700; color: var(--primary); letter-spacing: -0.5px; }
.tagline { font-size: 14px; color: var(--text-secondary); font-weight: 400; flex: 1; }

/* History button */
.history-btn { width: 36px; height: 36px; border: none; background: transparent; color: var(--text-secondary); border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all var(--transition); }
.history-btn:hover { background: var(--bg-secondary); color: var(--primary); }

/* Sidebar */
.sidebar-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.3); z-index: 200; animation: fadeIn 0.2s ease; }
.sidebar { position: fixed; top: 0; right: 0; width: 320px; height: 100%; background: var(--bg); z-index: 201; box-shadow: -4px 0 20px rgba(0,0,0,0.1); display: flex; flex-direction: column; animation: slideInRight 0.3s ease; }
.sidebar-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.sidebar-title { font-size: 16px; font-weight: 600; }
.sidebar-close { width: 32px; height: 32px; border: none; background: transparent; color: var(--text-secondary); border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all var(--transition); }
.sidebar-close:hover { background: var(--bg-secondary); }
.sidebar-body { flex: 1; overflow-y: auto; padding: 12px 0; }
.sidebar-empty { text-align: center; padding: 40px 20px; color: var(--text-secondary); font-size: 14px; }
.sidebar-item { display: flex; align-items: center; gap: 12px; padding: 14px 20px; cursor: pointer; transition: background var(--transition); border-bottom: 1px solid #f0f0f0; }
.sidebar-item:hover { background: var(--bg-secondary); }
.sidebar-item:active { background: var(--primary-light); }
.sidebar-item-icon { width: 36px; height: 36px; border-radius: 50%; background: var(--primary-light); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.sidebar-item-icon svg { width: 16px; height: 16px; color: var(--primary); }
.sidebar-item-info { flex: 1; min-width: 0; }
.sidebar-item-topic { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-item-meta { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.sidebar-item-time { font-size: 11px; color: var(--text-secondary); white-space: nowrap; }

/* Main */
.main { max-width: 720px; margin: 0 auto; padding: 40px 20px 80px; }

/* Input Section */
.input-section { animation: slideUp 0.5s ease; }
.input-card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.input-wrapper { display: flex; gap: 8px; align-items: center; border: 2px solid var(--border); border-radius: var(--radius); padding: 2px; transition: border-color var(--transition); }
.input-wrapper:focus-within { border-color: var(--primary); }
.knowledge-input { flex: 1; border: none; outline: none; padding: 14px 16px; font-size: 16px; background: transparent; color: var(--text); }
.knowledge-input::placeholder { color: var(--text-secondary); }
.submit-btn { width: 44px; height: 44px; border: none; background: var(--primary); color: #fff; border-radius: 8px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: opacity var(--transition), transform var(--transition); flex-shrink: 0; }
.submit-btn:hover { opacity: 0.9; }
.submit-btn:active { transform: scale(0.95); }
.submit-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.quick-topics { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.topic-chip { padding: 6px 14px; border: 1px solid var(--border); border-radius: 20px; background: var(--bg); color: var(--text-secondary); font-size: 13px; cursor: pointer; transition: all var(--transition); }
.topic-chip:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }

/* Topic Header */
.topic-header { display: flex; align-items: center; gap: 8px; padding: 16px 0 0; animation: fadeIn 0.3s ease; }
.topic-header-label { font-size: 12px; color: var(--text-secondary); font-weight: 500; letter-spacing: 0.5px; }
.topic-header-name { font-size: 18px; font-weight: 600; color: var(--text); }

/* Loading - 渐变光晕 + 文字轮播 */
.loading-section { text-align: center; padding: 60px 0 40px; animation: fadeIn 0.3s ease; }
.loading-glow { position: relative; width: 80px; height: 80px; margin: 0 auto 28px; display: flex; align-items: center; justify-content: center; }
.loading-glow-ring { position: absolute; inset: 0; border-radius: 50%; background: conic-gradient(from 0deg, #1976D2, #64B5F6, #90CAF9, #1976D2); mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px)); -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px)); animation: spin 2s linear infinite; }
.loading-glow-pulse { position: absolute; width: 60%; height: 60%; border-radius: 50%; background: radial-gradient(circle, rgba(25,118,210,0.15) 0%, transparent 70%); animation: glowPulse 2s ease-in-out infinite; }
.loading-text { font-size: 14px; color: var(--text-secondary); transition: opacity 0.25s ease; }

/* Section Header */
.section-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 16px; padding-top: 40px; }
.section-title { font-size: 20px; font-weight: 600; letter-spacing: -0.3px; }
.quiz-progress { font-size: 14px; color: var(--text-secondary); font-weight: 500; }

/* Explanation */
.explanation-section { animation: slideUp 0.4s ease; }
.explanation-content { font-size: 15px; line-height: 1.8; color: var(--text); }
.explanation-content h3 { font-size: 17px; font-weight: 600; margin: 20px 0 10px; color: var(--text); }
.explanation-content h2 { font-size: 19px; font-weight: 600; margin: 24px 0 12px; color: var(--text); }
.explanation-content h1 { font-size: 21px; font-weight: 700; margin: 28px 0 14px; color: var(--text); }
.explanation-content strong { font-weight: 600; color: var(--text); }
.explanation-content em { font-style: italic; }
.explanation-content code { font-family: 'SF Mono', 'Menlo', 'Consolas', monospace; font-size: 13px; background: #f0f0f0; padding: 2px 6px; border-radius: 4px; color: #C62828; }
.explanation-content ul { margin: 8px 0 12px 20px; list-style: disc; }
.explanation-content li { margin-bottom: 4px; }
.explanation-content br { content: ''; display: block; margin: 4px 0; }
.key-points { margin-top: 24px; padding: 20px; background: var(--bg-secondary); border-radius: var(--radius); }
.key-points-title { font-size: 15px; font-weight: 600; margin-bottom: 12px; color: var(--primary); }
.key-point { position: relative; padding-left: 16px; margin-bottom: 8px; font-size: 14px; color: var(--text); line-height: 1.6; }
.key-point strong { font-weight: 600; }
.key-point code { font-family: 'SF Mono', 'Menlo', 'Consolas', monospace; font-size: 12px; background: #e8e8ea; padding: 1px 5px; border-radius: 3px; }
.key-point::before { content: ''; position: absolute; left: 0; top: 9px; width: 6px; height: 6px; border-radius: 50%; background: var(--primary); }

/* Quiz */
.quiz-section { animation: slideUp 0.4s ease; }
.quiz-card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow); animation: fadeIn 0.3s ease; }
.quiz-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.quiz-number { font-size: 13px; font-weight: 600; color: var(--primary); letter-spacing: 0.5px; }
.quiz-type-tag { font-size: 11px; padding: 2px 8px; border-radius: 4px; background: var(--bg-secondary); color: var(--text-secondary); font-weight: 500; }
.quiz-question { font-size: 15px; line-height: 1.7; margin-bottom: 16px; font-weight: 500; }
.quiz-question strong { font-weight: 600; }
.quiz-question code { font-family: 'SF Mono', 'Menlo', 'Consolas', monospace; font-size: 13px; background: #f0f0f0; padding: 1px 5px; border-radius: 3px; }
.quiz-options { display: flex; flex-direction: column; gap: 8px; }
.quiz-option { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; transition: all var(--transition); font-size: 14px; }
.quiz-option:hover { border-color: var(--primary); background: var(--primary-light); }
.quiz-option.selected { border-color: var(--primary); background: var(--primary-light); }
.quiz-option .option-letter { width: 24px; height: 24px; border-radius: 50%; background: var(--bg-secondary); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; color: var(--text-secondary); flex-shrink: 0; }
.quiz-option.selected .option-letter { background: var(--primary); color: #fff; }

.fill-input { width: 100%; padding: 12px 14px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; outline: none; transition: border-color var(--transition); background: transparent; color: var(--text); }
.fill-input:focus { border-color: var(--primary); }

/* Buttons */
.btn { padding: 10px 28px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 500; cursor: pointer; transition: all var(--transition); border: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { opacity: 0.9; box-shadow: var(--shadow-md); }
.btn-primary:active { transform: scale(0.97); }
.btn-outline { border: 1.5px solid var(--border); background: var(--bg); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }

.quiz-actions { display: flex; justify-content: center; margin-top: 8px; }

/* Result */
.result-section { animation: slideUp 0.4s ease; }
.score-card { text-align: center; padding: 32px 20px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 24px; box-shadow: var(--shadow); }
.score-number { font-size: 48px; font-weight: 700; color: var(--primary); line-height: 1; }
.score-label { font-size: 14px; color: var(--text-secondary); margin-top: 4px; }
.score-bar-wrap { margin-top: 16px; height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; max-width: 200px; margin-left: auto; margin-right: auto; }
.score-bar { height: 100%; background: var(--primary); border-radius: 2px; transition: width 0.8s ease; }

.result-item { padding: 16px 20px; border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 12px; background: var(--bg); box-shadow: var(--shadow); }
.result-item-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.result-indicator { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; }
.result-indicator.correct { color: #2E7D32; }
.result-indicator.wrong { color: #C62828; }
.result-user-answer { font-size: 14px; color: var(--text-secondary); margin-bottom: 6px; }
.result-explanation { font-size: 14px; line-height: 1.7; color: var(--text); }

.continued-explanation { margin-top: 24px; padding: 20px; background: var(--bg-secondary); border-radius: var(--radius); }
.continued-explanation-title { font-size: 15px; font-weight: 600; margin-bottom: 12px; color: var(--primary); }
.continued-explanation-content { font-size: 14px; line-height: 1.8; white-space: pre-wrap; }

/* Chat / Continue asking */
.chat-section { animation: slideUp 0.4s ease; }
.chat-messages { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; min-height: 40px; }
.chat-placeholder { text-align: center; padding: 24px 0; color: var(--text-secondary); font-size: 14px; }
.chat-bubble { max-width: 85%; padding: 12px 16px; border-radius: 12px; font-size: 14px; line-height: 1.7; animation: fadeIn 0.3s ease; }
.chat-bubble.user { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.chat-bubble.assistant { align-self: flex-start; background: var(--bg-secondary); color: var(--text); border-bottom-left-radius: 4px; }
.chat-bubble .bubble-label { font-size: 11px; font-weight: 500; margin-bottom: 4px; opacity: 0.7; }
.chat-bubble .bubble-content { white-space: pre-wrap; }
.chat-bubble.typing .bubble-content::after { content: '|'; animation: blink 1s step-end infinite; color: var(--primary); }
.chat-input-wrap { display: flex; gap: 8px; align-items: center; border: 1.5px solid var(--border); border-radius: var(--radius); padding: 2px; transition: border-color var(--transition); background: var(--bg); }
.chat-input-wrap:focus-within { border-color: var(--primary); }
.chat-input { flex: 1; border: none; outline: none; padding: 12px 14px; font-size: 14px; background: transparent; color: var(--text); }
.chat-input::placeholder { color: var(--text-secondary); }
.chat-send-btn { width: 38px; height: 38px; border: none; background: var(--primary); color: #fff; border-radius: 8px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: opacity var(--transition), transform var(--transition); flex-shrink: 0; }
.chat-send-btn:hover { opacity: 0.9; }
.chat-send-btn:active { transform: scale(0.95); }
.chat-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Restart */
.restart-section { text-align: center; padding: 40px 0; animation: fadeIn 0.4s ease; }

/* Animations */
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideInRight { from { transform: translateX(100%); } to { transform: translateX(0); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
@keyframes blink { 50% { opacity: 0; } }

/* Typing cursor */
.typing-cursor::after { content: '|'; animation: blink 1s step-end infinite; color: var(--primary); }

/* Result tag for answered quiz */
.quiz-card.answered .quiz-option { opacity: 0.6; pointer-events: none; }
.quiz-card.answered .quiz-option.correct { opacity: 1; border-color: #2E7D32; background: #E8F5E9; }
.quiz-card.answered .quiz-option.wrong { opacity: 1; border-color: #C62828; background: #FFEBEE; }
.quiz-card.answered .quiz-option.correct .option-letter { background: #2E7D32; color: #fff; }
.quiz-card.answered .quiz-option.wrong .option-letter { background: #C62828; color: #fff; }
.quiz-card.answered .fill-input { opacity: 0.6; pointer-events: none; }
.quiz-card.answered .fill-input.correct { border-color: #2E7D32; background: #E8F5E9; opacity: 1; }
.quiz-card.answered .fill-input.wrong { border-color: #C62828; background: #FFEBEE; opacity: 1; }

/* Mobile */
@media (max-width: 600px) {
  .main { padding: 24px 16px 60px; }
  .input-card { padding: 16px; }
  .score-number { font-size: 40px; }
  .sidebar { width: 100%; }
  .phase-label { font-size: 11px; }
  .phase-item { padding: 4px 8px; }
}
/* Loading animations */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes glowPulse { 0%, 100% { transform: scale(1); opacity: 0.6; } 50% { transform: scale(1.3); opacity: 1; } }/* Thinking process area */
.thinking-area { margin-top: 20px; text-align: left; border-top: 1px solid var(--border); padding-top: 16px; animation: fadeIn 0.5s ease; }
.thinking-label { font-size: 11px; color: var(--text-secondary); font-weight: 500; letter-spacing: 0.5px; margin-bottom: 8px; text-transform: uppercase; }
.thinking-content { font-size: 13px; color: var(--text-secondary); line-height: 1.7; white-space: pre-wrap; max-height: 200px; overflow-y: auto; font-family: 'SF Mono', 'Menlo', 'Consolas', monospace; opacity: 0.8; }
.thinking-content::after { content: '|'; animation: blink 1s step-end infinite; color: var(--primary); }