:root {
  --bg: #ffffff;
  --bg-alt: #f5f6fb;
  --ink: #0f172a;
  --muted: #55607a;
  --line: #e4e7f0;
  --card: #ffffff;
  --brand: #4f46e5;
  --brand-2: #a21caf;
  --brand-3: #2563eb;
  --grad: linear-gradient(120deg, var(--brand-3), var(--brand) 45%, var(--brand-2));
  --radius: 18px;
  --shadow: 0 10px 30px -12px rgba(30, 27, 75, .18);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1020;
    --bg-alt: #111831;
    --ink: #e8ebf5;
    --muted: #9aa3bd;
    --line: #232c4a;
    --card: #141c36;
    --shadow: 0 10px 30px -12px rgba(0, 0, 0, .6);
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0;
  font-family: 'IBM Plex Sans Thai', system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; }
a { color: inherit; }
h1, h2, h3 { line-height: 1.3; margin: 0; }
.wrap { width: min(1140px, 100% - 32px); margin-inline: auto; }

/* ปุ่ม */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 12px 26px; border-radius: 999px; border: 0;
  background: var(--grad); color: #fff; font-weight: 600; text-decoration: none;
  box-shadow: 0 8px 20px -8px rgba(79, 70, 229, .7);
  transition: transform .15s, box-shadow .15s;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 12px 24px -8px rgba(79, 70, 229, .8); }
.btn-sm { padding: 8px 18px; font-size: .95rem; }
.btn-ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--line); box-shadow: none; }
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); box-shadow: none; }

/* แถบเมนู */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
.nav.scrolled { border-color: var(--line); }
.nav-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.15rem; text-decoration: none; }
.menu { display: flex; align-items: center; gap: 28px; }
.menu a:not(.btn) { text-decoration: none; color: var(--muted); font-weight: 500; }
.menu a:not(.btn):hover { color: var(--ink); }
.nav-toggle { display: none; background: none; border: 0; padding: 8px; cursor: pointer; }
.nav-toggle span { display: block; width: 22px; height: 2px; margin: 5px 0; background: var(--ink); border-radius: 2px; transition: .2s; }

@media (max-width: 820px) {
  .nav-toggle { display: block; }
  .menu {
    position: absolute; top: 64px; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    padding: 8px 16px 16px; background: var(--bg); border-bottom: 1px solid var(--line);
    display: none;
  }
  .nav.open .menu { display: flex; }
  .menu a:not(.btn) { padding: 12px 4px; border-bottom: 1px solid var(--line); }
  .menu .btn { margin-top: 12px; }
  .nav.open .nav-toggle span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .nav.open .nav-toggle span:nth-child(2) { opacity: 0; }
  .nav.open .nav-toggle span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
}

/* ส่วนหัว */
.hero { position: relative; overflow: hidden; padding: 72px 0 88px; }
.hero::before {
  content: ''; position: absolute; inset: -40% -10% auto auto; width: 70vw; height: 70vw;
  background: radial-gradient(closest-side, rgba(79, 70, 229, .22), transparent 70%);
  pointer-events: none;
}
.hero::after {
  content: ''; position: absolute; inset: auto auto -30% -15%; width: 50vw; height: 50vw;
  background: radial-gradient(closest-side, rgba(162, 28, 175, .16), transparent 70%);
  pointer-events: none;
}
.hero-inner { position: relative; display: grid; grid-template-columns: 1.1fr 1fr; gap: 48px; align-items: center; }
.eyebrow { color: var(--brand); font-weight: 600; margin: 0 0 8px; }
.hero h1 { font-size: clamp(2.3rem, 5.5vw, 3.8rem); font-weight: 700; }
.grad { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lead { font-size: 1.15rem; color: var(--muted); margin: 18px 0 28px; }
.cta { display: flex; flex-wrap: wrap; gap: 12px; }
.stats { list-style: none; padding: 0; margin: 40px 0 0; display: flex; flex-wrap: wrap; gap: 32px; }
.stats strong { display: block; font-size: 1.8rem; line-height: 1.2; }
.stats span { color: var(--muted); font-size: .92rem; }

.hero-art { position: relative; min-height: 340px; }
.win {
  position: relative; z-index: 1; margin: 30px 20px;
  background: #0f1530; color: #cdd5f3; border-radius: var(--radius);
  box-shadow: 0 30px 60px -20px rgba(30, 27, 75, .55);
  border: 1px solid rgba(255, 255, 255, .08); overflow: hidden;
}
.win-bar { display: flex; gap: 6px; padding: 12px 14px; background: rgba(255, 255, 255, .04); }
.win-bar i { width: 11px; height: 11px; border-radius: 50%; background: #ff5f57; }
.win-bar i:nth-child(2) { background: #febc2e; }
.win-bar i:nth-child(3) { background: #28c840; }
.win pre { margin: 0; padding: 20px 22px 26px; font: 500 .92rem/1.75 ui-monospace, Consolas, monospace; overflow-x: auto; }
.win b { color: #c4b5fd; font-weight: 500; }
.win s { color: #86efac; text-decoration: none; }
.win u { color: #fbbf24; text-decoration: none; }
.win em { color: #64748b; font-style: normal; }
.chip {
  position: absolute; z-index: 2; padding: 8px 16px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow);
  font-weight: 600; font-size: .9rem; animation: float 6s ease-in-out infinite;
}
.chip-a { top: 0; right: 0; }
.chip-b { bottom: 10px; left: 0; animation-delay: -2s; }
.chip-c { bottom: -8px; right: 24px; animation-delay: -4s; }
@keyframes float { 50% { transform: translateY(-8px); } }

@media (max-width: 900px) {
  .hero { padding: 40px 0 56px; }
  .hero-inner { grid-template-columns: 1fr; }
  .hero-art { min-height: 0; }
  .win { margin: 24px 0; }
}

/* หมวดเนื้อหา */
.section { padding: 88px 0; }
.section.alt { background: var(--bg-alt); }
.title { text-align: center; font-size: clamp(1.7rem, 3.4vw, 2.3rem); }
.sub { text-align: center; color: var(--muted); max-width: 640px; margin: 12px auto 44px; }
.left { text-align: left; margin-left: 0; }
.grid { display: grid; gap: 22px; }
.g3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 900px) { .g3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) {
  .g3 { grid-template-columns: 1fr; }
  .section { padding: 64px 0; }
}

.card, .feat, .work {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 28px; transition: transform .2s, box-shadow .2s, border-color .2s;
}
.card:hover, .feat:hover, .work:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: transparent; }
.card h3, .feat h3, .work h3 { font-size: 1.15rem; margin: 14px 0 8px; }
.card p, .feat p, .work p { color: var(--muted); margin: 0; }
.ico {
  width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; background: var(--grad);
}
.ico svg { width: 26px; height: 26px; fill: none; stroke: #fff; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.num { font-weight: 700; font-size: 1.05rem; color: var(--brand); }

/* ทักษะ */
.skill-groups { display: grid; gap: 36px; }
.skill-group h3 { font-size: 1.05rem; margin-bottom: 14px; color: var(--muted); }
.skill-group ul {
  list-style: none; padding: 0; margin: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 12px;
}
.skill-group li {
  display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center;
  padding: 18px 8px 14px; border-radius: 14px; font-size: .88rem; font-weight: 500; line-height: 1.3;
  background: var(--card); border: 1px solid var(--line);
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.skill-group li:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: transparent; }
/* พื้นขาวเสมอ ให้โลโก้สีเข้มอย่าง Next.js และ Rust ยังเห็นในโหมดมืด */
.logo {
  width: 56px; height: 56px; border-radius: 12px; display: grid; place-items: center;
  background: #fff; border: 1px solid #eef0f5;
}
.logo img { width: 36px; height: 36px; object-fit: contain; }
.logo b { font-size: 1.4rem; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
@media (max-width: 600px) { .skill-group ul { grid-template-columns: repeat(3, 1fr); } }

/* ผลงาน */
.filters { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-bottom: 32px; }
.filters button {
  font: inherit; font-weight: 500; padding: 8px 18px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--muted);
}
.filters button.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.work[hidden] { display: none; }
.tag {
  display: inline-block; font-size: .8rem; font-weight: 600; padding: 3px 12px; border-radius: 999px;
  background: var(--bg-alt); color: var(--muted); border: 1px solid var(--line);
}
.tag-live { background: rgba(34, 197, 94, .12); color: #15803d; border-color: rgba(34, 197, 94, .3); }
@media (prefers-color-scheme: dark) { .tag-live { color: #4ade80; } }

/* ติดต่อ */
.contact { background: var(--grad); color: #fff; }
.contact .sub { color: rgba(255, 255, 255, .85); }
.contact-inner { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; align-items: center; }
.person { display: flex; align-items: center; gap: 14px; }
.person span { display: block; opacity: .8; }
.avatar {
  width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255, 255, 255, .2); font-weight: 700; font-size: 1.1rem;
}
.channels { display: grid; gap: 12px; }
.ch {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 18px 22px; border-radius: 14px; text-decoration: none;
  background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .25);
  transition: background .15s, transform .15s;
}
.ch:hover { background: rgba(255, 255, 255, .22); transform: translateX(4px); }
.ch-k { opacity: .8; }
.ch-v { font-weight: 600; word-break: break-all; text-align: right; }
.ch-line { background: #06c755; border-color: #06c755; }
.ch-line:hover { background: #05b34c; }
@media (max-width: 800px) { .contact-inner { grid-template-columns: 1fr; } }

/* ท้ายหน้า */
.foot { padding: 40px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: .93rem; }
.foot-inner { display: grid; grid-template-columns: auto 1fr auto; gap: 24px; align-items: center; }
.foot .brand { color: var(--ink); }
.foot p { margin: 0; }
@media (max-width: 800px) { .foot-inner { grid-template-columns: 1fr; } }

/* เลื่อนขึ้นตอนเห็น */
.reveal { opacity: 0; transform: translateY(16px); transition: opacity .6s, transform .6s; }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .chip { animation: none; }
}
