:root {
      --primary: #1976d2;
      --primary-dark: #1565c0;
      --primary-light: #42a5f5;
      --primary-contrast: #ffffff;
    }

    html[data-theme="light"] {
      --bg: #f4f6f8;
      --paper: #ffffff;
      --text-primary: rgba(0, 0, 0, 0.87);
      --text-secondary: rgba(0, 0, 0, 0.6);
      --divider: rgba(0, 0, 0, 0.12);
      --elevation-1: 0 2px 1px -1px rgba(0, 0, 0, .2), 0 1px 1px 0 rgba(0, 0, 0, .14), 0 1px 3px 0 rgba(0, 0, 0, .12);
      --elevation-2: 0 3px 3px -2px rgba(0, 0, 0, .2), 0 3px 4px 0 rgba(0, 0, 0, .14), 0 1px 8px 0 rgba(0, 0, 0, .12);
      --elevation-8: 0 5px 5px -3px rgba(0, 0, 0, .2), 0 8px 10px 1px rgba(0, 0, 0, .14), 0 3px 14px 2px rgba(0, 0, 0, .12);
      --appbar-bg: rgba(255, 255, 255, 0.85);
      --hero-glow: rgba(25, 118, 210, 0.10);
      --preview-bg: #eef3f8;
    }

    html[data-theme="dark"] {
      --bg: #121212;
      --paper: #1e1e1e;
      --text-primary: rgba(255, 255, 255, 0.92);
      --text-secondary: rgba(255, 255, 255, 0.62);
      --divider: rgba(255, 255, 255, 0.12);
      --elevation-1: 0 2px 1px -1px rgba(0, 0, 0, .4), 0 1px 1px 0 rgba(0, 0, 0, .28), 0 1px 3px 0 rgba(0, 0, 0, .24);
      --elevation-2: 0 3px 3px -2px rgba(0, 0, 0, .4), 0 3px 4px 0 rgba(0, 0, 0, .28), 0 1px 8px 0 rgba(0, 0, 0, .24);
      --elevation-8: 0 5px 5px -3px rgba(0, 0, 0, .4), 0 8px 10px 1px rgba(0, 0, 0, .28), 0 3px 14px 2px rgba(0, 0, 0, .24);
      --appbar-bg: rgba(30, 30, 30, 0.85);
      --hero-glow: rgba(66, 165, 245, 0.14);
      --preview-bg: #2a2a2a;
    }

    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }

    html {
      scroll-behavior: smooth;
    }

    body {
      font-family: 'Prompt', sans-serif;
      background: var(--bg);
      color: var(--text-primary);
      line-height: 1.6;
      transition: background-color .3s ease, color .3s ease;
      -webkit-font-smoothing: antialiased;
    }

    @media (prefers-reduced-motion: reduce) {
      html {
        scroll-behavior: auto;
      }

      * {
        transition: none !important;
      }
    }

    .container {
      max-width: 1120px;
      margin: 0 auto;
      padding: 0 24px;
    }

    /* ---------- AppBar ---------- */
    .appbar {
      position: sticky;
      top: 0;
      z-index: 100;
      background: var(--appbar-bg);
      backdrop-filter: blur(12px);
      -webkit-backdrop-filter: blur(12px);
      box-shadow: var(--elevation-2);
      transition: background-color .3s ease;
    }

    .appbar .container {
      display: flex;
      align-items: center;
      justify-content: space-between;
      height: 64px;
    }

    .brand {
      display: flex;
      align-items: center;
      gap: 10px;
      font-weight: 600;
      font-size: 1.15rem;
      text-decoration: none;
      color: inherit;
    }

    .brand-mark {
      width: 34px;
      height: 34px;
      border-radius: 8px;
      background: linear-gradient(135deg, var(--primary-light), var(--primary-dark));
      display: grid;
      place-items: center;
      color: #fff;
      font-weight: 700;
      font-size: .95rem;
      box-shadow: var(--elevation-1);
    }

    .brand-logo {
      height: 40px;
      width: auto;
      display: block;
    }

    .footer-logo {
      height: 38px;
      width: auto;
      display: block;
    }

    html[data-theme="light"] .logo-dark {
      display: none;
    }

    html[data-theme="dark"] .logo-light {
      display: none;
    }

    .appbar-actions {
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .nav-links {
      display: flex;
      gap: 4px;
    }

    .nav-links a {
      color: var(--text-secondary);
      text-decoration: none;
      font-weight: 500;
      font-size: .95rem;
      padding: 8px 14px;
      border-radius: 8px;
      transition: background-color .2s, color .2s;
    }

    .nav-links a:hover {
      background: var(--hero-glow);
      color: var(--primary);
    }

    .nav-links a.active {
      color: var(--primary);
      background: var(--hero-glow);
    }

    .icon-btn {
      width: 44px;
      height: 44px;
      border-radius: 50%;
      border: none;
      cursor: pointer;
      background: transparent;
      color: var(--text-primary);
      display: grid;
      place-items: center;
      transition: background-color .2s;
    }

    .icon-btn:hover {
      background: var(--hero-glow);
    }

    .icon-btn:focus-visible {
      outline: 2px solid var(--primary);
      outline-offset: 2px;
    }

    .icon-btn svg {
      width: 24px;
      height: 24px;
    }

    html[data-theme="light"] .icon-moon {
      display: block;
    }

    html[data-theme="light"] .icon-sun {
      display: none;
    }

    html[data-theme="dark"] .icon-moon {
      display: none;
    }

    html[data-theme="dark"] .icon-sun {
      display: block;
    }

    /* ---------- Buttons ---------- */
    .btn {
      font-family: inherit;
      font-weight: 500;
      font-size: .95rem;
      letter-spacing: .02em;
      border-radius: 8px;
      cursor: pointer;
      padding: 11px 24px;
      border: none;
      text-decoration: none;
      display: inline-flex;
      align-items: center;
      gap: 8px;
      transition: background-color .2s, box-shadow .2s, transform .05s;
    }

    .btn:active {
      transform: translateY(1px);
    }

    .btn:focus-visible {
      outline: 2px solid var(--primary);
      outline-offset: 2px;
    }

    .btn-contained {
      background: var(--primary);
      color: var(--primary-contrast);
      box-shadow: var(--elevation-2);
    }

    .btn-contained:hover {
      background: var(--primary-dark);
      box-shadow: var(--elevation-8);
    }

    .btn-outlined {
      background: transparent;
      color: var(--primary);
      border: 1px solid var(--primary);
    }

    .btn-outlined:hover {
      background: var(--hero-glow);
    }

    .btn-lg {
      padding: 14px 32px;
      font-size: 1rem;
    }

    .btn-sm {
      padding: 8px 16px;
      font-size: .88rem;
    }

    /* ---------- Page header ---------- */
    .page-head {
      position: relative;
      padding: 72px 0 8px;
      overflow: hidden;
      text-align: center;
    }

    .page-head::before {
      content: '';
      position: absolute;
      top: -140px;
      left: 50%;
      transform: translateX(-50%);
      width: 560px;
      height: 460px;
      border-radius: 50%;
      background: radial-gradient(circle, var(--hero-glow) 0%, transparent 70%);
      pointer-events: none;
    }

    .page-head .inner {
      position: relative;
      max-width: 680px;
      margin: 0 auto;
    }

    .eyebrow {
      color: var(--primary);
      font-weight: 600;
      font-size: .9rem;
      letter-spacing: .08em;
      text-transform: uppercase;
      margin-bottom: 10px;
    }

    .page-head h1 {
      font-size: clamp(2rem, 4.5vw, 3rem);
      font-weight: 700;
      line-height: 1.2;
      margin-bottom: 16px;
      letter-spacing: -0.01em;
    }

    .page-head h1 .accent {
      color: var(--primary);
    }

    .page-head p {
      font-size: clamp(1.02rem, 2vw, 1.18rem);
      color: var(--text-secondary);
      font-weight: 300;
    }

    /* ---------- Portfolio grid ---------- */
    .portfolio {
      padding: 48px 0 72px;
    }

    .grid {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 28px;
    }

    .work {
      background: var(--paper);
      border: 1px solid var(--divider);
      border-radius: 16px;
      overflow: hidden;
      box-shadow: var(--elevation-1);
      transition: box-shadow .25s, transform .25s;
      display: flex;
      flex-direction: column;
    }

    .work:hover {
      box-shadow: var(--elevation-8);
      transform: translateY(-5px);
    }

    /* Live preview thumbnail (iframe scaled down) */
    .work-preview {
      position: relative;
      aspect-ratio: 16 / 10;
      overflow: hidden;
      background: var(--preview-bg);
      border-bottom: 1px solid var(--divider);
    }

    .work-preview iframe {
      position: absolute;
      top: 0;
      left: 0;
      width: 1280px;
      height: 800px;
      transform: scale(.273);
      transform-origin: top left;
      border: 0;
      pointer-events: none;
      background: #fff;
    }

    /* overlay ทำให้ทั้งรูปกดได้ + ขึ้นป้ายตอน hover */
    .work-preview .overlay {
      position: absolute;
      inset: 0;
      z-index: 2;
      display: grid;
      place-items: center;
      background: linear-gradient(180deg, rgba(25, 118, 210, 0) 40%, rgba(21, 101, 192, .55) 100%);
      opacity: 0;
      transition: opacity .25s;
      text-decoration: none;
    }

    .work-preview .overlay span {
      background: #fff;
      color: var(--primary);
      font-weight: 500;
      font-size: .9rem;
      padding: 9px 18px;
      border-radius: 100px;
      box-shadow: var(--elevation-2);
      display: inline-flex;
      align-items: center;
      gap: 6px;
      transform: translateY(8px);
      transition: transform .25s;
    }

    .work-preview .overlay span svg {
      width: 16px;
      height: 16px;
    }

    .work:hover .overlay {
      opacity: 1;
    }

    .work:hover .overlay span {
      transform: translateY(0);
    }

    .work-body {
      padding: 20px 22px 22px;
      display: flex;
      flex-direction: column;
      flex-grow: 1;
    }

    .work-tags {
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
      margin-bottom: 12px;
    }

    .work-tags span {
      background: var(--hero-glow);
      color: var(--primary);
      font-size: .74rem;
      font-weight: 500;
      padding: 3px 10px;
      border-radius: 100px;
    }

    .work-body h3 {
      font-size: 1.15rem;
      font-weight: 600;
      margin-bottom: 6px;
    }

    .work-body p {
      color: var(--text-secondary);
      font-weight: 300;
      font-size: .93rem;
      flex-grow: 1;
      margin-bottom: 16px;
    }

    .work-actions {
      display: flex;
      gap: 10px;
    }

    /* Placeholder card (ยังไม่ใส่ตัวอย่าง) */
    .work.placeholder .work-preview {
      display: grid;
      place-items: center;
      color: var(--text-secondary);
    }

    .work.placeholder .work-preview .ph {
      text-align: center;
      font-weight: 300;
      font-size: .9rem;
      padding: 0 20px;
    }

    .work.placeholder .work-preview .ph svg {
      width: 40px;
      height: 40px;
      opacity: .5;
      margin-bottom: 8px;
    }

    /* ---------- CTA band ---------- */
    section.cta {
      padding: 8px 0 80px;
    }

    .cta-band {
      background: linear-gradient(135deg, var(--primary), var(--primary-dark));
      border-radius: 24px;
      padding: 52px 40px;
      text-align: center;
      color: #fff;
      box-shadow: var(--elevation-8);
    }

    .cta-band h2 {
      font-size: clamp(1.5rem, 3.5vw, 2.1rem);
      font-weight: 600;
      margin-bottom: 12px;
    }

    .cta-band p {
      opacity: .92;
      font-weight: 300;
      margin-bottom: 26px;
    }

    .cta-actions {
      display: flex;
      flex-wrap: wrap;
      gap: 14px;
      justify-content: center;
    }

    .cta-band .btn-contained {
      background: #fff;
      color: var(--primary);
    }

    .cta-band .btn-contained:hover {
      background: rgba(255, 255, 255, .9);
    }

    /* ---------- Footer ---------- */
    footer {
      padding: 48px 0 32px;
      border-top: 1px solid var(--divider);
    }

    .footer-inner {
      display: flex;
      flex-wrap: wrap;
      justify-content: space-between;
      gap: 24px;
      align-items: center;
    }

    footer .brand {
      font-size: 1.05rem;
    }

    .footer-contact {
      display: flex;
      flex-wrap: wrap;
      gap: 12px;
      align-items: center;
    }

    .footer-contact a {
      width: 44px;
      height: 44px;
      border-radius: 50%;
      display: grid;
      place-items: center;
      background: var(--hero-glow);
      color: var(--primary);
      text-decoration: none;
      transition: background-color .2s, color .2s, transform .15s, box-shadow .2s;
    }

    .footer-contact a:hover {
      background: var(--primary);
      color: #fff;
      transform: translateY(-3px);
      box-shadow: var(--elevation-2);
    }

    .footer-contact a:focus-visible {
      outline: 2px solid var(--primary);
      outline-offset: 2px;
    }

    .footer-contact svg {
      width: 22px;
      height: 22px;
    }

    .copyright {
      text-align: center;
      color: var(--text-secondary);
      font-size: .85rem;
      font-weight: 300;
      margin-top: 28px;
    }

    /* ---------- Mobile menu ---------- */
    .nav-toggle {
      display: none;
      width: 44px;
      height: 44px;
      border-radius: 50%;
      border: none;
      cursor: pointer;
      background: transparent;
      color: var(--text-primary);
      place-items: center;
      transition: background-color .2s;
    }

    .nav-toggle:hover {
      background: var(--hero-glow);
    }

    .nav-toggle:focus-visible {
      outline: 2px solid var(--primary);
      outline-offset: 2px;
    }

    .nav-toggle svg {
      width: 26px;
      height: 26px;
    }

    .mobile-menu {
      display: none;
      flex-direction: column;
      border-top: 1px solid var(--divider);
    }

    .mobile-menu a {
      padding: 15px 24px;
      text-decoration: none;
      color: var(--text-primary);
      font-weight: 500;
      border-bottom: 1px solid var(--divider);
      transition: background-color .2s, color .2s;
    }

    .mobile-menu a:hover,
    .mobile-menu a.active {
      background: var(--hero-glow);
      color: var(--primary);
    }

    /* ---------- Responsive ---------- */
    @media (max-width: 900px) {
      .grid {
        grid-template-columns: repeat(2, 1fr);
      }

      .work-preview iframe {
        transform: scale(.36);
      }

      .nav-links {
        display: none;
      }

      .nav-toggle {
        display: grid;
      }

      .mobile-menu.open {
        display: flex;
      }
    }

    @media (max-width: 560px) {
      .grid {
        grid-template-columns: 1fr;
      }

      .work-preview iframe {
        transform: scale(.6);
      }

      .cta-band {
        padding: 40px 24px;
      }
    }
