/* ChangekoInter — "notebook" theme, light: cream ruled paper, ink-blue, highlighter yellow, chalkboard green.
   Mali (rounded Thai) for headings, Anuphan for reading, Sriracha (handwriting) only for small labels. */
:root {
  color-scheme: light;
  --paper: #fbf6e6;          /* page background */
  --surface: #fffdf6;        /* cards, panels */
  --surface-2: #f3ecd6;
  --text: #1c2a48;           /* ink */
  --muted: #545e78;
  --line: #e4d9bb;
  --rule: rgb(64 110 190 / .11);   /* notebook ruled lines */
  --margin: rgb(214 92 92 / .45);  /* red margin line */
  --ink: #2547a8;            /* ink-blue primary */
  --ink-2: #1b3684;
  --hl: #ffe45c;             /* highlighter */
  --hl-soft: rgb(255 228 92 / .75);
  --note: #fff1a6;           /* sticky note */
  --chalk: #2e5a4b;          /* chalkboard */
  --chalk-2: #264c3f;
  --chalk-text: #eef3e8;
  --chalk-muted: #bcd0c3;
  --wood: #9a6a3a;
  --star: #f2b01e;
  --news: #2547a8;
  --article: #22704f;
  --review: #a3470e;
  --radius: 12px;
  --shadow: 0 1px 0 rgb(28 42 72 / .06), 0 6px 18px rgb(120 96 40 / .10);
  --display: "Mali", "Anuphan", "Noto Sans Thai", system-ui, sans-serif;
  --body: "Anuphan", "Noto Sans Thai", "Leelawadee UI", "Thonburi", system-ui, sans-serif;
  --hand: "Sriracha", "Mali", cursive;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background-color: var(--paper);
  background-image: repeating-linear-gradient(180deg, transparent 0 31px, var(--rule) 31px 32px);
  color: var(--text);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.75;
  overflow-wrap: break-word;
  position: relative;
}
/* red margin line, only where the page has room to the left of the content */
@media (min-width: 1340px) {
  body::before {
    content: ""; position: absolute; top: 0; bottom: 0; left: calc(50% - 646px); width: 2px;
    background: var(--margin); box-shadow: 5px 0 0 var(--margin); pointer-events: none;
  }
}
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--ink); }
a:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { font-family: var(--display); overflow-wrap: anywhere; }
.wrap { max-width: 1240px; margin-inline: auto; padding: 0 16px; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.skip { position: absolute; left: -999px; top: 0; background: var(--hl); color: var(--text); padding: 8px 12px; z-index: 50; font-weight: 700; }
.skip:focus { left: 8px; }

/* ---------- header ---------- */
.site-header { background: var(--surface); color: var(--text); position: relative; border-bottom: 3px solid var(--ink); }
.topbar { background: var(--chalk); color: var(--chalk-text); font-size: .86rem; }
.topbar-row { display: flex; justify-content: space-between; align-items: center; height: 34px; }
.tagline { font-family: var(--hand); letter-spacing: .01em; }
.tagline::before { content: "✎ "; color: var(--hl); }
.header-row { display: flex; align-items: flex-end; gap: 28px; min-height: 80px; padding-top: 12px; }
.logo { display: inline-flex; align-items: center; gap: 10px; flex: none; align-self: center; }
.site-header .logo { margin-bottom: 8px; }
.logo:hover { color: inherit; }
.logo img { transform: rotate(-4deg); }
.logo-text {
  font-family: var(--display); font-weight: 700; font-size: 1.6rem; line-height: 1; color: var(--ink-2);
}
.logo-text b {
  font-weight: 700; color: var(--text); margin-left: 4px; padding: 0 .18em;
  background: linear-gradient(transparent 52%, var(--hl) 52% 92%, transparent 92%);
}
/* nav = notebook index tabs sitting on the header's bottom rule */
.nav { min-width: 0; flex: 1; }
.nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; align-items: flex-end; }
.nav ul::-webkit-scrollbar { display: none; }
.nav a {
  display: flex; align-items: center; gap: 6px; padding: 9px 16px 8px; white-space: nowrap;
  font-family: var(--display); font-weight: 600; font-size: .98rem; color: var(--muted);
  background: var(--surface-2); border: 1.5px solid var(--line); border-bottom: 0;
  border-radius: 12px 12px 0 0; transition: color .15s, background .15s, padding .15s;
}
.nav li:nth-child(6n+2) a { background: #e6efff; }
.nav li:nth-child(6n+3) a { background: #e3f3ea; }
.nav li:nth-child(6n+4) a { background: #fde8e4; }
.nav li:nth-child(6n+5) a { background: #efe7fb; }
.nav li:nth-child(6n+6) a { background: #fdf0d8; }
.nav a:hover { color: var(--text); padding-bottom: 12px; }
.nav ul li a[aria-current="page"] { background: var(--hl); color: var(--text); border-color: var(--ink); padding-bottom: 12px; }
.nav-ico { font-size: .95em; }

/* breadcrumbs */
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 4px; padding: 0; margin: 18px auto 0; font-size: .86rem; color: var(--muted); }
.crumbs li + li::before { content: "›"; margin-right: 4px; opacity: .6; }
.crumbs a:hover { text-decoration: underline; }
.crumbs [aria-current] { color: var(--text); }
.crumbs li:last-child span { display: inline-block; max-width: 60ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }

/* ---------- shared bits ---------- */
section { margin-top: 48px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.section-title {
  display: flex; align-items: center; gap: 8px; width: fit-content; max-width: 100%;
  font-weight: 700; font-size: 1.6rem; line-height: 1.3; margin: 0 0 18px; padding: 0 .25em;
  color: var(--text);
  background: linear-gradient(100deg, transparent 0 .2em, var(--hl-soft) .2em calc(100% - .1em), transparent calc(100% - .1em)) 0 78% / 100% .5em no-repeat;
}
.section-head .section-title { margin: 0; }
.section-title a:hover { color: var(--ink); }
.more {
  flex: none; font-family: var(--hand); font-size: 1rem; color: var(--ink);
  padding: 4px 4px; border-bottom: 2px solid currentColor;
}
.more:hover { color: var(--ink-2); background: var(--hl-soft); }
/* section badge = sticky note */
.badge {
  position: relative; z-index: 2;
  display: inline-flex; align-items: center; gap: 5px; min-height: 26px; padding: 1px 10px 1px 8px;
  background: var(--note); color: var(--text); font-family: var(--display); font-weight: 600; font-size: .8rem;
  line-height: 1.6; border-radius: 2px 2px 8px 2px; transform: rotate(-1.5deg);
  box-shadow: 1px 2px 0 rgb(120 96 40 / .18);
}
.badge:hover { color: var(--text); background: var(--hl); }
.type { font-family: var(--hand); font-size: .9rem; letter-spacing: .01em; }
.type-news { color: var(--news); }
.type-article { color: var(--article); }
.type-review { color: var(--review); }
.sub { color: var(--muted); margin: 0 0 8px; font-size: .95rem; line-height: 1.6; }
.meta { margin: 0; font-size: .83rem; color: var(--muted); }
.stretch::after { content: ""; position: absolute; inset: 0; z-index: 1; }

.topbar-count { font-family: var(--hand); color: var(--chalk-muted); white-space: nowrap; }
.section-note { margin: 0; font-family: var(--hand); color: var(--muted); }
.card-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin: 0; }
/* lesson duration pill */
.dur {
  display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; padding: 1px 10px; border-radius: 999px;
  background: #e6efff; color: var(--ink-2); font-family: var(--display); font-weight: 600; font-size: .78rem; line-height: 1.7;
  border: 1.5px solid rgb(37 71 168 / .25);
}
.cta {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 8px 22px; border-radius: 999px;
  background: var(--ink); color: #fff; font-family: var(--display); font-weight: 700; font-size: 1rem;
  box-shadow: 0 3px 0 var(--ink-2); transition: transform .15s, box-shadow .15s, background .15s;
}
a.cta:hover, .feature:hover .cta { color: var(--text); background: var(--hl); box-shadow: 0 3px 0 var(--star); transform: translateY(-2px); }

/* ---------- home: welcome banner (class homepage) ---------- */
.welcome {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 40px; align-items: center; margin-top: 30px;
}
.welcome-kicker {
  display: inline-block; margin: 0 0 10px; padding: 2px 14px; background: var(--note); font-family: var(--hand);
  transform: rotate(-2deg); box-shadow: 2px 3px 0 rgb(120 96 40 / .15);
}
.welcome h1 { font-size: clamp(2rem, 4.2vw, 3.2rem); font-weight: 700; line-height: 1.35; margin: 0 0 14px; color: var(--ink-2); }
.welcome h1 .hl { color: var(--text); }
.welcome-desc { margin: 0 0 22px; color: var(--muted); font-size: 1.08rem; max-width: 46ch; }
.welcome-stats { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 12px; }
.welcome-stats li {
  padding: 8px 16px; background: var(--surface); border: 1.5px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
  font-family: var(--display); font-weight: 600; color: var(--muted); font-size: .95rem;
}
.welcome-stats b { font-size: 1.35rem; color: var(--ink); margin-right: 2px; }
.hl {
  padding: 0 .12em; -webkit-box-decoration-break: clone; box-decoration-break: clone;
  background: linear-gradient(transparent 58%, var(--hl-soft) 58% 92%, transparent 92%);
}

/* featured lesson card */
.feature {
  position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow);
  padding: 12px; transform: rotate(.6deg); transition: transform .2s;
}
.feature:hover { transform: rotate(0) translateY(-3px); }
.feature::before { /* tape */
  content: ""; position: absolute; z-index: 3; top: -12px; left: 50%; width: 110px; height: 24px; transform: translateX(-50%) rotate(-3deg);
  background: rgb(255 228 92 / .65); box-shadow: 0 1px 2px rgb(120 96 40 / .12);
}
.feature-label {
  position: absolute; z-index: 2; top: 24px; left: -10px; margin: 0; padding: 4px 16px 4px 14px; background: var(--chalk); color: #fff;
  font-family: var(--display); font-weight: 700; font-size: .95rem; border-radius: 0 999px 999px 0; box-shadow: 0 3px 8px rgb(0 0 0 / .2);
}
.feature-img { overflow: hidden; border-radius: 10px; background: var(--surface-2); }
.feature-img img { width: 100%; aspect-ratio: 1200/630; object-fit: cover; transition: transform .6s cubic-bezier(.2, .7, .2, 1); }
.feature:hover .feature-img img { transform: scale(1.04); }
.feature-body { padding: 16px 10px 8px; }
.feature h2 { font-size: clamp(1.35rem, 2.4vw, 1.85rem); font-weight: 700; line-height: 1.4; margin: 10px 0 6px; }
.feature h2 a:hover { color: var(--ink); }
.feature-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin: 14px 0 0; }

/* ---------- home: subject tiles ---------- */
.subjects { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 18px; }
.subject {
  --tab: #cfe0ff;
  position: relative; display: flex; flex-direction: column; padding: 20px 20px 16px; background: var(--surface);
  border: 1.5px solid var(--line); border-top: 10px solid var(--tab); border-radius: 8px 8px var(--radius) var(--radius);
  box-shadow: var(--shadow); transition: transform .15s, border-color .15s;
}
.subject:nth-child(5n+2) { --tab: #bfe3cd; }
.subject:nth-child(5n+3) { --tab: #f8c9bf; }
.subject:nth-child(5n+4) { --tab: #d9c8f3; }
.subject:nth-child(5n+5) { --tab: #f6dc9a; }
.subject:hover { transform: translateY(-4px) rotate(-.5deg); border-color: var(--ink); border-top-color: var(--tab); }
.subject-ico {
  width: 60px; height: 60px; display: grid; place-items: center; font-size: 1.9rem; margin-bottom: 10px;
  background: var(--paper); border-radius: 50%; border: 2px dashed var(--line);
}
.subject:hover .subject-ico { background: var(--hl); border-color: transparent; }
.subject h3 { font-size: 1.35rem; font-weight: 700; line-height: 1.35; margin: 0 0 4px; }
.subject h3 a::after { content: ""; position: absolute; inset: 0; z-index: 1; }
.subject h3 a:hover { color: var(--ink); }
.subject-desc { margin: 0 0 10px; color: var(--muted); font-size: .9rem; line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.subject-last { margin: 0 0 12px; font-size: .88rem; line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.subject-last span { font-family: var(--hand); color: var(--ink); margin-right: 6px; }
.subject-count {
  margin: auto 0 0; padding-top: 10px; border-top: 1.5px dashed var(--line); display: flex; align-items: baseline; gap: 6px;
  font-family: var(--display); font-weight: 600; color: var(--muted);
}
.subject-count b { font-size: 1.5rem; color: var(--text); }
.subject-count span { margin-left: auto; color: var(--ink); }

/* ---------- home: to-do checklist + chalkboard announcements ---------- */
.todo-row { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 32px; margin-top: 52px; align-items: start; }
.todo-row > section { margin-top: 0; }
.todo {
  position: relative; padding: 26px 24px 14px 72px; border: 1px solid var(--line); border-radius: 4px var(--radius) var(--radius) 4px;
  background-color: var(--surface);
  background-image:
    linear-gradient(90deg, transparent 54px, var(--margin) 54px 56px, transparent 56px),
    repeating-linear-gradient(180deg, transparent 0 31px, var(--rule) 31px 32px);
  box-shadow: var(--shadow);
}
.todo::before { /* binder holes */
  content: ""; position: absolute; left: 18px; top: 30px; bottom: 30px; width: 16px;
  background: radial-gradient(circle at 8px 8px, var(--paper) 6px, rgb(120 96 40 / .25) 7px, transparent 7.5px) 0 0 / 16px 72px repeat-y;
}
.todo-title { margin: 0; font-size: 1.6rem; font-weight: 700; line-height: 1.3; color: var(--ink-2); }
.todo-note { margin: 0 0 8px; font-family: var(--hand); color: var(--muted); }
.todo ul { list-style: none; margin: 0; padding: 0; }
.todo li { position: relative; display: grid; grid-template-columns: 30px minmax(0, 1fr) 96px; gap: 16px; align-items: center; padding: 14px 0; }
.todo li + li { border-top: 1.5px dashed var(--line); }
.check {
  width: 28px; height: 28px; border: 2.5px solid var(--ink); border-radius: 6px; background: var(--surface);
  transition: background .15s;
}
.todo li:hover .check {
  background: var(--hl) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M4 10.5l4 4 9-10' fill='none' stroke='%232547a8' stroke-width='2.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/20px no-repeat;
}
.todo h3 { font-size: 1.08rem; font-weight: 600; line-height: 1.5; margin: 0 0 4px; }
.todo h3 a::after { content: ""; position: absolute; inset: 0; }
.todo h3 a:hover { color: var(--ink); background: linear-gradient(transparent 60%, var(--hl-soft) 60%); }
.todo .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.todo-sec { font-family: var(--hand); color: var(--ink); }
.todo img { border-radius: 6px; aspect-ratio: 4/3; object-fit: cover; border: 3px solid #fff; box-shadow: 0 2px 6px rgb(120 96 40 / .2); transform: rotate(2deg); }

.board {
  position: relative; background: var(--chalk); color: var(--chalk-text); border: 12px solid var(--wood); border-radius: 10px;
  padding: 22px 22px 18px; box-shadow: inset 0 0 50px rgb(0 0 0 / .3), var(--shadow);
}
.board::after { /* chalk ledge */
  content: ""; position: absolute; left: 20%; bottom: -12px; width: 46px; height: 6px; border-radius: 3px; background: #fff;
  box-shadow: 60px 0 0 var(--hl);
}
.board-title {
  margin: 0 0 10px; font-family: var(--hand); font-weight: 400; font-size: 1.8rem; line-height: 1.3; color: #fff;
  text-decoration: underline wavy rgb(255 228 92 / .8); text-decoration-thickness: 2px; text-underline-offset: .3em;
}
.board ol { list-style: none; margin: 0; padding: 0; }
.board li { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 12px; padding: 9px 0; }
.board li + li { border-top: 1.5px dashed rgb(255 255 255 / .2); }
.board time { font-size: .74rem; color: var(--chalk-muted); line-height: 1.4; padding-top: 4px; }
.board time b { display: block; font-family: var(--hand); font-weight: 400; font-size: 1.05rem; color: var(--hl); }
.board a { display: block; min-height: 24px; font-weight: 500; font-size: .95rem; line-height: 1.5; color: var(--chalk-text); }
.board a:hover { color: var(--hl); }
.board-sec { display: block; font-family: var(--hand); font-size: .82rem; color: var(--chalk-muted); }

/* ---------- lesson cards (3 columns) ---------- */
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 30px 24px; }
.card {
  position: relative; display: flex; flex-direction: column; background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); border: 1px solid var(--line); transition: transform .2s, box-shadow .2s;
}
.card::before {
  content: ""; position: absolute; z-index: 3; top: -9px; left: 22px; width: 64px; height: 20px; transform: rotate(-4deg);
  background: rgb(255 228 92 / .6); box-shadow: 0 1px 2px rgb(120 96 40 / .12); pointer-events: none;
}
.grid .card:nth-child(3n+2)::before { left: auto; right: 22px; transform: rotate(3deg); background: rgb(191 227 205 / .75); }
.grid .card:nth-child(3n+3)::before { left: 44%; transform: rotate(-2deg); background: rgb(207 224 255 / .8); }
.card:hover { transform: translateY(-4px) rotate(-.3deg); box-shadow: 0 14px 30px rgb(120 96 40 / .18); }
.card-img { position: relative; display: block; overflow: hidden; background: var(--surface-2); border-radius: var(--radius) var(--radius) 0 0; }
.card-img img { aspect-ratio: 16/9; object-fit: cover; width: 100%; transition: transform .5s cubic-bezier(.2, .7, .2, 1); }
.card:hover .card-img img { transform: scale(1.05); }
.card-img .dur { position: absolute; right: 10px; bottom: 10px; background: var(--surface); box-shadow: 0 2px 4px rgb(0 0 0 / .18); }
.card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; flex: 1; }
.card h3 { font-size: 1.12rem; font-weight: 600; line-height: 1.45; margin: 10px 0 6px; }
.card h3 a::after { content: ""; position: absolute; inset: 0; z-index: 1; }
.card h3 a:hover { color: var(--ink); background: linear-gradient(transparent 60%, var(--hl-soft) 60%); }
.card .sub { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .meta { margin-top: auto; padding-top: 8px; border-top: 1.5px dashed var(--line); }

/* ---------- section page: course header + numbered lesson list ---------- */
.course-head {
  margin-top: 18px; background: var(--chalk); color: var(--chalk-text); padding: 36px 0 40px; position: relative; overflow: hidden;
  border-block: 10px solid var(--wood); box-shadow: inset 0 0 80px rgb(0 0 0 / .28);
}
.course-head::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse 260px 60px at 78% 30%, rgb(255 255 255 / .07), transparent 70%);
}
.course-head-row { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 28px; align-items: center; }
.course-ico {
  width: 112px; height: 112px; display: grid; place-items: center; font-size: 3.4rem; border-radius: 24px;
  background: var(--surface); border: 4px solid var(--hl); transform: rotate(-4deg); box-shadow: 0 6px 16px rgb(0 0 0 / .25);
}
.course-kicker { margin: 0; font-family: var(--hand); color: var(--hl); font-size: 1.05rem; }
.course-head h1 { font-size: clamp(1.8rem, 4.4vw, 2.8rem); font-weight: 700; line-height: 1.4; margin: 4px 0 8px; color: #fff; }
.course-head h1 small { font-family: var(--hand); font-weight: 400; font-size: .5em; color: var(--hl); }
.course-desc { margin: 0 0 16px; color: var(--chalk-muted); max-width: 64ch; }
.course-desc a { color: var(--hl); text-decoration: underline; }
.course-stats { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.course-stats li { padding: 4px 14px; border: 1.5px dashed rgb(255 255 255 / .4); border-radius: 999px; font-size: .92rem; color: var(--chalk-text); }
.course-stats b { font-family: var(--display); font-size: 1.15rem; color: var(--hl); }
.course-head .cta { background: var(--hl); color: var(--text); box-shadow: 0 3px 0 var(--star); white-space: nowrap; }
.course-head .cta:hover { background: #fff; }
.course-body { max-width: 980px; }
.syllabus { margin-top: 36px; }
.lessons {
  list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.lesson {
  position: relative; display: grid; grid-template-columns: 64px 150px minmax(0, 1fr) auto; gap: 20px; align-items: center;
  padding: 18px 22px; transition: background .15s;
}
.lesson + .lesson { border-top: 1.5px dashed var(--line); }
.lesson:hover { background: #fffbe6; }
.lesson-no {
  font-family: var(--display); font-weight: 700; font-size: 2rem; line-height: 1; color: var(--ink);
  text-align: center; padding: 10px 0; border-right: 2px solid var(--margin);
}
.lesson img { border-radius: 8px; aspect-ratio: 16/10; object-fit: cover; }
.lesson h3 { font-size: 1.15rem; font-weight: 600; line-height: 1.5; margin: 0 0 4px; }
.lesson h3 a::after { content: ""; position: absolute; inset: 0; }
.lesson h3 a:hover { color: var(--ink); background: linear-gradient(transparent 60%, var(--hl-soft) 60%); }
.lesson .sub { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-bottom: 4px; }
.pager { display: flex; gap: 16px; justify-content: center; align-items: center; margin-top: 40px; font-family: var(--display); }
.pager span { font-family: var(--hand); color: var(--muted); }
.pager a { border: 1.5px solid var(--ink); color: var(--ink); background: var(--surface); padding: 6px 18px; border-radius: 999px; font-weight: 600; }
.pager a:hover { background: var(--hl); color: var(--text); }

/* ---------- article: lesson layout ---------- */
.lesson-bar { position: sticky; top: 0; z-index: 20; margin-top: 14px; background: rgb(255 253 246 / .96); border-block: 1px solid var(--line); box-shadow: 0 2px 8px rgb(120 96 40 / .08); }
.lesson-bar-row { display: flex; align-items: center; gap: 14px; height: 44px; }
.lesson-bar-sec { flex: none; font-family: var(--hand); color: var(--ink); white-space: nowrap; max-width: 40%; overflow: hidden; text-overflow: ellipsis; }
.lesson-bar-track { flex: 1; height: 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.lesson-bar-fill { display: block; height: 100%; background: linear-gradient(90deg, var(--chalk), var(--ink)); transform: scaleX(0); transform-origin: left; }
.lesson-bar-pct { flex: none; min-width: 3.2em; text-align: right; font-family: var(--display); font-weight: 700; font-size: .88rem; color: var(--ink-2); }
.lesson-page { max-width: 900px; }
.post-head { margin-top: 28px; }
.post-head h1 { font-size: clamp(1.8rem, 4vw, 2.7rem); font-weight: 700; line-height: 1.4; margin: 14px 0 12px; }
.post-head .type { padding: 0 10px; border: 1.5px solid currentColor; border-radius: 999px; }
.cat { font-family: var(--hand); font-size: .92rem; color: var(--muted); }
.post-sub { font-size: 1.2rem; color: var(--muted); margin: 0 0 18px; line-height: 1.6; }
.byline { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-block: 1.5px dashed var(--line); }
.byline .dur { margin-left: auto; font-size: .9rem; padding: 4px 14px; }
.avatar {
  width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--ink); color: #fff; font-family: var(--hand); font-size: 1.3rem;
  box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--hl);
}
.byline .meta { line-height: 1.65; }
.byline a { font-weight: 700; color: var(--ink); }
.post-cover { margin: 26px 0; }
.post-cover img { border-radius: 6px; width: 100%; aspect-ratio: 1200/630; object-fit: cover; border: 8px solid #fff; box-shadow: var(--shadow), 0 0 0 1px var(--line); }
/* the lesson content sits on a notebook page: ruled lines, red margin, binder holes */
.notebook {
  position: relative; padding: 44px 40px 36px 92px; border: 1px solid var(--line); border-radius: 4px 14px 14px 4px;
  background-color: var(--surface);
  background-image:
    linear-gradient(90deg, transparent 70px, var(--margin) 70px 72px, transparent 72px),
    repeating-linear-gradient(180deg, transparent 0 31px, var(--rule) 31px 32px);
  box-shadow: var(--shadow), 4px 4px 0 var(--surface-2), 5px 5px 0 var(--line);
}
.notebook::before {
  content: ""; position: absolute; left: 22px; top: 40px; bottom: 40px; width: 20px;
  background: radial-gradient(circle at 10px 10px, var(--paper) 8px, rgb(120 96 40 / .28) 9px, transparent 9.5px) 0 0 / 20px 120px repeat-y;
}
.notebook-label {
  position: absolute; top: -14px; right: 28px; margin: 0; padding: 2px 14px; background: var(--note); font-family: var(--hand);
  transform: rotate(2deg); box-shadow: 2px 3px 0 rgb(120 96 40 / .15);
}
.post-body { font-size: 1.12rem; }
.post-body > :first-child { margin-top: 0; }
.post-body .lead {
  font-size: 1.16rem; padding: 16px 20px; background: var(--note); border-radius: 2px 2px 14px 2px;
  box-shadow: 2px 3px 0 rgb(120 96 40 / .15); transform: rotate(-.4deg);
}
.post-body h2 {
  font-size: 1.55rem; font-weight: 700; line-height: 1.35; margin: 38px 0 8px; width: fit-content; max-width: 100%;
  padding: 0 .2em; background: linear-gradient(transparent 60%, var(--hl-soft) 60% 92%, transparent 92%);
}
.post-body h3 { font-size: 1.25rem; color: var(--ink-2); }
.post-body img { border-radius: 6px; margin: 24px 0; width: 100%; border: 6px solid #fff; box-shadow: var(--shadow); }
.post-body a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--hl); text-decoration-thickness: 3px; }
.post-body blockquote { margin: 24px 0; padding: 4px 0 4px 20px; border-left: 4px solid var(--chalk); font-family: var(--display); color: var(--chalk-2); }
.post-body ul { list-style: none; padding: 18px 20px; display: grid; gap: 8px; background: rgb(255 241 166 / .45); border: 1px solid var(--line); border-radius: var(--radius); }
.post-body li { display: flex; gap: 10px; font-weight: 500; }
.post-body li::before {
  content: ""; flex: none; width: 20px; height: 20px; margin-top: 6px; border-radius: 4px; border: 2px solid var(--ink);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M4 10.5l4 4 9-10' fill='none' stroke='%232547a8' stroke-width='2.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/16px no-repeat;
}
.post-foot { margin-top: 32px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; font-size: .94rem; color: var(--muted); }
.post-foot p { margin: 0; }
.post-foot a { color: var(--ink); font-weight: 600; }
.done-stamp {
  padding: 6px 16px; border: 2.5px solid var(--article); border-radius: 8px; color: var(--article) !important;
  font-family: var(--display); font-weight: 700; transform: rotate(-3deg);
}
/* next-lesson cards */
.next { max-width: 1100px; margin-top: 56px; }
.next-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.next-card {
  position: relative; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; transition: transform .2s;
}
.next-card:hover { transform: translateY(-3px); border-color: var(--ink); }
.next-card img { aspect-ratio: 16/9; object-fit: cover; width: 100%; }
.next-body { padding: 12px 16px 16px; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; flex: 1; }
.next-step { margin: 0; font-family: var(--hand); color: var(--muted); font-size: .9rem; }
.next-card h3 { font-size: 1.05rem; font-weight: 600; line-height: 1.5; margin: 0 0 4px; }
.next-card h3 a::after { content: ""; position: absolute; inset: 0; }
.next-card h3 a:hover { color: var(--ink); }
.next-card .dur { margin-top: auto; }
.next-first { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); background: var(--note); border-color: var(--star); }
.next-first img { height: 100%; }
.next-first .next-body { padding: 24px 28px; justify-content: center; }
.next-first .next-step { color: var(--ink-2); font-size: 1.1rem; }
.next-first h3 { font-size: 1.5rem; font-weight: 700; line-height: 1.4; }
.next-first .next-body::after { content: "ไปบทถัดไป →"; margin-top: 10px; padding: 8px 20px; border-radius: 999px; background: var(--ink); color: #fff; font-family: var(--display); font-weight: 700; }
.next-first .dur { margin-top: 0; }

/* ---------- footer ---------- */
.site-footer {
  margin-top: 80px; background: var(--chalk); color: var(--chalk-muted); font-size: .93rem; position: relative;
  border-top: 12px solid var(--wood); box-shadow: inset 0 30px 80px rgb(0 0 0 / .2);
}
.site-footer::before {
  content: ""; position: absolute; left: 0; right: 0; top: -12px; height: 12px; pointer-events: none;
  background:
    linear-gradient(90deg, transparent 12%, #fff 12% calc(12% + 38px), transparent calc(12% + 38px)) 0 3px / 100% 5px no-repeat,
    linear-gradient(90deg, transparent 15%, var(--hl) 15% calc(15% + 26px), transparent calc(15% + 26px)) 0 3px / 100% 5px no-repeat;
}
.site-footer a { color: var(--chalk-text); }
.site-footer a:hover { color: var(--hl); }
.site-footer .logo-text { color: #fff; }
.site-footer .logo-text b { color: var(--text); }
.footer-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); gap: 56px; padding-top: 48px; padding-bottom: 32px; }
.footer-brand p { margin: 16px 0 0; line-height: 1.75; max-width: 40ch; }
.footer-title { margin: 4px 0 14px; color: var(--hl); font-family: var(--hand); font-size: 1.15rem; }
.footer-subjects ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.footer-subjects a { display: block; padding: 8px 12px; border: 1.5px dashed rgb(255 255 255 / .3); border-radius: 8px; font-family: var(--display); font-weight: 600; }
.footer-subjects a:hover { border-style: solid; border-color: var(--hl); }
.footer-latest-wrap { padding-bottom: 40px; }
.footer-latest { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.footer-latest li { padding: 12px 14px; background: rgb(0 0 0 / .14); border-radius: 8px; border-left: 3px solid var(--hl); }
.footer-latest a { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.6; font-weight: 500; min-height: 24px; }
.footer-latest time { display: block; margin-top: 4px; font-size: .78rem; }
.footer-bottom { border-top: 1px solid rgb(255 255 255 / .14); background: var(--chalk-2); }
.footer-bottom-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-top: 14px; padding-bottom: 14px; font-size: .86rem; }
.footer-bottom p { margin: 0; }
.site-footer .to-top { color: var(--chalk-text); font-family: var(--hand); display: inline-block; padding: 6px 0; }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .welcome { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  .todo-row { grid-template-columns: minmax(0, 1fr); }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .footer-top { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .footer-latest { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .course-head-row { grid-template-columns: auto minmax(0, 1fr); }
  .course-cta { grid-column: 2; justify-self: start; }
}
@media (max-width: 760px) {
  .header-row { flex-direction: column; align-items: stretch; gap: 10px; padding-top: 14px; min-height: 0; }
  .site-header .logo { align-self: flex-start; margin-bottom: 0; }
  .nav ul { margin: 0 -16px; padding: 0 16px; }
  .tagline { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  .topbar-count { display: none; }
  .next-list { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .next-first { grid-template-columns: minmax(0, 1fr); }
  .next-first img { height: auto; }
  .lesson { grid-template-columns: 48px 110px minmax(0, 1fr); }
  .lesson > .dur { grid-column: 3; justify-self: start; margin-top: -10px; }
}
@media (max-width: 640px) {
  body { font-size: 16px; }
  .welcome { margin-top: 20px; }
  .feature { transform: none; padding: 8px; }
  .feature-label { top: 16px; }
  .grid { grid-template-columns: minmax(0, 1fr); }
  .subjects { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .subject { padding: 14px 12px 12px; }
  .subject-ico { width: 46px; height: 46px; font-size: 1.4rem; }
  .subject h3 { font-size: 1.08rem; }
  .subject-desc, .subject-last { display: none; }
  .subject-count b { font-size: 1.2rem; }
  .todo { padding: 22px 14px 10px 46px; background-image: linear-gradient(90deg, transparent 34px, var(--margin) 34px 36px, transparent 36px), repeating-linear-gradient(180deg, transparent 0 31px, var(--rule) 31px 32px); }
  .todo::before { left: 9px; }
  .todo li { grid-template-columns: 26px minmax(0, 1fr); gap: 12px; }
  .todo img { display: none; }
  .check { width: 24px; height: 24px; }
  .board { padding: 18px 14px 14px; border-width: 9px; }
  .board li { grid-template-columns: 62px minmax(0, 1fr); }
  .course-head { padding: 26px 0 30px; }
  .course-head-row { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .course-ico { width: 72px; height: 72px; font-size: 2.2rem; border-radius: 16px; }
  .course-cta { grid-column: auto; }
  .lesson { grid-template-columns: 40px minmax(0, 1fr); gap: 6px 14px; padding: 16px 14px; align-items: start; }
  .lesson img { display: none; }
  .lesson-no { font-size: 1.4rem; padding: 4px 0; }
  .lesson > .dur { grid-column: 2; margin-top: 0; }
  .notebook { padding: 32px 16px 24px 42px; background-image: linear-gradient(90deg, transparent 30px, var(--margin) 30px 32px, transparent 32px), repeating-linear-gradient(180deg, transparent 0 31px, var(--rule) 31px 32px); }
  .notebook::before { left: 5px; width: 16px; background-size: 16px 100px; background-image: radial-gradient(circle at 8px 8px, var(--paper) 6px, rgb(120 96 40 / .28) 7px, transparent 7.5px); }
  .byline { flex-wrap: wrap; }
  .next-list { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .next-card:not(.next-first) { display: grid; grid-template-columns: 112px minmax(0, 1fr); }
  .next-card:not(.next-first) img { height: 100%; aspect-ratio: auto; min-height: 96px; }
  .next-card:not(.next-first) .next-body { padding: 10px 12px; }
  .next-first .next-body { padding: 16px; }
  .next-first h3 { font-size: 1.2rem; }
  .footer-latest { grid-template-columns: minmax(0, 1fr); }
  .footer-subjects ul { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .footer-bottom-row { flex-direction: column; align-items: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ad slots: code comes from the admin app (zone ads) */
.ad-slot { display: flex; flex-direction: column; align-items: center; gap: 16px; margin: 24px auto; max-width: 1280px; padding: 0 16px; text-align: center; overflow: hidden; }
.ad-unit { width: 100%; max-width: 100%; overflow: hidden; }
.post-body + .ad-slot, .post-cover + .ad-slot { padding: 0; }

/* broken image: replaced by the site logo (script in layout.html), centred on the logo's own background */
img.img-fallback { object-fit: contain !important; background: #2547a8; filter: none !important; }
.post-body img.img-fallback, .post-cover img.img-fallback { aspect-ratio: 16/9; max-height: 420px; }

/* mobile: the last breadcrumb (article title) shrinks to the screen instead of pushing the page wider */
.crumbs li:last-child { display: flex; min-width: 0; max-width: 100%; }
.crumbs li:last-child span { min-width: 0; max-width: 60ch; }

/* empty state: no posts yet — a sticky note on a ruled page */
.empty {
  text-align: center; padding: 64px 24px; margin-top: 32px; border-radius: var(--radius); border: 1px solid var(--line);
  background-color: var(--surface);
  background-image: repeating-linear-gradient(180deg, transparent 0 31px, var(--rule) 31px 32px);
  box-shadow: var(--shadow);
}
.empty-ico { font-size: 3rem; margin: 0; line-height: 1; }
.empty h2 { font-size: 1.7rem; margin: 14px auto 8px; width: fit-content; padding: 0 .2em; background: linear-gradient(transparent 60%, var(--hl-soft) 60% 92%, transparent 92%); }
.empty p { margin: 0; color: var(--muted); }
.empty p:last-child { display: inline-block; margin-top: 6px; padding: 8px 16px; background: var(--note); font-family: var(--hand); color: var(--text); transform: rotate(-1.5deg); box-shadow: 2px 3px 0 rgb(120 96 40 / .15); }

/* sidebar ad zone: fits the column it sits in */
.ad-slot.ad-sidebar { margin: 0 0 16px; padding: 0; max-width: 100%; }
/* an ad never widens the page: the slot takes its parent's width and clips anything wider */
.ad-slot { width: 100%; min-width: 0; box-sizing: border-box; }
.ad-unit > * { max-width: 100%; }
