:root {
  color-scheme: light;
}

.site-logo-picture {
  display: contents;
}

/* 系统偏好与手动选择统一由 data-theme 控制。 */
:root[data-theme="dark"] {
  color-scheme: dark;
  --theme-page-bg: #09090b;
  --theme-surface: #18181b;
  --theme-surface-subtle: #111113;
  --theme-surface-muted: #202023;
  --theme-surface-info: #25252a;
  --theme-footer-bg: #111113;
  --theme-border: #303036;
  --theme-border-strong: #52525b;
  --theme-text-strong: #f4f4f5;
  --theme-text: #d4d4d8;
  --theme-text-muted: #a1a1aa;
  --theme-text-dim: #a1a1aa;
  --theme-link: #85c8f0;
  --theme-success-text: #8edbb5;
  --theme-success-bg: #18382e;
  --theme-success-border: #34634f;
  --theme-success-accent: #69bd94;
  --theme-danger-text: #ffb2ba;
  --theme-danger-bg: #3a252e;
  --theme-danger-border: #70404c;
  --theme-danger-accent: #df8792;
  --theme-warning-text: #edcb96;
  --theme-warning-bg: #362f23;
  --theme-warning-badge: #50412b;
  --theme-warning-border: #6d5939;
  --theme-warning-accent: #cda663;
  --theme-overlay: rgba(0, 0, 0, 0.68);
}

:root[data-theme="dark"] body,
:root[data-theme="dark"] .page-shell,
:root[data-theme="dark"] .bg-grid {
  background-image: none;
}

:root[data-theme="dark"] input::placeholder {
  color: var(--theme-text-dim);
  opacity: 1;
}

:root[data-theme="dark"] :is(.primary-button, .code-button, .renew-button,
  .summary-renew-button, .modal-primary, .friend-input-row button, .renewal-help > summary) {
  color: #ffffff;
  background: #4a75a3;
  border-color: #4a75a3;
}

:root[data-theme="dark"] :is(.primary-button, .code-button, .renew-button,
  .summary-renew-button, .modal-primary, .friend-input-row button, .renewal-help > summary):hover:not(:disabled) {
  background: #426b97;
  border-color: #426b97;
}

:root[data-theme="dark"] :is(.primary-button, .code-button, .renew-button,
  .summary-renew-button, .modal-primary, .friend-input-row button, .renewal-help > summary):active:not(:disabled) {
  background: #385d84;
  border-color: #385d84;
}

:root[data-theme="dark"] :is(.primary-button, .code-button, .renew-button,
  .summary-renew-button, .modal-primary, .friend-input-row button, .renewal-help > summary):focus-visible {
  outline: 2px solid #8faec7;
  outline-offset: 3px;
}

:root[data-theme="dark"] :is(.primary-button, .code-button, .renew-button,
  .summary-renew-button, .modal-primary, .friend-input-row button, .renewal-help > summary):disabled {
  color: var(--theme-text-muted);
  background: var(--theme-surface-muted);
  border-color: var(--theme-border);
  opacity: 1;
  box-shadow: none;
}

:root[data-theme="dark"] .renewal-help > summary,
:root[data-theme="dark"] .renewal-help > summary:is(:hover, :active):not(:disabled) {
  border-left-color: rgba(255, 255, 255, 0.18);
}

.header-actions {
  display: flex;
  flex: 1;
  min-width: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 8px 12px;
}

.theme-toggle {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--theme-border-strong, #c6d5e0);
  border-radius: 50%;
  background: var(--theme-surface, #ffffff);
  color: var(--theme-text-muted, #68849b);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 320ms ease, border-color 320ms ease, box-shadow 180ms ease;
}

.theme-icon {
  display: none;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

:root[data-theme="light"] .theme-icon-sun,
:root[data-theme="dark"] .theme-icon-moon {
  display: block;
}

.theme-toggle:hover {
  box-shadow: 0 0 0 3px rgba(105, 157, 193, 0.15);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--theme-link, #2276a7);
  outline-offset: 3px;
}

@media (pointer: coarse) {
  .theme-toggle {
    width: 44px;
    height: 44px;
  }
}

/* 仅过渡颜色，页面原有的布局和弹窗动画继续使用各自的规则。 */
:where(html, body, .page-shell, .pickup-panel, .empty-state-guide,
  .status-strip > div, .rental-summary, .credentials-rows, .verification-card,
  .verification-code-panel, .verification-stats, .tutorial-modal-card,
  .renewal-modal-card, .friend-guide-modal-card, .verification-failure-modal-card,
  .toc-panel, .message, input, h1, h2, h3, p, span, strong, label) {
  transition: background-color 320ms ease, border-color 320ms ease, color 320ms ease;
}

@media (prefers-reduced-motion: reduce) {
  .theme-toggle,
  :where(html, body, .page-shell, .pickup-panel, .empty-state-guide,
    .status-strip > div, .rental-summary, .credentials-rows, .verification-card,
    .verification-code-panel, .verification-stats, .tutorial-modal-card,
    .renewal-modal-card, .friend-guide-modal-card, .verification-failure-modal-card,
    .toc-panel, .message, input, h1, h2, h3, p, span, strong, label) {
    transition: none;
  }
}
