/* ═══════════════════════════════════════════════════════════
   Khunjibna Blog — Design system
   สีหลักดึงมาจากโลโก้ (teal + peach) รองรับ light / dark mode
   ═══════════════════════════════════════════════════════════ */

:root {
  --bg: #f7f4ee;
  --surface: #fffdf9;
  --surface-2: #efeae1;
  --ink: #1f2a2e;
  --muted: #5d6a6d;
  --faint: #8a9496;
  --line: rgba(31, 42, 46, 0.12);
  --line-strong: rgba(31, 42, 46, 0.22);
  --accent: #2e6170;
  --accent-hover: #234d59;
  --accent-ink: #ffffff;
  --accent-soft: #dcebee;
  --peach: #d9825a;
  --peach-soft: #f8e4d8;
  --zap: #f2a900;
  --zap-ink: #1f1a0c;
  --header-bg: rgba(247, 244, 238, 0.82);
  --shadow-sm: 0 1px 2px rgba(31, 42, 46, 0.06), 0 2px 8px rgba(31, 42, 46, 0.04);
  --shadow-md: 0 10px 30px -12px rgba(31, 42, 46, 0.22);
  --shadow-lg: 0 30px 60px -20px rgba(31, 42, 46, 0.35);
  --logo-filter: none;

  /* Sarabun: ฟอนต์มีหัว อ่านเนื้อหายาว ๆ ได้สบายตา / Anuphan: หัวข้อ ไม่มีหัวแต่อ่านชัด */
  --font-body: "Sarabun", "Noto Sans Thai Looped", "Noto Sans Thai", system-ui, sans-serif;
  --font-display: "Anuphan", "Noto Sans Thai", system-ui, sans-serif;

  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --container: 1180px;
  --measure: 720px;
  --gutter: clamp(16px, 4vw, 32px);

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111618;
    --surface: #182023;
    --surface-2: #212a2e;
    --ink: #ebe7df;
    --muted: #a3adaf;
    --faint: #7c878a;
    --line: rgba(235, 231, 223, 0.1);
    --line-strong: rgba(235, 231, 223, 0.2);
    --accent: #86bccb;
    --accent-hover: #a5d0dc;
    --accent-ink: #0d1a1e;
    --accent-soft: #1d3840;
    --peach: #f0a984;
    --peach-soft: #3a2a22;
    --header-bg: rgba(17, 22, 24, 0.8);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 10px 30px -12px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 30px 60px -20px rgba(0, 0, 0, 0.7);
    --logo-filter: brightness(1.9) saturate(0.85);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #111618;
  --surface: #182023;
  --surface-2: #212a2e;
  --ink: #ebe7df;
  --muted: #a3adaf;
  --faint: #7c878a;
  --line: rgba(235, 231, 223, 0.1);
  --line-strong: rgba(235, 231, 223, 0.2);
  --accent: #86bccb;
  --accent-hover: #a5d0dc;
  --accent-ink: #0d1a1e;
  --accent-soft: #1d3840;
  --peach: #f0a984;
  --peach-soft: #3a2a22;
  --header-bg: rgba(17, 22, 24, 0.8);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 10px 30px -12px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 30px 60px -20px rgba(0, 0, 0, 0.7);
  --logo-filter: brightness(1.9) saturate(0.85);
  color-scheme: dark;
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.8;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background-color 200ms ease, color 200ms ease;
}

img {
  max-width: 100%;
  height: auto;
}

a {
  color: inherit;
}

button {
  font: inherit;
  color: inherit;
}

::selection {
  background: var(--accent-soft);
  color: var(--ink);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

.container {
  width: min(var(--container), 100% - var(--gutter) * 2);
  margin-inline: auto;
}

.site-main {
  flex: 1;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -60px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-ink);
  text-decoration: none;
  transition: top 150ms ease;
}

.skip-link:focus {
  top: 12px;
}

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

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--peach);
}

.eyebrow::before {
  content: "";
  width: 22px;
  height: 1.5px;
  background: currentColor;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-ghost {
  border-color: var(--line-strong);
  background: transparent;
}

.btn-ghost:hover {
  border-color: var(--ink);
}

.btn-zap {
  background: var(--zap);
  color: var(--zap-ink);
  font-weight: 600;
}

.btn-zap:hover {
  background: #ffbd1f;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--ink);
}

/* ── Reading progress ────────────────────────────────────── */
.reading-progress {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 60;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--peach));
  transform-origin: 0 50%;
  transform: scaleX(0);
}

/* ═══════════════════════════════════════════════════════════
   Header
   ═══════════════════════════════════════════════════════════ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--header-bg);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color 200ms ease, background-color 200ms ease;
}

.site-header.is-scrolled {
  border-bottom-color: var(--line);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 72px;
}

.brand {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
}

.brand img {
  display: block;
  height: 40px;
  width: auto;
  filter: var(--logo-filter);
}

.main-nav {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.main-nav a {
  position: relative;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  transition: color 160ms ease, background-color 160ms ease;
}

.main-nav a:hover {
  color: var(--ink);
  background: var(--surface-2);
}

.main-nav a.active {
  color: var(--ink);
}

.main-nav a.active::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 2px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--peach);
  transform: translateX(-50%);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.search-trigger {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0 8px 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--faint);
  font-size: 0.88rem;
  cursor: pointer;
  transition: border-color 160ms ease, color 160ms ease;
}

.search-trigger:hover {
  border-color: var(--line-strong);
  color: var(--muted);
}

.search-trigger kbd {
  padding: 1px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.75rem;
  background: var(--surface-2);
}

.theme-toggle .icon-sun {
  display: none;
}

:root[data-theme="dark"] .theme-toggle .icon-sun {
  display: block;
}

:root[data-theme="dark"] .theme-toggle .icon-moon {
  display: none;
}

.menu-toggle {
  display: none;
}

.menu-toggle .icon-close {
  display: none;
}

.menu-toggle[aria-expanded="true"] .icon-close {
  display: block;
}

.menu-toggle[aria-expanded="true"] .icon-menu {
  display: none;
}

.mobile-menu {
  display: none;
}

@media (max-width: 820px) {
  .header-inner {
    min-height: 64px;
    gap: 8px;
  }

  .brand img {
    height: 34px;
  }

  .main-nav {
    display: none;
  }

  .header-actions {
    margin-left: auto;
  }

  .search-trigger {
    width: 42px;
    padding: 0;
    justify-content: center;
    border: 0;
    background: transparent;
    color: var(--muted);
  }

  .search-trigger span,
  .search-trigger kbd {
    display: none;
  }

  .menu-toggle {
    display: inline-grid;
  }

  .mobile-menu {
    display: block;
    max-height: 0;
    overflow: hidden;
    transition: max-height 260ms ease;
  }

  .mobile-menu.is-open {
    max-height: 420px;
    border-top: 1px solid var(--line);
  }

  .mobile-menu nav {
    display: grid;
    padding: 8px 0 16px;
  }

  .mobile-menu a {
    display: flex;
    justify-content: space-between;
    padding: 14px 4px;
    border-bottom: 1px solid var(--line);
    font-size: 1.05rem;
    font-weight: 500;
    text-decoration: none;
  }

  .mobile-menu a:last-child {
    border-bottom: 0;
  }

  .mobile-menu a.active {
    color: var(--accent);
  }
}

/* ═══════════════════════════════════════════════════════════
   Home — hero
   ═══════════════════════════════════════════════════════════ */
.home-hero {
  padding: clamp(40px, 8vw, 96px) 0 clamp(32px, 5vw, 56px);
}

.home-hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: clamp(24px, 5vw, 72px);
  align-items: end;
}

.home-hero h1 {
  margin: 18px 0 0;
  font-family: var(--font-display);
  font-size: clamp(2.1rem, 5.2vw, 3.6rem);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.home-hero h1 em {
  font-style: normal;
  color: var(--accent);
}

.home-hero-side p {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 1.05rem;
}

.hero-stats {
  display: flex;
  gap: 28px;
  margin: 0 0 24px;
  padding: 0;
  list-style: none;
}

.hero-stats strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.75rem;
  line-height: 1.2;
  color: var(--ink);
}

.hero-stats span {
  font-size: 0.85rem;
  color: var(--faint);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

@media (max-width: 820px) {
  .home-hero-grid {
    grid-template-columns: 1fr;
    align-items: start;
  }
}

/* ── Section heading ─────────────────────────────────────── */
.section {
  padding: clamp(32px, 5vw, 56px) 0;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.section-head h2 {
  margin: 6px 0 0;
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 3vw, 1.85rem);
  font-weight: 600;
  line-height: 1.35;
}

.link-arrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
}

.link-arrow svg {
  transition: transform 160ms ease;
}

.link-arrow:hover svg {
  transform: translateX(3px);
}

/* ═══════════════════════════════════════════════════════════
   Post cards
   ═══════════════════════════════════════════════════════════ */
.featured-card {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  transition: box-shadow 220ms ease, transform 220ms ease;
}

.featured-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-3px);
}

.featured-card .card-media {
  aspect-ratio: 4 / 3;
  border-radius: 0;
}

.featured-card .card-body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(24px, 4vw, 48px);
}

.featured-card .card-title {
  font-size: clamp(1.5rem, 3vw, 2.1rem);
  line-height: 1.4;
}

.featured-card .card-summary {
  -webkit-line-clamp: 4;
  font-size: 1.02rem;
}

.featured-badge {
  align-self: flex-start;
  margin-bottom: 16px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--peach-soft);
  color: var(--peach);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  gap: clamp(20px, 3vw, 32px);
}

.post-card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
}

.card-media {
  position: relative;
  display: block;
  overflow: hidden;
  aspect-ratio: 16 / 10;
  border-radius: var(--radius);
  background: var(--surface-2);
}

.card-media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 500ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

.post-card:hover .card-media img,
.featured-card:hover .card-media img {
  transform: scale(1.045);
}

.post-card .card-body {
  padding: 18px 2px 0;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  margin-bottom: 8px;
  font-size: 0.85rem;
  color: var(--faint);
}

.card-meta .dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
}

.card-title {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 1.22rem;
  font-weight: 600;
  line-height: 1.5;
  color: var(--ink);
  transition: color 160ms ease;
}

.post-card:hover .card-title,
.featured-card:hover .card-title {
  color: var(--accent);
}

.card-summary {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  margin: 0;
  font-size: 0.95rem;
  color: var(--muted);
}

@media (max-width: 820px) {
  .featured-card {
    grid-template-columns: 1fr;
  }

  .featured-card .card-media {
    aspect-ratio: 16 / 10;
  }
}

/* ═══════════════════════════════════════════════════════════
   Author card (โปรไฟล์ Nostr)
   ═══════════════════════════════════════════════════════════ */
.author-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 24px;
  align-items: center;
  padding: clamp(20px, 4vw, 36px);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(circle at 0% 0%, var(--accent-soft), transparent 55%),
    var(--surface);
}

.author-avatar {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--surface);
  box-shadow: var(--shadow-md);
  background: var(--surface-2);
}

.author-label {
  margin: 0 0 2px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
}

.author-name {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 600;
  line-height: 1.4;
}

.author-bio {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  margin: 4px 0 8px;
  color: var(--muted);
  font-size: 0.95rem;
  overflow-wrap: anywhere;
}

.author-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  font-size: 0.85rem;
  color: var(--faint);
}

.author-stats span:empty {
  display: none;
}

.author-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.author-extra {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding: 14px 18px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  font-size: 0.95rem;
  text-decoration: none;
  transition: border-color 160ms ease, background-color 160ms ease;
}

.author-extra:hover {
  border-color: var(--accent);
  background: var(--surface);
}

.author-extra span {
  font-size: 1.3rem;
}

.author-extra strong {
  font-weight: 500;
}

.author-extra small {
  display: block;
  color: var(--faint);
  font-size: 0.8rem;
}

@media (max-width: 720px) {
  .author-card {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .author-avatar {
    width: 64px;
    height: 64px;
  }

  .author-actions {
    grid-column: 1 / -1;
    flex-direction: row;
    flex-wrap: wrap;
  }

  .author-actions .btn {
    flex: 1;
  }
}

/* ═══════════════════════════════════════════════════════════
   Page header (archive / about / contact)
   ═══════════════════════════════════════════════════════════ */
.page-header {
  padding: clamp(40px, 7vw, 80px) 0 clamp(20px, 3vw, 32px);
}

.page-header h1 {
  margin: 14px 0 8px;
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 600;
  line-height: 1.3;
}

.page-header p:not(.eyebrow) {
  max-width: 60ch;
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
}

/* ── Archive ─────────────────────────────────────────────── */
.archive-tools {
  position: sticky;
  top: 72px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  background: var(--bg);
}

.archive-search {
  position: relative;
  flex: 1;
  max-width: 460px;
}

.archive-search svg {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--faint);
  pointer-events: none;
}

.input {
  width: 100%;
  height: 48px;
  padding: 0 16px 0 46px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.archive-count {
  font-size: 0.9rem;
  color: var(--faint);
  white-space: nowrap;
}

.archive-year {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 24px;
  padding: 32px 0;
  border-top: 1px solid var(--line);
}

.archive-year[hidden] {
  display: none;
}

.archive-year-label {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--faint);
}

.archive-year-label small {
  display: block;
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 400;
}

.archive-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.archive-item[hidden] {
  display: none;
}

.archive-link {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 20px;
  align-items: center;
  padding: 12px;
  margin: 0 -12px;
  border-radius: var(--radius);
  text-decoration: none;
  transition: background-color 160ms ease;
}

.archive-link:hover {
  background: var(--surface);
}

.archive-link .card-media {
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-sm);
}

.archive-link:hover .card-media img {
  transform: scale(1.06);
}

.archive-link:hover .card-title {
  color: var(--accent);
}

.archive-link .card-title {
  font-size: 1.12rem;
  margin-bottom: 4px;
}

.archive-link .card-meta {
  margin-bottom: 4px;
}

.archive-empty {
  padding: 64px 0;
  text-align: center;
  color: var(--muted);
}

@media (max-width: 720px) {
  .archive-tools {
    top: 64px;
  }

  .archive-year {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 24px 0;
  }

  .archive-link {
    grid-template-columns: 96px minmax(0, 1fr);
    gap: 14px;
  }

  .archive-link .card-summary {
    display: none;
  }
}

/* ═══════════════════════════════════════════════════════════
   Post
   ═══════════════════════════════════════════════════════════ */
.post-hero {
  width: min(var(--measure), 100% - var(--gutter) * 2);
  margin-inline: auto;
  padding: clamp(32px, 6vw, 64px) 0 clamp(20px, 3vw, 32px);
}

.back-link {
  display: flex;
  width: fit-content;
  align-items: center;
  gap: 6px;
  margin-bottom: 24px;
  font-size: 0.9rem;
  color: var(--muted);
  text-decoration: none;
}

.back-link:hover {
  color: var(--accent);
}

.post-hero h1 {
  margin: 14px 0 20px;
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 4.6vw, 2.9rem);
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.post-lede {
  margin: 0 0 24px;
  font-size: 1.15rem;
  color: var(--muted);
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  font-size: 0.9rem;
  color: var(--muted);
}

.post-meta span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.post-meta svg {
  color: var(--faint);
}

.post-body {
  width: min(var(--measure), 100% - var(--gutter) * 2);
  margin-inline: auto;
}

.post-content {
  font-size: 1.15rem;
  line-height: 1.9;
  overflow-wrap: break-word;
}

.post-content > :first-child {
  margin-top: 0;
}

.post-content p {
  margin: 0 0 1.35em;
}

.post-content h2,
.post-content h3,
.post-content h4 {
  margin: 2.2em 0 0.7em;
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.45;
}

.post-content h2 {
  font-size: 1.6rem;
}

.post-content h3 {
  font-size: 1.3rem;
}

.post-content img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
}

.post-content a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.post-content a:hover {
  text-decoration-thickness: 2px;
}

.post-content blockquote {
  margin: 1.8em 0;
  padding: 4px 0 4px 24px;
  border-left: 3px solid var(--peach);
  font-family: var(--font-display);
  font-size: 1.18rem;
  color: var(--muted);
}

.post-content hr {
  width: 80px;
  margin: 3em auto;
  border: 0;
  border-top: 2px dotted var(--line-strong);
}

.post-content ul,
.post-content ol {
  padding-left: 1.4rem;
}

.post-content li {
  margin-bottom: 0.4em;
}

.post-content code {
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--surface-2);
  font-size: 0.9em;
}

.post-content pre {
  overflow-x: auto;
  padding: 18px 20px;
  border-radius: var(--radius);
  background: var(--surface-2);
  line-height: 1.6;
}

.post-content pre code {
  padding: 0;
  background: none;
}

.post-content table {
  display: block;
  overflow-x: auto;
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

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

.post-content iframe,
.post-content video {
  max-width: 100%;
  border-radius: var(--radius);
}

/* ── Utility classes ที่บทความเก่าใช้อยู่ ─────────────────── */
.post-content .mx-auto { margin-left: auto; margin-right: auto; }
.post-content .rounded-xl { border-radius: var(--radius); }
.post-content .rounded-sm,
.post-content .rounded { border-radius: var(--radius-sm); }
.post-content .mb-2 { margin-bottom: 0.5rem; }
.post-content .mb-4 { margin-bottom: 1rem; }
.post-content .mb-6 { margin-bottom: 1.75rem; }
.post-content .mt-2 { margin-top: 0.5rem; }
.post-content .my-5 { margin-top: 1.25rem; margin-bottom: 1.25rem; }
.post-content .my-10 { margin-top: 2.5rem; margin-bottom: 2.5rem; }
.post-content .mx-5 { margin-left: 1.25rem; margin-right: 1.25rem; }
.post-content .ml-8,
.post-content .pl-6 { padding-left: 1.5rem; }
.post-content .px-2 { padding-left: 0.5rem; padding-right: 0.5rem; }
.post-content .px-5 { padding-left: 1.25rem; padding-right: 1.25rem; }
.post-content .py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.post-content .py-5 { padding-top: 1.25rem; padding-bottom: 1.25rem; }
.post-content .text-xl { font-size: 1.35rem; line-height: 1.55; font-family: var(--font-display); font-weight: 600; }
.post-content .text-md { font-size: 1.05rem; font-weight: 600; }
.post-content .underline { text-decoration: underline; }
.post-content .block { display: block; }
.post-content .list-disc { list-style: disc; }
.post-content .w-full { width: 100%; }
.post-content .h-full { height: 100%; }

.post-content .text-white,
.post-content .text-whlie { color: #fff; }
.post-content .text-gray-700,
.post-content .text-gray-800 { color: var(--muted); }
.post-content .text-green-800 { color: #2f7a4a; }
.post-content .text-blue-600,
.post-content .text-blue-800 { color: var(--accent); }
.post-content .text-purple-800 { color: #7a4fb0; }
.post-content .text-red-600,
.post-content .text-red-800 { color: #c2463d; }

:root[data-theme="dark"] .post-content .text-green-800 { color: #7fd19b; }
:root[data-theme="dark"] .post-content .text-purple-800 { color: #c3a4ef; }
:root[data-theme="dark"] .post-content .text-red-600,
:root[data-theme="dark"] .post-content .text-red-800 { color: #f09088; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .post-content .text-green-800 { color: #7fd19b; }
  :root:not([data-theme="light"]) .post-content .text-purple-800 { color: #c3a4ef; }
  :root:not([data-theme="light"]) .post-content .text-red-600,
  :root:not([data-theme="light"]) .post-content .text-red-800 { color: #f09088; }
}

/* ป้ายชื่อร้าน/แท็กในบทความ */
.post-content .bg-gray-400 {
  display: inline-block;
  padding: 2px 12px !important;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent) !important;
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.8;
}

.post-content .bg-red-200 {
  display: inline-block;
  border-radius: var(--radius-sm);
  background: var(--peach-soft);
  color: var(--ink);
}

/* กล่องเน้นข้อความ */
.post-content .bg-green-50,
.post-content .bg-red-50 {
  display: block;
  padding: 20px 24px !important;
  border: 0 !important;
  border-radius: var(--radius);
}

.post-content .bg-green-50 {
  background: var(--accent-soft);
}

.post-content .bg-red-50 {
  background: var(--peach-soft);
}

.post-content .border { border: 1px solid var(--line); }
.post-content .border-t { border-top: 1px solid var(--line); }
.post-content .border-b { border-bottom: 1px solid var(--line); }

/* ── Post footer ─────────────────────────────────────────── */
.post-footer {
  display: grid;
  gap: 32px;
  margin-top: 48px;
  padding-top: 32px;
  border-top: 1px solid var(--line);
}

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

.share-label {
  margin-right: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--muted);
}

.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  font-size: 0.9rem;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease;
}

.share-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.share-btn.is-done {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  padding: 4px 14px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 0.85rem;
  color: var(--muted);
}

.post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.post-nav a {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-decoration: none;
  transition: border-color 160ms ease, transform 160ms ease;
}

.post-nav a:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.post-nav small {
  font-size: 0.8rem;
  color: var(--faint);
}

.post-nav strong {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.5;
}

.post-nav .next {
  grid-column: 2;
  text-align: right;
}

@media (max-width: 600px) {
  .post-nav {
    grid-template-columns: 1fr;
  }

  .post-nav .next {
    grid-column: auto;
  }
}

.related {
  margin-top: clamp(48px, 8vw, 88px);
  padding: clamp(40px, 6vw, 64px) 0;
  background: var(--surface-2);
}

/* ═══════════════════════════════════════════════════════════
   Static pages (about / contact / 404)
   ═══════════════════════════════════════════════════════════ */
.prose-page {
  width: min(var(--measure), 100% - var(--gutter) * 2);
  margin-inline: auto;
  padding-bottom: clamp(48px, 8vw, 96px);
}

/* ── About ───────────────────────────────────────────────── */
.about-page {
  overflow: hidden;
}

.about-hero {
  position: relative;
  padding: clamp(48px, 8vw, 104px) 0 clamp(56px, 8vw, 96px);
}

.about-hero::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: 7%;
  right: max(-140px, calc((100vw - var(--container)) / 2 - 220px));
  width: clamp(280px, 42vw, 620px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, var(--peach-soft), transparent 68%);
  opacity: 0.72;
  pointer-events: none;
}

.about-hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.03fr) minmax(340px, 0.82fr);
  gap: clamp(40px, 7vw, 92px);
  align-items: center;
}

.about-hero h1 {
  max-width: 13ch;
  margin: 18px 0 22px;
  font-family: var(--font-display);
  font-size: clamp(2.35rem, 5.4vw, 4.35rem);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.about-lead {
  max-width: 62ch;
  margin: 0;
  color: var(--muted);
  font-size: clamp(1.05rem, 1.8vw, 1.18rem);
  line-height: 1.85;
}

.about-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
}

.about-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 18px 34px;
  margin: 38px 0 0;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.about-stats div {
  min-width: 92px;
}

.about-stats dt {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 600;
  line-height: 1.2;
}

.about-stats dd {
  margin: 4px 0 0;
  color: var(--faint);
  font-size: 0.82rem;
}

.about-portrait {
  position: relative;
  margin: 0;
}

.about-portrait::before {
  content: "";
  position: absolute;
  inset: -14px 18px 14px -18px;
  z-index: -1;
  border: 1px solid var(--line-strong);
  border-radius: calc(var(--radius-lg) + 6px);
  transform: rotate(-2deg);
}

.about-portrait > img {
  display: block;
  width: 100%;
  min-height: 420px;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  object-position: center;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.about-portrait figcaption {
  position: absolute;
  right: 18px;
  bottom: 18px;
  left: 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: var(--radius);
  background: rgba(20, 30, 32, 0.76);
  color: #fff;
  font-size: 0.9rem;
  line-height: 1.45;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.about-portrait figcaption small {
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.78rem;
}

.about-portrait-mark {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--peach);
  color: #fff;
}

.about-content {
  padding-bottom: clamp(64px, 9vw, 112px);
}

.about-intro {
  display: grid;
  grid-template-columns: minmax(220px, 0.7fr) minmax(0, 1.3fr);
  gap: clamp(32px, 7vw, 96px);
  padding: clamp(48px, 7vw, 88px) 0;
  border-top: 1px solid var(--line);
}

.about-intro h2,
.about-section-head h2,
.about-start h2,
.about-author-heading h2 {
  margin: 10px 0 0;
  font-family: var(--font-display);
  font-size: clamp(1.65rem, 3.4vw, 2.35rem);
  font-weight: 600;
  line-height: 1.35;
  text-wrap: balance;
}

.about-intro-copy {
  position: relative;
  padding-left: 32px;
}

.about-intro-copy::before {
  content: "“";
  position: absolute;
  top: -18px;
  left: -5px;
  font-family: Georgia, serif;
  font-size: 4rem;
  line-height: 1;
  color: var(--peach);
  opacity: 0.5;
}

.about-intro-copy p {
  margin: 0 0 1.15em;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.9;
}

.about-intro-copy p:first-child {
  color: var(--ink);
  font-size: 1.15rem;
}

.about-section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 28px;
}

.about-section-head > p {
  max-width: 34ch;
  margin: 0;
  color: var(--faint);
  font-size: 0.92rem;
  text-align: right;
}

.about-topic-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.about-topic-card {
  position: relative;
  min-height: 280px;
  padding: clamp(24px, 4vw, 38px);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  transition: background-color 180ms ease;
}

.about-topic-card:hover {
  background: var(--accent-soft);
}

.about-topic-icon {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  margin-bottom: 38px;
  border-radius: 15px;
  background: var(--surface-2);
  color: var(--accent);
}

.about-topic-number {
  position: absolute;
  top: 32px;
  right: 34px;
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--faint);
}

.about-topic-card h3 {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
  line-height: 1.4;
}

.about-topic-card > p:last-child {
  max-width: 48ch;
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.75;
}

.about-start {
  display: grid;
  grid-template-columns: minmax(250px, 0.75fr) minmax(0, 1.25fr);
  gap: clamp(32px, 7vw, 88px);
  margin-top: clamp(64px, 9vw, 112px);
  padding: clamp(28px, 5vw, 52px);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
}

.about-start-copy > p:last-child {
  max-width: 38ch;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.about-start-links {
  display: grid;
}

.about-start-links a {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  min-height: 88px;
  padding: 16px 4px;
  border-bottom: 1px solid var(--line-strong);
  color: inherit;
  text-decoration: none;
}

.about-start-links a:first-child {
  border-top: 1px solid var(--line-strong);
}

.about-start-index {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--peach);
}

.about-start-links small,
.about-start-links strong {
  display: block;
}

.about-start-links small {
  margin-bottom: 3px;
  color: var(--faint);
  font-size: 0.78rem;
}

.about-start-links strong {
  overflow: hidden;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.about-start-links svg {
  color: var(--accent);
  transition: transform 160ms ease;
}

.about-start-links a:hover svg {
  transform: translateX(4px);
}

.about-author {
  margin-top: clamp(64px, 9vw, 112px);
}

.about-author-heading {
  margin-bottom: 24px;
}

@media (max-width: 900px) {
  .about-hero-grid {
    grid-template-columns: 1fr;
  }

  .about-hero h1 {
    max-width: 16ch;
  }

  .about-portrait {
    width: min(620px, calc(100% - 12px));
    margin-inline: auto;
  }

  .about-portrait > img {
    min-height: 0;
    aspect-ratio: 16 / 10;
  }

  .about-start {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .about-hero {
    padding-top: 36px;
  }

  .about-hero h1 {
    font-size: clamp(2.15rem, 11vw, 3rem);
  }

  .about-actions .btn {
    flex: 1 1 100%;
  }

  .about-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
  }

  .about-stats div {
    min-width: 0;
  }

  .about-stats dt {
    font-size: 1.35rem;
  }

  .about-stats dd {
    line-height: 1.45;
  }

  .about-portrait > img {
    aspect-ratio: 4 / 3;
  }

  .about-portrait figcaption {
    right: 10px;
    bottom: 10px;
    left: 10px;
  }

  .about-intro {
    grid-template-columns: 1fr;
  }

  .about-intro-copy {
    padding: 22px 0 0;
  }

  .about-intro-copy::before {
    top: -10px;
    left: 0;
  }

  .about-section-head {
    display: block;
  }

  .about-section-head > p {
    margin-top: 12px;
    text-align: left;
  }

  .about-topic-grid {
    grid-template-columns: 1fr;
  }

  .about-topic-card {
    min-height: 0;
  }

  .about-start {
    margin-inline: calc(var(--gutter) * -0.35);
    padding: 28px 22px;
  }
}

.contact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
  gap: 16px;
  margin-top: 32px;
}

.contact-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-decoration: none;
  transition: border-color 160ms ease, transform 160ms ease;
}

.contact-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.contact-card .contact-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 8px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
}

.contact-card strong {
  font-weight: 600;
}

.contact-card small {
  color: var(--faint);
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}

.empty-state {
  padding: 72px 0;
  text-align: center;
}

.empty-state .big {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(4rem, 14vw, 7rem);
  font-weight: 700;
  line-height: 1;
  color: var(--accent-soft);
}

/* ═══════════════════════════════════════════════════════════
   Search dialog
   ═══════════════════════════════════════════════════════════ */
.search-dialog {
  width: min(640px, 100% - 32px);
  max-height: min(640px, 100% - 96px);
  margin: 10vh auto auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.search-dialog[open] {
  display: flex;
  flex-direction: column;
  animation: pop-in 180ms ease-out;
}

.search-dialog::backdrop {
  background: rgba(10, 16, 18, 0.45);
  backdrop-filter: blur(4px);
}

.search-field {
  position: relative;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.search-field svg {
  position: absolute;
  left: 22px;
  color: var(--faint);
}

.search-field input {
  flex: 1;
  height: 64px;
  padding: 0 20px 0 56px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 1.1rem;
}

.search-field input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.search-field input:focus {
  outline: none;
}

.search-field .icon-btn {
  margin-right: 10px;
}

.search-results {
  overflow-y: auto;
  margin: 0;
  padding: 8px;
  list-style: none;
}

.search-results a {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  padding: 10px;
  border-radius: 12px;
  text-decoration: none;
}

.search-results a:hover,
.search-results a[aria-selected="true"] {
  background: var(--surface-2);
}

.search-results img {
  width: 64px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface-2);
}

.search-results strong {
  display: block;
  font-weight: 500;
  line-height: 1.5;
}

.search-results small {
  color: var(--faint);
  font-size: 0.8rem;
}

.search-results mark {
  background: var(--peach-soft);
  color: inherit;
  border-radius: 3px;
}

.search-hint {
  padding: 28px 20px;
  text-align: center;
  color: var(--faint);
  font-size: 0.92rem;
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}

/* ═══════════════════════════════════════════════════════════
   Zap dialog
   ═══════════════════════════════════════════════════════════ */
.zap-dialog {
  width: min(440px, 100% - 24px);
  max-height: calc(100% - 24px);
  overflow-y: auto;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
}

.zap-dialog[open] {
  animation: pop-in 180ms ease-out;
}

.zap-dialog::backdrop {
  background: rgba(10, 16, 18, 0.5);
  backdrop-filter: blur(4px);
}

.zap-close {
  position: absolute;
  top: 12px;
  right: 12px;
}

.zap-head {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin: 0 32px 22px 0;
}

.zap-badge {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: rgba(242, 169, 0, 0.16);
  color: var(--zap);
}

.zap-head h3 {
  margin: 0 0 2px;
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
  line-height: 1.4;
}

.zap-head p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.zap-step[hidden] {
  display: none;
}

.zap-presets {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 0 0 18px;
  padding: 0;
  border: 0;
}

.zap-presets button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 58px;
  padding: 6px 4px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: transparent;
  line-height: 1.2;
  cursor: pointer;
  transition: border-color 140ms ease, background-color 140ms ease;
}

.zap-presets strong {
  font-size: 1.05rem;
  font-weight: 600;
}

.zap-presets small {
  font-size: 0.72rem;
  color: var(--faint);
}

.zap-presets button:hover,
.zap-presets button.is-active {
  border-color: var(--zap);
  background: rgba(242, 169, 0, 0.14);
}

.zap-field {
  display: block;
  margin-bottom: 14px;
}

.zap-field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--muted);
}

.zap-field-label small {
  font-weight: 400;
  color: var(--faint);
}

.zap-field .input {
  height: 48px;
  padding: 0 16px;
  border-radius: 12px;
}

.zap-amount {
  position: relative;
  display: block;
}

.zap-amount .input {
  padding-right: 60px;
  font-size: 1.05rem;
  font-weight: 500;
  -moz-appearance: textfield;
  appearance: textfield;
}

.zap-amount .input::-webkit-outer-spin-button,
.zap-amount .input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.zap-unit {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--faint);
  font-size: 0.9rem;
  pointer-events: none;
}

.zap-status {
  margin: 0 0 14px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(194, 70, 61, 0.1);
  color: #b3372f;
  font-size: 0.88rem;
  line-height: 1.5;
}

:root[data-theme="dark"] .zap-status {
  color: #f09088;
}

.zap-status[hidden] {
  display: none;
}

.zap-dialog .btn-zap {
  width: 100%;
  min-height: 50px;
}

.zap-spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.zap-submit.is-loading .zap-spinner {
  display: inline-block;
}

.zap-submit:disabled {
  opacity: 0.75;
  cursor: progress;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.zap-address {
  display: grid;
  gap: 6px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 0.82rem;
  color: var(--faint);
  text-align: center;
}

.zap-address-copy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  max-width: 100%;
  padding: 8px 12px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 140ms ease, color 140ms ease;
}

.zap-address-copy code {
  overflow: hidden;
  font-size: 0.85rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.zap-address-copy:hover,
.zap-address-copy.is-done {
  border-color: var(--accent);
  color: var(--accent);
}

.zap-amount-label {
  margin: 0 0 12px;
  text-align: center;
  color: var(--muted);
}

.zap-amount-label strong {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--ink);
}

.zap-qr {
  display: grid;
  place-items: center;
  width: min(260px, 100%);
  aspect-ratio: 1;
  margin: 0 auto;
  padding: 10px;
  border-radius: 16px;
  background: #fff;
}

.zap-qr canvas {
  display: block;
  width: 100% !important;
  height: auto !important;
}

.zap-qr canvas[hidden],
.zap-qr-fallback[hidden] {
  display: none;
}

.zap-qr-fallback {
  margin: 0;
  padding: 16px;
  color: #5d6a6d;
  font-size: 0.88rem;
  text-align: center;
}

.zap-hint {
  margin: 12px 0 16px;
  color: var(--faint);
  font-size: 0.85rem;
  text-align: center;
}

.zap-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.zap-actions .btn {
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
}

.zap-actions .btn-ghost.is-done {
  border-color: var(--accent);
  color: var(--accent);
}

.zap-back {
  display: block;
  margin: 14px auto 0;
  padding: 4px 8px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 0.88rem;
  cursor: pointer;
}

.zap-back:hover {
  color: var(--accent);
}

@media (max-width: 420px) {
  .zap-dialog {
    padding: 22px 18px;
  }

  .zap-actions {
    grid-template-columns: 1fr;
  }
}

/* ═══════════════════════════════════════════════════════════
   Footer
   ═══════════════════════════════════════════════════════════ */
.site-footer {
  margin-top: clamp(48px, 8vw, 96px);
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.related + .site-footer {
  margin-top: 0;
}

.footer-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) repeat(2, minmax(0, 1fr));
  gap: 40px;
  padding: 56px 0 40px;
}

.footer-brand img {
  height: 40px;
  width: auto;
  filter: var(--logo-filter);
}

.footer-brand p {
  max-width: 38ch;
  margin: 12px 0 18px;
  color: var(--muted);
  font-size: 0.95rem;
}

.social-links {
  display: flex;
  gap: 6px;
}

.social-links a {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  transition: color 160ms ease, border-color 160ms ease;
}

.social-links a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.footer-col h4 {
  margin: 0 0 14px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
}

.footer-col ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.footer-col a {
  color: var(--muted);
  font-size: 0.95rem;
  text-decoration: none;
}

.footer-col a:hover {
  color: var(--accent);
}

.footer-bottom {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  padding: 20px 0 28px;
  border-top: 1px solid var(--line);
  font-size: 0.85rem;
  color: var(--faint);
}

.footer-bottom p {
  margin: 0;
}

.footer-bottom a {
  color: inherit;
}

.to-top {
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
  cursor: pointer;
}

.to-top:hover {
  color: var(--accent);
}

@media (max-width: 820px) {
  .footer-grid {
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    padding-top: 40px;
  }

  .footer-brand {
    grid-column: 1 / -1;
  }
}

/* ═══════════════════════════════════════════════════════════
   Race log — รายการสนามวิ่ง + หน้ารีวิวสนาม
   ═══════════════════════════════════════════════════════════ */
.race-totals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  margin: 8px 0 24px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  list-style: none;
}

.race-totals li,
.race-stats > div {
  /* เส้นคั่นซ้าย/บน แล้วดึงออกนอกกรอบ — ไม่มีช่องสีเทาเมื่อแถวสุดท้ายไม่เต็ม */
  margin: -1px 0 0 -1px;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.race-totals li {
  padding: 16px 18px;
}

.race-totals strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 600;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
}

.race-totals span {
  font-size: 0.85rem;
  color: var(--faint);
}

.race-tools {
  gap: 8px;
}

.race-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease;
}

.race-chip small {
  color: var(--faint);
}

.race-chip:hover {
  border-color: var(--ink);
  color: var(--ink);
}

.race-chip.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.race-chip.is-active small {
  color: inherit;
  opacity: 0.8;
}

.race-badge {
  padding: 1px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.7;
}

.race-badge-trail {
  background: var(--peach-soft);
  color: var(--peach);
}

.race-badge-road {
  background: var(--accent-soft);
  color: var(--accent);
}

.race-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.race-chips span {
  padding: 1px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.85rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.race-chips .race-star {
  border-color: transparent;
  background: rgba(242, 169, 0, 0.14);
  color: var(--ink);
}

.is-dnf {
  color: #c2463d !important;
}

.race-empty {
  padding: 64px 24px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  text-align: center;
  color: var(--muted);
}

.race-empty p {
  margin: 0;
}

.race-cover {
  width: min(960px, 100% - var(--gutter) * 2);
  margin: 0 auto 32px;
}

.race-cover img {
  display: block;
  width: 100%;
  max-height: 520px;
  object-fit: cover;
  border-radius: var(--radius-lg);
}

/* ── แกลเลอรีภาพแนบ + lightbox ───────────────────────────── */
.race-gallery {
  margin-top: 44px;
}

.race-gallery h2 {
  margin: 0 0 14px;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
}

.race-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.race-gallery-grid li {
  min-width: 0;
}

.race-photo {
  display: block;
  width: 100%;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  cursor: zoom-in;
  overflow: hidden;
}

.race-photo img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  transition: transform 240ms ease;
}

.race-photo:hover img,
.race-photo:focus-visible img {
  transform: scale(1.05);
}

.race-photo:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.race-photo-caption {
  margin: 8px 2px 0;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--muted);
}

.race-lightbox {
  position: fixed;
  inset: 0;
  width: min(1100px, 100% - 32px);
  max-width: min(1100px, 100% - 32px);
  max-height: calc(100% - 32px);
  margin: auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.race-lightbox[open] {
  animation: pop-in 180ms ease-out;
}

.race-lightbox::backdrop {
  background: rgba(10, 16, 18, 0.72);
  backdrop-filter: blur(4px);
}

.race-lightbox-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
}

.race-lightbox-stage img {
  display: block;
  width: 100%;
  max-height: calc(100vh - 140px);
  object-fit: contain;
}

.race-lightbox-bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  border-top: 1px solid var(--line);
}

.race-lightbox-caption {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--muted);
}

.race-lightbox-count {
  margin-left: auto;
  font-size: 0.82rem;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.race-lightbox-nav,
.race-lightbox-close {
  position: absolute;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  opacity: 0.9;
}

.race-lightbox-nav:hover,
.race-lightbox-close:hover {
  opacity: 1;
  border-color: var(--accent);
  color: var(--accent);
}

.race-lightbox-nav:focus-visible,
.race-lightbox-close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.race-lightbox.is-single .race-lightbox-nav {
  display: none;
}

.race-lightbox-prev {
  top: 50%;
  left: 12px;
  transform: translateY(-50%);
}

.race-lightbox-next {
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
}

.race-lightbox-close {
  top: 12px;
  right: 12px;
}

.race-panel {
  margin-bottom: 40px;
}

.race-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.race-stats > div {
  padding: 14px 18px;
}

.race-stats dt {
  font-size: 0.82rem;
  color: var(--faint);
}

.race-stats dd {
  margin: 2px 0 0;
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 600;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}

.race-stats dd small {
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--muted);
}

.race-notes {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.race-notes p {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin: 0;
  padding: 14px 18px;
  border-radius: var(--radius);
  background: var(--surface-2);
  line-height: 1.7;
}

.race-notes em {
  font-style: normal;
  font-weight: 600;
}

.race-goal.is-met {
  background: var(--accent-soft);
}

.race-goal.is-missed {
  background: var(--peach-soft);
}

.race-goal-icon {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface);
  font-weight: 700;
}

.race-verdict {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 20px 32px;
  margin-top: 48px;
  padding: clamp(20px, 4vw, 32px);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.race-verdict h2 {
  grid-column: 1 / -1;
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 600;
}

.race-score {
  display: flex;
  gap: 8px;
  align-items: center;
}

.race-score strong {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 600;
  line-height: 1;
}

.race-score span {
  font-size: 0.85rem;
  line-height: 1.4;
  color: var(--faint);
}

.race-ratings {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.race-ratings li {
  display: grid;
  grid-template-columns: minmax(120px, 11rem) minmax(0, 1fr) 1.5rem;
  gap: 12px;
  align-items: center;
  font-size: 0.95rem;
}

.race-ratings b {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.race-bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}

.race-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.race-facts {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px 24px;
  margin: 0;
}

.race-facts dt {
  font-size: 0.82rem;
  color: var(--faint);
}

.race-facts dd {
  margin: 0;
}

.race-links {
  display: flex;
  flex-wrap: wrap;
  grid-column: 1 / -1;
  gap: 8px;
  margin: 0;
}

.run-tabs {
  display: flex;
  gap: 4px;
  margin: 8px 0 24px;
  border-bottom: 1px solid var(--line);
}

.run-tabs a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: -1px;
  padding: 12px 18px;
  border-bottom: 2px solid transparent;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  transition: color 160ms ease, border-color 160ms ease;
}

.run-tabs a:hover {
  color: var(--ink);
}

.run-tabs a[aria-selected="true"] {
  border-bottom-color: var(--peach);
  color: var(--ink);
}

.run-tabs small {
  padding: 0 8px;
  border-radius: 999px;
  background: var(--surface-2);
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
}

.run-panel[hidden],
[data-filter-type][hidden] {
  display: none;
}

.run-panel + .run-panel {
  margin-top: 48px;
}

.run-panel .race-tools {
  display: flex;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.route-grid .post-card .race-chips {
  margin-top: 2px;
}

.race-badge-mixed,
.race-badge-route {
  background: var(--surface-2);
  color: var(--muted);
}

.race-stats dd.is-text {
  font-family: var(--font-body);
  font-size: 1.02rem;
  font-weight: 500;
  line-height: 1.5;
}

.route-dots {
  display: inline-flex;
  gap: 3px;
  margin-right: 6px;
  vertical-align: middle;
}

.route-dots i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}

.route-dots i.on {
  background: var(--peach);
  box-shadow: none;
}

.route-info {
  display: block;
}

.route-info h2 {
  margin-bottom: 16px;
}

.route-safety {
  margin: 16px 0 0;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--peach-soft);
  line-height: 1.7;
}

.route-links {
  margin-top: 24px;
}

.race-related {
  margin-top: 40px;
}

.race-related h2 {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
}

.race-related ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.race-related a {
  display: block;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  transition: border-color 160ms ease;
}

.race-related a:hover {
  border-color: var(--accent);
}

.race-related small {
  color: var(--faint);
}

@media (max-width: 720px) {
  .race-verdict {
    grid-template-columns: 1fr;
  }

  .race-gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .race-ratings li {
    grid-template-columns: minmax(0, 1fr) 1.5rem;
  }

  .race-ratings .race-bar {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}

/* ── Reduced motion ──────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* การ์ดใน static page ไม่ใช้สีลิงก์แบบบทความ */
.prose-page .post-content {
  padding-top: 32px;
}

.post-content .contact-card,
.post-content .author-card a {
  color: inherit;
  text-decoration: none;
}
