:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #1a2233;
  --muted: #6b7488;
  --line: #e2e6ef;
  --brand: #3b5bdb;
  --brand-soft: #edf1ff;
  --ok: #16a34a;
  --ok-soft: #e9f7ee;
  --bad: #dc2626;
  --bad-soft: #fdecec;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 30, 60, 0.05), 0 8px 24px rgba(20, 30, 60, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0 16px 64px;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans Thai', 'Sarabun',
    'Leelawadee UI', 'Helvetica Neue', sans-serif;
  font-size: 16px;
  line-height: 1.65;
  -webkit-text-size-adjust: 100%;
}

.wrap {
  max-width: 720px;
  margin: 0 auto;
}

.wrap-wide {
  max-width: 1080px;
}

header.top {
  padding: 28px 0 18px;
}

header.top h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.01em;
}

header.top p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 16px;
}

h2 {
  font-size: 17px;
  margin: 0 0 14px;
}

label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
}

input[type='text'],
input[type='password'] {
  width: 100%;
  padding: 11px 13px;
  font: inherit;
  color: inherit;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 16px;
}

input:focus-visible,
button:focus-visible,
.choice:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

button {
  font: inherit;
  font-weight: 600;
  padding: 11px 20px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
}

button:hover:not(:disabled) {
  filter: brightness(1.07);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

button.ghost {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

button.small {
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
}

button.danger {
  background: #fff;
  color: var(--bad);
  border-color: var(--line);
}

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.spread {
  justify-content: space-between;
}

.hidden {
  display: none !important;
}

.msg {
  font-size: 14px;
  padding: 10px 13px;
  border-radius: 10px;
  margin-bottom: 14px;
  background: var(--bad-soft);
  color: var(--bad);
}

/* ---------------------------------------------------------- ทำแบบฝึกหัด */

.progress-head {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}

.bar {
  height: 6px;
  background: var(--line);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 22px;
}

.bar > span {
  display: block;
  height: 100%;
  background: var(--brand);
  border-radius: 99px;
  transition: width 0.25s ease;
}

.qtext {
  font-size: 19px;
  font-weight: 600;
  line-height: 1.55;
  margin: 0 0 18px;
}

.choice {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  width: 100%;
  padding: 13px 15px;
  margin-bottom: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  font: inherit;
  color: inherit;
  font-weight: 400;
  text-align: start;
}

.choice:hover {
  border-color: #c3ccdf;
  background: #fafbff;
}

.choice.selected {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.choice .marker {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.choice.selected .marker {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.dots {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 18px;
}

.dot {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  padding: 0;
}

.dot.done {
  background: var(--brand-soft);
  border-color: #c3ccf5;
  color: var(--brand);
}

.dot.current {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

/* -------------------------------------------------------------- ผลคะแนน */

.score-hero {
  text-align: center;
  padding: 8px 0 4px;
}

.score-big {
  font-size: 46px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.score-sub {
  color: var(--muted);
  font-size: 15px;
}

.pill {
  display: inline-block;
  margin-top: 12px;
  padding: 5px 16px;
  border-radius: 99px;
  font-size: 14px;
  font-weight: 600;
}

.pill.pass {
  background: var(--ok-soft);
  color: var(--ok);
}

.pill.fail {
  background: var(--bad-soft);
  color: var(--bad);
}

.review {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 15px 17px;
  margin-bottom: 12px;
}

.review.ok {
  border-inline-start: 4px solid var(--ok);
}

.review.no {
  border-inline-start: 4px solid var(--bad);
}

.review h3 {
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.55;
}

.review .line {
  font-size: 14px;
  margin: 3px 0;
}

.review .line b {
  font-weight: 600;
}

.review .why {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  font-size: 14px;
  color: var(--muted);
}

.tag {
  float: inline-end;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 99px;
  margin-inline-start: 10px;
}

.tag.ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.tag.no {
  background: var(--bad-soft);
  color: var(--bad);
}

/* ---------------------------------------------------------------- ผู้ดูแล */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.stat .n {
  font-size: 27px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.stat .k {
  font-size: 13px;
  color: var(--muted);
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  white-space: nowrap;
}

th,
td {
  padding: 10px 12px;
  text-align: start;
  border-bottom: 1px solid var(--line);
}

th {
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 600;
  background: #fafbfd;
}

tbody tr:hover {
  background: #fafbff;
}

td.num {
  font-variant-numeric: tabular-nums;
}

.qstat {
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.qstat:last-child {
  border-bottom: 0;
}

.qstat .head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  font-size: 15px;
  align-items: baseline;
}

.qstat .pct {
  flex: none;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.qbar {
  height: 8px;
  background: var(--line);
  border-radius: 99px;
  overflow: hidden;
  margin: 8px 0;
}

.qbar > span {
  display: block;
  height: 100%;
  border-radius: 99px;
}

.breakdown {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
}

.breakdown .correct-choice {
  color: var(--ok);
  font-weight: 600;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 34px 12px;
}

dialog {
  border: 0;
  border-radius: var(--radius);
  padding: 0;
  max-width: 640px;
  width: calc(100% - 32px);
  box-shadow: 0 20px 60px rgba(15, 22, 45, 0.25);
}

dialog::backdrop {
  background: rgba(15, 22, 45, 0.45);
}

dialog .body {
  padding: 22px 24px 24px;
  max-height: 74vh;
  overflow-y: auto;
  color: var(--ink);
}

@media (max-width: 560px) {
  .card {
    padding: 18px;
  }
  .qtext {
    font-size: 17px;
  }
  .score-big {
    font-size: 38px;
  }
}
