/* Global styles for broker-exam-web (mobile-first) */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif; background: #f7f8fa; color: #1a1a1a; line-height: 1.6; font-size: 15px; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 10; background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%); color: #fff; padding: 12px 16px; display: flex; align-items: center; gap: 12px; box-shadow: 0 2px 8px rgba(99,102,241,.2); }
.topbar h1 { margin: 0; font-size: 17px; font-weight: 600; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .back { cursor: pointer; font-size: 20px; padding: 4px 8px; border-radius: 6px; background: rgba(255,255,255,.15); text-decoration: none; color: #fff; }
.topbar .back:active { background: rgba(255,255,255,.3); }

/* Container */
.container { max-width: 900px; margin: 0 auto; padding: 16px; }

/* Card */
.card { background: #fff; border-radius: 12px; padding: 16px; margin-bottom: 12px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }

/* Home hero */
.hero { text-align: center; padding: 32px 16px 24px; }
.hero-title { font-size: 24px; font-weight: 700; margin: 0 0 8px; background: linear-gradient(135deg, #6366f1 0%, #ec4899 100%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-sub { color: #666; margin: 0; font-size: 14px; }

/* Subject cards */
.subject-card { background: linear-gradient(135deg, #fff 0%, #f8f5ff 100%); border-left: 4px solid #6366f1; padding: 16px; border-radius: 12px; margin-bottom: 12px; display: block; text-decoration: none; color: inherit; box-shadow: 0 1px 3px rgba(0,0,0,.06); transition: transform .15s; }
.subject-card:active { transform: scale(0.98); }
.subject-card.s2 { border-left-color: #ec4899; background: linear-gradient(135deg, #fff 0%, #fef2f8 100%); }
.subject-card .subject-title { font-size: 18px; font-weight: 600; margin: 0 0 4px; }
.subject-card .subject-meta { color: #888; font-size: 13px; }

/* Action buttons */
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.btn { display: flex; align-items: center; justify-content: center; padding: 14px 16px; background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; color: #333; text-decoration: none; font-size: 15px; font-weight: 500; cursor: pointer; }
.btn:active { background: #f3f4f6; }
.btn-primary { background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff; border: none; box-shadow: 0 2px 8px rgba(99,102,241,.3); }
.btn-primary:active { opacity: .9; }
.btn-danger { background: linear-gradient(135deg, #ec4899, #f43f5e); color: #fff; border: none; }

/* Category list */
.cat-section { margin-bottom: 18px; }
.cat-title { font-size: 15px; font-weight: 600; color: #444; margin: 0 0 8px; padding-left: 8px; border-left: 3px solid #6366f1; }
.group-title { font-size: 13px; color: #888; margin: 8px 0 4px; padding-left: 12px; }

.file-item { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: #fff; border-radius: 10px; margin-bottom: 8px; box-shadow: 0 1px 2px rgba(0,0,0,.04); text-decoration: none; color: inherit; transition: transform .15s; }
.file-item:active { transform: scale(0.98); background: #f8f9fb; }
.file-icon { width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 14px; color: #fff; font-weight: 700; flex-shrink: 0; }
.file-icon.pdf { background: #ef4444; }
.file-icon.docx, .file-icon.doc { background: #3b82f6; }
.file-info { flex: 1; min-width: 0; }
.file-name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 0; }
.file-size { font-size: 12px; color: #999; margin: 2px 0 0; }
.file-arrow { color: #ccc; font-size: 18px; }

/* Quiz picker */
.quiz-picker-list { margin-top: 8px; }
.quiz-item { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; background: #fff; border-radius: 10px; margin-bottom: 8px; box-shadow: 0 1px 2px rgba(0,0,0,.04); text-decoration: none; color: inherit; }
.quiz-item:active { background: #f8f9fb; }
.quiz-item-title { font-size: 15px; font-weight: 500; }
.quiz-item-meta { font-size: 13px; color: #888; }
.quiz-item-badge { background: #eef2ff; color: #6366f1; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; }

/* Quiz viewer */
.quiz-header { background: #fff; padding: 12px 16px; border-radius: 10px; margin-bottom: 12px; display: flex; align-items: center; gap: 12px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.mode-switch { display: flex; background: #f3f4f6; border-radius: 8px; padding: 2px; }
.mode-switch button { flex: 1; padding: 8px 12px; border: none; background: transparent; cursor: pointer; font-size: 13px; font-weight: 500; color: #666; border-radius: 6px; transition: all .2s; }
.mode-switch button.active { background: #6366f1; color: #fff; box-shadow: 0 1px 3px rgba(99,102,241,.3); }

.question-card { background: #fff; border-radius: 12px; padding: 18px 16px; margin-bottom: 12px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.question-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.question-no { font-size: 13px; color: #888; }
.question-type { background: #eef2ff; color: #6366f1; padding: 2px 8px; border-radius: 4px; font-size: 12px; }
.question-type.multi { background: #fef3c7; color: #d97706; }
.question-type.judge { background: #dcfce7; color: #16a34a; }
.question-stem { font-size: 15px; font-weight: 500; margin-bottom: 12px; line-height: 1.7; }

.option { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 8px; margin-bottom: 8px; cursor: pointer; transition: all .15s; }
.option:active { background: #f3f4f6; }
.option.selected { background: #eef2ff; border-color: #6366f1; }
.option.correct { background: #dcfce7; border-color: #16a34a; }
.option.wrong { background: #fee2e2; border-color: #ef4444; }
.option-label { width: 24px; height: 24px; border-radius: 50%; background: #fff; border: 1px solid #d1d5db; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; flex-shrink: 0; color: #666; }
.option.selected .option-label { background: #6366f1; color: #fff; border-color: #6366f1; }
.option.correct .option-label { background: #16a34a; color: #fff; border-color: #16a34a; }
.option.wrong .option-label { background: #ef4444; color: #fff; border-color: #ef4444; }
.option-text { flex: 1; font-size: 14px; line-height: 1.5; }

.explain { margin-top: 12px; padding: 10px 12px; background: #fef3c7; border-radius: 8px; border-left: 3px solid #f59e0b; font-size: 13px; line-height: 1.6; color: #78350f; }
.explain-label { font-weight: 600; margin-right: 4px; }

/* Navigation */
.quiz-nav { display: flex; gap: 10px; margin-top: 16px; }
.quiz-nav button { flex: 1; }

/* Answer sheet (question number grid) */
.sheet-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; margin-top: 12px; }
.sheet-cell { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; font-size: 13px; font-weight: 500; cursor: pointer; }
.sheet-cell.answered { background: #dbeafe; border-color: #60a5fa; color: #1e40af; }
.sheet-cell.correct { background: #dcfce7; border-color: #16a34a; color: #166534; }
.sheet-cell.wrong { background: #fee2e2; border-color: #ef4444; color: #991b1b; }
.sheet-cell.current { outline: 2px solid #6366f1; outline-offset: 2px; }

/* Result */
.result-hero { text-align: center; padding: 28px 16px; background: linear-gradient(135deg, #6366f1 0%, #ec4899 100%); color: #fff; border-radius: 12px; margin-bottom: 16px; }
.result-score { font-size: 48px; font-weight: 700; line-height: 1; }
.result-passed { background: linear-gradient(135deg, #10b981 0%, #059669 100%); }
.result-failed { background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%); }
.result-label { font-size: 13px; opacity: .9; margin-top: 6px; }
.result-verdict { font-size: 20px; font-weight: 600; margin-top: 10px; }
.result-summary { background: #fff; border-radius: 12px; padding: 14px 16px; display: flex; justify-content: space-around; text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,.06); margin-bottom: 12px; }
.result-summary .num { font-size: 22px; font-weight: 700; color: #6366f1; }
.result-summary .lbl { font-size: 12px; color: #888; }

/* Viewer page */
.viewer-wrap { background: #fff; border-radius: 12px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.06); min-height: 60vh; }
.viewer-toolbar { padding: 10px 14px; border-bottom: 1px solid #eef2f7; display: flex; justify-content: space-between; align-items: center; background: #fafbfc; }
.viewer-body { padding: 14px; max-height: calc(100vh - 180px); overflow: auto; }
.pdf-page { margin: 0 auto 10px; display: block; max-width: 100%; height: auto; box-shadow: 0 1px 3px rgba(0,0,0,.1); }

/* Loading */
.loading { text-align: center; padding: 40px 20px; color: #888; }
.loading::before { content: '⏳'; display: block; font-size: 32px; margin-bottom: 8px; }
.empty { text-align: center; padding: 40px 20px; color: #999; }

/* Responsive */
@media (min-width: 640px) {
    .container { padding: 24px; }
    .actions { grid-template-columns: repeat(4, 1fr); }
    .sheet-grid { grid-template-columns: repeat(10, 1fr); }
}
