/* TCT funnel: trang vở ô ly, bút đỏ chấm bài.
   Mực xanh = hành động và chữ chính. Mực đỏ = chỉ dấu của thầy cô, lề vở, cảnh báo. */
:root {
  color-scheme: light;
  --paper: #fbfcff;
  --sheet: #ffffff;
  --grid: #e0e9f7;
  --line: #c6d3ea;
  --ink: #1b2f7a;
  --ink-deep: #122058;
  --ink-wash: #e7edfb;
  --text: #18203a;
  --muted: #566080;
  --red: #d7352b;
  --red-wash: #fdecea;
  --red-margin: rgba(215, 53, 43, 0.42);
  --font: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --hand: 'Patrick Hand', 'Bradley Hand', 'Segoe Print', cursive;
  --margin-x: 8px;
  --pad-x: 22px;
  --pad-r: 16px;
  --cell: 28px;
}

@media (min-width: 720px) {
  :root { --margin-x: 56px; --pad-x: 96px; --pad-r: 40px; }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: var(--cell) var(--cell);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.6;
  min-height: 100vh;
  min-height: 100dvh;
}

/* Hai nét đỏ đôi bên lề, như vở học sinh */
body::before {
  content: '';
  position: fixed;
  top: 0;
  bottom: 0;
  left: var(--margin-x);
  width: 4px;
  border-left: 1px solid var(--red-margin);
  border-right: 1px solid var(--red-margin);
  pointer-events: none;
  z-index: 0;
}

img { max-width: 100%; height: auto; }
sup { font-size: 0.7em; line-height: 0; }
[hidden] { display: none !important; }

h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -0.01em; text-wrap: balance; }
p { margin: 0; text-wrap: pretty; }

.wrap {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1120px;
  margin-inline: auto;
  padding-inline: var(--pad-x) var(--pad-r);
}

/* Đầu trang */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-block: 20px 8px;
}

.brand {
  display: inline-flex;
  flex-direction: column;
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
  line-height: 1.1;
  white-space: nowrap;
}

.brand svg { display: block; width: 126px; height: 11px; margin-top: 3px; }

.top-note { color: var(--muted); font-size: 14px; text-align: right; }

/* Nút */
.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 12px 24px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: var(--ink);
  color: #fff;
  font: inherit;
  font-weight: 700;
  font-size: 17px;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
}

.btn:hover { background: var(--ink-deep); border-color: var(--ink-deep); }
.btn:disabled, .btn[aria-disabled='true'] { opacity: 0.55; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.ghost:hover { background: var(--ink-wash); border-color: var(--ink); }
.btn.small { min-height: 44px; padding: 8px 16px; font-size: 15px; }
.btn.block { width: 100%; }

:focus-visible { outline: 3px solid var(--red); outline-offset: 3px; }

/* Biểu mẫu */
.field { display: grid; gap: 6px; }
.field + .field { margin-top: 16px; }
.field label, .field .lbl { font-weight: 600; font-size: 15px; }
.field .opt-tag { font-weight: 400; color: var(--muted); }

.field input[type='text'],
.field input[type='tel'],
.field input[type='email'],
.field select {
  width: 100%;
  min-height: 52px;
  padding: 10px 14px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.field input:focus, .field select:focus { border-color: var(--ink); outline: 3px solid var(--ink-wash); outline-offset: 0; }
.field[data-bad] input, .field[data-bad] select { border-color: var(--red); background: var(--red-wash); }
.err { color: var(--red); font-size: 14px; font-weight: 600; min-height: 0; }
.err:empty { display: none; }
.row2 { display: grid; gap: 16px; }
.row2 > .field + .field { margin-top: 0; }

@media (min-width: 520px) {
  .row2 { grid-template-columns: 1fr 1fr; }
}

.consent { display: flex; gap: 12px; align-items: flex-start; margin-top: 18px; font-size: 15px; line-height: 1.5; }
.consent input { width: 22px; height: 22px; margin: 2px 0 0; flex: none; accent-color: var(--ink); }
.consent[data-bad] { color: var(--red); }
.trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.fine { color: var(--muted); font-size: 14px; line-height: 1.5; }
.form-err { margin-top: 14px; padding: 12px 14px; border-radius: 8px; background: var(--red-wash); color: #8f1d15; font-size: 15px; font-weight: 600; }

/* Trang 1 */
.hero { display: grid; gap: 28px; padding-block: 20px 56px; }

.hero-text h1 { font-size: clamp(30px, 6.2vw, 48px); font-weight: 800; color: var(--ink); max-width: 16em; }
.hero-text p { margin-top: 16px; max-width: 34em; font-size: 18px; }

.card {
  background: var(--sheet);
  border: 1.5px solid var(--line);
  border-radius: 6px;
  padding: 24px 20px;
}

.card h2 { font-size: 22px; color: var(--ink); font-weight: 800; }
.card .lead { margin-top: 6px; color: var(--muted); font-size: 15px; }
.card form { margin-top: 20px; }
.card .btn { margin-top: 22px; }
.card .fine { margin-top: 12px; }

@media (min-width: 900px) {
  .hero {
    grid-template-columns: minmax(0, 1fr) minmax(360px, 440px);
    grid-template-areas: 'text form' 'sheet form' 'steps form';
    column-gap: 56px;
    row-gap: 32px;
    align-items: start;
    padding-block: 36px 72px;
  }
  .hero-text { grid-area: text; }
  .hero-form { grid-area: form; position: sticky; top: 20px; }
  .sheet { grid-area: sheet; }
  .steps { grid-area: steps; }
  .card { padding: 28px 26px; }
}

/* Phiếu nhận xét mẫu: nét bút đỏ của thầy cô */
.sheet {
  position: relative;
  max-width: 460px;
  margin-top: 8px;
  padding: 18px 20px 20px 34px;
  background-color: var(--sheet);
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent 31px, var(--grid) 31px, var(--grid) 32px);
  border: 1.5px solid var(--line);
  border-radius: 3px;
  transform: rotate(-1.1deg);
}

.sheet::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 18px;
  width: 3px;
  border-left: 1px solid var(--red-margin);
  border-right: 1px solid var(--red-margin);
}

.sheet-tag { font-size: 13px; color: var(--muted); line-height: 1.3; }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-top: 10px; }
.sheet-name { font-family: var(--hand); font-size: 22px; line-height: 1; color: var(--ink); }

.score {
  position: relative;
  display: inline-grid;
  place-items: center;
  min-width: 84px;
  height: 56px;
  padding: 0 12px;
  font-family: var(--hand);
  font-size: 30px;
  line-height: 1;
  color: var(--red);
}

.score svg { position: absolute; inset: -6px; width: calc(100% + 12px); height: calc(100% + 12px); overflow: visible; }

.notes { list-style: none; margin: 14px 0 0; padding: 0; font-family: var(--hand); font-size: 21px; line-height: 32px; color: var(--red); }
.notes li { display: grid; grid-template-columns: 24px 1fr; gap: 8px; align-items: start; }
.notes svg { width: 22px; height: 22px; margin-top: 5px; }
.notes .ink { color: var(--ink); }

.pen { fill: none; stroke: var(--red); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }

@media (prefers-reduced-motion: no-preference) {
  .sheet .pen {
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    animation: ink 0.7s ease-out forwards;
  }
  .sheet .score .pen { animation-delay: 0.25s; }
  .sheet .notes li:nth-child(1) .pen { animation-delay: 0.9s; }
  .sheet .notes li:nth-child(2) .pen { animation-delay: 1.4s; }
  .sheet .notes li:nth-child(3) .pen { animation-delay: 1.9s; }
  @keyframes ink { to { stroke-dashoffset: 0; } }
}

/* Các bước: đây là một chuỗi thật nên đánh số */
.steps { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 14px; counter-reset: step; max-width: 34em; }
.steps li { position: relative; padding-left: 52px; counter-increment: step; }
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: -2px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 2px solid var(--red);
  border-radius: 50%;
  color: var(--red);
  background: var(--paper);
  font-family: var(--hand);
  font-size: 22px;
  line-height: 1;
}

.steps strong { display: block; color: var(--ink); }

.foot { position: relative; z-index: 1; padding: 24px var(--pad-x) 40px; color: var(--muted); font-size: 14px; max-width: 1120px; margin-inline: auto; }

/* Trang 2: làm bài */
.exam { max-width: 780px; margin-inline: auto; padding-bottom: 120px; }
.exam .top { padding-bottom: 12px; }

.intro { padding-block: 16px 40px; }
.intro h1 { font-size: clamp(28px, 5.6vw, 40px); color: var(--ink); font-weight: 800; }
.intro .lead { margin-top: 12px; font-size: 18px; }

.rules { margin: 24px 0 0; padding: 0; list-style: none; display: grid; gap: 12px; }
.rules li { display: grid; grid-template-columns: 28px 1fr; gap: 12px; align-items: start; }
.rules svg { width: 26px; height: 26px; margin-top: 2px; color: var(--ink); }
.intro .btn { margin-top: 28px; }
.intro .note { margin-top: 20px; padding: 14px 16px; background: var(--sheet); border-left: 4px solid var(--red); border-radius: 4px; font-size: 15px; }

.bar {
  position: sticky;
  top: 0;
  z-index: 5;
  margin-inline: calc(var(--pad-x) * -1) calc(var(--pad-r) * -1);
  padding: calc(8px + env(safe-area-inset-top, 0px)) var(--pad-r) 10px var(--pad-x);
  background: var(--paper);
  border-bottom: 1.5px solid var(--line);
}

.bar-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.bar .cnt { font-weight: 700; color: var(--ink); }
.timer { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 26px; letter-spacing: 0.01em; color: var(--ink); }
.timer[data-low] { color: var(--red); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.chip {
  appearance: none;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1.5px solid var(--line);
  border-radius: 6px;
  background: var(--sheet);
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.chip[data-done] { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip[aria-current='step'] { border: 3px solid var(--red); font-weight: 800; }

.qcard { margin-top: 20px; padding: 24px 20px; background: var(--sheet); border: 1.5px solid var(--line); border-radius: 6px; }
.qnum { font-family: var(--hand); font-size: 26px; line-height: 1; color: var(--red); }
.qtext { margin-top: 10px; font-size: 19px; line-height: 1.7; }
.qfig { display: block; margin: 16px auto 0; max-width: 340px; width: 100%; }

.fr { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; margin: 0 0.15em; line-height: 1.15; }
.fr > span { display: block; padding: 0 0.28em; }
.fr > span:first-child { border-bottom: 1.6px solid currentColor; }

.opts { margin-top: 18px; display: grid; gap: 10px; }

.opt {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 58px;
  padding: 10px 16px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  font-size: 19px;
}

.opt input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.opt:focus-within { outline: 3px solid var(--red); outline-offset: 2px; }

.opt .ltr {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  border: 1.5px solid var(--line);
  border-radius: 50%;
  font-weight: 700;
  color: var(--ink);
  background: var(--paper);
}

.opt[data-sel] { border-color: var(--ink); background: var(--ink-wash); }
.opt[data-sel] .ltr { background: var(--ink); border-color: var(--ink); color: #fff; }

.fillrow { margin-top: 18px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.fillrow label { font-weight: 600; }

.fillrow input {
  width: min(240px, 100%);
  min-height: 56px;
  padding: 8px 14px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font: inherit;
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
}

.fillrow input:focus { border-color: var(--ink); outline: 3px solid var(--ink-wash); }
.fillrow .unit { color: var(--muted); }
.hint { margin-top: 10px; font-size: 14px; color: var(--muted); }

.nav {
  position: sticky;
  bottom: 0;
  z-index: 4;
  display: flex;
  gap: 10px;
  margin: 24px calc(var(--pad-r) * -1) 0 calc(var(--pad-x) * -1);
  padding: 12px var(--pad-r) calc(12px + env(safe-area-inset-bottom, 0px)) var(--pad-x);
  background: var(--paper);
  border-top: 1.5px solid var(--line);
}

.nav .btn { flex: 1; }
.nav .btn.submit { flex: 1.3; }

.overlay { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 16px; background: rgba(18, 32, 88, 0.5); }
.dialog { width: 100%; max-width: 440px; padding: 24px; background: var(--sheet); border-radius: 10px; border: 1.5px solid var(--line); }
.dialog h2 { font-size: 22px; color: var(--ink); }
.dialog p { margin-top: 10px; }
.dialog .acts { display: grid; gap: 10px; margin-top: 22px; }

@media (min-width: 480px) {
  .dialog .acts { grid-template-columns: 1fr 1fr; }
}

.banner { margin-top: 20px; padding: 14px 16px; border-radius: 8px; background: var(--red-wash); border-left: 4px solid var(--red); font-weight: 600; }
.banner .btn { margin-top: 12px; }

.sr { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Trang 3: hoàn thành */
.done { padding-block: 32px 48px; max-width: 720px; }
.stamp { display: block; width: 96px; height: 96px; }
.stamp .pen { stroke-width: 4.5; }
.done h1 { margin-top: 18px; font-size: clamp(30px, 6vw, 44px); font-weight: 800; color: var(--ink); }
.done .lead { margin-top: 14px; font-size: 19px; max-width: 32em; }
.done h2 { margin-top: 40px; font-size: 22px; color: var(--ink); }
.done .steps { margin-top: 18px; max-width: none; }

.gift {
  margin-top: 40px;
  padding: 24px 22px;
  background: var(--sheet);
  border: 1.5px solid var(--line);
  border-left: 6px solid var(--red);
  border-radius: 6px;
}

.gift h2 { margin-top: 0; }
.gift p { margin-top: 8px; }
.gift .btn { margin-top: 18px; }
.gift .fine { margin-top: 10px; }

@media (prefers-reduced-motion: no-preference) {
  .stamp .pen { stroke-dasharray: 1; stroke-dashoffset: 1; animation: ink 0.8s ease-out forwards; }
  .stamp .pen + .pen { animation-delay: 0.55s; }
  @keyframes ink { to { stroke-dashoffset: 0; } }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ===== Trang kết quả: biểu đồ năng lực 5 kỹ năng ===== */
.result { margin-top: 36px; }
.result h2 { margin-top: 0; }
.result-wait { margin-top: 14px; color: var(--muted); }
.result-note { margin-top: 14px; padding: 16px 18px; background: var(--sheet); border: 1.5px solid var(--line); border-radius: 6px; }
.result-note .btn { margin-top: 12px; }

.overall { margin: 14px 0 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; }
.ov-num { font-size: clamp(56px, 12vw, 76px); font-weight: 800; line-height: 1; letter-spacing: -0.04em; color: var(--ink); }
.ov-of { font-size: 26px; font-weight: 800; color: var(--ink); margin-left: -6px; }
.ov-txt { font-family: var(--hand); font-size: 24px; color: var(--red); }

.radar-wrap { max-width: 520px; margin: 8px auto 0; }
.radar { display: block; width: 100%; height: auto; overflow: visible; }
.rd-ring { fill: none; stroke: var(--line); stroke-width: 1.2; }
.rd-ring.outer { stroke: #9fb1d6; stroke-width: 1.6; }
.rd-axis { stroke: var(--line); stroke-width: 1; }
.rd-area { fill: rgba(27, 47, 122, 0.16); stroke: var(--ink); stroke-width: 3; stroke-linejoin: round; }
.rd-dot { fill: var(--ink); }
.rd-dot.weak { fill: var(--red); }
.rd-name { font-family: var(--font); font-size: 17px; font-weight: 700; fill: var(--ink); }
.rd-score { font-family: var(--font); font-size: 17px; font-weight: 600; fill: var(--muted); }
.rd-name.weak, .rd-score.weak { fill: var(--red); }
.rd-pen { fill: none; stroke: var(--red); stroke-width: 3.4; stroke-linecap: round; stroke-linejoin: round; }
.radar-key { margin: 6px 0 0; text-align: center; font-size: 14px; color: var(--muted); }

@media (prefers-reduced-motion: no-preference) {
  .rd-pen { stroke-dasharray: 1; stroke-dashoffset: 1; animation: ink 1s ease-out 0.3s forwards; }
}

.sk-list { list-style: none; margin: 22px 0 0; padding: 0; display: grid; gap: 14px; }
.sk-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.sk-name { font-weight: 700; color: var(--ink); }
.sk-badge { margin-left: 10px; padding: 1px 9px; border: 2px solid var(--red); border-radius: 999px; font-family: var(--hand); font-size: 17px; font-weight: 400; color: var(--red); }
.sk-score { font-weight: 800; font-variant-numeric: tabular-nums; }
.sk-track { margin-top: 6px; height: 10px; border-radius: 5px; background: var(--ink-wash); overflow: hidden; }
.sk-fill { height: 100%; border-radius: 5px; background: var(--ink); }
.sk-list .weak .sk-fill { background: var(--red); }
.sk-list .weak .sk-score { color: var(--red); }
.sk-meta { margin-top: 3px; font-size: 14px; color: var(--muted); }

.issue {
  margin-top: 26px;
  padding: 18px 20px 20px;
  background: var(--sheet);
  border: 1.5px solid var(--line);
  border-left: 6px solid var(--red);
  border-radius: 6px;
}

.issue-tag { font-family: var(--hand); font-size: 22px; line-height: 1.1; color: var(--red); }
.issue h3 { margin-top: 6px; font-size: 24px; font-weight: 800; color: var(--ink); }
.issue p + p { margin-top: 10px; }
.issue .fine { color: var(--muted); }
