* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  min-height: 100%;
}

/* themed scrollbars (shared toolkit look) */
* {
  scrollbar-width: thin;
  scrollbar-color: #3a4150 #1b1e24;
}
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
*::-webkit-scrollbar-track {
  background: #1b1e24;
}
*::-webkit-scrollbar-thumb {
  background: #3a4150;
  border-radius: 5px;
  border: 2px solid #1b1e24;
}
*::-webkit-scrollbar-thumb:hover {
  background: #4a5568;
}

body {
  font-family:
    "Segoe UI",
    system-ui,
    -apple-system,
    Roboto,
    "Helvetica Neue",
    Arial,
    "Noto Sans",
    "PingFang SC",
    "Hiragino Sans",
    "Microsoft YaHei",
    "Microsoft JhengHei",
    "Yu Gothic UI",
    Meiryo,
    "Malgun Gothic",
    "Apple SD Gothic Neo",
    "Leelawadee UI",
    Thonburi,
    "Noto Sans Thai",
    sans-serif;
  background: #14161a;
  color: #d8dbe0;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 40px 20px;
  /* NOTE: no decorative background here — everything decorative lives in the
     fixed .bg layer so overscroll/bounce never reveals untinted areas */
}

/* Language-specific preferred fonts (html[lang] is set by the i18n system) */
:lang(zh-Hans) { font-family: "Segoe UI", system-ui, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif; }
:lang(zh-Hant) { font-family: "Segoe UI", system-ui, "PingFang TC", "Hiragino Sans CNS", "Microsoft JhengHei", "Noto Sans TC", sans-serif; }
:lang(ja) { font-family: "Segoe UI", system-ui, "Hiragino Sans", "Yu Gothic UI", Meiryo, "Noto Sans JP", sans-serif; }
:lang(ko) { font-family: "Segoe UI", system-ui, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif; }
:lang(th) { font-family: "Segoe UI", system-ui, "Leelawadee UI", Thonburi, "Noto Sans Thai", sans-serif; }
/* Thai stacked diacritics need extra line height to avoid clipping */
:lang(th) .subtitle,
:lang(th) .card .desc,
:lang(th) .group-desc,
:lang(th) footer {
  line-height: 1.7;
}

/* ----- language selector ----- */
#lang-switch {
  position: fixed;
  top: 14px;
  right: 16px;
  z-index: 40;
  font-size: 13px;
}
#lang-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  font: inherit;
  background: rgba(27, 30, 36, 0.92);
  border: 1px solid #2a2e36;
  border-radius: 8px;
  color: #9aa3b0;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
#lang-btn:hover {
  background: #2a2e36;
  color: #d8dbe0;
}
#lang-btn:focus-visible {
  outline: 2px solid #2d6cdf;
  outline-offset: 2px;
}
#lang-btn svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}
#lang-btn .chev {
  width: 11px;
  height: 11px;
  transition: transform 0.15s;
}
#lang-switch.open #lang-btn .chev {
  transform: rotate(180deg);
}
#lang-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0; /* right-aligned with the trigger so it never leaves the viewport */
  margin: 0;
  padding: 6px;
  list-style: none;
  min-width: 172px;
  max-height: min(430px, calc(100vh - 70px));
  overflow-y: auto;
  background: #1b1e24;
  border: 1px solid #3a4150;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity 0.14s ease, transform 0.14s ease;
}
#lang-switch.open #lang-menu {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}
#lang-menu li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 10px;
  border-radius: 6px;
  color: #d8dbe0;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s;
}
#lang-menu li:hover {
  background: #2a2e36;
}
#lang-menu li.active {
  color: #7ec8ff;
}
#lang-menu li.active::after {
  content: "✓";
  font-size: 11px;
}
@media (prefers-reduced-motion: reduce) {
  #lang-menu,
  #lang-btn .chev {
    transition: none;
  }
}

/* ----- themed background layer ----- */
/* Everything lives in one fixed, non-interactive layer behind the content.
   Animations only touch transform/opacity (compositor-friendly), so the
   page stays lightweight even on GitHub Pages + mobile. */
.bg {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
  /* the soft tint gradients — fixed to the viewport (not the document), so
     they cover the visible screen at all times, including elastic overscroll */
  background-image:
    radial-gradient(
      1000px 500px at 50% -10%,
      rgba(45, 108, 223, 0.14),
      transparent 70%
    ),
    radial-gradient(
      800px 400px at 50% 110%,
      rgba(126, 200, 255, 0.07),
      transparent 70%
    );
}
main {
  position: relative;
  z-index: 1;
}

/* faint blueprint grid, faded toward the edges so it never competes with
   the cards */
.bg-grid {
  position: absolute;
  inset: 0;
  /* minor lines every 56px, brighter major lines every 4th cell */
  background-image:
    linear-gradient(rgba(126, 200, 255, 0.16) 1px, transparent 1px),
    linear-gradient(90deg, rgba(126, 200, 255, 0.16) 1px, transparent 1px),
    linear-gradient(rgba(126, 200, 255, 0.09) 1px, transparent 1px),
    linear-gradient(90deg, rgba(126, 200, 255, 0.09) 1px, transparent 1px);
  background-size:
    224px 224px,
    224px 224px,
    56px 56px,
    56px 56px;
  -webkit-mask-image: radial-gradient(
    ellipse 85% 80% at 50% 45%,
    #000 35%,
    transparent 100%
  );
  mask-image: radial-gradient(
    ellipse 85% 80% at 50% 45%,
    #000 35%,
    transparent 100%
  );
}

/* two large soft glows drifting very slowly */
.bg-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  will-change: transform;
}
.bg-glow-a {
  width: 560px;
  height: 560px;
  left: -140px;
  top: -160px;
  background: radial-gradient(
    circle,
    rgba(45, 108, 223, 0.28),
    transparent 65%
  );
  animation: glow-drift-a 26s ease-in-out infinite alternate;
}
.bg-glow-b {
  width: 500px;
  height: 500px;
  right: -120px;
  bottom: -140px;
  background: radial-gradient(
    circle,
    rgba(126, 200, 255, 0.18),
    transparent 65%
  );
  animation: glow-drift-b 32s ease-in-out infinite alternate;
}
@keyframes glow-drift-a {
  from {
    transform: translate(0, 0);
  }
  to {
    transform: translate(90px, 60px);
  }
}
@keyframes glow-drift-b {
  from {
    transform: translate(0, 0);
  }
  to {
    transform: translate(-80px, -50px);
  }
}

/* floating wireframe primitives (cube / triangle / sphere — the shapes the
   toolkit generates). Kept at very low opacity near the viewport edges. */
.bg-shape {
  position: absolute;
  stroke: #7ec8ff;
  fill: none;
  stroke-width: 1.5;
  opacity: 0.18;
  filter: drop-shadow(0 0 6px rgba(126, 200, 255, 0.35));
  will-change: transform;
  animation: shape-float 18s ease-in-out infinite alternate;
}
.bg-cube {
  width: 130px;
  left: 6%;
  top: 16%;
  animation-duration: 22s;
}
.bg-tri {
  width: 90px;
  right: 9%;
  top: 22%;
  animation-duration: 17s;
  animation-delay: -6s;
}
.bg-sphere {
  width: 110px;
  left: 12%;
  bottom: 12%;
  animation-duration: 26s;
  animation-delay: -11s;
}
.bg-cube2 {
  width: 70px;
  right: 15%;
  bottom: 18%;
  animation-duration: 19s;
  animation-delay: -3s;
}
@keyframes shape-float {
  from {
    transform: translateY(-14px) rotate(-4deg);
  }
  to {
    transform: translateY(14px) rotate(5deg);
  }
}

/* accessibility: no motion for users who ask for none */
@media (prefers-reduced-motion: reduce) {
  .bg-glow,
  .bg-shape {
    animation: none;
  }
}

/* small screens: the cards fill most of the viewport — hide the floating
   shapes so nothing peeks through gaps, keep the grid + glows */
@media (max-width: 640px) {
  .bg-shape {
    display: none;
  }
}

main {
  width: 100%;
  max-width: 1160px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

/* ----- header ----- */
header {
  text-align: center;
  margin-bottom: 40px;
}
header h1 {
  margin: 0 0 12px;
  font-size: clamp(26px, 4.5vw, 38px);
  letter-spacing: 0.5px;
  color: #e6e9ee;
  font-weight: 700;
}
header h1 .accent {
  color: #7ec8ff;
}
header .subtitle {
  margin: 0 auto;
  max-width: 560px;
  font-size: 15px;
  line-height: 1.55;
  color: #9aa3b0;
}

/* ----- tool groups ----- */
/* Tools are grouped into titled sections so the page keeps its structure as
   more links are added. Each section owns a compact card grid. */
.group {
  width: 100%;
}
.group + .group {
  margin-top: 36px;
}
.group-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 14px;
  margin: 0 0 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid #2a2e36;
}
.group-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: #e6e9ee;
}
/* small accent bar in front of every section title */
.group-title::before {
  content: "";
  flex: none;
  width: 4px;
  height: 15px;
  border-radius: 2px;
  background: #2d6cdf;
}
.group-title code {
  font-family: inherit;
  color: #7ec8ff;
}
.group-desc {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: #8d97a7;
}
.group-desc code {
  font-family: inherit;
  color: #b7bec9;
}

/* ----- tool cards ----- */
.cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  width: 100%;
}

.card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #1b1e24;
  border: 1px solid #2a2e36;
  border-radius: 12px;
  padding: 18px 18px 16px;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    border-color 0.18s ease;
}
.card:hover,
.card:focus-visible {
  transform: translateY(-3px);
  border-color: #2d6cdf;
  box-shadow:
    0 10px 30px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(45, 108, 223, 0.35);
  outline: none;
}

/* icon + title share one row to keep the cards short */
.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.card .icon {
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(45, 108, 223, 0.16);
  border: 1px solid rgba(45, 108, 223, 0.35);
}
.card .icon svg {
  width: 20px;
  height: 20px;
  stroke: #7ec8ff;
  fill: none;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.card h3 {
  margin: 0;
  font-size: 15.5px;
  line-height: 1.3;
  color: #e6e9ee;
  font-weight: 650;
}
.card h3 code {
  font-family: inherit;
  color: #7ec8ff;
  font-weight: inherit;
}
.card .desc {
  margin: 0 0 16px;
  font-size: 13px;
  line-height: 1.5;
  color: #b7bec9;
}
/* compact pill link instead of a full-width button — lighter at scale, and
   it fills with the accent color when the card is hovered/focused */
.card .btn {
  margin-top: auto;
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(45, 108, 223, 0.14);
  border: 1px solid rgba(45, 108, 223, 0.4);
  color: #7ec8ff;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.2px;
  transition:
    background 0.15s,
    color 0.15s,
    border-color 0.15s;
}
.card:hover .btn,
.card:focus-visible .btn {
  background: #2d6cdf;
  border-color: #2d6cdf;
  color: #fff;
}
.card .btn svg {
  width: 13px;
  height: 13px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.18s ease;
}
.card:hover .btn svg {
  transform: translateX(3px);
}

/* ----- footer ----- */
footer {
  margin: 44px auto 0;
  font-size: 11.5px;
  color: #8d97a7;
  text-align: center;
  line-height: 1.6;
  max-width: 640px;
}
footer a {
  color: #7ec8ff;
  text-decoration: none;
}
footer a:hover {
  text-decoration: underline;
}

/* ----- responsive ----- */
/* three columns on desktop, two on tablets, one on phones */
@media (max-width: 1000px) {
  .cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
/* clear space under the fixed language selector so it can never sit on top
   of the centered page title on narrow screens */
@media (max-width: 900px) {
  body {
    padding-top: 72px;
  }
}
@media (max-width: 640px) {
  body {
    padding: 72px 16px 32px;
  }
  header {
    margin-bottom: 28px;
  }
  .group + .group {
    margin-top: 28px;
  }
  .cards {
    grid-template-columns: 1fr;
  }
}
