/* ===== 煤矿培训合格证题库 - 全局样式 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
.icon { width: 1em; height: 1em; vertical-align: -0.15em; display: inline-block; flex-shrink: 0; }
:root {
    --primary: #1a6fb5;
    --primary-dark: #155a92;
    --ok: #16a34a;
    --err: #dc2626;
    --warn: #d97706;
    --bg: #f1f4f8;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #e5e7eb;
    --radius: 10px;
    --q-font-size: 16px;
}
body.font-small { --q-font-size: 14px; }
body.font-medium { --q-font-size: 16px; }
body.font-large { --q-font-size: 18px; }
html, body { height: 100%; }
body {
    font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}
.app { max-width: 720px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }
.hidden { display: none !important; }

/* ===== 顶部 ===== */
.header {
    background: linear-gradient(135deg, #1a6fb5, #2c8ad6);
    color: #fff;
    padding: 14px 16px 12px;
    position: sticky; top: 0; z-index: 20;
    box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.header-top { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 8px; }
.header-top h1 { font-size: 17px; font-weight: 700; text-align: center; }
.mode-row {
    display: flex; align-items: center; justify-content: center;
    gap: 8px; margin-bottom: 10px; flex-wrap: wrap;
}
.mode-select-wrap {
    display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}
.mode-label-text {
    font-size: 12px; color: rgba(255,255,255,.85);
    display: flex; align-items: center; gap: 6px;
}
.mode-label-text::before {
    content: ""; display: inline-block; width: 3px; height: 14px;
    background: rgba(255,255,255,.6); border-radius: 2px;
}
.mode-select {
    padding: 5px 10px; border: 1px solid rgba(255,255,255,.35); border-radius: 8px;
    font-size: 13px; font-weight: 600; background: rgba(255,255,255,.15);
    color: #fff; cursor: pointer;
}
.mode-select option { background: #fff; color: #1f2937; }
.mode-select:focus { outline: none; border-color: rgba(255,255,255,.7); }

/* ===== 题量选择器（header内） ===== */
.count-selector {
    display: flex; align-items: center; gap: 6px; flex-shrink: 0;
}
.count-label { font-size: 12px; color: rgba(255,255,255,.7); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.count-selector select {
    padding: 4px 8px; border: 1px solid rgba(255,255,255,.3); border-radius: 6px;
    font-size: 12px; background: rgba(255,255,255,.12); color: #fff; cursor: pointer;
}
.count-selector select option { background: #fff; color: #1f2937; }
.count-selector select:focus { outline: none; border-color: rgba(255,255,255,.6); }

/* ===== 模式分隔线和背题按钮 ===== */
.mode-divider {
    width: 3px; height: 14px; background: rgba(255,255,255,.6);
    border-radius: 2px; user-select: none; font-size: 0; flex-shrink: 0;
}
.btn-mode-review {
    padding: 4px 12px; border: 1px solid rgba(255,255,255,.35); border-radius: 6px;
    font-size: 12px; font-weight: 600; background: rgba(255,255,255,.12);
    color: #fff; cursor: pointer; transition: all .2s; flex-shrink: 0;
}
.btn-mode-review:hover { background: rgba(255,255,255,.25); }
.btn-mode-review:active { transform: scale(.95); }
.btn-mode-review.review-active { background: #f59e0b; border-color: #f59e0b; color: #fff; }

.stats { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; text-align: center; }
.stat { background: rgba(255,255,255,.14); border-radius: 8px; padding: 6px 2px; }
.stat-num { display: block; font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 11px; opacity: .85; }

/* ===== 答题进度条 ===== */
.progress-bar {
    position: relative; height: 18px; margin-top: 8px;
    background: rgba(255,255,255,.15); border-radius: 9px; overflow: hidden;
}
.progress-fill {
    height: 100%; background: linear-gradient(90deg, #4ade80, #22c55e);
    border-radius: 9px; transition: width .3s ease; width: 0%;
}
.progress-text {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 600; color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,.3);
}
.stat-ok .stat-num { color: #bbf7d0; }
.stat-err .stat-num { color: #fecaca; }
.timer { font-variant-numeric: tabular-nums; }

/* ===== 模式栏 ===== */
/* ===== 模式网格（2x2） ===== */
.mode-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
    padding: 10px 12px; background: var(--card);
    border-bottom: 1px solid var(--border);
}
.mode-card {
    display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
    padding: 12px 14px; border: 1.5px solid var(--border);
    background: #f8fafc; color: var(--text); border-radius: 10px;
    cursor: pointer; transition: all .15s; text-align: left;
}
.mode-card.mode-wide { grid-column: 1 / -1; }
.mode-card:active { transform: scale(.97); }
.mode-card .mode-name { font-size: 15px; font-weight: 700; }
.mode-card .mode-desc { font-size: 11px; color: var(--muted); }
.mode-card.active {
    background: var(--primary); border-color: var(--primary); color: #fff;
}
.mode-card.active .mode-desc { color: rgba(255,255,255,.8); }

/* ===== 标题栏操作按钮组 ===== */
.header-actions {
    display: flex; gap: 6px; flex-wrap: wrap; justify-content: center;
}
.btn-header {
    padding: 4px 8px; border: 1px solid rgba(255,255,255,.4);
    background: rgba(255,255,255,.15); color: #fff; border-radius: 6px;
    font-size: 10px; cursor: pointer; transition: all .15s; white-space: nowrap;
}
.btn-header:hover { background: rgba(255,255,255,.25); }
.btn-header:active { transform: scale(.95); }
.btn-header.btn-clear:hover { background: #dc2626; border-color: #dc2626; }
.theme-toggle { width: 32px; padding: 4px 0; font-size: 14px; }
.btn-header.review-active { background: #f59e0b; border-color: #f59e0b; color: #fff; }

/* ===== 背题模式 ===== */
body.review-mode .option { cursor: default; }
body.review-mode .option.correct { background: rgba(74,222,128,.15); border-color: #4ade80; color: #16a34a; }
body.review-mode .analysis { display: block !important; }

/* ===== 自定义确认弹窗 ===== */
.confirm-mask {
    position: fixed; inset: 0; background: rgba(0,0,0,.4);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    display: flex; align-items: center; justify-content: center;
    z-index: 100;
}
.confirm-box {
    background: #fff; border-radius: 12px; padding: 20px;
    width: 80%; max-width: 320px; box-shadow: 0 8px 30px rgba(0,0,0,.2);
}
.confirm-title { font-size: 16px; font-weight: 700; margin-bottom: 10px; color: var(--text); }
.confirm-content { font-size: 14px; color: var(--muted); line-height: 1.6; margin-bottom: 18px; white-space: pre-line; max-height: 60vh; overflow-y: auto; }
.confirm-btns { display: flex; gap: 10px; }
.confirm-btn {
    flex: 1; padding: 10px; border: none; border-radius: 8px;
    font-size: 14px; cursor: pointer; transition: all .15s;
}
.confirm-btn:active { transform: scale(.97); }
.confirm-btn.cancel { background: #e5e7eb; color: var(--text); }
.confirm-btn.ok { background: var(--primary); color: #fff; }

/* ===== 答题结果弹窗 ===== */
.result-box {
    background: #fff; border-radius: 16px; padding: 24px 20px;
    width: 85%; max-width: 340px; box-shadow: 0 8px 30px rgba(0,0,0,.2);
    text-align: center; position: relative;
}
.result-close-x {
    position: absolute; top: 10px; right: 10px;
    width: 32px; height: 32px; border: none; background: transparent;
    font-size: 22px; color: #999; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%; line-height: 1;
}
.result-close-x:hover { background: rgba(0,0,0,.06); color: #333; }
.result-box h2 { font-size: 20px; font-weight: 700; margin-bottom: 12px; color: var(--text); }
.result-score {
    font-size: 72px; font-weight: 800; color: var(--primary);
    line-height: 1; margin: 8px 0 20px;
}
.result-stats {
    font-size: 13px; color: var(--text); line-height: 2;
    background: #f8fafc; border-radius: 10px; padding: 12px; margin-bottom: 16px;
}
.result-actions { display: flex; gap: 8px; margin-bottom: 12px; justify-content: center; }
.result-actions .confirm-btn { min-width: 120px; font-size: 14px; padding: 10px 20px; }
.share-img-wrap { margin-top: 12px; text-align: center; }
.share-tip { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.share-img-wrap img {
    max-width: 100%; border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
}

/* ===== 按钮 ===== */
.btn {
    padding: 10px 18px; border: none; border-radius: 8px;
    font-size: 14px; cursor: pointer; background: #e5e7eb; color: var(--text);
    transition: all .15s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.danger { background: var(--err); color: #fff; }

/* ===== 主内容 ===== */
.main { flex: 1; padding: 12px; padding-bottom: 30px; }
.question-card {
    background: var(--card); border-radius: var(--radius);
    padding: 16px; border: 1px solid var(--border); box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
.q-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.q-index {
    background: var(--primary); color: #fff; min-width: 34px; height: 34px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 8px; font-weight: 700; font-size: 15px;
}
.q-type {
    font-size: 12px; background: #eef2ff; color: #3730a3;
    padding: 3px 8px; border-radius: 4px;
}
.q-type.judge { background: #ecfdf5; color: #047857; }
.q-type.single { background: #eff6ff; color: #1d4ed8; }
.q-status { margin-left: auto; font-size: 13px; font-weight: 600; }
.q-status.ok { color: var(--ok); }
.q-status.err { color: var(--err); }
.q-title { font-size: var(--q-font-size); line-height: 1.7; margin-bottom: 14px; }

.options { display: flex; flex-direction: column; gap: 10px; }
.option {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 12px 14px; border: 1.5px solid var(--border);
    border-radius: 8px; cursor: pointer; transition: all .15s; background: #fff;
    font-size: calc(var(--q-font-size) - 1px); line-height: 1.6;
}
.option:active { background: #f0f6fd; }
.option .opt-key {
    flex-shrink: 0; width: 26px; height: 26px; border-radius: 50%;
    background: #f1f5f9; border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 14px; color: var(--text);
}
.option.selected { border-color: var(--primary); background: #eff6ff; }
.option.selected .opt-key { background: var(--primary); color: #fff; border-color: var(--primary); }
.option.correct { border-color: var(--ok); background: #f0fdf4; }
.option.correct .opt-key { background: var(--ok); color: #fff; border-color: var(--ok); }
.option.wrong { border-color: var(--err); background: #fef2f2; }
.option.wrong .opt-key { background: var(--err); color: #fff; border-color: var(--err); }
.option.disabled { cursor: default; }

/* 答案解析 */
.analysis {
    margin-top: 14px; padding: 12px; border-radius: 8px;
    background: #f8fafc; border: 1px dashed var(--border); font-size: calc(var(--q-font-size) - 2px);
}
.analysis .analysis-ans { margin-bottom: 6px; color: var(--ok); font-weight: 600; }
.analysis .analysis-detail { color: var(--muted); line-height: 1.7; }
.analysis-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.tts-btn {
    padding: 6px 14px; border: 1px solid var(--border); border-radius: 6px;
    background: #fff; cursor: pointer; font-size: 13px; color: var(--text);
    transition: all .2s;
}
.tts-btn:hover { border-color: #6366f1; color: #6366f1; }
.tts-btn.playing { background: #eef2ff; border-color: #6366f1; color: #4f46e5; }
.tts-rate {
    padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px;
    font-size: 13px; background: #fff; color: var(--text); cursor: pointer;
}
body.dark .tts-btn { background: #2a2a4a; border-color: #3a3a5a; color: #e0e0e0; }
body.dark .tts-btn.playing { background: rgba(99,102,241,.2); border-color: #818cf8; color: #a5b4fc; }
body.dark .tts-rate { background: #2a2a4a; border-color: #3a3a5a; color: #e0e0e0; }

/* ===== 答题卡 ===== */
.card-panel {
    background: var(--card); border-radius: var(--radius);
    margin-top: 12px; padding: 12px; border: 1px solid var(--border);
}
.card-header {
    display: flex; align-items: center; justify-content: space-between;
    cursor: pointer; padding: 4px 0; user-select: none;
}
.card-title { font-size: 14px; font-weight: 600; color: var(--text); }
.card-arrow { font-size: 12px; color: var(--text-muted); transition: transform .2s; }
.card-panel.collapsed .card-arrow { transform: rotate(-90deg); }
.card-content { margin-top: 10px; }
.card-content.hidden { display: none; }
.card-tabs { display: flex; gap: 8px; margin-bottom: 10px; }
.card-tab {
    padding: 6px 12px; border: 1px solid var(--border); background: #f8fafc;
    border-radius: 6px; font-size: 13px; cursor: pointer;
}
.card-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 6px; }
.card-cell {
    height: 36px; border-radius: 6px; border: 1px solid var(--border);
    background: #f8fafc; display: flex; align-items: center; justify-content: center;
    font-size: 13px; cursor: pointer; transition: all .12s; font-variant-numeric: tabular-nums;
}
.card-cell:hover { border-color: var(--primary); }
.card-cell.current { outline: 2px solid var(--primary); outline-offset: 1px; font-weight: 700; }
.card-cell.done { background: #dbeafe; border-color: #93c5fd; }
.card-cell.right { background: var(--ok); color: #fff; border-color: var(--ok); }
.card-cell.wrong { background: var(--err); color: #fff; border-color: var(--err); }

/* ===== 答题卡分页 ===== */
.card-pagination {
    display: flex; align-items: center; justify-content: center;
    gap: 12px; margin-top: 10px;
}
.card-page-btn {
    padding: 5px 14px; border: 1px solid var(--border); border-radius: 6px;
    background: #fff; color: var(--text); font-size: 12px; cursor: pointer;
    transition: all .15s;
}
.card-page-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.card-page-btn:disabled { opacity: .4; cursor: not-allowed; }
.card-page-info { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ===== 底部导航 ===== */
.nav-bottom {
    display: flex; gap: 10px; margin-top: 14px;
    position: sticky; bottom: 0; background: var(--bg); padding: 10px 0 6px;
}
.nav-bottom .btn { flex: 1; }
.nav-bottom .btn.danger { flex: 2; }

/* ===== 弹窗 ===== */
.modal-mask {
    position: fixed; inset: 0; background: rgba(0,0,0,.5);
    display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal {
    background: #fff; border-radius: 14px; padding: 24px; width: 100%; max-width: 360px;
    text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,.25);
}
.modal h2 { font-size: 18px; margin-bottom: 12px; }
.result-score { font-size: 52px; font-weight: 800; color: var(--primary); margin: 8px 0; }
.result-lines { font-size: 14px; color: var(--muted); margin-bottom: 16px; line-height: 2; }
.result-lines b { color: var(--text); }

@media (max-width: 480px) {
    .header { padding: 12px 12px 10px; }
    .stats { grid-template-columns: repeat(6, 1fr); }
    .stat-num { font-size: 14px; }
}

/* ===== 夜间模式（18:00-06:00 自动启用） ===== */
body.dark {
    background: #0f0f1a;
    color: #e0e0e0;
}
body.dark .header {
    background: linear-gradient(135deg, #1a1a2e 0%, #2a2a4a 100%);
}
body.dark .stat { background: rgba(255,255,255,.08); }
body.dark .stat-num { color: #e0e0e0; }
body.dark .stat-label { color: #8888aa; }
body.dark .stat-ok .stat-num { color: #4ade80; }
body.dark .stat-err .stat-num { color: #f87171; }
body.dark .timer { color: #c4b5fd; }
body.dark .progress-bar { background: rgba(255,255,255,.1); }
body.dark .progress-fill { background: linear-gradient(90deg, #4ade80, #16a34a); }
body.dark .question-card {
    background: #1a1a2e; border-color: #2a2a4a;
}
body.dark .q-title { color: #e0e0e0; }
body.dark .q-type { background: rgba(196,181,253,.15); color: #c4b5fd; }
body.dark .option {
    background: #252540; border-color: #3a3a5a; color: #e0e0e0;
}
body.dark .option:hover { background: #2f2f4f; }
body.dark .option.correct { background: rgba(74,222,128,.15); border-color: #4ade80; color: #4ade80; }
body.dark .option.wrong { background: rgba(248,113,113,.15); border-color: #f87171; color: #f87171; }
body.dark .option.disabled { opacity: .6; }
body.dark .analysis { background: rgba(196,181,253,.08); border-color: #3a3a5a; }
body.dark .analysis-ans { color: #c4b5fd; }
body.dark .analysis-detail { color: #b0b0d0; }
body.dark .card-panel { background: #1a1a2e; border-color: #2a2a4a; }
body.dark .card-tab { color: #8888aa; }
body.dark .card-tab.active { background: #2a2a4a; color: #e0e0e0; }
body.dark .card-cell {
    background: #252540; border-color: #3a3a5a; color: #e8e8f8; font-weight: 600;
}
body.dark .card-cell.done { background: rgba(99,102,241,.25); color: #a5b4fc; border-color: #6366f1; }
body.dark .card-cell.right { background: rgba(74,222,128,.25); color: #4ade80; border-color: #4ade80; font-weight: 700; }
body.dark .card-cell.wrong { background: rgba(248,113,113,.25); color: #f87171; border-color: #f87171; font-weight: 700; }
body.dark .card-cell.current { background: #6366f1; color: #fff; border-color: #6366f1; font-weight: 700; }
body.dark .card-title { color: #e0e0e0; }
body.dark .card-arrow { color: #a0a0c0; }
body.dark .btn { background: #252540; border-color: #3a3a5a; color: #e0e0e0; }
body.dark .btn.primary { background: #6366f1; border-color: #6366f1; color: #fff; }
body.dark .btn-header { background: rgba(255,255,255,.1); color: #e0e0e0; border-color: rgba(255,255,255,.2); }
body.dark .btn-clear { color: #f87171; }
body.dark .confirm-box, body.dark .result-box {
    background: #1a1a2e; border-color: #2a2a4a;
}
body.dark .confirm-title, body.dark .result-box h2 { color: #e0e0e0; }
body.dark .result-close-x { color: #8888aa; }
body.dark .result-close-x:hover { background: rgba(255,255,255,.1); color: #e0e0e0; }
body.dark .confirm-content { color: #b0b0d0; }

/* ===== 帮助弹窗结构化内容 ===== */
.help-content .help-item {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 7px 0;
}
.help-content .help-icon {
    flex-shrink: 0; width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 8px;
    background: rgba(64, 122, 255, .10);
    color: var(--primary);
}
.help-content .help-icon .icon { width: 18px; height: 18px; }
.help-content .help-txt { flex: 1; min-width: 0; }
.help-content .help-item-title { font-size: 14px; font-weight: 600; color: var(--text); line-height: 1.4; }
.help-content .help-item-desc { font-size: 12px; color: var(--muted); line-height: 1.5; margin-top: 2px; }
body.dark .help-content .help-item-title { color: #e8e8f0; }
body.dark .help-content .help-icon { background: rgba(130, 160, 255, .15); color: #9db4ff; }
body.dark .confirm-btn.cancel { background: #252540; color: #b0b0d0; border-color: #3a3a5a; }
body.dark .confirm-btn.ok { background: #6366f1; color: #fff; }
body.dark .share-tip { color: #8888aa; }
body.dark .mode-select, body.dark .count-selector select {
    background: rgba(255,255,255,.1); color: #e0e0e0; border-color: rgba(255,255,255,.25);
}
body.dark .mode-label-text, body.dark .count-label { color: rgba(255,255,255,.7); }
body.dark .mode-label-text::before { background: rgba(255,255,255,.4); }
body.dark .mode-divider { background: rgba(255,255,255,.4); }
body.dark .btn-mode-review { background: rgba(255,255,255,.1); color: #e0e0e0; border-color: rgba(255,255,255,.2); }

/* 密码弹窗 */
.pwd-box input[type="password"] {
    background: #fff;
    color: #333;
    outline: none;
    transition: border-color .2s;
}
.pwd-box input[type="password"]:focus {
    border-color: #6366f1;
}
.pwd-box input[type="password"]:disabled {
    background: #f5f5f5;
    color: #999;
    cursor: not-allowed;
}
.pwd-box .confirm-btn.ok:disabled {
    opacity: .5;
    cursor: not-allowed;
}
body.dark .pwd-box input[type="password"]:disabled {
    background: #1a1a2e;
    color: #666;
}
body.dark .pwd-box input[type="password"] {
    background: #252540;
    color: #e0e0e0;
    border-color: #3a3a5a;
}
body.dark .pwd-box input[type="password"]:focus {
    border-color: #6366f1;
}
body.dark .pwd-box #ikunResult {
    background: rgba(99,102,241,.1);
}
body.dark .pwd-box #ikunPwd {
    color: #a5b4fc;
}
#ikunPwd:active {
    transform: scale(.95);
}
#ikunPwd:hover {
    opacity: .8;
}

/* ===== 回到顶部按钮 ===== */
.back-to-top {
    position: fixed; right: 16px; bottom: 80px;
    width: 40px; height: 40px; border-radius: 50%;
    border: none; background: var(--primary); color: #fff;
    font-size: 18px; cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,.2);
    display: flex; align-items: center; justify-content: center;
    opacity: 0; visibility: hidden; transform: translateY(10px);
    transition: all .25s ease; z-index: 100;
}
.back-to-top.show {
    opacity: 1; visibility: visible; transform: translateY(0);
}
.back-to-top:hover { background: #2563eb; transform: translateY(-2px); }
body.dark .back-to-top { background: #3b82f6; box-shadow: 0 2px 8px rgba(0,0,0,.4); }
