/* ============================================================
   CET 训练营 · 样式
   ============================================================ */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --accent: #8b5cf6;
    --bg: #f5f6fa;
    --card: #ffffff;
    --text: #1f2430;
    --muted: #6b7280;
    --border: #e5e7eb;
    --success: #10b981;
    --warn: #f59e0b;
    --danger: #ef4444;
    --radius: 14px;
    --shadow: 0 2px 12px rgba(31, 36, 48, .06);
    --shadow-lg: 0 12px 40px rgba(79, 70, 229, .18);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: "Microsoft YaHei", "PingFang SC", -apple-system, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
}

/* ---------- 顶栏 ---------- */
.topbar { background: #fff; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50; }
.topbar-inner { max-width: 1100px; margin: 0 auto; padding: 0 20px; height: 58px; display: flex; align-items: center; gap: 18px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; color: var(--primary-dark); white-space: nowrap; }
.logo { font-size: 22px; }
.tag { background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff; font-size: 11px; padding: 2px 8px; border-radius: 20px; font-weight: 600; }
.nav { display: flex; gap: 4px; overflow-x: auto; flex: 1; }
.nav-item { border: none; background: transparent; padding: 8px 12px; border-radius: 8px; cursor: pointer; font-size: 13.5px; color: var(--muted); white-space: nowrap; font-family: inherit; }
.nav-item:hover { background: #f1f2f7; color: var(--text); }
.nav-item.active { background: #eef0ff; color: var(--primary-dark); font-weight: 600; }
.streak-box { font-size: 14px; font-weight: 700; color: #f97316; white-space: nowrap; }

/* ---------- 主区域 ---------- */
#main { max-width: 1100px; margin: 24px auto; padding: 0 20px; }

/* ---------- 卡片 ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-bottom: 20px; }
.card-title { font-size: 17px; font-weight: 700; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.card-title .sub { font-size: 12px; color: var(--muted); font-weight: 400; }

/* ---------- 仪表盘 ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { background: #fff; border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); border-top: 3px solid var(--primary); }
.stat:nth-child(2) { border-top-color: #8b5cf6; }
.stat:nth-child(3) { border-top-color: #10b981; }
.stat:nth-child(4) { border-top-color: #f59e0b; }
.stat .num { font-size: 28px; font-weight: 800; color: var(--primary-dark); }
.stat .label { font-size: 12px; color: var(--muted); margin-top: 4px; }
.week-chart { display: flex; align-items: flex-end; gap: 8px; height: 110px; padding-top: 10px; }
.wbar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; height: 100%; }
.wbar .bar { width: 100%; max-width: 38px; background: linear-gradient(180deg, #a5b4fc, #6366f1); border-radius: 6px 6px 2px 2px; min-height: 3px; transition: height .3s; }
.wbar .lbl { font-size: 11px; color: var(--muted); }
.wbar .min { font-size: 10px; color: #8b8f9c; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 800px) { .two-col { grid-template-columns: 1fr; } }

/* ---------- 按钮 ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: none; cursor: pointer; background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff; padding: 10px 18px; border-radius: 9px; font-size: 14px; font-weight: 600; font-family: inherit; transition: all .15s; }
.btn:hover { opacity: .92; transform: translateY(-1px); }
.btn.small { padding: 7px 14px; font-size: 13px; }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn.ghost:hover { background: #f4f4f8; }
.btn.success { background: linear-gradient(135deg, #10b981, #059669); }
.btn.danger { background: linear-gradient(135deg, #ef4444, #dc2626); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.recording { background: linear-gradient(135deg, #ef4444, #dc2626); animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(239,68,68,.4);} 50% { box-shadow: 0 0 0 8px rgba(239,68,68,0);} }

/* ---------- 输入框 / 选择 ---------- */
input[type=text], input[type=number], input[type=password], select, textarea {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; font-family: inherit; outline: none; background: #fff;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.12); }
textarea { resize: vertical; min-height: 90px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 6px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 140px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }

/* ---------- 标签 / 徽章 ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { padding: 6px 14px; border-radius: 20px; font-size: 13px; border: 1px solid var(--border); background: #fff; cursor: pointer; color: var(--muted); }
.chip.active { background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff; border-color: transparent; font-weight: 600; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.badge.cet4 { background: #eef2ff; color: #4f46e5; }
.badge.cet6 { background: #fdf2f8; color: #db2777; }
.badge.easy { background: #ecfdf5; color: #059669; }
.badge.medium { background: #fef3c7; color: #b45309; }
.badge.hard { background: #fee2e2; color: #b91c1c; }
.badge.new { background: #e0e7ff; color: #4338ca; }
.badge.learning { background: #fef3c7; color: #b45309; }
.badge.familiar { background: #d1fae5; color: #047857; }
.badge.mastered { background: #a7f3d0; color: #065f46; }

/* ---------- 文章列表 ---------- */
.article-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px; cursor: pointer; background: #fff; transition: all .15s; }
.article-item:hover { border-color: var(--primary); box-shadow: var(--shadow); transform: translateX(3px); }
.article-item .t { font-weight: 600; font-size: 15px; }
.article-item .meta { display: flex; gap: 8px; align-items: center; margin-top: 4px; font-size: 12px; color: var(--muted); }
.article-item .ops { display: flex; gap: 6px; }

/* ---------- 阅读视图 ---------- */
.reader-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.reader-en { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-bottom: 16px; font-size: 16px; line-height: 1.9; }
.reader-en p { margin-bottom: 14px; }
.w-token { cursor: pointer; border-radius: 3px; padding: 0 1px; }
.w-token:hover { background: #eef0ff; }
.w-token.known { color: #3730a3; }
.w-token.newbie { background: #fef3c7; color: #92400e; }
.reader-zh { background: #fbfbfd; border-left: 3px solid var(--accent); border-radius: 8px; padding: 14px 16px; color: #555; font-size: 14.5px; line-height: 1.9; display: none; }
.reader-zh.show { display: block; }

/* ---------- 跟读 ---------- */
.shadow-options { display: flex; gap: 10px; margin-bottom: 18px; }
.mode-card { flex: 1; text-align: center; padding: 16px; border: 2px solid var(--border); border-radius: var(--radius); cursor: pointer; background: #fff; transition: all .15s; }
.mode-card.active { border-color: var(--primary); background: #eef0ff; box-shadow: var(--shadow); }
.mode-card .ic { font-size: 26px; }
.mode-card .nm { font-weight: 700; margin-top: 6px; font-size: 14px; }
.mode-card .ds { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.sentence-list { margin-top: 6px; }
.sent { border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin-bottom: 12px; background: #fff; }
.sent.active { border-color: var(--primary); box-shadow: var(--shadow); }
.sent .s-text { font-size: 16px; line-height: 1.8; }
.sent .s-zh { color: var(--muted); font-size: 13px; margin-top: 4px; }
.sent .s-tools { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; align-items: center; }
.sent .s-score { margin-left: auto; font-weight: 700; font-size: 15px; }
.sent .s-score.good { color: var(--success); }
.sent .s-score.mid { color: var(--warn); }
.sent .s-score.bad { color: var(--danger); }
.audio-player { width: 140px; height: 34px; }

/* ---------- 拼写 ---------- */
.spell-box { text-align: center; padding: 30px 0; }
.spell-prompt { font-size: 20px; margin-bottom: 18px; min-height: 60px; }
.spell-input-wrap { display: flex; gap: 10px; justify-content: center; margin: 18px 0; }
.spell-input-wrap input { width: 320px; max-width: 80vw; font-size: 20px; text-align: center; letter-spacing: 1px; }
.spell-input-wrap input.ok, .gap-input.ok { border-color: var(--success) !important; background: #ecfdf5 !important; color: #047857; }
.spell-input-wrap input.bad, .gap-input.bad { border-color: var(--danger) !important; background: #fef2f2 !important; color: #b91c1c; }
.spell-input-wrap input.revealed, .gap-input.revealed { border-color: var(--warn) !important; background: #fffbeb !important; color: #92400e; }
.spell-actions { margin-top: 14px; display: flex; justify-content: center; }
.sent-zh { color: #555; font-size: 17px; margin-bottom: 6px; }
.sent-en { font-size: 19px; line-height: 2.4; }
.s-ph { color: var(--muted); font-size: 13px; font-weight: 400; }
.s-pos { color: #8b5cf6; font-size: 12.5px; font-weight: 600; margin-top: 2px; }
.gap-input { text-align: center; font-size: 17px; padding: 4px 6px; border: 2px dashed #c7d2fe; border-radius: 6px; outline: none; margin: 0 2px; background: #fafbff; }
.gap-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.15); }
.gap-input::placeholder { color: #c7d2fe; }

/* 段落朗读 */
.para { margin-bottom: 18px; border-radius: 8px; transition: background .2s; padding: 2px 4px; }
.para.playing { background: #fffbeb; box-shadow: 0 0 0 1px #fcd34d; }
.para-btn { font-size: 11.5px; padding: 3px 10px; border: 1px solid var(--border); border-radius: 14px; background: #fff; cursor: pointer; vertical-align: 3px; margin: 0 6px; }
.para-btn:hover { opacity: .85; }
.para-play-all { border-color: #a5b4fc; color: #4338ca; background: #eef0ff; }
.para-play-only { border-color: #6ee7b7; color: #047857; background: #ecfdf5; }

/* 双语悬停高亮 */
.w-token.on, .wl.on { background: #fef08a !important; color: #92400e !important; }
.wl { cursor: pointer; border-radius: 3px; }
.zh-hl { cursor: pointer; border-radius: 3px; }
.zh-hl.on { background: #fef08a; text-decoration: underline; }
.spell-feedback { min-height: 60px; font-size: 15px; }
.spell-feedback .correct { color: var(--success); font-weight: 700; }
.spell-feedback .wrong { color: var(--danger); font-weight: 700; }
.word-card { background: #f8f9ff; border: 1px solid #e3e6ff; border-radius: 12px; padding: 16px; margin-top: 10px; }
.word-card .wc-word { font-size: 22px; font-weight: 800; color: var(--primary-dark); }
.word-card .wc-ph { color: var(--muted); margin-left: 8px; }
.word-card .wc-def { margin-top: 6px; }
.word-card .wc-ex { color: #555; margin-top: 6px; font-style: italic; }
.word-card .wc-ex-zh { color: var(--muted); margin-top: 2px; }
.progress-dots { display: flex; gap: 6px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.pdot { width: 10px; height: 10px; border-radius: 50%; background: #e5e7eb; }
.pdot.done { background: var(--success); }
.pdot.cur { background: var(--primary); }
.pdot.wrong { background: var(--danger); }

/* ---------- 测试 ---------- */
.quiz-box { max-width: 680px; margin: 0 auto; }
.quiz-q { font-size: 18px; font-weight: 600; margin-bottom: 16px; min-height: 44px; }
.opt { display: block; width: 100%; text-align: left; padding: 13px 16px; border: 1.5px solid var(--border); border-radius: 10px; margin-bottom: 10px; background: #fff; cursor: pointer; font-size: 14.5px; font-family: inherit; transition: all .15s; }
.opt:hover:not(:disabled) { border-color: var(--primary); background: #f5f6ff; }
.opt.correct { border-color: var(--success); background: #ecfdf5; color: #047857; font-weight: 600; }
.opt.wrong { border-color: var(--danger); background: #fef2f2; color: #b91c1c; }
.opt:disabled { cursor: default; opacity: .75; }

/* ---------- 生词本 ---------- */
.book-stats { display: flex; gap: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.book-stat { background: #fff; border-radius: 10px; padding: 12px 18px; box-shadow: var(--shadow); }
.book-stat .n { font-size: 20px; font-weight: 800; color: var(--primary-dark); }
.book-stat .l { font-size: 11px; color: var(--muted); }
.table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 10px; overflow: hidden; box-shadow: var(--shadow); }
.table th, .table td { padding: 11px 12px; text-align: left; border-bottom: 1px solid #f1f2f7; font-size: 13.5px; }
.table th { background: #f8f9ff; color: #4b5563; font-size: 12.5px; }
.table tr:hover td { background: #fafaff; }
.select-status { padding: 5px 8px; border-radius: 6px; border: 1px solid var(--border); font-size: 12.5px; }

/* ---------- 管理 ---------- */
.tabs { display: flex; gap: 8px; margin-bottom: 18px; border-bottom: 2px solid var(--border); }
.tab { padding: 10px 16px; cursor: pointer; font-size: 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -2px; }
.tab.active { color: var(--primary-dark); font-weight: 700; border-bottom-color: var(--primary); }
.word-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.word-cell { border: 1px solid var(--border); border-radius: 10px; padding: 12px; background: #fff; position: relative; }
.word-cell .w { font-weight: 700; font-size: 16px; color: var(--primary-dark); }
.word-cell .p { color: var(--muted); font-size: 12.5px; }
.word-cell .d { color: #4b5563; margin-top: 5px; font-size: 13px; }
.word-cell .ops { display: flex; gap: 6px; margin-top: 10px; }

/* ---------- 单词弹窗 ---------- */
.word-popup { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; }
.word-popup.hidden { display: none; }
.popup-card { background: #fff; border-radius: 16px; max-width: 480px; width: 100%; padding: 24px; box-shadow: var(--shadow-lg); animation: pop .18s ease; }
@keyframes pop { from { transform: scale(.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.popup-head { display: flex; align-items: center; gap: 10px; }
.p-word { font-size: 30px; font-weight: 800; color: var(--primary-dark); }
.p-phonetic { color: var(--muted); font-size: 15px; }
.p-play { border: none; background: #eef0ff; width: 36px; height: 36px; border-radius: 50%; cursor: pointer; font-size: 16px; }
.p-pos { margin-top: 4px; font-size: 13px; color: #8b5cf6; font-weight: 600; }
.p-def { margin-top: 10px; font-size: 16px; font-weight: 600; }
.p-en-def { margin-top: 6px; color: #4b5563; }
.p-example { margin-top: 14px; background: #f8f9ff; padding: 10px 12px; border-radius: 8px; font-style: italic; color: #333; }
.p-example-zh { color: var(--muted); font-size: 13px; margin-top: 4px; }
.popup-actions { display: flex; gap: 10px; margin-top: 18px; justify-content: flex-end; }

/* ---------- Toast ---------- */
.toast { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%) translateY(80px); background: #1f2430; color: #fff; padding: 12px 22px; border-radius: 10px; font-size: 14px; opacity: 0; transition: all .3s; z-index: 200; box-shadow: 0 8px 30px rgba(0,0,0,.25); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { background: linear-gradient(135deg, #10b981, #059669); }
.toast.error { background: linear-gradient(135deg, #ef4444, #dc2626); }

/* ---------- 空状态 ---------- */
.empty { text-align: center; color: var(--muted); padding: 50px 0; }
.empty .ic { font-size: 44px; margin-bottom: 10px; }

/* ---------- 详情 / 折叠 ---------- */
.details { background: #f8f9ff; border-radius: 8px; padding: 14px; margin-bottom: 14px; font-size: 13.5px; }
.details b { color: var(--primary-dark); }

/* 语言切换小按钮 */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { border: none; background: #fff; padding: 7px 14px; font-size: 13px; cursor: pointer; color: var(--muted); font-family: inherit; }
.seg button.active { background: var(--primary); color: #fff; font-weight: 600; }

@media (max-width: 760px) {
    .topbar-inner { flex-wrap: wrap; height: auto; padding: 10px 14px; gap: 8px; }
    .nav { order: 3; width: 100%; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .mode-card .ds { display: none; }
}
