.nav-end,
.nav-tools {
  display: flex;
  align-items: center;
}

.nav-end {
  gap: 12px;
}

.nav-tools {
  gap: 7px;
}

.nav-tool {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text-soft);
  background: rgba(255, 255, 255, 0.035);
  cursor: pointer;
  transition: color 160ms ease, border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.nav-tool:hover {
  color: var(--text);
  border-color: rgba(110, 203, 255, 0.36);
  background: rgba(110, 203, 255, 0.08);
  transform: translateY(-1px);
}

.nav-tool:focus-visible,
.menu-button:focus-visible {
  outline: 2px solid var(--blue-bright);
  outline-offset: 3px;
}

.nav-tool svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-tool-value {
  min-width: 11px;
  color: var(--teal);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: -0.04em;
}

.theme-toggle .icon-moon {
  display: none;
}

html[data-theme="light"] .theme-toggle .icon-sun {
  display: none;
}

html[data-theme="light"] .theme-toggle .icon-moon {
  display: block;
}

.stage-signature {
  position: absolute;
  right: 188px;
  bottom: -19px;
  z-index: 3;
  width: 330px;
  height: 76px;
  pointer-events: none;
  color: rgba(206, 244, 255, 0.94);
  filter: drop-shadow(0 5px 14px rgba(30, 169, 209, 0.22));
}

.signature-glyphs {
  position: absolute;
  top: 2px;
  left: 8px;
  width: 318px;
  height: 40px;
  display: block;
  overflow: hidden;
  background: currentColor;
  mask-position: left center;
  mask-repeat: no-repeat;
  mask-size: contain;
  -webkit-mask-position: left center;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-size: contain;
  clip-path: inset(0 100% 0 0);
  animation: signature-write 5.4s cubic-bezier(0.22, 0.72, 0.25, 1) infinite;
}

.signature-glyphs-zh {
  mask-image: url("assets/signature-zh.svg");
  -webkit-mask-image: url("assets/signature-zh.svg");
}

.signature-glyphs-en {
  display: none;
  mask-image: url("assets/signature-en.svg");
  -webkit-mask-image: url("assets/signature-en.svg");
}

html[data-language="en"] .signature-glyphs-zh {
  display: none;
}

html[data-language="en"] .signature-glyphs-en {
  display: block;
}

.signature-underline-svg {
  position: absolute;
  right: 2px;
  bottom: 0;
  width: 318px;
  height: 31px;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.signature-underline-svg path {
  stroke-dasharray: 270;
  stroke-dashoffset: 270;
  animation: signature-underline 5.4s ease-in-out infinite;
}

.stage-signature .signature-flourish {
  stroke-dasharray: 42;
  stroke-dashoffset: 42;
  animation-name: signature-flourish;
}

html[data-theme="light"] .stage-signature {
  color: rgba(19, 103, 145, 0.94);
  filter: drop-shadow(0 5px 12px rgba(24, 123, 173, 0.16));
}

.slot-number {
  height: 1em;
  display: inline-flex;
  align-items: flex-start;
  overflow: hidden;
  line-height: 1;
  letter-spacing: -0.045em;
  animation: slot-number-visibility 4.6s ease-in-out infinite;
}

.chip-speed .slot-number span {
  margin-top: 0;
  color: inherit;
  font-size: inherit;
}

.slot-reel {
  width: 0.58em;
  height: 1em;
  display: inline-block;
  overflow: hidden;
}

.slot-track {
  display: flex;
  flex-direction: column;
  transform: translateY(-4em);
  will-change: transform, filter;
  animation: slot-reel-drop 4.6s cubic-bezier(0.2, 0.72, 0.2, 1) infinite both;
  animation-delay: calc(var(--slot-order) * 65ms);
}

.slot-track i {
  height: 1em;
  flex: 0 0 1em;
  display: block;
  color: inherit;
  font: inherit;
  line-height: 1;
  text-align: center;
}

.slot-dot {
  width: 0.28em;
  height: 1em;
  display: inline-block;
  line-height: 0.9;
  text-align: center;
}

html[lang="en"] .hero h1 {
  font-size: clamp(40px, 3.1vw, 48px);
  letter-spacing: -0.065em;
}

html[lang="en"] .hero-lead {
  max-width: 600px;
}

html[lang="en"] .feature-card h3 {
  letter-spacing: -0.035em;
}

.language-marquee span {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  transition: color 180ms ease, border-color 180ms ease, background 180ms ease, box-shadow 220ms ease;
}

.language-marquee span::after {
  content: "";
  position: absolute;
  right: 12px;
  bottom: 3px;
  left: 12px;
  height: 1px;
  border-radius: 999px;
  opacity: 0;
  transform: scaleX(0.25);
  background: linear-gradient(90deg, transparent, var(--key-accent) 24%, var(--key-accent) 76%, transparent);
  pointer-events: none;
}

.language-marquee span.is-lit {
  z-index: 1;
  color: #efffff;
  border-color: var(--key-accent);
  background: var(--key-fill);
  animation: workbench-key-light var(--key-light-duration) cubic-bezier(0.2, 0.78, 0.2, 1);
}

.language-marquee span.is-lit::after {
  animation: workbench-key-led var(--key-light-duration) ease-out;
}

html[data-theme="light"] .language-marquee span.is-lit {
  color: #12354d;
  border-color: var(--key-accent);
  background: rgba(230, 249, 255, 0.96);
}

@keyframes slot-number-visibility {
  0%, 4%, 100% { opacity: 0; filter: blur(2px); }
  10%, 84% { opacity: 1; filter: blur(0); }
  91% { opacity: 0; filter: blur(1px); }
}

@keyframes workbench-key-light {
  0% { transform: translateY(0) scale(0.98); box-shadow: 0 0 0 rgba(0, 0, 0, 0); }
  14% { transform: translateY(-2px) scale(1.035); box-shadow: 0 0 0 1px var(--key-accent), 0 0 22px var(--key-glow), inset 0 -8px 16px var(--key-fill); }
  48% { transform: translateY(-1px) scale(1.018); box-shadow: 0 0 0 1px var(--key-accent), 0 0 16px var(--key-glow), inset 0 -6px 13px var(--key-fill); }
  100% { transform: translateY(0) scale(1); box-shadow: 0 0 9px var(--key-glow); }
}

@keyframes workbench-key-led {
  0%, 100% { opacity: 0; transform: scaleX(0.25); }
  18%, 62% { opacity: 1; transform: scaleX(1); box-shadow: 0 0 9px var(--key-glow); }
}

@keyframes signature-write {
  0%, 9% { opacity: 0; clip-path: inset(0 100% 0 0); transform: translateY(3px); }
  32%, 78% { opacity: 1; clip-path: inset(0 0 0 0); transform: translateY(0); }
  88%, 100% { opacity: 0; clip-path: inset(0 0 0 0); transform: translateY(-1px); }
}

@keyframes signature-underline {
  0%, 27% { opacity: 0; stroke-dashoffset: 270; }
  35%, 78% { opacity: 0.82; stroke-dashoffset: 0; }
  88%, 100% { opacity: 0; stroke-dashoffset: 0; }
}

@keyframes signature-flourish {
  0%, 38% { opacity: 0; stroke-dashoffset: 42; }
  46%, 78% { opacity: 0.82; stroke-dashoffset: 0; }
  88%, 100% { opacity: 0; stroke-dashoffset: 0; }
}

@keyframes slot-reel-drop {
  0%, 8% { transform: translateY(-4em); filter: blur(1.5px); }
  37% { transform: translateY(0.13em); filter: blur(0.3px); }
  43% { transform: translateY(-0.05em); filter: blur(0); }
  49%, 88% { transform: translateY(0); filter: blur(0); }
  89%, 100% { transform: translateY(-4em); filter: blur(1.5px); }
}

@media (max-width: 1600px) and (min-width: 981px) {
  .chip-speed {
    right: 76px;
  }

  .stage-signature {
    right: 236px;
  }
}

@media (max-width: 980px) {
  .nav-end {
    gap: 8px;
  }

  .site-nav a {
    padding-inline: 10px;
  }

  .nav-tool {
    width: 38px;
    height: 38px;
  }
}

@media (max-width: 760px) {
  .nav-end,
  .nav-tools {
    gap: 6px;
  }

  .nav-tool {
    width: 36px;
    height: 36px;
    border-radius: 11px;
  }

  .nav-tool svg {
    width: 17px;
    height: 17px;
  }

  .language-toggle {
    width: 43px;
  }

  .menu-button {
    margin-left: 1px;
  }

  html[lang="en"] .hero h1 {
    font-size: clamp(30px, 8vw, 40px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .language-marquee span.is-lit {
    animation-name: workbench-key-light-reduced;
  }

  .signature-glyphs,
  .signature-underline-svg path,
  .slot-number,
  .slot-track {
    animation-duration: 7s;
  }
}

@keyframes workbench-key-light-reduced {
  0%, 100% { box-shadow: 0 0 4px var(--key-glow); }
  40%, 65% { box-shadow: 0 0 11px var(--key-glow); }
}
