/* Application chrome: title bar, ribbon, navigation pane, status bar, File
   backstage, dialogs and menus. Page typography lives in book.css. */

:root {
  --accent: #034fa0;
  --accent-deep: #0f3464;
  --accent-ink: #fff;
  --accent-soft: rgba(3, 79, 160, .12);
  --accent-line: #034fa0;
  --chrome: #f5f5f4;
  --chrome-2: #fbfbfa;
  --ribbon: #fcfcfb;
  --canvas: #e4e4e2;
  --line: #d9d9d6;
  --line-strong: #c4c4c0;
  --text: #242424;
  --muted: #646461;
  --hover: rgba(0, 0, 0, .055);
  --press: rgba(0, 0, 0, .1);
  --field: #fff;
  --shadow: 0 1px 3px rgba(0, 0, 0, .14), 0 3px 12px rgba(0, 0, 0, .07);
  --menu-shadow: 0 6px 24px rgba(0, 0, 0, .18), 0 1px 3px rgba(0, 0, 0, .12);
  --ui-font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --hl: #ffe066;
  --hl-current: #ff9f43;
  --disabled: #a8a8a4;
  color-scheme: light;
}

:root[data-theme="sepia"] {
  --canvas: #dcd5c6;
}

:root[data-theme="dark"] {
  --accent: #0f3464;
  --accent-deep: #0a2547;
  --accent-soft: rgba(110, 168, 230, .16);
  --accent-line: #6ea8e6;
  --chrome: #262626;
  --chrome-2: #2c2c2c;
  --ribbon: #2e2e2e;
  --canvas: #1a1a1a;
  --line: #3b3b3b;
  --line-strong: #4a4a4a;
  --text: #e6e6e6;
  --muted: #a3a3a3;
  --hover: rgba(255, 255, 255, .07);
  --press: rgba(255, 255, 255, .12);
  --field: #1f1f1f;
  --shadow: 0 1px 3px rgba(0, 0, 0, .5), 0 3px 12px rgba(0, 0, 0, .35);
  --menu-shadow: 0 6px 24px rgba(0, 0, 0, .55), 0 1px 3px rgba(0, 0, 0, .4);
  --hl: #8a6d00;
  --hl-current: #c45f00;
  --disabled: #686866;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--chrome);
  color: var(--text);
  font: 13px/1.4 var(--ui-font);
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { flex: none; }

.app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}
.app > * { flex: none; }
.app > .workspace { flex: 1; }

/* Title bar ---------------------------------------------------------------- */

.titlebar {
  position: relative;
  z-index: 40;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 560px) minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  height: 38px;
  padding: 0 12px;
  background: var(--accent);
  color: var(--accent-ink);
  user-select: none;
}
.tb-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tb-logo { display: flex; opacity: .95; }
.tb-title {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.tb-doc { font-weight: 600; }
.tb-author { opacity: .75; }
.tb-right { justify-self: end; white-space: nowrap; }
.tb-note { font-size: 12px; opacity: .75; }

/* Title bar search ("Search for tools, help, and more") */
.tb-search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 4px 0 10px;
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 6px;
  background: rgba(255, 255, 255, .14);
  color: rgba(255, 255, 255, .9);
  user-select: text;
}
.tb-search:hover { background: rgba(255, 255, 255, .2); }
.tb-search > svg { width: 16px; height: 16px; }
.tb-search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  outline: 0;
  background: none;
  color: inherit;
  font-size: 13px;
}
.tb-search input::placeholder { color: rgba(255, 255, 255, .82); }
.tb-search input::-webkit-search-cancel-button { display: none; }
.tb-search:focus-within {
  border-color: var(--line-strong);
  background: var(--field);
  color: var(--text);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .2);
}
.tb-search:focus-within input::placeholder { color: var(--muted); }
.tb-count { flex: none; font-size: 12px; opacity: .8; white-space: nowrap; }
.tb-step {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 3px;
  background: none;
  color: inherit;
}
.tb-step svg { width: 15px; height: 15px; }
.tb-step:hover { background: rgba(127, 127, 127, .2); }

.tb-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  min-width: 300px;
  max-height: min(460px, 70vh);
  overflow-y: auto;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--chrome-2);
  color: var(--text);
  box-shadow: var(--menu-shadow);
}
.tbr-head {
  margin: 8px 8px 4px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
}
.tbr-head:first-child { margin-top: 4px; }
.tbr-note { margin: 4px 8px 8px; color: var(--muted); }
.tbr-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 6px 8px;
  border: 0;
  border-radius: 4px;
  background: none;
  text-align: left;
}
.tbr-item > svg { width: 16px; height: 16px; color: var(--accent-line); }
.tbr-item:hover, .tbr-item.active { background: var(--hover); }
.tbr-item.active { box-shadow: inset 2px 0 0 var(--accent-line); }
.tbr-res { display: flex; flex-direction: column; min-width: 0; line-height: 1.4; }
.tbr-res small { color: var(--muted); font-size: 11.5px; }
.tbr-res > span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tbr-res mark { background: var(--hl); color: inherit; border-radius: 2px; }
.tbr-all { color: var(--accent-line); font-weight: 600; }

/* Ribbon tabs -------------------------------------------------------------- */

.tabs {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 34px;
  padding: 0 8px;
  background: var(--chrome);
}
.tab {
  position: relative;
  height: 30px;
  padding: 0 14px;
  border: 0;
  border-radius: 4px 4px 0 0;
  background: none;
  white-space: nowrap;
}
.tab:hover { background: var(--hover); }
.tab[aria-selected="true"] { color: var(--accent-line); font-weight: 600; }
.tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 0;
  height: 3px;
  border-radius: 2px;
  background: var(--accent-line);
}
.tab-file {
  margin-right: 4px;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 4px 4px 0 0;
}
.tab-file:hover { background: var(--accent-deep); }
.tab-fake, .tab-fake[aria-selected="true"] { color: var(--disabled); }
.tab-fake[aria-selected="true"]::after { background: var(--disabled); }
.tabs-spacer { flex: 1; }
.ribbon-toggle { align-self: center; }

/* Ribbon ------------------------------------------------------------------- */

.ribbon {
  margin: 0 8px 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--ribbon);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
}
.panel {
  display: flex;
  align-items: stretch;
  min-height: 92px;
  padding: 4px 4px 0;
  overflow-x: auto;
  scrollbar-width: thin;
}
.ribbon-collapsed .ribbon { display: none; }
.ribbon-collapsed.ribbon-peek .ribbon {
  display: block;
  position: absolute;
  z-index: 30;
  top: 72px;
  left: 0;
  right: 0;
  box-shadow: var(--menu-shadow);
}

.group {
  flex: none;
  display: flex;
  flex-direction: column;
  padding: 0 8px;
  border-right: 1px solid var(--line);
}
.group:last-child { border-right: 0; }
.group-body {
  flex: 1;
  display: flex;
  align-items: flex-start;
  gap: 2px;
}
.group-body.col { flex-direction: column; justify-content: center; gap: 6px; }
.group-label {
  padding: 2px 0 4px;
  text-align: center;
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
}
.row { display: flex; align-items: center; gap: 2px; }

.rb {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 28px;
  height: 28px;
  padding: 0 4px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: none;
  white-space: nowrap;
}
.rb:hover { background: var(--hover); }
a.rb { color: inherit; text-decoration: none; }

/* Placeholder commands: greyed out so only working controls look live. */
.rb-fake { color: var(--disabled); cursor: default; }
.rb-fake:hover, .rb-fake:active { background: none; }
.panel:has(> .group .rb-fake) .group:has(.rb-fake) .group-label { color: var(--disabled); }
.rb:active { background: var(--press); }
.rb[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent-line) 45%, transparent);
}
.rb-text { gap: 6px; padding: 0 8px 0 4px; }
.rb-drop { font-family: Georgia, serif; font-size: 14px; padding: 0 2px 0 6px; }
.rb-sep { width: 1px; height: 20px; margin: 0 4px; background: var(--line); }
.rb-label { width: 84px; color: var(--muted); }

.rb.big {
  flex-direction: column;
  justify-content: flex-start;
  gap: 2px;
  min-width: 58px;
  height: auto;
  min-height: 64px;
  padding: 4px 6px;
  line-height: 1.15;
  text-align: center;
  font-size: 12px;
}
.rb.big > svg { margin-bottom: 2px; }
.rb.big span { display: inline-flex; flex-direction: column; align-items: center; }
.rb.big span svg { display: inline; margin-top: 1px; }

.sel {
  height: 26px;
  padding: 0 6px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--field);
}
.sel:hover { border-color: var(--muted); }
.sel:focus-visible { outline: 2px solid var(--accent-line); outline-offset: -1px; }
.sel-font { width: 168px; }
.sel-size { width: 62px; margin-left: 4px; }

.checks { align-items: flex-start; gap: 4px; padding-top: 4px; }
.chk { display: flex; align-items: center; gap: 6px; padding: 1px 2px; white-space: nowrap; cursor: pointer; }
.chk input { margin: 0; accent-color: var(--accent-line); }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: none;
  color: inherit;
}
.icon-btn:hover { background: var(--hover); }

/* Workspace ---------------------------------------------------------------- */

.workspace {
  position: relative;
  display: flex;
  min-height: 0;
  border-top: 1px solid var(--line);
}

.navpane {
  flex: none;
  display: none;
  flex-direction: column;
  width: 280px;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--chrome-2);
}
.nav-open .navpane { display: flex; }
.np-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 6px 4px 14px;
}
.np-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.np-search {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 4px 12px 8px;
  padding: 0 8px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--field);
  color: var(--muted);
}
.np-search:focus-within { border-color: var(--accent-line); box-shadow: 0 0 0 1px var(--accent-line); }
.np-search input {
  flex: 1;
  min-width: 0;
  height: 28px;
  border: 0;
  outline: 0;
  background: none;
  color: var(--text);
}
.np-sub {
  display: flex;
  justify-content: space-between;
  margin: 0 12px;
  padding: 2px 2px 6px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}
.np-sub #np-label { color: var(--accent-line); font-weight: 600; }
.np-sub #np-count { color: var(--muted); }
.np-body { flex: 1; min-height: 0; overflow-y: auto; padding: 6px 6px 16px; }
.np-empty { margin: 12px 8px; color: var(--muted); }

.toc-row {
  display: flex;
  align-items: center;
  padding-left: calc(var(--depth, 0) * 14px);
  border-radius: 4px;
}
.toc-row:hover { background: var(--hover); }
.toc-row.active { background: var(--accent-soft); }
.toc-row.active .toc-link { font-weight: 600; }
.toc-caret, .toc-caret-gap {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 26px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
}
.toc-caret svg { transition: transform .12s; }
.toc-row[aria-expanded="true"] > .toc-caret svg { transform: rotate(90deg); }
.toc-link {
  flex: 1;
  min-width: 0;
  padding: 4px 6px 4px 2px;
  border: 0;
  background: none;
  text-align: left;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.toc-row[aria-level="1"] .toc-link { color: var(--text); }
.toc-row:not([aria-level="1"]) .toc-link { color: var(--muted); }
.toc-row.active .toc-link { color: var(--text); }

.res-head {
  margin: 10px 6px 4px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .03em;
}
.res {
  display: block;
  width: 100%;
  margin-bottom: 4px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--field);
  text-align: left;
  line-height: 1.45;
  font-size: 12.5px;
}
.res:hover { border-color: var(--accent-line); }
.res.active { border-color: var(--accent-line); box-shadow: inset 3px 0 0 var(--accent-line); }
.res mark { background: var(--hl); color: inherit; border-radius: 2px; }

.nav-scrim { display: none; }

.canvas {
  position: relative;
  flex: 1;
  min-width: 0;
  overflow: auto;
  background: var(--canvas);
  outline: none;
  scroll-behavior: auto;
}

.busy {
  position: absolute;
  top: 16px;
  left: 50%;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--chrome-2);
  box-shadow: var(--menu-shadow);
  transform: translateX(-50%);
  pointer-events: none;
}
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--line-strong);
  border-top-color: var(--accent-line);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.doc-nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  width: min(var(--page-w), calc(100% - 32px));
  margin: 0 auto;
  padding: 4px 0 48px;
}
.dn-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 48%;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--chrome-2);
  text-align: left;
}
.dn-btn span { display: flex; flex-direction: column; min-width: 0; }
.dn-btn span, .dn-btn small { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.dn-btn small { color: var(--muted); font-size: 11.5px; }
.dn-btn:hover { border-color: var(--accent-line); }
.dn-next { margin-left: auto; text-align: right; }
.dn-next span { align-items: flex-end; }
.dn-end { margin-left: auto; align-self: center; color: var(--muted); }

/* Status bar --------------------------------------------------------------- */

.statusbar {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 28px;
  padding: 0 8px;
  border-top: 1px solid var(--line);
  background: var(--chrome);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.sb-item { padding: 0 8px; }
.sb-btn-text { height: 24px; border: 0; border-radius: 3px; background: none; color: inherit; }
.sb-btn-text:hover { background: var(--hover); }
.sb-spacer { flex: 1; }
.sb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 3px;
  background: none;
  color: inherit;
}
.sb-btn svg { width: 16px; height: 16px; }
.sb-btn:hover { background: var(--hover); color: var(--text); }
.sb-zoom { display: flex; align-items: center; }
.sb-zoom input { width: 110px; accent-color: var(--accent-line); }
.sb-zoomval {
  min-width: 46px;
  height: 24px;
  border: 0;
  border-radius: 3px;
  background: none;
  color: inherit;
}
.sb-zoomval:hover { background: var(--hover); }

/* Backstage (File) --------------------------------------------------------- */

.backstage {
  position: fixed;
  inset: 38px 0 0;
  z-index: 20;
  display: flex;
  background: var(--chrome-2);
}
.bs-side {
  flex: none;
  display: flex;
  flex-direction: column;
  width: 200px;
  padding: 12px 0;
  background: var(--accent);
  color: var(--accent-ink);
}
.bs-back {
  width: 40px;
  height: 40px;
  margin: 0 0 12px 12px;
  border: 1px solid rgba(255, 255, 255, .35);
  border-radius: 50%;
  background: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.bs-back:hover { background: rgba(255, 255, 255, .12); }
.bs-link {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 44px;
  padding: 0 20px;
  border: 0;
  background: none;
  text-align: left;
  font-size: 14px;
}
.bs-link:hover { background: rgba(255, 255, 255, .1); }
a.bs-link { color: inherit; text-decoration: none; }
.bs-link.active { background: rgba(255, 255, 255, .18); font-weight: 600; }
.bs-side-spacer { flex: 1; }
.bs-main {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 28px 44px 48px;
}
.bs-main h1 { margin: 0 0 22px; font-size: 30px; font-weight: 400; }
.bs-h2 { margin: 30px 0 8px; font-size: 15px; font-weight: 600; }
.bs-browse {
  display: flex;
  align-items: center;
  gap: 16px;
  width: min(520px, 100%);
  padding: 16px 18px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--ribbon);
  text-align: left;
}
.bs-browse:hover { border-color: var(--accent-line); background: var(--accent-soft); }
.bs-browse svg { color: var(--accent-line); }
.bs-browse span { display: flex; flex-direction: column; gap: 2px; }
.bs-browse strong { font-size: 15px; font-weight: 600; }
.bs-browse small { color: var(--muted); font-size: 12.5px; }
.bs-empty { max-width: 520px; }

.recent { list-style: none; margin: 0; padding: 0; max-width: 820px; border-top: 1px solid var(--line); }
.recent-item { display: flex; align-items: center; border-bottom: 1px solid var(--line); }
.recent-item:hover { background: var(--hover); }
.recent-item.current .ri-title::after { content: " · open"; color: var(--accent-line); font-weight: 400; font-size: 12px; }
.ri-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 8px 8px 6px;
  border: 0;
  background: none;
  text-align: left;
}
.ri-cover {
  flex: none;
  width: 36px;
  height: 50px;
  border-radius: 2px;
  object-fit: cover;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  background: var(--field);
}
.no-cover { display: inline-flex; align-items: center; justify-content: center; color: var(--muted); }
.ri-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ri-title, .ri-sub { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.ri-title { font-size: 14px; font-weight: 600; }
.ri-sub { color: var(--muted); }
.ri-meta { display: flex; flex-direction: column; align-items: flex-end; color: var(--muted); font-size: 12px; white-space: nowrap; }
.ri-more { margin-right: 6px; }

.info { display: flex; gap: 28px; align-items: flex-start; }
.info-cover { flex: none; width: 140px; height: auto; border-radius: 3px; box-shadow: var(--shadow); }
.info-cover.no-cover { height: 190px; background: var(--field); }
.info-cover.no-cover svg { width: 48px; height: 48px; }
.info-text h2 { margin: 0 0 14px; font-size: 20px; font-weight: 600; }
.props { border-collapse: collapse; }
.props th, .props td { padding: 5px 0; vertical-align: top; text-align: left; }
.props th { width: 150px; padding-right: 16px; color: var(--muted); font-weight: 400; }

.muted { color: var(--muted); }

.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  backdrop-filter: blur(2px);
  pointer-events: none;
}
.drop-overlay > div {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 28px 40px;
  border: 2px dashed var(--accent-line);
  border-radius: 12px;
  background: var(--chrome-2);
  font-size: 16px;
  box-shadow: var(--menu-shadow);
}

/* Dialogs, menus, toasts (ui.js) ------------------------------------------ */

.ui-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, .3);
}
.ui-dialog {
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  border-radius: 8px;
  background: var(--chrome-2);
  box-shadow: var(--menu-shadow);
}
.ui-dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 10px 4px 20px; }
.ui-dialog-head h2 { margin: 0; font-size: 16px; font-weight: 600; }
.ui-dialog-body { padding: 4px 20px 8px; overflow-y: auto; }
.ui-dialog-body p { margin: .5em 0; }
.ui-dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 16px; }
.btn {
  min-width: 80px;
  height: 32px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--field);
}
.btn:hover { background: var(--hover); }
.btn.primary { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.1); }
.field { display: flex; flex-direction: column; gap: 4px; }
.field input { height: 30px; padding: 0 8px; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--field); }

.ui-menu {
  position: fixed;
  z-index: 90;
  min-width: 180px;
  max-height: calc(100vh - 16px);
  overflow-y: auto;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--chrome-2);
  box-shadow: var(--menu-shadow);
}
.ui-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 6px 14px 6px 8px;
  border: 0;
  border-radius: 4px;
  background: none;
  text-align: left;
  white-space: pre;
}
.ui-menu button:hover, .ui-menu button:focus-visible { background: var(--hover); outline: none; }
.ui-menu button.disabled { color: var(--disabled); cursor: default; }
.ui-menu button.disabled:hover { background: none; }
.ui-menu button svg { width: 18px; height: 18px; color: var(--accent-line); }
.ui-menu-gap { flex: none; width: 18px; }
.ui-menu-sep { height: 1px; margin: 4px 6px; background: var(--line); }

.ui-toast {
  position: fixed;
  left: 50%;
  bottom: 44px;
  z-index: 95;
  max-width: calc(100vw - 32px);
  padding: 9px 16px;
  border-radius: 6px;
  background: #323232;
  color: #fff;
  box-shadow: var(--menu-shadow);
  opacity: 0;
  transform: translate(-50%, 8px);
  transition: opacity .18s, transform .18s;
  pointer-events: none;
}
.ui-toast.show { opacity: 1; transform: translate(-50%, 0); }

:focus-visible { outline: 2px solid var(--accent-line); outline-offset: 1px; }

/* Narrow screens ----------------------------------------------------------- */

@media (max-width: 760px) {
  .tb-note, .tb-title { display: none; }
  .titlebar { grid-template-columns: auto minmax(0, 1fr); gap: 10px; }
  .tb-right { display: none; }
  .tb-results { min-width: 0; position: fixed; top: 42px; left: 8px; right: 8px; }
  .tabs { overflow-x: auto; scrollbar-width: none; }
  .ribbon { margin: 0 4px 4px; }
  .ribbon-collapsed.ribbon-peek .ribbon { top: 72px; }
  .panel { min-height: 84px; }
  .rb.big { min-width: 52px; font-size: 11.5px; }
  .sel-font { width: 130px; }

  .navpane {
    position: absolute;
    z-index: 15;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(320px, 86vw);
    box-shadow: var(--menu-shadow);
  }
  .nav-open .nav-scrim {
    display: block;
    position: absolute;
    inset: 0;
    z-index: 14;
    background: rgba(0, 0, 0, .25);
  }

  .sb-wide, .sb-zoom input { display: none; }
  .sb-item { padding: 0 4px; }

  .backstage { flex-direction: column; }
  .bs-side { flex-direction: row; align-items: center; width: auto; padding: 6px 8px; overflow-x: auto; }
  .bs-back { margin: 0 8px 0 0; width: 34px; height: 34px; }
  .bs-link { height: 36px; padding: 0 12px; }
  .bs-side-spacer { display: none; }
  .bs-main { padding: 20px 16px 40px; }
  .bs-main h1 { font-size: 24px; margin-bottom: 16px; }
  .ri-meta { display: none; }
  .info { flex-direction: column; }
  .props th { width: 110px; }
}

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2s; }
  .ui-toast, .toc-caret svg { transition: none; }
}
