:root {
    --primary: #667eea;
    --success: #48bb78;
    --danger: #e53e3e;
    --warning: #ed8936;
    --info: #4299e1;
    --bg: #f5f7fa;
    --card: #ffffff;
    --text: #2d3748;
    --text-light: #718096;
    --border: #e2e8f0;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

/* 登录界面样式 */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.login-box {
    background: var(--card);
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 400px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

.login-logo {
    text-align: center;
    font-size: 48px;
    margin-bottom: 10px;
}

.login-title {
    text-align: center;
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}

.login-subtitle {
    text-align: center;
    color: var(--text-light);
    font-size: 14px;
    margin-bottom: 30px;
}

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    transition: all 0.2s;
    outline: none;
}

.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.login-btn {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 10px;
}

.login-btn:hover {
    background: #5568d3;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.login-btn:active {
    transform: translateY(0);
}

.error-message {
    background: #fed7d7;
    color: #742a2a;
    padding: 12px;
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 20px;
    border-left: 4px solid var(--danger);
    display: none;
    animation: shake 0.5s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.error-message.show {
    display: block;
}

.hidden {
    display: none !important;
}

/* 主应用样式 */
.app { 
    display: flex; 
    min-height: 100vh; 
    display: none;
}

.app.show {
    display: flex;
}

.sidebar {
    width: 320px;
    background: var(--card);
    border-right: 1px solid var(--border);
    padding: 20px;
    position: fixed;
    height: 100vh;
    display: flex;
    flex-direction: column;
    z-index: 100;
}

/* 侧边栏头部 */
.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 15px;
    margin-bottom: 15px;
    border-bottom: 2px solid var(--border);
}

.sidebar-header .logo {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
}

.sidebar-header .user-name {
    font-size: 14px;
    color: var(--text-light);
}

/* 侧边栏底部 */
.sidebar-footer {
    margin-top: auto;
    padding-top: 15px;
    border-top: 1px solid var(--border);
}



.sync-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 15px;
    font-weight: 600;
    transition: all 0.3s;
}

.sync-status.online {
    background: linear-gradient(135deg, #c6f6d5, #9ae6b4);
    color: #22543d;
    border: 1px solid #9ae6b4;
}

.sync-status.offline {
    background: linear-gradient(135deg, #fed7d7, #fc8181);
    color: #742a2a;
    border: 1px solid #fc8181;
}

.sync-status.syncing {
    background: linear-gradient(135deg, #bee3f8, #90cdf4);
    color: #2a4365;
    border: 1px solid #90cdf4;
}

.sync-status.error {
    background: linear-gradient(135deg, #feebc8, #fbd38d);
    color: #744210;
    border: 1px solid #fbd38d;
}

.sync-status.given-up {
    background: #e2e8f0;
    color: #4a5568;
    border: 1px solid #cbd5e0;
}

.sync-status.pending {
    background: linear-gradient(135deg, #faf5ff, #e9d8fd);
    color: #553c9a;
    border: 1px solid #d6bcfa;
}

.sync-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: currentColor;
    animation: pulse 1.5s infinite;
}

.sync-status.syncing .sync-dot {
    animation: spin 1s linear infinite;
    border-radius: 50%;
    border: 2px solid transparent;
    border-top-color: currentColor;
    background: transparent;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(0.9); }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.retry-count {
    font-size: 11px;
    opacity: 0.8;
    margin-left: auto;
}

.nav-section { margin-bottom: 20px; }

.nav-title {
    font-size: 12px;
    color: var(--text-light);
    margin-bottom: 8px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

select {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
}

.btn {
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-secondary {
    background: #edf2f7;
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-warning {
    background: var(--warning);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-sm { padding: 6px 10px; font-size: 11px; }

.admin-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.disaster-recovery {
    margin-top: 15px;
    padding: 12px;
    background: #fffaf0;
    border: 1px solid #fbd38d;
    border-radius: 8px;
}

.disaster-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #744210;
    font-weight: 600;
    cursor: pointer;
}

.disaster-content {
    display: none;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed #fbd38d;
}

.disaster-content.show { display: block; }

.disaster-content p {
    font-size: 11px;
    color: #975a16;
    margin-bottom: 8px;
    line-height: 1.5;
}

.btn-group {
    display: flex;
    gap: 8px;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 10px;
}

.stat-box {
    text-align: center;
    padding: 10px;
    background: white;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.stat-number {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 11px;
    color: var(--text-light);
    margin-top: 2px;
}

.log-panel {
    margin-top: 10px;
    max-height: 300px;
    overflow-y: auto;
    font-size: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    background: white;
}

.log-item {
    padding: 8px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.log-item:last-child { border-bottom: none; }

.log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.log-keyword {
    font-weight: 700;
    font-size: 13px;
    color: var(--text);
}

.log-status {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.log-status.mastered { background: #c6f6d5; color: #22543d; }
.log-status.not-mastered { background: #fed7d7; color: #742a2a; }
.log-status.forgot { background: #fee; color: #c53030; border: 1px solid #fc8181; }
.log-status.review { background: #bee3f8; color: #2a4365; }
.log-status.start { background: #feebc8; color: #744210; }
.log-status.complete { background: #d9f7e8; color: #276749; border: 1px solid var(--success); }

.log-meta {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #999;
}

.log-complete-mark {
    font-size: 10px;
    color: var(--success);
    font-weight: 700;
    margin-left: 4px;
}

.main {
    flex: 1;
    margin-left: 320px;
    padding: 20px;
    max-width: 800px;
}

.header {
    margin-bottom: 20px;
}

.header h1 { font-size: 24px; margin-bottom: 5px; }
.header p { color: var(--text-light); font-size: 14px; }

/* 主内容区域头部 */
.main-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border);
}

.main-header .subject-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 10px;
}

.main-header .subject-title .subject-icon {
    font-size: 28px;
}

.knowledge-card {
    background: var(--card);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border: 2px solid transparent;
    position: relative;
}

.knowledge-card.mastered { border-color: var(--success); }
.knowledge-card.reviewing { border-color: var(--info); background: rgba(66, 153, 225, 0.02); }

.review-badge {
    position: absolute;
    top: 0;
    right: 0;
    background: var(--info);
    color: white;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 700;
    border-bottom-left-radius: 12px;
    border-top-right-radius: 12px;
}

.knowledge-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
}

.knowledge-title-section { flex: 1; }

.knowledge-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
}

.knowledge-meta-line {
    font-size: 13px;
    color: var(--text-light);
    display: flex;
    align-items: center;
    gap: 8px;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.badge-success { background: var(--success); color: white; }
.badge-warning { background: var(--warning); color: white; }
.badge-danger { background: var(--danger); color: white; }
.badge-info { background: var(--info); color: white; }

.review-control {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: 15px;
}

.review-count-box {
    text-align: center;
    min-width: 50px;
}

.review-count-number {
    font-size: 26px;
    font-weight: 700;
    color: var(--info);
    line-height: 1;
}

.review-count-label {
    font-size: 10px;
    color: var(--text-light);
    margin-top: 2px;
}

.btn-review {
    background: var(--warning);
    color: white;
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    font-weight: 600;
}

.btn-review:hover { background: #dd6b20; }

.knowledge-content {
    font-size: 16px;
    line-height: 2.2;
    padding: 15px;
    background: var(--bg);
    border-radius: 8px;
    margin: 10px 0;
}

.knowledge-content p {
    margin-bottom: 10px;
}

.knowledge-content p:last-child {
    margin-bottom: 0;
}

.content-list {
    margin: 10px 0;
    padding-left: 24px;
}

.content-list li {
    margin-bottom: 8px;
    line-height: 1.8;
}

.formula-block {
    background: rgba(102, 126, 234, 0.1);
    border-left: 3px solid var(--primary);
    padding: 12px 16px;
    margin: 10px 0;
    border-radius: 0 8px 8px 0;
    font-family: 'Courier New', monospace;
    font-size: 18px;
    font-weight: 600;
}

.blank {
    display: inline-block;
    min-width: 100px;
    padding: 4px 10px;
    margin: 0 4px;
    border-bottom: 2px solid var(--primary);
    color: transparent;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    background: transparent;
    border-radius: 4px;
    font-weight: 600;
    user-select: none;
}

.blank.mastered {
    color: var(--success);
    border-bottom-color: var(--success);
    background: rgba(72, 187, 120, 0.1);
}

.blank.not-mastered {
    border-bottom-color: var(--danger);
    background: rgba(229, 62, 62, 0.05);
}

.blank:hover { background: rgba(102, 126, 234, 0.1); }

/* Hint 区域上方的图片 - 缩略图样式 */
.hint-images {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 15px 0;
}

.hint-image-item {
    background: var(--bg);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid var(--border);
    flex: 0 0 auto;
    max-width: 200px;
}

.hint-image-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.hint-image-item img {
    width: 100%;
    height: 120px;
    object-fit: contain;
    display: block;
    background: white;
}

.image-caption {
    padding: 8px 12px;
    font-size: 12px;
    color: var(--text-light);
    background: white;
    text-align: center;
}

.hint {
    font-size: 13px;
    color: var(--text-light);
    margin-top: 10px;
    padding: 8px 12px;
    background: rgba(237, 242, 247, 0.5);
    border-radius: 6px;
    border-left: 3px solid var(--primary);
}

/* 模态框 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
}

.modal.show { display: flex; }

.modal-content {
    background: var(--card);
    padding: 24px;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    margin: 20px auto;
}

.modal-content.modal-lg {
    max-width: 700px;
}

.modal-content.modal-xl {
    max-width: 900px;
}

.modal-content.modal-image {
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-content.modal-image .modal-body {
    flex: 1;
    overflow: auto;
    display: flex;
    flex-direction: column;
}

.image-preview-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    max-height: 70vh;
    overflow: auto;
}

.image-preview-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
}

/* 图片缩放容器 */
.image-zoom-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    max-height: 70vh;
    overflow: hidden;
    position: relative;
    background: #f5f5f5;
    border-radius: 8px;
}

.image-zoom-container img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    transition: none;
    user-select: none;
    -webkit-user-drag: none;
}

/* 缩放控制 */
.zoom-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.zoom-controls span {
    font-size: 14px;
    color: var(--text-light);
    min-width: 50px;
    text-align: center;
}

.modal-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.action-buttons {
    display: flex;
    gap: 10px;
}

.modal-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 16px;
    text-align: center;
}

.modal-body {
    margin-bottom: 20px;
}

.answer-display {
    background: rgba(102, 126, 234, 0.1);
    border: 2px dashed var(--primary);
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.modal-actions .btn {
    flex: 1;
    padding: 10px;
    max-width: 150px;
}

/* 图片预览 */
.image-info {
    margin-top: 15px;
    padding: 10px;
    background: var(--bg);
    border-radius: 6px;
    font-size: 12px;
    color: var(--text-light);
    word-break: break-all;
}

/* 表格 */
.table-container {
    overflow-x: auto;
    max-height: 400px;
    overflow-y: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th,
.data-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    background: var(--bg);
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-table tr:hover {
    background: rgba(102, 126, 234, 0.05);
}

/* 资源网格 */
.resource-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
    max-height: 400px;
    overflow-y: auto;
    padding: 10px;
}

.resource-item {
    background: var(--bg);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid var(--border);
}

.resource-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.resource-item img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    display: block;
}

.resource-name {
    padding: 8px;
    font-size: 11px;
    color: var(--text-light);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 内容块编辑器 */
.content-block-item {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 12px;
    display: grid;
    gap: 10px;
}

.block-type {
    width: 150px;
}

.block-editor textarea {
    width: 100%;
    min-height: 80px;
    resize: vertical;
}

.block-editor input {
    width: 100%;
}

.image-upload-area {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    padding: 10px;
    background: rgba(102, 126, 234, 0.05);
    border-radius: 6px;
    border: 1px dashed var(--border);
}

.upload-status {
    font-size: 12px;
    color: var(--success);
}

.block-editor .image-preview {
    background: var(--bg);
    padding: 10px;
    border-radius: 6px;
    text-align: center;
}

.block-editor .image-preview img {
    max-height: 150px;
    border-radius: 4px;
}

/* 编辑器工具栏 */
.editor-toolbar {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    padding: 8px;
    background: rgba(102, 126, 234, 0.05);
    border-radius: 6px;
    border: 1px solid var(--border);
}

.editor-toolbar .btn {
    font-size: 12px;
    padding: 6px 12px;
}

/* 表格中的输入框样式 */
.data-table .form-input {
    padding: 6px 10px;
    font-size: 13px;
    border: 1px solid transparent;
    background: transparent;
}

.data-table .form-input:hover,
.data-table .form-input:focus {
    border-color: var(--primary);
    background: white;
}

input[type="file"] { display: none; }

/* 知识点目录树 */
.knowledge-tree {
    flex: 1;
    overflow-y: auto;
    font-size: 13px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
}

.tree-category {
    margin-bottom: 8px;
}

.tree-category-header {
    font-weight: 600;
    color: var(--text);
    padding: 6px 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    border-radius: 4px;
    transition: background 0.2s;
}

.tree-category-header:hover {
    background: var(--bg);
}

.tree-category-arrow {
    font-size: 10px;
    transition: transform 0.2s;
    width: 12px;
}

.tree-category.expanded .tree-category-arrow {
    transform: rotate(90deg);
}

.tree-chapters {
    padding-left: 12px;
    display: none;
}

.tree-category.expanded .tree-chapters {
    display: block;
}

.tree-chapter {
    margin: 4px 0;
}

.tree-chapter-header {
    font-weight: 500;
    color: var(--text-light);
    padding: 4px 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    border-radius: 4px;
    font-size: 12px;
    transition: background 0.2s;
}

.tree-chapter-header:hover {
    background: var(--bg);
}

.tree-chapter-arrow {
    font-size: 10px;
    transition: transform 0.2s;
    width: 12px;
}

.tree-chapter.expanded .tree-chapter-arrow {
    transform: rotate(90deg);
}

.tree-knowledges {
    padding-left: 12px;
    display: none;
}

.tree-chapter.expanded .tree-knowledges {
    display: block;
}

.tree-knowledge {
    padding: 4px 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    border-radius: 4px;
    font-size: 12px;
    color: var(--text);
    transition: background 0.2s;
}

.tree-knowledge:hover {
    background: rgba(102, 126, 234, 0.1);
}

.tree-knowledge.active {
    background: rgba(102, 126, 234, 0.15);
    color: var(--primary);
    font-weight: 600;
}

.tree-knowledge-icon {
    font-size: 12px;
    width: 16px;
    text-align: center;
}

.tree-knowledge-icon.mastered {
    color: var(--success);
}

.tree-knowledge-icon.pending {
    color: var(--text-light);
}

.tree-knowledge-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pending-changes {
    font-size: 10px;
    color: var(--warning);
    font-weight: 600;
    margin-left: 4px;
}

@media (max-width: 768px) {
    .sidebar { display: none; }
    .main { margin-left: 0; }
    .knowledge-header { flex-direction: column; }
    .review-control { margin-left: 0; margin-top: 10px; }
    .login-box { padding: 30px 20px; }
    .modal-content { width: 95%; margin: 10px; }
    .form-row { grid-template-columns: 1fr; }
    .hint-images { grid-template-columns: 1fr; }
}
