/* Visual site: theme tokens and the few primitives several components share.
   Pages and stories sit inside .theme-root; dark is the extra class .theme-root--dark on that element. */
.theme-root {
  --bg: #e8eef5;
  --panel: #fff;
  --fg: #2d3748;
  --muted: #6b7c93;
  --line: #d6dde6;
  --line-soft: #e6ebf1;
  --accent: #1ea7fd;
  --accent-fg: #fff;
  --accent-text: #0a6fb3;
  --icon: #5a6a7e;
  --pill: #f3f6fa;
  --danger: #b42318;
  --danger-bg: #fde8e8;
  --ok: #067647;
  --ok-bg: #e3f6ea;
  --warn: #b54708;
  --warn-bg: #fef3c7;
  --code-bg: #f3f6fa;
  --kind-diff-bg: #fde8e8;
  --kind-diff-fg: #b42318;
  --kind-new-bg: #e3f6ea;
  --kind-new-fg: #067647;
  --kind-removed-bg: #fef3c7;
  --kind-removed-fg: #b54708;
  --kind-light-diff-bg: #fde8e8;
  --kind-light-diff-fg: #b42318;
  --kind-light-new-bg: #e3f6ea;
  --kind-light-new-fg: #067647;
  --kind-light-removed-bg: #fef3c7;
  --kind-light-removed-fg: #b54708;
  --kind-dark-diff-bg: #3d1f1f;
  --kind-dark-diff-fg: #ff8a80;
  --kind-dark-new-bg: #1b3a28;
  --kind-dark-new-fg: #6ee7a8;
  --kind-dark-removed-bg: #3a2e14;
  --kind-dark-removed-fg: #fbbf24;
  --snap-light-bg: #f8f9fa;
  --snap-light-fg: #2b2d31;
  --snap-light-muted: #6c757d;
  --snap-dark-bg: #1a1d21;
  --snap-dark-fg: #e4e6eb;
  --snap-dark-muted: #9ca3af;
  --shadow: 0 18px 48px rgba(15, 23, 42, 0.12);
  --shadow-soft: 0 0 0 1px rgba(0, 0, 0, 0.25), 0 10px 28px rgba(0, 0, 0, 0.22);
  --backdrop: rgba(0, 0, 0, 0.45);
  --topbar-h: 48px;
  --seg-h: 32px;
  --bottom-bar-h: 0px;
  color-scheme: light;
}
.theme-root--dark {
  --bg: #12151a;
  --panel: #1a1d21;
  --fg: #e8edf4;
  --muted: #8b9bb0;
  --line: #2c333c;
  --line-soft: #242a31;
  --accent: #4da3ff;
  --accent-fg: #0b1220;
  --accent-text: #7bbaff;
  --icon: #9aa8b8;
  --pill: #25292f;
  --danger: #ff8a80;
  --danger-bg: #3d1f1f;
  --ok: #6ee7a8;
  --ok-bg: #1b3a28;
  --warn: #fbbf24;
  --warn-bg: #3a2e14;
  --code-bg: #12151a;
  --kind-diff-bg: #3d1f1f;
  --kind-diff-fg: #ff8a80;
  --kind-new-bg: #1b3a28;
  --kind-new-fg: #6ee7a8;
  --kind-removed-bg: #3a2e14;
  --kind-removed-fg: #fbbf24;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.34);
  color-scheme: dark;
}

* { box-sizing: border-box; }
body { margin: 0; }
.theme-root {
  font: 14px/1.4 ui-sans-serif, system-ui, sans-serif;
  background: var(--bg);
  color: var(--fg);
}
.link { color: var(--accent-text); }
.theme-root :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-root [hidden] { display: none !important; }

.page { max-width: 960px; margin: 0 auto; padding: 24px 16px 48px; }
.page--narrow { max-width: 440px; }
.page__title { margin: 0 0 4px; font-size: 24px; line-height: 1.25; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.muted { color: var(--muted); }
.skeleton { color: var(--muted); padding: 24px 0; }

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--fg);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: var(--pill); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn--primary:hover { background: var(--accent); filter: brightness(1.06); }
.btn--small { min-height: 28px; padding: 4px 10px; font-size: 13px; }
.btn--ghost { border-color: transparent; background: transparent; }

.alert { padding: 10px 12px; border-radius: 8px; margin: 0 0 12px; }
.alert--error { background: var(--danger-bg); color: var(--danger); }
.alert--warn { background: var(--warn-bg); color: var(--warn); }

.tag { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--pill); border: 1px solid var(--line); color: var(--muted); max-width: 100%; }
.tag--ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.tag--warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }

.kind { font-size: 11px; font-weight: 700; letter-spacing: 0.04em; padding: 2px 6px; border-radius: 3px; }
.kind--diff { background: var(--kind-diff-bg); color: var(--kind-diff-fg); }
.kind--new { background: var(--kind-new-bg); color: var(--kind-new-fg); }
.kind--removed { background: var(--kind-removed-bg); color: var(--kind-removed-fg); }

@media (max-width: 720px) {
  .page { padding: 16px 16px 40px; }
  .page__title { font-size: 20px; }
}

/* The sticky report bar is one row (52px); the phone's bottom bar is measured by the page (--bottom-bar-h, set on the body),
   these are only the values before the first measurement. */
.theme-root { --header-h: 52px; }
@media (max-width: 720px) { .theme-root { --seg-h: 40px; --bottom-bar-h: 96px; } }

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

/* AdminPage */
.adm__page { padding-bottom: 96px; }
.adm__tabs { display: flex; gap: 4px; margin: 16px 0 0; border-bottom: 1px solid var(--line); }
.adm__tab { appearance: none; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; background: none; color: var(--muted); font: inherit; font-weight: 600; cursor: pointer; }
.adm__tab:hover { color: var(--fg); }
.adm__tab[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--accent); }
.adm__tab-count { padding: 0 7px; border-radius: 999px; background: var(--pill); color: var(--muted); font-size: 12px; font-weight: 600; }
/* one line for the result of the last change; its height is kept so nothing moves when it fills */
.adm__status { min-height: 20px; margin: 10px 0 6px; font-size: 13px; line-height: 20px; color: var(--ok); }
.adm__status[data-bad="true"] { color: var(--danger); }
.adm__panel { min-width: 0; }

.btn--danger { border-color: var(--danger); color: var(--danger); background: transparent; }
.btn--danger:hover:not(:disabled) { background: var(--danger-bg); }

.adm-input, .adm-select { box-sizing: border-box; min-height: 34px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--fg); font: inherit; min-width: 0; }
.adm-input { flex: 1 1 160px; }
.adm-input::placeholder { color: var(--muted); }

.adm-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0 12px; }
.adm-bar__text { flex: 1 1 200px; max-width: 320px; }
.adm-bar__project { flex: 0 1 200px; }
.adm-bar__count { color: var(--muted); font-size: 13px; }
.adm-bar__count--lead { flex: 1; }
.adm-bar__new { margin-left: auto; }

.adm-table { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.adm-head, .adm-row { display: grid; grid-template-columns: var(--adm-cols); align-items: center; }
.adm-head { border-bottom: 1px solid var(--line); }
.adm-th { padding: 8px 12px; font-size: 12px; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.adm-row { border-bottom: 1px solid var(--line-soft); }
.adm-row:last-child { border-bottom: 0; }
.adm-cell { min-width: 0; padding: 10px 12px; }
.adm-tokens .adm-table { --adm-cols: minmax(120px, 1.3fr) 56px 56px minmax(110px, 1.6fr) 74px 74px 84px 84px; }
.adm-projects .adm-table { --adm-cols: minmax(140px, 1.2fr) minmax(90px, 0.8fr) minmax(140px, 1.6fr) 100px 150px 90px; }
.adm-cell--label { overflow: hidden; }
.adm-label { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; font-weight: 600; }
.adm-cell--projects .tag { margin: 1px 2px 1px 0; }
.adm-cell--when { color: var(--muted); font-size: 13px; white-space: nowrap; }
.adm-bar__sort { flex: none; }
.adm-cell--id code { color: var(--muted); font: 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.adm-cell--act { text-align: right; white-space: nowrap; }
.adm-cell--repo { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adm-role { display: inline-block; min-width: 44px; font-weight: 600; }
.adm-empty { margin: 16px 0; color: var(--muted); }
.adm-note { margin: 12px 0 0; color: var(--muted); font-size: 12px; }

@media (max-width: 720px) {
  .adm__page { padding-bottom: 24px; }
  .adm-bar__text, .adm-bar__project { flex: 1 1 100%; max-width: none; }
  .adm-bar__count { flex: 1; }
  .adm-bar__new { margin-left: 0; }
  .adm-table { border: 0; background: none; border-radius: 0; overflow: visible; }
  .adm-head { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .adm-row, .adm-row:last-child { display: block; margin: 0 0 10px; padding: 6px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
  .adm-cell { display: flex; gap: 8px; align-items: baseline; padding: 6px 0; border: 0; }
  .adm-cell::before { content: attr(data-label); flex: 0 0 78px; color: var(--muted); font-size: 12px; }
  .adm-cell--act { justify-content: flex-end; }
  .adm-cell--act::before { content: none; }
  .adm-cell--label { padding-top: 4px; }
  .adm-cell--projects, .adm-cell--repo { flex-wrap: wrap; }
  .adm-cell--projects, .adm-cell--repo { white-space: normal; }
}

/* AppHeader */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--topbar-h);
  padding: 0 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.topbar__brand { display: inline-flex; align-items: center; gap: 8px; color: var(--fg); font-weight: 700; font-size: 16px; text-decoration: none; }
.topbar__logo { width: 20px; height: 20px; color: var(--accent); }
.topbar__grow { flex: 1; min-width: 0; }
.topbar__end { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.topbar__who { color: var(--muted); font-size: 13px; padding: 0 6px; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn { appearance: none; display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--icon); cursor: pointer; }
.icon-btn:hover { background: var(--pill); }
.icon-btn__icon { width: 16px; height: 16px; display: block; }
@media (max-width: 720px) {
  .topbar { padding: 0 10px; }
  .topbar__brand-text, .topbar__who { display: none; }
  }
.topbar__notice { color: var(--danger); font-size: 13px; white-space: nowrap; }
@media (max-width: 720px) { .topbar__notice { white-space: normal; font-size: 12px; } }
.topbar__admin { flex: none; }

/* BranchList */
/* The page of a project: every branch, the base first. */
.blist__warning { margin: 0 0 16px; }
.blist__search { max-width: 360px; margin: 0 0 12px; }
.blist__rows { margin: 0; padding: 4px; list-style: none; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.blist__row + .blist__row { border-top: 1px solid var(--line-soft, var(--line)); }
.blist__empty { margin: 12px 0 0; color: var(--muted); }

/* BranchMenu */
/* The branch menu: a popover under the branch in the bar; on a phone a bottom sheet with its search field at the bottom. */
.bmenu__backdrop { position: fixed; inset: 0; z-index: 30; background: transparent; }
.bmenu__panel { position: absolute; top: calc(100% + 6px); left: 0; z-index: 31; display: flex; flex-direction: column; width: min(460px, 92vw); max-height: min(70vh, 560px); padding: 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--fg); box-shadow: var(--shadow); outline: none; font-weight: 400; }
.bmenu__top { display: none; }
.bmenu__search { flex: none; padding: 4px 4px 8px; }
.bmenu__filter { appearance: none; box-sizing: border-box; width: 100%; height: var(--seg-h, 32px); padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--fg); font: inherit; font-size: 13px; }
.bmenu__filter:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.bmenu__list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.bmenu__empty { margin: 0; padding: 12px; color: var(--muted); font-size: 13px; }
@media (max-width: 720px) {
  .bmenu__backdrop { background: var(--backdrop); }
  .bmenu__panel { position: fixed; left: 0; right: 0; bottom: var(--sheet-gap, 0px); top: auto; width: auto; max-height: calc(100% - 64px); min-height: min(50%, 360px); padding: 0 8px calc(8px + env(safe-area-inset-bottom, 0px)); border: 0; border-radius: 16px 16px 0 0; }
  .bmenu__top { display: flex; flex: none; flex-direction: column; align-items: center; gap: 6px; padding: 10px 8px 6px; }
  .bmenu__title { align-self: flex-start; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
  .bmenu__handle { width: 40px; height: 4px; border-radius: 2px; background: var(--line); }
  /* the thumb rule: the list above, the field at the bottom */
  .bmenu__list { order: 1; }
  .bmenu__search { order: 2; padding: 8px 0 0; border-top: 1px solid var(--line-soft, var(--line)); }
  .bmenu__filter { height: 40px; font-size: 16px; }
}

/* BranchRow */
/* One branch: name (the base marked), what changed, and when it was published, right-aligned; a branch compared with another
   baseline than the current one carries a muted chip before the time. */
.brow { display: grid; grid-template-columns: minmax(0, 1.4fr) auto minmax(0, 1fr); align-items: center; gap: 4px 16px; padding: 10px 12px; border-radius: 8px; color: inherit; text-decoration: none; }
.brow:hover { background: var(--pill); }
.brow:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.brow--current { background: var(--pill); box-shadow: inset 0 0 0 1px var(--line); }
.brow__main { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.brow__name { overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.brow__tag { flex: none; padding: 0 6px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); font-size: 11px; }
.brow__facts { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-size: 12px; }
.brow__kind { font-size: 10px; }
.brow__when { display: flex; align-items: center; justify-content: flex-end; gap: 8px; min-width: 0; overflow: hidden; color: var(--muted); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.brow__older { flex: none; padding: 0 6px; border: 1px dashed var(--line); border-radius: 10px; font-size: 11px; cursor: help; }
.brow--menu, .brow--menu:hover { grid-template-columns: minmax(0, 1fr) auto; }
.brow--menu .brow__when { grid-column: 1 / -1; grid-row: 2; }
.brow--menu .brow__facts { justify-content: flex-end; }
@media (max-width: 720px) {
  /* name on the first line, what changed on the second, the time at the right edge on the third */
  .brow, .brow--menu, .brow--menu:hover { grid-template-columns: minmax(0, 1fr); padding: 12px; }
  .brow__main, .brow .brow__facts, .brow--menu .brow__facts, .brow .brow__when, .brow--menu .brow__when { grid-column: 1; }
  .brow .brow__facts, .brow--menu .brow__facts { justify-content: flex-start; }
}

/* CodeBox */
.codebox { position: relative; border: 1px solid var(--line); border-radius: 8px; background: var(--code-bg); }
.codebox__text {
  margin: 0;
  padding: 12px 56px 12px 12px;
  white-space: pre;
  overflow-x: auto;
  /* the box has rounded corners: the text and its fades must not paint over them */
  border-radius: 7px;
  /* a fade at an edge that has more to scroll to (scroll-shadow trick: the fades are fixed, the covers scroll) */
  background:
    linear-gradient(to right, var(--code-bg) 30%, transparent) left center / 24px 100% no-repeat local,
    linear-gradient(to left, var(--code-bg) 30%, transparent) right center / 24px 100% no-repeat local,
    linear-gradient(to right, color-mix(in srgb, var(--fg) 18%, transparent), transparent) left center / 14px 100% no-repeat scroll,
    linear-gradient(to left, color-mix(in srgb, var(--fg) 18%, transparent), transparent) right center / 14px 100% no-repeat scroll;
  font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.codebox__copy { appearance: none; position: absolute; top: 50%; right: 4px; transform: translateY(-50%); display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--icon); cursor: pointer; }
.codebox__copy:hover:not(:disabled) { background: var(--pill); color: var(--fg); }
.codebox__copy:disabled { opacity: 0.35; cursor: not-allowed; }
.codebox .codebox__icon { display: none; width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.codebox__copy[data-state="idle"] .codebox__icon--copy, .codebox__copy[data-state="done"] .codebox__icon--done, .codebox__copy[data-state="failed"] .codebox__icon--failed { display: block; }
.codebox__copy[data-state="done"] { color: var(--ok); }
.codebox__copy[data-state="failed"] { color: var(--danger); }
.codebox__hint { position: absolute; top: 50%; right: 48px; transform: translateY(-50%); padding: 2px 8px; border-radius: 6px; background: var(--danger-bg); color: var(--danger); font-size: 12px; pointer-events: none; }
.codebox__hint:empty { display: none; }

/* ComponentNav */
/* One list of components, two layouts: a collapsible column beside the snapshots, a bottom sheet on phones. */
.nav-host { display: contents; }
.nav--column { position: sticky; top: var(--header-h); height: calc(100vh - var(--header-h)); background: var(--panel); border-right: 1px solid var(--line); }
.nav__layer { position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; justify-content: flex-end; }
.nav__backdrop { position: absolute; inset: 0; background: var(--backdrop); touch-action: none; overscroll-behavior: contain; }
.nav--sheet {
  position: relative;
  display: flex;
  flex-direction: column;
  /* a strip of the backdrop always stays above, to tap on; the layer already ends above the keyboard */
  max-height: calc(100% - 64px - var(--sheet-gap, var(--bottom-bar-h)));
  min-height: min(50%, 360px);
  margin-bottom: var(--sheet-gap, var(--bottom-bar-h));
  border-radius: 16px 16px 0 0;
  background: var(--panel);
  box-shadow: var(--shadow);
  outline: none;
}
.nav__top { flex: none; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 16px 6px; touch-action: none; cursor: grab; }
.nav__title { align-self: flex-start; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.nav__handle { width: 40px; height: 4px; border-radius: 2px; background: var(--line); }
.nav--sheet .toc { flex: 1; min-height: 0; }

/* ComponentSearch */
.search { position: relative; }
.search__input { width: 100%; padding: 6px 32px 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--fg); font: inherit; }
.search__clear { appearance: none; position: absolute; top: 50%; right: 4px; transform: translateY(-50%); display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--icon); cursor: pointer; }
.search__clear:hover { background: var(--pill); }
.search .search__icon { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
@media (max-width: 720px) {
  .search__input { min-height: 44px; padding-right: 44px; font-size: 16px; }
  .search__clear { width: 36px; height: 36px; right: 4px; }
}

/* ComponentSwitcher */
/* One outlined group: the arrows are its end segments, the name button the middle one, thin dividers between. */
.switcher { display: flex; align-items: stretch; min-width: 0; height: var(--seg-h); border: 1px solid var(--line); border-radius: 8px; background: var(--panel); overflow: hidden; }
.switcher__seg { appearance: none; display: flex; align-items: center; justify-content: center; min-width: 0; margin: 0; padding: 0; border: 0; border-radius: 0; background: transparent; color: var(--fg); font: inherit; cursor: pointer; }
.switcher__seg:hover:not(:disabled) { background: var(--pill); }
.switcher__seg:disabled { opacity: 0.35; cursor: not-allowed; }
.switcher__seg + .switcher__seg { border-left: 1px solid var(--line); }
.switcher__step { flex: none; width: 34px; color: var(--icon); }
.switcher .switcher__icon { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.switcher__name { flex: 1; justify-content: flex-start; gap: 8px; padding: 0 10px; font-weight: 600; text-align: left; }
.switcher__text { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.switcher__count { flex: none; color: var(--muted); font-weight: 500; }
.switcher__mark { flex: none; font-size: 10px; }
@media (max-width: 720px) {
  .switcher__step { width: 44px; }
}

/* Dropdown */
/* A button showing the current value with a chevron; the menu opens below it, and above it from the bottom bar on phones. */
.dd { position: relative; flex: none; }
.dd__btn { appearance: none; display: inline-flex; align-items: center; gap: 6px; height: var(--seg-h); box-sizing: border-box; max-width: 100%; padding: 0 8px 0 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--fg); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.dd__btn:hover { background: var(--pill); }
.dd__btn[aria-expanded="true"] { background: var(--pill); }
.dd__btn:focus-visible, .dd__option:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.dd__value { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd .dd__chevron { flex: none; width: 16px; height: 16px; fill: none; stroke: var(--icon); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.dd__backdrop { position: fixed; inset: 0; z-index: 30; }
.dd__menu { position: absolute; top: calc(100% + 4px); left: 0; z-index: 31; display: flex; flex-direction: column; min-width: 100%; max-height: 60vh; overflow: auto; padding: 4px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); box-shadow: var(--shadow); }
.dd__option { appearance: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 32px; margin: 0; padding: 0 8px; border: 0; border-radius: 6px; background: transparent; color: var(--fg); font: inherit; font-size: 13px; text-align: left; white-space: nowrap; cursor: pointer; }
.dd__option:hover { background: var(--pill); }
.dd__option[aria-selected="true"] { font-weight: 600; }
.dd .dd__check { width: 16px; height: 16px; fill: none; stroke: var(--accent-text); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; visibility: hidden; }
.dd__option[aria-selected="true"] .dd__check { visibility: visible; }
@media (max-width: 720px) {
  .dd__menu { top: auto; bottom: calc(100% + 4px); }
  .dd__option { min-height: 44px; }
}

/* GetStarted */
.get-started__ai { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; margin: 0 0 28px; }
.get-started__llm { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; }
.get-started__check { display: none; width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.get-started__llm[data-state="done"] .get-started__check { display: block; }
.get-started__hint { margin: 0; }
.get-started__or { margin: 0 0 12px; font-size: 16px; }
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 24px; }
.step { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.step__title { display: flex; align-items: baseline; gap: 10px; margin: 0; font-size: 15px; }
.step__n { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.step__text { margin: 0; }
.get-started__next { margin: 24px 0 0; }

/* InstallCommand */
.install-command { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.install-command .codebox { align-self: stretch; }
.install-command__script { font-size: 13px; }

/* LibraryCard */
.lcard { appearance: none; display: flex; flex-direction: column; gap: 4px; min-width: 0; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: inherit; font: inherit; text-align: left; cursor: pointer; }
.lcard:hover { border-color: var(--muted); }
.lcard:focus-visible { outline: 2px solid var(--focus, currentColor); outline-offset: 2px; }
.lcard__preview, .lcard__folder { display: flex; align-items: center; justify-content: center; aspect-ratio: 4 / 3; overflow: hidden; border-radius: 6px; background: var(--snap-light-bg); }
.theme-root--dark .lcard__preview { background: var(--snap-dark-bg); }
.lcard__img { display: block; max-width: 100%; max-height: 100%; object-fit: contain; }
.lcard__folder { background: var(--pill); color: var(--muted); }
.lcard__folder-icon { width: 40%; height: 40%; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; }
.lcard__name { overflow: hidden; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.lcard__where { overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.lcard__foot { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; color: var(--muted); font-size: 12px; }
.lcard__badge { font-size: 10px; }
/* a quiet skeleton while the preview is on its way; once nothing is loading the placeholder is plain */
.lcard__preview--loading { background-image: linear-gradient(100deg, transparent 30%, color-mix(in srgb, var(--fg) 7%, transparent) 50%, transparent 70%); background-size: 220% 100%; animation: lcard-skeleton 1.4s ease-in-out infinite; }
@keyframes lcard-skeleton { from { background-position: 120% 0; } to { background-position: -120% 0; } }
@media (prefers-reduced-motion: reduce) { .lcard__preview--loading { animation: none; } }

/* LibraryGrid */
.lgrid { padding: 16px 20px 24px; }
.lgrid__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; margin-bottom: 12px; }
.lgrid__crumbs { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px; min-width: 0; font-size: 15px; }
.lgrid__crumb { appearance: none; padding: 0; border: 0; background: transparent; color: var(--muted); font: inherit; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.lgrid__crumb:hover { color: var(--fg); }
.lgrid__sep { color: var(--muted); }
.lgrid__here { font-weight: 650; }
.lgrid__count { margin: 0; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.lgrid__cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.lgrid__heading { grid-column: 1 / -1; margin: 12px 0 0; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.lgrid__heading:first-child { margin-top: 0; }
.lgrid__empty { margin: 16px 0; color: var(--muted); }
.lgrid__search { max-width: 360px; margin-top: 16px; }
@media (max-width: 720px) {
  .lgrid { padding: 12px 12px calc(var(--bottom-bar-h, 0px) + 12px); }
  .lgrid__cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  /* the thumb rule: the search field is at the bottom of the screen */
  .lgrid__search { position: sticky; bottom: var(--bottom-bar-h, 0px); max-width: none; margin: 16px -12px 0; padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line-soft); background: var(--bg); }
}

/* LoginForm */
.login-page {
  min-height: 100vh;
  min-height: 100dvh;
  padding: 20px 24px;
  display: grid;
  grid-template-rows: 1fr auto 1fr;
}
.login-page__brand { grid-row: 1; align-self: start; justify-self: start; display: flex; align-items: center; gap: 10px; }
.login-page__logo { width: 28px; height: 28px; }
.login-page__name { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.login-page__card {
  grid-row: 2;
  justify-self: center;
  width: min(100%, 420px);
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.login-form { margin: 0; display: flex; flex-direction: column; gap: 20px; }
.login-form__title { margin: 0; font-size: 22px; line-height: 1.25; }
.login-form__error { margin: -8px 0 0; color: var(--danger); font-size: 14px; }
.login-form__field { display: flex; flex-direction: column; gap: 8px; }
.login-form__label { font-size: 14px; font-weight: 500; }
.login-form__input {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-size: 16px;
}
.login-form__actions { display: flex; flex-direction: column; gap: 16px; }
.login-form__submit { width: 100%; min-height: 48px; border-radius: 12px; font-size: 16px; }
.login-form__link { align-self: center; }
/* Stays in the form for password managers, but is not seen or reached with Tab. */
.login-form__username { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip: rect(0 0 0 0); opacity: 0; }
@media (max-width: 640px) {
  /* Phones: the title and the field are information; the button is the action, so it sits at the bottom. */
  .login-page { padding: 16px 20px calc(16px + env(safe-area-inset-bottom, 0px)); grid-template-rows: auto 1fr; gap: 24px; }
  .login-page__card { grid-row: 2; display: flex; flex-direction: column; align-self: stretch; }
  .login-form { flex: 1; }
  .login-form__actions { margin-top: auto; }
  .login-form__submit { min-height: 48px; }
  .login-page__card { width: 100%; padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
  .login-form__input { font-size: 16px; }
}

/* Loupe */
.loupe {
  position: fixed;
  width: 168px;
  height: 168px;
  border: 3px solid var(--panel);
  border-radius: 50%;
  overflow: hidden;
  pointer-events: none;
  z-index: 10;
  background: var(--snap-light-bg);
  box-shadow: var(--shadow-soft);
}
.loupe--dark { background: var(--snap-dark-bg); }
.loupe__canvas { display: block; width: 100%; height: 100%; }

/* PreviewBanner */
/* A thin strip above everything, so it never covers a control; the sticky bars sit below it (--preview-h). */
.preview-banner { position: sticky; top: 0; z-index: 40; display: flex; align-items: center; justify-content: center; gap: 12px; height: 28px; padding: 0 12px; background: var(--warn-bg); color: var(--warn); border-bottom: 1px solid var(--line); font-size: 13px; }
.preview-banner__exit { color: inherit; font-weight: 600; text-decoration: underline; }
.theme-root:has(.preview-banner) { --preview-h: 28px; }
.rh, .topbar { top: var(--preview-h, 0px); }
.nav--column { top: calc(var(--header-h) + var(--preview-h, 0px)); height: calc(100vh - var(--header-h) - var(--preview-h, 0px)); }

/* ProjectCard */
.project { display: flex; flex-direction: column; gap: 10px; min-width: 0; padding: 0; overflow: hidden; }
.project__head { padding: 14px 16px 0; }
.project__name { margin: 0; font-size: 18px; overflow-wrap: anywhere; }
.project__link { color: inherit; text-decoration: none; }
.project__link:hover { text-decoration: underline; }
.project__slug { color: var(--muted); font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.project__facts { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px; }
.project__repo { font-size: 13px; overflow-wrap: anywhere; }
.project__branches { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--line-soft); }
.project__branch-row { border-bottom: 1px solid var(--line-soft); }
.project__branch-row:last-child { border-bottom: 0; }
.project__branch { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 6px 16px; color: var(--fg); text-decoration: none; font-size: 13px; }
.project__branch:hover { background: var(--pill); }
.project__branch-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project__when { color: var(--muted); font-size: 12px; white-space: nowrap; }
.project__more { padding: 8px 16px; border-top: 1px solid var(--line-soft); color: var(--accent-text); font-size: 13px; cursor: pointer; }
.project__more:hover { background: var(--pill); }
.project__rest[open] > .project__more { border-bottom: 0; }
.project:target { outline: 2px solid var(--accent); outline-offset: -2px; }
.project__none { padding: 10px 16px; color: var(--muted); font-size: 13px; }
.changes { font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 3px; background: var(--danger-bg); color: var(--danger); }
.changes--zero { background: var(--ok-bg); color: var(--ok); }
@media (max-width: 720px) {
  .project { border-radius: 0; border-left: 0; border-right: 0; border-top: 0; }
}

/* ProjectsList */
.projects { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr)); gap: 16px; }
@media (max-width: 720px) {
  .projects { gap: 0; margin: 0 -16px; }
}
.projects__footer { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 32px; padding-top: 12px; border-top: 1px solid var(--line-soft); color: var(--muted); font-size: 13px; }
.projects__footer strong { color: var(--fg); font-weight: 600; }
.projects__signout { appearance: none; padding: 0; border: 0; background: none; color: var(--accent-text); font: inherit; cursor: pointer; }
.projects__signout:hover { text-decoration: underline; }
.projects__notice { color: var(--danger); }

/* ReportBody */
.snap-band--light { --kind-diff-bg: var(--kind-light-diff-bg); --kind-diff-fg: var(--kind-light-diff-fg); --kind-new-bg: var(--kind-light-new-bg); --kind-new-fg: var(--kind-light-new-fg); --kind-removed-bg: var(--kind-light-removed-bg); --kind-removed-fg: var(--kind-light-removed-fg); }
.snap-band--dark { --kind-diff-bg: var(--kind-dark-diff-bg); --kind-diff-fg: var(--kind-dark-diff-fg); --kind-new-bg: var(--kind-dark-new-bg); --kind-new-fg: var(--kind-dark-new-fg); --kind-removed-bg: var(--kind-dark-removed-bg); --kind-removed-fg: var(--kind-dark-removed-fg); }
.report__empty { padding: 20px; color: var(--muted); }
.snap-band--light { background: var(--snap-light-bg); color: var(--snap-light-fg); --muted: var(--snap-light-muted); }
.snap-band--dark { background: var(--snap-dark-bg); color: var(--snap-dark-fg); --muted: var(--snap-dark-muted); }
.report__dark-title { margin: 0; padding: 16px 20px 0; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }

/* ReportHeader */
/* One bar for the report page: sidebar toggle, then where you are, what you compare, tools and account. One row at
   every width from a tablet up; what does not fit gives way in order: the breadcrumb shrinks, the layout pill becomes a
   select, the rarely used tools move into a menu. */
.rh {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 8px 12px;
  height: 52px;
  padding: 0 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.rh__controls { display: contents; }
.rh__toggle { order: 0; flex: none; margin-left: -4px; }
.rh__nav { order: 2; flex: 0 1 300px; min-width: 120px; }
.rh__left { order: 1; flex: 0 1 auto; display: flex; align-items: center; gap: 8px; min-width: 0; }
.rh__mid { order: 3; flex: 1 1 0; display: flex; justify-content: center; align-items: center; gap: 8px; min-width: max-content; }
.rh__tools { order: 4; flex: none; display: flex; align-items: center; gap: 4px; }
.rh__account { order: 5; flex: none; display: flex; align-items: center; gap: 4px; margin-left: auto; }
.rh__brand { display: inline-flex; flex: none; color: var(--accent); }
.rh__logo { width: 22px; height: 22px; }
.rh__crumb { display: flex; align-items: baseline; gap: 6px; min-width: 0; color: var(--muted); flex: 0 1 auto; }
.rh__crumb-link { color: var(--muted); text-decoration: none; }
.rh__crumb-link:hover { color: var(--fg); text-decoration: underline; }
.rh__sep { color: var(--line); }
.rh__project { color: var(--fg); font-weight: 650; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.rh__project:hover { text-decoration: underline; }
.rh__switch { position: relative; display: inline-flex; min-width: 0; flex: 0 1 auto; }
/* the branch is text with a small chevron: the one control that switches branches, no box around it */
.rh__branch { appearance: none; display: inline-flex; align-items: baseline; gap: 6px; min-width: 0; padding: 0; border: 0; border-radius: 4px; background: transparent; color: var(--fg); font: inherit; white-space: nowrap; cursor: pointer; }
.rh__branch:hover .rh__branch-text { text-decoration: underline; }
.rh__branch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.rh__branch-text { min-width: 0; overflow: hidden; }
.rh__chevron { align-self: center; flex: none; width: 12px; height: 12px; fill: none; stroke: var(--muted); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.rh__changes { color: var(--muted); font-size: inherit; line-height: inherit; font-variant-numeric: tabular-nums; flex: none; margin-left: -2px; }
.rh__modes-dd { display: none; }
.rh__btn { appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--icon); cursor: pointer; font: inherit; font-size: 13px; font-weight: 600; list-style: none; }
.rh__btn::-webkit-details-marker { display: none; }
.rh__btn:hover { background: var(--pill); }
.rh__btn[aria-pressed="true"] { background: var(--pill); color: var(--fg); box-shadow: inset 0 0 0 1px var(--line); }
.rh__btn:focus-visible, .rh__toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.rh__btn:disabled { opacity: 0.35; cursor: not-allowed; }
.rh__btn--wide { width: auto; padding: 0 8px; }
.rh__icon { width: 16px; height: 16px; display: block; }
.rh .rh__icon--line { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.rh__more-slot { display: contents; }
.rh__more { display: none; position: relative; }
/* the two extra tools are always there so nothing moves when Diff is switched; without Diff they are dimmed */
.rh__more--off { opacity: 0.4; pointer-events: none; }
.rh__menu { position: absolute; top: calc(100% + 6px); right: 0; z-index: 7; display: flex; gap: 4px; padding: 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); box-shadow: var(--shadow); }
.rh__notice { position: absolute; left: 16px; right: 16px; top: 100%; padding: 6px 0; background: var(--panel); color: var(--danger); font-size: 13px; }

/* Not enough room for the layout switch: a dropdown takes its place. */
@media (max-width: 1400px) {
  .rh__modes-seg { display: none; }
  .rh__modes-dd { display: block; }
}
/* Tablet: the breadcrumb keeps the project name only, Autofocus and Party move into the menu. */
@media (max-width: 1000px) {
  .rh__crumb-link, .rh__sep { display: none; }
  .rh__inline { display: none; }
  .rh__more { display: block; }
  .rh__nav { flex-basis: 220px; }
}
@media (max-width: 860px) {
  .rh { padding: 0 10px; gap: 8px; }
  .rh__btn-label { display: none; }
  .rh__btn--wide { width: 32px; padding: 0; }
  .rh__nav { flex-basis: 180px; min-width: 150px; }
  }
@media (max-width: 720px) {
  .rh { padding: 0 10px; }
  .rh__toggle { display: none; }
  .rh__left { flex: 1 1 auto; }
  .rh__crumb { display: flex; }
  /* The controls sit in a bar at the bottom of the screen, within thumb reach; its height is measured, not assumed. */
  .rh__controls {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 6;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
    background: var(--panel);
    border-top: 1px solid var(--line);
  }
  .rh__nav { order: 0; flex: 0 0 100%; }
  .rh__mid { order: 1; flex: 0 1 auto; min-width: 0; justify-content: flex-start; gap: 6px; }
  .rh__tools { order: 2; margin-left: auto; }
  .rh__btn { width: 38px; height: 38px; }
  .rh__btn--wide { width: 38px; padding: 0; }
  .rh__menu { top: auto; bottom: calc(100% + 8px); }
}
@media (max-width: 400px) {
  .rh__tools { gap: 2px; }
  .rh__btn { width: 36px; }
  }

/* The layout switch and Diff are always in the bar, so nothing moves from story to story; without two pictures they are muted */
.rh__modes { display: flex; align-items: center; min-width: 0; margin: 0; padding: 0; border: 0; }
.rh__modes:disabled { opacity: 0.45; }
.rh__modes:disabled .seg__btn, .rh__modes:disabled .dd__btn { opacity: 1; cursor: not-allowed; }
.rh__modes-dd .dd__btn { min-width: 92px; justify-content: space-between; } /* the widest label ("Swipe") fits: choosing a layout never resizes the bar */
.rh__admin { display: inline-flex; align-items: center; height: 32px; padding: 0 10px; border-radius: 8px; color: var(--fg); font-size: 13px; font-weight: 600; text-decoration: none; }
.rh__admin:hover { background: var(--pill); }
@media (max-width: 720px) { .rh__admin { display: none; } }

/* ReportLayout */
.rl__banner { margin: 12px 20px 0; }
.rl__shell { display: grid; grid-template-columns: 260px minmax(0, 1fr); align-items: start; }
.rl__shell--single { grid-template-columns: minmax(0, 1fr); }
.rl__main { min-width: 0; scroll-margin-top: var(--header-h); }
@media (max-width: 720px) {
  .rl__banner { margin: 12px 12px 0; }
  .rl__main { min-height: 100vh; min-height: 100dvh; padding-bottom: calc(var(--bottom-bar-h) + 16px + env(safe-area-inset-bottom, 0px)); }
}

/* ReportScreen */
.rs__loading { padding: 24px 16px; max-width: 960px; margin: 0 auto; }

/* ReportToc */
.toc { display: flex; flex-direction: column; min-height: 0; height: 100%; padding: 12px 16px; }
.toc__head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.toc__title { color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.toc .toc__icon { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.toc__search { margin-bottom: 8px; }
.toc__search--bottom { flex: none; display: flex; align-items: center; gap: 8px; margin: 8px 0 0; padding-bottom: env(safe-area-inset-bottom, 0px); border-top: 1px solid var(--line-soft); padding-top: 8px; }
.toc__list { flex: 1; min-height: 0; overflow: auto; /* the window changes the spacers as it moves: the browser must not "anchor" the scroll position to a row */ overflow-anchor: none; }
.toc__group { appearance: none; display: flex; align-items: flex-end; gap: 4px; box-sizing: border-box; width: 100%; height: 30px; margin: 0; padding: 0 8px 4px; overflow: hidden; border: 0; background: transparent; white-space: nowrap; color: var(--muted); font: inherit; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-align: left; text-transform: uppercase; cursor: pointer; }
.toc__group:hover { color: var(--fg); }
.toc__chev { flex: none; width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; transform: rotate(90deg); transition: transform 0.12s; }
.toc__group[aria-expanded="false"] .toc__chev { transform: none; }
.toc__group-name { overflow: hidden; text-overflow: ellipsis; }
.toc__folder { box-sizing: border-box; height: 26px; padding: 8px 8px 0; overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.toc__row { display: flex; flex-wrap: nowrap; align-items: center; gap: 6px; width: 100%; height: 36px; min-width: 0; margin: 0; padding: 0 8px; overflow: hidden; border: 0; border-radius: 6px; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.toc__row:hover { background: var(--pill); }
.toc__row[aria-current="true"] { background: var(--pill); }
.toc__name { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toc__count { flex: none; color: var(--muted); font-size: 12px; }
.toc__mark { flex: none; font-size: 10px; }
@media (max-width: 720px) {
  .toc__search { margin-bottom: 8px; }
.toc__search--bottom { flex: none; display: flex; align-items: center; gap: 8px; margin: 8px 0 0; padding-bottom: env(safe-area-inset-bottom, 0px); border-top: 1px solid var(--line-soft); padding-top: 8px; }
  .toc__row { height: 44px; }
}
.toc__empty { margin: 12px 8px; color: var(--muted); }
.toc__search--bottom .search { flex: 1; min-width: 0; }
.toc__close { appearance: none; flex: none; display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0; border: 1px solid var(--line); border-radius: 10px; background: transparent; color: var(--icon); cursor: pointer; }
.toc__close:hover { background: var(--pill); }
.toc__head[hidden] { display: none; }

/* Segmented */
/* A segmented switch in the family of the other controls: 32px (40px on phones), 8px radius, 1px border, a quiet selected
   segment (the muted fill with a hairline, bold text), a focus ring only for the keyboard. */
.seg { display: inline-flex; align-items: center; flex: none; gap: 2px; height: var(--seg-h); box-sizing: border-box; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.seg__btn { appearance: none; height: 100%; margin: 0; padding: 0 12px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font: inherit; font-size: 13px; font-weight: 500; white-space: nowrap; cursor: pointer; }
.seg__btn:hover:not(:disabled) { background: color-mix(in srgb, var(--pill) 45%, transparent); color: var(--fg); }
.seg__btn[aria-checked="true"] { background: var(--pill); color: var(--fg); font-weight: 600; box-shadow: inset 0 0 0 1px var(--line); }
.seg__btn[aria-checked="true"]:hover:not(:disabled) { background: var(--pill); }
/* what changed: a small amber diamond after the label, never a fill, so it cannot be read as the selection */
.seg__mark { display: inline-block; width: 6px; height: 6px; margin-left: 6px; vertical-align: middle; border-radius: 1px; transform: rotate(45deg); background: var(--kind-diff-fg, currentColor); }
.seg__btn:disabled { opacity: 0.4; cursor: not-allowed; }
.seg__btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
@media (max-width: 720px) { .seg__btn { padding: 0 10px; } }

/* SnapshotCard */
.snap { padding: 16px 20px 24px; }
.snap__meta { display: flex; gap: 10px; align-items: baseline; margin-bottom: 12px; }
.snap__note { margin: 0; padding: 24px 12px; border: 1px dashed var(--line); border-radius: 8px; color: var(--muted); font-size: 13px; text-align: center; }
.snap__id { font-weight: 650; }
.snap__link { color: inherit; }
.snap__status { margin: 0; color: var(--muted); }
.snap__status--error { color: var(--kind-diff-fg); }
.snap__side { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; align-items: start; }
.snap__side .snap__figure { min-width: 0; padding: 0 16px; }
.snap__side .snap__figure + .snap__figure { border-left: 1px solid var(--line); }
.snap__side .snap__figure:first-child { padding-left: 0; }
.snap__side .snap__figure:last-child { padding-right: 0; }
.snap__figure { margin: 0; }
.snap__caption { margin-bottom: 10px; color: var(--muted); font-size: 13px; font-weight: 600; }
.snap__img { display: block; max-width: 100%; height: auto; }
.snap[data-crisp="true"] .snap__img { image-rendering: pixelated; }
/* A picture fills its pane in whole steps (2x, 3x, ...) so small ones stay crisp, and shrinks to fit when the pane is narrower. */
.snap__zoom { container-type: inline-size; min-width: 0; --uwpx: calc(var(--uw) * 1px); }
.snap__frame, .snap__swipe, .snap__onion { position: relative; display: block; box-sizing: border-box; max-width: 100%; width: min(100%, var(--uwpx)); margin: 0 auto; line-height: 0; }
@supports (width: round(down, 100px, 7px)) {
  .snap__frame, .snap__swipe, .snap__onion { width: min(calc(var(--uwpx) * 4), max(min(100cqw, var(--uwpx)), round(down, 100cqw, var(--uwpx)))); }
}
.snap__dim { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.snap[data-autofocus="true"] .snap__frame, .snap[data-autofocus="true"] .snap__oneup { cursor: none; }
.snap__oneup, .snap__stack { display: none; }
.snap--diff[data-mode="one"] .snap__side, .snap--diff[data-mode="swipe"] .snap__side, .snap--diff[data-mode="onion"] .snap__side { display: none; }
.snap--diff[data-mode="one"] .snap__oneup { display: block; }
.snap--diff[data-mode="swipe"] .snap__stack--swipe { display: block; }
.snap--diff[data-mode="onion"] .snap__stack--onion { display: block; }
.snap__swipe, .snap__onion { aspect-ratio: var(--uw) / var(--uh); }
.snap__swipe { touch-action: pan-y; cursor: ew-resize; }
.snap__under, .snap__over { position: absolute; inset: 0; overflow: hidden; }
.snap__swipe .snap__under { clip-path: inset(0 calc(100% - var(--swipe-reveal, 50%)) 0 0); }
.snap__swipe .snap__over { clip-path: inset(0 0 0 var(--swipe-reveal, 50%)); }
.snap__under--onion { opacity: var(--onion-base, 1); }
.snap__over--onion { opacity: calc(var(--onion, 50) / 100); }
.snap__img--layer { position: absolute; top: 0; left: 0; max-width: none; height: auto; }
.snap__rule { position: absolute; top: 0; bottom: 0; left: var(--swipe-reveal, 50%); width: 0; border-left: 1px dotted var(--muted); pointer-events: none; }
/* The comparison control of Swipe and Onion sticks to the bottom of the visible area while its mode is on, so it works however tall
   the picture is; it follows the picture in the flow, so the last rows are never hidden behind it. */
.snap__slider { position: sticky; bottom: 0; z-index: 4; display: flex; align-items: center; gap: 10px; box-sizing: border-box; margin: 8px calc(-1 * var(--snap-pad, 20px)) 0; padding: 8px var(--snap-pad, 20px); border-top: 1px solid var(--line); background: var(--panel); color: var(--muted); font-size: 12px; }
.snap__rangewrap { position: relative; display: block; flex: 1; max-width: 420px; padding-bottom: 12px; }
.snap__ticks { position: absolute; left: 8px; right: 8px; bottom: -2px; display: flex; justify-content: space-between; font-style: normal; font-size: 10px; line-height: 1; pointer-events: none; }
.snap__ticks i { font-style: normal; }
.snap__value { min-width: 3ch; font-variant-numeric: tabular-nums; text-align: right; color: var(--fg); }
.snap__reset { appearance: none; min-width: 32px; height: 24px; padding: 0 8px; border: 1px solid var(--line); border-radius: 12px; background: transparent; color: var(--muted); font: inherit; font-size: 11px; cursor: pointer; }
.snap__reset:hover { background: var(--pill); color: var(--fg); }
.snap__range { width: 100%; margin: 0; }
@media (max-width: 720px) {
  .snap__side { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .snap__side .snap__figure, .snap__side .snap__figure:first-child, .snap__side .snap__figure:last-child { padding: 0; }
  .snap__side .snap__figure + .snap__figure { border-left: 0; padding-top: 16px; border-top: 1px solid var(--line); }
  .snap { padding: 12px 12px 20px; --snap-pad: 12px; }
  /* the same bottom zone as the other working controls: above the bottom bar */
  .snap__slider { bottom: var(--bottom-bar-h, 0px); }
}
.snap__placeholder { max-width: 100%; border-radius: 8px; background: color-mix(in srgb, var(--muted) 12%, transparent); }
/* Before the size of the picture is known the card keeps roughly the room the picture will take, so the cards below do not jump. */
.snap__status--loading { min-height: 200px; }
.snap--diff[data-mode="one"] .snap__side--loading, .snap--diff[data-mode="swipe"] .snap__side--loading, .snap--diff[data-mode="onion"] .snap__side--loading { display: flex; }
.snap--diff[data-mode="one"] .snap__side--loading .snap__figure + .snap__figure, .snap--diff[data-mode="swipe"] .snap__side--loading .snap__figure + .snap__figure, .snap--diff[data-mode="onion"] .snap__side--loading .snap__figure + .snap__figure { display: none; }

/* StateMessage */
.state { text-align: center; padding: 40px 16px; color: var(--muted); }
.state__title { margin: 0 0 6px; color: var(--fg); font-size: 18px; }
.state__text { margin: 0 0 14px; overflow-wrap: anywhere; }
.state__actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
@media (max-width: 720px) {
  /* the way out of an error is the frequent action: a bar at the bottom, within thumb reach */
  .state { padding-bottom: 120px; }
  .state__actions { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; flex-direction: column; padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px)); background: var(--panel); border-top: 1px solid var(--line); }
  .state__actions .btn { display: flex; align-items: center; justify-content: center; min-height: 44px; }
}
.state__list { list-style: none; max-width: 420px; margin: 0 auto 14px; padding: 0; text-align: left; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.state__list-item { border-bottom: 1px solid var(--line-soft); }
.state__list-item:last-child { border-bottom: 0; }
.state__list-link { display: block; padding: 8px 12px; color: var(--fg); text-decoration: none; overflow-wrap: anywhere; }
.state__list-link:hover { background: var(--pill); }

/* StoryHead */
.story-head { padding: 16px 20px 12px; }
.story-head__crumbs { display: flex; align-items: baseline; gap: 6px; margin-bottom: 8px; color: var(--muted); font-size: 13px; }
.story-head__crumb { appearance: none; padding: 0; border: 0; background: transparent; color: inherit; font: inherit; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.story-head__crumb:hover { color: var(--fg); }
/* Nothing in the head changes its place or size when the story changes, only text: the title row is one line with the switch in
   a slot at its right end, the facts are one line (cut with an ellipsis, in full in the tooltip), the chips are one line. */
.story-head__row { display: flex; align-items: center; gap: 16px; height: var(--seg-h, 32px); }
.story-head__title { flex: 1 1 0; min-width: 0; margin: 0; overflow: hidden; font-size: 20px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.story-head__variants { flex: none; display: flex; justify-content: flex-end; min-width: 164px; }
/* both sides have the same width, room for the mark, so the switch never changes size */
.story-head__variants .seg__btn { min-width: 76px; text-align: center; }
.story-head__meta { height: 1.4em; margin: 4px 0 0; overflow: hidden; color: var(--muted); font-size: 13px; line-height: 1.4; font-variant-numeric: tabular-nums; text-overflow: ellipsis; white-space: nowrap; }
.chipbar { position: relative; display: flex; align-items: center; gap: 6px; height: 36px; margin-top: 8px; }
.story-head__chips { position: relative; display: flex; flex: 1 1 0; flex-wrap: nowrap; gap: 6px; min-width: 0; padding: 1px 0; overflow-x: auto; overflow-y: hidden; scrollbar-width: none;
  --fade-l: 0px; --fade-r: 0px;
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 var(--fade-l), #000 calc(100% - var(--fade-r)), transparent 100%);
  mask-image: linear-gradient(to right, transparent 0, #000 var(--fade-l), #000 calc(100% - var(--fade-r)), transparent 100%); }
.story-head__chips::-webkit-scrollbar { display: none; }
.chipbar[data-start="true"] .story-head__chips { --fade-l: 24px; }
.chipbar[data-end="true"] .story-head__chips { --fade-r: 24px; }
.chip { flex: none; }
.chipbar__chev { appearance: none; flex: none; display: none; align-items: center; justify-content: center; width: 28px; height: 28px; padding: 0; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--muted); cursor: pointer; }
.chipbar__chev:hover { background: var(--pill); color: var(--fg); }
.chipbar__chev svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.chipbar[data-overflow="true"][data-start="true"] .chipbar__chev--prev, .chipbar[data-overflow="true"][data-end="true"] .chipbar__chev--next { display: inline-flex; }
.chipbar__all-slot { position: relative; flex: none; display: none; }
.chipbar[data-overflow="true"] .chipbar__all-slot { display: block; }
.chipbar__all { appearance: none; min-height: 28px; padding: 0 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--fg); font: inherit; font-size: 13px; font-weight: 600; white-space: nowrap; cursor: pointer; }
.chipbar__all:hover { background: var(--pill); }
.chipbar__all:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.chip { appearance: none; display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 0 10px; border: 1px solid var(--line); border-radius: 14px; background: transparent; color: inherit; font: inherit; font-size: 13px; cursor: pointer; }
.chip:hover { background: var(--pill); }
.chip--current { border-color: var(--fg); background: var(--pill); font-weight: 600; }
.chip__mark { font-size: 10px; }
@media (max-width: 720px) {
  .story-head { padding: 12px 12px 8px; }
  .chip { min-height: 36px; }
  .chipbar { height: 44px; }
  .story-head__variants { min-width: 140px; }
  .story-head__variants .seg__btn { min-width: 64px; }
}

/* StoryMenu */
/* The list of all stories of a component: a menu under the "N stories" button, a bottom sheet on a phone (BranchMenu's panel). */
.bmenu--stories .bmenu__panel { left: auto; right: 0; width: min(360px, 92vw); }
.srow { appearance: none; display: flex; align-items: center; gap: 8px; width: 100%; min-height: 32px; padding: 4px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--fg); font: inherit; font-size: 13px; text-align: left; cursor: pointer; }
.srow:hover { background: var(--pill); }
.srow:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.srow--current { background: var(--pill); font-weight: 600; box-shadow: inset 0 0 0 1px var(--line); }
.srow__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.srow__mark { flex: none; font-size: 10px; }
@media (max-width: 720px) {
  .bmenu--stories .bmenu__panel { left: 0; right: 0; width: auto; }
  .srow { min-height: 44px; }
}

/* ThemeToggle */
/* Exactly one icon at a time: the moon while the page is light (press for dark), the sun while it is dark. */
.theme-toggle { appearance: none; display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--icon); cursor: pointer; }
.theme-toggle:hover { background: var(--pill); }
.theme-toggle .theme-toggle__icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle .theme-toggle__moon { display: block; }
.theme-toggle .theme-toggle__sun { display: none; }
.theme-root--dark .theme-toggle .theme-toggle__moon { display: none; }
.theme-root--dark .theme-toggle .theme-toggle__sun { display: block; }
@media (max-width: 720px) { .theme-toggle { width: 36px; height: 36px; } }

/* TokenSheet */
/* the sheets of the administration page: a centred dialog, a bottom sheet on a phone (its actions are at the thumb) */
.sheet { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; padding: 16px; background: var(--backdrop); }
.sheet__panel { box-sizing: border-box; display: flex; flex-direction: column; width: min(560px, 100%); max-height: min(720px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.sheet__panel:focus { outline: none; }
.sheet__head { display: flex; align-items: center; gap: 8px; padding: 14px 12px 10px 16px; border-bottom: 1px solid var(--line-soft); }
.sheet__title { flex: 0 1 auto; min-width: 0; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 17px; line-height: 24px; }
.sheet__slug { flex: 1; color: var(--muted); font: 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.sheet__head .tag { flex: none; }
.sheet__close { appearance: none; margin-left: auto; display: inline-flex; align-items: center; justify-content: center; flex: none; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--icon); cursor: pointer; }
.sheet__close:hover { background: var(--pill); color: var(--fg); }
.sheet__icon { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.sheet__body { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 16px 8px; }
.sheet__section { padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.sheet__section:last-child { border-bottom: 0; }
.sheet__h { display: block; margin: 0 0 8px; font-size: 12px; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; color: var(--muted); }
.sheet__text { margin: 8px 0; }
.sheet__help { margin: 8px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.sheet__help strong { color: var(--fg); }
.sheet__section > .adm-input { display: block; width: 100%; }
.sheet__lbl { display: block; margin: 8px 0 4px; color: var(--muted); font-size: 12px; }
.sheet__save { margin-top: 10px; }
.sheet__row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.sheet__warn { margin: 8px 0; }
.sheet__warn p { margin: 0 0 6px; }
.sheet__chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.sheet__all { margin-top: 6px; }
.sheet__list { margin: 0; padding: 0; list-style: none; }
.sheet__item { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line-soft); }
.sheet__item:last-child { border-bottom: 0; }
.sheet__item-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.sheet__dropped { margin: 4px 0 0; padding-left: 18px; }
.sheet__foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; padding: 10px 16px 12px; border-top: 1px solid var(--line-soft); }
.sheet__status { flex: 1 1 100%; order: -1; margin: 0; min-height: 20px; }

.chip { display: inline-flex; align-items: center; min-height: 28px; border: 1px solid var(--line); border-radius: 999px; background: var(--pill); color: var(--fg); font: inherit; font-size: 13px; font-weight: 600; }
.chip__text { padding: 0 4px 0 10px; }
.chip__x { appearance: none; display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font: inherit; font-size: 16px; line-height: 1; cursor: pointer; }
.chip__x:hover:not(:disabled) { background: var(--danger-bg); color: var(--danger); }
button.chip { appearance: none; padding: 0 12px; cursor: pointer; }
button.chip:hover:not(:disabled) { border-color: var(--accent); }
.chip--toggle[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.chip:disabled, .chip__x:disabled { opacity: 0.5; cursor: not-allowed; }
.sheet__section .seg { display: inline-flex; }

@media (max-width: 720px) {
  .sheet { align-items: flex-end; padding: 0; }
  .sheet__panel { width: 100%; max-height: 88%; border-radius: 16px 16px 0 0; border-bottom: 0; }
  .sheet__foot { padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
  .sheet__foot .btn { flex: 1; min-height: 44px; }
  .sheet__close { width: 44px; height: 44px; }
  .chip, button.chip { min-height: 36px; }
  .chip__x { width: 34px; height: 34px; }
  .adm-input { min-height: 44px; font-size: 16px; }
}
