/* The docs: a top bar, the sidebar of pages, the article, its outline, and search that looks like the bar. */

body.docs { background: var(--bg); }
.dshell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 220px;
  grid-template-rows: 60px 1fr;
  grid-template-areas: "top top top" "side main toc";
  min-height: 100vh;
}

/* ---------- Top bar ---------- */
.dtop {
  grid-area: top;
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 22px;
  background: rgba(12, 12, 14, 0.72);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  backdrop-filter: blur(18px) saturate(160%);
  border-bottom: 1px solid var(--line);
}
.dbrand { display: flex; align-items: center; gap: 10px; }
.dbrand img { height: 36px; margin: -2px 0 0 -6px; }
.dbrand span { font-size: 14px; color: var(--muted); padding-left: 10px; border-left: 1px solid var(--line); }
.dsearch-open {
  margin: 0 auto;
  width: min(420px, 40vw);
  height: 36px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 8px 0 12px;
  border: 0;
  border-radius: 10px;
  background: rgba(255,255,255,0.05);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--dim);
  font: 14px var(--sans);
  cursor: pointer;
  transition: background 0.2s;
}
.dsearch-open:hover { background: rgba(255,255,255,0.08); }
.dsearch-open .sym { width: 15px; height: 15px; }
.dsearch-open kbd { margin-left: auto; }
.dlinks { display: flex; gap: 20px; align-items: center; font-size: 14px; color: var(--muted); }
.dlinks a:hover { color: var(--text); }
.dlinks .dl { color: #0c0c0e; background: #f4f4f6; padding: 7px 14px; border-radius: 999px; font-weight: 500; }
.dmenu { display: none; border: 0; background: none; color: var(--text); width: 34px; height: 34px; border-radius: 8px; cursor: pointer; }
.dmenu .sym { width: 18px; height: 18px; }

/* ---------- Sidebar ---------- */
.dside { grid-area: side; position: sticky; top: 60px; height: calc(100vh - 60px); overflow-y: auto; padding: 24px 14px 60px 22px; border-right: 1px solid var(--line); scrollbar-width: thin; }
.dgroup { margin-bottom: 22px; }
.dgroup p { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; padding: 0 10px; font-size: 13px; font-weight: 600; color: var(--text); }
.dgroup p .sym { width: 14px; height: 14px; color: #b9a6ff; }
.dgroup a { display: block; padding: 5px 10px 5px 32px; border-radius: 8px; font-size: 14px; color: var(--muted); transition: color 0.15s, background 0.15s; }
.dgroup a:hover { color: var(--text); }
.dgroup a[aria-current] { color: var(--text); background: rgba(255,255,255,0.08); }

/* ---------- Article ---------- */
.dmain { grid-area: main; min-width: 0; padding: 48px clamp(20px, 5vw, 72px) 80px; }
.doc { max-width: 740px; margin: 0 auto; font-size: 15.5px; line-height: 1.7; color: #d9d9de; }
.doc .crumb { margin: 0 0 10px; font-size: 13.5px; font-weight: 500; color: #b9a6ff; }
.doc h1 { font-family: var(--serif); font-size: clamp(34px, 4vw, 44px); line-height: 1.08; color: #f4f4f6; letter-spacing: -0.01em; margin: 0 0 14px; }
.doc .lead { font-size: 17.5px; line-height: 1.6; color: var(--muted); margin: 0 0 32px; }
.doc h2 { font-family: var(--sans); font-size: 22px; font-weight: 600; letter-spacing: -0.01em; color: #f4f4f6; margin: 48px 0 12px; scroll-margin-top: 80px; }
.doc h3 { font-family: var(--sans); font-size: 17px; font-weight: 600; color: #f4f4f6; margin: 30px 0 8px; scroll-margin-top: 80px; }
.doc .anchor { margin-left: 8px; color: var(--dim); opacity: 0; font-weight: 400; transition: opacity 0.15s; }
.doc h2:hover .anchor, .doc h3:hover .anchor { opacity: 1; }
.doc p { margin: 0 0 14px; }
.doc a:not(.anchor):not(.card):not(.prev):not(.next) { color: #c8bbff; text-decoration: underline; text-decoration-color: rgba(200,187,255,0.35); text-underline-offset: 3px; }
.doc a:not(.anchor):hover { text-decoration-color: currentColor; }
.doc strong { color: #f4f4f6; font-weight: 600; }
.doc ul, .doc ol { margin: 0 0 16px; padding-left: 22px; }
.doc li { margin: 4px 0; }
.doc li::marker { color: var(--dim); }
.doc code { font-size: 0.86em; background: rgba(255,255,255,0.07); padding: 1px 6px; border-radius: 6px; color: #ececf1; }
.doc pre { background: #141418; border-radius: 12px; padding: 14px 16px; overflow-x: auto; box-shadow: inset 0 0 0 1px var(--line); font-size: 13.5px; line-height: 1.6; }
.doc pre code { background: none; padding: 0; }
.doc hr { border: 0; border-top: 1px solid var(--line); margin: 36px 0; }

/* Keys, drawn like the app's keycaps. */
kbd {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  margin: 0 1px;
  border-radius: 6px;
  font: 500 12px var(--sans);
  line-height: 1;
  color: #ececf1;
  background: linear-gradient(rgba(255,255,255,0.12), rgba(255,255,255,0.06));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.14), 0 1px 0 rgba(0,0,0,0.6);
  vertical-align: 1px;
}

/* Tables: shortcuts, settings, what a command does. */
.doc table { width: 100%; border-collapse: collapse; margin: 6px 0 22px; font-size: 14.5px; }
.doc th { text-align: left; font-weight: 600; font-size: 13px; color: var(--muted); padding: 8px 12px; border-bottom: 1px solid var(--line); }
.doc td { padding: 9px 12px; border-bottom: 1px solid rgba(255,255,255,0.05); vertical-align: top; }
.doc td:first-child { white-space: nowrap; color: #f4f4f6; }

/* Callouts: a tip, a note, or a caution. */
.callout { display: flex; gap: 12px; margin: 18px 0 22px; padding: 13px 16px; border-radius: 12px; background: rgba(255,255,255,0.04); box-shadow: inset 0 0 0 1px var(--line); font-size: 14.5px; }
.callout::before { flex: none; width: 18px; height: 18px; margin-top: 3px; background: currentColor; -webkit-mask: var(--ico) center / contain no-repeat; mask: var(--ico) center / contain no-repeat; }
.callout > div > :last-child { margin-bottom: 0; }
.callout.tip { color: #9fc6ff; --ico: url(../icons/sym/lightbulb.png); }
.callout.note { color: #c8bbff; --ico: url(../icons/sym/questionmark.circle.png); }
.callout.warn { color: #ffcf8f; --ico: url(../icons/sym/exclamationmark.triangle.png); }
.callout::before { content: ""; }
.callout > div { color: #d9d9de; }
.callout b:first-child { color: #f4f4f6; }

/* Numbered steps. */
.doc ol.steps { list-style: none; padding: 0; counter-reset: s; }
.doc ol.steps > li { position: relative; padding-left: 40px; margin: 0 0 14px; counter-increment: s; }
.doc ol.steps > li::before { content: counter(s); position: absolute; left: 0; top: 1px; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 600; color: #f4f4f6; background: rgba(185,166,255,0.16); box-shadow: inset 0 0 0 1px rgba(185,166,255,0.3); }

/* A feature that's still being finished. */
.badge { display: inline-block; margin-left: 8px; padding: 2px 8px; border-radius: 6px; font: 500 11.5px var(--sans); vertical-align: 3px; color: #ffcf8f; background: rgba(255,180,90,0.12); }

/* Link cards (the welcome page). */
.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 10px 0 28px; }
.card { display: block; padding: 16px 18px; border-radius: 14px; background: rgba(255,255,255,0.035); box-shadow: inset 0 0 0 1px var(--line); text-decoration: none; transition: background 0.2s, box-shadow 0.2s; }
.card:hover { background: rgba(255,255,255,0.06); box-shadow: inset 0 0 0 1px rgba(185,166,255,0.35); }
.card [data-sym] { display: flex; }
.card .sym { width: 18px; height: 18px; color: #b9a6ff; }
.card b { display: block; margin: 8px 0 2px; color: #f4f4f6; font-size: 15px; font-weight: 600; }
.card span { display: block; font-size: 13.5px; line-height: 1.5; color: var(--muted); }

/* A live demo from the site. */
.doc figure.demo { margin: 22px 0 28px; }
.doc figure.demo .stage { border-radius: 16px; box-shadow: 0 20px 60px -30px rgba(0,0,0,0.8), 0 0 0 1px var(--line); }
.doc figure.demo .keys-strip { height: 48px; }
.doc figure.demo figcaption { font-size: 13px; color: var(--dim); text-align: center; margin-top: -4px; }

/* Previous / next. */
.pager { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-top: 56px; padding-top: 24px; border-top: 1px solid var(--line); }
.pager a { min-width: 180px; max-width: 48%; padding: 10px 16px; border-radius: 12px; box-shadow: inset 0 0 0 1px var(--line); color: #f4f4f6; font-weight: 500; font-size: 15px; transition: box-shadow 0.2s; }
.pager a:hover { box-shadow: inset 0 0 0 1px rgba(185,166,255,0.4); }
.pager small { display: block; font-size: 12.5px; color: var(--dim); font-weight: 400; }
.pager .next { text-align: right; margin-left: auto; }

/* ---------- Outline ---------- */
.dtoc { grid-area: toc; position: sticky; top: 60px; height: calc(100vh - 60px); overflow-y: auto; padding: 48px 20px 40px 8px; font-size: 13px; }
.dtoc p { margin: 0 0 8px; font-weight: 600; color: var(--text); }
.dtoc a { display: block; padding: 4px 0 4px 10px; color: var(--dim); border-left: 1px solid var(--line); transition: color 0.15s, border-color 0.15s; }
.dtoc a.h3 { padding-left: 22px; }
.dtoc a:hover { color: var(--text); }
.dtoc a.on { color: var(--text); border-left-color: #b9a6ff; }

/* ---------- Search: a bar like Saiki's ---------- */
.dsearch { position: fixed; inset: 0; z-index: 200; display: none; align-items: flex-start; justify-content: center; padding: 12vh 16px 0; background: rgba(0,0,0,0.45); }
.dsearch.open { display: flex; animation: dsIn 0.16s ease-out; }
@keyframes dsIn { from { opacity: 0; } }
.dsearch-bar {
  width: min(640px, 100%);
  border-radius: 22px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(10,10,12,0.96) 0, rgba(20,20,24,0.9) 64px, rgba(24,24,28,0.86) 100%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  backdrop-filter: blur(24px) saturate(160%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12), inset 0 1px 0 rgba(255,255,255,0.3), 0 30px 80px -10px rgba(0,0,0,0.7);
  animation: dsBar 0.3s var(--e-open, ease-out);
}
@keyframes dsBar { from { transform: scale(0.97); } }
.dsearch label { display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 18px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.dsearch label .sym { width: 18px; height: 18px; color: var(--dim); }
.dsearch input { flex: 1; border: 0; outline: 0; background: none; color: var(--text); font: 19px var(--sans); caret-color: #9fc6ff; }
.dsearch input::-webkit-search-cancel-button { display: none; }
.dres { max-height: min(56vh, 460px); overflow-y: auto; padding: 6px; }
.dres a { display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; border-radius: 14px; text-decoration: none; }
.dres a.on { background: rgba(255,255,255,0.1); }
.dres .ri { width: 28px; height: 28px; flex: none; display: grid; place-items: center; border-radius: 8px; background: rgba(255,255,255,0.06); color: #b9a6ff; }
.dres .ri .sym { width: 15px; height: 15px; }
.dres .rt { min-width: 0; }
.dres b { display: block; font-size: 14.5px; font-weight: 500; color: #f4f4f6; }
.dres small { display: block; font-size: 12.5px; line-height: 1.45; color: var(--dim); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.dres mark { background: none; color: #c8bbff; }
.dres .none { margin: 0; padding: 18px; color: var(--dim); font-size: 14px; }
.dfoot { display: flex; gap: 16px; padding: 10px 16px; border-top: 1px solid rgba(255,255,255,0.08); font-size: 12px; color: var(--dim); }
.dfoot kbd { min-width: 18px; height: 18px; font-size: 10.5px; }

/* ---------- Small screens ---------- */
@media (max-width: 1180px) {
  .dshell { grid-template-columns: 250px minmax(0, 1fr); grid-template-areas: "top top" "side main"; }
  .dtoc { display: none; }
}
@media (max-width: 820px) {
  .dshell { grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "main"; }
  .dmenu { display: grid; place-items: center; }
  .dside { position: fixed; top: 60px; left: 0; bottom: 0; width: 280px; height: auto; z-index: 40; background: #0f0f12; transform: translateX(-100%); transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1); }
  .side-open .dside { transform: none; box-shadow: 20px 0 60px rgba(0,0,0,0.6); }
  .dsearch-open span, .dsearch-open kbd, .dlinks a:not(.dl) { display: none; }
  .dsearch-open { width: 36px; margin-left: auto; margin-right: 0; padding: 0; justify-content: center; }
  .dbrand span { display: none; }
  .cards { grid-template-columns: 1fr; }
  .pager a { min-width: 0; max-width: none; flex: 1 1 0; }
  .dmain { padding-top: 32px; }
  .doc td:first-child { white-space: normal; }
}

/* A page swapped in place fades up quickly; until the shell is built, the bare article stays hidden (no flash). */
body.docs > article.doc { visibility: hidden; }
.doc.enter { animation: docIn 0.22s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
@keyframes docIn { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { .doc.enter { animation: none; } }
