.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-height: 42px;
  padding: 10px 15px;
  border: 1px solid rgba(145, 203, 255, 0.18);
  border-radius: 999px;
  background: rgba(18, 33, 58, 0.82);
  color: #ffffff;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 800;
  cursor: pointer;
  line-height: 1.2;
  position: relative;
  z-index: 5;
  appearance: none;
  -webkit-appearance: none;
  -webkit-tap-highlight-color: rgba(153, 204, 255, 0.28);
  user-select: none;
  touch-action: manipulation;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.theme-toggle::before {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: inherit;
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(0, 210, 255, 0.5);
  background: rgba(27, 52, 88, 0.92);
  color: #99ccff;
  outline: none;
}

.top-nav .theme-toggle {
  min-height: 44px;
  padding: 12px 18px;
  border: 1px solid rgba(145, 203, 255, 0.22);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(35, 57, 90, 0.94) 0%, rgba(18, 31, 53, 0.94) 100%);
  color: #e6eefb;
  font-size: 14px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 12px 22px rgba(0, 0, 0, 0.18);
}

html[data-trr-theme="light"] .theme-toggle {
  min-height: 34px;
  padding: 8px 13px;
  border: 0;
  border-radius: 10px;
  background: #4477aa;
  color: #ffffff;
  font-size: 12px;
  box-shadow: none;
}

html[data-trr-theme="light"] .top-nav .theme-toggle {
  min-height: 44px;
  padding: 12px 18px;
  border: 1px solid rgba(255, 255, 255, 0.20);
  border-radius: 999px;
  background: #4477aa;
  color: #ffffff;
  font-size: 14px;
}

html[data-trr-theme="light"] .top-nav .theme-toggle:hover,
html[data-trr-theme="light"] .top-nav .theme-toggle:focus-visible {
  background: #225588;
  color: #99ccff;
}

html[data-trr-theme="light"] .theme-toggle:hover,
html[data-trr-theme="light"] .theme-toggle:focus-visible {
  background: #225588;
  color: #99ccff;
}

.hmenu .theme-toggle {
  width: 100%;
}

@media (max-width: 640px) {
  .topbar,
  .hero-topbar {
    position: relative;
    z-index: 80;
    overflow: visible;
  }

  .nav,
  .top-nav {
    position: relative;
    z-index: 90;
    overflow: visible;
  }

  .nav .theme-toggle,
  .top-nav .theme-toggle {
    display: flex;
    width: auto;
    flex: 0 0 auto;
    min-height: 42px;
    margin-top: 4px;
    padding: 10px 15px;
    border-radius: 999px;
    font-size: 0.9rem;
    line-height: 1.15;
    pointer-events: auto;
    position: relative;
    z-index: 120;
    touch-action: manipulation;
  }

  html[data-trr-theme="light"] .nav .theme-toggle,
  html[data-trr-theme="light"] .top-nav .theme-toggle {
    width: auto;
    flex: 0 0 auto;
    min-height: 34px;
    padding: 8px 13px;
    border-radius: 10px;
    font-size: 12px;
  }
}
