/* ============================================================
   ChainGPT-inspired visual upgrade — SSRobotics edition
   Keeps the orange–gold brand. Loads AFTER style.css/fix.css.
   ============================================================ */

/* ---------- 0. Declutter: retire legacy background layers ---------- */
/* One coherent background system (glow + grid below) instead of
   five stacked legacy effects fighting each other. */
#mujoco-stream,
#bg-fallback-canvas,
.hologram-overlay,
#particle-canvas {
  display: none !important;
}
.flashlight-zone {
  mask-image: none !important;
  -webkit-mask-image: none !important;
}

/* ---------- 0a1. Unified ambient background — identical on EVERY page ---------- */
/* The old code injected orange "energy lines" into only 3 sections, so pages
   looked mismatched. One fixed ambient layer now serves the whole site. */
.cyber-energy-bg { display: none !important; }

.cg-ambient {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  overflow: hidden;
}
.cg-ambient i {
  position: absolute;
  display: block;
  border-radius: 50%;
  filter: blur(70px);
  will-change: transform;
}
.cg-ambient i:nth-child(1) {
  width: 520px; height: 520px;
  left: -140px; top: 8%;
  background: radial-gradient(circle, rgba(255, 109, 0, 0.16), transparent 65%);
  animation: cg-drift-a 34s ease-in-out infinite alternate;
}
.cg-ambient i:nth-child(2) {
  width: 640px; height: 640px;
  right: -180px; top: 34%;
  background: radial-gradient(circle, rgba(255, 170, 0, 0.11), transparent 65%);
  animation: cg-drift-b 42s ease-in-out infinite alternate;
}
.cg-ambient i:nth-child(3) {
  width: 460px; height: 460px;
  left: 38%; bottom: -160px;
  background: radial-gradient(circle, rgba(255, 130, 20, 0.12), transparent 65%);
  animation: cg-drift-c 38s ease-in-out infinite alternate;
}
@keyframes cg-drift-a { to { transform: translate(120px, 90px) scale(1.15); } }
@keyframes cg-drift-b { to { transform: translate(-140px, -70px) scale(0.9); } }
@keyframes cg-drift-c { to { transform: translate(-90px, -110px) scale(1.1); } }

[data-theme="light"] .cg-ambient i { opacity: 0.55; }

@media (prefers-reduced-motion: reduce) {
  .cg-ambient i { animation: none; }
}

/* Hero used to have its own tint layer — clear it so ALL pages share
   exactly the same background system */
.hero-overlay,
[data-theme="dark"] .hero-overlay,
[data-theme="light"] .hero-overlay { background: transparent !important; }

/* ---------- 0a2. Retire the custom cursor + orange trail dots ---------- */
.custom-cursor, .custom-cursor-glow, .cursor-trail-dot { display: none !important; }
body.custom-cursor-active * { cursor: auto !important; }

/* ---------- 0a3. Tech Stack grid: uniform, calm, aligned ---------- */
.tech-badge {
  animation: none !important;
  min-width: 112px;
  max-width: 132px;
  justify-content: flex-start;
}
.tech-badge img { width: 40px !important; height: 40px !important; }
.tech-badge .tech-emoji { font-size: 2rem; line-height: 40px; height: 40px; display: block; }

/* ---------- 0a4. Hero balance on wide screens ---------- */
#home.hero-section.spa-section.spa-active { justify-content: center !important; }
#home .hero-content { margin-right: clamp(0px, 24vw, 620px); }
@media (max-width: 900px) {
  #home .hero-content { margin-right: 0; }
}

/* ---------- 0b. Typography: proper Thai pairing ---------- */
body, button, input, textarea, select {
  font-family: 'Outfit', 'Noto Sans Thai', 'Segoe UI', Tahoma, sans-serif;
}
h1, h2, h3, h4, .section-title, .hero-title, .logo-text {
  font-family: 'Space Grotesk', 'Noto Sans Thai', 'Outfit', sans-serif;
}

/* ---------- 0c. One-page scroll polish ---------- */
html { scroll-padding-top: 96px; } /* anchors land below floating navbar */
.nav-links a.nav-active { color: #ff8c1a !important; }
.nav-links a.nav-active::after { width: 70% !important; }
.spa-section { scroll-margin-top: 90px; }

/* ---------- 1. Deep space background + neon glows ---------- */
[data-theme="dark"] {
  --bg-color: #05070d;
  --nav-bg: rgba(7, 10, 18, 0.72);
  --glass-bg: rgba(13, 18, 30, 0.55);
  --glass-border: rgba(255, 255, 255, 0.08);
  --neon: #ff6d00;
  --neon-2: #ffd700;
}

[data-theme="dark"] body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -3;
  pointer-events: none;
  background:
    radial-gradient(900px 500px at 85% -5%, rgba(255, 109, 0, 0.13), transparent 60%),
    radial-gradient(700px 500px at 8% 25%, rgba(255, 170, 0, 0.07), transparent 60%),
    radial-gradient(800px 600px at 55% 115%, rgba(255, 109, 0, 0.10), transparent 60%);
}

/* Subtle blueprint grid, fading toward the middle */
[data-theme="dark"] body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -3;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 56px 56px;
  -webkit-mask-image: radial-gradient(ellipse at 50% 0%, rgba(0,0,0,.9), transparent 75%);
          mask-image: radial-gradient(ellipse at 50% 0%, rgba(0,0,0,.9), transparent 75%);
}

/* ---------- 2. Floating pill navbar ---------- */
[data-theme="dark"] .navbar {
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: min(1240px, calc(100% - 32px));
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(8, 11, 20, 0.66);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .nav-links a {
  position: relative;
}

[data-theme="dark"] .nav-links a::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 0;
  height: 2px;
  transform: translateX(-50%);
  border-radius: 2px;
  background: linear-gradient(90deg, var(--neon), var(--neon-2));
  box-shadow: 0 0 12px rgba(255, 109, 0, 0.8);
  transition: width 0.25s ease;
}

[data-theme="dark"] .nav-links a:hover::after {
  width: 70%;
}

/* ---------- 3. Hero — ChainGPT scale ---------- */
[data-theme="dark"] .hero-title {
  font-family: 'Space Grotesk', 'Outfit', sans-serif;
  font-size: clamp(3rem, 7.2vw, 5.6rem) !important;
  line-height: 1.04;
  letter-spacing: -0.02em;
  text-shadow: 0 0 60px rgba(255, 109, 0, 0.25);
}

[data-theme="dark"] .hero-title .highlight {
  background: linear-gradient(90deg, #ff6d00, #ffd700, #ff9040, #ff6d00);
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: cg-gradient-shift 6s linear infinite;
}

@keyframes cg-gradient-shift {
  to { background-position: 300% 0; }
}

[data-theme="dark"] .hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 8px 18px;
  border-radius: 999px;
  border: 1px solid rgba(255, 109, 0, 0.35);
  background: rgba(255, 109, 0, 0.08);
  box-shadow: 0 0 24px rgba(255, 109, 0, 0.18) inset, 0 0 18px rgba(255, 109, 0, 0.12);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.8rem;
}

[data-theme="dark"] .hero-badge::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--neon);
  box-shadow: 0 0 0 0 rgba(255, 109, 0, 0.7);
  animation: cg-ping 1.8s ease-out infinite;
}

@keyframes cg-ping {
  70% { box-shadow: 0 0 0 9px rgba(255, 109, 0, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 109, 0, 0); }
}

/* Hero corner brackets — HUD frame like ChainGPT's decorative corners */
[data-theme="dark"] .hero-content {
  position: relative;
}

[data-theme="dark"] .hero-content::before,
[data-theme="dark"] .hero-content::after {
  content: "";
  position: absolute;
  width: 46px;
  height: 46px;
  border: 2px solid rgba(255, 109, 0, 0.45);
  pointer-events: none;
}

[data-theme="dark"] .hero-content::before {
  top: -18px;
  left: -26px;
  border-right: none;
  border-bottom: none;
  border-top-left-radius: 10px;
}

[data-theme="dark"] .hero-content::after {
  bottom: -18px;
  right: -26px;
  border-left: none;
  border-top: none;
  border-bottom-right-radius: 10px;
}

/* Hero stat chips */
[data-theme="dark"] .hero-stat-item {
  padding: 14px 22px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(13, 18, 30, 0.5);
  backdrop-filter: blur(10px);
  position: relative;
  overflow: hidden;
}

[data-theme="dark"] .hero-stat-item::before {
  content: "";
  position: absolute;
  top: 0;
  left: 15%;
  right: 15%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--neon), transparent);
  opacity: 0.8;
}

/* ---------- 4. Buttons — neon glow + shine sweep ---------- */
[data-theme="dark"] .primary-btn {
  position: relative;
  overflow: hidden;
  border-radius: 999px;
  background: linear-gradient(90deg, #ff6d00, #ff9d00);
  box-shadow: 0 0 22px rgba(255, 109, 0, 0.45), 0 6px 24px rgba(0, 0, 0, 0.4);
  transition: transform 0.2s ease, box-shadow 0.25s ease;
}

[data-theme="dark"] .primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 38px rgba(255, 109, 0, 0.7), 0 10px 30px rgba(0, 0, 0, 0.45);
}

[data-theme="dark"] .primary-btn::after {
  content: "";
  position: absolute;
  top: 0;
  left: -80%;
  width: 50%;
  height: 100%;
  background: linear-gradient(105deg, transparent, rgba(255, 255, 255, 0.45), transparent);
  transform: skewX(-20deg);
  animation: cg-shine 3.2s ease-in-out infinite;
}

@keyframes cg-shine {
  0%, 60% { left: -80%; }
  100% { left: 130%; }
}

[data-theme="dark"] .secondary-btn {
  border-radius: 999px;
  border: 1px solid rgba(255, 109, 0, 0.5);
  transition: all 0.25s ease;
}

[data-theme="dark"] .secondary-btn:hover {
  background: rgba(255, 109, 0, 0.12);
  box-shadow: 0 0 24px rgba(255, 109, 0, 0.3);
}

/* ---------- 5. Section titles — ghost number + glow rule ---------- */
[data-theme="dark"] .section-title {
  position: relative;
  font-family: 'Space Grotesk', 'Outfit', sans-serif;
  font-size: clamp(2rem, 4.5vw, 3.2rem);
  letter-spacing: -0.01em;
  padding-top: 34px;
  background: linear-gradient(90deg, #ffffff 30%, #ffb066 70%, #ffd700);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

[data-theme="dark"] .section-title::before {
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 4.6rem;
  font-weight: 700;
  line-height: 1;
  color: transparent;
  -webkit-text-fill-color: transparent;
  -webkit-text-stroke: 1px rgba(255, 140, 40, 0.28);
  background: none;
  pointer-events: none;
}

#about .section-title::before { content: "01"; }
#projects .section-title::before { content: "02"; }
#knowledge-hub .section-title::before { content: "03"; }
#tech-stack .section-title::before { content: "04"; }
#courses .section-title::before { content: "05"; }
#downloads .section-title::before { content: "06"; }

[data-theme="dark"] .section-title::after {
  content: "";
  display: block;
  width: 90px;
  height: 3px;
  margin: 14px auto 0;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--neon), var(--neon-2));
  box-shadow: 0 0 18px rgba(255, 109, 0, 0.8);
}

/* ---------- 6. Cards — dark glass + neon hover ---------- */
[data-theme="dark"] .glass,
[data-theme="dark"] .card,
[data-theme="dark"] .project-card,
[data-theme="dark"] .course-card,
[data-theme="dark"] .knowledge-card,
[data-theme="dark"] .repo-card,
[data-theme="dark"] .github-card,
[data-theme="dark"] .download-card {
  background: rgba(11, 15, 26, 0.62) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  border-radius: 20px;
  transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

[data-theme="dark"] .project-card:hover,
[data-theme="dark"] .glass:hover {
  transform: translateY(-6px);
  border-color: rgba(255, 109, 0, 0.55);
  box-shadow:
    0 18px 44px rgba(0, 0, 0, 0.5),
    0 0 34px rgba(255, 109, 0, 0.16);
}

[data-theme="dark"] .tag {
  border: 1px solid rgba(255, 109, 0, 0.35);
  background: rgba(255, 109, 0, 0.1);
  border-radius: 999px;
}

/* ---------- 7. Tech ticker (marquee under hero) ---------- */
/* Hide the legacy app.js marquee — replaced by .cg-ticker below */
.tech-marquee-container { display: none !important; }

.cg-ticker {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  padding: 14px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(6, 9, 16, 0.55);
  backdrop-filter: blur(8px);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
          mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
}

.cg-ticker-track {
  display: flex;
  gap: 46px;
  width: max-content;
  animation: cg-marquee 26s linear infinite;
  will-change: transform;
}

.cg-ticker span {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.55);
  white-space: nowrap;
}

.cg-ticker span i {
  color: var(--neon, #ff6d00);
  font-size: 0.7rem;
}

@keyframes cg-marquee {
  to { transform: translateX(-50%); }
}

@media (prefers-reduced-motion: reduce) {
  .cg-ticker-track { animation: none; }
  [data-theme="dark"] .primary-btn::after { animation: none; }
}

/* ---------- 8. Robot companion speech bubble ---------- */
#robot-bubble {
  position: fixed;
  z-index: 960;
  transform: translate(-100%, -50%) scale(0.85);   /* grows to the LEFT of the robot */
  transform-origin: right center;
  padding: 10px 16px;
  border-radius: 14px 14px 4px 14px;               /* tail points bottom-right toward the robot */
  background: rgba(10, 14, 24, 0.9);
  border: 1px solid rgba(255, 109, 0, 0.5);
  box-shadow: 0 0 24px rgba(255, 109, 0, 0.25), 0 8px 24px rgba(0, 0, 0, 0.5);
  color: #ffe8d1;
  font-family: 'Outfit', 'Noto Sans Thai', sans-serif;
  font-size: 0.92rem;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

#robot-bubble.visible {
  opacity: 1;
  transform: translate(-100%, -50%) scale(1);
}

/* ---------- 9. Footer (redesigned) & chatbot button polish ---------- */
.cg-footer {
  padding: 64px 6% 0 !important;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}
[data-theme="dark"] .cg-footer {
  background:
    radial-gradient(700px 240px at 50% 0%, rgba(255, 109, 0, 0.08), transparent 70%),
    rgba(5, 7, 13, 0.92);
}
[data-theme="light"] .cg-footer {
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  background:
    radial-gradient(700px 240px at 50% 0%, rgba(255, 109, 0, 0.05), transparent 70%),
    rgba(255, 255, 255, 0.75);
}
.cg-footer-grid {
  display: grid;
  /* The column count is no longer fixed at four: link columns are added and
     removed from SSRobotics Studio, so a hardcoded 1.6fr 1fr 1fr 1.4fr made a
     fifth column wrap onto its own row and shove the sponsors under the logo.
     The brand block keeps a real minimum, everything after it shares the rest.
     (style.css's catch-all [class*="-grid"] !important rule used to win here and
     pin the footer to four fixed 290px tracks — that was the real reason a fifth
     column dropped to a second row. It now excludes this class.) */
  grid-template-columns: minmax(230px, 1.6fr) repeat(auto-fit, minmax(150px, 1fr));
  gap: 40px;
  max-width: 1240px;
  /* kept explicitly: the catch-all used to supply it */
  margin: 1.5rem auto 0;
  text-align: left;
}
.cg-footer-logo { height: 46px; width: auto; margin-bottom: 14px; }
.cg-footer-tagline {
  font-size: 0.92rem;
  line-height: 1.7;
  max-width: 320px;
  color: rgba(148, 163, 184, 0.95);
}
[data-theme="light"] .cg-footer-tagline { color: #5a6478; }
.cg-footer-social { display: flex; gap: 12px; margin-top: 18px; }
.cg-footer-social a {
  width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  border: 1px solid rgba(255, 109, 0, 0.35);
  color: #ff8c1a;
  font-size: 1rem;
  transition: all 0.25s ease;
}
.cg-footer-social a:hover {
  background: rgba(255, 109, 0, 0.15);
  box-shadow: 0 0 18px rgba(255, 109, 0, 0.35);
  transform: translateY(-2px);
}
.cg-footer-col h4 {
  font-size: 0.8rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #ff8c1a;
  margin-bottom: 16px;
}
.cg-footer-col a {
  display: block;
  padding: 5px 0;
  font-size: 0.92rem;
  color: rgba(148, 163, 184, 0.95);
  text-decoration: none;
  transition: color 0.2s ease, transform 0.2s ease;
}
[data-theme="light"] .cg-footer-col a { color: #5a6478; }
.cg-footer-col a:hover { color: #ff8c1a; transform: translateX(4px); }
.cg-footer .sponsors-list { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin: 0; }
.cg-footer .sponsor-logo {
  height: 40px; width: auto;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  padding: 4px 8px;
  opacity: 0.9;
}
.cg-footer-bottom {
  margin-top: 44px;
  padding: 18px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  max-width: 1240px;
  margin-left: auto;
  margin-right: auto;
}
[data-theme="light"] .cg-footer-bottom { border-top-color: rgba(15, 23, 42, 0.08); }
.cg-footer-bottom p { font-size: 0.82rem; color: rgba(148, 163, 184, 0.8); margin: 0; }
[data-theme="light"] .cg-footer-bottom p { color: #7c8698; }
@media (max-width: 900px) {
  .cg-footer-grid { grid-template-columns: 1fr 1fr; }
  .cg-footer-bottom { justify-content: center; text-align: center; }
}

/* ---------- 9b. Section kickers (editorial labels above titles) ---------- */
/* extra top room so the kicker clears the floating navbar.
   Driven by --ss-sec-pad-top (set by SSRobotics Studio's "layout" pane) —
   fallback 135px preserves the original look before Studio settings load. */
.spa-section.spa-active:not(#home) { padding-top: var(--ss-sec-pad-top, 135px) !important; }
.spa-section .container { position: relative; }
.spa-section .container::before {
  display: block;
  text-align: center;
  font-family: 'Space Grotesk', 'Outfit', sans-serif;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.38em;
  text-transform: uppercase;
  color: #ff8c1a;
  opacity: 0.85;
  margin-bottom: 6px;
}
#about .container::before { content: "• Who we are •"; }
#projects .container::before { content: "• What we build •"; }
#knowledge-hub .container::before { content: "• Learn & explore •"; }
#courses .container::before { content: "• Level up •"; }
#tech-stack .container::before { content: "• Our arsenal •"; }
#downloads .container::before { content: "• Members only •"; }

/* ---------- 9c. Hero scroll cue ---------- */
.cg-scroll-cue {
  position: absolute;
  left: 50%;
  bottom: 64px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  opacity: 0.75;
  transition: opacity 0.25s ease;
  z-index: 5;
}
.cg-scroll-cue:hover { opacity: 1; }
.cg-scroll-mouse {
  width: 24px; height: 38px;
  border: 2px solid rgba(255, 140, 26, 0.7);
  border-radius: 14px;
  display: flex;
  justify-content: center;
  padding-top: 6px;
}
.cg-scroll-dot {
  width: 4px; height: 8px;
  border-radius: 3px;
  background: #ff8c1a;
  animation: cg-scroll-drop 1.6s ease-in-out infinite;
}
@keyframes cg-scroll-drop {
  0% { transform: translateY(0); opacity: 1; }
  70% { transform: translateY(12px); opacity: 0; }
  100% { transform: translateY(0); opacity: 0; }
}
.cg-scroll-label {
  font-size: 0.7rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: #ff8c1a;
}
@media (max-width: 900px) { .cg-scroll-cue { display: none; } }
@media (prefers-reduced-motion: reduce) { .cg-scroll-dot { animation: none; } }

[data-theme="dark"] .chatbot-toggle-btn {
  box-shadow: 0 0 0 1px rgba(255, 109, 0, 0.5), 0 0 28px rgba(255, 109, 0, 0.45);
}

/* ============================================================
   Chat window — same design system as the site
   ============================================================ */
.chat-container {
  border-radius: 22px !important;
  border: 1px solid rgba(255, 140, 26, 0.35) !important;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55), 0 0 40px rgba(255, 109, 0, 0.15) !important;
}
[data-theme="dark"] .chat-container {
  background: rgba(9, 12, 22, 0.92) !important;
  backdrop-filter: blur(22px) saturate(1.3) !important;
}
.chat-header {
  background: linear-gradient(120deg, #ff6d00, #ff9d00) !important;
  color: #14100a !important;
}
.chat-header .header-avatar {
  border: 2px solid rgba(255, 255, 255, 0.7) !important;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.25) !important;
}
.chat-header .status-indicator { color: #0a3d1f !important; }
.message.user {
  background: linear-gradient(120deg, #ff6d00, #ff9d00) !important;
  color: #fff !important;
  border-radius: 16px 16px 4px 16px !important;
  box-shadow: 0 4px 14px rgba(255, 109, 0, 0.25) !important;
}
.message.bot {
  border-radius: 16px 16px 16px 4px !important;
  border: 1px solid rgba(255, 255, 255, 0.06) !important;
}
[data-theme="dark"] .message.bot { background: rgba(20, 26, 40, 0.85) !important; }
[data-theme="dark"] .chat-input { background: rgba(9, 12, 22, 0.95) !important; border-top-color: rgba(255, 255, 255, 0.06) !important; }
[data-theme="dark"] #user-input {
  background: rgba(20, 26, 40, 0.8) !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
}
#user-input:focus { border-color: rgba(255, 140, 26, 0.6) !important; box-shadow: 0 0 0 3px rgba(255, 109, 0, 0.15) !important; }
#send-btn { color: #ff8c1a !important; }

/* ============================================================
   Login modal — glass card matching the theme
   ============================================================ */
.modal-container, [data-theme="dark"] .modal-container {
  border-radius: 22px !important;
  border: 1px solid rgba(255, 140, 26, 0.3) !important;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), 0 0 50px rgba(255, 109, 0, 0.12) !important;
}
[data-theme="dark"] .modal-container { background: rgba(10, 13, 24, 0.95) !important; }
.input-group input:focus {
  border-color: rgba(255, 140, 26, 0.6) !important;
  box-shadow: 0 0 0 3px rgba(255, 109, 0, 0.15) !important;
}
.modal-header h2 {
  background: linear-gradient(90deg, #ff6d00, #ffd700);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ============================================================
   Accessibility — visible focus for keyboard users
   ============================================================ */
a:focus-visible,
button:focus-visible,
input:focus-visible,
.btn:focus-visible,
.tab-btn:focus-visible {
  outline: 2.5px solid #ff8c1a !important;
  outline-offset: 2px !important;
  border-radius: 6px;
}

/* ============================================================
   Mobile polish
   ============================================================ */
@media (max-width: 900px) {
  /* Sign In pill looked empty — icon-only but properly sized & colored */
  .nav-login-btn {
    min-width: 42px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
  .nav-login-btn i { font-size: 1rem; color: #ff8c1a !important; }
  .navbar { padding-left: 14px; padding-right: 14px; }
}
@media (max-width: 560px) {
  .cg-footer-grid { grid-template-columns: 1fr; gap: 28px; text-align: center; }
  .cg-footer-tagline { margin: 0 auto; }
  .cg-footer-social { justify-content: center; }
  .cg-footer .sponsors-list { justify-content: center; }
  .cg-ticker span { font-size: 0.72rem; }
  .hero-stats { justify-content: center !important; }
}

/* ---------- 10. Selection & misc ---------- */
[data-theme="dark"] ::selection {
  background: rgba(255, 109, 0, 0.55);
  color: #fff;
}

/* ============================================================
   LIGHT THEME — ChainGPT-style bright edition
   ============================================================ */
[data-theme="light"] {
  --bg-color: #f3f5fa;
  --text-color: #16203a;
  --nav-bg: rgba(255, 255, 255, 0.7);
  --glass-bg: rgba(255, 255, 255, 0.72);
  --glass-border: rgba(15, 23, 42, 0.08);
  --neon: #ff6d00;
  --neon-2: #f5a623;
}

[data-theme="light"] body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -3;
  pointer-events: none;
  background:
    radial-gradient(900px 500px at 85% -5%, rgba(255, 109, 0, 0.09), transparent 60%),
    radial-gradient(700px 500px at 8% 25%, rgba(255, 170, 0, 0.06), transparent 60%),
    radial-gradient(800px 600px at 55% 115%, rgba(255, 109, 0, 0.07), transparent 60%);
}

[data-theme="light"] body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -3;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(15, 23, 42, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 23, 42, 0.045) 1px, transparent 1px);
  background-size: 56px 56px;
  -webkit-mask-image: radial-gradient(ellipse at 50% 0%, rgba(0,0,0,.9), transparent 75%);
          mask-image: radial-gradient(ellipse at 50% 0%, rgba(0,0,0,.9), transparent 75%);
}

/* Soften the old particle dots so they stop fighting the content */
[data-theme="light"] #particle-canvas { opacity: 0.1 !important; }

/* Floating pill navbar — light glass */
[data-theme="light"] .navbar {
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: min(1240px, calc(100% - 32px));
  border-radius: 18px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  box-shadow: 0 8px 28px rgba(22, 32, 58, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

[data-theme="light"] .nav-links a { position: relative; }
[data-theme="light"] .nav-links a::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 0;
  height: 2px;
  transform: translateX(-50%);
  border-radius: 2px;
  background: linear-gradient(90deg, var(--neon), var(--neon-2));
  transition: width 0.25s ease;
}
[data-theme="light"] .nav-links a:hover::after { width: 70%; }

/* Hero — readable and bold on light */
[data-theme="light"] .hero-title {
  font-family: 'Space Grotesk', 'Outfit', sans-serif;
  font-size: clamp(3rem, 7.2vw, 5.6rem) !important;
  line-height: 1.04;
  letter-spacing: -0.02em;
  color: #141d38;
  -webkit-text-fill-color: #141d38;
  background: none;
  text-shadow: none;
}
[data-theme="light"] .hero-title .highlight {
  background: linear-gradient(90deg, #ff6d00, #f5a623, #ff8b2e, #ff6d00);
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: cg-gradient-shift 6s linear infinite;
}
[data-theme="light"] .hero-text,
[data-theme="light"] .hero-subtitle {
  color: #46536e !important;
}
[data-theme="light"] .hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 8px 18px;
  border-radius: 999px;
  border: 1px solid rgba(255, 109, 0, 0.4);
  background: rgba(255, 109, 0, 0.08);
  color: #d45a00;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.8rem;
}
[data-theme="light"] .hero-badge::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--neon);
  animation: cg-ping 1.8s ease-out infinite;
}
[data-theme="light"] .hero-content { position: relative; }
[data-theme="light"] .hero-content::before,
[data-theme="light"] .hero-content::after {
  content: "";
  position: absolute;
  width: 46px;
  height: 46px;
  border: 2px solid rgba(255, 109, 0, 0.4);
  pointer-events: none;
}
[data-theme="light"] .hero-content::before {
  top: -18px; left: -26px;
  border-right: none; border-bottom: none;
  border-top-left-radius: 10px;
}
[data-theme="light"] .hero-content::after {
  bottom: -18px; right: -26px;
  border-left: none; border-top: none;
  border-bottom-right-radius: 10px;
}
[data-theme="light"] .hero-stat-item {
  background: rgba(255, 255, 255, 0.85) !important;
  border: 1px solid rgba(255, 109, 0, 0.22) !important;
  box-shadow: 0 4px 18px rgba(22, 32, 58, 0.07) !important;
  border-radius: 16px !important;
}

/* Buttons */
[data-theme="light"] .primary-btn {
  position: relative;
  overflow: hidden;
  border-radius: 999px;
  background: linear-gradient(90deg, #ff6d00, #ff9d00);
  color: #fff;
  box-shadow: 0 8px 24px rgba(255, 109, 0, 0.35);
  transition: transform 0.2s ease, box-shadow 0.25s ease;
}
[data-theme="light"] .primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 34px rgba(255, 109, 0, 0.5);
}
[data-theme="light"] .secondary-btn {
  border-radius: 999px;
  border: 1px solid rgba(255, 109, 0, 0.55);
  color: #d45a00;
  transition: all 0.25s ease;
}
[data-theme="light"] .secondary-btn:hover {
  background: rgba(255, 109, 0, 0.09);
}

/* Section titles */
[data-theme="light"] .section-title {
  position: relative;
  font-family: 'Space Grotesk', 'Outfit', sans-serif;
  font-size: clamp(2rem, 4.5vw, 3.2rem);
  letter-spacing: -0.01em;
  padding-top: 34px;
  background: linear-gradient(90deg, #141d38 30%, #e06510 75%, #f5a623);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
[data-theme="light"] .section-title::before {
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 4.6rem;
  font-weight: 700;
  line-height: 1;
  color: transparent;
  -webkit-text-fill-color: transparent;
  -webkit-text-stroke: 1px rgba(255, 109, 0, 0.3);
  background: none;
  pointer-events: none;
}
[data-theme="light"] .section-title::after {
  content: "";
  display: block;
  width: 90px;
  height: 3px;
  margin: 14px auto 0;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--neon), var(--neon-2));
}

/* Cards */
[data-theme="light"] .glass,
[data-theme="light"] .card,
[data-theme="light"] .project-card,
[data-theme="light"] .course-card,
[data-theme="light"] .knowledge-card,
[data-theme="light"] .repo-card,
[data-theme="light"] .github-card,
[data-theme="light"] .download-card {
  background: rgba(255, 255, 255, 0.82) !important;
  border: 1px solid rgba(15, 23, 42, 0.09) !important;
  border-radius: 20px;
  box-shadow: 0 6px 24px rgba(22, 32, 58, 0.06);
  transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}
[data-theme="light"] .project-card:hover,
[data-theme="light"] .glass:hover {
  transform: translateY(-6px);
  border-color: rgba(255, 109, 0, 0.5) !important;
  box-shadow: 0 18px 40px rgba(22, 32, 58, 0.12), 0 0 24px rgba(255, 109, 0, 0.1);
}
/* Card text readable on white */
[data-theme="light"] .project-content h3,
[data-theme="light"] .card h3,
[data-theme="light"] .course-card h3 { color: #16203a; }
[data-theme="light"] .project-content p,
[data-theme="light"] .card p,
[data-theme="light"] .course-card p { color: #4b5563; }
/* Soften injected energy lines on light */
[data-theme="light"] .cyber-energy-bg { opacity: 0.35; }
[data-theme="light"] .tag {
  border: 1px solid rgba(255, 109, 0, 0.4);
  background: rgba(255, 109, 0, 0.09);
  color: #d45a00;
  border-radius: 999px;
}

/* Ticker */
[data-theme="light"] .cg-ticker {
  border-top: 1px solid rgba(15, 23, 42, 0.07);
  background: rgba(255, 255, 255, 0.6);
}
[data-theme="light"] .cg-ticker span { color: #5a6478; }

/* Bubble */
[data-theme="light"] #robot-bubble {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(255, 109, 0, 0.5);
  color: #d45a00;
  box-shadow: 0 8px 24px rgba(22, 32, 58, 0.15), 0 0 18px rgba(255, 109, 0, 0.15);
}

[data-theme="light"] ::selection {
  background: rgba(255, 109, 0, 0.35);
}

/* ---------- Hard overrides (beat legacy !important rules in fix.css) ---------- */
/* Sections: let the global themed background (glow + grid) show through,
   instead of the legacy hardcoded near-black plate (#07071a) */
[data-theme="dark"] .spa-section.spa-active:not(#home),
[data-theme="light"] .spa-section.spa-active:not(#home),
[data-theme="dark"] #downloads.spa-section.spa-active,
[data-theme="light"] #downloads.spa-section.spa-active {
  background: transparent !important;
}
/* Legacy light section plates (grey) — also clear */
[data-theme="light"] .projects-section,
[data-theme="light"] .courses-section,
[data-theme="light"] .tech-stack-section,
[data-theme="light"] .about-section,
[data-theme="light"] .downloads-section {
  background: transparent;
}

/* Light hero title: dark navy base + gradient highlight (ChainGPT structure) */
[data-theme="light"] #home .hero-title,
[data-theme="light"] .hero-title {
  background: none !important;
  color: #141d38 !important;
  -webkit-text-fill-color: #141d38 !important;
}
[data-theme="light"] #home .hero-title .highlight,
[data-theme="light"] .hero-title .highlight {
  background: linear-gradient(90deg, #ff6d00, #f5a623, #ff8b2e, #ff6d00) !important;
  background-size: 300% 100% !important;
  -webkit-background-clip: text !important;
  background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
  animation: cg-gradient-shift 6s linear infinite !important;
}
/* Hero paragraph: readable in both themes (legacy rule forced pale grey) */
[data-theme="light"] #home .hero-content .hero-text,
[data-theme="light"] #home > .hero-content > p {
  color: #46536e !important;
  -webkit-text-fill-color: #46536e !important;
}
[data-theme="dark"] #home .hero-content .hero-text,
[data-theme="dark"] #home > .hero-content > p {
  color: #c3cee0 !important;
  -webkit-text-fill-color: #c3cee0 !important;
}
/* Typed subtitle: legacy green → brand gold/orange */
[data-theme="dark"] #home h2,
[data-theme="dark"] .hero-subtitle {
  color: #ffb84d !important;
  -webkit-text-fill-color: #ffb84d !important;
}
[data-theme="light"] #home h2,
[data-theme="light"] .hero-subtitle {
  color: #c0440a !important;
  -webkit-text-fill-color: #c0440a !important;
}

/* ============================================================
   SYS_TELEMETRY HUD — glass restyle (both themes)
   ============================================================ */
.hud-dashboard-panel {
  top: 100px !important;
  right: 24px !important;
  width: 225px !important;
  background: rgba(10, 14, 24, 0.55) !important;
  border: 1px solid rgba(255, 109, 0, 0.35) !important;
  border-radius: 16px !important;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35), 0 0 24px rgba(255, 109, 0, 0.1) !important;
  font-family: 'Space Grotesk', 'Courier New', monospace !important;
  backdrop-filter: blur(14px) !important;
  -webkit-backdrop-filter: blur(14px) !important;
}
.hud-header {
  color: var(--neon, #ff6d00) !important;
  border-bottom-color: rgba(255, 109, 0, 0.25) !important;
  letter-spacing: 3px !important;
}
.hud-blink { color: #ff6d00 !important; }
.hud-bar-fill { background: linear-gradient(90deg, #ff6d00, #ffd700) !important; }
.hud-canvas-container {
  border-radius: 10px !important;
  border-color: rgba(255, 109, 0, 0.15) !important;
}
/* graph → orange monochrome (hue-rotate alone made it pink) */
#hudGraph { filter: grayscale(1) sepia(1) saturate(4.5) hue-rotate(-15deg) brightness(1.15); }
.hud-canvas-labels * { color: #ffb84d !important; text-shadow: none !important; }
[data-theme="light"] .hud-dashboard-panel {
  background: rgba(255, 255, 255, 0.75) !important;
  border: 1px solid rgba(255, 109, 0, 0.3) !important;
  color: #5a6478 !important;
  box-shadow: 0 8px 28px rgba(22, 32, 58, 0.12), 0 0 20px rgba(255, 109, 0, 0.08) !important;
}
[data-theme="light"] .hud-val { color: #1c2540 !important; }
[data-theme="light"] .hud-canvas-container { background: rgba(15, 23, 42, 0.85) !important; }
[data-theme="light"] .hud-logger { color: #8b96ad !important; border-top-color: rgba(15,23,42,0.12) !important; }
[data-theme="light"] .hud-bar-bg { background: rgba(15, 23, 42, 0.1) !important; }

/* ============================================================
   De-green pass — legacy neon-green accents → brand orange/gold
   ============================================================ */
.tab-btn.active,
[data-theme="dark"] .tab-btn.active,
[data-theme="light"] .tab-btn.active {
  background: rgba(255, 109, 0, 0.14) !important;
  border-color: rgba(255, 109, 0, 0.45) !important;
  color: #ff8c1a !important;
}
.sys-badge {
  color: #ffb84d !important;
  background: rgba(255, 109, 0, 0.1) !important;
  border-color: rgba(255, 109, 0, 0.35) !important;
}
.led-blink {
  background: #ff6d00 !important;
  box-shadow: 0 0 6px #ff6d00 !important;
}
.bio-avatar {
  border-color: #ff9d00 !important;
  box-shadow: 0 0 30px rgba(255, 140, 26, 0.4) !important;
}
.social-hex:hover {
  background: rgba(255, 109, 0, 0.15) !important;
  border-color: #ff8c1a !important;
  color: #ff8c1a !important;
}
.tel-item { border-radius: 14px !important; }
.tel-item:hover {
  background: rgba(255, 140, 26, 0.06) !important;
  border-color: rgba(255, 140, 26, 0.35) !important;
}
[data-theme="dark"] .tel-item i { color: #ffb84d !important; }

/* About page — light-mode contrast fixes */
[data-theme="light"] .social-hex {
  background: rgba(22, 32, 58, 0.06) !important;
  border: 1px solid rgba(22, 32, 58, 0.18) !important;
  color: #3c4a63 !important;
}
[data-theme="light"] .tel-item {
  background: #ffffff !important;
  border: 1px solid rgba(15, 23, 42, 0.09) !important;
  box-shadow: 0 4px 16px rgba(22, 32, 58, 0.06) !important;
}
[data-theme="light"] .tel-item h4 { color: #16203a !important; }
[data-theme="light"] .tel-item p { color: #5a6478 !important; }
[data-theme="light"] .tel-item i { color: #e8720c !important; }
[data-theme="light"] .bio-role { color: #c25a00 !important; }
[data-theme="light"] .bio-name { color: #141d38 !important; }
.hud-ring { border-color: rgba(255, 140, 26, 0.5) !important; }
.ring-1 {
  border: 2px solid rgba(255, 140, 26, 0.2) !important;
  border-top: 2px solid #ff8c1a !important;
}
.ring-3 {
  border-left: 2px solid #ffd700 !important;
  border-right: 2px solid #ffd700 !important;
}
.skill-percent { color: #ff8c1a !important; }
.skill-fill {
  background: repeating-linear-gradient(45deg, #ff6d00, #ff6d00 10px, #e05e00 10px, #e05e00 20px) !important;
  box-shadow: 0 0 10px rgba(255, 109, 0, 0.5) !important;
}
#scroll-progress-bar,
.section-divider, .accent-line, .title-line {
  background: linear-gradient(90deg, #ff6d00, #ffd700) !important;
  box-shadow: 0 0 10px rgba(255, 109, 0, 0.6) !important;
}
.hud-label { color: #ff8c1a !important; }
.hud-pill { border-color: rgba(255, 109, 0, 0.3) !important; }
.hud-val { text-shadow: 0 0 5px rgba(255, 140, 26, 0.5) !important; }
.boot-text { color: #ffb84d !important; }
a:focus-visible, button:focus-visible, .btn:focus-visible {
  outline-color: #ff8c1a !important;
}
[data-theme="light"] .bio-desc { color: #5a6478 !important; }
[data-theme="light"] .skill-track {
  background: rgba(15, 23, 42, 0.08) !important;
  border-color: rgba(15, 23, 42, 0.1) !important;
}

/* ============================================================
   Chatbot toggle — mascot style (matches the 3D robot)
   ============================================================ */
.chatbot-toggle-btn {
  background: linear-gradient(145deg, #ffffff, #e9edf5) !important;
  border: 2px solid rgba(255, 109, 0, 0.55) !important;
  box-shadow: 0 0 0 4px rgba(255, 109, 0, 0.12), 0 0 28px rgba(255, 109, 0, 0.4) !important;
}
.chatbot-toggle-btn .toggle-avatar { display: none !important; }
.chatbot-toggle-btn .toggle-icon {
  display: flex !important;
  align-items: center;
  justify-content: center;
  font-size: 1.9rem !important;
  filter: drop-shadow(0 2px 6px rgba(255, 109, 0, 0.4));
}
[data-theme="dark"] .chatbot-toggle-btn {
  background: linear-gradient(145deg, #1a2032, #0d1220) !important;
}

/* ============================================================
   Professional micro-interactions (enhance.js companion)
   ============================================================ */

/* Cursor spotlight — adds depth to the ambient background, every page */
.cg-spotlight {
  position: fixed;
  top: 0; left: 0;
  width: 620px; height: 620px;
  margin: -310px 0 0 -310px;   /* center on transform point */
  border-radius: 50%;
  pointer-events: none;
  z-index: -1;                  /* above ambient (-2), below content */
  background: radial-gradient(circle, rgba(255,109,0,0.10), rgba(255,140,0,0.05) 40%, transparent 70%);
  opacity: 1;
  transition: opacity .4s ease;
  will-change: transform;
}
[data-theme="light"] .cg-spotlight {
  background: radial-gradient(circle, rgba(255,109,0,0.08), rgba(255,140,0,0.04) 40%, transparent 70%);
}

/* Magnetic buttons ease back smoothly */
.primary-btn, .cg-magnetic { transition: transform .25s cubic-bezier(.2,.8,.2,1), box-shadow .25s ease; }

/* Card cover image: subtle zoom on hover (image sits in overflow:hidden card) */
.project-card .project-image {
  transition: transform .5s cubic-bezier(.2,.8,.2,1), filter .4s ease;
}
.project-card:hover .project-image {
  transform: scale(1.06);
  filter: saturate(1.08) brightness(1.04);
}

/* Reveal-on-scroll fallback */
[data-reveal] {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity .7s cubic-bezier(.2,.8,.2,1), transform .7s cubic-bezier(.2,.8,.2,1);
}
[data-reveal].cg-revealed { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  [data-reveal] { opacity: 1; transform: none; }
  .project-card:hover .project-image { transform: none; }
}

/* ============================================================
   ABOUT / IDENTITY & NEURAL SKILLS — full redesign
   ============================================================ */

/* Layout: bio full-width, then skills + telemetry as an equal-height row */
.matrix-grid { gap: 22px !important; align-items: stretch; }
.matrix-skills-card, .matrix-telemetry-card { grid-row: 2 / 3 !important; height: 100%; }

/* ---- Card shell: refined glass, orange system ---- */
.matrix-bio-card,
.matrix-skills-card,
.matrix-telemetry-card {
  border: 1px solid rgba(255, 140, 26, 0.22) !important;
  background: linear-gradient(160deg, rgba(17,22,34,0.72), rgba(9,12,20,0.82)) !important;
  border-radius: 22px !important;
  box-shadow: 0 18px 46px rgba(0,0,0,0.4) !important;
  position: relative;
  overflow: hidden;
}
[data-theme="light"] .matrix-bio-card,
[data-theme="light"] .matrix-skills-card,
[data-theme="light"] .matrix-telemetry-card {
  background: linear-gradient(160deg, rgba(255,255,255,0.92), rgba(248,250,253,0.86)) !important;
  border: 1px solid rgba(15,23,42,0.08) !important;
  box-shadow: 0 14px 36px rgba(22,32,58,0.08) !important;
}
/* subtle top accent line on every card */
.matrix-bio-card::after,
.matrix-skills-card::after,
.matrix-telemetry-card::after {
  content: ""; position: absolute; top: 0; left: 24px; right: 24px; height: 2px;
  background: linear-gradient(90deg, transparent, rgba(255,140,26,0.7), transparent);
}

/* ---- Bio card ---- */
.matrix-bio-card { padding: 34px 44px !important; gap: 44px !important; }

/* clean rotating conic ring instead of the 3 busy rings */
.matrix-bio-card .hud-ring { display: none !important; }
.bio-hud-container { width: 172px !important; height: 172px !important; }
.bio-hud-container::before {
  content: ""; position: absolute; inset: 8px; border-radius: 50%;
  background: conic-gradient(from 0deg, #ff6d00, #ffd700, #ff9040, #ff6d00);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px));
          mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px));
  animation: cg-ring-spin 7s linear infinite;
}
.bio-hud-container::after {
  content: ""; position: absolute; inset: 20px; border-radius: 50%;
  border: 1px solid rgba(255,140,26,0.25);
}
@keyframes cg-ring-spin { to { transform: rotate(360deg); } }
.bio-avatar {
  width: 138px !important; height: 138px !important;
  border: 3px solid rgba(9,12,20,0.9) !important;
  box-shadow: 0 0 28px rgba(255,140,26,0.35) !important;
}
[data-theme="light"] .bio-avatar { border-color: #fff !important; }

.bio-name {
  font-family: 'Space Grotesk','Noto Sans Thai',sans-serif;
  font-size: 1.75rem !important; letter-spacing: -0.01em; margin: 2px 0 8px !important;
}
[data-theme="light"] .bio-name { color: #141d38 !important; }

/* role becomes a pill badge */
.bio-role {
  display: inline-block; font-family: 'Space Grotesk',sans-serif !important;
  font-size: 0.82rem !important; font-weight: 600; letter-spacing: 0.04em;
  color: #ff8c1a !important; -webkit-text-fill-color: #ff8c1a !important;
  background: rgba(255,109,0,0.1); border: 1px solid rgba(255,109,0,0.32);
  padding: 5px 14px; border-radius: 999px; margin-bottom: 16px !important;
}
.bio-desc { font-size: 0.95rem !important; max-width: 560px; margin-bottom: 18px !important; }
[data-theme="light"] .bio-desc { color: #5a6478 !important; }

/* highlight tags */
.bio-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.bio-tags span {
  font-size: 0.78rem; font-weight: 500; padding: 5px 12px; border-radius: 8px;
  color: #cbd5e1; background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.08);
}
[data-theme="light"] .bio-tags span { color: #46536e; background: rgba(15,23,42,0.04); border-color: rgba(15,23,42,0.08); }

/* social buttons → clean rounded (drop the hexagon) */
.bio-socials { gap: 10px !important; }
.social-hex {
  width: 42px !important; height: 42px !important; border-radius: 12px !important;
  clip-path: none !important;
  background: rgba(255,255,255,0.05) !important; border: 1px solid rgba(255,140,26,0.25) !important;
  color: #ff8c1a !important;
}
.social-hex:hover { background: rgba(255,109,0,0.14) !important; transform: translateY(-3px) !important; box-shadow: 0 8px 20px rgba(255,109,0,0.25); }
[data-theme="light"] .social-hex { background: rgba(15,23,42,0.05) !important; color: #d45a00 !important; }

/* sys badge refined */
.sys-badge { top: 20px !important; right: 24px !important; border-radius: 999px !important; letter-spacing: 0.08em; }

/* ---- Card titles: modern, not terminal ---- */
.matrix-card-title {
  font-family: 'Space Grotesk','Noto Sans Thai',sans-serif !important;
  font-size: 0.82rem !important; font-weight: 600 !important; letter-spacing: 0.16em !important;
  text-transform: uppercase; color: #ff8c1a !important;
  border-left: none !important; padding: 0 0 16px 0 !important; margin-bottom: 22px !important;
  border-bottom: 1px solid rgba(255,140,26,0.15) !important;
  display: flex; align-items: center; gap: 9px;
}
.matrix-card-title::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: #ff8c1a; box-shadow: 0 0 8px rgba(255,140,26,0.9);
}
[data-theme="light"] .matrix-card-title { color: #d45a00 !important; }

/* ---- Skill bars: smooth & rounded ---- */
.matrix-skills-card, .matrix-telemetry-card { padding: 28px 30px !important; }
.skill-bars { gap: 18px !important; }
.skill-label { font-size: 0.9rem !important; }
[data-theme="light"] .skill-label { color: #16203a !important; }
.skill-percent {
  font-family: 'Space Grotesk',monospace !important; font-weight: 700;
  color: #ff8c1a !important;
}
.skill-track {
  height: 8px !important; border-radius: 999px !important;
  background: rgba(255,255,255,0.06) !important; border: none !important;
}
[data-theme="light"] .skill-track { background: rgba(15,23,42,0.08) !important; }
.skill-fill {
  border-radius: 999px !important;
  background: linear-gradient(90deg, #ff6d00, #ffd700) !important;
  box-shadow: 0 0 12px rgba(255,140,26,0.5) !important;
}

/* ---- Telemetry: compact 2×2 tiles ---- */
.telemetry-grid { gap: 14px !important; }
.tel-item {
  background: rgba(255,255,255,0.03) !important;
  border: 1px solid rgba(255,255,255,0.07) !important;
  border-radius: 16px !important; padding: 20px 14px !important;
}
[data-theme="light"] .tel-item { background: rgba(15,23,42,0.03) !important; border-color: rgba(15,23,42,0.08) !important; }
.tel-item:hover {
  background: rgba(255,109,0,0.06) !important; border-color: rgba(255,140,26,0.4) !important;
  transform: translateY(-4px) !important; box-shadow: 0 12px 28px rgba(0,0,0,0.3);
}
.tel-item i {
  font-size: 1.15rem !important; color: #ff8c1a !important;
  width: 42px; height: 42px; line-height: 42px; margin: 0 auto 12px !important;
  border-radius: 12px; background: rgba(255,109,0,0.1); display: block;
}
.tel-item h4 {
  font-family: 'Space Grotesk',sans-serif !important; font-size: 2rem !important;
  background: linear-gradient(90deg, #ff8c1a, #ffd700);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.tel-item p { font-size: 0.72rem !important; letter-spacing: 0.08em; }
[data-theme="light"] .tel-item p { color: #5a6478 !important; }

@media (max-width: 900px) {
  .matrix-bio-card { flex-direction: column !important; text-align: center; padding: 30px 24px !important; gap: 20px !important; }
  .bio-tags, .bio-socials { justify-content: center; }
  .bio-role { margin-left: auto; margin-right: auto; }
}

/* Fix over-broad [class*="grid"] rule in style.css that hijacked the About grids */
.matrix-grid {
  grid-template-columns: 1fr 1fr !important;
  margin-top: 0 !important;
}
.telemetry-grid {
  grid-template-columns: repeat(2, 1fr) !important;
  margin-top: 0 !important;
}
.matrix-bio-card { grid-column: 1 / 3 !important; }
.matrix-skills-card { grid-column: 1 / 2 !important; }
.matrix-telemetry-card { grid-column: 2 / 3 !important; }
@media (max-width: 900px) {
  .matrix-grid { grid-template-columns: 1fr !important; }
  .matrix-bio-card, .matrix-skills-card, .matrix-telemetry-card { grid-column: 1 / 2 !important; }
}

/* Beat [class*="-grid"]:not()... (specificity 0,3,0) with #id scoping */
#about .matrix-grid {
  display: grid !important;
  grid-template-columns: 1fr 1fr !important;
  gap: 22px !important;
  margin-top: 0 !important;
}
#about .telemetry-grid {
  display: grid !important;
  grid-template-columns: repeat(2, 1fr) !important;
  gap: 14px !important;
  margin-top: 0 !important;
}
#about .matrix-bio-card { grid-column: 1 / 3 !important; }
#about .matrix-skills-card { grid-column: 1 / 2 !important; grid-row: 2 / 3 !important; }
#about .matrix-telemetry-card { grid-column: 2 / 3 !important; grid-row: 2 / 3 !important; }
@media (max-width: 900px) {
  #about .matrix-grid { grid-template-columns: 1fr !important; }
  #about .matrix-bio-card, #about .matrix-skills-card, #about .matrix-telemetry-card { grid-column: 1 / 2 !important; }
}

/* Bio card: clean row layout (avatar left, info right) filling the wide card */
#about .matrix-bio-card {
  flex-direction: row !important;
  align-items: center !important;
  justify-content: flex-start !important;
  text-align: left !important;
}
#about .bio-hud-container { flex: 0 0 auto !important; }
#about .bio-info { flex: 1 1 auto !important; }
@media (max-width: 900px) {
  #about .matrix-bio-card { flex-direction: column !important; text-align: center !important; }
  #about .bio-tags, #about .bio-socials { justify-content: center !important; }
}

/* Beat [class*="card"] hijacking the title into a dark bar */
#about .matrix-card-title {
  background: transparent !important;
  border: none !important;
  border-bottom: 1px solid rgba(255, 140, 26, 0.15) !important;
  border-radius: 0 !important;
  padding: 0 0 16px 0 !important;
  box-shadow: none !important;
}
[data-theme="light"] #about .matrix-card-title { border-bottom-color: rgba(255,109,0,0.2) !important; }
/* light-mode stat numbers → brand orange (beat fix.css dark override) */
[data-theme="light"] #about .tel-item h4 {
  color: #d45a00 !important; -webkit-text-fill-color: #d45a00 !important;
  background: none !important;
}

/* ============================================================
   New SYS_TELEMETRY HUD (real metrics) + retire the old one
   ============================================================ */
#hud-dashboard, .hud-dashboard-panel { display: none !important; } /* legacy fake HUD */

/* Compact monitor, bottom-right corner */
#cg-hud {
  position: fixed; top: 90px; left: 22px; width: 234px; z-index: 900;
  padding: 13px 15px; border-radius: 16px;
  background: rgba(9,12,20,0.62); border: 1px solid rgba(255,140,26,0.3);
  box-shadow: 0 12px 34px rgba(0,0,0,0.45), 0 0 22px rgba(255,109,0,0.1);
  backdrop-filter: blur(16px) saturate(1.3); -webkit-backdrop-filter: blur(16px) saturate(1.3);
  font-family: 'Space Grotesk','Noto Sans Thai',sans-serif; pointer-events: none;
}
[data-theme="light"] #cg-hud {
  background: rgba(255,255,255,0.82); border-color: rgba(255,109,0,0.28);
  box-shadow: 0 12px 30px rgba(22,32,58,0.12);
}
.cg-hud-head {
  font-size: 0.66rem; font-weight: 700; letter-spacing: 2.5px; color: #ff8c1a;
  display: flex; align-items: center; gap: 8px; margin-bottom: 10px;
}
.cg-hud-dot { width: 7px; height: 7px; border-radius: 50%; background: #ff6d00; box-shadow: 0 0 8px #ff6d00; animation: cg-hud-blink 1.4s infinite alternate; }
@keyframes cg-hud-blink { from { opacity: 1; } to { opacity: 0.25; } }
.cg-hud-main { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.cg-hud-fps { display: flex; align-items: baseline; gap: 5px; }
.cg-hud-fps b { font-size: 2rem; font-weight: 700; line-height: 1;
  background: linear-gradient(90deg,#ff8c1a,#ffd700); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.cg-hud-fps span { font-size: 0.6rem; letter-spacing: 1.5px; color: #8b98ad; }
#hud-spark { width: 120px; height: 40px; display: block; }
.cg-hud-chips { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.cg-hud-chips > div {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px; border-radius: 9px; font-size: 0.66rem;
  background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.06);
}
[data-theme="light"] .cg-hud-chips > div { background: rgba(15,23,42,0.04); border-color: rgba(15,23,42,0.07); }
.cg-hud-chips span { color: #8b98ad; letter-spacing: 0.5px; }
.cg-hud-chips b { color: #ffb84d; font-weight: 700; }
[data-theme="light"] .cg-hud-chips b { color: #d45a00; }
@media (max-width: 1100px) { #cg-hud { display: none !important; } }

/* ============================================================
   Talk-to-the-robot: hide old chat button, add ask bar + answer bubble
   ============================================================ */
#chatbot-toggle, .chatbot-toggle-btn, .chatbot-widget { display: none !important; }

#robot-ask {
  position: fixed; z-index: 961; transform: translate(-50%, 0) scale(0.9);
  display: flex; align-items: center; gap: 6px;
  padding: 6px 6px 6px 14px; border-radius: 999px;
  background: rgba(10,14,24,0.92); border: 1px solid rgba(255,140,26,0.5);
  box-shadow: 0 10px 30px rgba(0,0,0,0.5), 0 0 22px rgba(255,109,0,0.25);
  opacity: 0; pointer-events: none; transition: opacity .25s ease, transform .25s ease;
  backdrop-filter: blur(12px);
}
#robot-ask.visible { opacity: 1; transform: translate(-50%, 0) scale(1); pointer-events: auto; }
[data-theme="light"] #robot-ask { background: rgba(255,255,255,0.96); }
#robot-ask input {
  width: 230px; border: none; outline: none; background: transparent;
  color: #ffe8d1; font-family: 'Outfit','Noto Sans Thai',sans-serif; font-size: 0.92rem;
}
[data-theme="light"] #robot-ask input { color: #16203a; }
#robot-ask input::placeholder { color: rgba(203,213,225,0.6); }
[data-theme="light"] #robot-ask input::placeholder { color: #94a3b8; }
#robot-ask button {
  width: 34px; height: 34px; border-radius: 50%; border: none; cursor: pointer;
  font-size: 0.9rem; display: flex; align-items: center; justify-content: center; transition: transform .15s ease;
}
#robot-ask #robot-ask-send { background: linear-gradient(135deg,#ff6d00,#ff9d00); color: #14100a; }
#robot-ask #robot-ask-send:hover { transform: scale(1.1); }
#robot-ask #robot-ask-close { background: rgba(255,255,255,0.08); color: #cbd5e1; }
[data-theme="light"] #robot-ask #robot-ask-close { background: rgba(15,23,42,0.08); color: #64748b; }

/* Answer bubble — bigger, wraps, scrollable for long replies (still to the LEFT) */
#robot-bubble.answer {
  max-width: 320px; width: max-content; white-space: normal; text-align: left; line-height: 1.5;
  max-height: 260px; overflow-y: auto; padding: 14px 16px; pointer-events: auto;
  transform: translate(-100%, -50%) scale(1);
}
@media (max-width: 760px) {
  #robot-ask input { width: 160px; }
}

/* ============================================================
   Custom cursor — branded arrow + ring-on-clickable (native, no lag)
   ============================================================ */
html, body {
  cursor: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='26'%20height='26'%20viewBox='0%200%2026%2026'%3E%3Cpath%20d='M5%203%20L5%2021%20L10%2016%20L13%2023%20L16%2022%20L13%2015%20L20%2015%20Z'%20fill='%23ff6d00'%20stroke='%23ffffff'%20stroke-width='1.5'%20stroke-linejoin='round'/%3E%3C/svg%3E") 5 3, auto;
}
a, button, .btn, [role="button"], [onclick], label, summary, select,
.project-card, .tab-btn, .social-hex, .nav-links a, .cg-scroll-cue,
#robot-hit, .hamburger, .theme-toggle, #theme-toggle, #lang-toggle {
  cursor: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='30'%20height='30'%20viewBox='0%200%2030%2030'%3E%3Ccircle%20cx='15'%20cy='15'%20r='10'%20fill='rgba(255,109,0,0.12)'%20stroke='%23ff6d00'%20stroke-width='2'/%3E%3Ccircle%20cx='15'%20cy='15'%20r='3'%20fill='%23ffd700'/%3E%3C/svg%3E") 15 15, pointer;
}
input[type="text"], input[type="email"], input[type="password"], input[type="search"], textarea {
  cursor: text;
}
/* touch devices: no custom cursor */
@media (hover: none), (pointer: coarse) {
  html, body, a, button, .btn { cursor: auto; }
}

/* ============================================================
   11. Final polish — a11y focus, grounded marquee, light-mode
   contrast, and a proper mobile experience.  (cg35+)
   ============================================================ */

/* ---- Accessibility: clear keyboard focus on every interactive element ---- */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid #ff8c1a !important;
  outline-offset: 2px !important;
  border-radius: 6px;
}
[data-theme="light"] a:focus-visible,
[data-theme="light"] button:focus-visible {
  outline-color: #d45a00 !important;
}
/* don't show the ring on mouse click, only keyboard */
a:focus:not(:focus-visible),
button:focus:not(:focus-visible) { outline: none !important; }

/* ---- Marquee: sits as a grounded footer strip, no floating gap ---- */
.cg-ticker {
  padding: 16px 0 18px !important;
  background: rgba(6, 9, 16, 0.72) !important;
  border-top: 1px solid rgba(255, 140, 26, 0.28) !important;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 140, 26, 0.12);
}
[data-theme="light"] .cg-ticker {
  background: rgba(255, 255, 255, 0.82) !important;
  border-top: 1px solid rgba(255, 109, 0, 0.32) !important;
  box-shadow: 0 -8px 24px rgba(22, 32, 58, 0.08), inset 0 1px 0 rgba(255, 109, 0, 0.1);
}
[data-theme="light"] .cg-ticker span { color: #47506a !important; font-weight: 700; }

/* ---- Light-mode contrast: make hero + subtitle read crisply ---- */
[data-theme="light"] #home .hero-text,
[data-theme="light"] #home > .hero-content > p { color: #38415a !important; }
[data-theme="light"] .hero-badge {
  color: #c0490b !important;
  background: rgba(255, 109, 0, 0.1) !important;
  border-color: rgba(255, 109, 0, 0.35) !important;
}
[data-theme="light"] .hero-stat-label { color: #5a6478 !important; }

/* ============================================================
   Mobile experience (<= 820px) — designed, not just hidden
   ============================================================ */
@media (max-width: 820px) {
  #home.hero-section.spa-section.spa-active {
    flex-direction: column !important;
    justify-content: center !important;
    text-align: center;
    padding: 96px 6% 96px !important;
  }
  #home .hero-content { margin-right: 0 !important; max-width: 100% !important; }
  .hero-content { text-align: center !important; }
  .hero-title { font-size: clamp(2.1rem, 9vw, 3.2rem) !important; line-height: 1.12 !important; }
  .hero-subtitle { font-size: 1rem !important; }
  .hero-buttons { justify-content: center !important; flex-wrap: wrap; gap: 12px; }
  .hero-buttons .btn { flex: 1 1 auto; min-width: 150px; text-align: center; }
  .hero-stats { justify-content: center !important; flex-wrap: wrap; gap: 18px 26px; }
  .hero-stat-item { min-width: 40%; }
  /* marquee stays but slimmer */
  .cg-ticker { padding: 11px 0 12px !important; }
  .cg-ticker span { font-size: 0.68rem !important; letter-spacing: 0.1em; }
  .cg-ticker-track { gap: 30px !important; }
  /* scroll cue would collide with the marquee on short screens */
  .cg-scroll-cue { display: none !important; }
}

/* very small phones: tighten stats to 2-up and shrink badge */
@media (max-width: 480px) {
  .hero-badge { font-size: 0.72rem !important; }
  .hero-stat-number { font-size: 1.6rem !important; }
  .hero-stat-item { min-width: 44%; }
}

/* Respect users who ask for less motion — freeze the marquee + tech pulses */
@media (prefers-reduced-motion: reduce) {
  .cg-ticker-track { animation: none !important; }
}

/* ============================================================
   12. Studio tag palette — extra colours selectable from
       SSRobotics Studio (tag-red already exists in style.css)
   ============================================================ */
.tag.tag-green  { background: rgba(37,194,110,.14); color:#25c26e; border-color: rgba(37,194,110,.35); }
.tag.tag-blue   { background: rgba(0,180,255,.14);  color:#00b4ff; border-color: rgba(0,180,255,.35); }
.tag.tag-purple { background: rgba(139,92,246,.16); color:#a78bfa; border-color: rgba(139,92,246,.38); }
.tag.tag-gold   { background: rgba(212,160,23,.16); color:#e3b73f; border-color: rgba(212,160,23,.4); }
body[data-theme="light"] .tag.tag-green  { color:#12894a; }
body[data-theme="light"] .tag.tag-blue   { color:#0071a8; }
body[data-theme="light"] .tag.tag-purple { color:#6d3fe0; }
body[data-theme="light"] .tag.tag-gold   { color:#8a6410; }

/* =========================================================================
   Books — "หนังสือแนะนำ" (#books)
   -------------------------------------------------------------------------
   Book covers are portrait (roughly 2:3) and their proportions are the whole
   point of the shelf, so these cards do NOT reuse .project-card — a landscape
   card would crop every spine off. `object-fit`-style cover framing is done
   with background-size:cover on a fixed aspect-ratio box so covers of slightly
   different scans still line up in a row.
   ========================================================================= */
.books-intro {
  max-width: 720px;
  margin: -10px auto 34px;
  text-align: center;
  color: var(--txt-dim, #9aa4bb);
  font-size: 1rem;
  line-height: 1.7;
}

.books-grid {
  display: grid;
  /* 220px, not the 290px the style.css catch-all used to force: 290 is a
     landscape card width and it stretched portrait covers into billboards. */
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--ss-card-gap, 26px);
  margin-top: 1.5rem;
  /* stretch, not start: covers are portrait but blurbs are not all the same
     length, and ragged card bottoms in a row read as a broken grid */
  align-items: stretch;
}

.book-card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  background: rgba(13, 18, 30, .55);
  border: 1px solid rgba(255, 109, 0, .16);
  border-radius: var(--ss-card-radius, 16px);
  overflow: hidden;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: transform .28s cubic-bezier(.2, .7, .3, 1), border-color .28s, box-shadow .28s;
}
.book-card:hover {
  transform: translateY(-6px);
  border-color: rgba(255, 109, 0, .55);
  box-shadow: 0 18px 44px -18px rgba(255, 109, 0, .55);
}
/* a book with no link is not clickable, so it must not pretend to be */
.book-card.no-link { cursor: default; }
.book-card.no-link:hover { transform: none; }

.book-cover-wrap { position: relative; }

.book-cover {
  aspect-ratio: 2 / 3;
  background-size: cover;
  background-position: center;
  background-color: #0a0e18;
  display: grid;
  place-items: center;
  padding: 18px;
}
/* the placeholder is what a book looks like before its real cover is uploaded —
   it has to read as a designed cover, not as a broken image */
.book-cover.no-img { position: relative; }
.book-cover.no-img::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(115deg, rgba(255, 255, 255, .05) 0 1px, transparent 1px 9px),
    linear-gradient(180deg, transparent 55%, rgba(0, 0, 0, .45));
  pointer-events: none;
}
/* the spine — a thin lit edge on the left, which is what sells "this is a book" */
.book-cover.no-img::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 9px;
  background: linear-gradient(90deg, rgba(0, 0, 0, .55), rgba(255, 255, 255, .1));
}
.book-ph {
  position: relative;
  z-index: 1;
  font-family: 'Space Grotesk', 'Noto Sans Thai', sans-serif;
  font-weight: 700;
  font-size: 1.02rem;
  line-height: 1.35;
  text-align: center;
  color: #fff;
  text-shadow: 0 2px 12px rgba(0, 0, 0, .6);
  /* long titles must not spill past the cover */
  display: -webkit-box;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-badge {
  position: absolute;
  top: 10px; left: 10px;
  z-index: 2;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .04em;
  color: #160a00;
  background: linear-gradient(135deg, var(--neon, #ff6d00), var(--neon-2, #ffd700));
  box-shadow: 0 4px 14px -4px rgba(255, 109, 0, .8);
}

.book-info { padding: 16px 16px 18px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.book-info h3 {
  margin: 0;
  font-size: 1.02rem;
  line-height: 1.35;
  font-family: 'Space Grotesk', 'Noto Sans Thai', sans-serif;
}
.book-meta { margin: 0; font-size: .78rem; color: var(--txt-dim, #8d97ad); line-height: 1.5; }
.book-desc {
  margin: 0;
  font-size: .86rem;
  line-height: 1.6;
  color: var(--txt-dim, #9aa4bb);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.book-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.book-go {
  /* auto keeps the call-to-action pinned to the card's bottom edge once the
     cards stretch to a common height */
  margin-top: auto;
  padding-top: 4px;
  font-size: .84rem;
  font-weight: 600;
  color: var(--neon, #ff6d00);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.book-card:hover .book-go { color: var(--neon-2, #ffd700); }
.book-go i { font-size: .78rem; transition: transform .25s; }
.book-card:hover .book-go i { transform: translate(2px, -2px); }

.books-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 46px 20px;
  color: var(--txt-dim, #8d97ad);
  border: 1px dashed rgba(255, 109, 0, .28);
  border-radius: 16px;
}

/* ---------- light theme ---------- */
body[data-theme="light"] .book-card {
  background: rgba(255, 255, 255, .78);
  border-color: rgba(255, 109, 0, .22);
  box-shadow: 0 8px 26px -18px rgba(20, 30, 60, .5);
}
body[data-theme="light"] .book-card:hover {
  border-color: rgba(255, 109, 0, .6);
  box-shadow: 0 18px 40px -20px rgba(255, 109, 0, .5);
}
body[data-theme="light"] .book-meta,
body[data-theme="light"] .book-desc,
body[data-theme="light"] .books-intro { color: #5a6478; }
body[data-theme="light"] .books-empty { color: #5a6478; border-color: rgba(255, 109, 0, .35); }

/* ---------- narrow screens ---------- */
@media (max-width: 900px) {
  .books-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px; }
  .book-info { padding: 13px 13px 15px; }
  .book-info h3 { font-size: .95rem; }
  .book-desc { -webkit-line-clamp: 2; }
}
@media (max-width: 420px) {
  .books-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .book-ph { font-size: .82rem; -webkit-line-clamp: 5; }
  .book-desc { display: none; }
}
