/* ===== 全局样式 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}
body {
    background: #0d1117;
    color: #e6edf3;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== 导航栏 ===== */
.navbar {
    background: #161b22;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #30363d;
    flex-wrap: wrap;
}
.navbar a {
    color: #8b949e;
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 6px;
    transition: all 0.2s;
}
.navbar a:hover {
    color: #fff;
    background: #21262d;
}
.logo {
    font-size: 1.2rem;
    font-weight: 600;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}
.logo i {
    color: #58a6ff;
}
.search-form {
    display: flex;
    background: #21262d;
    border-radius: 20px;
    padding: 4px 10px;
}
.search-form input {
    background: transparent;
    border: none;
    color: #fff;
    padding: 6px 8px;
    outline: none;
    width: 200px;
}
.search-form button {
    background: transparent;
    border: none;
    color: #58a6ff;
    cursor: pointer;
}

/* ===== 容器 ===== */
.container {
    max-width: 1280px;
    margin: 20px auto;
    padding: 0 20px;
    flex: 1;
    width: 100%;
}

/* ===== 页面头部 ===== */
.page-header {
    margin-bottom: 24px;
    border-bottom: 2px solid #30363d;
    padding-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.page-header i {
    color: #58a6ff;
    background: rgba(88,166,255,0.1);
    padding: 12px;
    border-radius: 12px;
    font-size: 1.5rem;
}
.page-header h1 {
    margin: 0;
    font-size: 1.8rem;
    color: #f0f6fc;
}
.page-header h2 {
    margin: 0;
    font-size: 1.4rem;
    color: #f0f6fc;
}

/* ===== 卡片样式 ===== */
.card {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    transition: all 0.2s;
}
.card:hover {
    border-color: #58a6ff;
}
.card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    border-bottom: 1px solid #30363d;
    padding-bottom: 16px;
}
.card-header i {
    font-size: 1.5rem;
    color: #58a6ff;
    background: rgba(88,166,255,0.1);
    padding: 10px;
    border-radius: 10px;
}
.card-header h2 {
    margin: 0;
    font-size: 1.3rem;
    color: #e6edf3;
}
.card-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: #e6edf3;
}

/* ===== 卡片网格 ===== */
.grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}
.grid-cards .card {
    display: flex;
    flex-direction: column;
    transition: transform 0.2s;
}
.grid-cards .card:hover {
    transform: translateY(-4px);
}

/* ===== 仪表盘卡片 ===== */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-top: 20px;
}
.dashboard-card {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 16px;
    padding: 24px 16px;
    text-align: center;
    color: #fff;
    text-decoration: none;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.dashboard-card:hover {
    background: #21262d;
    transform: translateY(-4px);
    border-color: #58a6ff;
}
.dashboard-card i {
    font-size: 2.5rem;
    color: #58a6ff;
    background: rgba(88,166,255,0.1);
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 32px;
}
.dashboard-card span {
    font-size: 1.1rem;
    font-weight: 500;
}
.dashboard-card small {
    color: #8b949e;
    font-size: 0.85rem;
}

/* ===== 表格 ===== */
.table-responsive {
    overflow-x: auto;
    margin: 20px 0;
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 12px;
    padding: 16px;
}
table {
    width: 100%;
    border-collapse: collapse;
}
th {
    background: #21262d;
    padding: 12px;
    text-align: left;
    color: #8b949e;
    font-weight: 500;
    font-size: 0.9rem;
}
td {
    padding: 12px;
    border-bottom: 1px solid #30363d;
    color: #e6edf3;
}
tr:hover td {
    background: #21262d;
}

/* ===== 按钮 ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #238636;
    color: #fff;
    padding: 8px 16px;
    border-radius: 8px;
    text-decoration: none;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
}
.btn:hover {
    background: #2ea043;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(35,134,54,0.3);
}
.btn-danger {
    background: #da3633;
}
.btn-danger:hover {
    background: #f85149;
}
.btn-sm {
    padding: 4px 10px;
    font-size: 0.8rem;
}
.btn-outline {
    background: transparent;
    border: 1px solid #58a6ff;
    color: #58a6ff;
}
.btn-outline:hover {
    background: #58a6ff;
    color: #fff;
}

/* ===== 表单 ===== */
.form-group {
    margin-bottom: 20px;
}
label {
    display: block;
    color: #8b949e;
    font-size: 0.9rem;
    margin-bottom: 6px;
    font-weight: 500;
}
label i {
    color: #58a6ff;
    margin-right: 6px;
}
.form-control {
    width: 100%;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 8px;
    color: #e6edf3;
    padding: 10px 14px;
    font-size: 0.95rem;
    transition: all 0.2s;
}
.form-control:focus {
    outline: none;
    border-color: #58a6ff;
    box-shadow: 0 0 0 3px rgba(88,166,255,0.1);
}
.form-control:hover {
    border-color: #6e7681;
}
textarea.form-control {
    resize: vertical;
    min-height: 100px;
}
select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238b949e' 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");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
}
.help-text {
    color: #8b949e;
    font-size: 0.85rem;
    margin-top: 6px;
}

/* ===== 分页 ===== */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 30px 0;
    list-style: none;
}
.pagination li a, .pagination li span {
    display: block;
    padding: 8px 14px;
    background: #21262d;
    color: #e6edf3;
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.2s;
}
.pagination li.active span {
    background: #238636;
}
.pagination li a:hover {
    background: #30363d;
}

/* ===== 标签 ===== */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}
.badge-primary {
    background: rgba(88,166,255,0.1);
    color: #58a6ff;
    border: 1px solid rgba(88,166,255,0.3);
}
.badge-success {
    background: rgba(46,160,67,0.1);
    color: #2ea043;
    border: 1px solid rgba(46,160,67,0.3);
}
.badge-warning {
    background: rgba(240,136,62,0.1);
    color: #f0883e;
    border: 1px solid rgba(240,136,62,0.3);
}
.badge-danger {
    background: rgba(248,81,73,0.1);
    color: #f85149;
    border: 1px solid rgba(248,81,73,0.3);
}

/* ===== 辅助类 ===== */
.flex {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
}
.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}
.mt-4 {
    margin-top: 24px;
}
.mb-4 {
    margin-bottom: 24px;
}
.text-center {
    text-align: center;
}
.text-right {
    text-align: right;
}

/* ===== 知识点标签 ===== */
.knowledge-tag {
    display: inline-flex;
    align-items: center;
    background: #21262d;
    border: 1px solid #30363d;
    border-radius: 30px;
    padding: 4px 12px;
    margin: 4px;
    font-size: 0.9rem;
}
.knowledge-tag .remove {
    margin-left: 8px;
    color: #da3633;
    cursor: pointer;
}
.add-knowledge-panel {
    background: #21262d;
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 16px;
    margin-top: 12px;
}

/* ===== 首页卡片样式 ===== */
.home-card-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 20px;
}
.home-card-grid .list-item {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 12px;
    padding: 24px;
    transition: all 0.2s;
}
.home-card-grid .list-item:hover {
    background: #21262d;
    border-color: #58a6ff;
}
.home-card-grid .list-item .question-title {
    color: #fff;
    font-size: 1.3rem;
    margin-bottom: 16px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    line-height: normal;
    height: auto;
}

/* 题型标签 */
.type-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
}
.type-single {
    background: rgba(88,166,255,0.15);
    color: #58a6ff;
    border: 1px solid rgba(88,166,255,0.3);
}
.type-multiple {
    background: rgba(126,224,126,0.15);
    color: #7ee07e;
    border: 1px solid rgba(126,224,126,0.3);
}
.type-badge i {
    font-size: 0.75rem;
}

.home-card-grid .options {
    color: #fff;
    margin-bottom: 16px;
    line-height: 1.8;
    background: #21262d;
    border-radius: 8px;
    padding: 12px 16px;
}
.home-card-grid .options > div {
    padding: 4px 0;
}
.home-card-grid .meta {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.home-card-grid .difficulty {
    color: #ff7b72;
    background: rgba(255,123,114,0.1);
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid rgba(255,123,114,0.3);
    font-size: 0.9rem;
}
.home-card-grid .rit {
    color: #7ee07e;
    background: rgba(126,224,126,0.1);
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid rgba(126,224,126,0.3);
    font-size: 0.9rem;
}
.home-card-grid .chapter {
    color: #8b949e;
    background: #21262d;
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid #30363d;
    font-size: 0.9rem;
}
.home-card-grid .solution {
    display: none;
    background: #21262d;
    border-left: 3px solid #58a6ff;
    padding: 16px;
    border-radius: 8px;
    margin-top: 16px;
    color: #fff;
}
.home-card-grid .card.show-solution .solution {
    display: block;
}
.show-solution-btn {
    background: transparent;
    border: 1px solid #58a6ff;
    color: #58a6ff;
    padding: 6px 16px;
    border-radius: 30px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}
.show-solution-btn:hover {
    background: #58a6ff;
    color: #fff;
}

/* ===== 筛选栏 ===== */
.filter-bar {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 30px;
}
.filter-bar select {
    background: #21262d;
    border: 1px solid #30363d;
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    width: 100%;
}

/* ===== 修复公式显示不全的问题（强化版）===== */
mjx-container,
mjx-container[jax="CHTML"],
.math,
.card .options,
.card .solution,
.question-title,
.options-container,
.answer-options,
.mistake-options,
.card-options,
.list-item .options,
.list-item .solution,
.home-card-grid .options,
.home-card-grid .solution,
.profile .answer-options,
.detail-stats,
.answer-card .question-title,
.answer-card .answer-options,
.answer-card .solution-section {
    line-height: normal !important;
    min-height: unset !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
}

/* 确保所有卡片容器不限制高度 */
.card,
.list-item,
.answer-card,
.home-card-grid .list-item {
    height: auto !important;
    min-height: unset !important;
    overflow: visible !important;
}

/* 给公式容器适当的外边距，避免重叠 */
mjx-container {
    margin: 0.2em 0 !important;
    display: inline-block !important;
    vertical-align: middle !important;
}

/* 确保flex容器不会压缩内容 */
.flex,
.meta,
.answer-meta,
.card-meta {
    flex-wrap: wrap !important;
    align-items: center !important;
    height: auto !important;
}

/* ===== 选项分列布局 ===== */
.options,
.card-options,
.mistake-options,
.answer-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px 20px;
    font-size: 1.2rem; /* 与题干字号保持一致 */
    line-height: 1.6;
}

.options > div,
.card-options > div,
.mistake-options > div,
.answer-options > div {
    padding: 4px 0;
    word-break: break-word;
}

/* 如果选项包含 strong 标签（选项字母），保持加粗 */
.options > div strong,
.card-options > div strong,
.mistake-options > div strong,
.answer-options > div strong {
    font-weight: 600;
    margin-right: 4px;
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
        gap: 12px;
    }
    .navbar .search-form {
        width: 100%;
    }
    .navbar .search-form input {
        width: 100%;
    }
    .page-header h1 {
        font-size: 1.5rem;
    }
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}