* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ========== 深色模式基础样式 ========== */
html.dark {
    background: #0f172a;
    color: #e2e8f0;
}

html.dark body {
    background: #0f172a;
}

body {
    font-family: 'Segoe UI', 'Roboto', 'Noto Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #f8fafc;
}

/* ========== 固定顶部工具栏 ========== */
.toolbar {
    background: white;
    border-bottom: 1px solid #e2e8f0;
    padding: 2px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    z-index: 100;
    flex-shrink: 0;
    transition: background 0.2s, border-color 0.2s;
}

html.dark .toolbar {
    background: #1e293b;
    border-bottom-color: #334155;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.toolbar-left h1 {
    font-size: 1.4rem;
    font-weight: 600;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    display: flex;
    align-items: center;
    gap: 8px;
}

.toolbar-left h1 i {
    background: none;
    -webkit-background-clip: unset;
    background-clip: unset;
    color: #667eea;
}

html.dark .toolbar-left h1 i {
    color: #8b5cf6;
}

.badge {
    background: #e9ecef;
    padding: 4px 12px;
    border-radius: 30px;
    font-size: 0.8rem;
    font-weight: 500;
    color: #2c3e50;
    transition: background 0.2s, color 0.2s;
}

html.dark .badge {
    background: #334155;
    color: #cbd5e1;
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

/* 搜索框 */
.search-box {
    position: relative;
    min-width: 280px;
}

.search-box i:first-child {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 0.9rem;
}

html.dark .search-box i:first-child {
    color: #64748b;
}

.search-box input {
    width: 100%;
    padding: 8px 32px 8px 36px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    font-size: 0.9rem;
    transition: all 0.2s;
    background: #f8fafc;
    color: #1e293b;
}

html.dark .search-box input {
    background: #0f172a;
    border-color: #475569;
    color: #e2e8f0;
}

html.dark .search-box input::placeholder {
    color: #64748b;
}

.search-box input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

html.dark .search-box input:focus {
    border-color: #8b5cf6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

.clear-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: #94a3b8;
    padding: 4px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.clear-btn:hover {
    color: #e53e3e;
}

html.dark .clear-btn:hover {
    color: #f87171;
}

/* 筛选下拉 */
.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f8fafc;
    padding: 4px 12px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    transition: background 0.2s, border-color 0.2s;
}

html.dark .filter-group {
    background: #0f172a;
    border-color: #475569;
}

.filter-group i {
    color: #667eea;
    font-size: 0.9rem;
}

html.dark .filter-group i {
    color: #8b5cf6;
}

.filter-group select {
    border: none;
    background: transparent;
    padding: 6px 8px;
    font-size: 0.9rem;
    cursor: pointer;
    outline: none;
    color: #1e293b;
}

html.dark .filter-group select {
    color: #e2e8f0;
}

.filter-group select option {
    background: white;
    color: #1e293b;
}

html.dark .filter-group select option {
    background: #1e293b;
    color: #e2e8f0;
}

/* 导出按钮 */
#exportBtn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: transform 0.1s, opacity 0.2s;
}

#exportBtn:hover {
    opacity: 0.9;
    transform: scale(0.98);
}

/* ========== 表格容器 - 可滚动区域 ========== */
.table-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
    position: relative;
    background: white;
    transition: background 0.2s;
}

html.dark .table-container {
    background: #0f172a;
}

/* 表格样式 */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    min-width: 900px;
}

thead {
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 1px 0 #e2e8f0;
}

html.dark thead {
    box-shadow: 0 1px 0 #334155;
}

th {
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
    color: #1e293b;
    background: #fafcff;
    border-bottom: 2px solid #e2e8f0;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}

html.dark th {
    background: #1e293b;
    color: #e2e8f0;
    border-bottom-color: #334155;
}

th:hover {
    background: #f1f5f9;
}

html.dark th:hover {
    background: #334155;
}

th span {
    margin-right: 6px;
}

th i {
    font-size: 0.75rem;
    color: #94a3b8;
    transition: color 0.1s;
}

html.dark th i {
    color: #64748b;
}

th.asc i,
th.desc i {
    color: #667eea;
}

html.dark th.asc i,
html.dark th.desc i {
    color: #8b5cf6;
}

th.asc i {
    transform: rotate(180deg);
    display: inline-block;
}

td {
    padding: 5px;
    border-bottom: 1px solid #f0f2f5;
    color: #334155;
    vertical-align: top;
    line-height: 1.5;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}

html.dark td {
    border-bottom-color: #1e293b;
    color: #cbd5e1;
}

tbody tr:hover {
    background: #fef9e7;
}

html.dark tbody tr:hover {
    background: #334155;
}

/* 语法点列 - 代码样式 */
td:nth-child(2) code {
    background: #f1f5f9;
    padding: 2px 8px;
    border-radius: 6px;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.8rem;
    color: #d946ef;
    display: inline-block;
    transition: background 0.2s;
}

html.dark td:nth-child(2) code {
    background: #0f172a;
    color: #c084fc;
}

/* 课程标签 */
.lesson-badge {
    display: inline-block;
    background: #eef2ff;
    color: #4f46e5;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    text-align: center;
    min-width: 55px;
    transition: background 0.2s, color 0.2s;
}

html.dark .lesson-badge {
    background: #334155;
    color: #a78bfa;
}

/* 例句列 - 适当留白 */
td:nth-child(4) {
    color: #475569;
    font-style: normal;
    max-width: 500px;
    word-break: break-word;
}

html.dark td:nth-child(4) {
    color: #94a3b8;
}

/* 加载状态 */
.loading-row td {
    text-align: center;
    padding: 80px 20px;
    background: white;
}

html.dark .loading-row td {
    background: #0f172a;
}

.loading-spinner {
    display: inline-block;
    width: 28px;
    height: 28px;
    border: 3px solid #e2e8f0;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 12px;
    vertical-align: middle;
}

html.dark .loading-spinner {
    border-color: #334155;
    border-top-color: #8b5cf6;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* 空状态 */
.empty-state td {
    text-align: center;
    padding: 80px 20px;
    color: #94a3b8;
}

html.dark .empty-state td {
    color: #64748b;
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    display: block;
    color: #cbd5e1;
}

html.dark .empty-state i {
    color: #475569;
}

/* ========== 底部固定栏 ========== */
.footer-bar {
    background: white;
    border-top: 1px solid #e2e8f0;
    padding: 10px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: #64748b;
    flex-shrink: 0;
    z-index: 100;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}

html.dark .footer-bar {
    background: #1e293b;
    border-top-color: #334155;
    color: #94a3b8;
}

.footer-info {
    display: flex;
    gap: 20px;
}

.footer-info i {
    margin-right: 6px;
    color: #94a3b8;
}

html.dark .footer-info i {
    color: #64748b;
}

.footer-info strong {
    color: #4f46e5;
    font-weight: 600;
}

html.dark .footer-info strong {
    color: #a78bfa;
}

.separator {
    width: 1px;
    height: 14px;
    background: #e2e8f0;
    margin: 0 4px;
}

html.dark .separator {
    background: #334155;
}

.footer-tip {
    display: flex;
    align-items: center;
    gap: 8px;
}

.footer-tip i {
    font-size: 0.7rem;
    color: #94a3b8;
}

html.dark .footer-tip i {
    color: #64748b;
}

/* ========== 滚动条美化 ========== */
.table-container::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.table-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

html.dark .table-container::-webkit-scrollbar-track {
    background: #1e293b;
}

.table-container::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

html.dark .table-container::-webkit-scrollbar-thumb {
    background: #475569;
}

.table-container::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

html.dark .table-container::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

.edge-padding {
    height: 70px;
}

/* ========== 响应式 ========== */
@media (max-width: 768px) {
    .toolbar {
        flex-direction: column;
        align-items: stretch;
        padding: 2px;
    }

    .toolbar-left {
        justify-content: space-between;
    }

    .toolbar-right {
        flex-direction: column;
        align-items: stretch;
    }

    .search-box {
        min-width: auto;
    }

    .footer-bar {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }

    th,
    td {
        padding: 5px;
    }
}