* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 0;
}

/* 顶部导航 */
.navbar {
    background: rgba(102,126,234,0.9);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    padding: 14px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}
.navbar .brand {
    color: #fff;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 1px;
}
.navbar .nav-links {
    display: flex;
    gap: 6px;
}
.navbar .nav-links a {
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    font-size: 16px;
    padding: 8px 16px;
    border-radius: 20px;
    transition: all 0.3s;
}
.navbar .nav-links a.active,
.navbar .nav-links a:hover {
    background: rgba(255,255,255,0.25);
    color: #fff;

}

/* 主容器 */
.container {
    max-width: 780px;
    margin: 24px auto;
    padding: 0 16px 40px;
}

/* 卡片 */
.card {
    background: #fff;
    border-radius: 16px;
    padding: 28px 24px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.12);
    margin-bottom: 20px;
}
.card-title {
    font-size: 20px;
    font-weight: 700;
    color: #1a1a2e;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.card-title .icon {
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 14px;
}

/* 表单 */
.form-row {
    display: flex;
    gap: 12px;
    margin-bottom: 18px;
}
.form-item {
    flex: 1;
    margin-bottom: 18px;
}
.form-item label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #555;
}
select, input[type="text"], textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid #e8e8e8;
    border-radius: 10px;
    font-size: 14px;
    color: #333;
    background: #fafafa;
    transition: border-color 0.3s, box-shadow 0.3s;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}
select {
    background: #fafafa 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='%23999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") no-repeat right 12px center;
    padding-right: 36px;
}
select:focus, input[type="text"]:focus, textarea:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102,126,234,0.15);
    background-color: #fff;
}
textarea {
    resize: vertical;
    min-height: 60px;
}

/* 上传区域 */
.upload-area {
    border: 2px dashed #d0d5dd;
    border-radius: 12px;
    padding: 32px 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: #fafbfc;
    position: relative;
    overflow: hidden;
}
.upload-area:hover, .upload-area.dragover {
    border-color: #667eea;
    background: rgba(102,126,234,0.04);
}
.upload-area .upload-icon {
    font-size: 40px;
    margin-bottom: 8px;
}
.upload-area .upload-text {
    font-size: 14px;
    color: #666;
}
.upload-area .upload-hint {
    font-size: 12px;
    color: #aaa;
    margin-top: 4px;
}
.upload-area.has-file {
    border-style: solid;
    border-color: #667eea;
    padding: 12px;
}
#preview, #g_preview, #entry_preview {
    max-width: 100%;
    max-height: 240px;
    border-radius: 8px;
    display: none;
    margin: 0 auto;
}
.file-name {
    font-size: 12px;
    color: #667eea;
    margin-top: 8px;
    word-break: break-all;
}

/* 按钮 */
.btn-primary {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    letter-spacing: 1px;
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(102,126,234,0.4);
}
.btn-primary:active {
    transform: translateY(0);
}
.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-search {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: 6px;
}
.btn-search:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(102,126,234,0.3);
}

.btn-export-pdf {
    width: 100%;
    padding: 10px;
    background: #fff;
    color: #667eea;
    border: 1.5px solid #667eea;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 6px;
    transition: all 0.2s;
}

.btn-export-pdf:hover {
    background: #667eea;
    color: #fff;
}

.btn-solve {
    background: #f0f4ff;
    color: #4361ee;
    border: 1px solid #4361ee;
    padding: 5px 14px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    margin-top: 8px;
    transition: all 0.2s;
}

.btn-solve:hover {
    background: #4361ee;
    color: #fff;
}

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

.btn-solve-collapse {
    padding: 2px 8px;
    font-size: 12px;
    border: none;
    background: none;
    color: #999;
    text-decoration: underline;
}

.btn-solve-collapse:hover {
    background: none;
    color: #4361ee;
}

.q-solve {
    margin-top: 12px;
    padding: 14px 16px;
    background: #f8f9ff;
    border-radius: 8px;
    font-size: 15px;
    line-height: 1.8;
    overflow-x: auto;
    overflow-wrap: break-word;
    word-break: break-word;
}

.q-solve *,
.q-solve li,
.q-solve ol,
.q-solve ul,
.q-solve blockquote {
    border-left: none !important;
}

.q-solve h3 {
    font-size: 16px;
    margin: 12px 0 6px;
    color: #333;
}

.q-solve p {
    margin: 6px 0;
}

.q-solve .katex-display {
    overflow-x: auto;
    max-width: 100%;
    padding: 4px 0;
}

.q-solve .katex {
    font-size: 1.3em;
}

.q-solve .katex-display .katex {
    font-size: 1.1em;
}

.q-solve table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0;
}

.q-solve th,
.q-solve td {
    border: 1px solid #ddd;
    padding: 6px 8px;
    font-size: 14px;
    text-align: left;
}

.q-solve ul,
.q-solve ol {
    padding-left: 20px;
    margin: 6px 0;
}

.q-solve pre {
    background: #eee;
    padding: 10px;
    border-radius: 6px;
    overflow-x: auto;
    font-size: 13px;
}

.q-solve code {
    background: #eee;
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 0.9em;
}

.q-btn-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

.btn-remove {
    padding: 5px 14px;
    font-size: 13px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    background: #fff;
    color: #e74c3c;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-remove:hover {
    background: #e74c3c;
    color: #fff;
    border-color: #e74c3c;
}

/* 结果区域 */
.result-card {
    display: none;
    animation: fadeUp 0.4s ease;
}
.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.result-header .title {
    font-size: 16px;
    font-weight: 700;
    color: #1a1a2e;
}
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}
.badge-success {
    background: #e8f5e9;
    color: #2e7d32;
}
.badge-error {
    background: #fce4ec;
    color: #c62828;
}
.result-stats {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}
.stat-box {
    flex: 1;
    text-align: center;
    padding: 12px 8px;
    background: #f5f6ff;
    border-radius: 10px;
}
.stat-box .num {
    font-size: 24px;
    font-weight: 700;
    color: #667eea;
}
.stat-box .label {
    font-size: 11px;
    color: #888;
    margin-top: 2px;
}
.error-list {
    list-style: none;
}
.error-list li {
    padding: 12px 14px;
    background: #f9f9fb;
    border-radius: 10px;
    margin-bottom: 10px;
    border-left: 3px solid #667eea;
}
.error-list .q-no {
    font-size: 13px;
    font-weight: 700;
    color: #667eea;
    margin-bottom: 4px;
}
.error-list .q-content {
    font-size: 13px;
    color: #444;
    line-height: 1.6;
    margin-bottom: 4px;
}
.error-list .q-type {
    font-size: 12px;
    color: #999;
}
.error-list .q-img {
    margin: 8px 0;
}

.error-list .q-img img {
    max-width: 100%;
    max-height: 200px;
    border-radius: 6px;
    border: 1px solid #eee;
    cursor: pointer;
}

.raw-json {
    margin-top: 14px;
    padding: 12px;
    background: #f1f3f5;
    border-radius: 8px;
    font-size: 12px;
    color: #555;
    max-height: 200px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
}
.raw-toggle {
    font-size: 13px;
    color: #667eea;
    cursor: pointer;
    margin-top: 10px;
    text-align: center;
}

/* Loading */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 200;
    justify-content: center;
    align-items: center;
}
.loading-overlay.show {
    display: flex;
}
.loading-box {
    background: #fff;
    border-radius: 16px;
    padding: 32px 40px;
    text-align: center;
}
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e8e8e8;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 12px;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
.loading-box p {
    font-size: 14px;
    color: #666;
}

/* Toast */
.toast {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: #333;
    color: #fff;
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 14px;
    opacity: 0;
    transition: all 0.3s;
    z-index: 300;
    pointer-events: none;
}
.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* 错题本样式 */
.notebook-filter {
    background: #f8f9ff;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}
.notebook-empty {
    text-align: center;
    padding: 40px 20px;
    color: #999;
}
.notebook-empty .icon {
    font-size: 48px;
    margin-bottom: 12px;
    color: #ddd;
}

.nb-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    padding: 8px 0;
}

.nb-page-btn {
    padding: 6px 16px;
    font-size: 13px;
    border: 1px solid #667eea;
    border-radius: 6px;
    background: #fff;
    color: #667eea;
    cursor: pointer;
    transition: all 0.2s;
}

.nb-page-btn:hover:not(:disabled) {
    background: #667eea;
    color: #fff;
}

.nb-page-btn:disabled {
    border-color: #ddd;
    color: #ccc;
    cursor: not-allowed;
}

.nb-page-info {
    font-size: 13px;
    color: #666;
}

/* AI阅卷结果样式 */
.grading-item {
    border-left-color: #4caf50;
}
.grading-item.wrong {
    border-left-color: #f44336;
}
.grading-item.unknown {
    border-left-color: #ff9800;
}
.grading-status {
    font-size: 12px;
    font-weight: 600;
    margin-left: 8px;
}
.grading-status.right {
    color: #4caf50;
}
.grading-status.wrong {
    color: #f44336;
}
.grading-status.unknown {
    color: #ff9800;
}

/* 移动端适配 */
@media (max-width: 480px) {
    .navbar {
        flex-wrap: wrap;
        padding: 10px 12px;
        gap: 8px;
    }
    .navbar .brand { font-size: 16px; }
    .navbar .nav-links {
        width: 100%;
        flex-wrap: wrap;
        gap: 4px;
    }
    .navbar .nav-links a { font-size: 12px; padding: 5px 10px; }
    .container { padding: 0 10px 32px; margin-top: 16px; }
    .card { padding: 18px 14px; border-radius: 14px; }
    .card-title { font-size: 17px; }
    .form-row { flex-direction: column; gap: 0; }
    .form-row .form-item { margin-bottom: 18px; }
    .upload-area { padding: 24px 12px; }
    .upload-area .upload-icon { font-size: 32px; }
    .result-stats { flex-direction: column; gap: 8px; }
    .notebook-stat-item { min-width: 70px; }

    .q-solve {
        padding: 12px 14px;
        font-size: 14px;
        line-height: 1.7;
    }
    .q-solve .katex {
        font-size: 1.0em;
    }
    .q-solve .katex-display {
        font-size: 1.0em;
    }
    .q-solve ul,
    .q-solve ol {
        padding-left: 16px;
    }
}

/* 登录/注册页面样式 */
.auth-card {
    max-width: 400px;
    margin: 60px auto;
    padding: 32px 28px;
}

.auth-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 28px;
    background: #f0f2ff;
    border-radius: 12px;
    padding: 4px;
}

.auth-tab {
    flex: 1;
    padding: 12px;
    border: none;
    background: transparent;
    color: #666;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 10px;
    transition: all 0.3s;
}

.auth-tab.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.auth-tab:hover:not(.active) {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
}

#loginForm, #registerForm {
    animation: fadeUp 0.4s ease;
}

.form-item input[type="password"] {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid #e8e8e8;
    border-radius: 10px;
    font-size: 14px;
    color: #333;
    background: #fafafa;
    transition: border-color 0.3s, box-shadow 0.3s;
    outline: none;
}

.form-item input[type="password"]:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102,126,234,0.15);
    background-color: #fff;
}

.form-item input[type="email"] {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid #e8e8e8;
    border-radius: 10px;
    font-size: 14px;
    color: #333;
    background: #fafafa;
    transition: border-color 0.3s, box-shadow 0.3s;
    outline: none;
}

.form-item input[type="email"]:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102,126,234,0.15);
    background-color: #fff;
}

/* 个人中心样式 */
.mine-menu {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mine-menu-item {
    display: flex;
    align-items: center;
    padding: 16px 18px;
    background: #f8f9ff;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.mine-menu-item:hover {
    background: #eef0ff;
    transform: translateX(4px);
}

.mine-menu-item-disabled {
    cursor: default;
    opacity: 0.6;
}

.mine-menu-item-disabled:hover {
    background: #f8f9ff;
    transform: none;
}

.mine-menu-icon {
    font-size: 22px;
    margin-right: 14px;
}

.mine-menu-text {
    flex: 1;
    font-size: 15px;
    font-weight: 600;
    color: #333;
}

.mine-menu-arrow {
    font-size: 20px;
    color: #ccc;
}

.mine-menu-tag {
    font-size: 12px;
    color: #999;
    background: #eee;
    padding: 3px 10px;
    border-radius: 10px;
}

/* 笔记清除结果样式 */
#e_preview {
    max-width: 100%;
    max-height: 240px;
    border-radius: 8px;
    display: none;
    margin: 0 auto;
}

.erase-result-body {
    text-align: center;
}

.erase-img-wrap {
    margin-bottom: 20px;
}

.erase-img-wrap img {
    max-width: 100%;
    max-height: 400px;
    border-radius: 10px;
    border: 1px solid #eee;
}

.btn-download {
    display: inline-block;
    padding: 12px 36px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    letter-spacing: 1px;
}

.btn-download:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(102,126,234,0.4);
}

.btn-download:active {
    transform: translateY(0);
}

/* 智能切题样式 */
#c_preview {
    max-width: 100%;
    max-height: 240px;
    border-radius: 8px;
    display: none;
    margin: 0 auto;
}

.cut-tip {
    font-size: 13px;
    color: #888;
    text-align: center;
    margin-bottom: 16px;
}

.cut-canvas-wrap {
    position: relative;
    display: block;
    width: 100%;
    text-align: center;
    overflow: hidden;
}

.cut-canvas-wrap img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 8px;
    border: 1px solid #eee;
    margin: 0 auto;
}

.cut-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.cut-box {
    position: absolute;
    border: 2px solid #667eea;
    background: rgba(102, 126, 234, 0.08);
    border-radius: 6px;
    cursor: pointer;
    pointer-events: all;
    transition: all 0.2s;
}

.cut-box:hover {
    background: rgba(102, 126, 234, 0.15);
}

.cut-box.selected {
    border-color: #4caf50;
    background: rgba(76, 175, 80, 0.12);
    border-width: 2.5px;
}

.cut-box-label {
    position: absolute;
    top: -10px;
    left: 6px;
    background: #667eea;
    color: #fff;
    font-size: 11px;
    padding: 1px 8px;
    border-radius: 8px;
    font-weight: 600;
    line-height: 16px;
}

.cut-box.selected .cut-box-label {
    background: #4caf50;
}

.cut-box-add {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid #667eea;
    background: rgba(255, 255, 255, 0.9);
    color: #667eea;
    font-size: 20px;
    font-weight: 700;
    line-height: 28px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.cut-box-add:hover {
    background: #667eea;
    color: #fff;
}

.cut-box.selected .cut-box-add {
    border-color: #4caf50;
    color: #4caf50;
}

.cut-box.selected .cut-box-add:hover {
    background: #4caf50;
    color: #fff;
}

.cut-box-handle {
    position: absolute;
    z-index: 10;
    touch-action: none;
}
.cut-box-handle.top {
    top: -12px; left: 0; right: 0; height: 24px;
    cursor: n-resize;
}
.cut-box-handle.bottom {
    bottom: -12px; left: 0; right: 0; height: 24px;
    cursor: s-resize;
}
.cut-box-handle.left {
    left: -12px; top: 0; bottom: 0; width: 24px;
    cursor: w-resize;
}
.cut-box-handle.right {
    right: -12px; top: 0; bottom: 0; width: 24px;
    cursor: e-resize;
}

.cut-actions {
    margin-top: 20px;
}

.cut-selected-info {
    text-align: center;
    font-size: 14px;
    color: #555;
    font-weight: 600;
    margin-bottom: 12px;
}

.cut-btn-row {
    display: flex;
    gap: 12px;
}

.btn-merge, .btn-confirm {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-merge {
    background: #fff3e0;
    color: #e65100;
    border: 1px solid #ffcc80;
}

.btn-merge:hover:not(:disabled) {
    background: #ff9800;
    color: #fff;
}

.btn-confirm {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

.btn-confirm:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn-merge:disabled, .btn-confirm:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.entry-tip {
    font-size: 13px;
    color: #999;
    margin-bottom: 8px;
    text-align: center;
}

.entry-btn-row {
    display: flex;
    flex-direction: row;
    gap: 16px;
    margin-top: 8px;
}

.entry-btn-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.entry-btn-col .btn-primary,
.entry-btn-col .btn-secondary {
    width: 100%;
    min-height: 44px;
    padding: 12px 20px;
    font-size: 15px;
}

.btn-secondary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 15px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-secondary:hover {
    opacity: 0.9;
}

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

.entry-progress {
    margin-top: 16px;
    padding: 16px;
    background: #f8f9fa;
    border-radius: 10px;
    border: 1px solid #eee;
}
.progress-title {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin-bottom: 12px;
}
.progress-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    margin-bottom: 6px;
    border-radius: 6px;
    font-size: 13px;
    background: #fff;
    border: 1px solid #e8e8e8;
    transition: all 0.3s;
}
.progress-item.processing {
    border-color: #667eea;
    background: #f0f2ff;
}
.progress-item.success {
    border-color: #4caf50;
    background: #f1f8e9;
}
.progress-item.error {
    border-color: #f44336;
    background: #ffebee;
}
