:root {
    --bg-secondary: #f8fafc;
    --bg-hover: #f1f5f9;
    --bg-active: #e2e8f0;
    --warning-bg: #fef3c7;
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #e0e7ff;
    --success-color: #10b981;
    --success-bg: #d1fae5;
    --danger-color: #ef4444;
    --danger-bg: #fee2e2;
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --bg-main: #f3f4f6;
    --bg-card: #ffffff;
    --border-color: #e5e7eb;
    --radius: 12px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --transition: all 0.2s ease-in-out;
}

[data-theme="dark"] {
    --bg-secondary: #252525;
    --bg-hover: #2a2a2a;
    --bg-active: #333333;
    --warning-bg: #78350f;
    --primary-light: #2d2a6a;
    --success-bg: #064e3b;
    --danger-bg: #7f1d1d;
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --bg-main: #121212;
    --bg-card: #1e1e1e;
    --border-color: var(--text-main);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

[data-theme="eyecare"] {
    --bg-secondary: #F6EBD1;
    --bg-hover: #F0E6D2;
    --bg-active: #E6D5B8;
    --warning-bg: #FDF3D5;
    --bg-main: #FCF4DC;
    --bg-card: #FFFBF2;
    --text-main: #333333;
    --border-color: #E6D5B8;
    --primary-light: #F0E6D2;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Noto Sans SC', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

#app {
    max-width: 800px;
    margin: 0 auto;
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

.screen {
    display: none;
    padding: 20px 20px 80px 20px;
    min-height: 100vh;
    animation: fadeIn 0.3s ease-in-out;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

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

/* ================= 首页样式 ================= */
.sync-banner {
    background: linear-gradient(90deg, var(--primary-light), #f3f4f6);
    border: 1px solid var(--primary-light);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin: 20px 20px 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--primary-hover);
    font-size: 14px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.sync-banner-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sync-icon {
    font-size: 18px;
}

header {
    text-align: center;
    margin-bottom: 30px;
    padding-top: 20px;
}

header h1 {
    font-size: 24px;
    color: var(--primary-color);
    margin-bottom: 8px;
}

header p {
    color: var(--text-muted);
    font-size: 14px;
}

.controls-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

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

.topic-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    padding-bottom: 100px; /* 为底部浮动栏留空间 */
}

.topic-card {
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    padding: 15px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.topic-card:hover {
    border-color: var(--primary-light);
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.topic-card.selected {
    border-color: var(--primary-color);
    background-color: var(--primary-light);
}

.topic-title {
    font-weight: 500;
    margin-bottom: 8px;
    font-size: 15px;
}

.topic-count {
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg-main);
    padding: 2px 8px;
    border-radius: 10px;
    align-self: flex-start;
}

.floating-start {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-card); opacity: 0.95;
    backdrop-filter: blur(5px);
    border-top: 1px solid var(--border-color);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.05);
    z-index: 10;
}

/* 如果屏幕较大，限制浮动栏宽度与容器一致 */
@media (min-width: 800px) {
    .floating-start {
        max-width: 800px;
        left: 50%;
        transform: translateX(-50%);
    }
}

.selected-info {
    font-size: 14px;
    color: var(--text-muted);
}

.selected-info span {
    font-weight: 700;
    color: var(--primary-color);
}

/* ================= 练习页样式 ================= */
.practice-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-top: 10px;
}

.progress-container {
    flex: 1;
    margin: 0 20px;
    text-align: center;
}

.progress-text {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 5px;
    font-weight: 500;
}

.progress-bar-bg {
    height: 6px;
    background-color: var(--bg-active);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--primary-color);
    width: 0%;
    transition: width 0.3s ease;
}

.question-container {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 25px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.question-header {
    margin-bottom: 15px;
    display: flex;
    gap: 10px;
}

.badge {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 4px;
    background: var(--primary-light);
    color: var(--primary-color);
    font-weight: 500;
}

.badge-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
}

.question-text {
    font-size: 17px;
    font-weight: 500;
    margin-bottom: 25px;
    white-space: pre-wrap;
    line-height: 1.5;
}

.options-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.option-item {
    display: flex;
    align-items: flex-start;
    padding: 15px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    background: var(--bg-card);
}

.option-item:hover {
    border-color: #cbd5e1;
    background-color: var(--bg-secondary);
}

.option-item.selected {
    border-color: var(--primary-color);
    background: var(--primary-light);
}

.option-item.correct {
    border-color: var(--success-color);
    background: var(--success-bg);
}

.option-item.wrong {
    border-color: var(--danger-color);
    background: var(--danger-bg);
}

.option-label {
    font-weight: 700;
    margin-right: 15px;
    color: var(--text-muted);
    width: 20px;
}

.option-item.selected .option-label {
    color: var(--primary-color);
}

.option-item.correct .option-label {
    color: var(--success-color);
}

.option-item.wrong .option-label {
    color: var(--danger-color);
}

.option-text {
    flex: 1;
    white-space: pre-wrap;
}

.feedback-area {
    margin-top: 20px;
    padding: 15px;
    border-radius: var(--radius);
    font-weight: 500;
    animation: fadeIn 0.3s;
}

.feedback-area.hidden {
    display: none;
}

.feedback-area.success {
    background: var(--success-bg);
    color: #065f46;
    border-left: 4px solid var(--success-color);
}

.feedback-area.error {
    background: var(--danger-bg);
    color: #991b1b;
    border-left: 4px solid var(--danger-color);
}

.practice-footer {
    display: flex;
    justify-content: space-between;
    margin-top: auto;
    padding-bottom: 20px;
}

/* ================= 通用组件 ================= */
.btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

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

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-main);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
}

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

.btn-full {
    width: 100%;
}

.btn-icon {
    background: none;
    border: none;
    font-size: 16px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: var(--transition);
}

.btn-icon:hover {
    background-color: var(--bg-active);
    color: var(--text-main);
}

.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-main);
}

.checkbox-label input {
    display: none;
}

.custom-checkbox {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    margin-right: 8px;
    position: relative;
    transition: var(--transition);
}

.checkbox-label input:checked + .custom-checkbox {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.checkbox-label input:checked + .custom-checkbox::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 2px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.text-success { color: var(--success-color); }
.text-danger { color: var(--danger-color); }

/* ================= 侧边抽屉 ================= */
.overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 40;
    opacity: 1;
    transition: opacity 0.3s;
}

.overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.drawer {
    position: fixed;
    top: 0; right: -300px; bottom: 0;
    width: 300px;
    background: var(--bg-card);
    z-index: 50;
    box-shadow: -5px 0 15px rgba(0,0,0,0.1);
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
}

.drawer.open {
    right: 0;
}

.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 20px 80px 20px;
    border-bottom: 1px solid var(--border-color);
}

.drawer-stats {
    display: flex;
    justify-content: space-around;
    padding: 15px 0;
    background: var(--bg-main);
    border-bottom: 1px solid var(--border-color);
}

.stat-item {
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
}

.stat-value {
    font-size: 16px;
    font-weight: 700;
}

.drawer-actions {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
}

.grid-nav {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    align-content: start;
}

.nav-dot {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    cursor: pointer;
    font-weight: 500;
    color: var(--text-muted);
}

.nav-dot.current {
    border-color: var(--primary-color);
    border-width: 2px;
    color: var(--primary-color);
    transform: scale(1.1);
}

.nav-dot.answered-correct {
    background: var(--success-color);
    color: white;
    border-color: var(--success-color);
}

.nav-dot.answered-wrong {
    background: var(--danger-color);
    color: white;
    border-color: var(--danger-color);
}

/* Global hidden */
.hidden { display: none !important; }

/* Radio Buttons */
.radio-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-main);
}
.radio-label input { display: none; }
.custom-radio {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    margin-right: 8px;
    position: relative;
    transition: var(--transition);
}
.radio-label input:checked + .custom-radio {
    border-color: var(--primary-color);
}
.radio-label input:checked + .custom-radio::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary-color);
}

/* ================= 特殊模块样式 ================= */
.special-topics {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.special-card {
    flex: 1;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px 20px 80px 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: var(--transition);
}

.special-card:hover {
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

#card-wrong:hover {
    border-color: var(--danger-color);
    background-color: var(--danger-bg);
}

#card-bookmark:hover {
    border-color: #f59e0b;
    background-color: var(--warning-bg);
}

.special-icon {
    font-size: 28px;
    margin-right: 15px;
}

.special-info {
    display: flex;
    flex-direction: column;
}

.special-title {
    font-size: 16px;
    font-weight: 700;
}

.special-count {
    font-size: 13px;
    color: var(--text-muted);
}

/* ================= 练习页新增样式 ================= */
.question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.question-badges {
    display: flex;
    gap: 10px;
}

.bookmark-btn {
    font-size: 22px;
    color: #cbd5e1;
    padding: 0 8px;
}

.bookmark-btn.active {
    color: #f59e0b;
}

.btn-danger {
    background: var(--danger-bg);
    color: var(--danger-color);
    border: 1px solid var(--danger-color);
}

.btn-danger:hover:not(:disabled) {
    background: var(--danger-color);
    color: white;
}

/* ================= 搜索功能样式 ================= */
.search-container {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

#search-input {
    flex: 1;
    padding: 10px 15px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 15px;
    outline: none;
    transition: var(--transition);
}

#search-input:focus {
    border-color: var(--primary-color);
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    background: var(--bg-card);
    border-radius: var(--radius);
    z-index: 60;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    opacity: 1;
    transition: opacity 0.3s;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 15px 20px;
}

.search-result-item {
    background: var(--bg-main);
    border-radius: var(--radius);
    padding: 15px;
    margin-bottom: 15px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: var(--transition);
}

.search-result-item:hover {
    border-color: var(--primary-color);
    background: var(--primary-light);
}

.search-result-topic {
    font-size: 12px;
    color: var(--primary-color);
    font-weight: bold;
    margin-bottom: 5px;
}

.search-result-q {
    font-size: 15px;
    font-weight: 500;
    margin-bottom: 10px;
}

.search-result-opt {
    font-size: 13px;
    color: var(--text-muted);
}

.search-result-opt.correct {
    color: var(--success-color);
    font-weight: 700;
}

.empty-search {
    text-align: center;
    color: var(--text-muted);
    padding: 30px 0;
}

/* ================= AI 小助手样式 ================= */
.ai-assistant-area {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px dashed var(--border-color);
}

.ai-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.ai-mode-toggle {
    display: flex;
    gap: 15px;
}

.ai-btn {
    border-color: #8b5cf6;
    color: #8b5cf6;
}

.ai-btn:hover {
    background: #8b5cf6;
    color: white;
}

.ai-notice {
    font-size: 12px;
    color: var(--text-muted);
    text-align: right;
    margin-bottom: 15px;
}

.ai-output {
    background: var(--bg-main);
    padding: 15px;
    border-radius: var(--radius);
    border: 1px solid #e2e8f0;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-main);
    max-height: 400px;
    overflow-y: auto;
    white-space: pre-wrap;
}

.ai-output .think-block {
    color: var(--text-muted);
    border-left: 3px solid #cbd5e1;
    padding-left: 10px;
    margin: 10px 0;
    background-color: var(--bg-secondary);
}

/* ================= 底部版权样式 ================= */
.app-footer {
    text-align: center;
    padding: 20px 20px 80px 20px;
    margin-top: 30px;
    color: var(--text-muted);
    font-size: 13px;
    border-top: 1px solid var(--border-color);
}

.footer-links {
    margin-bottom: 8px;
}

.footer-link {
    color: var(--primary-color);
    text-decoration: none;
    margin: 0 5px;
}

.footer-link:hover {
    text-decoration: underline;
}

.footer-divider {
    color: #cbd5e1;
    margin: 0 5px;
}


/* 窄屏幕自适应竖着排 */
@media (max-width: 768px) {
    .special-topics {
        flex-direction: column;
    }
}
/* ================= 用户同步组件 ================= */
.user-auth-widget {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 20;
}

.btn-auth {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
    transition: var(--transition);
}

.btn-auth:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.auth-icon {
    font-size: 16px;
}

.sync-status {
    font-size: 12px;
    color: var(--text-muted);
    background-color: var(--bg-active);
    padding: 2px 8px;
    border-radius: 10px;
}

.sync-status.synced {
    background: var(--success-bg);
    color: var(--success-color);
}

.sync-status.syncing {
    background-color: var(--warning-bg);
    color: #d97706;
}

@media (max-width: 600px) {
    .user-auth-widget {
        top: 10px;
        left: 10px;
    }
}
