:root {
  --theme-background: #ffffff;
  --theme-sidebar-background: #f6f8fa;
  --theme-surface: #ffffff;
  --theme-surface-muted: #f6f8fa;
  --theme-surface-subtle: #f0f2f4;
  --theme-text: #24292f;
  --theme-text-muted: #57606a;
  --theme-border: #d0d7de;
  --theme-link: #0969da;
  --theme-link-active: #0550ae;
  --theme-control: #57606a;
  --theme-control-hover: #24292f;
  --theme-accent: #0969da;
  --theme-error: #cf222e;
  --theme-search-mark: #fff1a8;
  --theme-shadow: rgba(27, 31, 36, 0.15);

  --pf-text: var(--theme-text);
  --pf-text-secondary: var(--theme-text-muted);
  --pf-text-muted: var(--theme-text-muted);
  --pf-background: var(--theme-surface);
  --pf-border: var(--theme-border);
  --pf-border-focus: var(--theme-link);
  --pf-skeleton: var(--theme-surface-muted);
  --pf-skeleton-shine: var(--theme-surface-subtle);
  --pf-hover: var(--theme-surface-muted);
  --pf-mark: var(--theme-text);
  --pf-outline-focus: var(--theme-link);
  --pf-shadow-sm: 0 2px 8px var(--theme-shadow);
}

:root[data-theme="dark"] {
  --theme-background: #242424;
  --theme-sidebar-background: #2d2d2d;
  --theme-surface: #2d2d2d;
  --theme-surface-muted: #363636;
  --theme-surface-subtle: #464646;
  --theme-text: #e3e3e3;
  --theme-text-muted: #b3b3b3;
  --theme-border: #464646;
  --theme-link: #76b7ff;
  --theme-link-active: #9acaff;
  --theme-control: #b3b3b3;
  --theme-control-hover: #ffffff;
  --theme-accent: #2f81f7;
  --theme-error: #ff8a80;
  --theme-search-mark: #6b5c16;
  --theme-shadow: rgba(0, 0, 0, 0.35);
}

html,
body,
.book,
.book-body,
.book-body .body-inner {
  background: var(--theme-background);
  color: var(--theme-text);
}

.book-header {
  background: var(--theme-background);
  color: var(--theme-text-muted);
  height: 100px;
  position: relative;
}

.book-header .btn {
  color: var(--theme-control);
}

.book-header .btn:hover,
.book-header .btn:focus {
  color: var(--theme-control-hover);
}

.book-header .btn.theme-toggle {
  background: transparent;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  left: 8px;
  margin: 0;
  position: absolute;
  top: 50px;
  width: 44px;
}

.book-header .theme-toggle:focus-visible {
  box-shadow: inset 0 0 0 2px var(--theme-link) !important;
}

.theme-toggle__label {
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

:root[data-theme="dark"] .theme-toggle__icon--dark,
:root[data-theme="dark"] .theme-toggle__label--dark,
:root[data-theme="light"] .theme-toggle__icon--light,
:root[data-theme="light"] .theme-toggle__label--light {
  display: none;
}

.book-summary {
  background: var(--theme-sidebar-background);
  border-right-color: var(--theme-border);
  color: var(--theme-text);
}

.book-summary ul.summary li a,
.book-summary ul.summary li span,
.book-summary ul.summary li.done > a {
  color: var(--theme-text);
}

.book-summary ul.summary li.header {
  color: var(--theme-text-muted);
}

.book-summary ul.summary li.active > a {
  color: var(--theme-link-active);
}

.book-summary ul.summary li.divider {
  background: var(--theme-border);
}

#book-search-input {
  background: var(--theme-surface);
  border-bottom-color: var(--theme-border);
  border-top-color: var(--theme-border);
  position: relative;
}

#book-search-input pagefind-input {
  width: 100%;
}

#book-search-input .pf-input {
  padding-inline-end: 70px !important;
}

.search-shortcut {
  align-items: center;
  background: var(--theme-surface-muted);
  border: 1px solid var(--theme-border);
  border-radius: 4px;
  color: var(--theme-text-muted);
  display: flex;
  font-size: 10px;
  height: 20px;
  line-height: 1;
  padding: 0 5px;
  pointer-events: none;
  position: absolute;
  right: 14px;
  top: 14px;
}

#site-search-input:has(.pf-input:not(:placeholder-shown)) + .search-shortcut {
  display: none;
}

#book-search-results .search-results {
  display: none;
}

body.with-search #book-search-results .search-noresults {
  display: none;
}

body.with-search #book-search-results .search-results {
  display: block;
}

#book-search-results pagefind-summary {
  margin-bottom: 16px;
}

#book-search-results pagefind-keyboard-hints {
  border-top: 1px solid var(--theme-border);
  margin-top: 20px;
  padding-top: 12px;
}

#book-search-results .pf-result-card,
#book-search-results .pf-heading-chip {
  background: var(--theme-surface);
}

#book-search-results .pf-result-title,
#book-search-results .pf-result-excerpt,
#book-search-results .pf-heading-excerpt {
  white-space: normal;
}

#book-search-results .pf-result-excerpt mark,
#book-search-results .pf-heading-excerpt mark,
.markdown-section mark.pagefind-highlight {
  background: var(--theme-search-mark);
  border-radius: 2px;
  color: var(--theme-text);
  font-weight: 600;
  padding: 0 2px;
}

body.search-loading #book-search-results .search-results {
  opacity: 0.65;
}

body.search-unavailable #book-search-input::after {
  color: var(--theme-error);
  content: "搜索暂不可用";
  display: block;
  font-size: 12px;
  padding: 6px 7px 0;
}

@media (max-width: 600px) {
  .search-shortcut {
    display: none;
  }

  #book-search-input .pf-input {
    padding-inline-end: 36px !important;
  }
}

.markdown-section {
  color: var(--theme-text);
}

.markdown-section a {
  color: var(--theme-link);
}

.markdown-section h6,
.markdown-section blockquote {
  color: var(--theme-text-muted);
}

.markdown-section code,
.markdown-section pre {
  background: var(--theme-surface-muted);
  color: var(--theme-text);
}

.markdown-section table td,
.markdown-section table th {
  border-color: var(--theme-border);
}

.markdown-section table tr {
  background: var(--theme-surface);
  border-top-color: var(--theme-border);
}

.markdown-section table tr:nth-child(2n) {
  background: var(--theme-surface-muted);
}

.markdown-section blockquote {
  border-left-color: var(--theme-border);
}

.markdown-section hr {
  background: var(--theme-border);
}

.page-inner .btn-group .btn,
.button {
  background: var(--theme-surface-muted);
  color: var(--theme-text-muted);
}

.button:hover,
.navigation:hover {
  color: var(--theme-control-hover);
}

.navigation {
  color: var(--theme-control);
}

.dropdown-menu {
  background: var(--theme-surface);
  border-color: var(--theme-border);
  box-shadow: 0 6px 12px var(--theme-shadow);
}

.dropdown-menu .dropdown-caret .caret-outer {
  border-bottom-color: var(--theme-border);
}

.dropdown-menu .dropdown-caret .caret-inner {
  border-bottom-color: var(--theme-surface);
}

.password-gate {
  background: var(--theme-background);
}

.password-gate__panel {
  background: var(--theme-surface);
  border-color: var(--theme-border);
  box-shadow: 0 8px 24px var(--theme-shadow);
}

.password-gate__title {
  color: var(--theme-text);
}

.password-gate__input {
  background: var(--theme-background);
  border-color: var(--theme-border);
  color: var(--theme-text);
}

.password-gate__input:focus {
  border-color: var(--theme-link);
  outline: 2px solid transparent;
}

.password-gate__button {
  background: var(--theme-accent);
  color: #ffffff;
}

.password-gate__error {
  color: var(--theme-error);
}

::selection {
  background: var(--theme-link);
  color: #ffffff;
}
