/*
 * Ambient Assist AI docs.
 *
 * The theme tokens are the website's (website/static/styles.css) and the
 * admin dashboard's (admin_ui/admin.css), and stay identical to them
 * (tests/test_docs_site_stub.py): dark by default, [data-theme="light"]
 * switches it. Header, footer, buttons and the segmented switch are the
 * website's. Each group of settings is a table: Feature, Description,
 * Default (templates/shortcodes/settings.html).
 *
 * A page is the menu, the article and "On this page"; under 1024 px "On
 * this page" folds under the page's head, and under 860 px the menu opens
 * from a bar over the page.
 */

/* Theme tokens ----------------------------------------------------------- */

:root,
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #070b14;
  --panel: #0b1221;
  --raised: #0f1729;
  --line: #172033;
  --edge: #1d2740;
  --edge-strong: #2a3654;
  --text: #eef2fa;
  --text-2: #a5b1c8;
  --text-3: #7d8aa4;
  --accent: #4353f5;
  --accent-hover: #5563ff;
  --accent-text: #8e9bff;
  --seg-active: #1d2851;
  --dot: #5b8cff;
  --ok: #4ad39b;
  --warn: #ffb65c;
  --danger: #ff8796;
  --scrim: rgba(3, 6, 14, 0.66);
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f5f9;
  --panel: #ffffff;
  --raised: #f5f7fb;
  --line: #e6eaf0;
  --edge: #dce2eb;
  --edge-strong: #cdd5e2;
  --text: #0e1430;
  --text-2: #4a5670;
  --text-3: #5e6a82;
  --accent: #4353f5;
  --accent-hover: #3645e8;
  --accent-text: #3442e0;
  --seg-active: #e3e8f6;
  --dot: #4f7cff;
  --ok: #0b7a4f;
  --warn: #b45d00;
  --danger: #b4233a;
  --scrim: rgba(14, 20, 48, 0.4);
  --shadow: 0 30px 80px rgba(14, 20, 48, 0.18);
}

:root {
  --font: system-ui, -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, Menlo, monospace;
  --menu-w: 248px;
  --rail-w: 196px;
}

/* Base -------------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3,
p,
ul,
ol,
figure {
  margin: 0;
}

ul,
ol {
  padding: 0;
  list-style: none;
}

a {
  color: var(--accent-text);
}

a:hover {
  color: var(--text);
}

button {
  font: inherit;
  color: inherit;
}

svg {
  flex: none;
}

:focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 3px;
}

.skip {
  position: absolute;
  top: -60px;
  left: 16px;
  z-index: 30;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
}

.skip:focus {
  top: 16px;
}

.wrap {
  width: min(100% - 48px, 1280px);
  margin-inline: auto;
}

/* Small type: the tracked capitals used for eyebrows and labels. */

.eyebrow,
.label {
  color: var(--text-3);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.label {
  font-size: 10.5px;
  letter-spacing: 0.22em;
}

kbd {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border: 1px solid var(--edge-strong);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text-3);
  font-family: var(--font);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1;
}

/* Header ------------------------------------------------------------------ */

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 28px;
  padding: 24px 0 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.wordmark {
  color: var(--text);
  font-size: 21px;
  line-height: 1;
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
}

.wordmark b {
  font-weight: 700;
}

.wordmark span {
  font-weight: 300;
}

.wordmark:hover {
  color: var(--text);
}

.docs-tag {
  padding: 4px 9px 4px 11px;
  border: 1px solid color-mix(in srgb, var(--accent) 50%, transparent);
  border-radius: 999px;
  color: var(--accent-text);
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.search {
  display: flex;
  flex: 1 1 260px;
  align-items: center;
  gap: 10px;
  max-width: 400px;
  min-height: 40px;
  padding: 0 8px 0 12px;
  border: 1px solid var(--edge-strong);
  border-radius: 10px;
  background: var(--raised);
  color: var(--text-3);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.search:hover {
  border-color: var(--text-3);
}

.search-text {
  flex: 1;
}

.header-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 22px;
  margin-left: auto;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 22px;
}

.nav a {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 11px 0;
  color: var(--text-2);
  font-size: 14px;
  text-decoration: none;
}

.nav a:hover {
  color: var(--text);
}

/* Segmented control ------------------------------------------------------- */

.seg {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 4px;
  border: 1px solid var(--edge-strong);
  border-radius: 10px;
  background: var(--raised);
}

.seg-btn {
  min-height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
}

.seg-btn:hover {
  background: color-mix(in srgb, var(--seg-active) 55%, transparent);
}

.seg-btn[aria-pressed="true"] {
  background: var(--seg-active);
}

.seg-sm .seg-btn {
  min-height: 30px;
  padding: 0 11px;
  font-size: 13px;
}

/* Buttons ----------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.btn-sm {
  min-height: 36px;
  padding: 0 14px;
  font-size: 13.5px;
}

.btn-primary,
.btn-primary:hover {
  color: #fff;
}

.btn-primary {
  background: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-quiet,
.btn-quiet:hover {
  color: var(--text);
}

.btn-quiet {
  border-color: var(--edge-strong);
  background: var(--raised);
}

.btn-quiet:hover {
  border-color: var(--text-3);
}

/* The page: menu, article, "On this page" -------------------------------- */

.docs {
  display: grid;
  grid-template-columns: var(--menu-w) minmax(0, 1fr) var(--rail-w);
  align-items: start;
  gap: 48px;
  padding-top: 34px;
  border-top: 1px solid var(--line);
}

/* a page with no parts to list (a section's, the home page) */
.docs.no-rail {
  grid-template-columns: var(--menu-w) minmax(0, 1fr);
}

/* The menu: every page, by where it is in the product. */

.menu {
  position: sticky;
  top: 24px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: 0 6px 24px 0;
  scrollbar-width: thin;
}

.menu-group + .menu-group {
  margin-top: 26px;
}

.menu-group > .label {
  margin: 0 0 8px 12px;
}

/* a group's title opens its section's own page */
.menu .menu-title {
  display: inline;
  padding: 0;
  border-radius: 0;
  color: inherit;
  font-size: inherit;
  line-height: inherit;
}

.menu .menu-title:hover {
  background: none;
  color: var(--text);
}

.menu .menu-title[aria-current="page"] {
  background: none;
  color: var(--accent-text);
  font-weight: inherit;
}

.menu a {
  display: block;
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.45;
  text-decoration: none;
}

.menu a:hover {
  background: color-mix(in srgb, var(--seg-active) 55%, transparent);
  color: var(--text);
}

.menu a[aria-current="page"] {
  background: var(--seg-active);
  color: var(--text);
  font-weight: 600;
}

.menu .open > a {
  color: var(--text);
}

.menu-sub {
  margin: 2px 0 4px 18px;
  padding-left: 8px;
  border-left: 1px solid var(--edge);
}

.menu-sub a {
  padding: 5px 10px;
  font-size: 13.5px;
}

.menu-head {
  display: none;
}

/* The article ------------------------------------------------------------- */

.article {
  min-width: 0;
  max-width: 800px;
  container-type: inline-size;
}

.crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
}

.crumbs a {
  color: var(--text-3);
  text-decoration: none;
}

.crumbs a:hover {
  color: var(--text);
}

.crumbs svg {
  width: 12px;
  height: 12px;
  color: var(--edge-strong);
}

.article h1 {
  margin-top: 14px;
  font-size: clamp(34px, 4.2vw, 46px);
  font-weight: 700;
  line-height: 1.06;
  letter-spacing: -0.026em;
}

.lead {
  max-width: 680px;
  margin-top: 16px;
  color: var(--text-2);
  font-size: 17px;
  line-height: 1.6;
}

/* At a glance: cells the website's way (1px gaps over the divider colour),
   four across, or two by two when the article is narrow. */
.facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin-top: 28px;
  border: 1px solid var(--edge);
  border-radius: 22px;
  background: var(--line);
  overflow: hidden;
}

@container (max-width: 640px) {
  .facts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.fact {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 20px 18px;
  background: var(--panel);
}

.fact-value {
  color: var(--text);
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.4;
}

.find {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
  margin-top: 16px;
  padding: 14px 16px 14px 20px;
  border: 1px solid var(--edge);
  border-radius: 16px;
  color: var(--text-2);
  font-size: 14px;
}

.path {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
}

.path b {
  color: var(--text);
  font-weight: 600;
}

.path svg {
  width: 12px;
  height: 12px;
  color: var(--text-3);
}

/* The page's text (its Markdown). Each ## heading opens a part. */

.content > h2 {
  margin-top: 60px;
  font-size: 25px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.014em;
  scroll-margin-top: 20px;
}

.content > h2:first-child {
  margin-top: 52px;
}

.content > h3 {
  margin-top: 34px;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.35;
  scroll-margin-top: 20px;
}

.anchor {
  margin-left: 10px;
  color: var(--text-3);
  font-weight: 500;
  text-decoration: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}

h2:hover .anchor,
h3:hover .anchor,
.anchor:focus-visible {
  opacity: 1;
}

.content > p,
.content > ul,
.content > ol {
  max-width: 680px;
  margin-top: 12px;
  color: var(--text-2);
  font-size: 15.5px;
  line-height: 1.7;
}

.content > ul {
  padding-left: 22px;
  list-style: disc;
}

.content > ol {
  padding-left: 22px;
  list-style: decimal;
}

.content li + li {
  margin-top: 6px;
}

.content li::marker {
  color: var(--text-3);
}

.content strong {
  color: var(--text);
  font-weight: 600;
}

.content code,
.settings code {
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--raised);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.86em;
  overflow-wrap: anywhere;
}

/* A group of settings: Feature, Description, Default ---------------------- */

.settings-wrap {
  margin-top: 20px;
  border: 1px solid var(--edge);
  border-radius: 18px;
  background: var(--panel);
  overflow: hidden;
}

.settings {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
  line-height: 1.6;
}

.settings th {
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--raised);
  color: var(--text-3);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-align: left;
  text-transform: uppercase;
}

.settings td {
  padding: 16px 20px;
  border-top: 1px solid var(--line);
  vertical-align: top;
}

.settings tbody tr:first-child td {
  border-top: 0;
}

.settings .col-feature {
  width: 23%;
}

.settings .col-default {
  width: 116px;
}

.feat {
  color: var(--text);
  font-weight: 600;
}

.desc {
  color: var(--text-2);
}

.desc p + p {
  margin-top: 8px;
}

/* What a setting starts as: On, Off, or its value. */
.dflt {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
}

.dflt::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-3);
}

.dflt-on::before {
  background: var(--ok);
}

.dflt-value::before {
  display: none;
}

.dflt-off {
  color: var(--text-2);
}

.dflt-none {
  color: var(--text-3);
  font-weight: 400;
}

.dflt-none::before {
  display: none;
}

/* The settings that carry what people read and copy: amber, as on the
   dashboard. */
.settings-content {
  border-color: color-mix(in srgb, var(--warn) 32%, var(--edge));
}

.settings-content th {
  border-bottom-color: color-mix(in srgb, var(--warn) 25%, transparent);
  background: color-mix(in srgb, var(--warn) 9%, var(--panel));
}

.settings-content td {
  border-top-color: color-mix(in srgb, var(--warn) 16%, transparent);
}

/* What each role gives (templates/roles.html): wider than a phone, so it
   scrolls inside its own frame and never widens the page. */
.table-scroll {
  margin-top: 20px;
  border: 1px solid var(--edge);
  border-radius: 18px;
  background: var(--panel);
  overflow-x: auto;
}

.roles {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 13.5px;
  line-height: 1.5;
}

.roles th {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--raised);
  color: var(--text-3);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-align: left;
  text-transform: uppercase;
}

.roles td {
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  color: var(--text-2);
  vertical-align: top;
}

.roles tbody tr:first-child td {
  border-top: 0;
}

.roles th:first-child {
  width: 30%;
}

.roles td.feat {
  color: var(--text);
  font-weight: 600;
}

/* The models we recommend for each kind of call, and why
   (templates/shortcodes/recommended.html): a row for each kind, its reason
   under it across the table. Its three columns fit a phone; in a narrower
   window it scrolls as the roles table does. */
.models {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  line-height: 1.55;
}

.models thead th {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--raised);
  color: var(--text-3);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-align: left;
  text-transform: uppercase;
}

.models td,
.models tbody th {
  padding: 12px 14px 4px;
  border-top: 1px solid var(--line);
  color: var(--text-2);
  text-align: left;
  vertical-align: top;
}

.models thead + tbody tr:first-child > * {
  border-top: 0;
}

.models tr.why td {
  padding: 0 14px 14px;
  border-top: 0;
}

.models .feat {
  width: 30%;
  color: var(--text);
  font-weight: 600;
}

.models td.model {
  width: 45%;
  color: var(--text);
}

.models td.effort {
  width: 25%;
}

.models td.model code {
  display: block;
  margin-top: 4px;
  color: var(--text-3);
  font-family: var(--mono);
  font-size: 0.86em;
  overflow-wrap: anywhere;
}

.models-note {
  max-width: 680px;
  margin-top: 12px;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.6;
}

/* A note beside the text (templates/shortcodes/note.html); amber for what
   can't be undone or reads content. */
.callout {
  display: flex;
  gap: 12px;
  max-width: 680px;
  margin-top: 18px;
  padding: 14px 18px;
  border: 1px solid var(--edge);
  border-radius: 14px;
  background: var(--raised);
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.6;
}

.callout > svg {
  margin-top: 2px;
  color: var(--accent-text);
}

.callout p + p {
  margin-top: 8px;
}

.callout strong {
  color: var(--text);
  font-weight: 600;
}

.callout-warn {
  border-color: color-mix(in srgb, var(--warn) 35%, var(--edge));
  background: color-mix(in srgb, var(--warn) 7%, var(--panel));
}

.callout-warn > svg {
  color: var(--warn);
}

/* A video from the stage's videos, as wide as the text. */
.video {
  margin-top: 20px;
}

.video video {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--edge);
  border-radius: 14px;
  background: #000;
}

/* An example: a copy of what the app shows, labelled so. */
.example {
  max-width: 560px;
  margin-top: 20px;
  border: 1px solid var(--edge);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.18);
  overflow: hidden;
}

.example-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--raised);
}

.example-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px 22px 22px;
}

.example-title {
  font-size: 17px;
  font-weight: 650;
  line-height: 1.3;
}

.example-sub {
  color: var(--text-2);
  font-size: 13.5px;
  line-height: 1.55;
}

.example-row {
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 13.5px;
  line-height: 1.5;
}

.example-row b {
  display: block;
  color: var(--text);
  font-weight: 600;
}

.example-row span {
  color: var(--text-2);
}

.example-person {
  color: var(--text-2);
  font-size: 13.5px;
}

.example-person b {
  color: var(--text);
  font-weight: 600;
}

.example-h {
  margin-top: 6px;
  font-size: 13px;
  font-weight: 700;
}

.ticks {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ticks li {
  display: flex;
  gap: 10px;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.55;
}

.ticks svg {
  width: 16px;
  height: 16px;
  margin-top: 3px;
  color: var(--accent-text);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

.dialog-actions span {
  pointer-events: none;
}

/* An example's choices, still: the one chosen, and one that can't be. */
.example-seg {
  display: flex;
}

.example-seg .seg-btn {
  display: inline-flex;
  flex: 1 1 auto;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  pointer-events: none;
}

.example-seg .is-on {
  background: var(--seg-active);
}

.example-seg .is-off {
  opacity: 0.45;
}

/* An example's dropdown, still: its choice, under the row's words. */
.example-row .example-pick {
  display: flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  margin-top: 8px;
  padding: 5px 12px;
  border: 1px solid var(--edge-strong);
  border-radius: 8px;
  background: var(--raised);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  pointer-events: none;
}

.example-row .example-pick::after {
  content: "";
  width: 6px;
  height: 6px;
  margin-top: -3px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  opacity: 0.6;
  transform: rotate(45deg);
}

/* A section's pages as cards, and the pages either side of a page. */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  margin-top: 32px;
}

.cards a,
.pager a {
  display: block;
  padding: 16px 18px;
  border: 1px solid var(--edge);
  border-radius: 16px;
  background: var(--panel);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.cards a span {
  display: block;
  margin-top: 4px;
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 400;
  line-height: 1.5;
}

.cards a:hover,
.pager a:hover {
  border-color: var(--edge-strong);
  background: var(--raised);
}

.pager {
  display: flex;
  gap: 12px;
  margin-top: 64px;
}

.pager a {
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  gap: 6px;
  padding: 18px 20px;
  font-size: 16px;
}

.pager .next {
  align-items: flex-end;
  text-align: right;
}

.pager-gap {
  flex: 1 1 0;
}

/* The home page: each part of the product with its pages. */

.areas {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  margin-top: 36px;
}

.area {
  padding: 22px 22px 24px;
  border: 1px solid var(--edge);
  border-radius: 22px;
  background: var(--panel);
}

.area h2 {
  font-size: 19px;
  font-weight: 700;
  line-height: 1.3;
}

.area h2 a {
  color: var(--text);
  text-decoration: none;
}

.area h2 a:hover {
  color: var(--accent-text);
}

.area > p {
  margin-top: 6px;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.55;
}

.area ul {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.area li a {
  display: block;
  padding: 4px 0;
  color: var(--text-2);
  font-size: 14px;
  text-decoration: none;
}

.area li a:hover {
  color: var(--text);
}

/* On this page: the parts of the article, the one in view marked. */

.rail {
  position: sticky;
  top: 24px;
  font-size: 13.5px;
}

.rail .label {
  margin-bottom: 12px;
}

.toc a {
  display: block;
  padding: 6px 0 6px 14px;
  border-left: 2px solid var(--edge);
  color: var(--text-2);
  line-height: 1.4;
  text-decoration: none;
}

.toc a:hover {
  color: var(--text);
}

.toc a[aria-current="true"] {
  border-left-color: var(--accent);
  color: var(--text);
  font-weight: 600;
}

.rail-foot {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.rail-foot a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-2);
  text-decoration: none;
}

.rail-foot a:hover {
  color: var(--text);
}

.rail-foot svg {
  width: 13px;
  height: 13px;
}

/* Below 1024 px "On this page" sits under the page's head instead. */
.toc-inline {
  display: none;
  margin-top: 16px;
  border: 1px solid var(--edge);
  border-radius: 16px;
  background: var(--panel);
}

.toc-inline summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 18px;
  cursor: pointer;
  list-style: none;
}

.toc-inline summary::-webkit-details-marker {
  display: none;
}

.toc-inline summary svg {
  width: 14px;
  height: 14px;
  color: var(--text-3);
  transition: transform 0.15s ease;
}

.toc-inline[open] summary svg {
  transform: rotate(180deg);
}

.toc-inline .toc {
  padding: 0 18px 14px;
}

/* Footer ------------------------------------------------------------------ */

.site-footer {
  margin-top: 104px;
  padding-bottom: 48px;
}

.footer-top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px 32px;
  padding-top: 32px;
  border-top: 1px solid var(--line);
}

.footer-brand {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.footer-tagline {
  color: var(--text-2);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.32em;
  text-transform: uppercase;
}

.notes {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
  margin-top: 24px;
  color: var(--text-3);
  font-size: 13px;
}

/* Search: a dialog over the page, Ctrl K or "/" opens it. */

.find-dialog {
  width: min(640px, 100% - 32px);
  max-height: min(560px, 100vh - 96px);
  margin: 12vh auto auto;
  padding: 0;
  border: 1px solid var(--edge-strong);
  border-radius: 18px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
}

.find-dialog::backdrop {
  background: var(--scrim);
}

.find-top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}

.find-top svg {
  width: 18px;
  height: 18px;
  color: var(--text-3);
}

.find-top input {
  flex: 1;
  min-width: 0;
  height: 58px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 17px;
  outline: none;
}

.find-results {
  max-height: 420px;
  overflow-y: auto;
  padding: 8px;
}

.find-results a {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
}

.find-results a strong {
  font-weight: 500;
}

.find-where {
  color: var(--text-3);
  font-size: 12.5px;
}

.find-snippet {
  margin-top: 2px;
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.5;
}

.find-results a[aria-selected="true"] {
  background: var(--seg-active);
}

.find-results mark {
  background: none;
  color: var(--accent-text);
  font-weight: 700;
}

.find-empty {
  padding: 22px 12px;
  color: var(--text-3);
  font-size: 14px;
  text-align: center;
}

.find-foot {
  display: flex;
  gap: 16px;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  color: var(--text-3);
  font-size: 12px;
}

/* The menu on a narrow window: a bar that opens it over the page. */

.menu-bar {
  display: none;
}

.scrim {
  display: none;
}

/* Widths ------------------------------------------------------------------ */

/* A narrow article stacks each row: the feature and what it starts as on
   one line, the description under them. */
@container (max-width: 560px) {
  .settings thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  .settings,
  .settings tbody {
    display: block;
  }

  .settings tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px 14px;
    padding: 15px 18px;
    border-top: 1px solid var(--line);
  }

  .settings-content tr {
    border-top-color: color-mix(in srgb, var(--warn) 16%, transparent);
  }

  .settings tbody tr:first-child {
    border-top: 0;
  }

  .settings td {
    display: block;
    padding: 0;
    border: 0;
  }

  .settings td.desc {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}

@media (max-width: 1199px) {
  :root {
    --menu-w: 224px;
    --rail-w: 176px;
  }

  .docs {
    gap: 36px;
  }
}

@media (max-width: 1023px) {
  .docs {
    grid-template-columns: var(--menu-w) minmax(0, 1fr);
  }

  .rail {
    display: none;
  }

  .toc-inline {
    display: block;
  }
}

@media (max-width: 860px) {
  .docs,
  .docs.no-rail {
    grid-template-columns: minmax(0, 1fr);
    padding-top: 0;
    border-top: 0;
  }

  .header-right .nav {
    display: none;
  }

  .menu-bar {
    position: sticky;
    top: env(safe-area-inset-top, 0px);
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 26px;
    padding: 10px 0;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(10px);
  }

  .menu-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 36px;
    padding: 0 12px;
    border: 1px solid var(--edge-strong);
    border-radius: 9px;
    background: var(--raised);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
  }

  .menu-btn svg {
    width: 16px;
    height: 16px;
  }

  .menu-where {
    overflow: hidden;
    color: var(--text-3);
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .menu {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 50;
    width: min(320px, 86vw);
    max-height: none;
    padding: calc(18px + env(safe-area-inset-top, 0px)) 14px calc(32px + env(safe-area-inset-bottom, 0px)) calc(14px + env(safe-area-inset-left, 0px));
    border-right: 1px solid var(--edge-strong);
    background: var(--panel);
    box-shadow: var(--shadow);
    transform: translateX(-102%);
    transition: transform 0.22s ease;
  }

  .menu.open-sheet {
    transform: none;
  }

  .menu-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0 0 18px 12px;
  }

  .menu-close {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--edge-strong);
    border-radius: 9px;
    background: var(--raised);
    cursor: pointer;
  }

  .scrim.show {
    position: fixed;
    inset: 0;
    z-index: 45;
    display: block;
    background: var(--scrim);
  }
}

@media (max-width: 640px) {
  .wrap {
    width: min(100% - 32px, 1280px);
  }

  .site-header {
    gap: 14px 16px;
    padding: 20px 0 16px;
  }

  .header-right {
    gap: 8px 12px;
  }

  .header-right .btn {
    display: none;
  }

  /* the wordmark on a row of its own, then search beside the theme switch */
  .brand {
    flex: 1 1 100%;
  }

  .search {
    order: 3;
    flex: 1 1 0;
    min-width: 0;
    max-width: none;
  }

  .search kbd {
    display: none;
  }

  .header-right {
    order: 4;
    margin-left: 0;
  }

  .lead {
    font-size: 16px;
  }

  .fact {
    padding: 14px 16px;
  }

  .part {
    padding-top: 48px;
  }

  .article h2 {
    font-size: 22px;
  }

  .pager {
    flex-direction: column;
  }

  .pager .next {
    align-items: flex-start;
    text-align: left;
  }
}

@media (pointer: coarse) {
  .seg-btn,
  .seg-sm .seg-btn {
    min-height: 40px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .menu {
    transition: none;
  }
}
