/* ========== 全局样式 ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', 'Arial', 'Microsoft YaHei', sans-serif;
    background: linear-gradient(135deg, #f4f6f9 0%, #e8ecf1 100%);
    min-height: 100vh;
}

/* ========== 头部 ========== */
header {
    background: linear-gradient(135deg, #1976d2 0%, #0d47a1 100%);
    color: white;
    text-align: center;
    padding: 30px 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

header h1 {
    font-size: 2rem;
    margin-bottom: 8px;
}

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

/* ========== 主容器 ========== */
main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* ========== 卡片盒子 ========== */
.box {
    background: white;
    padding: 24px;
    margin-bottom: 24px;
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    transition: transform 0.2s, box-shadow 0.2s;
}

.box:hover {
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

.box h2 {
    color: #1976d2;
    margin-bottom: 16px;
    font-size: 1.4rem;
    border-left: 4px solid #1976d2;
    padding-left: 12px;
}

/* ========== 输入区域 ========== */
textarea {
    width: 100%;
    height: 140px;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
    transition: border-color 0.2s;
}

textarea:focus {
    outline: none;
    border-color: #1976d2;
}

.upload-area {
    margin: 12px 0;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.upload-label {
    background: #f5f5f5;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

.upload-label:hover {
    background: #e0e0e0;
}

input[type="file"] {
    display: none;
}

.file-name {
    font-size: 13px;
    color: #666;
}

.button-group {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 12px;
}

/* ========== 按钮样式 ========== */
button {
    padding: 10px 20px;
    background: #1976d2;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

button:hover {
    background: #0d47a1;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(25,118,210,0.3);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    background: #9e9e9e;
    cursor: not-allowed;
    transform: none;
}

.danger-btn {
    background: #f57c00;
}

.danger-btn:hover {
    background: #e65100;
}

/* ========== 解析结果卡片 ========== */
.result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 16px;
}

.card {
    background: #fafbfc;
    border-radius: 12px;
    padding: 16px;
    transition: all 0.2s;
    border: 1px solid #edf2f7;
}

.card:hover {
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    border-color: #1976d2;
}

.card h3 {
    color: #1976d2;
    font-size: 1rem;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.card p {
    line-height: 1.6;
    color: #2d3748;
    font-size: 14px;
    white-space: pre-wrap;
    word-break: break-word;
}

/* ========== 错题本样式 ========== */
.notebook-header {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

#searchInput {
    flex: 1;
    padding: 12px 16px;
    border-radius: 40px;
    border: 2px solid #e0e0e0;
    font-size: 14px;
    transition: all 0.2s;
}

#searchInput:focus {
    outline: none;
    border-color: #1976d2;
    box-shadow: 0 0 0 3px rgba(25,118,210,0.1);
}

#notebookList {
    max-height: 500px;
    overflow-y: auto;
}

#notebookList .card {
    background: white;
    margin-bottom: 12px;
}

#notebookList .card p {
    margin: 8px 0;
}

.deleteBtn {
    background: #d32f2f;
    padding: 6px 14px;
    font-size: 12px;
    margin-top: 8px;
}

.deleteBtn:hover {
    background: #b71c1c;
}

/* ========== 统计图表 ========== */
#categoryChart {
    max-width: 400px;
    margin: 16px auto;
    display: block;
}

/* ========== 页脚 ========== */
footer {
    text-align: center;
    padding: 24px;
    color: #666;
    font-size: 12px;
    border-top: 1px solid #e0e0e0;
    margin-top: 20px;
}

/* ========== 滚动条美化 ========== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: #1976d2;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #0d47a1;
}

/* ========== 加载动画 ========== */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.loading {
    animation: pulse 1.5s ease-in-out infinite;
}

/* ========== 响应式设计 ========== */
@media (max-width: 768px) {
    main {
        padding: 12px;
    }
    
    .box {
        padding: 16px;
    }
    
    header h1 {
        font-size: 1.5rem;
    }
    
    button {
        padding: 8px 16px;
        font-size: 13px;
    }
    
    .result-grid {
        grid-template-columns: 1fr;
    }
}
/* 让错题本和统计图表两列并排显示 */
@media (min-width: 768px) {
    .notebook-stats-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 24px;
    }
}