/* =========================================================================
   Question Bank 2.1 样式
   手机优先；题型用颜色区分；触摸设备的 :hover 复位加了 :not() 排除，
   避免「粘性 hover」把已判分的对错底色盖掉。
   头部沿用 1.0 的紫色渐变色块；按钮尺寸也跟 1.0 对齐（大按钮、撑满一行）。
   ========================================================================= */

:root {
    --bg: #f4f6f9;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --line: #e5e7eb;
    --primary: #2563eb;
    --primary-d: #1d4ed8;
    --green: #15803d;
    --green-bg: #dcfce7;
    --red: #b91c1c;
    --red-bg: #fee2e2;
    --amber: #b45309;
    --amber-bg: #fef3c7;
    --orange: #c2410c;
    --orange-bg: #ffedd5;
    --blue-bg: #dbeafe;
    --radius: 12px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    -webkit-text-size-adjust: 100%;
}

.container {
    max-width: 820px;
    margin: 0 auto;
    padding: 10px 12px 40px;
}

/* ---------------- 头部（照 1.0 的紫色横幅：大标题 + 居中） ---------------- */

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: 18px 20px;
    border-radius: 10px;
    margin-bottom: 14px;
    text-align: center;
    box-shadow: 0 4px 14px rgba(102, 126, 234, .28);
    cursor: pointer;               /* 整个标题区可点击 → 弹出「点将系统」说明 */
    user-select: none;
    -webkit-user-select: none;
    transition: filter .15s;
}

header:active { filter: brightness(.96); }

h1 {
    margin: 0;
    font-size: clamp(1.35rem, 5vw, 1.75rem);
    font-weight: 700;
    line-height: 1.25;
    color: #fff;
    letter-spacing: .3px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, .16);
}

/* 标题第二行：点将 —— 篆书用图片 */
.title-alias {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1px;
    margin: 5px 0 0;
    line-height: 1;
}

.alias-zi {
    height: 26px;
    width: auto;
    display: block;
    /* 整图两字（图 745×544），按高度固定，显示约 35.6×26px */
}

@media (max-width: 380px) {
    .alias-zi { height: 23px; }
}

/* 四大块：标题正下方，一行排满 */
.nav-buttons {
    display: flex;
    gap: 8px;
    width: 100%;
    margin-bottom: 18px;
}

.nav-btn {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    padding: 8px 4px 9px;
    font-size: .9rem;
    font-weight: 600;
    color: #495057;
    background: #f8f9fa;
    border: 1px solid #eceef1;
    border-radius: 8px;
    cursor: pointer;
    transition: background .2s, color .2s, box-shadow .2s;
    white-space: nowrap;
    overflow: hidden;
}

.nav-label {
    font-size: .88rem;
    font-weight: 600;
    line-height: 1.25;
}

/* 第二行：练习/错题库/待巩固显示「当前题号 / 总题数」，统计显示正确率 */
.nav-sub {
    font-size: .72rem;
    font-weight: 500;
    line-height: 1.2;
    color: #868e96;
    letter-spacing: .2px;
}

.nav-btn.active .nav-sub { color: rgba(255, 255, 255, .88); }

.nav-btn:active { filter: brightness(.96); }

/* 四块各给一个浅底色，选中时换成同色系深底 */
.nav-btn[data-mode="browse"]       { background: #e8f1ff; border-color: #cfe1ff; color: #1d4ed8; }
.nav-btn[data-mode="browse"].active       { background: #2563eb; border-color: #2563eb; color: #fff; box-shadow: 0 3px 10px rgba(37, 99, 235, .32); }

.nav-btn[data-mode="practice"]     { background: #fdecec; border-color: #fad4d4; color: #c02626; }
.nav-btn[data-mode="practice"].active     { background: #dc2626; border-color: #dc2626; color: #fff; box-shadow: 0 3px 10px rgba(220, 38, 38, .30); }

.nav-btn[data-mode="point"]        { background: #fff4e5; border-color: #ffe2bd; color: #b45309; }
.nav-btn[data-mode="point"].active        { background: #d97706; border-color: #d97706; color: #fff; box-shadow: 0 3px 10px rgba(217, 119, 6, .30); }

.nav-btn[data-mode="stats"]        { background: #e9f8ef; border-color: #ccecd9; color: #15803d; }
.nav-btn[data-mode="stats"].active        { background: #16a34a; border-color: #16a34a; color: #fff; box-shadow: 0 3px 10px rgba(22, 163, 74, .30); }

/* 第二行跟着本块色调走，不用统一灰 */
.nav-sub { color: inherit; opacity: .72; }
.nav-btn.active .nav-sub { opacity: .9; }

/* ---------------- 模式容器 ---------------- */

.mode { display: none; }
.mode.active { display: block; }

/* ---------------- 模式条 ---------------- */

.pool-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: #eef2ff;
    color: #3730a3;
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 12.5px;
    margin-bottom: 10px;
}

.pool-empty {
    background: #fff;
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    padding: 28px 16px;
    text-align: center;
    color: var(--muted);
    font-size: 14px;
}

/* ---------------- 题目卡片 ---------------- */

.question-container {
    background: var(--card);
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
}

.question-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 7px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 12px;
    /* 手机上也必须是一行：宁可压缩尺寸，也不允许换行 */
    flex-wrap: nowrap;
}

.question-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
}

.question-number {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--muted);
    white-space: nowrap;
    flex: 0 0 auto;
}

.question-meta .type-badge,
.question-meta .tag-badge {
    padding: 2px 7px;
    font-size: 11.5px;
    flex: 0 0 auto;
}

/* 题型标签：按题型配色 */
.type-badge {
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    padding: 2px 9px;
    border-radius: 999px;
    line-height: 1.5;
    white-space: nowrap;
}

.type-single { color: var(--primary-d); background: var(--blue-bg); }
.type-multiple { color: var(--orange); background: var(--orange-bg); }
.type-judge { color: var(--green); background: var(--green-bg); }

/* 评级标签 */
.tag-badge {
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    padding: 2px 9px;
    border-radius: 999px;
    white-space: nowrap;
}

.tag-know { color: var(--green); background: var(--green-bg); }
.tag-unknown { color: var(--red); background: var(--red-bg); }

.header-actions {
    display: flex;
    align-items: center;
    gap: 5px;
    flex: 0 0 auto;
}

#jumpInput {
    width: 52px;
    padding: 5px 5px;
    font-size: 12.5px;
    border: 1px solid var(--line);
    border-radius: 8px;
    text-align: center;
    background: #fff;
    color: var(--text);
    flex: 0 0 auto;
}

/* 双态按钮：没输数字=上一题，输了数字=跳转 */
#jumpBtn {
    font-size: 12.5px;
    padding: 6px 10px;
    min-width: 0;
    white-space: nowrap;
    flex: 0 0 auto;
    font-family: inherit;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    cursor: pointer;
}
#jumpBtn:active { opacity: .82; }

#jumpBtn.jump-mode {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.question-text {
    font-size: 16.5px;
    font-weight: 500;
    line-height: 1.75;
    margin-bottom: 14px;
    white-space: pre-wrap;
    word-break: break-word;
}

/* ---------------- 选项 ---------------- */

.options { display: flex; flex-direction: column; gap: 9px; }

.option {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 13px;
    background: #fff;
    border: 1.5px solid var(--line);
    border-radius: 10px;
    cursor: pointer;
    font-size: 15.5px;
    line-height: 1.6;
    transition: background .12s, border-color .12s;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

.option-letter {
    flex: 0 0 auto;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #f1f5f9;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 1px;
}

.option-text { flex: 1 1 auto; word-break: break-word; }

/* 已选（未判分） */
.option.selected {
    border-color: var(--primary);
    background: #eff6ff;
}

.option.selected .option-letter {
    background: var(--primary);
    color: #fff;
}

/* 判分后：对 */
.option.correct {
    border-color: #16a34a;
    background: var(--green-bg);
}

.option.correct .option-letter { background: #16a34a; color: #fff; }

/* 判分后：错 */
.option.wrong {
    border-color: #dc2626;
    background: var(--red-bg);
}

.option.wrong .option-letter { background: #dc2626; color: #fff; }

/* 漏选：正确答案但没勾——浅绿底 + 虚线边框，和「已选中正确项」的实线绿区分开 */
.option.missed {
    border-style: dashed;
    border-color: #16a34a;
    background: var(--green-bg);
}

.option.missed .option-letter { background: #16a34a; color: #fff; }

/* 非触摸设备才有 hover 效果 */
@media (hover: hover) and (pointer: fine) {
    .option:hover {
        border-color: #c7d2fe;
        background: #fafbff;
    }
    .nav-btn:not(.active):hover { background: #e9ecef; }
    .stat-row:hover { box-shadow: 0 2px 8px rgba(16, 24, 40, .12); }
}

/* 触摸设备：把 :hover 复位，只对未选中/未判分的元素生效 */
@media (hover: none) {
    .option:not(.selected):not(.correct):not(.wrong):not(.missed):hover {
        background: #fff;
        border-color: var(--line);
    }
    .nav-btn:not(.active):hover { background: #fff; color: #495057; }
}

/* ---------------- 解析（与「解析：」同一行） ---------------- */

.explanation {
    margin-top: 14px;
    padding: 11px 13px;
    background: #f8fafc;
    border-left: 3px solid #94a3b8;
    border-radius: 8px;
    font-size: 14.5px;
    line-height: 1.75;
    color: #334155;
    word-break: break-word;
}

.exp-label {
    font-weight: 700;
    color: #0f172a;
}

/* ---------------- 无效题（答案越界）提示 ---------------- */

.anomaly-box {
    margin: 12px 0 2px;
    padding: 10px 12px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-left: 4px solid #dc2626;
    border-radius: 8px;
    font-size: 13.5px;
    line-height: 1.65;
    color: #b91c1c;
    word-break: break-word;
}

.option.dead {
    opacity: .55;
    filter: grayscale(1);
    cursor: default;
    pointer-events: none;
}

/* ---------------- 操作区 ---------------- */

.question-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
}

/* 确定答案 / 返回：各自独占一行，紧跟评级块之后 */
#submitRow,
#backRow {
    margin-top: 12px;
}

#backBtn {
    min-width: 96px;
}

.btn {
    font-family: inherit;
    flex: 1 1 0;
    min-width: 120px;
    font-size: 15px;
    font-weight: 600;
    padding: 12px 20px;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background .12s, opacity .12s;
    touch-action: manipulation;
}

.btn:active { opacity: .82; }

.btn-sm {
    flex: 0 0 auto;
    min-width: auto;
    font-size: 12.5px;
    padding: 6px 12px;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-secondary { background: #fff; color: var(--text); border-color: var(--line); }
.btn-success { background: #16a34a; color: #fff; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-info { background: #0ea5e9; color: #fff; }
.btn-warning { background: #f59e0b; color: #fff; }

/* 评级两连：放在解析之前 */
.tag-group {
    gap: 10px;
    margin-top: 14px;
}

.tag-btn {
    flex: 1 1 0;
    font-size: 15.5px;
    font-weight: 700;
    padding: 12px 6px;
    background: #fff;
    border: 1.5px solid var(--line);
    color: var(--text);
    border-radius: 10px;
}

.tag-btn[data-tag="know"] { color: var(--green); border-color: #bbf7d0; background: #f0fdf4; }
.tag-btn[data-tag="unknown"] { color: var(--red); border-color: #fecaca; background: #fef2f2; }

.tag-btn.active {
    box-shadow: inset 0 0 0 2px currentColor;
    font-weight: 800;
}

/* ---------------- 统计页 ---------------- */

.stats-container h2 {
    font-size: 18px;
    margin: 6px 0 14px;
    display: flex;
    align-items: baseline;
    gap: 6px;
    flex-wrap: wrap;
    color: #7c3aed;
}

/* 标题右侧小字：当前第 x 轮 第 y 关（右对齐、带颜色） */
.stats-round {
    margin-left: auto;
    font-size: 12px;
    font-weight: 600;
    color: #7c3aed;
    text-align: right;
}

.stats-bank {
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
}

.stats-summary {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 14px;
}

.stat-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 12px 14px;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
}

.stat-card h3 {
    margin: 0 0 8px;
    font-size: 13px;
    color: var(--muted);
    font-weight: 600;
}

.stat-card p {
    margin: 3px 0;
    font-size: 14px;
    display: flex;
    justify-content: space-between;
    gap: 6px;
}

.stat-card p span { font-weight: 700; color: var(--text); }
.stat-hint-sm { font-size: 11.5px !important; color: var(--muted); display: block !important; }

.stats-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.stats-hint {
    font-size: 12.5px;
    line-height: 1.7;
    color: var(--muted);
    background: #fff;
    border-radius: 10px;
    padding: 10px 12px;
    margin: 0 0 16px;
}

.question-stats h3 {
    font-size: 15px;
    margin: 0 0 10px;
}

.stats-filter {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.stats-filter select,
.stats-filter input {
    font-family: inherit;
    font-size: 13.5px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
}

.stats-filter input { flex: 1 1 auto; min-width: 0; }

.question-stats-list { display: flex; flex-direction: column; gap: 8px; }

.stat-row {
    background: #fff;
    border-radius: 10px;
    padding: 10px 12px;
    cursor: pointer;
    transition: box-shadow .15s, transform .1s;
}

.stat-row:active { transform: scale(.995); }

.stat-row-head {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 5px;
    flex-wrap: wrap;
}

.stat-row-num { font-size: 12px; color: var(--muted); margin-left: auto; }
.stat-row-text { font-size: 14px; line-height: 1.6; color: #374151; word-break: break-word; }
.stats-empty { color: var(--muted); font-size: 14px; padding: 12px; text-align: center; }

/* ---------------- 轻提示 ---------------- */

.toast {
    position: fixed;
    left: 50%;
    bottom: 42px;
    transform: translate(-50%, 12px);
    max-width: 84vw;
    background: rgba(17, 24, 39, .92);
    color: #fff;
    font-size: 13.5px;
    line-height: 1.5;
    padding: 10px 16px;
    border-radius: 999px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s, transform .18s;
    z-index: 99;
    text-align: center;
}

.toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* ---------------- 宽屏微调 ---------------- */

@media (min-width: 640px) {
    .nav-btn { font-size: 14.5px; padding: 11px 8px; }
    .stats-summary { grid-template-columns: repeat(4, 1fr); }
    .question-container { padding: 20px; }
}

@media (max-width: 380px) {
    .nav-btn { font-size: 12.5px; padding: 10px 2px; }
    h1 { font-size: 1.3rem; }
    .question-text { font-size: 15.5px; }
    /* 窄屏再收一档，保证题号行仍是一行 */
    .question-header { gap: 5px; }
    .question-meta { gap: 4px; }
    .question-number { font-size: 11.5px; }
    .question-meta .type-badge,
    .question-meta .tag-badge { font-size: 10.5px; padding: 1px 6px; }
    #jumpInput { width: 44px; font-size: 11.5px; padding: 4px; }
    #jumpBtn { font-size: 11px; padding: 5px 7px; }
}

/* 320px 级小屏（iPhone SE 一代等）再收一档，保证「第 1057 题 + 标签 + 跳转」仍是一行 */
@media (max-width: 340px) {
    .question-header { gap: 4px; }
    .question-meta { gap: 3px; }
    .question-number { font-size: 11px; }
    .question-meta .type-badge,
    .question-meta .tag-badge { font-size: 10px; padding: 1px 5px; }
    #jumpInput { width: 40px; font-size: 11px; padding: 3px; }
    #jumpBtn { font-size: 10.5px; padding: 5px 6px; }
}

/* ===== 功能说明面板（统计页按钮 / 快捷键 T）===== */
.help-mask {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .45);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 90;
}

.help-panel {
    background: #fff;
    border-radius: 14px;
    width: min(600px, 100%);
    max-height: 86vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 18px 48px rgba(15, 23, 42, .22);
}

.help-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--line);
}

.help-head h3 { margin: 0; font-size: 16px; }

.help-close {
    border: none;
    background: none;
    font-size: 22px;
    line-height: 1;
    color: var(--muted);
    cursor: pointer;
    padding: 0 4px;
}

.help-body {
    padding: 14px 18px 18px;
    overflow-y: auto;
    font-size: 13px;
    line-height: 1.75;
    color: var(--text);
}

.help-body h4 {
    margin: 14px 0 6px;
    font-size: 13.5px;
    color: var(--primary);
}

.help-body h4:first-child { margin-top: 0; }

.help-body p { margin: 0 0 8px; }

.help-keys {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
}

.help-keys th,
.help-keys td {
    border-bottom: 1px solid var(--line);
    padding: 6px 8px;
    text-align: left;
    vertical-align: top;
}

.help-keys th {
    color: var(--muted);
    font-weight: 600;
    background: #f8fafc;
}

.help-keys td:first-child { white-space: nowrap; font-weight: 600; }

.help-keys td:last-child { color: var(--muted); white-space: nowrap; }

.help-note { margin-top: 10px; font-size: 12px; color: var(--muted); }

/* ===== 统计页四个按钮：与上方四个模块一样并排等宽、不换行 ===== */
.stats-actions { flex-wrap: nowrap; }

.stats-actions .btn {
    flex: 1 1 0;
    min-width: 0;
    white-space: nowrap;
    padding: 12px 6px;
    font-size: 14px;
}

/* 功能说明：实心底色，和导出/导入/重置保持同一套风格 */
.btn-help { background: #7c3aed; color: #fff; }

@media (max-width: 560px) {
    .stats-actions .btn { padding: 10px 4px; font-size: 13.5px; }
}

@media (max-width: 380px) {
    .stats-actions .btn { padding: 10px 2px; font-size: 12.5px; }
}

/* 「题目错」筛选下状态文字标红，与对错次数区分开 */
.stat-row-num.stat-row-bad { color: #dc2626; font-weight: 600; }

/* 正确率卡片小字：第 N 轮 + 上一轮成绩，窄屏整段换行不折断 */
#sRoundNote .rn-prev { white-space: nowrap; }

@media (max-width: 380px) {
    #sRoundNote .rn-sep { display: none; }
    #sRoundNote .rn-prev { display: block; }
}

/* ===== 2.6.0：统计卡片标题两端对齐 + 可点击行 ===== */

/* 卡片标题：左边名称、右边百分比，两端对齐 */
.stat-card h3.card-title {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin: 0 0 8px;
    font-size: 13px;
    color: var(--muted);
    font-weight: 600;
    white-space: nowrap;
}

.stat-card h3.card-title span:first-child { flex: 0 0 auto; }

.stat-card h3.card-title span:last-child {
    flex: 0 0 auto;
    color: var(--text);
    font-weight: 700;
    font-size: 14.5px;
}

/* 卡片里可点击的行（点了切换下方明细筛选）：用链接色区分 */
.stat-card p[data-filter] { cursor: pointer; color: #1d4ed8; }
.stat-card p[data-filter] span { color: #1d4ed8; }
.stat-card p[data-filter]:active { opacity: .7; }

/* 点将模式里的「错题库」标签配色（比「不会」偏红一点的深红） */
.tag-wrongbank { color: #b91c1c; background: #fee2e2; }

/* ===== 2.6.0：点将系统说明 / 通用提示弹窗 ===== */

.about-meta {
    margin: 2px 0;
    font-size: 13px;
    color: var(--muted);
}

/* 关于弹窗抬头：标题 + 下方小字版本号/作者 */
.about-titles { display: flex; flex-direction: column; gap: 1px; }

.about-sub {
    margin: 0;
    font-size: 11.5px;
    font-weight: 500;
    color: var(--muted);
    letter-spacing: .2px;
}

.notice-panel {
    width: min(420px, 100%);
}

.notice-text {
    margin: 4px 0 14px;
    font-size: 14.5px;
    line-height: 1.75;
    color: var(--text);
}

.notice-actions { display: flex; }

.notice-actions .btn { flex: 1 1 auto; }
