:root {
  --action-ink: #67384b;
  --action-tint: #f1e5e4;
  --menu-sheet: #fffcf6;
  --menu-text: #392f35;
  --menu-line: #cdbfb5;
  /* Motion follows Apple's springs: SwiftUI Spring(duration: d, bounce: b) has stiffness (2π/d)²
     and damping ratio 1 − b. Each curve samples its spring over 1.2 × d, so a use with a CSS
     duration of 1.2 × d moves like that spring and settles within 0.5%.
     Smooth (bounce 0) suits fades, colors, sheets and large turns. Snappy (bounce .15) answers
     hover and press. Bouncy (bounce .3) is for small marks and icons that confirm a choice. */
  --ease-smooth: cubic-bezier(.2,.12,.12,1.04);
  --ease-snappy: cubic-bezier(.26,.28,.12,1.16);
  --ease-bouncy: cubic-bezier(.32,.48,.08,1.24);
  /* Spring durations: d .2 for color and opacity, .25 for a control's response, .3 for appearing. */
  --motion-quick: .24s;
  --motion-press: .3s;
  --motion-open: .36s;
}
@supports (transition-timing-function: linear(0, 1)) {
  :root {
    --ease-smooth: linear(0, 0.005 1.4%, 0.02 2.9%, 0.046 4.5%, 0.083 6.3%, 0.163 9.6%, 0.359 16.7%, 0.451 20.3%,
      0.539 23.9%, 0.615 27.6%, 0.679 31.1%, 0.735 34.6%, 0.784 38.4%, 0.826 42.2%, 0.868 46.9%, 0.903 52.1%,
      0.931 57.7%, 0.953 63.9%, 0.97 70.9%, 0.982 78.8%, 0.99 88.3%, 1);
    --ease-snappy: linear(0, 0.006 1.5%, 0.023 3%, 0.053 4.8%, 0.096 6.7%, 0.137 8.3%, 0.188 10.1%, 0.41 17.4%,
      0.508 20.8%, 0.602 24.3%, 0.682 27.8%, 0.747 31.1%, 0.803 34.4%, 0.852 37.9%, 0.892 41.4%, 0.929 45.7%,
      0.958 50.3%, 0.979 55.4%, 0.994 61%, 1.002 67%, 1.006 74.2%, 1);
    --ease-bouncy: linear(0, 0.007 1.6%, 0.028 3.3%, 0.063 5.1%, 0.112 7.1%, 0.161 8.8%, 0.223 10.8%, 0.472 18.1%,
      0.579 21.4%, 0.68 24.8%, 0.764 28.1%, 0.832 31.1%, 0.889 34.3%, 0.937 37.4%, 0.975 40.7%, 1.005 44.3%,
      1.026 48%, 1.04 52.2%, 1.046 56.8%, 1.043 63.7%, 1.012 85.3%, 1);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --action-ink: #f1c4d1;
  --action-tint: #49343f;
  --menu-sheet: #312a31;
  --menu-text: #f3e9e1;
  --menu-line: #69585e;
}
:where(img,button,summary,[role=button],[role=tab],nav a,.book-bar a,.entry-action,.board-write-link,a[download],.guide-actions a) {
  -webkit-user-select: none; user-select: none;
}
book-theme-toggle { display: inline-flex; flex: none; vertical-align: middle; }
book-theme-toggle .theme-toggle {
  anchor-name: --theme-trigger;
  display: inline-grid; place-items: center; width: var(--control-size); height: var(--control-size); min-height: var(--control-size);
  padding: 0; color: var(--action-ink); background: transparent; border: 0; border-radius: 50%; cursor: pointer;
}
book-theme-toggle .theme-toggle:is(:hover, :focus-visible), book-theme-toggle:has(:popover-open) .theme-toggle { background: var(--action-tint); }
.theme-toggle use { opacity: 0; transform: scale(.66) rotate(-22deg); transform-origin: 12px 12px; }
[data-theme-choice="system"] .theme-system, [data-theme-choice="light"] .theme-light, [data-theme-choice="dark"] .theme-dark { opacity: 1; transform: none; }
book-theme-toggle .theme-panel {
  box-sizing: border-box; position: fixed; inset: auto; margin: 0; padding: var(--space-1);
  width: 176px; border: 1px solid var(--menu-line); border-radius: 12px;
  font: 500 .9rem/1.3 var(--book-body-font); color: var(--menu-text); background: var(--menu-sheet);
  box-shadow: 0 4px 20px #23172025;
}
@supports (top: anchor(bottom)) {
  .theme-panel { position-anchor: --theme-trigger; }
  book-theme-toggle .theme-panel { top: calc(anchor(bottom) + 5px); right: anchor(right); position-try-fallbacks: flip-block, flip-inline; }
}
.theme-panel > strong { display: block; padding: var(--space-2); font-size: var(--support-size); }
.theme-panel > button {
  display: grid; grid-template-columns: 18px 1fr 16px; align-items: center; gap: var(--space-2); width: 100%; min-height: var(--control-size);
  padding: 0 var(--space-2); color: inherit; background: transparent; border: 0; border-radius: 6px; text-align: start; font: inherit; cursor: pointer;
}
.theme-panel > button:is(:hover,[aria-pressed="true"]) { color: var(--action-ink); background: var(--action-tint); }
.theme-panel button:not([aria-pressed="true"]) svg:last-child { visibility: hidden; }
.theme-panel svg, .theme-toggle svg { pointer-events: none; }
.book-search-symbol { display: grid; pointer-events: none; }
.book-search-symbol svg { grid-area: 1 / 1; }
.book-search-symbol svg:last-child, [aria-expanded="true"] > .book-search-symbol svg:first-child { opacity: 0; rotate: -45deg; scale: .7; }
[aria-expanded="true"] > .book-search-symbol svg:last-child { opacity: 1; rotate: 0deg; scale: 1; }
:is(.board-archive,.first-visit,.archive,.sheet > details) > summary { display: flex; align-items: center; gap: .55em; }
:is(.board-archive,.first-visit,.archive,.sheet > details) > summary::-webkit-details-marker { display: none; }
:is(.board-archive,.first-visit,.archive,.sheet > details) > summary::before {
  content: ""; width: .85em; height: .85em; flex: none; color: inherit;
  background: linear-gradient(currentColor,currentColor) center / 100% 2px no-repeat,
    linear-gradient(currentColor,currentColor) center / 2px 100% no-repeat;
}
:is(.board-archive,.first-visit,.archive,.sheet > details)[open] > summary::before {
  background-size: 100% 2px,2px 0;
}
.guide-actions, .entry-heading { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.entry-heading { margin-bottom: .65rem; }
.entry-heading h2 { margin: 0; }
.sheet > header > book-theme-toggle { margin-inline-start: auto; }

/* This mark has no hit area. The native control handles press, release and focus. */
.book-press-mark {
  position: fixed; z-index: 2147483647; pointer-events: none; user-select: none; box-sizing: border-box;
  width: 22px; height: 22px; margin: -11px; border: 1.5px solid currentColor; border-radius: 50%;
}
@media (prefers-reduced-motion: no-preference) {
  .theme-toggle use { transition: transform var(--motion-open) var(--ease-bouncy), opacity var(--motion-quick) var(--ease-smooth); }
  .book-search-symbol svg { transition: opacity var(--motion-quick) var(--ease-smooth), rotate var(--motion-press) var(--ease-snappy), scale var(--motion-press) var(--ease-bouncy); }
  :is(.board-archive,.first-visit,.archive,.sheet > details) > summary::before { transition: background-size var(--motion-press) var(--ease-smooth); }
  :where(a, button, summary, label) > :is(.ui-icon,svg[aria-hidden="true"]), .book-wordmark, .photo-action-caption, .theme-swatch::after {
    transition: scale var(--motion-press) var(--ease-bouncy), rotate var(--motion-press) var(--ease-bouncy);
  }
  :where(a, button:enabled, summary, label):active > :is(.ui-icon,svg[aria-hidden="true"],.book-wordmark,.photo-action-caption) { scale: .86; }
  :where(a[href],summary):hover { text-decoration-thickness: .12em; }
  .directory-search-row:not([hidden]), dialog[open] > :first-child, [popover]:popover-open > strong, :where(.board-archive,.first-visit,.archive,.mw-section)[open] > :not(summary), .post-notice, .account-notice {
    animation: sheet-ink-in var(--motion-open) var(--ease-smooth);
  }
  .theme-option input:checked + .theme-swatch::after,
  #sort-options [aria-pressed="true"] svg,
  .theme-panel [aria-pressed="true"] svg:last-child { animation: ink-set var(--motion-open) var(--ease-bouncy); }
  :where(.directory-search,.wiki-bar,.board-form-grid,.profile-form,.comment-form)
    :is(input,textarea,select) { transition: border-color var(--motion-quick) var(--ease-smooth); }
  :where(.directory-search,.wiki-bar,.board-form-grid,.profile-form,.comment-form)
    :is(input,textarea,select):focus-visible { border-color: var(--action-ink); }
  :where(p,li,dd,footer) a[href] { transition: text-underline-offset var(--motion-quick) var(--ease-smooth); }
  :where(p,li,dd,footer) a[href]:hover { text-underline-offset: .3em; }
  @media (hover: hover) and (pointer: fine) {
    .book-utilities > :is(a,button):hover > svg, .directory-sort > button:hover > svg,
    .entry-action:hover svg, .downloads a:hover svg { scale: 1.09; rotate: -5deg; }
    .book-brand:hover .book-wordmark { scale: 1.025; }
  }
}
@keyframes sheet-ink-in { from { opacity: .55; } to { opacity: 1; } }
@keyframes ink-set { from { scale: .65 .85; opacity: .5; } to { scale: 1; opacity: 1; } }
@media (forced-colors: active) {
  :is(.board-archive,.first-visit,.archive,.sheet > details) > summary::before {
    content: "+"; background: none; line-height: .85; text-align: center;
  }
  :is(.board-archive,.first-visit,.archive,.sheet > details)[open] > summary::before { content: "−"; }
}
@media (prefers-reduced-motion: reduce) {
  :root *, :root *::before, :root *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
:root { scroll-padding-block-start: calc(var(--header-offset, 0px) + .5rem); }
header[data-scroll-header] {
  position: sticky; top: 0; z-index: 4;
  transition: translate var(--motion-open) var(--ease-smooth);
}
header[data-scroll-header][data-away]:not(:has(:focus-visible,:popover-open,[aria-expanded="true"])) { translate: 0 calc(-100% - 5px); }
:root:has([aria-modal="true"]) header[data-scroll-header] { z-index: 0; }
@media (prefers-reduced-motion: reduce) { header[data-scroll-header] { transition: none; } }

::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) {
  animation-duration: var(--motion-quick); animation-timing-function: var(--ease-smooth);
}
/* The new page covers the previous one as it appears, so the two never show at half strength.
   The snappy spring clamps at full opacity, which ends the fade without a lingering trace. */
::view-transition-old(root) { animation: none; mix-blend-mode: normal; }
::view-transition-new(root) { animation-name: page-in; mix-blend-mode: normal; animation-timing-function: var(--ease-snappy); }
@keyframes page-in { from { opacity: 0; } }
