/* ========================================================
   WordBank 日语单词本 · 全局样式
   ======================================================== */

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

html, body { min-height: 100%; }

body {
    font-family: 'Hiragino Sans', 'Yu Gothic', 'Microsoft YaHei UI',
                 'Segoe UI', 'PingFang SC', 'Noto Sans CJK SC', sans-serif;
    line-height: 1.6;
    color: #233142;
    background: #f5f7fb;
}

.hidden { display: none !important; }

/* ---------- 头部 ---------- */
#header {
    background: linear-gradient(135deg, #6366f1 0%, #ec4899 100%);
    color: #fff;
    padding: 1.5rem 1rem 1.2rem;
    text-align: center;
}
#header h1 {
    font-size: 2rem;
    letter-spacing: 1px;
}
#header h1 .sub {
    font-size: 1rem;
    font-weight: 400;
    opacity: 0.9;
    margin-left: 0.5rem;
}
#header > p {
    opacity: 0.92;
    margin: 0.3rem 0 1rem;
}
.deck-switcher {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255,255,255,0.15);
    padding: 0.4rem 0.7rem;
    border-radius: 8px;
    backdrop-filter: blur(6px);
}
.deck-switcher-label { font-size: 0.9rem; opacity: 0.9; }
.deck-switcher select {
    padding: 0.3rem 0.5rem;
    border: none;
    border-radius: 6px;
    background: #fff;
    color: #333;
    min-width: 180px;
}

/* ---------- 导航 ---------- */
#nav {
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    position: sticky;
    top: 0;
    z-index: 50;
}
#nav ul {
    display: flex;
    flex-wrap: wrap;
    list-style: none;
    max-width: 1200px;
    margin: 0 auto;
}
#nav li { flex: 1 1 120px; }
#nav a {
    display: block;
    padding: 0.9rem 0.4rem;
    text-align: center;
    color: #556075;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    border-bottom: 3px solid transparent;
    transition: all 0.2s ease;
}
#nav a:hover   { background: #f3f4ff; color: #4f46e5; }
#nav a.active  { color: #4f46e5; border-bottom-color: #6366f1; background: #f9faff; }

/* ---------- 主体 ---------- */
#main {
    max-width: 1200px;
    margin: 1.5rem auto;
    padding: 0 1rem;
    min-height: 62vh;
}
.page {
    display: none;
    background: #fff;
    border-radius: 14px;
    padding: 1.8rem;
    box-shadow: 0 4px 20px rgba(15,23,42,0.04);
}
.page.active { display: block; }
.page h2 {
    font-size: 1.5rem;
    color: #1e293b;
    margin-bottom: 1.2rem;
    padding-bottom: 0.6rem;
    border-bottom: 2px solid #eef2ff;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.deck-name-tag {
    display: inline-block;
    padding: 0.15rem 0.6rem;
    font-size: 0.85rem;
    border-radius: 999px;
    background: #eef2ff;
    color: #4f46e5;
    border: 1px solid #c7d2fe;
    font-weight: 500;
}

/* ---------- 通用按钮 ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.55rem 1rem;
    background: #6366f1;
    color: #fff;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s;
}
.btn:hover:not(:disabled)   { background: #4f46e5; transform: translateY(-1px); }
.btn:disabled               { opacity: 0.45; cursor: not-allowed; }
.btn-mini                   { padding: 0.3rem 0.65rem; font-size: 0.82rem; border-radius: 6px; }
.btn-secondary              { background: #94a3b8; }
.btn-secondary:hover:not(:disabled) { background: #64748b; }
.btn-danger                 { background: #ef4444; }
.btn-danger:hover:not(:disabled)    { background: #dc2626; }
.btn-warning                { background: #f59e0b; }
.btn-warning:hover:not(:disabled)   { background: #d97706; }
.btn-success                { background: #10b981; }
.btn-success:hover:not(:disabled)   { background: #059669; }

/* ---------- 通用表单 ---------- */
.form-group { margin-bottom: 1rem; }
.form-group label {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 500;
    color: #334155;
    font-size: 0.92rem;
}
.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.55rem 0.7rem;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fafbff;
    font-size: 0.95rem;
    color: #0f172a;
    font-family: inherit;
    transition: border 0.15s, box-shadow 0.15s;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #6366f1;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}
.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}
.form-row > .form-group { flex: 1 1 180px; margin-bottom: 0.8rem; }
.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem;
    margin-top: 1.2rem;
}
.muted      { color: #94a3b8; }
.muted-small{ color: #94a3b8; font-size: 0.82rem; }

/* ---------- 通用卡片 ---------- */
.card {
    background: #fafbff;
    border: 1px solid #eef2ff;
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 1rem;
}

/* ---------- 首页 ---------- */
.home-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
}
.home-stats .card {
    text-align: center;
    background: linear-gradient(135deg, #ffffff, #f3f4ff);
    border-color: #e0e7ff;
}
.home-stats h3 { font-size: 0.95rem; color: #475569; margin-bottom: 0.2rem; font-weight: 500; }
.big-number {
    font-size: 2.2rem;
    font-weight: 700;
    color: #4f46e5;
    margin: 0.4rem 0;
    line-height: 1;
}

.home-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem;
    margin: 1.2rem 0;
}

.home-section {
    margin-top: 1.8rem;
    padding: 1.2rem 1.3rem;
    background: #f8fafc;
    border-radius: 12px;
    border-left: 4px solid #6366f1;
}
.home-section h3 { font-size: 1.1rem; margin-bottom: 0.6rem; color: #1e293b; }
.tips-list { padding-left: 1.4rem; line-height: 2; color: #475569; }

/* 首页词库卡片 */
.home-deck-card {
    cursor: pointer;
    padding: 1rem 1.1rem;
    border-radius: 12px;
    border: 2px solid transparent;
    background: #fff;
    box-shadow: 0 2px 8px rgba(15,23,42,0.04);
    transition: transform 0.15s, border-color 0.15s;
    border-color: color-mix(in srgb, var(--dc, #6366f1) 20%, #fff);
}
.home-deck-card:hover { transform: translateY(-2px); border-color: var(--dc, #6366f1); }
.home-deck-card.current { border-color: var(--dc, #6366f1); background: color-mix(in srgb, var(--dc, #6366f1) 6%, #fff); }
.hdc-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.3rem;
}
.hdc-head h4 { font-size: 1rem; color: #0f172a; }
.dot-current {
    background: var(--dc, #6366f1);
    color: #fff;
    padding: 0.1rem 0.5rem;
    font-size: 0.75rem;
    border-radius: 999px;
    font-weight: 500;
}
.hdc-desc { font-size: 0.85rem; color: #64748b; margin-bottom: 0.8rem; min-height: 1.2rem; }
.hdc-stat {
    display: flex;
    gap: 0.8rem;
}
.hdc-stat > div {
    flex: 1;
    text-align: center;
    background: #fff;
    padding: 0.4rem;
    border-radius: 8px;
    border: 1px solid #f1f5f9;
}
.hdc-stat b { display: block; font-size: 1.05rem; color: #1e293b; }
.hdc-stat small { font-size: 0.72rem; color: #94a3b8; }

/* ---------- 词库管理页 ---------- */
.decks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}
.deck-card {
    position: relative;
    padding: 1rem 1.1rem 1.1rem;
    background: #fff;
    border: 2px solid #e2e8f0;
    border-top: 6px solid var(--card-color, #6366f1);
    border-radius: 12px;
    transition: transform 0.15s, box-shadow 0.15s;
}
.deck-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(15,23,42,0.08); }
.deck-card.active {
    border-color: var(--card-color, #6366f1);
    background: color-mix(in srgb, var(--card-color, #6366f1) 5%, #fff);
}
.deck-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.4rem;
}
.deck-card-header h3 { color: #0f172a; font-size: 1.1rem; }
.badge-current {
    background: var(--card-color, #6366f1);
    color: #fff;
    font-size: 0.72rem;
    padding: 0.1rem 0.55rem;
    border-radius: 999px;
    font-weight: 500;
}
.deck-desc { font-size: 0.88rem; color: #64748b; margin-bottom: 0.8rem; min-height: 1.2rem; }
.deck-stats-row {
    display: flex;
    gap: 0.6rem;
    margin-bottom: 0.8rem;
}
.deck-stats-row > div {
    flex: 1;
    text-align: center;
    background: #f8fafc;
    padding: 0.4rem 0.2rem;
    border-radius: 8px;
    font-size: 0.82rem;
    color: #475569;
    line-height: 1.3;
}
.deck-stats-row strong {
    display: block;
    font-size: 1.05rem;
    color: #0f172a;
}
.deck-mastery-mini {
    display: flex;
    width: 100%;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.9rem;
    background: #f1f5f9;
}
.deck-mastery-mini span { display: block; transition: width 0.3s; }
.deck-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

/* 新建词库表单 */
.new-deck-form h3 { margin-bottom: 0.8rem; color: #1e293b; }
.color-picker {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    padding: 0.3rem 0;
}
.color-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    padding: 0;
}
.color-dot.active {
    border-color: #1e293b;
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px rgba(0,0,0,0.08);
}

/* ---------- 今日学习页 ---------- */
.today-progress-bar {
    margin-bottom: 1.2rem;
    padding: 0.8rem 1rem;
    background: #f8fafc;
    border-radius: 10px;
}
.tpb-row {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 0.5rem;
}
.tpb-row:last-child { margin-bottom: 0; }
.tpb-label { width: 60px; font-size: 0.88rem; color: #475569; font-weight: 500; }
.tpb-track {
    flex: 1;
    height: 10px;
    background: #e2e8f0;
    border-radius: 5px;
    overflow: hidden;
}
.tpb-fill {
    height: 100%;
    transition: width 0.4s ease;
    border-radius: 5px;
}
.tpb-review { background: linear-gradient(90deg, #3b82f6, #6366f1); }
.tpb-new    { background: linear-gradient(90deg, #f97316, #ec4899); }
.tpb-num    { width: 80px; text-align: right; font-size: 0.88rem; color: #334155; font-variant-numeric: tabular-nums; }
.tpb-meta { justify-content: space-between; color: #64748b; font-size: 0.85rem; margin-top: 0.4rem; }
.tpb-meta b { color: #0f172a; font-size: 0.95rem; }

.stage-badge {
    display: inline-block;
    padding: 0.2rem 0.9rem;
    margin-bottom: 0.8rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 500;
}
.stage-review { background: #dbeafe; color: #1d4ed8; }
.stage-new    { background: #ffe4e6; color: #be185d; }

/* 今日复习卡片 */
.review-card {
    min-height: 280px;
    padding: 1.8rem 1.5rem;
    background: linear-gradient(135deg, #ffffff 0%, #f5f3ff 100%);
    border: 2px solid #e0e7ff;
    border-radius: 14px;
    margin-bottom: 1.2rem;
    position: relative;
}
.rc-front { text-align: center; padding: 1rem 0 0.8rem; }
.rc-front-type { color: #94a3b8; font-size: 0.82rem; margin-bottom: 0.6rem; }
.rc-front-text {
    font-size: 2.6rem;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 0.5rem;
    line-height: 1.25;
    word-break: break-word;
}
.rc-front-sub {
    color: #6366f1;
    font-size: 1.15rem;
}
.rc-front-sub small { color: #94a3b8; font-size: 0.9rem; }
.rc-pos {
    display: inline-block;
    margin-top: 0.8rem;
    padding: 0.15rem 0.6rem;
    border-radius: 4px;
    background: #fff7ed;
    color: #9a3412;
    font-size: 0.8rem;
    border: 1px solid #fed7aa;
}
.rc-answer {
    margin-top: 1.5rem;
    padding-top: 1.3rem;
    border-top: 1px dashed #cbd5e1;
}
.rc-meaning {
    font-size: 1.1rem;
    color: #0f172a;
    margin-bottom: 1rem;
    line-height: 1.7;
}
.rc-example {
    background: #fff;
    padding: 0.8rem 1rem;
    border-radius: 8px;
    border-left: 4px solid #6366f1;
    margin-bottom: 0.8rem;
}
.ex-jp { color: #0f172a; line-height: 1.7; }
.ex-zh { color: #64748b; margin-top: 0.3rem; font-size: 0.9rem; }
.rc-notes {
    background: #fefce8;
    padding: 0.6rem 0.9rem;
    border-radius: 8px;
    color: #854d0e;
    margin-bottom: 0.8rem;
    font-size: 0.93rem;
    line-height: 1.6;
}
.rc-tags { color: #64748b; font-size: 0.88rem; }

.review-actions {
    display: flex;
    justify-content: center;
    gap: 0.8rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.review-actions .btn { min-width: 110px; padding: 0.7rem 1.2rem; font-size: 1rem; }

.review-controls {
    display: flex;
    justify-content: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.today-tips {
    margin-top: 1.2rem;
    background: #f8fafc;
    padding: 0.8rem 1rem;
    border-radius: 8px;
    color: #475569;
    font-size: 0.88rem;
}
.today-tips summary { cursor: pointer; font-weight: 500; color: #334155; }
.today-tips ul { margin-top: 0.6rem; padding-left: 1.3rem; line-height: 1.8; }

/* ---------- 今日学习：环节子菜单 ---------- */
.stage-tabs {
    display: flex;
    gap: 0.6rem;
    margin: 1rem 0 1.2rem;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 0;
}
.stage-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.7rem 1rem;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: #64748b;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s, background 0.2s;
    border-radius: 8px 8px 0 0;
    margin-bottom: -2px;
}
.stage-tab:hover:not(:disabled):not(.active) {
    color: #4f46e5;
    background: #f1f5f9;
}
.stage-tab.active {
    color: #4f46e5;
    border-bottom-color: #4f46e5;
    background: linear-gradient(180deg, #eef2ff 0%, transparent 100%);
    font-weight: 700;
}
.stage-tab:disabled {
    color: #cbd5e1;
    cursor: not-allowed;
    opacity: 0.6;
}
.stage-tab-icon { font-size: 1.15rem; }
.stage-tab-label { font-size: 1rem; }
.stage-tab-count {
    background: #e2e8f0;
    color: #475569;
    padding: 0.1rem 0.6rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.stage-tab.active .stage-tab-count {
    background: #4f46e5;
    color: #fff;
}

/* ---------- 新词输入模式 ---------- */
.rc-input-card { padding: 1.8rem 1.5rem; }
.rc-hint-row {
    background: #f1f5f9;
    padding: 0.6rem 0.9rem;
    border-radius: 8px;
    margin: 1rem 0 1.2rem;
    color: #1e293b;
    line-height: 1.6;
    border-left: 3px solid #6366f1;
    font-size: 0.95rem;
}
.rc-input-area {
    margin-top: 0.5rem;
}
.rc-input-mode {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.6rem;
}
.rc-input-mode .btn-mini.active {
    background: #4f46e5;
    color: #fff;
    border-color: #4f46e5;
}
.rc-input-tip {
    color: #94a3b8;
    font-size: 0.8rem;
    margin-left: 0.4rem;
}
.rc-input {
    width: 100%;
    padding: 0.8rem 1rem;
    border: 2px solid #c7d2fe;
    border-radius: 10px;
    font-size: 1.4rem;
    font-family: 'Hiragino Sans', 'Yu Gothic', 'Microsoft YaHei', system-ui, sans-serif;
    background: #fff;
    color: #0f172a;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.rc-input:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 4px rgba(99,102,241,0.15);
}
.rc-input:disabled {
    background: #f8fafc;
    color: #64748b;
    cursor: not-allowed;
}
.rc-input-buttons {
    display: flex;
    gap: 0.6rem;
    margin-top: 0.8rem;
    flex-wrap: wrap;
}
.rc-kana-hint {
    background: #fefce8;
    color: #854d0e;
    padding: 0.6rem 0.9rem;
    border-radius: 8px;
    margin-bottom: 0.6rem;
    font-size: 0.88rem;
    line-height: 1.6;
}
.rc-result {
    margin-top: 1.2rem;
    padding: 1rem 1.2rem;
    border-radius: 10px;
    border: 2px solid;
    background: #fff;
}
.rc-result.rc-correct {
    border-color: #22c55e;
    background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
}
.rc-result.rc-wrong {
    border-color: #ef4444;
    background: linear-gradient(135deg, #fef2f2 0%, #fff1f2 100%);
}
.rc-result-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 0.6rem;
}
.rc-correct .rc-result-title { color: #15803d; }
.rc-wrong   .rc-result-title { color: #b91c1c; }
.rc-your-answer {
    color: #64748b;
    margin-bottom: 0.4rem;
    font-size: 0.92rem;
}
.rc-your-answer code {
    background: #f1f5f9;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    color: #0f172a;
    font-family: ui-monospace, Consolas, monospace;
}
.rc-result-correct {
    margin-bottom: 0.6rem;
    font-size: 1rem;
    color: #1e293b;
    line-height: 1.7;
}
.rc-reading {
    font-size: 1.3rem;
    color: #4f46e5;
    font-weight: 600;
}
.rc-romaji {
    color: #64748b;
    font-style: italic;
    font-size: 0.95rem;
}
.rc-result-meaning {
    color: #1e293b;
    margin-bottom: 0.6rem;
    line-height: 1.7;
}

.today-complete {
    text-align: center;
    padding: 2rem 1rem 1rem;
}
.today-complete h2 {
    font-size: 1.7rem;
    margin-bottom: 1.2rem;
    border: none;
    padding: 0;
    justify-content: center;
}
.today-complete-actions {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.7rem;
    margin-top: 1rem;
}

/* ---------- 单词列表页 ---------- */
.toolbar {
    margin-bottom: 1rem;
    padding: 0.8rem 1rem;
    background: #f8fafc;
    border-radius: 10px;
}
.toolbar-row {
    display: flex;
    gap: 0.8rem;
    flex-wrap: wrap;
    align-items: flex-end;
}
.toolbar-col {
    flex: 1 1 140px;
    min-width: 140px;
}
.toolbar-col.flex-2 { flex: 2 1 260px; }
.toolbar-col label {
    display: block;
    font-size: 0.82rem;
    color: #64748b;
    margin-bottom: 0.25rem;
}
.toolbar-col input, .toolbar-col select {
    width: 100%;
    padding: 0.45rem 0.6rem;
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    background: #fff;
    font-size: 0.92rem;
}
.toolbar-col input:focus, .toolbar-col select:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}
.toolbar-col .btn { width: 100%; }

.wl-card { padding: 1rem 1.1rem; }
.wl-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.6rem;
    margin-bottom: 0.6rem;
    flex-wrap: wrap;
}
.wl-jp {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.5rem;
}
.wl-word {
    font-size: 1.4rem;
    font-weight: 700;
    color: #0f172a;
}
.wl-reading { color: #4f46e5; font-size: 0.98rem; }
.wl-romaji  { color: #64748b; font-size: 0.88rem; font-style: italic; }
.wl-pos {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    font-size: 0.75rem;
    background: #fef3c7;
    color: #92400e;
    border-radius: 4px;
    border: 1px solid #fde68a;
}
.wl-head-right { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.wl-level {
    padding: 0.15rem 0.6rem;
    font-size: 0.8rem;
    border-radius: 999px;
    border: 1px solid;
    font-weight: 500;
}
.wl-deck-tag {
    padding: 0.15rem 0.6rem;
    font-size: 0.78rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--deck-color, #6366f1) 15%, #fff);
    color: var(--deck-color, #6366f1);
    border: 1px solid color-mix(in srgb, var(--deck-color, #6366f1) 35%, #fff);
    font-weight: 500;
}
.wl-meaning {
    color: #1e293b;
    margin-bottom: 0.7rem;
    line-height: 1.7;
}
.wl-example {
    background: #fff;
    border-left: 3px solid #a5b4fc;
    padding: 0.5rem 0.8rem;
    border-radius: 4px;
    margin-bottom: 0.7rem;
    font-size: 0.9rem;
}
.wl-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    color: #64748b;
    font-size: 0.82rem;
    margin-bottom: 0.7rem;
}
.wl-tags { color: #475569; }
.wl-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.7rem;
    margin-top: 1.2rem;
    color: #475569;
    font-size: 0.9rem;
}

/* ---------- 添加单词 · 批量导入 ---------- */
.batch-area {
    margin-top: 1.5rem;
    padding: 1rem 1.1rem;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: 10px;
}
.batch-area h4 { color: #9a3412; margin-bottom: 0.5rem; }
.batch-area textarea {
    width: 100%;
    min-height: 160px;
    padding: 0.6rem;
    font-family: ui-monospace, Consolas, 'Microsoft YaHei', monospace;
    font-size: 0.88rem;
    border: 1px solid #fdba74;
    border-radius: 6px;
    background: #fff;
}
.batch-area code {
    background: #fff;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    font-family: ui-monospace, Consolas, monospace;
    color: #9a3412;
}

/* ---------- 学习统计页 ---------- */
.stats-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.9rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    padding: 1rem 0.8rem;
    background: linear-gradient(135deg, #ffffff, #f8fafc);
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    text-align: center;
}
.stat-label { font-size: 0.85rem; color: #64748b; }
.stat-value {
    font-size: 1.7rem;
    font-weight: 700;
    color: #4f46e5;
    margin: 0.3rem 0;
    line-height: 1.1;
}
.stats-section {
    background: #f8fafc;
    padding: 1.1rem 1.2rem;
    border-radius: 12px;
    margin-bottom: 1.2rem;
}
.stats-section h3 { color: #1e293b; margin-bottom: 0.8rem; font-size: 1.05rem; }

.mastery-bar               { display: flex; flex-direction: column; gap: 0.6rem; }
.mastery-item              { display: grid; grid-template-columns: 60px 1fr 48px; align-items: center; gap: 0.7rem; }
.mastery-label             { font-weight: 500; color: #334155; }
.mastery-bar-outer         { height: 14px; background: #e2e8f0; border-radius: 7px; overflow: hidden; }
.mastery-bar-inner         { height: 100%; border-radius: 7px; transition: width 0.4s; }
.mastery-count             { text-align: right; color: #475569; font-variant-numeric: tabular-nums; }

.mini-mastery {
    display: flex;
    width: 100%;
    height: 10px;
    border-radius: 5px;
    overflow: hidden;
    background: #e2e8f0;
    margin-bottom: 0.3rem;
}
.mini-mastery span { display: block; }

/* 近7天柱图 */
.week-chart {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.6rem;
    align-items: end;
    height: 180px;
}
.week-day {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    height: 100%;
}
.week-day.today .week-label div:first-child { color: #4f46e5; font-weight: 700; }
.week-bar {
    width: 100%;
    max-width: 48px;
    height: 130px;
    background: #f1f5f9;
    border-radius: 8px 8px 4px 4px;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column-reverse;
}
.week-bar-review { background: linear-gradient(180deg, #3b82f6, #6366f1); min-height: 2px; }
.week-bar-new    { background: linear-gradient(180deg, #ec4899, #f97316); min-height: 2px; }
.week-label {
    text-align: center;
    margin-top: 0.4rem;
    font-size: 0.82rem;
    color: #475569;
}
.week-num {
    display: flex;
    flex-direction: column;
    margin-top: 0.2rem;
    font-size: 0.72rem;
    line-height: 1.5;
}
.wc-new { color: #db2777; }
.wc-rev { color: #2563eb; }

/* 词库表 */
.deck-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    font-size: 0.92rem;
}
.deck-table th, .deck-table td {
    padding: 0.7rem 0.8rem;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
    vertical-align: middle;
}
.deck-table th {
    background: #f1f5f9;
    font-weight: 600;
    color: #334155;
    font-size: 0.85rem;
}
.deck-table tbody tr:hover { background: #fafbff; }
.sw {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 0.5rem;
    vertical-align: middle;
}

.settings-form .form-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.settings-form input[type='number'] { max-width: 200px; }
.settings-form input[type='checkbox'] { width: auto; }

/* ---------- JLPT 一键导入面板 ---------- */
.jlpt-importer {
    background: linear-gradient(135deg, #eef2ff 0%, #fdf4ff 100%);
    border: 1px solid #c7d2fe;
}
.jlpt-header {
    margin-bottom: 1rem;
}
.jlpt-header h3 {
    color: #4338ca;
    font-size: 1.1rem;
}
.jlpt-levels {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    margin-bottom: 1rem;
}
.jlpt-level-item {
    background: #fff;
    padding: 0.8rem 1rem;
    border-radius: 10px;
    background: #fff;
}
.jlpt-level-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.8rem;
    flex-wrap: wrap;
}
.jlpt-level-badge {
    display: inline-block;
    color: #fff;
    padding: 0.18rem 0.7rem;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.82rem;
    margin-right: 0.7rem;
}
.jlpt-import-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding-top: 0.5rem;
    border-top: 1px dashed #c7d2fe;
}

/* ---------- 空状态 ---------- */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #64748b;
}
.empty-state p {
    font-size: 1.05rem;
    margin-bottom: 1.2rem;
}

/* ---------- 页脚 ---------- */
#footer {
    margin-top: 3rem;
    background: #0f172a;
    color: #cbd5e1;
    text-align: center;
    padding: 1.3rem 1rem;
    font-size: 0.9rem;
}

/* ---------- 账号与同步（位于 header 渐变背景之上，因此用白色系文字） ---------- */
.account-area {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.7rem;
}
.account-btn { white-space: nowrap; }
.account-local-hint {
    font-size: 0.78rem;
    color: #fff;
    background: rgba(255, 255, 255, 0.18);
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    white-space: nowrap;
}
.account-user {
    font-size: 0.9rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    max-width: 12rem;
    overflow: hidden;
    text-overflow: ellipsis;
}
.account-status {
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.9);
    white-space: nowrap;
}

.sync-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #cbd5e1;
    flex: none;
}
.sync-dot.is-ok      { background: #4ade80; }
.sync-dot.is-dirty   { background: #fbbf24; }
.sync-dot.is-syncing { background: #60a5fa; animation: syncPulse 1s ease-in-out infinite; }
.sync-dot.is-offline { background: #cbd5e1; }
.sync-dot.is-error   { background: #f87171; }
@keyframes syncPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

.auth-panel {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 60;
    width: 300px;
    box-sizing: border-box;
    padding: 1rem;
    text-align: left;
    background: #fff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 14px 36px rgba(15, 23, 42, 0.22);
}
.auth-panel-title {
    margin-bottom: 0.7rem;
    font-size: 0.95rem;
    font-weight: 700;
    color: #1e293b;
}
.auth-input {
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 0.5rem;
    padding: 0.55rem 0.7rem;
    font-size: 0.92rem;
    color: #0f172a;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
}
.auth-input:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.auth-error {
    min-height: 1.1em;
    margin-bottom: 0.5rem;
    font-size: 0.82rem;
    color: #ef4444;
}
.auth-panel-actions { display: flex; gap: 0.5rem; }
.auth-panel-note {
    margin: 0.8rem 0 0;
    font-size: 0.78rem;
    line-height: 1.6;
    color: #64748b;
}
.auth-panel-note code {
    padding: 0.05rem 0.3rem;
    font-size: 0.75rem;
    background: #f1f5f9;
    border-radius: 4px;
}

/* ---------- 响应式 ---------- */
@media (max-width: 768px) {
    #header h1 { font-size: 1.5rem; }
    #header h1 .sub { display: block; margin: 0.2rem 0 0; font-size: 0.9rem; }
    .deck-switcher { width: 100%; justify-content: center; margin-top: 0.3rem; }
    .deck-switcher select { flex: 1; min-width: 0; }
    #nav ul { flex-direction: column; }
    #nav li { flex: none; }
    #nav a { border-bottom: none; border-left: 3px solid transparent; text-align: left; padding-left: 1rem; }
    #nav a.active { border-left-color: #6366f1; border-bottom-color: transparent; }
    .page { padding: 1rem; border-radius: 10px; }
    .big-number { font-size: 1.8rem; }
    .rc-front-text { font-size: 2rem; }
    .mastery-item { grid-template-columns: 50px 1fr 40px; font-size: 0.88rem; }
    .home-actions .btn { width: 100%; }
    .review-actions .btn { min-width: 90px; flex: 1 1 90px; }
    .week-chart { gap: 0.3rem; }
    .toolbar-row { flex-direction: column; align-items: stretch; }
    .toolbar-col { width: 100%; }
    .deck-table { font-size: 0.82rem; }
    .deck-table th, .deck-table td { padding: 0.5rem 0.4rem; }
    /* 账号区：小屏下水平居中，登录面板改为屏幕居中的浮层 */
    .account-area { justify-content: center; }
    .auth-panel {
        position: fixed;
        top: 50%;
        left: 50%;
        right: auto;
        width: calc(100vw - 2rem);
        max-width: 340px;
        transform: translate(-50%, -50%);
    }
}
