/* NonDev — nondev.net
   ฟอนต์: IBM Plex Sans Thai (เนื้อหา) + IBM Plex Mono (ตัวเลข/ป้ายละติน) • สว่าง/มืดตาม prefers-color-scheme
   ภาษาไทยต้องการ line-height สูงกว่าละติน (สระบน/วรรณยุกต์/สระล่าง) — เนื้อข่าว 1.85 พาดหัว ≥ 1.3 */

/* ---------- โทเคน ---------- */
:root {
  --bg: #f5f3ee;
  --surface: #fffdf9;
  --surface-2: #ece8df;
  --ink: #14161b;
  --ink-2: #363b47;
  --muted: #5b6170;
  --line: #e0dbd0;
  --line-2: #c9c2b4;
  --accent: #2243d0;
  --accent-soft: #e6eafb;
  --lime: #d4f53c;
  --lime-ink: #14161b;
  --fb: #1565d8;
  --fb-hover: #0f56bd;
  --danger: #b42a25;
  --ok: #1d7a3a;
  --top-bg: #14161b;
  --top-ink: #d9d7d0;
  --foot-bg: #14161b;
  --foot-ink: #d9d7d0;
  --foot-muted: #9a9ea8;
  --shadow: 0 1px 0 rgb(20 22 27 / 4%), 0 10px 30px -18px rgb(20 22 27 / 35%);
  --r: 14px;
  --r-s: 9px;
  --font: "IBM Plex Sans Thai", "Noto Sans Thai", "Sarabun", "Leelawadee UI", "Thonburi", system-ui, -apple-system,
    "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --wrap: 1220px;
  --gutter: 16px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0f13;
    --surface: #15181e;
    --surface-2: #1e222a;
    --ink: #ecebe6;
    --ink-2: #c9cbd2;
    --muted: #979dab;
    --line: #262a33;
    --line-2: #3a3f4b;
    --accent: #a3b4ff;
    --accent-soft: #1a2039;
    --danger: #ff8a80;
    --ok: #7ad992;
    --top-bg: #07080a;
    --top-ink: #b9bcc5;
    --foot-bg: #07080a;
    --shadow: 0 1px 0 rgb(0 0 0 / 30%), 0 12px 30px -18px rgb(0 0 0 / 80%);
  }
}

@media (min-width: 640px) {
  :root { --gutter: 24px; }
}
@media (min-width: 1100px) {
  :root { --gutter: 32px; }
}

/* สีหมวด: --cat ใช้กับจุด/เส้น • --c1..c3 ใช้ไล่สีปก */
.cat-ai { --cat: #6b4cf6; --c1: #1a1150; --c2: #4f36d6; --c3: #8d78ff; }
.cat-hardware { --cat: #d9730d; --c1: #3a1b04; --c2: #b55a08; --c3: #f29a3a; }
.cat-software { --cat: #0f9488; --c1: #042b28; --c2: #0b7a70; --c3: #2fc4b4; }
.cat-security { --cat: #e0393c; --c1: #3a080c; --c2: #b8242c; --c3: #ff6b6b; }
.cat-mobile { --cat: #d1347f; --c1: #380a23; --c2: #ad2465; --c3: #f472b6; }
.cat-business { --cat: #2563eb; --c1: #0a1a45; --c2: #1d4fcc; --c3: #60a5fa; }
.cat-science { --cat: #2f9e44; --c1: #0a2a13; --c2: #217d37; --c3: #5bd27a; }
.cat-other { --cat: #64748b; --c1: #1c232d; --c2: #475466; --c3: #94a3b8; }

/* ---------- พื้นฐาน ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: 1rem; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; outline: none; }
h1, h2, h3 { margin: 0; line-height: 1.35; font-weight: 700; }
p, ul, ol, dl, dd, figure, blockquote { margin: 0; }
ul, ol { padding: 0; }
a { color: var(--accent); text-underline-offset: 0.22em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
button, input, textarea { font: inherit; color: inherit; }
.icon { display: inline-block; width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.2em; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--lime); color: var(--lime-ink); }

.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: var(--gutter); }
.narrow { max-width: calc(46rem + 2 * var(--gutter)); }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: 1rem; top: -100px; z-index: 50; background: var(--lime); color: var(--lime-ink);
  padding: 0.6rem 1rem; border-radius: var(--r-s); font-weight: 600; text-decoration: none;
}
.skip:focus { top: 1rem; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }

/* ---------- ปุ่ม ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5em;
  padding: 0.62rem 1.15rem; min-height: 44px;
  border-radius: 999px; border: 1px solid transparent;
  background: var(--ink); color: var(--bg);
  font-weight: 600; font-size: 0.95rem; line-height: 1.3; text-decoration: none; cursor: pointer;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--ink-2); }
.btn-ghost, .btn-outline { background: transparent; color: var(--ink); border-color: var(--line-2); }
.btn-ghost:hover, .btn-outline:hover { background: var(--surface-2); border-color: var(--ink-2); }
.btn-fb { background: var(--fb); color: #fff; }
.btn-fb:hover { background: var(--fb-hover); }
.btn-danger { background: transparent; color: var(--danger); border-color: currentColor; }
.btn-danger:hover { background: var(--danger); color: var(--bg); }
.btn-small { padding: 0.3rem 0.85rem; min-height: 36px; font-size: 0.85rem; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* ---------- ส่วนหัว ---------- */
.topbar { background: var(--top-bg); color: var(--top-ink); font-size: 0.8rem; }
.topbar-in { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 36px; }
.today { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toplinks { display: flex; align-items: center; gap: 1.1rem; }
.toplinks a { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 0.35em; white-space: nowrap; }
.toplinks a:hover { color: #fff; text-decoration: underline; }
.toplinks .icon { width: 1em; height: 1em; }
.toplink-fb .icon { color: #5b9dff; }
@media (max-width: 640px) {
  .today, .toplinks a[href="/about"] { display: none; }
  .topbar-in { justify-content: flex-end; }
}

.masthead {
  display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 0.75rem 1.5rem;
  padding-block: 1rem;
}
.brand { display: inline-flex; align-items: center; gap: 0.6rem; color: var(--ink); text-decoration: none; }
.brand-logo { width: 36px; height: 36px; flex: none; }
.logo-bg { fill: var(--ink); }
.logo-n { stroke: var(--bg); }
.logo-cur { fill: var(--lime); }
.brand-name { font-size: 1.65rem; font-weight: 700; letter-spacing: -0.03em; line-height: 1; font-family: var(--font); }
.brand-dev {
  display: inline-block; line-height: 1.08; background: var(--lime); color: var(--lime-ink); border-radius: 6px;
  padding: 0.04em 0.14em 0.1em; margin-left: 0.03em;
}
.tagline { color: var(--muted); font-size: 0.9rem; line-height: 1.5; justify-self: start; max-width: 26rem; }
.search { display: flex; align-items: center; position: relative; grid-column: 1 / -1; }
.search input {
  width: 100%; min-height: 44px; padding: 0.55rem 3rem 0.55rem 1.1rem;
  border: 1px solid var(--line-2); border-radius: 999px; background: var(--surface); color: var(--ink);
  -webkit-appearance: none; appearance: none;
}
.search input::placeholder { color: var(--muted); opacity: 1; }
.search input:focus-visible { outline: 3px solid var(--accent); outline-offset: 0; border-color: transparent; }
.search button {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--ink); color: var(--bg);
  display: grid; place-items: center; cursor: pointer;
}
.search button .icon { width: 18px; height: 18px; }
@media (max-width: 719px) {
  .tagline { display: none; }
}
@media (min-width: 720px) {
  .masthead { grid-template-columns: auto 1fr minmax(240px, 340px); padding-block: 1.35rem; }
  .search { grid-column: auto; }
  .tagline { border-left: 1px solid var(--line-2); padding-left: 1.25rem; }
}

.catnav { border-block: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 20; }
.catnav ul {
  display: flex; list-style: none; gap: 0.25rem; overflow-x: auto; scrollbar-width: none;
  margin-inline: calc(-1 * var(--gutter)); padding-inline: var(--gutter);
  -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent);
  mask-image: linear-gradient(90deg, #000 85%, transparent);
}
.catnav ul::-webkit-scrollbar { display: none; }
.catnav a {
  display: block; padding: 0.7rem 0.8rem 0.62rem; white-space: nowrap; color: var(--ink-2); text-decoration: none;
  font-weight: 500; font-size: 0.95rem; border-bottom: 3px solid transparent;
}
.catnav a:hover { color: var(--ink); border-bottom-color: var(--cat, var(--line-2)); }
.catnav a[aria-current="page"] { color: var(--ink); font-weight: 700; border-bottom-color: var(--cat, var(--ink)); }
@media (min-width: 1100px) {
  .catnav ul { -webkit-mask-image: none; mask-image: none; }
}

/* ---------- ปกข่าวที่สร้างเอง ---------- */
.cover {
  position: relative; overflow: hidden; isolation: isolate;
  aspect-ratio: 16 / 9; border-radius: var(--r);
  background: linear-gradient(var(--ang, 135deg), var(--c1) 0%, var(--c2) 62%, var(--c3) 120%);
  color: rgb(255 255 255 / 42%);
  container-type: inline-size;
}
.tone-1 { --ang: 160deg; }
.tone-2 { --ang: 35deg; }
.tone-3 { --ang: 205deg; }
.cover::after {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: radial-gradient(circle at 88% 12%, rgb(255 255 255 / 16%), transparent 42%),
    radial-gradient(circle at 8% 100%, rgb(0 0 0 / 28%), transparent 55%);
}
.cover svg { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; }
.cover .a { stroke: var(--lime); }
.cover .af { fill: var(--lime); }
.cover-label {
  position: absolute; left: 5cqi; right: 5cqi; bottom: 4.5cqi;
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.3em;
}
.cover-cat {
  color: #fff; font-weight: 700; line-height: 1.25; letter-spacing: -0.01em;
  font-size: clamp(13px, 7cqi, 56px); text-shadow: 0 2px 18px rgb(0 0 0 / 30%);
}
.cover-cat::before {
  content: ""; display: block; width: 1.4em; height: 0.16em; min-height: 3px; background: var(--lime);
  border-radius: 2px; margin-bottom: 0.35em;
}
.cover--card .cover-cat { font-size: clamp(13px, 6.2cqi, 26px); }
.cover-mark {
  position: absolute; top: 3.5cqi; right: 4.5cqi; font-family: var(--mono); font-weight: 500;
  font-size: clamp(10px, 2cqi, 15px); line-height: 1.5; color: rgb(255 255 255 / 85%); letter-spacing: 0.04em;
  background: rgb(0 0 0 / 28%); padding: 0.1em 0.65em; border-radius: 999px;
}
.cover--thumb { aspect-ratio: 1; border-radius: var(--r-s); }

/* ภาพประกอบจริง: ใช้กรอบและสัดส่วนเดียวกับปกที่สร้างเอง (ไม่มีการกระโดดของเลย์เอาต์) */
.cover--img { background: var(--surface-2); outline: 1px solid var(--line); outline-offset: -1px; }
.cover--img::after { content: none; }
.cover--img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
/* ภาพแนวตั้ง (ส่วนใหญ่เป็นภาพบุคคล): เน้นส่วนบนให้เห็นหน้า • หน้าข่าวให้กรอบสูงขึ้นเป็น 3:2 (คลาสมาจากเซิร์ฟเวอร์ จึงไม่กระโดด) */
.img-tall img { object-position: 50% 25%; }
.article-figure .cover--hero.img-tall { aspect-ratio: 3 / 2; }
.img-ai {
  position: absolute; top: 8px; right: 8px; font-family: var(--mono); font-weight: 600; font-size: 0.72rem;
  line-height: 1; letter-spacing: 0.04em; color: #fff; background: rgb(0 0 0 / 66%); padding: 0.34em 0.6em; border-radius: 999px;
}
.cover--thumb .img-ai { top: 4px; right: 4px; font-size: 0.62rem; }
.img-credit { margin-top: 0.55rem; font-size: 0.8rem; line-height: 1.55; color: var(--muted); overflow-wrap: anywhere; }
.img-credit a { color: inherit; }
.img-credit a:hover { color: var(--ink); }

/* ---------- การ์ดข่าว ---------- */
.story { position: relative; min-width: 0; }
.story-body { min-width: 0; }
.story-title { font-weight: 600; line-height: 1.42; overflow-wrap: anywhere; text-wrap: pretty; }
.story-title a { color: var(--ink); text-decoration: none; }
.story-title a::after { content: ""; position: absolute; inset: 0; z-index: 0; }
.story:hover .story-title a { text-decoration: underline; text-decoration-thickness: 2px; text-decoration-color: var(--cat, var(--accent)); text-underline-offset: 0.25em; }
.story-title a:focus-visible { outline: none; }
.story:has(.story-title a:focus-visible) { outline: 3px solid var(--accent); outline-offset: 6px; border-radius: var(--r-s); }
.story-dek { color: var(--ink-2); margin-top: 0.35rem; line-height: 1.7; }
.kicker {
  position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 0.45em;
  font-size: 0.8rem; font-weight: 600; color: var(--ink-2); text-decoration: none; line-height: 1.6;
}
.kicker::before { content: ""; width: 0.62em; height: 0.62em; border-radius: 2px; background: var(--cat); flex: none; }
a.kicker:hover { color: var(--ink); text-decoration: underline; }
.meta { color: var(--muted); font-size: 0.82rem; margin-top: 0.45rem; line-height: 1.5; }
.meta .sep { margin-inline: 0.45em; }
.meta .src { font-weight: 500; }

.story--lead { display: grid; gap: 1.1rem; }
.story--lead .story-title { font-size: clamp(1.45rem, 1.05rem + 1.7vw, 2.25rem); line-height: 1.32; font-weight: 700; letter-spacing: -0.01em; margin-top: 0.2rem; text-wrap: balance; }
.story--lead .story-dek { font-size: 1.05rem; margin-top: 0.6rem; }

.story--card { display: flex; flex-direction: column; gap: 0.8rem; }
.story--card .story-title { font-size: 1.08rem; margin-top: 0.15rem; }

.story--row {
  display: grid; grid-template-columns: minmax(0, 1fr) 84px; gap: 0.9rem; align-items: start;
  padding-block: 1.1rem; border-bottom: 1px solid var(--line);
}
.story--row .cover { grid-column: 2; grid-row: 1; }
.story--row .story-body { grid-column: 1; grid-row: 1; }
.story--row .story-title { font-size: 1.04rem; }
.story--row .story-dek { display: none; }
@media (min-width: 640px) {
  .story--row { grid-template-columns: 196px minmax(0, 1fr); gap: 1.4rem; }
  .story--row .cover { grid-column: 1; aspect-ratio: 16 / 10; }
  .story--row .story-body { grid-column: 2; }
  .story--row .story-title { font-size: 1.15rem; }
  .story--row .story-dek {
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; font-size: 0.95rem;
  }
}
.rows > .story--row:first-child { padding-top: 0.4rem; }

.card-grid { display: grid; gap: 1.75rem 1.5rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); }
@media (min-width: 1100px) {
  .card-grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* ---------- หัวข้อส่วน ---------- */
.section-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 1rem;
  border-top: 2px solid var(--ink); padding-top: 0.7rem; margin-bottom: 1rem;
}
.section-head h2 { font-size: 1.12rem; font-weight: 700; display: flex; align-items: center; gap: 0.5rem; }
.section-head h2::before { content: ""; width: 0.7rem; height: 0.7rem; background: var(--lime); border-radius: 2px; box-shadow: inset 0 0 0 1px rgb(0 0 0 / 18%); }
.more { display: inline-flex; align-items: center; gap: 0.3em; font-size: 0.88rem; font-weight: 600; color: var(--ink-2); text-decoration: none; white-space: nowrap; }
.more:hover { color: var(--ink); text-decoration: underline; }
.more .icon { width: 1em; height: 1em; }
.more-wrap { margin-top: 1.5rem; }

/* ---------- หน้าแรก ---------- */
.home { padding-top: 1.5rem; }
.top-stories { display: grid; gap: 2rem; margin-bottom: 2.75rem; }
.top-side { display: grid; gap: 1.75rem; align-content: start; }
@media (min-width: 640px) and (max-width: 939px) {
  .top-side { grid-template-columns: 1fr 1fr; gap: 1.5rem; }
}
@media (min-width: 940px) {
  .top-stories { grid-template-columns: minmax(0, 1.72fr) minmax(0, 1fr); gap: 2.5rem; }
  .top-side { border-left: 1px solid var(--line); padding-left: 2.5rem; }
}

.with-side { display: grid; gap: 2.75rem; }
@media (min-width: 1024px) {
  .with-side { grid-template-columns: minmax(0, 1fr) 330px; gap: 3.5rem; }
}
.sidebar { display: grid; gap: 2.25rem; align-content: start; }
@media (min-width: 1024px) {
  .sidebar { position: sticky; top: 4.5rem; }
}

.ranked-list { list-style: none; }
.ranked { position: relative; display: grid; grid-template-columns: 2.6rem minmax(0, 1fr); gap: 0.4rem; padding-block: 0.85rem; border-bottom: 1px solid var(--line); }
.ranked:first-child { padding-top: 0.2rem; }
.ranked:last-child { border-bottom: 0; }
.rank { font-family: var(--mono); font-weight: 600; font-size: 1.35rem; line-height: 1.25; color: var(--muted); }
.ranked:first-child .rank { color: var(--ink); }
.ranked .story-title { font-size: 0.98rem; }
.ranked .story-title a::after { content: ""; position: absolute; inset: 0; }
.ranked:hover .story-title a { text-decoration: underline; text-decoration-color: var(--accent); }
.ranked .meta { margin-top: 0.25rem; }

.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; list-style: none; }
.chip {
  display: inline-flex; align-items: center; gap: 0.45em; padding: 0.32rem 0.8rem; min-height: 36px;
  border: 1px solid var(--line-2); border-radius: 999px; color: var(--ink-2); text-decoration: none;
  font-size: 0.88rem; font-weight: 500; background: var(--surface); max-width: 100%; overflow-wrap: anywhere;
}
.chip:hover { background: var(--lime); color: var(--lime-ink); border-color: var(--lime); text-decoration: none; }
.chip-n { font-family: var(--mono); font-size: 0.75rem; color: var(--muted); }
.chip:hover .chip-n { color: var(--lime-ink); }

.by-cat { margin-top: 3.5rem; }
.cat-grid { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 270px), 1fr)); }
.cat-col {
  background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--cat);
  border-radius: var(--r-s); padding: 1rem 1.15rem 1.1rem; display: flex; flex-direction: column; gap: 0.6rem;
}
.cat-col-h { font-size: 1.05rem; }
.cat-col-h a { color: var(--ink); text-decoration: none; }
.cat-col-h a:hover { text-decoration: underline; }
.cat-col ul { list-style: none; display: grid; gap: 0.7rem; }
.cat-col li { line-height: 1.5; font-size: 0.95rem; }
.cat-col li a { color: var(--ink); text-decoration: none; font-weight: 500; }
.cat-col li a:hover { text-decoration: underline; text-decoration-color: var(--cat); }
.meta-inline { color: var(--muted); font-size: 0.78rem; white-space: nowrap; }
.cat-col .more { margin-top: auto; padding-top: 0.3rem; }

/* ---------- ติดตามเพจ ---------- */
.follow {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem 1.5rem;
  margin-top: 2.5rem; padding: 1.3rem 1.5rem; border-radius: var(--r);
  background: #16263a; border: 1px solid #2f4f7a; color: #e8eef8;
}
.follow-title { font-weight: 700; font-size: 1.1rem; line-height: 1.45; }
.follow-sub { color: #b5c3d8; font-size: 0.92rem; margin-top: 0.2rem; }
.follow--compact { margin-top: 0; flex-direction: column; align-items: stretch; padding: 1.15rem 1.2rem; }
.follow--compact .follow-title { font-size: 1rem; }
.follow .btn-fb { white-space: nowrap; }

/* ---------- หน้ารายการ ---------- */
.list-page { padding-top: 0.5rem; }
.list-head { padding: 1.75rem 0 1.25rem; margin-bottom: 1.75rem; border-bottom: 2px solid var(--ink); }
.list-head[class*="cat-"] { border-bottom-color: var(--cat); }
.eyebrow { font-size: 0.82rem; font-weight: 600; color: var(--muted); display: flex; align-items: center; gap: 0.45em; }
.list-head[class*="cat-"] .eyebrow::before { content: ""; width: 0.62em; height: 0.62em; border-radius: 2px; background: var(--cat); }
.list-head h1 { font-size: clamp(1.75rem, 1.3rem + 2vw, 2.7rem); line-height: 1.3; letter-spacing: -0.015em; margin-top: 0.2rem; overflow-wrap: anywhere; }
.list-desc { color: var(--ink-2); margin-top: 0.5rem; max-width: 42rem; }
.list-count { color: var(--muted); font-size: 0.88rem; margin-top: 0.35rem; font-variant-numeric: tabular-nums; }
.list-page .card-grid { margin-bottom: 1rem; }
.sub-h { font-size: 1.05rem; margin: 2rem 0 0.85rem; }

.pager { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1rem; padding: 2rem 0 0.5rem; }
.pager > :last-child { justify-self: end; }
.pager-pos { color: var(--muted); font-size: 0.88rem; white-space: nowrap; }

.search--big { margin: 0.5rem 0 1.25rem; max-width: 36rem; gap: 0.6rem; }
.search--big input { padding-right: 1.1rem; }
.search--big button.btn {
  position: static; transform: none; flex: none; width: auto; height: auto; min-height: 44px;
  border-radius: 999px; padding: 0.62rem 1.35rem; background: var(--ink); color: var(--bg);
}

.empty { padding: 2rem 0; color: var(--ink-2); display: grid; gap: 1rem; max-width: 40rem; }

/* ---------- หน้าข่าว ---------- */
.article-layout { display: grid; gap: 3rem; padding-top: 1.25rem; }
@media (min-width: 1024px) {
  .article-layout { grid-template-columns: minmax(0, 1fr) 300px; gap: 4rem; }
  .article-side { position: sticky; top: 4.5rem; align-self: start; padding-top: 2.6rem; }
}
.article { min-width: 0; max-width: 46rem; }
.crumbs { display: flex; flex-wrap: wrap; gap: 0.5em; font-size: 0.85rem; color: var(--muted); margin-bottom: 1.25rem; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--ink); text-decoration: underline; }
.article-head h1 {
  font-size: clamp(1.6rem, 1.15rem + 2.1vw, 2.55rem); line-height: 1.33; letter-spacing: -0.015em;
  margin-top: 0.35rem; overflow-wrap: anywhere; text-wrap: balance;
}
.dek { font-size: clamp(1.06rem, 1rem + 0.35vw, 1.22rem); color: var(--ink-2); line-height: 1.72; margin-top: 0.85rem; }
.byline {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1.1rem; margin-top: 1.25rem;
  padding-block: 0.8rem; border-block: 1px solid var(--line); font-size: 0.86rem; color: var(--muted);
}
.byline a:not(.ai-badge) { color: var(--ink-2); }
.byline-item { white-space: nowrap; }
.ai-badge {
  display: inline-flex; align-items: center; gap: 0.35em; padding: 0.18rem 0.7rem 0.18rem 0.55rem;
  border-radius: 999px; background: var(--lime); color: var(--lime-ink); font-weight: 600; font-size: 0.8rem;
  text-decoration: none; white-space: nowrap;
}
.ai-badge:hover { text-decoration: underline; }
.ai-badge .icon { width: 1.05em; height: 1.05em; }
.article-cover { margin: 1.5rem 0 1.75rem; }

.prose { font-size: 1.1rem; line-height: 1.88; color: var(--ink); }
.prose p { margin-bottom: 1.15em; text-wrap: pretty; }
.prose h2 { font-size: 1.32rem; line-height: 1.42; margin: 1.7em 0 0.55em; }
.prose ul, .prose ol { padding-left: 1.4em; margin-bottom: 1.15em; }
.prose li { margin-bottom: 0.45em; padding-left: 0.2em; }
.prose li::marker { color: var(--cat, var(--accent)); }
.article .prose li::marker { color: var(--muted); }
.prose blockquote {
  margin: 1.5em 0; padding: 0.2em 0 0.2em 1.2em; border-left: 4px solid var(--lime);
  font-size: 1.12rem; color: var(--ink-2); font-style: normal;
}
.prose blockquote p:last-child { margin-bottom: 0; }
@media (min-width: 720px) {
  .prose { font-size: 1.15rem; }
}

.source-box {
  margin-top: 2.25rem; padding: 1.3rem 1.5rem 1.5rem; border: 1px solid var(--line-2);
  border-radius: var(--r); background: var(--surface);
}
.source-box h2 { font-size: 1rem; margin-bottom: 0.75rem; }
.source-box dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 0.4rem 1.1rem; margin-bottom: 1.1rem; font-size: 0.95rem; }
.source-box dt { color: var(--muted); }
.source-box dd { overflow-wrap: anywhere; }
.source-name { font-weight: 600; }
.source-title { font-weight: 500; font-style: italic; }
@media (max-width: 479px) {
  .source-box { padding: 1.1rem 1.1rem 1.25rem; }
  .source-box dl { grid-template-columns: 1fr; gap: 0; }
  .source-box dd { margin-bottom: 0.55rem; }
}

.ai-note {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0.75rem; align-items: start;
  margin-top: 1.25rem; padding: 1rem 1.25rem; border-radius: var(--r); background: var(--accent-soft);
  font-size: 0.92rem; line-height: 1.72; color: var(--ink-2);
}
.ai-note .icon { color: var(--accent); margin-top: 0.25em; }

.article-tags { margin-top: 1.75rem; }
.share { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--line); }
.share-label { font-weight: 600; font-size: 0.92rem; margin-right: 0.35rem; }
.share-btn {
  display: inline-flex; align-items: center; gap: 0.45em; min-height: 40px; padding: 0.4rem 0.95rem;
  border: 1px solid var(--line-2); border-radius: 999px; background: var(--surface); color: var(--ink);
  font-size: 0.88rem; font-weight: 500; text-decoration: none; cursor: pointer;
}
.share-btn:hover { border-color: var(--ink-2); background: var(--surface-2); }
.share-btn .icon { width: 1.05em; height: 1.05em; }
.share-fb .icon { color: #1877f2; }
.share-line .icon { color: #06c755; }
.share-btn[hidden] { display: none; }

.related { margin-top: 3.5rem; }
.preview-bar { background: var(--lime); color: var(--lime-ink); font-size: 0.9rem; padding: 0.6rem 0; }
.preview-bar a { color: inherit; font-weight: 600; margin-left: 0.5rem; }

/* ---------- เกี่ยวกับ / ข้อผิดพลาด ---------- */
.about .prose { font-size: 1.05rem; }
.about .prose h2 { scroll-margin-top: 4.5rem; }
.about .prose a { font-weight: 500; }
.error-page { padding-top: 2.5rem; text-align: left; }
.error-code {
  font-family: var(--mono); font-weight: 600; font-size: clamp(4rem, 3rem + 6vw, 7.5rem); line-height: 1;
  color: transparent; -webkit-text-stroke: 2px var(--ink); letter-spacing: -0.04em;
}
.error-page h1 { font-size: clamp(1.6rem, 1.3rem + 1.5vw, 2.3rem); margin: 0.5rem 0 0.6rem; }
.error-page > p { color: var(--ink-2); margin-bottom: 1rem; max-width: 36rem; }

/* ---------- ส่วนท้าย ---------- */
.site-foot { margin-top: 4.5rem; background: var(--foot-bg); color: var(--foot-ink); font-size: 0.92rem; }
.site-foot a { color: inherit; }
.site-foot a:hover { color: #fff; }
.site-foot .brand { color: #f3f1ec; }
.site-foot .logo-bg { fill: #f3f1ec; }
.site-foot .logo-n { stroke: #14161b; }
.foot-grid { display: grid; gap: 2rem; padding-block: 2.75rem 2rem; }
@media (min-width: 760px) {
  .foot-grid { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 1fr); gap: 3rem; }
}
.foot-brand { display: grid; gap: 0.75rem; align-content: start; }
.foot-note { color: var(--foot-muted); font-size: 0.85rem; line-height: 1.7; max-width: 30rem; }
.site-foot h2 { font-size: 0.85rem; font-weight: 600; color: var(--foot-muted); margin-bottom: 0.7rem; }
.site-foot nav ul { list-style: none; display: grid; gap: 0.4rem; }
.site-foot nav a { text-decoration: none; }
.site-foot nav a:hover { text-decoration: underline; }
.foot-bottom {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem 1.5rem;
  padding-block: 1.1rem 1.5rem; color: var(--foot-muted); font-size: 0.85rem; position: relative;
}
.foot-bottom::before {
  content: ""; position: absolute; top: 0; left: var(--gutter); right: var(--gutter);
  border-top: 1px solid rgb(255 255 255 / 12%);
}
.foot-bottom a { color: var(--foot-ink); font-weight: 600; }

/* ---------- หลังบ้าน ---------- */
.admin { padding-top: 1.5rem; display: grid; gap: 1.5rem; }
.admin-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.admin-head h1 { font-size: 1.8rem; }
.admin-login { padding-top: 2.5rem; }
.admin-login h1 { font-size: 1.8rem; margin-bottom: 1.25rem; }
.stack { display: grid; gap: 0.6rem; max-width: 24rem; }
.stack input {
  min-height: 44px; padding: 0.5rem 0.9rem; border: 1px solid var(--line-2); border-radius: var(--r-s);
  background: var(--surface);
}
.flash { padding: 0.75rem 1rem; border-radius: var(--r-s); background: var(--accent-soft); color: var(--ink); }
.flash--error { background: color-mix(in srgb, var(--danger) 14%, var(--surface)); }
.admin-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 1.25rem 1.4rem; display: grid; gap: 0.9rem; }
.admin-panel h2 { font-size: 1.15rem; }
.stat-row { display: flex; flex-wrap: wrap; gap: 0.75rem; list-style: none; }
.stat-row li { display: grid; padding: 0.6rem 1rem; border: 1px solid var(--line); border-radius: var(--r-s); min-width: 7rem; }
.stat-n { font-family: var(--mono); font-size: 1.5rem; font-weight: 600; line-height: 1.2; }
.stat-l { color: var(--muted); font-size: 0.85rem; }
.bad { color: var(--danger); }
.admin-item { border-top: 1px solid var(--line); padding-top: 0.9rem; display: grid; gap: 0.45rem; }
.admin-item h3 { font-size: 1.02rem; line-height: 1.45; }
.admin-item--row { grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 1rem; }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.admin-img { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 0.9rem; align-items: start; }
.admin-thumb {
  display: block; width: 160px; height: auto; aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--r-s);
  background: var(--surface-2);
}
.admin-thumb--none { display: grid; place-items: center; color: var(--muted); font-size: 0.8rem; border: 1px dashed var(--line-2); }
.admin-img-info { display: grid; gap: 0.4rem; }
@media (max-width: 520px) {
  .admin-img { grid-template-columns: 1fr; }
}
.notes { white-space: pre-wrap; font-family: var(--font); font-size: 0.88rem; background: var(--surface-2); padding: 0.75rem 0.9rem; border-radius: var(--r-s); margin: 0.4rem 0 0; }
.caption { display: grid; gap: 0.35rem; max-width: 44rem; }
.caption textarea { width: 100%; padding: 0.6rem 0.8rem; border: 1px solid var(--line-2); border-radius: var(--r-s); background: var(--bg); line-height: 1.6; resize: vertical; }
.caption .btn { justify-self: start; }
details summary { cursor: pointer; color: var(--ink-2); font-size: 0.9rem; }
.table-wrap { overflow-x: auto; }
table.runs { border-collapse: collapse; width: 100%; font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.runs th, .runs td { text-align: left; padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.runs th { color: var(--muted); font-weight: 600; }
.runs td.err { white-space: normal; color: var(--danger); min-width: 12rem; }

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

@media print {
  .site-head, .site-foot, .share, .follow, .article-side, .related, .sidebar { display: none !important; }
  body { background: #fff; color: #000; }
}
