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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.delete-image-btn {
    margin-top: 10px;
    padding: 5px 10px;
    font-size: 0.9rem;
}

.preview-image_delete {
    max-width: 100%;
    max-height: 300px;
    margin-bottom: 10px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.header p {
    font-size: 1.2rem;
    opacity: 0.9;
}

.main-content {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    overflow: hidden;
    min-height: 600px;
}

.nav-tabs {
    display: flex;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.nav-tab {
    flex: 1;
    padding: 15px 20px;
    text-align: center;
    cursor: pointer;
    border: none;
    background: none;
    font-size: 1rem;
    font-weight: 500;
    color: #6c757d;
    transition: all 0.3s ease;
}

.nav-tab.active {
    background: white;
    color: #667eea;
    border-bottom: 3px solid #667eea;
}

.nav-tab:hover {
    background: #e9ecef;
}

.tab-content {
    display: none;
    padding: 30px;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

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

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #495057;
}

.form-control {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.btn {
    padding: 12px 30px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

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

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.upload-area {
    border: 3px dashed #dee2e6;
    border-radius: 15px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 20px;
}

.upload-area:hover {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.05);
}

.upload-area.dragover {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.1);
}

.upload-icon {
    font-size: 3rem;
    color: #6c757d;
    margin-bottom: 15px;
}

.preview-image {
    max-width: 100%;
    max-height: 300px;
    border-radius: 10px;
    margin: 20px 0;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.response-area {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 10px;
    margin-top: 20px;
    min-height: 200px;
    border: 1px solid #dee2e6;
}

.response-content {
    line-height: 1.6;
    font-size: 1rem;
}


.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #6c757d;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.alert {
    padding: 15px 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    border: 1px solid transparent;
}

.alert-success {
    background: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}

.alert-danger {
    background: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

.alert-info {
    background: #cce7ff;
    border-color: #b3d9ff;
    color: #004085;
}

.user-info {
    background: #e7f3ff;
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 20px;
}

.history-item {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 15px;
    transition: box-shadow 0.3s ease;
}

.history-item:hover {
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.history-date {
    color: #6c757d;
    font-size: 0.9rem;
    margin-bottom: 10px;
}

.history-image {
    max-width: 200px;
    max-height: 150px;
    border-radius: 8px;
    margin-bottom: 10px;
}

.history-response {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin-top: 10px;
    font-size: 0.95rem;
    line-height: 1.5;
}

.hidden {
    display: none !important;
}

/* AI回答展示样式 */
.ai-response {
    background: #fff;
    border-radius: 15px;
    padding: 10px;
    margin: 10px 0;
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
    border-left: 5px solid #667eea;
}

.subject-info {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 10px;
    padding: 10px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 10px;
}

.subject-info span {
    background: #667eea;
    color: white;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

.subject-info .subject {
    background: #28a745;
}

.subject-info .grade {
    background: #17a2b8;
}

.subject-info .difficulty {
    background: #ffc107;
    color: #212529;
}

.ai-response h3 {
    color: #2c3e50;
    font-size: 1.2rem;
    margin: 2px 0 2px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid #e9ecef;
    display: flex;
    align-items: center;
    gap: 2px;
}
/* 调整内部子元素间距 */
.ai-response > div {
    margin-bottom: 6px; /* 统一子元素底部间距 */
}

.question-analysis {
    background: #f8f9fa;
    padding: 5px;
    border-radius: 10px;
    margin: 4px 0;
    border-left: 4px solid #6c757d;
}

.answer-section {
    background: #d4edda;
    padding: 5px;
    border-radius: 10px;
    margin: 4px 0;
    border-left: 4px solid #28a745;
}

@media (max-width: 768px) {
    .response-area {
        background: #f8f9fa;
        border-radius: 2px;
        padding: 1px;
        margin-top: 20px;
        min-height: 200px;
        border: 1px solid #dee2e6;
    }

    .response-content {
        line-height: 1.6;
        font-size: 1rem;
    }

    /* AI回答展示样式 */
    .ai-response {
        background: #fff;
        border-radius: 2px;
        padding: 1px;
        margin: 10px 0;
        box-shadow: 0 8px 25px rgba(0,0,0,0.1);
        border-left: 5px solid #667eea;
    }

    .question-analysis {
        background: #f8f9fa;
        padding: 5px;
        border-radius: 10px;
        margin: 4px 0;
        border-left: 4px solid #6c757d;
    }

    .answer-section {
        background: #d4edda;
        padding: 5px;
        border-radius: 10px;
        margin: 4px 0;
        border-left: 4px solid #28a745;
    }
}

.correct-answer, .calculation-result {
    font-size: 1.1rem;
    margin: 4px 0;
}

.correct-answer strong, .calculation-result strong {
    color: #28a745;
    font-size: 1.2rem;
}

.solution-steps {
    background: #fff3cd;
    padding: 5px;
    border-radius: 10px;
    margin: 5px 0;
    border-left: 4px solid #ffc107;
}

.steps-list {
    margin: 5px 0;
    padding-left: 20px;
}

.steps-list li {
    margin: 12px 0;
    line-height: 1.6;
    padding: 8px 0;
}

.steps-list li strong {
    color: #495057;
}

.knowledge-points {
    background: #cce7ff;
    padding: 5px;
    border-radius: 10px;
    margin: 5px 0;
    border-left: 4px solid #007bff;
}

.knowledge-list {
    margin: 5px 0;
    padding-left: 20px;
}

.knowledge-list li {
    margin: 10px 0;
    line-height: 1.6;
}

.knowledge-list li strong {
    color: #007bff;
}

.tips-section {
    background: #f0f8ff;
    padding: 5px;
    border-radius: 10px;
    margin: 5px 0;
    border-left: 4px solid #17a2b8;
}

.tips-content {
    margin: 15px 0;
    line-height: 1.6;
}

.solution-analysis {
    background: #f8d7da;
    padding: 5px;
    border-radius: 10px;
    margin: 5px 0;
    border-left: 4px solid #dc3545;
}

.formula {
    background: #e9ecef;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    color: #495057;
}

/* 历史记录优化样式 */
.history-filters {
    background: white;
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.filter-group {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
    margin-bottom: 15px;
}

.filter-group label {
    font-weight: 500;
    color: #495057;
    margin-right: 8px;
}

.filter-select {
    padding: 8px 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    background: white;
    color: #495057;
    font-size: 0.9rem;
    transition: border-color 0.3s ease;
}

.filter-select:focus {
    outline: none;
    border-color: #667eea;
}

.search-box {
    flex: 1;
    min-width: 200px;
    padding: 10px 15px;
    border: 2px solid #e9ecef;
    border-radius: 25px;
    font-size: 0.9rem;
    transition: border-color 0.3s ease;
}

.search-box:focus {
    outline: none;
    border-color: #667eea;
}

.history-item {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 15px;
    padding: 25px;
    margin-bottom: 20px;
    transition: all 0.3s ease;
    position: relative;
}

.history-item:hover {
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    transform: translateY(-2px);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.history-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.history-date {
    color: #6c757d;
    font-size: 0.9rem;
    background: #f8f9fa;
    padding: 4px 10px;
    border-radius: 15px;
}

.history-subject {
    background: #28a745;
    color: white;
    padding: 4px 10px;
    border-radius: 15px;
    font-size: 0.8rem;
    font-weight: 500;
}

.history-grade {
    background: #17a2b8;
    color: white;
    padding: 4px 10px;
    border-radius: 15px;
    font-size: 0.8rem;
    font-weight: 500;
}

.question-preview {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 10px;
    margin: 15px 0;
    border-left: 4px solid #6c757d;
}

.question-text {
    font-weight: 500;
    color: #495057;
    margin-bottom: 10px;
}

.history-image {
    max-width: 200px;
    max-height: 150px;
    border-radius: 10px;
    margin: 10px 0;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.history-response {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    margin-top: 15px;
    font-size: 0.95rem;
    line-height: 1.6;
    max-height: 300px;
    overflow-y: auto;
}

.expand-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.3s ease;
    margin-top: 10px;
}

.expand-btn:hover {
    background: #5a6fd8;
}

/* .delete-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 15px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.3s ease;
}

.delete-btn:hover {
    background: #c82333;
} */


/* 删除按钮样式（右上角悬浮） */
.delete-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    line-height: 24px;
    text-align: center;
    transition: background 0.3s;
}
.delete-btn:hover {
    background: rgba(255, 0, 0, 0.7);
}

.delete-btn-parent {
    position: relative;
    display: inline-block; /* 让容器大小跟随图片 */
    /* border: 2px dashed #ccc;
    border-radius: 8px; */

}

.row {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.col {
    flex: 1;
}

/* 摄像头相关样式 */
.camera-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 2000;
    justify-content: center;
    align-items: center;
}

.camera-modal.active {
    display: flex;
}

.camera-container {
    background: white;
    border-radius: 20px;
    padding: 20px;
    max-width: 90%;
    /* use viewport units so height is relative to screen */
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    /* allow scrolling inside modal when content (video + controls) exceed height */
    overflow: auto;
}

.camera-video {
    width: 100%;
    max-width: 640px;
    /* limit height relative to viewport to avoid pushing controls off-screen */
    max-height: 60vh;
    height: auto;
    border-radius: 15px;
    background: #000;
    margin-bottom: 20px;
    /* make sure the video scales and preserves aspect ratio without stretching layout */
    object-fit: contain;
}

.camera-preview {
    width: 100%;
    max-width: 640px;
    max-height: 60vh;
    height: auto;
    border-radius: 15px;
    margin-bottom: 20px;
    display: none;
    object-fit: contain;
}

.camera-controls {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
    /* keep controls visible at the bottom when scrolling inside the container */
    position: sticky;
    bottom: 0;
    padding-bottom: 10px;
    background: transparent; /* keep visual consistent; change if you want a panel */
}

.camera-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 22px;
    font-size: 0.98rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.camera-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.camera-btn-secondary {
    background: #6c757d;
    color: white;
}

.camera-btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

.camera-btn-success {
    background: #28a745;
    color: white;
}

.camera-btn-success:hover {
    background: #218838;
    transform: translateY(-2px);
}

.camera-btn-danger {
    background: #dc3545;
    color: white;
}

.camera-btn-danger:hover {
    background: #c82333;
    transform: translateY(-2px);
}

.upload-options {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.upload-option-btn {
    padding: 12px 24px;
    border: 2px solid #667eea;
    border-radius: 25px;
    background: white;
    color: #667eea;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.upload-option-btn:hover {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.camera-error {
    background: #f8d7da;
    color: #721c24;
    padding: 15px;
    border-radius: 10px;
    margin: 15px 0;
    text-align: center;
    border: 1px solid #f5c6cb;
}

.camera-loading {
    text-align: center;
    padding: 20px;
    color: #667eea;
}

.camera-loading i {
    font-size: 2rem;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    .header h1 {
        font-size: 2rem;
    }

    .nav-tabs {
        flex-direction: column;
    }

    .tab-content {
        padding: 2px;
    }

    .row {
        flex-direction: column;
    }

    .camera-container {
        padding: 15px;
        margin: 10px;
    }

    .camera-controls {
        flex-direction: column;
        width: 100%;
    }

    .camera-btn {
        width: 100%;
        justify-content: center;
    }

    .upload-options {
        flex-direction: column;
    }

    .upload-option-btn {
        width: 100%;
        justify-content: center;
    }
}

/* 更紧凑的按钮样式，针对小于等于480px的设备 */
@media (max-width: 480px) {
    .camera-controls {
        gap: 8px;
        padding-bottom: 6px;
    }

    .camera-btn {
        padding: 8px 12px;
        font-size: 0.9rem;
        border-radius: 16px;
        gap: 6px;
        min-height: 36px;
    }

    .camera-btn i {
        font-size: 0.95rem; /* 图标稍微缩小 */
    }

    .camera-btn-primary, .camera-btn-secondary, .camera-btn-success, .camera-btn-danger {
        padding: 8px 12px;
    }
}

/* ✅ 右上角消息容器 */
.message-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    width: 320px;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none; /* 防止遮挡下方按钮 */
}

/* ✅ 消息项样式 */
.message-item {
    background-color: white;
    border-left: 4px solid;
    padding: 12px 16px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: slideIn 0.3s ease-out;
    position: relative;
    pointer-events: all; /* 允许点击关闭按钮 */
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.message-item.alert-success {
    border-color: #28a745;
    color: #155724;
    background-color: #d4edda;
}

.message-item.alert-danger {
    border-color: #dc3545;
    color: #721c24;
    background-color: #f8d7da;
}

.message-item .close-btn {
    background: none;
    border: none;
    font-size: 18px;
    font-weight: bold;
    color: #666;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    margin-left: 10px;
    opacity: 0.8;
}

.message-item .close-btn:hover {
    opacity: 1;
}

/* ✅ 动画：从右上角滑入 */
@keyframes slideIn {
    from {
        transform: translateX(100px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ✅ 自动消失（3秒后） */
.message-item[data-duration] {
    transition: opacity 0.3s ease-out;
}

.message-item[data-duration]::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    background: #007bff;
    animation: progress 3s linear forwards;
}

@keyframes progress {
    from { width: 100%; }
    to { width: 0; }
}

/* ✅ 如果有多个消息，自动向上堆叠 */
.message-container > .message-item:nth-child(n+2) {
    margin-top: -40px;
}

/* 分页控件美化 */
.pagination {
    display: flex; /* script may toggle display, keep flex as default */
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 20px;
    padding: 8px 12px;
    background: linear-gradient(180deg, rgba(255,255,255,0.6), rgba(245,245,245,0.6));
    border-radius: 12px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.06);
}

.pagination .btn {
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 0.95rem;
    min-width: 84px;
}

.pagination .btn i { margin-right: 6px; }

.pagination .btn[disabled] {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.pagination #page-info {
    font-size: 0.95rem;
    color: #495057;
    padding: 6px 10px;
    border-radius: 8px;
}

@media (max-width: 600px) {
    .pagination { gap: 8px; padding: 6px; }
    .pagination .btn { padding: 6px 10px; min-width: 64px; font-size: 0.9rem; }
    .pagination #page-info { font-size: 0.85rem; }
}

.copyright {
    color: var(--text-text_tertiary);
    display: flex;
    font-size: 12px;
    justify-content: center;
    line-height: 18px;
    position: absolute;
    text-align: center;
    /* top: 50%;
    transform: translateY(-50%); */
    white-space: nowrap;
    width: 100%;
    z-index: 99;
    left: 50%; /* 先移动到父容器50%位置 */
    transform: translateX(-50%); /* 再向左回退自身宽度的50% */
}
.copyright__item
{
    align-items: center;
    display: flex;
    flex: none;
}

