* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

/* 固定黑色模式全局样式 */
body {
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', 'Noto Sans', sans-serif;
    background-color: #0a0c10;
    color: #e8edf5;
    line-height: 1.5;
    padding: 0 0 2rem 0;
    overflow-y: scroll;
    overflow-x: hidden;
}

a {
    color: #8ab3f0;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
    border-bottom: 1px solid transparent;
}

a:hover {
    color: #b8d4ff;
    border-bottom-color: #6a8fc8;
}

a:active {
    color: #6d9eef;
}

a:visited {
    color: #9b7bcb;
}

/* 针对不同状态的链接保持一致性 */
a:link,
a:visited,
a:hover,
a:active {
    text-decoration: none;
}

/* 主容器 */
#app {
    width: 100%;
    display: flex;
    flex-direction: column;
}

.bar {
    position: fixed;
    width: 100%;
    z-index: 2;
}

/* 统计栏 - 深色 */
.stats-bar {
    background: #0f1117;
    padding: 0.7rem 1.5rem;
    border-bottom: 1px solid #1f2a3a;
    font-size: 0.85rem;
    color: #cbd5e6;
    font-weight: 500;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
}

/* 搜索过滤区域 深色 */
.controls {
    padding: 1rem 1.5rem;
    background: #0f1117;
    border-bottom: 1px solid #1f2a3a;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.search-box {
    flex: 2;
    min-width: 180px;
    position: relative;
}

.search-box input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #2a3448;
    border-radius: 44px;
    font-size: 0.9rem;
    background-color: #131720;
    color: #eef3ff;
    transition: 0.2s;
    outline: none;
    font-family: inherit;
}

.search-box input::placeholder {
    color: #6f7c9a;
}

.search-box input:focus {
    border-color: #5f7eb0;
    box-shadow: 0 0 0 3px rgba(80, 120, 180, 0.2);
    background-color: #181e2a;
}

.clear-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: #94a3b8;
    font-size: 1.3rem;
    font-weight: 600;
    padding: 4px 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.level-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.level-badge {
    background: #1a1f2c;
    padding: 6px 16px;
    border-radius: 40px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    color: #bfcef0;
    border: 1px solid #2a344a;
}

.level-badge.active {
    background: #2c4c8c;
    color: white;
    border-color: #4a7cbc;
    box-shadow: 0 2px 8px rgba(40, 80, 140, 0.3);
}

.level-badge.reset-btn {
    background: #1a1f2c;
    border: 1px solid #2f3b54;
}

.level-badge.reset-btn.active {
    background: #4a5a7c;
    border-color: #6c82ac;
    color: white;
}

/* 卡片网格 */
.grammar-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 1.2rem;
    margin-top: 110px;
    padding: 1.5rem;
}

/* 卡片样式 - 深色优雅 */
.grammar-card {
    background: #12161f;
    border-radius: 20px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
    transition: all 0.2s ease;
    border: 1px solid #232a38;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.grammar-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px -8px rgba(0, 0, 0, 0.6);
    border-color: #3a465e;
    background: #141b26;
}

.card-header {
    padding: 1rem 1.2rem 0.6rem 1.2rem;
    border-bottom: 2px solid #1e2636;
    display: flex;
    flex-direction: column;
    flex-wrap: wrap;
    gap: 8px;
}

.title-section {
    display: flex;
    align-items: center;
    gap: 10px;
}

.title {
    font-size: 1.35rem;
    font-weight: 700;
    color: #dee9ff;
    letter-spacing: -0.2px;
    word-break: break-word;
}

.info-section {
    display: flex;
    align-items: center;
    gap: 10px;
}

.kana {
    font-size: 0.8rem;
}

.level-tag {
    font-size: 0.7rem;
    font-weight: 600;
    background: #1f2a40;
    padding: 2px 4px;
    color: #aac4f0;
    text-transform: uppercase;
}

.meaning {
    padding: 0.4rem 1.2rem;
    font-size: 1rem;
    font-weight: 500;
    color: #cfdff5;
    border-left: 3px solid #3f6b9e;
    margin: 0.4rem 0 0 1rem;
    background: #0e1320;
}

.example-section {
    padding: 0.5rem 1.2rem 1.2rem 1.2rem;
    margin-top: 4px;
}

.example-text {
    background: #0a0f18;
    padding: 10px 12px;
    border-radius: 14px;
    font-size: 0.9rem;
    font-family: 'SF Mono', 'Menlo', 'Cascadia Code', monospace;
    color: #dfeaff;
    border: 1px solid #242e42;
    word-break: break-word;
    white-space: pre-wrap;
}

.no-results {
    text-align: center;
    padding: 3rem 1.5rem;
    color: #8a9ac0;
    font-size: 1rem;
    grid-column: 1 / -1;
}

.error-message {
    text-align: center;
    padding: 2rem;
    margin: 2rem;
    border-radius: 24px;
    color: #f3a683;
    border: 1px solid #542e2e;
    background-color: #1a121c;
}

@media (max-width: 640px) {
    .grammar-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
        margin-top: 145px;
        padding: 1rem;
    }

    .controls {
        padding: 0.8rem 1rem;
    }

    .stats-bar {
        padding: 0.6rem 1rem;
    }

    .title {
        font-size: 1.2rem;
    }

    .meaning {
        font-size: 0.9rem;
    }

    .level-badge {
        padding: 4px 12px; /* 减小内边距 */
        font-size: 0.7rem; /* 减小字体 */
        border-radius: 30px; /* 稍微减小圆角 */
    }
}

@media (max-width: 480px) {
    .level-filter {
        width: 100%;
        justify-content: flex-start;
    }

    .search-box {
        width: 100%;
    }
}

.loading {
    text-align: center;
    padding: 3rem;
    color: #9aacd4;
}