.theme-toggle {
  position: fixed !important;
  top: 18px !important;
  right: 18px !important;
  left: auto !important;
  bottom: auto !important;
  z-index: 1000 !important;
  width: 44px !important;
  height: 44px !important;
  margin: 0 !important;
  padding: 0 !important;
  display: grid !important;
  place-items: center !important;
  border-radius: 999px !important;
  border: 1px solid rgba(0, 0, 0, 0.12) !important;
  background: #ffffff !important;
  color: #2c1c42 !important;
  box-shadow: 0 2px 10px rgba(26, 35, 50, 0.14) !important;
  cursor: pointer !important;
  -webkit-appearance: none !important;
  appearance: none !important;
  font: inherit !important;
  transition: transform 0.25s ease, background 0.25s ease, color 0.25s ease, border-color 0.25s ease !important;
}

.theme-toggle:hover {
  transform: rotate(-18deg) scale(1.05) !important;
}

.theme-toggle:focus-visible {
  outline: none !important;
  border-color: rgba(124, 58, 237, 0.42) !important;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.18), 0 2px 10px rgba(26, 35, 50, 0.14) !important;
}

.theme-toggle svg {
  width: 22px !important;
  height: 22px !important;
  display: block !important;
}

.theme-toggle .icon-moon {
  display: none !important;
}

:root[data-theme="dark"] .theme-toggle {
  background: #1d1924 !important;
  color: #ecebf0 !important;
  border-color: rgba(151, 129, 190, 0.25) !important;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5) !important;
}

:root[data-theme="dark"] .theme-toggle:focus-visible {
  border-color: rgba(151, 129, 190, 0.5) !important;
  box-shadow: 0 0 0 3px rgba(116, 85, 183, 0.2), 0 2px 10px rgba(0, 0, 0, 0.5) !important;
}

:root[data-theme="dark"] .theme-toggle .icon-sun {
  display: none !important;
}

:root[data-theme="dark"] .theme-toggle .icon-moon {
  display: block !important;
}


/* Dark theme applies to the form UI only; exported cards stay light. */
:root[data-theme="dark"] body {
  color: #ecebf0;
}

:root[data-theme="dark"] .sub {
  color: #aaa4b5;
  border-top-color: rgba(151, 129, 190, 0.24);
}

:root[data-theme="dark"] .form-card {
  background: #1d1924;
  border-color: rgba(151, 129, 190, 0.25);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.24);
}

:root[data-theme="dark"] .q-number {
  color: #aa8be8;
}

:root[data-theme="dark"] .q-label {
  color: #ecebf0;
}

:root[data-theme="dark"] .radio-option {
  background: #25202f;
  border-color: rgba(151, 129, 190, 0.22);
}

:root[data-theme="dark"] .radio-option:active {
  background: #2d2639;
}

:root[data-theme="dark"] .radio-text {
  color: #ded9e6;
}

:root[data-theme="dark"] .radio-option input[type="radio"] {
  border-color: #9483b5;
}

:root[data-theme="dark"] .radio-option input[type="radio"]:checked {
  border-color: #8968cc;
  background-color: #8968cc;
  box-shadow: inset 0 0 0 3px #25202f;
}

:root[data-theme="dark"] .radio-option:has(input:checked) {
  background: #302740;
  border-color: rgba(170, 139, 232, 0.52);
}

:root[data-theme="dark"] textarea,
:root[data-theme="dark"] input[type="text"],
:root[data-theme="dark"] input[type="number"] {
  background: #25202f;
  border-color: rgba(151, 129, 190, 0.24);
  color: #ecebf0;
}

:root[data-theme="dark"] textarea::placeholder,
:root[data-theme="dark"] input::placeholder {
  color: #918a9d;
}

:root[data-theme="dark"] textarea:focus,
:root[data-theme="dark"] input:focus {
  border-color: #8968cc;
  box-shadow: 0 0 0 3px rgba(116, 85, 183, 0.22);
}

:root[data-theme="dark"] .age-input-wrapper,
:root[data-theme="dark"] .char-hint,
:root[data-theme="dark"] .export-hint {
  color: #aaa4b5;
}

.export-hint {
  display: none !important;
}

.submit-area {
  margin-top: 10px;
}

.site-footer {
  margin-top: 14px !important;
}

:root[data-theme="dark"] .site-footer {
  color: #aaa4b5;
}

:root[data-theme="dark"] .github-link {
  color: #aaa4b5;
}

:root[data-theme="dark"] .site-footer a {
  color: #aaa4b5;
}

:root[data-theme="dark"] .github-link:hover {
  color: #aa8be8;
}

:root[data-theme="dark"] .site-footer a:hover {
  color: #aa8be8;
}

:root[data-theme="dark"] #output-card {
  background: #ffffff;
  color: #2c1c42;
}

/* ── Scrollbar ── */
:root {
  --survey-scrollbar-source: #7c3aed;
  --survey-scrollbar-thumb: color-mix(in srgb, var(--survey-scrollbar-source) 38%, white);
  --survey-scrollbar-thumb-hover: var(--survey-scrollbar-source);
}

:root[data-theme="dark"] {
  --survey-scrollbar-source: #8968cc;
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--survey-scrollbar-thumb) transparent;
}

/* 避免标准属性覆盖自定义滚动条伪元素样式。 */
@supports selector(::-webkit-scrollbar) {
  * {
    scrollbar-width: auto;
    scrollbar-color: auto;
  }
}

*::-webkit-scrollbar {
  width: 6px !important;
  height: 6px !important;
  background: transparent !important;
}

*::-webkit-scrollbar-track,
*::-webkit-scrollbar-corner {
  background: transparent !important;
}

*::-webkit-scrollbar-button {
  display: none !important;
}

*::-webkit-scrollbar-thumb {
  background: var(--survey-scrollbar-thumb) !important;
  border-radius: 999px !important;
}

*::-webkit-scrollbar-thumb:hover,
*::-webkit-scrollbar-thumb:active {
  background: var(--survey-scrollbar-thumb-hover) !important;
}

/* 移动端滚动条仅在滑动时显现 */
@media (hover: none), (pointer: coarse) {
  * {
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
  }

  @supports selector(::-webkit-scrollbar) {
    * {
      scrollbar-width: auto;
      scrollbar-color: auto;
    }
  }

  *::-webkit-scrollbar-thumb {
    background: transparent !important;
    transition: background 0.25s ease;
  }

  html.is-scrolling *::-webkit-scrollbar-thumb {
    background: var(--survey-scrollbar-thumb) !important;
  }

  html.is-scrolling * {
    scrollbar-color: var(--survey-scrollbar-thumb) transparent;
  }
}

html.survey-overlay-scrollbar {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

html.survey-overlay-scrollbar::-webkit-scrollbar {
  width: 0 !important;
  height: 0 !important;
  display: none !important;
}

.survey-overlay-thumb {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 900;
  width: 6px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--survey-scrollbar-thumb);
  touch-action: none;
}

.survey-overlay-thumb:hover,
.survey-overlay-thumb:active,
.survey-overlay-thumb.is-dragging {
  background: var(--survey-scrollbar-thumb-hover);
}

.survey-overlay-thumb:focus {
  outline: none;
}

.survey-overlay-thumb:focus-visible {
  outline: 2px solid var(--survey-scrollbar-thumb-hover);
  outline-offset: 1px;
}

.survey-overlay-thumb[hidden] {
  display: none !important;
}

@media print {
  .survey-overlay-thumb {
    display: none !important;
  }
}

@media (forced-colors: active) {
  html.survey-overlay-scrollbar {
    scrollbar-width: thin;
    scrollbar-color: CanvasText Canvas;
  }

  html.survey-overlay-scrollbar::-webkit-scrollbar {
    display: block !important;
    width: 6px !important;
    height: 6px !important;
  }

  .survey-overlay-thumb {
    display: none !important;
  }
}

@media (max-width: 620px) {
  .theme-toggle {
    top: 12px !important;
    right: 12px !important;
    width: 40px !important;
    height: 40px !important;
  }
}
