@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=Noto+Sans+Thai:wght@400;500;600;700;800&display=swap");

/* Shared design tokens — aligned with the AI Marketing workshop. */
:root {
  /* Light-only site: pin the scheme so browser UI (scrollbars, form controls)
     stays light even when the OS is set to dark. */
  color-scheme: light;

  --bg: #f7f3ef;
  --surface: #fffdfc;
  --surface-alt: #faf7f5;
  --ink: #171514;
  --soft: #675e59;
  --faint: #8b817b;
  --line: #e7dfd9;
  --primary: #171514;
  --primary-ink: #fff;
  --mint: #b7ddd1;
  --mint-strong: #46b794;
  --yellow: #ffcf63;
  --pink: #ffadb6;
  --blue: #add4f0;
  --code: #171514;
  --code-ink: #f7f3ef;
  --shadow: 0 16px 42px rgba(38, 27, 20, .08);
  --radius: 24px;
  --sans: "Noto Sans Thai", system-ui, sans-serif;
  --mono: "IBM Plex Mono", monospace;

  /* Compatibility aliases for the existing workshop components. */
  --bg-alt: var(--surface-alt);
  --text: var(--ink);
  --text-dim: var(--soft);
  --border: var(--line);
  --brand: var(--primary);
  --brand-dim: color-mix(in srgb, var(--mint) 44%, transparent);
  --code-bg: var(--code);
  --code-text: var(--code-ink);
  --tip-bg: color-mix(in srgb, var(--mint) 22%, var(--surface));
  --tip-border: var(--mint-strong);
  --warn-bg: color-mix(in srgb, var(--yellow) 15%, var(--surface));
  --warn-border: #df9f19;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background-color: var(--bg);
  background-image: linear-gradient(176deg,
    color-mix(in srgb, var(--pink) 14%, var(--bg)) 0%,
    color-mix(in srgb, var(--pink) 9%, var(--bg)) 5%,
    transparent 8%,
    color-mix(in srgb, var(--blue) 10%, var(--bg)) 15%,
    transparent 21%,
    color-mix(in srgb, var(--mint) 11%, var(--bg)) 28%,
    transparent 35%,
    color-mix(in srgb, var(--yellow) 11%, var(--bg)) 44%,
    transparent 52%,
    color-mix(in srgb, var(--pink) 10%, var(--bg)) 64%,
    transparent 71%,
    color-mix(in srgb, var(--blue) 8%, var(--bg)) 80%,
    transparent 87%,
    color-mix(in srgb, var(--yellow) 9%, var(--bg)) 100%);
  background-attachment: fixed;
  background-repeat: repeat-y;
  background-size: 100% 820px;
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

.layout {
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 68px;
  padding: 10px clamp(18px, 4vw, 56px);
  border-bottom: 1px solid var(--border);
  overflow: visible;
  isolation: isolate;
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 24px rgba(38, 27, 20, .035);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar::before,
.topbar::after {
  content: "";
  position: absolute;
  z-index: -1;
  border-radius: 50%;
  pointer-events: none;
}

.topbar::before {
  top: -58px;
  left: 34%;
  width: 160px;
  height: 160px;
  background: color-mix(in srgb, var(--yellow) 38%, transparent);
  filter: blur(2px);
  animation: header-float 10s ease-in-out infinite alternate;
}

.topbar::after {
  right: 12%;
  bottom: -46px;
  width: 112px;
  height: 112px;
  background: color-mix(in srgb, var(--blue) 38%, transparent);
  animation: header-float 12s ease-in-out infinite alternate-reverse;
}

.brand {
  flex: 0 0 auto;
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 7px 13px;
  border: 1px solid color-mix(in srgb, var(--mint) 58%, var(--line));
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  box-shadow: 4px 4px 0 color-mix(in srgb, var(--mint) 36%, transparent);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: .035em;
  text-transform: uppercase;
  color: var(--text);
  text-decoration: none;
  transition: transform .2s ease, box-shadow .2s ease, background .2s ease;
}

.brand:hover {
  transform: translate(-2px, -2px) rotate(-1deg);
  background: var(--surface);
  box-shadow: 6px 6px 0 color-mix(in srgb, var(--yellow) 48%, transparent);
}

.nav-toggle {
  position: relative;
  z-index: 1;
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 1.2rem;
  padding: 4px 10px;
  color: var(--text);
  cursor: pointer;
  transition: transform .2s ease, background .2s ease, border-color .2s ease;
}

.nav-toggle:hover {
  transform: rotate(8deg) scale(1.05);
  border-color: var(--mint-strong);
  background: color-mix(in srgb, var(--mint) 30%, var(--surface));
}

.top-nav {
  position: relative;
  z-index: 1;
  display: flex;
  flex: 1 1 auto;
  justify-content: center;
  gap: 4px;
}

.top-nav a {
  position: relative;
  display: block;
  padding: 7px 11px;
  border-radius: 12px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.88rem;
  letter-spacing: .045em;
  text-transform: uppercase;
  white-space: nowrap;
  transition: color .2s ease, background .2s ease, transform .2s ease;
}

.top-nav a::after {
  content: "";
  position: absolute;
  right: 11px;
  bottom: 4px;
  left: 11px;
  height: 2px;
  border-radius: 999px;
  background: var(--mint-strong);
  transform: scaleX(0);
  transform-origin: center;
  transition: transform .2s ease;
}

.top-nav a:hover {
  background: color-mix(in srgb, var(--yellow) 26%, var(--surface));
  color: var(--text);
  transform: translateY(-2px);
}

.top-nav a:hover::after { transform: scaleX(1); }

.top-nav a.active {
  background: color-mix(in srgb, var(--mint) 55%, var(--surface));
  color: var(--ink);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--mint-strong) 38%, transparent);
  animation: nav-pop .42s cubic-bezier(.2, .9, .35, 1.2) both;
}

.top-nav a.active::after { transform: scaleX(1); }

@keyframes header-float {
  from { transform: translate3d(-12px, -4px, 0) scale(.94); }
  to { transform: translate3d(18px, 10px, 0) scale(1.06); }
}

@keyframes nav-pop {
  from { transform: translateY(-6px) scale(.92); opacity: .25; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.content {
  width: min(100%, 1280px);
  margin: 0 auto;
  padding: 48px clamp(20px, 5vw, 64px) 72px;
}

article {
  width: min(100%, 1040px);
  margin: 0 auto;
}

article h1 {
  font-size: 1.25rem;
  margin-top: 2.6em;
  color: var(--primary-ink);
  background: var(--primary);
  padding: 10px 16px;
  border-radius: 14px;
}

article > h1:first-of-type {
  font-size: 1.9rem;
  margin-top: 0;
  color: var(--text);
  background: none;
  padding: 0 0 14px;
  border-bottom: 2px solid var(--border);
  border-radius: 0;
}

article h2 {
  font-size: 1.4rem;
  margin-top: 2.4em;
  padding-top: 0.4em;
  border-top: 1px solid var(--border);
}

article h3 {
  font-size: 1.15rem;
  margin-top: 1.8em;
  color: var(--ink);
}

article p, article li {
  color: var(--text);
}

article a {
  color: var(--brand);
}

.lead {
  color: var(--text-dim);
  font-size: 1.05rem;
}

.home-banner {
  position: relative;
  margin: 24px 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(30, 20, 15, .035);
}

/* ใช้กับภาพหลักของ banner เท่านั้น ไม่รวมโลโก้ใน technology badge */
article .home-banner > img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.lesson-banner {
  position: relative;
  /* ใช้กรอบเดียวกับ Banner หน้าแรก เพื่อให้ทุกหน้าอยู่ในแนวเดียวกัน */
  width: 100%;
  max-width: 100%;
  margin: 24px 0;
  transform: none;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 12px 30px rgba(30, 20, 15, .05);
}

article .lesson-banner img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  object-position: center;
  margin: 0;
  border: 0;
  border-radius: 0;
}

.lesson-banner-copy {
  position: absolute;
  z-index: 1;
  top: clamp(24px, 4vw, 54px);
  left: clamp(24px, 5vw, 64px);
  width: min(44%, 560px);
  min-height: 320px;
  padding: 20px 22px 22px;
  border: 1px solid color-mix(in srgb, var(--mint-strong) 42%, var(--surface));
  border-radius: 24px;
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  box-shadow: 0 14px 32px rgba(38, 27, 20, .12);
  -webkit-backdrop-filter: blur(14px) saturate(.88);
  backdrop-filter: blur(14px) saturate(.88);
  transform: none;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.lesson-banner-copy h2 {
  margin: 9px 0 10px;
  padding: 0;
  border: 0;
  font-size: clamp(1.35rem, 2.5vw, 2.2rem);
  line-height: 1.22;
  letter-spacing: -.02em;
}

.lesson-banner-copy h2::after {
  content: "";
  display: block;
  width: 76px;
  height: 6px;
  margin-top: 13px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--mint-strong), var(--yellow), var(--pink));
}

.lesson-banner-kicker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid color-mix(in srgb, var(--mint-strong) 54%, var(--line));
  border-radius: 999px;
  background: color-mix(in srgb, var(--mint) 42%, var(--surface));
  color: var(--ink);
  font-family: var(--mono);
  font-size: clamp(.65rem, 1vw, .76rem);
  font-weight: 600;
  letter-spacing: .03em;
}

.lesson-banner-copy code {
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: .9em;
}

.stack-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0 28px;
}

/* บนหน้าแรก ชุด badge ลอยทับอยู่มุมบนซ้ายของ banner
   เรียงเป็นพีระมิด 3 / 2 / 1 ด้วย grid 3 คอลัมน์ */
.home-banner .stack-badges {
  position: absolute;
  top: 8%;
  left: 4%;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, max-content));
  justify-content: start;
  justify-items: start;
  max-width: calc(100% - 8%);
  margin: 0;
  /* แถวห่างกันมากกว่าคอลัมน์ ให้อ่านเป็นชั้น ๆ ชัดขึ้น */
  gap: 12px 10px;
}

/* แถว 2 มี 2 อัน และแถว 3 มี 1 อัน */
.home-banner .badge:nth-child(4) { grid-column: 1; }
.home-banner .badge:nth-child(5) { grid-column: 2; }
.home-banner .badge:nth-child(6) { grid-column: 1; }

.home-banner .badge {
  background: color-mix(in srgb, var(--badge-accent) 30%, #fff);
  border-color: color-mix(in srgb, var(--badge-accent) 62%, var(--border));
  color: #2b2320;
  box-shadow: 0 7px 18px rgba(30, 20, 15, .1);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.badge.tech-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 62px;
  padding: 12px 20px;
  border-radius: 999px;
  font-size: clamp(.9rem, 1.25vw, 1.08rem);
  font-weight: 700;
  letter-spacing: .01em;
  transition: transform .2s ease, box-shadow .2s ease;
}

.badge.tech-badge:hover {
  transform: translateY(-3px) rotate(-1deg);
  box-shadow: 0 11px 22px rgba(30, 20, 15, .14);
}

.tech-logo {
  width: 27px;
  height: 27px;
  flex: 0 0 auto;
  object-fit: contain;
  margin: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  display: block !important;
}

.badge {
  --badge-accent: var(--mint);
  background: color-mix(in srgb, var(--badge-accent) 24%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--badge-accent) 55%, var(--border));
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 0.85rem;
  color: var(--ink);
  font-weight: 600;
}

.badge:nth-child(4n + 2) { --badge-accent: var(--yellow); }
.badge:nth-child(4n + 3) { --badge-accent: var(--blue); }
.badge:nth-child(4n + 4) { --badge-accent: var(--pink); }

.card-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
  margin: 20px 0 32px;
}

.card {
  --card-accent: var(--mint);
  position: relative;
  display: flex;
  gap: 18px;
  align-items: center;
  min-height: 176px;
  padding: 24px 58px 24px 22px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--card-accent) 52%, var(--border));
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  background: color-mix(in srgb, var(--card-accent) 18%, var(--surface));
  box-shadow: 0 8px 24px rgba(30, 20, 15, .035);
  transition: border-color .2s ease, transform .2s ease, box-shadow .2s ease;
}

.card:nth-child(4n + 2) { --card-accent: var(--yellow); }
.card:nth-child(4n + 3) { --card-accent: var(--blue); }
.card:nth-child(4n + 4) { --card-accent: var(--pink); }

.card::before {
  content: "";
  position: absolute;
  top: -36px;
  right: -28px;
  width: 104px;
  height: 104px;
  border-radius: 32px;
  background: color-mix(in srgb, var(--card-accent) 42%, transparent);
  transform: rotate(18deg);
  pointer-events: none;
}

.card::after {
  content: "→";
  position: absolute;
  right: 18px;
  bottom: 18px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--primary-ink);
  font-size: 1rem;
  font-weight: 800;
  line-height: 1;
  pointer-events: none;
}

.card:hover {
  border-color: color-mix(in srgb, var(--card-accent) 78%, var(--ink));
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.card-num {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  flex: 0 0 58px;
  width: 58px;
  height: 58px;
  min-width: 0;
  border: 1px solid color-mix(in srgb, var(--card-accent) 72%, var(--border));
  border-radius: 18px;
  background: color-mix(in srgb, var(--card-accent) 68%, var(--surface));
  box-shadow: 0 8px 18px color-mix(in srgb, var(--card-accent) 26%, transparent);
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--ink);
  font-family: var(--mono);
}

.card-body {
  position: relative;
  z-index: 1;
  min-width: 0;
}

.card-body h3 {
  margin: 0 0 6px;
  font-size: 1rem;
  color: var(--text);
}

.card-done {
  margin: 0 0 8px;
  font-size: 0.88rem;
  color: var(--text-dim);
}

/* Article images */
article img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin: 1.2em 0;
  display: block;
}

/* Markdown table styling */
article table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  margin: 1.5em 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  box-shadow: 0 10px 26px rgba(30, 20, 15, .045);
  font-size: .94rem;
}

article th, article td {
  padding: 13px 16px;
  text-align: left;
  vertical-align: top;
  border: 0;
  border-bottom: 1px solid var(--line);
}

article th {
  background: color-mix(in srgb, var(--mint) 34%, var(--surface));
  color: var(--ink);
  font-size: .92rem;
  font-weight: 800;
}

article th::before {
  content: "";
  display: inline-block;
  width: 9px;
  height: 9px;
  margin: 0 8px 1px 0;
  border-radius: 50%;
  background: var(--mint-strong);
}

article th:nth-child(2)::before { background: #d69b1c; }
article th:nth-child(3)::before { background: #d46c7a; }
article th:nth-child(4)::before { background: #5c9fcb; }

article th + th,
article td + td { border-left: 1px solid var(--line); }

article tbody tr:nth-child(odd) td {
  background: color-mix(in srgb, var(--yellow) 8%, var(--surface));
}

article tbody tr:nth-child(even) td {
  background: color-mix(in srgb, var(--blue) 7%, var(--surface));
}

article tbody tr:hover td {
  background: color-mix(in srgb, var(--mint) 18%, var(--surface));
}

article tbody tr:last-child td { border-bottom: 0; }

article th:first-child { border-top-left-radius: 19px; }
article th:last-child { border-top-right-radius: 19px; }

/* Blockquote callouts: 💡 tip / ⚠️ warning / plain */
article blockquote {
  --callout-accent: var(--mint);
  position: relative;
  margin: 1.35em 6px 1.55em 0;
  padding: 18px 76px 18px 22px;
  overflow: hidden;
  border: 2px solid color-mix(in srgb, var(--callout-accent) 68%, var(--line));
  background: color-mix(in srgb, var(--callout-accent) 18%, var(--surface));
  border-radius: 22px;
  box-shadow:
    6px 6px 0 color-mix(in srgb, var(--callout-accent) 52%, transparent),
    0 12px 28px rgba(30, 20, 15, .05);
  transition: transform .2s ease, box-shadow .2s ease;
}

article blockquote:nth-of-type(4n + 2) { --callout-accent: var(--yellow); }
article blockquote:nth-of-type(4n + 3) { --callout-accent: var(--blue); }
article blockquote:nth-of-type(4n + 4) { --callout-accent: var(--pink); }

article blockquote::before {
  content: "";
  position: absolute;
  top: -26px;
  right: -18px;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--callout-accent) 58%, var(--surface));
  pointer-events: none;
}

article blockquote::after {
  content: "";
  position: absolute;
  top: 22px;
  right: 24px;
  width: 20px;
  height: 20px;
  border: 3px solid color-mix(in srgb, var(--callout-accent) 48%, var(--ink));
  border-radius: 6px;
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  transform: rotate(12deg);
  pointer-events: none;
}

article blockquote:hover {
  transform: translate(-2px, -2px);
  box-shadow:
    8px 8px 0 color-mix(in srgb, var(--callout-accent) 58%, transparent),
    0 16px 32px rgba(30, 20, 15, .07);
}

article blockquote > * {
  position: relative;
  z-index: 1;
}

article blockquote p {
  margin: 0.4em 0;
}

article blockquote.journey-card > p:first-child {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
  font-size: 1.12rem;
}

.journey-title-icon,
.status-icon {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  font-family: var(--mono);
  font-weight: 800;
  line-height: 1;
}

.journey-title-icon {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--yellow) 52%, var(--surface));
  box-shadow: 3px 3px 0 color-mix(in srgb, var(--pink) 38%, transparent);
  color: var(--ink);
}

article blockquote.journey-card > ul {
  display: grid;
  gap: 8px;
  margin: 0 0 16px;
  padding: 0;
}

article blockquote.journey-card > ul > li {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  margin: 0;
  padding: 8px 12px;
  list-style: none;
  border: 1px solid color-mix(in srgb, var(--line) 80%, var(--surface));
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface) 78%, transparent);
}

.status-icon {
  width: 25px;
  height: 25px;
  border-radius: 9px;
  font-size: .9rem;
}

.status-done {
  background: color-mix(in srgb, var(--mint) 68%, var(--surface));
  color: #1a765d;
}

.status-current {
  background: color-mix(in srgb, var(--yellow) 72%, var(--surface));
  color: #8e5d00;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--yellow) 23%, transparent);
  animation: status-pulse 1.8s ease-in-out infinite;
}

.status-pending {
  background: color-mix(in srgb, var(--blue) 55%, var(--surface));
  color: #367da9;
}

@keyframes status-pulse {
  50% { transform: translateY(-2px) rotate(8deg); }
}

article li:has(> input[type="checkbox"]) {
  list-style: none;
  margin-left: -1.4em;
}

article li input[type="checkbox"] {
  margin-right: 8px;
}

/* Code blocks */
.code-block {
  margin: 1.2em 0;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid #34302d;
  box-shadow: var(--shadow);
}

.code-block-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #171514;
  padding: 6px 12px;
  border-bottom: 1px solid #34302d;
}

.code-lang {
  color: #c8beb6;
  font-size: 0.75rem;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.copy-btn {
  background: #272321;
  color: #f7f3ef;
  border: 1px solid #47413d;
  border-radius: 999px;
  font-size: 0.78rem;
  padding: 3px 10px;
  cursor: pointer;
}

.copy-btn:hover {
  border-color: var(--mint-strong);
}

.copy-btn.copied {
  color: #b8f0dd;
}

.code-block pre {
  margin: 0;
  padding: 14px 16px;
  background: var(--code-bg);
  overflow-x: auto;
}

.code-block code {
  color: var(--code-text);
  font-family: var(--mono);
  font-size: 0.88rem;
  line-height: 1.6;
  white-space: pre;
}

/* Inline code */
article :not(pre) > code {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1px 6px;
  font-family: var(--mono);
  font-size: 0.88em;
  color: var(--brand);
}

article hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.4em 0;
}

.page-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 3em;
  padding-top: 1.5em;
  border-top: 1px solid var(--border);
}

.page-nav-btn {
  color: var(--brand);
  text-decoration: none;
  font-weight: 600;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.page-nav-btn:hover {
  background: var(--surface-alt);
}

@media (max-width: 1040px) {
  .nav-toggle { display: inline-block; }
  .top-nav {
    position: absolute;
    top: calc(100% + 8px);
    right: 18px;
    display: none;
    width: min(280px, calc(100vw - 36px));
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: var(--shadow);
    z-index: 20;
    flex-direction: column;
    gap: 3px;
  }
  .top-nav.open { display: flex; }
  .top-nav a { width: 100%; }
}

@media (max-width: 820px) {
  .topbar {
    min-height: 60px;
    padding: 8px 18px;
  }
  .content { padding: 24px 18px; }
  article table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
  article th, article td { padding: 11px 13px; }
  .lesson-banner {
    position: static;
    width: 100%;
    max-width: none;
    margin: 18px 0 28px;
    transform: none;
    display: flex;
    flex-direction: column;
  }
  .lesson-banner img {
    aspect-ratio: 16 / 9;
    object-position: center;
  }
  .lesson-banner-copy {
    position: static;
    width: auto;
    min-height: 0;
    padding: 18px 20px 20px;
    border: 0;
    border-top: 1px solid var(--line);
    border-radius: 0;
    transform: none;
    background: var(--surface);
    box-shadow: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    display: block;
  }
  .lesson-banner-copy h2 { font-size: 1.25rem; }
  .lesson-banner-copy p { font-size: .9rem; }
  /* จอเล็ก: badge กลับไปอยู่ใต้ banner ตามเดิม จะได้ไม่บังภาพ */
  .home-banner .stack-badges {
    position: static;
    max-width: none;
    margin: 12px 0 0;
    padding: 0 12px 12px;
  }
  .home-banner .badge {
    box-shadow: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .card-grid { grid-template-columns: 1fr; gap: 14px; }
  .card {
    min-height: 0;
    padding: 18px 52px 18px 18px;
  }
  .card-num {
    flex-basis: 52px;
    width: 52px;
    height: 52px;
    border-radius: 16px;
    font-size: 1.2rem;
  }
  article blockquote { padding: 16px 58px 16px 18px; }
  article blockquote::before {
    top: -20px;
    right: -18px;
    width: 72px;
    height: 72px;
  }
  article blockquote::after {
    top: 18px;
    right: 18px;
    width: 16px;
    height: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .topbar::before,
  .topbar::after,
  .top-nav a.active,
  .status-current {
    animation: none;
  }

  .brand,
  .nav-toggle,
  .top-nav a,
  .top-nav a::after {
    transition: none;
  }
}
