:root {
  --bg: #0a0a0c;
  --bg-rgb: 10,10,12;
  --text-soft: #c6c6cc;
  --card-a: rgba(255,255,255,.065);
  --card-b: rgba(255,255,255,.025);
  --dot-border: #17171a;
  --surface: rgba(255,255,255,.055);
  --surface-strong: rgba(255,255,255,.085);
  --line: rgba(255,255,255,.10);
  --text: #f3f3f5;
  --muted: #92939b;
  --accent: #fff;
  --radius: 22px;
  --max: 1180px;

  /* Background image: put a file in images/ and set it here, e.g.
     --bg-image: url("images/background.jpg");
     --bg-overlay is how dark the layer over the image is (0 = clear, 1 = black). */
  --bg-image: url("images/bg.png");
  --bg-overlay: .72;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background:
    linear-gradient(rgba(var(--bg-rgb),var(--bg-overlay)), rgba(var(--bg-rgb),var(--bg-overlay))),
    var(--bg-image) center / cover no-repeat fixed;
  background-color: var(--bg);
  color: var(--text);
  transition: background-color .35s ease, color .35s ease;
  font-family: "Inter", "Noto Sans Thai", sans-serif;
  line-height: 1.5;
  overflow-x: hidden;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.6'/%3E%3C/svg%3E");
  z-index: 20;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; }

.ambient {
  position: fixed;
  width: 480px;
  height: 480px;
  border-radius: 50%;
  filter: blur(110px);
  opacity: .08;
  pointer-events: none;
}
.ambient-a { background: #7b61ff; top: -250px; left: -180px; }
.ambient-b { background: #00c2ff; right: -260px; top: 38%; }

.topbar {
  width: min(calc(100% - 40px), var(--max));
  margin: 0 auto;
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  z-index: 2;
}
.brand {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .18em;
}
.works-link {
  color: var(--muted);
  font-size: 13px;
  transition: color .2s ease;
}
.works-link:hover { color: var(--text); }
.works-link span { margin-left: 5px; }

main {
  width: min(calc(100% - 40px), var(--max));
  margin: 0 auto;
}

.profile {
  padding: 30px 0 70px;
}
.profile-card {
  position: relative;
  width: min(100%, 560px);
  margin: 0 auto;
  padding: 40px 34px 34px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--card-a), var(--card-b));
  backdrop-filter: blur(18px);
  box-shadow: 0 24px 80px rgba(0,0,0,.22);
}
.profile-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
}
.avatar-wrap {
  flex: 0 0 auto;
  position: relative;
}
.avatar {
  display: block;
  width: 112px;
  height: 112px;
  border-radius: 34px;
  object-fit: cover;
  background: #18181c;
  border: 1px solid rgba(255,255,255,.12);
}
.status-dot {
  position: absolute;
  right: -4px;
  bottom: -4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #666;
  border: 5px solid var(--dot-border);
}
.status-dot.online { background: #23a55a; }
.status-dot.idle { background: #f0a61a; }
.status-dot.dnd { background: #f23f43; }
.status-dot.offline { background: #747f8d; }

.profile-copy {
  min-width: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.eyebrow, .section-kicker {
  font-size: 10px;
  letter-spacing: .17em;
  color: var(--muted);
  font-weight: 700;
}
.dot-separator { margin: 0 6px; opacity: .4; }
h1 {
  margin: 10px 0 0;
  font-size: clamp(30px, 5vw, 44px);
  line-height: 1.2;
  letter-spacing: -.045em;
}
#discord-tag {
  margin: 2px 0 14px;
  color: var(--muted);
  font-size: 13px;
}
.bio {
  margin: 0;
  color: var(--text-soft);
  font-size: 13px;
  max-width: 34ch;
}
.socials {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-top: 22px;
}
.social-icons {
  display: flex;
  justify-content: center;
  gap: 10px;
}
.socials a {
  width: 42px;
  height: 42px;
  padding: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text-soft);
  font-size: 11px;
  transition: background .2s, color .2s, transform .2s;
}
.socials a img {
  width: 24px;
  height: 24px;
  display: block;
  object-fit: contain;
  border-radius: 6px;
}
.socials a.social-text {
  width: auto;
  height: 36px;
  min-width: 120px;
  padding: 0 18px;
  border-radius: 999px;
}
.socials a:hover {
  background: var(--surface-strong);
  color: var(--text);
  transform: translateY(-1px);
}

.activity {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: left;
}
.activity.hidden { display: none; }
.activity-icon {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: rgba(30,215,96,.12);
  color: #1ed760;
}
.activity-copy { display: grid; gap: 1px; }
.activity-label { color: var(--muted); font-size: 9px; letter-spacing: .14em; font-weight: 700; }
.activity-copy strong { font-size: 12px; }
.activity-copy small { color: var(--muted); font-size: 11px; }

.works-section { padding: 0 0 170px; }
.section-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-bottom: 30px;
  text-align: center;
}
.section-head h2 {
  margin: 6px 0 0;
  font-size: clamp(24px, 4vw, 34px);
  letter-spacing: -.04em;
}
.work-count { color: var(--muted); font-size: 11px; }

.gallery {
  --work-ratio: 4 / 5; /* change to 1 / 1 for squares, 3 / 4 for taller tiles */
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.work {
  aspect-ratio: var(--work-ratio);
  margin: 0;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  border-radius: 15px;
  background: #151518;
  border: 1px solid rgba(255,255,255,.07);
}
.work img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .5s cubic-bezier(.2,.7,.2,1), filter .5s;
}
.work:hover img {
  transform: scale(1.025);
  filter: brightness(.72);
}
.work-info {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 38px 15px 15px;
  background: linear-gradient(transparent, rgba(0,0,0,.72));
  opacity: 0;
  transform: translateY(5px);
  transition: .25s ease;
}
.work:hover .work-info { opacity: 1; transform: translateY(0); }
.work-title { display: block; font-size: 12px; font-weight: 600; }
.work-meta { display: block; color: #bbb; font-size: 10px; margin-top: 2px; }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 50px;
  background: rgba(5,5,7,.92);
  backdrop-filter: blur(15px);
}
.lightbox.open { display: flex; }
.lightbox figure {
  margin: 0;
  max-width: min(1000px, 90vw);
  max-height: 90vh;
  text-align: center;
}
.lightbox img {
  max-width: 100%;
  max-height: 78vh;
  object-fit: contain;
  border-radius: 10px;
}
.lightbox figcaption {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
  font-size: 12px;
}
.lightbox figcaption span { color: var(--muted); }
.lightbox-close, .lightbox-arrow {
  position: fixed;
  border: 0;
  color: #fff;
  background: rgba(255,255,255,.08);
  width: 42px; height: 42px;
  border-radius: 50%;
  cursor: pointer;
  transition: background .2s;
}
.lightbox-close { top: 22px; right: 22px; font-size: 25px; }
.lightbox-arrow { top: 50%; transform: translateY(-50%); font-size: 30px; }
.lightbox-close:hover, .lightbox-arrow:hover { background: rgba(255,255,255,.15); }
.lightbox-arrow.prev { left: 22px; }
.lightbox-arrow.next { right: 22px; }

/* ---------- Floating Spotify player ---------- */
.sp-card {
  position: fixed;
  z-index: 40;
  left: 20px;
  bottom: 20px;
  width: min(420px, calc(100vw - 40px));
  display: flex;
  gap: 16px;
  padding: 14px;
  border-radius: 26px;
  background: #171717;
  color: #fff;
  box-shadow: 0 18px 55px rgba(0,0,0,.45), 0 0 0 1px rgba(255,255,255,.06);
}
.sp-cover {
  flex: 0 0 auto;
  width: 104px;
  align-self: flex-start;
  aspect-ratio: 1;
  border-radius: 14px;
  overflow: hidden;
  background: #3b3b3b;
  display: grid;
  place-items: center;
}
.sp-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sp-cover img[hidden] { display: none; }
.sp-logo { width: 68%; height: 68%; }
.sp-card.has-cover .sp-logo { display: none; }

.sp-body { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: space-between; }
.sp-top { display: flex; align-items: flex-start; gap: 10px; }
.sp-text { flex: 1; min-width: 0; }
.sp-title { font-size: 17px; font-weight: 700; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-artist { font-size: 13px; color: #d4d4d4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

button.sp-icon-btn, button.sp-main {
  border: 0; padding: 0; background: none; font: inherit; cursor: pointer;
}
.sp-icon-btn { display: grid; place-items: center; width: 28px; height: 28px; color: #fff; flex: 0 0 auto; transition: opacity .15s, transform .15s; }
.sp-icon-btn svg { width: 100%; height: 100%; }
.sp-add { width: 26px; height: 26px; }
.sp-add:hover, button.sp-icon-btn:hover { opacity: .75; }
.sp-dim { width: 22px; height: 22px; color: #e8e8e8; }
.sp-skip { width: 24px; height: 24px; }
.sp-static { opacity: .9; }
#sp-shuffle[aria-pressed="true"] { color: #1ed760; }

/* mini play + minimize buttons */
.sp-collapse { width: 24px; height: 24px; opacity: .8; }
.sp-collapse svg { transition: transform .25s ease; }
.sp-mini-play { display: none; width: 30px; height: 30px; }
.sp-mini-play svg { width: 22px; height: 22px; }
.sp-mini-play .ic-pause { display: none; }
.sp-card.is-playing .sp-mini-play .ic-pause { display: block; }
.sp-card.is-playing .sp-mini-play .ic-play { display: none; }

/* minimized state: a slim bar with cover, title, play and expand */
.sp-card { transition: width .25s ease, padding .25s ease, border-radius .25s ease; }
.sp-card.is-collapsed {
  width: min(300px, calc(100vw - 40px));
  padding: 10px 12px 10px 10px;
  gap: 12px;
  align-items: center;
  border-radius: 20px;
}
.sp-card.is-collapsed .sp-cover { width: 46px; align-self: center; border-radius: 10px; }
.sp-card.is-collapsed .sp-progress,
.sp-card.is-collapsed .sp-controls,
.sp-card.is-collapsed .sp-add { display: none; }
.sp-card.is-collapsed .sp-mini-play { display: grid; }
.sp-card.is-collapsed .sp-top { align-items: center; }
.sp-card.is-collapsed .sp-title { font-size: 14px; }
.sp-card.is-collapsed .sp-artist { font-size: 12px; }
.sp-card.is-collapsed .sp-collapse svg { transform: rotate(180deg); }

.sp-progress { margin-top: 2px; }
.sp-bar-hit { padding: 6px 0; cursor: pointer; }
.sp-bar { height: 4px; border-radius: 4px; background: #5c5c5c; overflow: hidden; }
.sp-fill { height: 100%; width: 0; background: #fff; border-radius: 4px; transition: width .25s linear; }
.sp-times { display: flex; justify-content: space-between; margin-top: 0; font-size: 10.5px; color: #cfcfcf; font-variant-numeric: tabular-nums; }

.sp-controls { display: flex; align-items: center; justify-content: space-between; margin-top: 2px; }
.sp-main {
  width: 50px; height: 50px; border-radius: 50%;
  background: #fff; color: #171717;
  display: grid; place-items: center;
  transition: transform .15s;
}
button.sp-main { background: #fff; }
.sp-main:hover { transform: scale(1.06); }
.sp-main svg { width: 24px; height: 24px; }
.sp-main .ic-pause { display: none; }
.sp-main .ic-play { margin-left: 2px; }
.sp-card.is-playing .sp-main .ic-pause { display: block; }
.sp-card.is-playing .sp-main .ic-play { display: none; }

/* Keep the hidden engine INSIDE the viewport (browsers/Spotify may refuse to play from an offscreen or display:none iframe). */
.sp-embed-host { position: fixed; right: 0; bottom: 0; width: 300px; height: 152px; opacity: 0.01; pointer-events: none; z-index: -1; overflow: hidden; }
.sp-embed-host iframe { width: 300px; height: 152px; border: 0; }

footer {
  width: min(calc(100% - 40px), var(--max));
  margin: 0 auto;
  padding: 25px 0 45px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 10px;
}
footer a:hover { color: var(--text); }

@media (max-width: 900px) and (min-width: 701px) {
  .gallery { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 700px) {
  body { background-attachment: scroll, scroll; }
  .topbar, main, footer { width: min(calc(100% - 24px), var(--max)); }
  .topbar { height: 64px; }
  .profile { padding: 22px 0 48px; }
  .profile-card { padding: 24px; }
  .profile-card { padding: 32px 22px 26px; }
  .avatar { width: 96px; height: 96px; border-radius: 30px; }
  .status-dot { width: 18px; height: 18px; border-width: 4px; }
  h1 { font-size: 31px; }
  .bio { font-size: 12px; }
  .gallery { grid-template-columns: repeat(2, 1fr); gap: 9px; }
  .work { border-radius: 11px; }
  .work-info { display: none; }
  .lightbox { padding: 25px; }
  .lightbox-arrow { width: 36px; height: 36px; }
  .lightbox-arrow.prev { left: 10px; }
  .lightbox-arrow.next { right: 10px; }
  .sp-card.is-collapsed { width: min(300px, calc(100vw - 24px)); }
  .sp-card.is-collapsed .sp-cover { width: 46px; }
  .sp-card { left: 12px; bottom: 12px; width: calc(100vw - 24px); gap: 12px; padding: 12px; border-radius: 22px; }
  .sp-cover { width: 88px; }
  .sp-title { font-size: 15px; }
  .sp-main { width: 44px; height: 44px; }
}

/* ---------- Day / Night toggle ---------- */
.top-actions { display: flex; align-items: center; gap: 16px; }
.theme-toggle {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  padding: 0; cursor: pointer;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 50%;
  transition: background .2s, transform .3s;
}
.theme-toggle:hover { background: var(--surface-strong); transform: rotate(18deg); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .i-moon { display: none; }
:root[data-theme="light"] .theme-toggle .i-sun { display: none; }
:root[data-theme="light"] .theme-toggle .i-moon { display: block; }

:root[data-theme="light"] {
  --bg: #f3f3f6;
  --bg-rgb: 243,243,246;
  --surface: rgba(0,0,0,.045);
  --surface-strong: rgba(0,0,0,.08);
  --line: rgba(0,0,0,.11);
  --text: #16161a;
  --text-soft: #44454d;
  --muted: #6b6c75;
  --accent: #111;
  --card-a: rgba(255,255,255,.85);
  --card-b: rgba(255,255,255,.55);
  --dot-border: #f3f3f6;
}
:root[data-theme="light"] .profile-card { box-shadow: 0 24px 70px rgba(30,30,60,.12); }
:root[data-theme="light"] .socials a:not(.social-text) { background: #18181c; border-color: transparent; }

/* ---------- Visitor counter ---------- */
.view-count {
  position: absolute; top: 16px; left: 18px;
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums;
}
.view-count[hidden] { display: none; }
.view-count svg { width: 15px; height: 15px; }
.view-count b { font-weight: 600; color: var(--text-soft); }
