/* ==========================================================================
   uhm docs — warm-dark system, lifted verbatim from docs/demo/demo.css and
   applied on top of docsify's dark.css layout base.
   OKLCH is the source of truth; hex values are approximate sRGB equivalents.
   ========================================================================== */

:root {
  --bg: oklch(0.085 0 0);            /* #141414 near-black page */
  --surface: oklch(0.145 0.008 25.7);/* #252220 warm card surface */
  --surface-2: oklch(0.175 0.01 25.7);/* slightly raised surface */
  --ink: oklch(0.96 0.006 25.7);     /* #f4f1ee near-white text */
  --muted: oklch(0.72 0.018 25.7);   /* #b1a39a muted warm gray */
  --primary: oklch(0.665 0.222 25.7);/* #ec5a3c coral brand */
  --accent: oklch(0.78 0.12 205);    /* #69c2d0 cyan focus */
  --rule: oklch(0.29 0.018 25.7);    /* #4a4441 hairline */
  --font-ui: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --theme-color: var(--primary);
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --mobile-header-height: calc(3.5rem + env(safe-area-inset-top, 0px));
  --z-backdrop: 30;
  --z-drawer: 35;
  --z-header: 40;
  --z-skip-link: 50;
}

* { box-sizing: border-box; }

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.6;
}

::selection { background: color-mix(in oklch, var(--primary) 30%, transparent); }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

a { color: var(--primary); text-decoration: none; text-underline-offset: 0.2em; }
a:hover { color: var(--ink); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  inset-block-start: var(--space-3);
  inset-inline-start: var(--space-3);
  z-index: var(--z-skip-link);
  padding: var(--space-2) var(--space-3);
  border-radius: 8px;
  background: var(--ink);
  color: var(--bg);
  font-weight: 700;
  transform: translateY(calc(-100% - 2rem));
}
.skip-link:focus { transform: translateY(0); }

/* ---------- Sidebar ------------------------------------------------------- */

aside.sidebar,
.sidebar {
  background: var(--bg);
  border-right: 1px solid var(--rule);
  color: var(--muted);
  padding: 1.5rem 0 1rem;
}

.sidebar-nav { padding: 0 1.25rem; }

.sidebar ul { margin: 0; }
.sidebar ul li { font-size: 0.9rem; line-height: 1.5; }
.sidebar ul li a {
  color: var(--muted);
  font-weight: 500;
  min-height: 2rem;
  padding: 0.28rem 0;
  display: flex;
  align-items: center;
}
.sidebar ul li a:hover { color: var(--ink); }
.sidebar ul li.active > a { color: var(--primary); font-weight: 600; }
.sidebar ul li ul { padding-left: 0.85rem; margin: 0.15rem 0 0.5rem; }
.sidebar ul li strong {
  display: block;
  margin: 1.1rem 0 0.35rem;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 620;
  opacity: 0.8;
}

.sidebar-section-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 2.25rem;
  margin: 0.65rem 0 0.2rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: 620 0.7rem/1.3 var(--font-ui);
  letter-spacing: 0.08em;
  text-align: start;
  text-transform: uppercase;
  cursor: pointer;
}
.sidebar-section-toggle::after {
  content: "+";
  color: var(--primary);
  font: 600 1rem/1 var(--font-mono);
}
.sidebar-section-toggle[aria-expanded="true"]::after { content: "−"; }
.sidebar-section-toggle:hover { color: var(--ink); }

/* brand wordmark at top of sidebar: "uhm" + a coral period */
.app-name { padding: 0 1.25rem 1rem; }
.app-name a,
.app-name-link {
  color: var(--ink) !important;
  font-size: 1.25rem !important;
  font-weight: 760;
  letter-spacing: -0.025em;
}
.app-name a::after { content: "."; color: var(--primary); }

/* sidebar search */
.sidebar .search { margin: 0 1.25rem 0.75rem; }
.sidebar .search .input-wrap input {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 8px;
  color: var(--ink);
  font-family: var(--font-ui);
  min-height: 2.75rem;
  padding: 0.55rem 0.7rem;
}
.sidebar .search .input-wrap input:focus { border-color: var(--primary); outline: none; }
.sidebar .search .clear-button { color: var(--muted); }
.sidebar .search h3 {
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0.75rem 0 0.25rem;
}
.sidebar .search p { font-size: 0.85rem; color: var(--muted); }
.sidebar .search a { color: var(--ink); font-weight: 500; }
.sidebar .search a:hover { color: var(--primary); }
.sidebar .search .matching-post { border-bottom: 1px solid var(--rule); padding: 0.4rem 0; }

/* ---------- Content ------------------------------------------------------- */

.content,
section.content { background: var(--bg); }
.markdown-section {
  max-width: 50rem;
  padding: 2.5rem 2.25rem 5rem;
  color: var(--ink);
}

.markdown-section h1,
.markdown-section h2,
.markdown-section h3,
.markdown-section h4 {
  color: var(--ink);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.markdown-section h1 {
  font-size: 2.4rem;
  letter-spacing: -0.035em;
  margin: 0 0 1.25rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--rule);
}
.markdown-section h2 {
  font-size: 1.5rem;
  margin: 2.5rem 0 0.9rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--rule);
}
.markdown-section h3 { font-size: 1.15rem; margin: 1.8rem 0 0.6rem; }
.markdown-section h4 { font-size: 1rem; color: var(--muted); margin: 1.4rem 0 0.4rem; }

.markdown-section p { margin: 0.85rem 0; }
.markdown-section ul,
.markdown-section ol { margin: 0.85rem 0; padding-left: 1.25rem; }
.markdown-section li { margin: 0.3rem 0; }

.markdown-section strong { color: var(--ink); font-weight: 650; }
.markdown-section em { color: var(--ink); }

.markdown-section img { border-radius: 12px; box-shadow: 0 0 0 1px var(--rule); }

.markdown-section hr { border: 0; border-top: 1px solid var(--rule); margin: 2rem 0; }

/* blockquote → callout / note */
.markdown-section blockquote {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  color: var(--muted);
  margin: 1.25rem 0;
}
.markdown-section blockquote p { margin: 0.3rem 0; color: var(--ink); }

/* tables — docsify's base theme stripes even rows with #f8f8f8 (light); with
   near-white text that is white-on-white and unreadable. The theme rule is
   `.markdown-section tr:nth-child(2n){background-color:#f8f8f8}` (specificity
   0,2,2, no !important). Repaint with our dark surface tokens and !important so
   that stripe can never win the cascade. */
.markdown-section table {
  display: table;
  width: 100%;
  border-collapse: collapse;
  margin: 1.25rem 0;
  font-size: 0.92rem;
}
/* odd rows: no background set — the dark page background shows through */
/* even rows: a subtle band a shade above the page background */
.markdown-section table tbody tr:nth-child(2n),
.markdown-section table tbody tr:nth-child(2n) > th,
.markdown-section table tbody tr:nth-child(2n) > td {
  background-color: var(--surface) !important;
}
/* hover: a raised surface; higher specificity than the even-row rule so it
   wins on both odd and even rows */
.markdown-section table tbody tr:hover > th,
.markdown-section table tbody tr:hover > td,
.markdown-section table tbody tr:nth-child(2n):hover > th,
.markdown-section table tbody tr:nth-child(2n):hover > td {
  background-color: var(--surface-2) !important;
}
.markdown-section th,
.markdown-section td {
  border-bottom: 1px solid var(--rule);
  padding: 0.55rem 0.75rem;
  text-align: left;
  vertical-align: top;
}
.markdown-section th {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 620;
  border-bottom: 2px solid var(--rule);
}

/* inline code */
.markdown-section code,
.markdown-section p code,
.markdown-section li code,
.markdown-section td code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--surface);
  padding: 0.12em 0.4em;
  border-radius: 6px;
  color: var(--ink);
}

/* fenced code blocks — the .player-region card recipe from the demo */
.markdown-section pre {
  background: var(--surface);
  border: 0;
  border-radius: 14px;
  box-shadow: 0 0 0 1px var(--rule);
  padding: 1rem 1.1rem;
  margin: 1.25rem 0;
  overflow: auto;
}
.markdown-section pre > code {
  background: none;
  box-shadow: none;
  padding: 0;
  overflow: visible;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--ink);
}

/* ---------- Cover page ---------------------------------------------------- */

section.cover,
.cover {
  background: var(--bg) !important;
}
.cover .mask { background: var(--bg) !important; opacity: 1 !important; }

.cover.show .cover-main,
section.cover.show .cover-main {
  width: min(46rem, calc(100% - 2rem));
  max-width: 46rem;
  margin-inline: auto;
}

section.cover .cover-title {
  color: var(--ink);
  font-size: 3.5rem;
  font-weight: 760;
  letter-spacing: -0.04em;
  line-height: 0.95;
  margin: 0 0 var(--space-4);
  text-align: center;
}
section.cover .cover-title .dot { color: var(--primary); }

section.cover blockquote {
  color: var(--muted);
  font-size: 1.2rem;
  border: 0;
  background: none;
  padding: 0;
  margin: 0 0 0.75rem;
  line-height: 1.5;
}
section.cover blockquote p { color: var(--muted); }
section.cover > .cover-main > p:not(.cover-title):not(.cover-meta) {
  max-width: 38rem;
  margin-inline: auto;
  color: var(--muted);
  font-size: 1rem;
  text-wrap: pretty;
}

/* cover CTAs (docsify renders the link list as buttons; scope to list items so
   the .app-name-link wordmark above stays a plain wordmark, not a pill) */
.cover-main li a {
  display: flex;
  min-height: 2.75rem;
  align-items: center;
  justify-content: center;
  color: var(--ink) !important;
  font-weight: 600;
  font-family: var(--font-ui);
  font-size: 0.95rem;
  padding: 0.6rem 1.15rem;
  margin: 0;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--surface);
  transition: border-color 0.12s ease, color 0.12s ease, background 0.12s ease;
}
.cover-main li:first-child a {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--bg) !important;
}
.cover-main li:first-child a:hover {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--bg) !important;
}
.cover-main li:last-child a {
  border-color: transparent;
  background: transparent;
  color: var(--muted) !important;
}
.cover-main li:last-child a:hover { color: var(--ink) !important; }
.cover-main li a:hover {
  color: var(--ink) !important;
  border-color: var(--primary);
  background: var(--surface-2);
}

.cover .cover-meta {
  margin-top: 2rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}
section.cover .cover-main ul {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-3);
  max-width: none;
  margin: var(--space-6) auto;
  padding: 0;
  list-style: none;
}

/* ---------- GitHub corner & pagination ------------------------------------ */

.github-corner svg { width: 3.5rem; height: 3.5rem; fill: var(--primary); color: var(--bg); }

/* ---------- Immediate mobile shell --------------------------------------- */

.mobile-header,
.sidebar-backdrop { display: none; }

.sidebar-toggle { display: none !important; }

.mobile-wordmark {
  display: flex;
  min-height: 2.75rem;
  align-items: center;
  color: var(--ink);
  font-size: 1.1rem;
  font-weight: 760;
  letter-spacing: -0.025em;
}
.mobile-wordmark span { color: var(--primary); }

.mobile-header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.mobile-source {
  display: flex;
  min-height: 2.75rem;
  align-items: center;
  padding-inline: var(--space-2);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.mobile-menu-button {
  display: grid;
  width: 2.75rem;
  height: 2.75rem;
  place-items: center;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.mobile-menu-button:hover { border-color: var(--primary); background: var(--surface-2); }
.mobile-menu-button:active { transform: translateY(1px); }

.menu-icon {
  display: flex;
  width: 1rem;
  flex-direction: column;
  gap: 3px;
}
.menu-icon > span {
  width: 100%;
  height: 2px;
  border-radius: 1px;
  background: currentColor;
  transition: transform 0.18s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.12s ease-out;
}
.mobile-menu-button[aria-expanded="true"] .menu-icon > span:first-child {
  transform: translateY(5px) rotate(45deg);
}
.mobile-menu-button[aria-expanded="true"] .menu-icon > span:nth-child(2) { opacity: 0; }
.mobile-menu-button[aria-expanded="true"] .menu-icon > span:last-child {
  transform: translateY(-5px) rotate(-45deg);
}

.app-nav { color: var(--muted); }
.app-nav a { color: var(--muted); }
.app-nav a:hover { color: var(--ink); }

.pagination .pagination-item a { color: var(--muted); }
.pagination .pagination-item a:hover { color: var(--primary); }

/* ---------- Edit-page footer & copy-code button --------------------------- */

.edit-page {
  margin: 2.5rem 0 0;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  font-size: 0.82rem;
}
.edit-page a { color: var(--muted); }
.edit-page a:hover { color: var(--primary); }

/* docsify-copy-code button (class name is docsify-copy-code-button) */
.docsify-copy-code-button {
  background: var(--surface-2) !important;
  border: 1px solid var(--rule) !important;
  border-radius: 6px !important;
  color: var(--muted) !important;
  font-family: var(--font-ui) !important;
  font-size: 0.72rem !important;
  padding: 0.15rem 0.5rem !important;
  transition: color 0.12s ease, border-color 0.12s ease;
}
.docsify-copy-code-button:hover { color: var(--ink) !important; border-color: var(--primary) !important; }
.docsify-copy-code-button.success { color: var(--accent) !important; border-color: var(--accent) !important; }

/* ---------- Scrollbars ---------------------------------------------------- */

* { scrollbar-width: thin; scrollbar-color: var(--rule) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 8px; }
*::-webkit-scrollbar-thumb:hover { background: var(--muted); }
*::-webkit-scrollbar-track { background: transparent; }

/* ---------- Responsive ---------------------------------------------------- */

@media (max-width: 42rem) {
  .markdown-section { padding: calc(var(--mobile-header-height) + 1.5rem) 1.25rem 4rem; }
  .markdown-section h1 { font-size: 1.9rem; }
  .markdown-section pre { padding: 0.85rem; border-radius: 12px; }

  section.cover .cover-title { font-size: 2.75rem; }

  section.cover .cover-main ul {
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
  }

  .comparison-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }
  .comparison-table,
  .comparison-table tbody,
  .comparison-table tr,
  .comparison-table td { display: block; width: 100%; }
  .comparison-table tr {
    padding-block: var(--space-2);
    border-bottom: 1px solid var(--rule);
  }
  .comparison-table td {
    padding: var(--space-2) 0;
    border: 0;
  }
  .comparison-table td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: var(--space-1);
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 650;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }
}

@media (max-width: 48rem) {
  .mobile-header {
    position: fixed;
    inset: 0 0 auto;
    z-index: var(--z-header);
    display: flex;
    height: var(--mobile-header-height);
    align-items: flex-end;
    justify-content: space-between;
    padding: env(safe-area-inset-top, 0px) max(var(--space-3), env(safe-area-inset-right, 0px)) 0 max(var(--space-4), env(safe-area-inset-left, 0px));
    border-bottom: 1px solid var(--rule);
    background: var(--bg);
  }

  section.cover {
    min-height: 100svh;
    min-height: 100dvh;
    padding: calc(var(--mobile-header-height) / 2) var(--space-4) var(--space-8);
  }

  aside.sidebar,
  .sidebar {
    position: fixed;
    inset: var(--mobile-header-height) auto 0 0;
    z-index: var(--z-drawer);
    width: min(20rem, calc(100vw - 3rem));
    padding-top: var(--space-4);
    transform: translateX(-100%);
    transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
  }
  body.close:not(.nav-open) .sidebar { transform: translateX(-100%); }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open { overflow: hidden; }

  .sidebar-backdrop {
    position: fixed;
    inset: var(--mobile-header-height) 0 0;
    z-index: var(--z-backdrop);
    background: rgb(0 0 0 / 68%);
  }
  body.nav-open .sidebar-backdrop { display: block; }

  .sidebar .search { margin-inline: var(--space-4); }
  .sidebar .app-name { display: none; }
  .sidebar .search .input-wrap input { width: 100%; }
  .sidebar-nav { padding-inline: var(--space-4); }
  .sidebar ul { margin-inline-start: 0; }
  .sidebar ul li { margin-inline-end: 0; }
  .sidebar ul li a { min-height: 2.75rem; }
  .sidebar-section-toggle { min-height: 2.75rem; margin-top: var(--space-2); }

  .github-corner { display: none; }
}

@media (pointer: coarse) {
  .sidebar ul li a,
  .sidebar-section-toggle,
  .docsify-copy-code-button { min-height: 2.75rem; }
}

/* Respect users who prefer less motion (the chrome is already static). */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
