/* css/exam.css — หน้าทำข้อสอบ: split view, timer, passages เหมือนเอกสารจริง */
.exam-shell { display: flex; flex-direction: column; gap: 12px; }
.exam-header { position: sticky; top: 56px; z-index: 40; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; box-shadow: var(--shadow); }
.exam-title { font-weight: 800; }
.exam-part-badge { background: var(--primary-soft); color: var(--primary); border-radius: 6px; padding: 2px 10px; font-weight: 700; font-size: .85rem; }
.exam-timer { font-variant-numeric: tabular-nums; font-size: 1.35rem; font-weight: 800; letter-spacing: .05em; margin-left: auto; }
.exam-timer.warn { color: var(--warning); }
.exam-timer.danger { color: var(--danger); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .55; } }
.exam-count { font-size: .85rem; color: var(--text-muted); }

.exam-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.exam-tabs { display: none; gap: 8px; }
@media (max-width: 1023px) {
  .exam-layout { grid-template-columns: 1fr; }
  .exam-passages, .exam-questions { display: none; }
  .exam-layout[data-tab="passage"] .exam-passages { display: block; }
  .exam-layout[data-tab="questions"] .exam-questions { display: block; }
  .exam-tabs { display: flex; gap: 8px; }
}
.exam-tabs button { flex: 1; padding: 10px; border: 1px solid var(--border); background: var(--surface-2); border-radius: 8px; font-weight: 700; cursor: pointer; }
.exam-tabs button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
@media (min-width: 1024px) {
  .exam-passages { display: block !important; position: sticky; top: 132px; max-height: calc(100vh - 150px); overflow-y: auto; }
  .exam-questions { display: block !important; }
}

/* ===== passage renderers ===== */
.passage-doc { background: #fff; color: #1a1a1a; border: 1px solid #d0d5dd; border-radius: 4px; padding: 20px 22px; box-shadow: 0 2px 6px rgba(0,0,0,.12); font-family: var(--font-latin), var(--font-thai); font-size: .95rem; line-height: 1.65; }
:root[data-theme="dark"] .passage-doc, @media (prefers-color-scheme: dark) { }
.passage-label { display: inline-block; font-size: .72rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: #0b5cad; border: 1px solid #0b5cad; border-radius: 4px; padding: 1px 8px; margin-bottom: 10px; }
.passage-doc h3.doc-title { margin: .2em 0 .5em; font-size: 1.12em; border-bottom: 2px solid #333; padding-bottom: 6px; color: #111; }
.doc-meta { width: 100%; border-collapse: collapse; margin-bottom: 12px; font-size: .9em; }
.doc-meta td { padding: 2px 4px; vertical-align: top; }
.doc-meta td:first-child { font-weight: 700; width: 90px; color: #444; }
.doc-meta tr + tr td { border-top: 1px solid #e5e7eb; }
.passage-doc table.doc-table { width: 100%; border-collapse: collapse; font-size: .88em; margin: 10px 0; }
.passage-doc table.doc-table th, .passage-doc table.doc-table td { border: 1px solid #9ca3af; padding: 5px 8px; text-align: left; }
.passage-doc table.doc-table th { background: #e5e7eb; color: #111; }
.chat-row { display: flex; gap: 10px; margin: 10px 0; align-items: flex-start; }
.chat-avatar { flex: 0 0 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; color: #fff; font-size: .8rem; }
.chat-body { background: #eef1f5; border-radius: 12px; padding: 8px 12px; max-width: 85%; }
.chat-name { font-size: .72rem; font-weight: 700; color: #374151; }
.chat-time { font-size: .68rem; color: #6b7280; float: right; margin-left: 8px; }
.blank { display: inline-block; min-width: 90px; border-bottom: 2px solid #0b5cad; color: #0b5cad; font-weight: 700; text-align: center; padding: 0 6px; }
.sentence-slot { display: inline-block; background: #fde68a; border: 1px dashed #b45309; color: #92400e; border-radius: 4px; padding: 0 4px; font-weight: 700; }
.evidence-highlight { background: #fff3a3; outline: 2px solid #eab308; border-radius: 2px; }
.multi-passage-separator { border: none; border-top: 3px double #9ca3af; margin: 14px 0; }

/* navigation panel */
.exam-sidebar { position: fixed; right: 12px; bottom: 70px; z-index: 45; }
.exam-nav-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.2); padding: 12px; width: 260px; display: none; }
.exam-nav-panel.open { display: block; }
.exam-nav-toggle { border-radius: 999px; width: 56px; height: 56px; font-size: 1.3rem; border: none; background: var(--primary); color: #fff; box-shadow: var(--shadow); cursor: pointer; }
@media (min-width: 1280px) {
  .exam-sidebar { position: static; }
  .exam-nav-panel { display: block !important; width: auto; box-shadow: none; border: none; background: transparent; padding: 0; }
  .exam-nav-toggle { display: none; }
}

/* modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .55); z-index: 80; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: var(--surface); border-radius: var(--radius); max-width: 560px; width: 100%; max-height: 85vh; overflow-y: auto; padding: 22px; box-shadow: 0 20px 50px rgba(0,0,0,.35); }
.modal h2 { margin-top: 0; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.q-list-inline { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.q-list-inline span { background: var(--surface-2); border-radius: 6px; padding: 2px 8px; font-size: .85rem; }

/* results */
.score-hero { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; }
.score-ring { width: 150px; height: 150px; }
.part-score-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 14px 0; }
@media (max-width: 640px) { .part-score-grid { grid-template-columns: 1fr; } }
.part-score { text-align: center; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.bar-row { display: grid; grid-template-columns: minmax(120px, 200px) 1fr auto; gap: 10px; align-items: center; margin: 6px 0; font-size: .9rem; }
.bar-track { background: var(--surface-2); border-radius: 6px; height: 14px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--primary); }
.bar-fill.weak { background: var(--danger); }
.bar-fill.ok { background: var(--warning); }
.bar-fill.strong { background: var(--success); }

/* history chart */
.chart-box { width: 100%; overflow-x: auto; }
.review-filters { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.review-filters button { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 6px 14px; cursor: pointer; font-weight: 600; }
.review-filters button.active { background: var(--primary); border-color: var(--primary); color: #fff; }
