/* ส่วนประกอบของเนื้อหา บทเรียน และเครื่องมือ */
h1 {
  font-size: var(--text-h1);
  line-height: 1.25;
  margin: 6px 0 14px;
  letter-spacing: -0.01em;
}
h2 {
  font-size: var(--text-h2);
  line-height: 1.35;
  margin: 0 0 10px;
}
h3 {
  font-size: 1.1875rem;
  margin: 34px 0 8px;
  line-height: 1.4;
}
h4 {
  margin: 20px 0 10px;
  font-size: var(--text-body);
}
.lead {
  font-size: var(--text-lead);
  color: var(--muted);
  max-width: 68ch;
  margin: 0 0 24px;
}
.muted,
.hint {
  color: var(--muted);
}
.hint {
  font-size: var(--text-small);
}
.section {
  margin-top: 56px;
}
.prose {
  max-width: var(--measure);
}
.prose p,
.prose li {
  max-width: 72ch;
}

/* ---------- หน้าแรก ---------- */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 40px;
  align-items: center;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: clamp(24px, 4vw, 48px);
  box-shadow: var(--shadow-2);
}
.hero h1 {
  font-size: clamp(2.25rem, 1.2rem + 3.4vw, 3.5rem);
}
.hero-cta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.hero-cta .btn {
  padding: 11px 18px;
  font-size: var(--text-body);
}
.hero-meta {
  margin: 22px 0 0;
  font-size: var(--text-small);
  color: var(--muted);
}
.crumbs {
  font-size: var(--text-meta);
  color: var(--muted);
}
.crumbs a {
  color: inherit;
}
.author {
  margin: 0;
  position: relative;
  z-index: 1;
}
/* รูปต้นฉบับแนวตั้ง ศีรษะอยู่ชิดขอบบน จึงยึดด้านบนไว้ ไม่ให้ศีรษะถูกตัด */
.author img {
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  object-position: 50% 0;
  border-radius: 16px;
  display: block;
}
/* ป้ายชื่อผู้เขียน: ชื่อเด่นที่สุด → สาขา (สีแบรนด์) → ตำแหน่งและสังกัด (รอง) คั่นด้วยเส้นทองสั้น */
.author figcaption {
  display: grid;
  gap: 2px;
  margin-top: var(--space-lg);
  padding-top: var(--space-md);
  background: linear-gradient(var(--gold), var(--gold)) no-repeat 0 0 / 32px 2px;
}
.author-name {
  font-size: var(--text-lead);
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: 0.005em;
  color: var(--ink);
}
.author-role {
  font-size: var(--text-small);
  font-weight: 600;
  line-height: 1.5;
  color: var(--blue);
}
.author-org {
  margin-top: var(--space-xs);
  font-size: var(--text-meta);
  line-height: 1.6;
  color: var(--muted);
}
/* ตำแหน่ง · ศูนย์ · โรงพยาบาล คนละบรรทัด ไม่ให้ตัดคำภาษาไทยกลางคำประสม */
.author-org > span {
  display: block;
  white-space: nowrap;
}
/* เส้นทางเรียนเป็นลำดับ จึงเรียงเป็นแถวละหนึ่งช่วง ซ้ายคือหัวช่วง ขวาคือบทในช่วง */
.path {
  list-style: none;
  padding: 0;
  display: grid;
  gap: var(--space-md);
}
.path-card {
  display: grid;
  grid-template-columns: minmax(200px, 260px) minmax(0, 1fr);
  gap: var(--space-sm) var(--space-xl);
  align-items: start;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--space-lg) 20px;
}
.path-card .path-head {
  margin-bottom: 0;
}
@media (min-width: 900px) {
  .path-card ul {
    columns: 2;
    column-gap: var(--space-xl);
  }
  .path-card li {
    break-inside: avoid;
  }
}
@media (max-width: 760px) {
  .path-card {
    grid-template-columns: 1fr;
  }
}
.path-head {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 8px;
}
.path-head b,
.path-head small {
  display: block;
}
.path-head small {
  color: var(--muted);
  font-size: var(--text-meta);
}
/* ตัวเลขวงกลมของช่วงเรียน ใช้เฉพาะหัวการ์ดเส้นทางและหัวกลุ่มเครื่องมือ ไม่ให้ชนกับ td.num ในตาราง */
.path-head .num,
.tool-group .num {
  flex: 0 0 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  font-weight: 700;
}
.path-card ul {
  margin: 0;
  padding-left: 18px;
  font-size: var(--text-small);
}
.path-card li.done::marker {
  color: var(--ok);
}
.path-card li.done a {
  color: var(--ok);
}
.path-card a {
  color: var(--ink);
  text-decoration: none;
}
.path-card a:hover {
  color: var(--blue);
  text-decoration: underline;
}
.quote-lg {
  font-size: clamp(1.25rem, 0.9rem + 1.2vw, 1.75rem);
  font-weight: 600;
  line-height: 1.5;
  max-width: 40ch;
  margin: 0;
}
.share {
  display: flex;
  gap: 24px;
  align-items: center;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 24px;
}
.share img {
  flex: none;
  width: 140px;
  height: 140px;
  border-radius: 10px;
  border: 1px solid var(--line);
}
.share p {
  margin: 0 0 12px;
}
@media (max-width: 560px) {
  .share {
    flex-direction: column;
    align-items: flex-start;
  }
}
.note-block {
  padding-top: 20px;
  background: linear-gradient(var(--gold), var(--gold)) no-repeat 0 0 / 56px 3px;
}

/* ---------- การ์ด ---------- */
.case-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}
.case-card {
  display: grid;
  gap: 4px;
  align-content: start;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  text-decoration: none;
  color: var(--ink);
}
.case-card:hover {
  border-color: var(--blue);
}
.case-card span {
  color: var(--muted);
  font-size: var(--text-small);
}
.case-card small {
  color: var(--blue);
  font-size: var(--text-meta);
  font-weight: 600;
}
.case-card b {
  font-size: var(--text-lead);
}
.cards {
  display: grid;
  gap: 10px;
  margin: 16px 0;
}
.cards-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.cards-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.cards-4 {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}
/* ห้าใบเรียงแถวเดียวเมื่อพอ ไม่งั้นแบ่งสองคอลัมน์ ไม่ให้เหลือใบเดียวค้างแถวล่าง */
.cards-5 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
@media (min-width: 900px) {
  .cards-5 {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  display: grid;
  gap: 4px;
  align-content: start;
}
.card span {
  font-size: var(--text-small);
  color: var(--muted);
  line-height: 1.6;
}
.card.accent {
  border-color: var(--blue);
  background: var(--soft);
}

/* ---------- บทเรียน ---------- */
.phase-bar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 18px;
  font-size: var(--text-small);
  margin-bottom: 28px;
}
.phase-bar a {
  color: var(--muted);
  text-decoration: none;
}
.phase-bar a:hover {
  color: var(--blue);
}
.fig {
  margin: 20px 0;
}
.fig-zoom {
  display: block;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  cursor: zoom-in;
  width: 100%;
}
.fig-zoom:hover {
  background: #fff;
}
.fig img {
  display: block;
  width: 100%;
  height: auto;
}
/* แผนภาพ SVG ในบทเรียน ใช้สีจาก token จึงรองรับโหมดมืด */
.fig-svg svg {
  display: block;
  width: 100%;
  height: auto;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-family: var(--font-sans);
}
.fb-spine {
  stroke: var(--ink);
  stroke-width: 4;
  stroke-linecap: round;
}
.fb-bone {
  stroke: var(--blue);
  stroke-width: 3;
  stroke-linecap: round;
}
.fb-sub {
  stroke: var(--muted);
  stroke-width: 1.5;
}
.fb-cat {
  fill: var(--blue);
  font-size: 18px;
  font-weight: 700;
  text-anchor: middle;
}
.fb-head {
  fill: var(--navy);
}
.fb-head-text {
  fill: #fff;
  font-size: 18px;
  font-weight: 700;
}
.fig figcaption {
  font-size: var(--text-small);
  color: var(--muted);
  margin-top: 8px;
}
.callout {
  background: var(--soft);
  border: 1px solid color-mix(in srgb, var(--blue) 28%, transparent);
  border-radius: 10px;
  padding: 12px 16px;
  margin: 18px 0;
}
.callout.warn {
  background: var(--warn-soft);
  border-color: var(--warn-line);
}
.callout ol,
.callout ul {
  margin: 6px 0 0;
  padding-left: 22px;
}
.pillars {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 16px 0;
}
.pillars div {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px 12px 26px;
  text-align: center;
  font-weight: 600;
  border-bottom: 6px solid var(--line);
}
.pillars small {
  display: block;
  color: var(--muted);
  font-weight: 400;
  font-size: var(--text-meta);
}
.pillars .hl {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
  border-bottom-color: var(--gold);
}
.pillars .hl small {
  color: #c9d6ea;
}
.steeep {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  margin: 14px 0;
}
.steeep div {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 10px;
}
.steeep b {
  grid-row: span 2;
  font-size: 1.75rem;
  line-height: 1;
  color: var(--blue);
}
.steeep span {
  font-weight: 600;
}
.steeep small {
  color: var(--muted);
  line-height: 1.5;
}
.flow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 14px 0 4px;
}
.flow-item {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: var(--text-small);
}
.flow-item:last-child {
  border-color: var(--blue);
  color: var(--blue);
  font-weight: 600;
}
.flow-arrow {
  color: var(--muted);
}
.flow-note {
  font-size: var(--text-meta);
  color: var(--muted);
  margin: 4px 0 14px;
}
.table-wrap {
  position: relative;
  overflow-x: auto;
  margin: 14px 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
}
table {
  border-collapse: collapse;
  width: 100%;
  font-size: var(--text-small);
}
th,
td {
  text-align: left;
  vertical-align: top;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
}
thead th {
  background: var(--bg);
  font-weight: 600;
  white-space: nowrap;
}
tbody tr:last-child > * {
  border-bottom: 0;
}
tbody th {
  font-weight: 600;
}
td {
  font-variant-numeric: tabular-nums;
}
.raci-table td {
  text-align: center;
  font-weight: 700;
}
.formula {
  text-align: center;
  background: var(--navy);
  color: #fff;
  border-radius: 12px;
  padding: 20px;
  margin: 18px 0;
  font-size: clamp(1.0625rem, 0.9rem + 0.8vw, 1.375rem);
  font-weight: 700;
}
.formula small {
  display: block;
  font-size: var(--text-small);
  font-weight: 400;
  color: #c9d6ea;
  margin-top: 4px;
}
.steps {
  padding-left: 22px;
}
.steps li {
  margin: 8px 0;
}
.steps li::marker {
  font-weight: 700;
  color: var(--blue);
}
.defs dt {
  font-weight: 700;
  margin-top: 16px;
}
.defs dd {
  margin: 4px 0 0;
  padding-left: 14px;
  border-left: 2px solid var(--line);
}
.pdsa {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 10px 0 20px;
}
.pdsa-step {
  border-radius: 12px;
  padding: 14px;
  text-align: center;
  background: var(--paper);
  border: 1px solid var(--line);
  position: relative;
}
.pdsa-step b {
  display: block;
  font-size: 1.75rem;
  line-height: 1.1;
  color: var(--blue);
}
.pdsa-step span {
  font-size: var(--text-small);
}
.pdsa-step:not(:last-child)::after {
  content: "→";
  position: absolute;
  right: -9px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}
.pdsa-step:last-child::after {
  content: "แล้ววนรอบใหม่";
  display: block;
  font-size: var(--text-meta);
  color: var(--muted);
}
.quote {
  position: relative;
  margin: 24px 0;
  padding: 26px 24px 18px 64px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: var(--text-lead);
}
.quote::before {
  content: "“";
  position: absolute;
  left: 18px;
  top: 2px;
  font-size: 4rem;
  line-height: 1;
  font-weight: 700;
  color: var(--gold-ink);
}
.quote mark {
  background: none;
  color: var(--danger);
  font-weight: 600;
}
.quote cite {
  display: block;
  font-size: var(--text-small);
  color: var(--muted);
  font-style: normal;
  margin-top: 8px;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chips span {
  background: var(--soft);
  color: var(--blue);
  border-radius: 99px;
  padding: 3px 12px;
  font-size: var(--text-small);
  font-weight: 600;
}
.why-list {
  list-style: none;
  padding: 0;
  counter-reset: w;
}
.why-list li {
  position: relative;
  padding: 6px 0 6px 20px;
}
.why-list li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 0.95em;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--blue);
}
.why-list li:nth-child(2) {
  margin-left: 16px;
}
.why-list li:nth-child(3) {
  margin-left: 32px;
}
.why-list li:nth-child(4) {
  margin-left: 48px;
}
.why-list li:nth-child(5) {
  margin-left: 64px;
}
.ticks {
  list-style: none;
  padding: 0;
}
.ticks li {
  padding-left: 26px;
  position: relative;
  margin: 6px 0;
}
.ticks li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 0.7em;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--blue);
}
.timeline {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  margin: 16px 0;
  border-top: 3px solid var(--line);
}
.timeline div {
  padding: 10px 6px 0;
  font-size: var(--text-meta);
  position: relative;
  color: var(--muted);
}
.timeline div::before {
  content: "";
  position: absolute;
  top: -8px;
  left: 6px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--paper);
  border: 3px solid var(--blue);
}
.timeline div:last-child::before {
  background: var(--danger);
  border-color: var(--danger);
}
.timeline b {
  display: block;
  color: var(--ink);
  font-size: var(--text-small);
}
.hier {
  display: grid;
  gap: 6px;
  margin: 16px 0;
}
.hier .lv {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 14px;
  align-items: center;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 16px;
}
.hier .lv > b {
  font-size: 1.5rem;
  text-align: center;
  border-radius: 8px;
  color: #fff;
  line-height: 44px;
}
.hier small {
  display: block;
  color: var(--muted);
}
.hier em {
  font-style: normal;
  font-size: var(--text-meta);
  font-weight: 600;
  color: var(--muted);
}
.lv1 > b {
  background: #1f7a4d;
}
.lv2 > b {
  background: #2e8a5b;
}
.lv3 > b {
  background: #2357c8;
}
.lv4 > b {
  background: #8a6212;
}
.lv5 > b {
  background: #b42318;
}
.hier .lv1 {
  margin-right: 0;
}
.hier .lv2 {
  margin-right: 3%;
}
.hier .lv3 {
  margin-right: 6%;
}
.hier .lv4 {
  margin-right: 9%;
}
.hier .lv5 {
  margin-right: 12%;
}
.ladder {
  padding-left: 22px;
}
.ladder li {
  margin: 6px 0;
  padding: 6px 10px;
  border-radius: 8px;
}
.ladder li.hl {
  background: var(--ok-soft);
}
.aim {
  background: var(--paper);
  border: 1px dashed var(--blue);
  border-radius: 10px;
  padding: 14px 18px;
  font-weight: 600;
}

/* ---------- Tip of tools ---------- */
.tip {
  margin: 28px 0;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 22px;
  box-shadow: var(--shadow-1);
}
.tip-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  margin: 0 0 10px;
  font-size: var(--text-lead);
}
.tip-badge {
  background: var(--gold);
  color: var(--navy);
  border-radius: 99px;
  padding: 2px 10px;
  font-size: var(--text-meta);
  font-weight: 700;
}
.tip p {
  margin: 0 0 12px;
}
.tip-cols {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 24px;
}
.tip h4 {
  margin: 0 0 4px;
  font-size: var(--text-small);
}
.tip-cols > div:first-child h4 {
  color: var(--ok);
}
.tip-cols > div:last-child h4 {
  color: var(--warn);
}
.tip ul {
  margin: 0 0 12px;
  padding-left: 20px;
  font-size: var(--text-small);
}
.tip li {
  margin: 3px 0;
}
.tip-example {
  background: var(--bg);
  border-radius: 10px;
  padding: 12px 16px;
  margin: 4px 0 14px;
  font-size: var(--text-small);
}
.tip-example .table-wrap {
  box-shadow: none;
  margin: 8px 0;
}
.tip-use {
  border-top: 1px solid var(--line);
  padding-top: 10px;
  margin: 0 !important;
}

/* ---------- ส่วนท้ายบทเรียน ---------- */
/* หัวข้อ h2 ทุกส่วนในบทใช้ขนาดเดียวกัน ให้โครงหัวข้ออ่านเป็นระดับเดียว */
.lesson h2 {
  font-size: var(--text-h3);
  line-height: 1.4;
}
.prose h2.sec {
  font-size: var(--text-h3);
  line-height: 1.4;
  margin: 40px 0 10px;
  scroll-margin-top: calc(var(--top-h) + 20px);
}
.check h2,
.keys h2,
.activity h2 {
  scroll-margin-top: calc(var(--top-h) + 20px);
}
.act-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  margin-top: 14px;
}
.act-foot small {
  flex: 1 1 240px;
  color: var(--muted);
  font-size: var(--text-meta);
}
.toc {
  margin: var(--space-xl) 0 var(--space-sm);
  padding: 4px 0 4px 18px;
  border-left: 1px solid var(--line);
  font-size: var(--text-small);
}
.toc b {
  display: block;
  color: var(--muted);
  font-size: var(--text-meta);
  font-weight: 600;
  margin-bottom: 4px;
}
.toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.toc li {
  break-inside: avoid;
}
@media (min-width: 760px) {
  .toc ul {
    columns: 2;
    column-gap: var(--space-xl);
  }
}
.toc a {
  display: inline-block;
  padding: 3px 0;
  color: var(--ink);
  text-decoration: none;
}
.toc a:hover {
  color: var(--blue);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.read-progress {
  position: fixed;
  top: var(--top-h);
  left: 0;
  right: 0;
  height: 3px;
  z-index: 20;
  pointer-events: none;
}
.read-progress i {
  display: block;
  height: 100%;
  background: var(--blue-solid);
  transform: scaleX(0);
  transform-origin: left;
}
.keys {
  margin-top: 40px;
  background: var(--navy);
  color: #fff;
  border-radius: 16px;
  padding: 22px 26px;
}
.keys h2 {
  color: var(--gold);
}
.keys ul {
  margin: 0;
  padding-left: 20px;
}
.keys li {
  margin: 4px 0;
}
.activity {
  margin-top: 8px;
  border: 1px solid var(--blue);
  background: var(--soft);
  border-radius: 16px;
  padding: 22px 26px;
}
.activity ol {
  padding-left: 22px;
}
.check {
  margin-top: 32px;
}
/* fieldset ใช้ block ไม่ใช้ grid: legend ที่ float จะอยู่ในกรอบเสมอทุกเบราว์เซอร์ (grid ทำให้บางเบราว์เซอร์วาด legend บนเส้นขอบ) */
.mcq {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  padding: 16px 18px;
  margin: 0 0 12px;
  min-width: 0;
  display: block;
}
.mcq legend {
  float: left;
  width: 100%;
  padding: 0;
  margin: 0 0 12px;
  font-weight: 600;
  line-height: 1.5;
}
.mcq legend + * {
  clear: both;
}
.mcq > .opt,
.mcq > .opt-radio {
  display: flex;
  margin-top: 8px;
}
.mcq > legend + .opt,
.mcq > legend + .opt-radio {
  margin-top: 0;
}
.mcq > .mcq-why {
  margin-top: 10px;
}
.opt,
.opt-radio {
  text-align: left;
  justify-content: flex-start;
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  line-height: 1.5;
}
.opt > span:first-child {
  flex: 1;
}
.opt-mark {
  display: inline-flex;
  flex: none;
}
.opt.right .opt-mark {
  color: var(--ok);
}
.opt.wrong .opt-mark {
  color: var(--danger);
}
.opt-radio {
  display: flex;
  gap: 10px;
  align-items: baseline;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  font-size: var(--text-small);
}
.opt-radio:hover {
  border-color: var(--blue);
}
.opt.right,
.opt-radio.right {
  border-color: var(--ok);
  background: var(--ok-soft);
}
.opt.wrong,
.opt-radio.wrong {
  border-color: var(--danger);
  background: var(--danger-soft);
}
.mcq-why {
  margin: 4px 0 0;
  font-size: var(--text-small);
}
.mcq-why:empty {
  display: none;
}
.notes {
  margin-top: 28px;
}
.notes label {
  display: grid;
  margin-bottom: 6px;
}
.notes small {
  color: var(--muted);
  font-size: var(--text-meta);
}
textarea,
input,
select {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  padding: 8px 10px;
  width: 100%;
  font-size: var(--text-small);
}
textarea:focus,
input:focus,
select:focus {
  border-color: var(--blue);
}
.note-warn {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 6px;
  color: var(--muted);
  font-size: var(--text-meta);
}
.lesson-end {
  margin-top: 40px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 18px;
}
.phase-end {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: var(--soft);
  border-radius: 12px;
  padding: 16px 18px;
  color: var(--blue);
}
.phase-end .ico {
  flex: none;
  margin-top: 2px;
}
.phase-end p {
  margin: 0;
  display: grid;
  gap: 2px;
  color: var(--ink);
}
.phase-end span {
  color: var(--muted);
  font-size: var(--text-small);
}
.end-main {
  display: grid;
  justify-items: start;
  gap: 6px;
}
.end-next {
  min-height: 48px;
  padding: 10px 22px;
  font-size: var(--text-body);
}
.end-main small {
  color: var(--muted);
  font-size: var(--text-small);
}
.end-sub {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px 20px;
  font-size: var(--text-small);
}
.end-sub a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  color: var(--muted);
  text-decoration: none;
}
.end-sub a:hover {
  color: var(--blue);
}
.end-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ok);
}
.linkish {
  border: 0;
  background: none;
  padding: 0 2px;
  min-height: 44px;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  font-size: var(--text-small);
}
.linkish:hover {
  background: none;
  color: var(--blue);
}
.pager {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 36px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}
.pager a {
  text-decoration: none;
  font-size: var(--text-small);
  color: var(--muted);
}
.pager .primary-link {
  color: var(--blue);
  font-weight: 600;
  margin-left: auto;
}

/* ---------- จอเล็ก ---------- */
@media (max-width: 760px) {
  .hero {
    grid-template-columns: 1fr;
  }
  .author {
    display: flex;
    gap: 14px;
    align-items: center;
  }
  .author img {
    width: 88px;
    aspect-ratio: 1;
    object-position: 50% 4%;
    border-radius: 50%;
  }
  .hero-cta .btn {
    width: 100%;
    justify-content: center;
  }
  .author figcaption {
    margin: 0;
  }
  .author-name {
    font-size: var(--text-body);
  }
  .cards-2,
  .cards-3,
  .tip-cols,
  .pillars {
    grid-template-columns: 1fr;
  }
  .pdsa {
    grid-template-columns: repeat(2, 1fr);
  }
  .pdsa-step::after {
    display: none !important;
  }
  .timeline {
    grid-template-columns: repeat(3, 1fr);
    row-gap: 16px;
  }
  .hier .lv {
    grid-template-columns: 36px 1fr;
    margin-right: 0 !important;
  }
  .hier em {
    grid-column: 2;
  }
  .keys,
  .activity {
    padding: 18px;
  }
  .pb-long {
    display: none;
  }
  .toc a {
    padding: 9px 0;
  }
  .phase-bar {
    padding: 8px 14px;
    margin-bottom: 20px;
  }
  .end-main {
    justify-items: stretch;
    text-align: center;
  }
  .end-next {
    justify-content: center;
  }
}

/* ---------- จังหวะของบทเรียน ---------- */
/* ทุกส่วนของบทใช้ความกว้างอ่านเดียวกับเนื้อหา ขอบขวาไม่กระโดด */
article.lesson > * {
  max-width: var(--measure);
}
/* ส่วนหลักหลังเนื้อหา (สรุป เช็ก บันทึก จบขั้น) ห่างกันระดับ section ส่วนหัวข้อย่อยในเนื้อหาห่างน้อยกว่า */
article.lesson > .keys,
article.lesson > .check,
article.lesson > .notes,
article.lesson > .lesson-end {
  margin-top: var(--space-section);
}
.prose > h2.sec:first-child {
  margin-top: var(--space-page);
}
