/* =====================================================================
   HTET prep additions: attempt palette states, analysis, planner, charts
   (loaded after style.css)
   ===================================================================== */
:root {
  --review: #6250d6;
  --review-bg: #efedfc;
  --skip: #c3c2b7;
  --ink-2: #52514e;
  --ink-3: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --series-1: #2a78d6;
  --track: #eaf0ff;
}

.small { font-size: 12.5px; }
.muted { color: var(--muted); }
.c-ok { color: var(--success); }
.c-bad { color: var(--danger); }
.pad { padding: 18px; }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.link { color: var(--primary); font-weight: 600; }
.link:hover { text-decoration: underline; }
.navbar .nav-links a.active { background: rgba(255, 255, 255, 0.18); opacity: 1; }
.card-title { font-size: 16px; margin: 0 0 6px; }
.card-title-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.sub-title { font-size: 13.5px; margin: 16px 0 8px; }
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 900px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.grid-2 > * { min-width: 0; }
.plain-list { margin: 8px 0 0; padding-left: 18px; line-height: 1.6; }

/* ---- attempt page ---- */
.question-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.opt-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.question-number-tag { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.kbd-hint { font-size: 11.5px; color: var(--muted); align-self: center; }
@media (max-width: 640px) { .kbd-hint { display: none; } }
.btn-review { background: var(--review-bg); color: var(--review); }
.attempt-bottombar .btn { padding: 11px 8px; }
.section-tabs {
  position: sticky; top: 106px; z-index: 39;
  display: flex; gap: 6px; overflow-x: auto; padding: 8px 16px;
  background: #fff; border-bottom: 1px solid var(--border);
}
.section-tabs[hidden] { display: none; }
.section-tab {
  flex: 0 0 auto; border: 1.5px solid var(--border); background: #fff; color: var(--text);
  border-radius: 20px; padding: 6px 12px; font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.section-tab .count { color: var(--muted); font-weight: 500; margin-left: 4px; }
.section-tab.active { border-color: var(--primary); background: var(--primary); color: #fff; }
.section-tab.active .count { color: #dbe5ff; }
.palette-section { font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; margin: 12px 0 6px; }
.palette-section:first-child { margin-top: 0; }
#paletteGrid { max-height: 52vh; overflow-y: auto; padding: 3px; }
.palette-cell.st-answered { background: var(--success); color: #fff; }
.palette-cell.st-notanswered { background: var(--danger); color: #fff; }
.palette-cell.st-marked { background: var(--review); color: #fff; border-radius: 50%; }
.palette-cell.st-answered-marked { background: var(--review); color: #fff; border-radius: 50%; box-shadow: inset 0 0 0 3px var(--success); }
.legend b { color: var(--text); margin-left: 2px; }
.dot-answered { background: var(--success); }
.dot-notanswered { background: var(--danger); }
.dot-notvisited { background: #eef0f5; border: 1px solid #d1d5db; }
.dot-marked { background: var(--review); }
.dot-answered-marked { background: var(--review); box-shadow: inset 0 0 0 2px var(--success); }
.tag-pill.review { background: var(--review-bg); color: var(--review); }

/* ---- tiles ---- */
.tile-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 16px; }
@media (min-width: 640px) { .tile-row { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 992px) { .tile-row { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); } }
.tile { background: #f8f9fc; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; min-width: 0; }
.tile-label { font-size: 11.5px; color: var(--muted); }
.tile-value { font-size: 19px; font-weight: 700; margin-top: 2px; }
.tile-value small { font-size: 12px; font-weight: 500; color: var(--muted); }

/* ---- result page ---- */
.result-head { padding: 20px; }
.result-head h2 { margin: 6px 0 2px; font-size: 20px; }
.result-head-main { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.score-block { text-align: right; min-width: 220px; }
@media (max-width: 640px) { .score-block { text-align: left; } }
.status-line { font-size: 13px; font-weight: 600; margin: 2px 0 6px; }
.status-line.ok { color: var(--success); }
.status-line.warn { color: #b45309; }
.target-meter { height: 8px; border-radius: 4px; background: var(--track); overflow: hidden; margin: 6px 0 4px; }
.target-meter-fill { height: 100%; background: var(--primary); border-radius: 4px; }
.tabs { display: flex; gap: 4px; margin: 20px 0 14px; overflow-x: auto; border-bottom: 1px solid var(--border); }
.tab { background: none; border: none; padding: 10px 14px; font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2.5px solid transparent; white-space: nowrap; font-family: inherit; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel[hidden] { display: none; }

.insights { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-direction: column; gap: 10px; }
.insight { border: 1px solid var(--border); border-left: 4px solid var(--skip); border-radius: 8px; padding: 10px 12px; }
.insight.sev-high { border-left-color: var(--danger); }
.insight.sev-medium { border-left-color: var(--accent); }
.insight.sev-low { border-left-color: var(--primary); }
.insight-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.insight-title { font-weight: 700; font-size: 14px; }
.insight-detail { font-size: 13px; color: var(--ink-2); margin-top: 4px; line-height: 1.45; }
.gain-chip { flex: 0 0 auto; font-size: 11.5px; font-weight: 700; color: var(--success); background: var(--success-bg); padding: 2px 8px; border-radius: 12px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.q-chip { font-size: 12px; padding: 3px 8px; border-radius: 12px; background: #eef0f5; font-weight: 600; }
.q-chip:hover { background: #e0e5f0; }
.q-chip.wrong { background: var(--danger-bg); color: var(--danger); }
.q-chip.correct { background: var(--success-bg); color: var(--success); }
.topic-chip { font-size: 12px; padding: 3px 9px; border-radius: 12px; background: #eaf0ff; color: var(--primary-dark); }
.muted-chip { background: #f1f1ef; color: var(--ink-2); }
.ok-chip { background: var(--success-bg); color: var(--success); }
.order-list { margin: 8px 0 0; padding-left: 20px; line-height: 1.7; font-weight: 600; }

.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; font-variant-numeric: tabular-nums; }
.data-table thead th { font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .2px; }
.data-table tbody th { font-weight: 600; white-space: normal; min-width: 140px; }
.data-table tr.hl td, .data-table tr.hl th { background: #fff7ec; }
.data-table tr[hidden] { display: none; }
.meter { display: inline-block; width: 64px; height: 6px; background: var(--track); border-radius: 3px; overflow: hidden; vertical-align: middle; margin-right: 6px; }
.meter-fill { height: 100%; background: var(--series-1); border-radius: 3px; }
.status-chip { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 12px; text-transform: capitalize; background: #eef0f5; color: var(--ink-2); white-space: nowrap; }
.status-chip.st-weak, .status-chip.lv-weak { background: var(--danger-bg); color: var(--danger); }
.status-chip.st-average, .status-chip.lv-average { background: #fff3e0; color: #b45309; }
.status-chip.st-strong, .status-chip.lv-strong { background: var(--success-bg); color: var(--success); }

.bucket-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 640px) { .bucket-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 992px) { .bucket-grid { grid-template-columns: repeat(3, 1fr); } }
.bucket { border-top: 3px solid var(--skip); }
.bucket.b-correct_fast { border-top-color: var(--success); }
.bucket.b-correct_slow { border-top-color: #86b6ef; }
.bucket.b-wrong_fast, .bucket.b-wrong_slow { border-top-color: var(--danger); }
.bucket.b-skipped_after_time { border-top-color: var(--accent); }
.bucket-head { display: flex; justify-content: space-between; align-items: baseline; }
.bucket-title { font-weight: 700; font-size: 14px; }
.bucket-count { font-size: 20px; font-weight: 700; }

.filter-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; background: #eef0f5; padding: 3px; border-radius: 8px; }
.seg-btn { position: relative; border: none; background: transparent; padding: 6px 10px; font-size: 12.5px; font-weight: 600; border-radius: 6px; cursor: pointer; color: var(--ink-2); text-transform: capitalize; font-family: inherit; }
.seg-btn.active { background: #fff; color: var(--primary); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.seg-btn input { position: absolute; opacity: 0; pointer-events: none; }
.seg-sm .seg-btn { padding: 5px 9px; font-size: 12px; }
select { padding: 7px 10px; border: 1.5px solid var(--border); border-radius: 8px; font-size: 13px; background: #fff; font-family: inherit; }

.review-item[hidden] { display: none; }
.review-item.flash { box-shadow: 0 0 0 3px var(--accent); transition: box-shadow .3s; }
.review-item { scroll-margin-top: 70px; }
.q-head-right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.review-item .q-head { gap: 10px; flex-wrap: wrap; }
.time-pill { font-size: 11.5px; font-weight: 600; color: var(--ink-2); background: #f1f1ef; padding: 2px 8px; border-radius: 12px; }
.time-pill.slow { background: #fff3e0; color: #b45309; }
.review-q { margin-top: 0; font-size: 15px; }
.opt-flag { margin-left: auto; font-size: 12px; font-weight: 700; flex: 0 0 auto; }
.opt-flag.ok { color: var(--success); }
.opt-flag.bad { color: var(--danger); }
.explanation { margin-top: 8px; background: #f5f8ff; border-left: 3px solid var(--primary); padding: 8px 12px; border-radius: 6px; font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; }

/* ---- charts (inline SVG) ---- */
.viz { display: block; overflow: visible; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; max-width: 100%; height: auto; }
.strip-scroll .viz { max-width: none; }
.viz .track { fill: var(--track); }
.viz .bar { fill: var(--series-1); }
.viz .ref { fill: #0b0b0b; }
.viz .grid { stroke: var(--grid); stroke-width: 1; }
.viz .baseline { stroke: var(--axis); stroke-width: 1; }
.viz .sep { stroke: var(--grid); stroke-width: 1; }
.viz .ideal-line { stroke: var(--ink-2); stroke-width: 1.5; }
.viz .target-line { stroke: var(--accent); stroke-width: 1.5; }
.viz .axis-label { fill: var(--ink-3); font-size: 11px; }
.viz .value-label { fill: #0b0b0b; font-size: 12px; font-weight: 700; }
.viz .series-line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.viz .series-dot { fill: var(--series-1); stroke: #fff; stroke-width: 2; }
.viz .m-ok { fill: var(--success); }
.viz .m-bad { fill: var(--danger); }
.viz .m-skip { fill: var(--skip); }
.viz .tip-target { cursor: pointer; outline: none; }
.viz .tip-target.hover .m-ok, .viz .tip-target.hover .m-bad, .viz .tip-target.hover .m-skip, .viz .tip-target.hover .bar { opacity: .75; }
.viz .tip-target:focus-visible .series-dot, .viz .tip-target:focus-visible .bar { stroke: #0b0b0b; stroke-width: 2; }
.viz-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--ink-2); margin: 4px 0 10px; }
.viz-legend .key { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -2px; }
.viz-legend .key.key-ref, .viz-legend .key.key-target { width: 3px; border-radius: 1px; }
.key-bar { background: var(--series-1); }
.key-ref { background: var(--ink-2); }
.key-target { background: var(--accent); }
.key-ok { background: var(--success); }
.key-bad { background: var(--danger); }
.key-skip { background: var(--skip); }
.strip-scroll { overflow-x: auto; padding-bottom: 4px; }
.bullet-rows { display: flex; flex-direction: column; gap: 4px; }
.bullet-row { display: grid; grid-template-columns: 170px 1fr 110px; gap: 12px; align-items: center; }
@media (max-width: 640px) { .bullet-row { grid-template-columns: 1fr 96px; } .bullet-label { grid-column: 1 / -1; } }
.bullet-label { font-size: 13px; font-weight: 600; }
.bullet-value { font-size: 13px; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.viz-tooltip { position: fixed; z-index: 200; pointer-events: none; background: #16213e; color: #fff; font-size: 12px; line-height: 1.45; padding: 7px 10px; border-radius: 6px; white-space: pre-line; max-width: 280px; opacity: 0; transition: opacity .08s; box-shadow: 0 4px 12px rgba(0, 0, 0, .2); left: 0; top: 0; }
.viz-tooltip.show { opacity: 1; }
.heat-table td.heat { text-align: center; font-weight: 600; }
.ramp-legend { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.ramp-legend .ramp { display: inline-flex; }
.ramp-legend .ramp i { width: 18px; height: 10px; display: inline-block; }

/* ---- dashboard ---- */
.group-title { margin-top: 28px; }
.quiz-card-top { display: flex; gap: 6px; flex-wrap: wrap; }
.plan-cta { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; border-left: 4px solid var(--accent); }
.today-card { border-left: 4px solid var(--primary); }
.today-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; }
.today-list li { display: flex; gap: 8px; align-items: baseline; }
.kind-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); flex: 0 0 8px; transform: translateY(-1px); }
.today-list .kind-mock .kind-dot, .today-list .kind-analysis .kind-dot { background: var(--accent); }
.today-list .kind-revise .kind-dot { background: var(--review); }

/* ---- planner ---- */
.planner-form .field > label { font-size: 14px; }
.inline-fields { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inline-fields input[type=number], .inline-fields input[type=date] { width: auto; flex: 1 1 140px; }
.inline-fields input[type=range] { flex: 1 1 160px; }
.field input[type=date], .field input[type=number] { padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 8px; font-size: 14px; font-family: inherit; }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.check-line { display: flex; gap: 8px; align-items: center; font-weight: 500; font-size: 13px; margin: 6px 0; }
.check-line input { width: auto; }
.level-table { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.level-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; border-bottom: 1px dashed var(--border); padding-bottom: 8px; }
.level-name { font-size: 13.5px; font-weight: 600; }
.notice-stack { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.notice { padding: 10px 14px; border-radius: 8px; font-size: 13.5px; line-height: 1.45; }
.notice.ok { background: var(--success-bg); color: #14532d; }
.notice.warn { background: #fff3e0; color: #7c2d12; }
.phase-bar { display: flex; gap: 2px; height: 28px; margin: 8px 0; }
.phase-seg { border-radius: 4px; display: flex; align-items: center; padding: 0 8px; font-size: 12px; font-weight: 600; color: #fff; overflow: hidden; white-space: nowrap; min-width: 4px; }
.ph-learn { background: #2a78d6; }
.ph-practice { background: #c2410c; }
.ph-revision { background: #6250d6; }
.ph-eve { background: #6b6a65; }
.phase-chip { font-size: 11px; font-weight: 700; color: #fff; padding: 2px 8px; border-radius: 10px; text-transform: capitalize; vertical-align: 2px; white-space: nowrap; }
.topic-list { margin: 8px 0 0; padding-left: 20px; line-height: 1.7; font-size: 13.5px; }
.day-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.day-card { padding: 12px 14px; scroll-margin-top: 70px; }
.day-card.is-today { border: 2px solid var(--primary); }
.day-card.is-done { opacity: .62; }
.day-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.day-check { display: flex; gap: 8px; align-items: center; cursor: pointer; font-size: 14px; }
.day-check input { width: 18px; height: 18px; }
.day-meta { display: flex; gap: 8px; align-items: center; }
.day-items { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.day-items li { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; }
.day-item-body { flex: 1; min-width: 0; }
.kind-tag { flex: 0 0 78px; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .3px; padding: 3px 6px; border-radius: 6px; text-align: center; background: #eaf0ff; color: var(--primary-dark); }
.kind-mock .kind-tag, .kind-analysis .kind-tag { background: #fff3e0; color: #b45309; }
.kind-revise .kind-tag { background: var(--review-bg); color: var(--review); }
.kind-practice .kind-tag { background: var(--success-bg); color: var(--success); }
.kind-strategy .kind-tag { background: #f1f1ef; color: var(--ink-2); }
@media (max-width: 480px) { .kind-tag { flex-basis: 64px; } }

/* phones: the attempt top bar wraps to two rows, so keep section tabs in normal flow */
@media (max-width: 640px) {
  .section-tabs { position: static; }
}
