/* Balm theme documentation. One stylesheet for every page. */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("inter-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #ffffff;
  --bg-soft: #f6f5f2;
  --bg-code: #f1efea;
  --text: #1c1c1e;
  --muted: #5d6068;
  --border: #e4e2dd;
  --accent: #245c4c;
  --accent-soft: #e6f0ec;
  --warn-bg: #fff6e5;
  --warn-border: #e5b95c;
  --focus: #2563eb;
  --topbar-h: 60px;
  --sidebar-w: 264px;
  --radius: 10px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141517;
    --bg-soft: #1c1d20;
    --bg-code: #24262a;
    --text: #e9e9eb;
    --muted: #a3a6ad;
    --border: #2e3035;
    --accent: #86c9b3;
    --accent-soft: #1d2d28;
    --warn-bg: #2c2415;
    --warn-border: #8a6a2a;
    --focus: #7aa7ff;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-padding-top: calc(var(--topbar-h) + 16px); -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  font-feature-settings: "cv11", "ss01";
}

a { color: var(--accent); text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

code, kbd {
  font-family: var(--mono);
  font-size: 0.86em;
  background: var(--bg-code);
  border-radius: 5px;
  padding: 0.1em 0.35em;
  overflow-wrap: anywhere;
}

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

.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 100;
  background: var(--text); color: var(--bg);
  padding: 8px 14px; border-radius: 8px; text-decoration: none;
}
.skip-link:focus { top: 10px; }

/* ------------------------------------------------------------ top bar */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 16px;
  height: var(--topbar-h);
  padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; white-space: nowrap; }
.brand__mark {
  display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--text); color: var(--bg);
  font-weight: 700; font-size: 16px;
}
.brand__name { font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }
.brand__sub { color: var(--muted); font-size: 15px; }

.nav-toggle {
  display: none;
  align-items: center; gap: 8px;
  min-height: 40px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text);
  font: inherit; font-size: 14px; cursor: pointer;
}
.nav-toggle__bars, .nav-toggle__bars::before, .nav-toggle__bars::after {
  display: block; width: 16px; height: 2px; background: currentColor; border-radius: 2px; position: relative;
}
.nav-toggle__bars::before, .nav-toggle__bars::after { content: ""; position: absolute; left: 0; }
.nav-toggle__bars::before { top: -5px; }
.nav-toggle__bars::after { top: 5px; }

.search { position: relative; margin-left: auto; width: min(380px, 100%); }
.no-js .search { display: none; }
.search input {
  width: 100%; height: 40px;
  padding: 0 38px 0 14px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--bg-soft); color: var(--text);
  font: inherit; font-size: 15px;
}
.search input::placeholder { color: var(--muted); }
.search input:focus { outline: 2px solid var(--focus); outline-offset: 1px; background: var(--bg); }
.search__key { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 12px; }
.search input:focus ~ .search__key { display: none; }

.search-results {
  position: absolute; right: 0; top: calc(100% + 8px);
  width: min(560px, calc(100vw - 32px));
  max-height: min(70vh, 560px); overflow: auto;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.16);
  padding: 6px;
}
.search-results__count { margin: 6px 10px 8px; font-size: 13px; color: var(--muted); }
.search-results ul { list-style: none; margin: 0; padding: 0; }
.search-results a {
  display: block; padding: 10px 12px; border-radius: 8px;
  color: inherit; text-decoration: none;
}
.search-results a:hover, .search-results a:focus { background: var(--accent-soft); outline: none; }
.search-results .r-title { display: block; font-weight: 600; }
.search-results .r-page { display: block; font-size: 12.5px; color: var(--accent); margin-top: 1px; }
.search-results .r-snip { display: block; font-size: 13.5px; color: var(--muted); margin-top: 3px; line-height: 1.45; }
.search-results mark { background: color-mix(in srgb, var(--accent) 22%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }

/* ------------------------------------------------------------ layout */
.layout { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }

.sidebar {
  position: sticky; top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h)); height: calc(100dvh - var(--topbar-h));
  overflow-y: auto; overscroll-behavior: contain;
  padding: 24px 16px 40px 20px;
  border-right: 1px solid var(--border);
}
.nav, .nav ul { list-style: none; margin: 0; padding: 0; }
.nav > li { margin: 2px 0; }
.nav > li > a {
  display: block; padding: 7px 12px; border-radius: 8px;
  color: var(--text); text-decoration: none; font-weight: 500; font-size: 15px;
}
.nav > li > a:hover { background: var(--bg-soft); }
.nav > li.current > a { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.toc { margin: 4px 0 10px 12px !important; padding-left: 10px !important; border-left: 1px solid var(--border); }
.toc a {
  display: block; padding: 4px 8px; font-size: 13.5px; line-height: 1.4;
  color: var(--muted); text-decoration: none; border-radius: 6px;
}
.toc a:hover { color: var(--text); background: var(--bg-soft); }

.content { min-width: 0; padding: 40px clamp(20px, 5vw, 64px) 32px; }
.content:focus { outline: none; }
.doc { max-width: 980px; }
.doc p, .doc ul, .doc ol { max-width: 76ch; }

/* ------------------------------------------------------------ type */
h1, h2, h3, h4 { line-height: 1.25; letter-spacing: -0.015em; }
h1 { font-size: clamp(30px, 4vw, 40px); margin: 0 0 12px; letter-spacing: -0.025em; }
h2 { font-size: 26px; margin: 56px 0 14px; padding-top: 8px; }
h3 { font-size: 19px; margin: 36px 0 10px; }
h4 { font-size: 16px; margin: 26px 0 8px; }
.doc-head { margin-bottom: 28px; padding-bottom: 24px; border-bottom: 1px solid var(--border); }
.lead { font-size: 18.5px; color: var(--muted); margin: 0; max-width: 70ch; }
li + li { margin-top: 4px; }

:target { scroll-margin-top: calc(var(--topbar-h) + 16px); }
h2:target, h3:target, h4:target { animation: flash 1.6s ease-out 1; }
@keyframes flash { from { background: var(--accent-soft); } to { background: transparent; } }
@media (prefers-reduced-motion: reduce) { h2:target, h3:target, h4:target { animation: none; } }

/* ------------------------------------------------------------ components */
.cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px;
  list-style: none; padding: 0; margin: 8px 0 12px; max-width: none !important;
}
.cards li { margin: 0; }
.cards a {
  display: block; height: 100%;
  padding: 16px 18px; border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
}
.cards a:hover { border-color: var(--accent); background: var(--bg-soft); }
.cards strong { display: block; margin-bottom: 4px; color: var(--accent); }
.cards span { display: block; font-size: 14px; color: var(--muted); line-height: 1.5; }

.steps { padding-left: 1.4em; }
.steps > li { padding-left: 4px; margin-bottom: 8px; }

.contents { margin: 8px 0 8px; padding: 18px 22px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-soft); }
.contents__title { font-size: 14px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0 0 10px; padding: 0; }
.contents__list { margin: 0; padding-left: 1.1em; max-width: none !important; }
.contents__list li { margin: 3px 0; }
.contents__list--cols { columns: 3 190px; column-gap: 28px; }
.contents__list--cols li { break-inside: avoid; }
.contents__groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 18px 28px; }
.contents__group { font-size: 15px; margin: 0 0 6px; }
.contents__group a { color: var(--text); text-decoration: none; }
.contents__group a:hover { color: var(--accent); }
.contents__groups .contents__list { list-style: none; padding: 0; font-size: 14.5px; }

.entry { margin: 0; }
.where { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; font-size: 14px; color: var(--muted); margin: 0 0 10px; }
.where span {
  font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent);
}
.use { background: var(--bg-soft); border-left: 3px solid var(--accent); padding: 10px 14px; border-radius: 0 8px 8px 0; }
.accepts { font-size: 14.5px; color: var(--muted); }
.page-note { font-size: 15px; color: var(--muted); border-top: 1px solid var(--border); padding-top: 16px; margin-top: 32px; }

.callout { margin: 8px 0 28px; padding: 18px 20px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--bg-soft); max-width: 76ch; }
.callout p { margin: 0; }
.callout p + p { margin-top: 8px; }
.callout__title { font-weight: 700; }
.callout--warn { background: var(--warn-bg); border-color: var(--warn-border); }

.cta { margin: 4px 0 8px; }
.button {
  display: inline-block; padding: 11px 20px; border-radius: 999px;
  background: var(--accent); color: var(--bg); font-weight: 600; text-decoration: none;
}
.button:hover { filter: brightness(1.08); }

/* ------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; margin: 12px 0 20px; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 14.5px; line-height: 1.5; }
th, td { text-align: left; vertical-align: top; padding: 10px 14px; border-bottom: 1px solid var(--border); }
thead th { background: var(--bg-soft); font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 600; }
tbody tr:last-child > * { border-bottom: 0; }
tbody th { font-weight: 600; }
table.plain td:first-child { white-space: nowrap; }

.settings th[scope="row"] { width: 24%; }
.settings td:nth-child(2) { width: 24%; }
.settings td:nth-child(3) { width: 14%; }
.settings tr.group th {
  background: var(--bg-soft); color: var(--text); font-size: 13px; letter-spacing: 0.02em;
  text-transform: none; padding: 8px 14px;
}
.settings tr.note td { color: var(--muted); font-size: 14px; font-style: italic; }
.settings .cond { display: block; margin-top: 4px; font-size: 13px; color: var(--muted); }
.settings td:nth-child(4):empty::after { content: ""; }

.opts { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.opts li { margin: 0; padding: 1px 8px; border: 1px solid var(--border); border-radius: 999px; font-size: 13px; background: var(--bg); }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; border: 1px solid var(--border); margin-right: 6px; vertical-align: -1px; }

details.settings-details { margin: 12px 0 22px; }
details.settings-details > summary {
  display: inline-flex; align-items: center; gap: 8px;
  cursor: pointer; list-style: none;
  padding: 7px 14px; border: 1px solid var(--border); border-radius: 999px;
  font-size: 14px; font-weight: 600; color: var(--text); background: var(--bg);
}
details.settings-details > summary::-webkit-details-marker { display: none; }
details.settings-details > summary::before {
  content: ""; width: 7px; height: 7px;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(-45deg); transition: transform 0.15s;
}
details.settings-details[open] > summary::before { transform: rotate(45deg); }
details.settings-details > summary:hover { border-color: var(--accent); }
details.settings-details .count { color: var(--muted); font-weight: 500; }

@media (max-width: 720px) {
  .settings thead { display: none; }
  .settings, .settings tbody, .settings tr, .settings th, .settings td { display: block; width: auto !important; }
  .settings tbody tr { padding: 10px 14px; border-bottom: 1px solid var(--border); }
  .settings tbody tr:last-child { border-bottom: 0; }
  .settings tbody th, .settings tbody td { border: 0; padding: 2px 0; }
  .settings td[data-label]::before {
    content: attr(data-label); display: block;
    font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-top: 6px;
  }
  .settings td[data-label="Notes"]:empty { display: none; }
  .settings tr.group { background: var(--bg-soft); }
  .settings tr.group th { padding: 0; background: none; }
}

/* ------------------------------------------------------------ pager, footer */
.pager { display: flex; justify-content: space-between; gap: 16px; max-width: 980px; margin: 56px 0 0; padding-top: 24px; border-top: 1px solid var(--border); }
.pager a {
  display: flex; flex-direction: column; gap: 2px;
  padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius);
  text-decoration: none; font-weight: 600; min-width: 0;
}
.pager a:hover { border-color: var(--accent); }
.pager a span { font-size: 12.5px; font-weight: 500; color: var(--muted); }
.pager .next { text-align: right; margin-left: auto; }
.site-footer { max-width: 980px; margin-top: 32px; font-size: 14px; color: var(--muted); }

/* ------------------------------------------------------------ narrow screens */
@media (max-width: 960px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .nav-toggle { display: inline-flex; }
  .sidebar {
    position: fixed; left: 0; top: var(--topbar-h); bottom: 0; z-index: 25;
    width: min(320px, 86vw); height: auto;
    background: var(--bg); border-right: 1px solid var(--border);
    transform: translateX(-102%); visibility: hidden;
    transition: transform 0.2s ease, visibility 0s linear 0.2s;
  }
  .nav-open .sidebar { transform: none; visibility: visible; transition: transform 0.2s ease; box-shadow: 0 0 60px rgba(0, 0, 0, 0.2); }
  .no-js .sidebar { position: static; transform: none; visibility: visible; width: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .no-js .nav-toggle { display: none; }
  .content { padding-top: 28px; }
}
@media (max-width: 600px) {
  .topbar { gap: 10px; padding: 0 12px; }
  .brand__sub { display: none; }
  .nav-toggle__label { display: none; }
  .search__key { display: none; }
  h2 { font-size: 23px; }
  .lead { font-size: 17px; }
  .pager { flex-direction: column; }
  .pager .next { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .sidebar, .nav-open .sidebar, details.settings-details > summary::before { transition: none; }
}
@media print {
  .topbar, .sidebar, .pager { display: none; }
  .layout { display: block; }
  details.settings-details > summary { display: none; }
  details.settings-details > * { display: block; }
}
