/* The look is a phone app first, because that is where this gets used: standing
 * somewhere with one hand free. So the chrome is the system font at system
 * sizes, the targets are thumb-sized, and the one thing worth doing on a screen
 * is the only thing that screen shows.
 *
 * Only the text under review is monospace. It is the thing being weighed word by
 * word, and a proportional face hides the run of a sentence; everything around
 * it reads better as ordinary interface text. */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
/* Any `display` in a rule below beats the hidden attribute, so a hidden panel
 * stays laid out over the page and swallows every tap behind it, and a hidden
 * pane shows its textarea over whatever replaced it. Both of those shipped, from
 * two different rules, which is what makes this the right place to fix it rather
 * than one selector at a time. */
[hidden] {
  display: none !important;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: var(--w-text) var(--t-body) / var(--lh-body) var(--ui);
  height: var(--vvh, 100dvh);
  display: flex;
  overflow: hidden;
}
/* While the on-screen keyboard is up and a field has the focus, `viewport.js` gives the
 * root the visible area's height and offset. The body is that tall and sits at that
 * offset, and as it has a transform what is fixed to the frame, the pages, panels and
 * sheets, is placed against it and not against the screen the keyboard covers. */
:root[data-keyboard] body {
  transform: translateY(var(--vvtop, 0px));
}
/* The headings, once, on the type scale: the browser's own sizes would otherwise show through
 * wherever a part writes an h1 to h4 and says nothing of its size. */
h1,
h2,
h3,
h4 {
  color: var(--ink);
  font-weight: var(--w-title);
}
h1 {
  font-size: var(--t-display);
  line-height: var(--lh-display);
}
h2 {
  font-size: var(--t-head);
  line-height: var(--lh-head);
}
h3 {
  font-size: var(--t-title);
  line-height: var(--lh-title);
}
h4 {
  font-size: var(--t-body);
  line-height: var(--lh-body);
}
/* A person who asked for less motion gets none: every move of the frame ends where it began at once. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* The tokens: every value the frame's look is made of, once. A part reads these and holds no
 * literal radius, size, colour, shadow, duration or space of its own; the one place a literal
 * may stand is this file. Radius has three steps and one for a tray, space six, type seven, elevation two.
 *
 * Colour is a set of roles, and each theme gives them values: dark here, light below as what
 * the system picks and as what a chosen theme (`data-theme` on the root) forces. */
:root {
  --bg: #0d0f12;
  --raised: #181b20;
  --raised-2: #252931;
  --line: #38383a;
  --line-strong: #636a75;
  --ink: #eef0f3;
  --dim: #a2a8b2;
  --tint: #5aa9ff;
  --tint-fill: #0a5fd6;
  --tint-wash: color-mix(in srgb, var(--tint) 15%, transparent);
  --on-tint: #fff;
  --good: #30d158;
  --warn: #f0ad5c;
  --bad: #ff5a50;
  /* on black a shadow does not show, so the dark elevations carry a hairline of light too */
  --e-1: 0 2px 10px rgb(0 0 0 / .5), 0 0 0 1px rgb(255 255 255 / .08);
  --e-2: 0 8px 30px rgb(0 0 0 / .6), 0 0 0 1px rgb(255 255 255 / .08);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #eceef2;
    --raised: #fbfbfd;
    --raised-2: #e3e6eb;
    --line: #d1d1d6;
    --line-strong: #83888f;
    --ink: #1b1d21;
    --dim: #5b616b;
    --tint: #0062cc;
    --tint-fill: #0062cc;
    --tint-wash: color-mix(in srgb, var(--tint) 11%, transparent);
    --good: #1b7233;
    --warn: #9a4f00;
    --bad: #c40013;
    --e-1: 0 2px 10px rgb(0 0 0 / .14);
    --e-2: 0 8px 30px rgb(0 0 0 / .28);
  }
}
:root[data-theme="light"] {
  --bg: #eceef2;
  --raised: #fbfbfd;
  --raised-2: #e3e6eb;
  --line: #d1d1d6;
  --line-strong: #83888f;
  --ink: #1b1d21;
  --dim: #5b616b;
  --tint: #0062cc;
  --tint-fill: #0062cc;
  --tint-wash: color-mix(in srgb, var(--tint) 11%, transparent);
  --good: #1b7233;
  --warn: #9a4f00;
  --bad: #c40013;
  --e-1: 0 2px 10px rgb(0 0 0 / .14);
  --e-2: 0 8px 30px rgb(0 0 0 / .28);
}
/* The second palette, a lichen green: the accent roles only, the surfaces are the theme's. */
:root[data-accent="green"] {
  --tint: #86c999;
  --tint-fill: #357a48;
  --tint-wash: color-mix(in srgb, var(--tint) 15%, transparent);
}
@media (prefers-color-scheme: light) {
  :root[data-accent="green"]:not([data-theme="dark"]) {
    --tint: #2f6b3f;
    --tint-fill: #2f6b3f;
    --tint-wash: color-mix(in srgb, var(--tint) 12%, transparent);
  }
}
:root[data-accent="green"][data-theme="light"] {
  --tint: #2f6b3f;
  --tint-fill: #2f6b3f;
  --tint-wash: color-mix(in srgb, var(--tint) 12%, transparent);
}
:root {
  /* what the state layers lay over an element: a step of the ink, whatever the element is */
  --hover: color-mix(in srgb, var(--ink) 6%, transparent);
  --press: color-mix(in srgb, var(--ink) 12%, transparent);
  --scrim: rgb(0 0 0 / .4);
  /* how far past a sheet the scrim of one laid over another reaches */
  --scrim-reach: 100vmax;

  /* the interface's scale: the settings page's, kept per device; type, space and the lines of a desk's controls
   * follow it, and a finger's 44px does not, which is the least a touch screen is given whatever the scale */
  --ui-scale: 1;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  --ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;

  --r-1: 6px;
  --r-2: 10px;
  --r-3: 14px;
  --r-tray: 8px;
  --r-full: 999px;
  --radius: var(--r-2);

  --s-1: calc(4px * var(--ui-scale));
  --s-2: calc(8px * var(--ui-scale));
  --s-3: calc(12px * var(--ui-scale));
  --s-4: calc(16px * var(--ui-scale));
  --s-5: calc(24px * var(--ui-scale));
  --s-6: calc(32px * var(--ui-scale));
  --pad: var(--s-4);

  --t-caption: calc(12px * var(--ui-scale));
  --lh-caption: calc(16px * var(--ui-scale));
  --t-small: calc(14px * var(--ui-scale));
  --lh-small: calc(20px * var(--ui-scale));
  --t-body: calc(16px * var(--ui-scale));
  --lh-body: calc(24px * var(--ui-scale));
  --t-title: calc(18px * var(--ui-scale));
  --lh-title: calc(24px * var(--ui-scale));
  --t-head: calc(22px * var(--ui-scale));
  --lh-head: calc(28px * var(--ui-scale));
  --t-display: calc(28px * var(--ui-scale));
  --lh-display: calc(34px * var(--ui-scale));
  --t-mono: calc(14px * var(--ui-scale));
  --lh-mono: calc(20px * var(--ui-scale));
  --w-text: 400;
  --w-control: 500;
  --w-title: 600;

  --bd: 1px solid var(--line);
  --bd-control: 1px solid var(--line-strong);
  /* the edge of a field: an inset ring, so the field keeps its size and has no border */
  --ring-input: inset 0 0 0 var(--hair) var(--line-strong);
  --e-0: none;
  /* the thickness of the bar that marks the selected tab or row */
  --ind: 2px;
  --hair: 1px;
  /* the bar's pad below its controls: the border takes the rest of the 4px */
  --bar-pad-b: calc(var(--s-1) - var(--hair));
  --focus-ring: 2px solid var(--tint);
  --focus-off: 2px;
  --focus-in: -2px;

  --m-fast: 120ms;
  --m-base: 200ms;
  --m-slow: 260ms;
  --curve: cubic-bezier(.32, .72, 0, 1);

  /* density follows the pointer: a thumb's 44px and a phone's 16px text under 821px or on a
   * touch screen, a laptop's 32px and 14px with a mouse */
  --control-h: calc(32px * var(--ui-scale));
  --t-control: var(--t-small);
  --lh-control: var(--lh-small);

  /* the least a finger is given to hit, which a dense row reaches by a pad past its box */
  --hit: 44px;
  /* a line of a list or a tree in a panel: dense enough to read a column of names at once */
  --row-h: calc(28px * var(--ui-scale));
  /* the places bar on a phone: a target and its pad, the most it may take of the screen */
  --dock-h: 56px;

  /* the home indicator on a phone with no button, so a bottom bar clears it */
  --floor: env(safe-area-inset-bottom, 0px);
  /* how tall the applet's own bars are, which a panel sits under; an applet that
   * measures its bars sets it, and one with none leaves it at nothing */
  --bars: 0px;
}
@media (max-width: 820px), (pointer: coarse) {
  :root {
    --control-h: 44px;
    /* a field under 16px has a phone's keyboard zoom the page to it, so a scale below one stops here */
    --t-control: max(16px, var(--t-body));
    --lh-control: var(--lh-body);
  }
}

/* The tree's nine tints, for the dark theme and again for the light, in the way the roles above are set. A row is
 * tinted as a background at a low strength, `--tree-alpha`, and the icon and the marker take the full colour. */
:root {
  --tint-red: #ff453a;
  --tint-orange: #ff9f0a;
  --tint-yellow: #ffd60a;
  --tint-green: #30d158;
  --tint-teal: #40c8e0;
  --tint-blue: #0a84ff;
  --tint-purple: #bf5af2;
  --tint-pink: #ff375f;
  --tint-grey: #8e8e93;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --tint-red: #d70015;
    --tint-orange: #b25000;
    --tint-yellow: #8a6d00;
    --tint-green: #248a3d;
    --tint-teal: #0e7c86;
    --tint-blue: #007aff;
    --tint-purple: #8944ab;
    --tint-pink: #d30f45;
    --tint-grey: #6c6c70;
  }
}
:root[data-theme="light"] {
  --tint-red: #d70015;
  --tint-orange: #b25000;
  --tint-yellow: #8a6d00;
  --tint-green: #248a3d;
  --tint-teal: #0e7c86;
  --tint-blue: #007aff;
  --tint-purple: #8944ab;
  --tint-pink: #d30f45;
  --tint-grey: #6c6c70;
}

/* The frame every applet sits in: the bar across the top and the stage under it.
 *
 * The stage is a row, the left panel, the applet's `main` and the right panel, and
 * `main` takes whatever width the panels leave. Which side a panel sits on is its
 * `data-side` and not where the applet wrote it, so an applet cannot put its list on
 * the wrong edge by writing its markup in another order. Pages and sheets are fixed,
 * over all of it, and take no room in the row. */
body {
  flex-direction: column;
}
/* The browser's own swipe past the page's edge, held where a browser lets a page hold it (Chrome
 * and Firefox do; Safari takes the gesture whatever this says, so panels.js holds it there). */
html {
  overscroll-behavior-x: none;
}
#bar {
  display: flex;
  align-items: center;
  gap: var(--s-1);
  /* the least the controls allow: a control with a pad of 4px above and 3px below and the border
   * is 40px on a laptop's pointer; a phone's 44px control with none is 45px */
  padding: var(--s-1) var(--s-2) var(--bar-pad-b);
  background: var(--bg);
  flex: none;
  min-width: 0;
}
#bar-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--t-title);
  line-height: var(--lh-title);
  font-weight: var(--w-title);
  text-align: center;
}
#bar-actions,
#bar-switcher {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex: none;
}
/* Actions wider than the room the bar has are folded behind the three dots after the row
 * at every width and push nothing past the screen; nothing scrolls sideways, and on a
 * phone the bar stays one row. */
#bar-actions {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
}
#bar-actions > * {
  flex: none;
}
#bar-actions > [data-folded] {
  display: none;
}
#bar-actions:empty,
#bar-actions:not(:has(> :not([hidden]))) {
  /* nothing to show, and an applet may hold an action hidden until it applies, so
   * the row goes rather than leaving the gap before it under the bar */
  display: none;
}
/* The title keeps a width of its own however much else the bar carries, and the
 * switcher gives way before it does, its name cut short rather than the title gone. */
#bar-title {
  min-width: 5rem;
}
#bar-switcher {
  flex: 0 1 auto;
  min-width: 0;
}
#bar-switcher .switch,
#bar-switcher .switch-name {
  min-width: 0;
  max-width: 100%;
}
#bar-switcher .switch > span:first-child,
#bar-switcher .switch-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* On a phone the switcher is measured from nothing and grows to its name's width at
 * most, as the title already does into the rest, so the one row holds down to 320
 * wide and the actions give way to both. */
@media (max-width: 820px) {
  #bar-switcher {
    flex: 1 1 0;
    max-width: max-content;
  }
}
@media (max-width: 820px), (pointer: coarse) {
  #bar {
    padding: 0 var(--s-1);
    gap: calc(var(--s-1) / 2);
  }
}
#stage {
  flex: 1;
  display: flex;
  gap: var(--s-2);
  padding: 0 var(--s-2) var(--s-2);
  min-height: 0;
  min-width: 0;
}
#stage > main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  /* Without this a flex child refuses to shrink below its content, so a long page
   * made `main` taller than the screen and the overflow never reached the element
   * that would have scrolled it. */
  min-height: 0;
  background: var(--raised);
  border-radius: var(--r-2);
}
#stage > .panel[data-side="left"] {
  order: -1;
}
#stage > .panel[data-side="right"] {
  order: 1;
}
/* Under 600px the page is one layer: `main` is `--raised` with the big corners on top, inset from
 * the sides, and the places bar floats under it as a layer of its own. From there up the places are a
 * rail and `main` is a layer like a laptop's. Panels are overlays under 1100px and take no
 * room in the row. */
@media (max-width: 599px) {
  #stage {
    gap: 0;
    padding: 0 var(--s-2);
  }
  #stage > main {
    border-radius: var(--r-3);
  }
}
/* An applet whose content is the whole window, a game or a scene, carries `data-immersive` on its
 * `main`: no bar, and the stage is the window with no pad and no corners. It reaches its menu
 * through the badge. */
body:has(#stage > main[data-immersive]) > #bar {
  display: none;
}
body:has(#stage > main[data-immersive]) > #stage {
  padding: 0;
  gap: 0;
}
#stage > main[data-immersive] {
  border-radius: 0;
}

/* The tab bar, the applet's places: an icon over a short label each.
 *
 * On a phone it is a layer of its own, floating at the bottom where a thumb is: raised, with the
 * layers' corners, inset from the edges and from the home indicator, and no taller than its
 * 44px targets and a 4px pad around them (`--dock-h` is the most it may take, 56px); from 821px up it is a rail down the left of the stage, where a laptop's eye
 * looks for the same thing. The tabs are the same at both, only where they sit changes.
 * `#tabbar-items` and `#tabbar-shell` lay nothing out of their own, so the applet's tabs,
 * the shell's and the three dots are one row of items for the overflow to fold. */
:root {
  --rail: 0px;
}
#tabbar {
  display: flex;
  flex: none;
  min-width: 0;
  overflow: hidden;
  background: var(--raised);
  border-radius: var(--r-2);
  box-shadow: var(--e-1);
  margin: var(--s-2) var(--s-2) calc(var(--s-2) + var(--floor));
  padding: var(--s-1);
}
#tabbar[hidden] {
  display: none;
}
#tabbar-items,
#tabbar-shell {
  display: contents;
}
#tabbar .tab,
#tabbar-items > * {
  position: relative;
  /* as wide as its label, so a place is never named by a cut word: the tab does not shrink under it */
  flex: 1 0 auto;
  min-width: calc(var(--hit) + var(--s-3));
  min-height: var(--hit);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 0;
  border-radius: 0;
  background: none;
  color: var(--dim);
  font-size: var(--t-caption);
  font-weight: var(--w-control);
  line-height: var(--lh-caption);
  text-decoration: none;
  white-space: nowrap;
}
#tabbar .tab[hidden],
#tabbar-items > [hidden],
#tabbar [data-folded] {
  display: none;
}
#tabbar svg {
  width: 22px;
  height: 22px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
/* the one showing: the tint and the bar along its top edge */
#tabbar [aria-current="page"] {
  color: var(--tint);
  box-shadow: inset 0 var(--ind) 0 var(--tint);
}
/* a count: in the tab's corner, right of the icon and level with it, never over it */
#tabbar .tab .badge,
#tabbar-items > * .badge {
  position: absolute;
  top: var(--s-1);
  right: auto;
  left: calc(50% + 11px + var(--s-1));
}
/* while the menu behind the three dots is open it is the place marked, and the tab showing waits */
#tabbar:has(#tabbar-more[aria-expanded="true"]) [aria-current="page"]:not(#tabbar-more) {
  color: var(--dim);
  box-shadow: none;
}
#tabbar #tabbar-more[aria-expanded="true"] {
  color: var(--tint);
  box-shadow: inset 0 var(--ind) 0 var(--tint);
}
#tabbar .tab > span,
#tabbar-items > * > span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (min-width: 600px) {
  :root:has(#tabbar:not([hidden])) {
    --rail: 76px;
  }
  #tabbar {
    position: fixed;
    left: 0;
    top: var(--bars);
    bottom: 0;
    width: var(--rail);
    flex-direction: column;
    margin: 0;
    background: var(--bg);
    border-radius: 0;
    box-shadow: none;
    padding: var(--s-2) var(--s-1) var(--floor);
    gap: var(--s-1);
    z-index: 5;
  }
  #tabbar .tab,
  #tabbar-items > * {
    flex: none;
    min-width: 0;
    min-height: 56px;
    gap: calc(var(--s-1) / 2);
    padding: var(--s-1);
    width: 100%;
  }
  /* the rail's tab is narrower than the offset leaves room for: the count hugs the tab's right edge, narrower, still beside the icon */
  #tabbar .tab .badge,
  #tabbar-items > * .badge {
    left: auto;
    right: 0;
    min-width: calc(var(--s-5) - var(--s-1));
    padding-inline: calc(var(--s-1) / 2);
  }
  /* in the rail the bar is down its left edge */
  #tabbar [aria-current="page"],
  #tabbar #tabbar-more[aria-expanded="true"] {
    box-shadow: inset var(--ind) 0 0 var(--tint);
  }
  #tabbar:has(#tabbar-more[aria-expanded="true"]) [aria-current="page"]:not(#tabbar-more) {
    box-shadow: none;
  }
  body:has(> #tabbar:not([hidden])) > #stage {
    margin-left: var(--rail);
  }
  .panel[data-side="left"] {
    left: var(--rail);
  }
}

/* What a row folded away, a list under its three dots. */
#overflow-menu {
  position: fixed;
  z-index: 40;
  min-width: 200px;
  max-width: min(320px, calc(100vw - var(--s-4)));
  max-height: calc(var(--vvh, 100dvh) - var(--bars) - var(--s-4));
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: var(--s-1);
  border-radius: var(--r-2);
  background: var(--raised);
  box-shadow: var(--e-1);
}
#overflow-menu[hidden] {
  display: none;
}
#overflow-menu > button {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  background: none;
  border-radius: var(--r-1);
  text-align: left;
  white-space: nowrap;
}
#overflow-menu > button[aria-current="page"] {
  color: var(--tint);
  background-color: var(--tint-wash);
}
#overflow-menu svg {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* A row that folds: one line, never scrolling, what does not fit hidden behind a more button at its end. */
[data-fold],
.coll-select {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  min-width: 0;
  /* the height of its tallest item: a column that is too full for its page does not squeeze a row that clips to nothing */
  min-height: min-content;
  max-width: 100%;
  overflow: hidden;
}
[data-fold] > * {
  flex: none;
}
[data-fold] > [data-folded] {
  display: none;
}
.fold-more {
  min-width: var(--control-h);
  min-height: var(--control-h);
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  color: inherit;
  border-radius: var(--r-1);
}
.fold-more[aria-current="page"] {
  color: var(--tint);
}
.fold-more svg {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* The open tabs, in the bar: the views a person has open, a link each with a close button beside it,
 * and a plus at the end. The tabs are a fold row, so the ones that fit are shown and the rest are
 * behind its three dots; nothing scrolls sideways. The row takes no height of its own, the bar is the
 * row, and a tab is 34px tall on a laptop's pointer and 44px under a finger. On a phone the row is not
 * drawn: the bar's button and the sheet are the same set (09-topbar.css). */
#opentabs {
  display: flex;
  align-items: flex-end;
  gap: calc(var(--s-1) / 2);
  min-width: 0;
  flex: 0 1 auto;
  /* the tabs stand on the bar's bottom line, so they reach down through its pad */
  align-self: flex-end;
  margin-bottom: calc(-1 * var(--bar-pad-b));
}
#opentabs[hidden] {
  display: none;
}
#opentabs-items {
  flex: 0 1 auto;
  gap: calc(var(--s-1) / 2);
  min-height: 0;
  align-items: flex-end;
}
#opentabs .fold-more,
#opentabs #opentabs-new {
  align-self: center;
  margin-bottom: var(--bar-pad-b);
}
/* A tab is an underline on the bar's line: no background and no rounding, and the one showing
 * has its name in the ink and a bar of the tint along its bottom edge. */
.vtab {
  display: inline-flex;
  align-items: center;
  color: var(--dim);
}
.vtab:has(> [aria-current="page"]) {
  box-shadow: inset 0 calc(-1 * var(--ind)) 0 var(--tint);
}
.vtab-link {
  display: inline-flex;
  align-items: center;
  box-sizing: border-box;
  min-width: var(--control-h);
  max-width: 9.5rem;
  min-height: var(--control-h);
  padding: 0 calc(var(--s-1) / 2) 0 var(--s-3);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: inherit;
  font-size: var(--t-small);
  line-height: var(--lh-small);
  font-weight: var(--w-control);
  text-decoration: none;
}
.vtab-link[aria-current="page"] {
  color: var(--ink);
  font-weight: var(--w-title);
}
.vtab-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--s-5);
  min-width: var(--s-5);
  min-height: var(--control-h);
  padding: 0;
  background: none;
  border: none;
  border-radius: var(--r-1);
  color: var(--dim);
}
.vtab-close[hidden] {
  display: none;
}
.vtab-close svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}
@media (pointer: coarse) {
  .vtab-close {
    width: var(--control-h);
    min-width: var(--control-h);
  }
}

/* The rest of the top bar: the breadcrumb, what the bar says on a phone, the avatar and the menu it
 * opens, and the sheet of open tabs a phone's button raises.
 *
 * Where the applet has the open tabs (`data-open-tabs` on the root) the bar carries no title: on a
 * wide screen the tabs and the crumbs say where the person is, and under 821px, or on a touch screen
 * shorter than 500 pixels (a phone on its side), the row of tabs is not drawn and the bar has a
 * button with their count and the name of the view instead. */
:root[data-open-tabs] #bar-title {
  display: none;
}
#bar-here,
#bar-tabs {
  display: none;
}
#bar-here {
  flex: 1;
  min-width: 0;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--t-title);
  line-height: var(--lh-title);
  font-weight: var(--w-title);
  padding: 0;
}
/* The button is the name of the tab showing, the count and the chevron, one control that opens the list. */
#bar-tabs {
  flex: 1 1 0;
  width: auto;
  min-width: 0;
  justify-content: flex-start;
  padding: 0 var(--s-2);
  gap: var(--s-2);
  color: var(--ink);
}
#bar-tabs svg {
  flex: none;
  color: var(--dim);
}
#bar-tabs-count {
  flex: none;
}
/* the name takes what it needs and the count and chevron follow it, one control */
#bar-tabs #bar-here {
  flex: 0 1 auto;
}
#bar-tabs svg {
  width: 19px;
  height: 19px;
}
/* The count is a quiet figure that belongs to the button, read after the name and before the
 * chevron: dim, in the caption size, with tabular figures. It is no badge: no fill, no round, no
 * ink on a colour, since a filled circle with a number reads as a notification. */
#bar-tabs-count {
  color: var(--dim);
  font-size: var(--t-caption);
  font-weight: var(--w-text);
  line-height: var(--lh-caption);
  font-variant-numeric: tabular-nums;
  background: none;
  border-radius: 0;
}
#bar-tabs-count::before {
  content: "\00b7";
  padding-right: var(--s-2);
}
@media (max-width: 820px), (pointer: coarse) and (max-height: 500px) {
  :root[data-open-tabs] #opentabs,
  #bar-crumbs {
    display: none;
  }
  :root[data-open-tabs] #bar-tabs {
    display: inline-flex;
  }
  :root[data-open-tabs] #bar-here {
    display: block;
  }
  /* On a phone the bar holds the tabs button and the avatar and nothing more: what an applet
   * puts in its actions, the other applets and the three dots are in the avatar's menu, where a
   * thumb has room, and the panels open by a swipe from their edge (20-panels.css). */
  :root[data-open-tabs] :is(#bar-actions, #bar-more, #bar-switcher) {
    display: none;
  }
}

/* The breadcrumb takes the room the tabs leave and gives way before they do: the earlier crumbs are
 * cut short before the last, and the list is gone where there is no room. */
#bar-crumbs {
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  container-type: inline-size;
}
#bar-crumbs ol {
  display: flex;
  align-items: center;
  margin: 0;
  padding: 0 var(--s-2);
  list-style: none;
  white-space: nowrap;
  font-size: var(--t-small);
  line-height: var(--lh-small);
  color: var(--dim);
}
@container (max-width: 5rem) {
  #bar-crumbs ol {
    visibility: hidden;
  }
}
#bar-crumbs li {
  flex: 0 10 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
#bar-crumbs li:last-child {
  flex: 0 1 auto;
  color: var(--ink);
  font-weight: var(--w-title);
}
#bar-crumbs li + li::before {
  content: "/";
  padding: 0 var(--s-2);
  color: var(--line-strong);
}
#bar-crumbs a {
  color: inherit;
  text-decoration: none;
  border-radius: var(--r-1);
}
#bar-crumbs a:hover {
  color: var(--ink);
}

/* The avatar: a round mark in the bar's control, the account's first letter or a person. */
#bar-account-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--s-5);
  height: var(--s-5);
  border-radius: var(--r-full);
  background: var(--raised-2);
  color: var(--ink);
  font-size: var(--t-small);
  font-weight: var(--w-title);
  line-height: 1;
}
#bar-account-mark svg {
  width: 17px;
  height: 17px;
}
@media (max-width: 820px), (pointer: coarse) {
  #bar-account-mark {
    width: var(--s-6);
    height: var(--s-6);
  }
}
@media (hover: hover) {
  #bar-account:hover #bar-account-mark {
    background-image: linear-gradient(var(--press), var(--press));
  }
}
#bar-account[aria-expanded="true"] #bar-account-mark {
  box-shadow: 0 0 0 var(--ind) var(--tint);
}

/* What the avatar opens, in the style of the overflow menu. */
#account-menu {
  position: fixed;
  z-index: 40;
  min-width: 280px;
  max-width: min(360px, calc(100vw - var(--s-4)));
  max-height: calc(var(--vvh, 100dvh) - var(--bars) - var(--s-4));
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: var(--s-1);
  border-radius: var(--r-2);
  background: var(--raised);
  box-shadow: var(--e-1);
}
#account-menu[hidden] {
  display: none;
}
#account-head {
  display: flex;
  flex-direction: column;
  padding: var(--s-2) var(--s-3);
  border-bottom: var(--bd);
  margin-bottom: var(--s-1);
}
#account-head small {
  color: var(--dim);
  overflow-wrap: anywhere;
}
#account-items,
#account-shell {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
}
#account-items:not(:empty) + #account-shell {
  border-top: var(--bd);
  margin-top: var(--s-1);
  padding-top: var(--s-1);
}
#account-menu :is(button, a[href]) {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  width: 100%;
  min-height: var(--control-h);
  padding: var(--s-1) var(--s-3);
  background: none;
  border-radius: var(--r-1);
  color: var(--ink);
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
}
#account-menu svg {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* The open tabs as a list: a row of 44px for each, the name and a close control, and a row to open
 * another. */
#tabs-list {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  min-height: 0;
}
.tabs-row {
  display: flex;
  align-items: center;
  border-bottom: var(--bd);
}
.tabs-link {
  flex: 1;
  min-width: 0;
  min-height: var(--control-h);
  display: flex;
  align-items: center;
  padding: 0 var(--s-1);
  border-radius: var(--r-1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--dim);
  text-decoration: none;
}
.tabs-link[aria-current="page"] {
  color: var(--ink);
  font-weight: var(--w-title);
  padding-left: var(--s-3);
}
/* the tint is the row's, edge to edge, so the close stands inside it */
.tabs-row[data-current] {
  background-color: var(--tint-wash);
  box-shadow: inset var(--ind) 0 0 var(--tint);
}
.tabs-close {
  flex: none;
  width: var(--control-h);
  min-width: var(--control-h);
  min-height: var(--control-h);
  padding: 0;
  background: none;
  color: var(--dim);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.tabs-close[hidden] {
  display: none;
}
.tabs-close svg,
.tabs-new svg {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}
.tabs-new {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  width: 100%;
  min-height: var(--control-h);
  margin-top: var(--s-1);
  background: none;
  color: var(--tint);
  text-align: left;
}

/* With no name before it, the count is the button's first word and takes no dot. */
#bar-tabs:has(#bar-here[hidden]) #bar-tabs-count::before {
  content: none;
}

/* The bell and the badges the applet asks for, before the avatar: icon buttons with a count. The
 * count is the quiet figure of the tabs' button, and a filled circle only where the role is bad. */
[data-notifications] {
  display: none;
}
#bar-badges {
  display: contents;
}
#bar-notify,
.bar-badge {
  position: relative;
  gap: var(--s-1);
}
#bar-notify-count,
.bar-badge-count {
  color: var(--dim);
  font-size: var(--t-caption);
  font-weight: var(--w-text);
  font-variant-numeric: tabular-nums;
  background: none;
  border-radius: 0;
}
#bar-notify[data-role="bad"] #bar-notify-count,
.bar-badge[data-role="bad"] .bar-badge-count {
  color: var(--bad);
}
#bar-notify[data-role="warn"] #bar-notify-count,
.bar-badge[data-role="warn"] .bar-badge-count {
  color: var(--warn);
}
#bar-notify[data-role="info"] #bar-notify-count,
.bar-badge[data-role="info"] .bar-badge-count {
  color: var(--tint);
}
#notify-list {
  display: flex;
  flex-direction: column;
}
.notify-row {
  display: grid;
  grid-template-columns: 5.5em 1fr auto;
  align-items: center;
  gap: var(--s-3);
  min-height: 44px;
  padding: 0 var(--s-4);
  color: inherit;
  text-decoration: none;
}
.notify-row[data-unread] {
  font-weight: var(--w-strong, 600);
}
.notify-row[data-role="bad"] > small:first-child {
  color: var(--bad);
}
.notify-row[data-role="warn"] > small:first-child {
  color: var(--warn);
}
.notify-row > small {
  color: var(--dim);
}
.notify-empty {
  padding: var(--s-4);
  color: var(--dim);
}

/* A badge is a link and draws as the bar's icons do, and the bell and a badge are as wide as their count
 * needs beside the glyph, with the control's width as the least. */
a.bar-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--control-h);
  height: var(--control-h);
  padding: 0 var(--s-2);
  color: var(--dim);
  flex: none;
  text-decoration: none;
}
a.bar-icon:hover {
  color: var(--ink);
}
a.bar-icon svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
button#bar-notify {
  width: auto;
  padding: 0 var(--s-2);
}
.notify-row > span {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Controls.
 *
 * One look for a button and one for a field, and one set of rules for what they do when a
 * pointer is over them, a finger is on them, the keyboard is at them or they are off. The
 * height is `--control-h`: 44px under a finger, which is apple's own minimum target and the
 * difference between a tool you can use walking and one you have to stop and aim at, and
 * 32px with a mouse. */
input,
button,
select,
textarea {
  font: inherit;
  font-family: var(--ui);
  font-size: var(--t-control);
  line-height: var(--lh-control);
  color: var(--ink);
  background: var(--raised-2);
  border: none;
  border-radius: var(--r-1);
  padding: var(--s-1) var(--s-3);
  min-height: var(--control-h);
}
/* A field is the page's surface with an edge, so it reads as somewhere to write and not as a
 * button; a checkbox, a radio and a range keep the native look. */
input:not([type="checkbox"], [type="radio"], [type="range"], [type="color"], [type="file"]),
select,
textarea {
  background: var(--bg);
  box-shadow: var(--ring-input);
}
::placeholder {
  color: var(--dim);
  opacity: 1;
}
textarea {
  font-family: var(--mono);
  /* the size of a control, so a phone's keyboard does not zoom the page to a field under 16px */
  font-size: var(--t-control);
  line-height: var(--lh-control);
  width: 100%;
  padding: var(--s-3);
  resize: vertical;
}
button {
  cursor: pointer;
  font-weight: var(--w-control);
  transition: background-color var(--m-fast) ease-out, color var(--m-fast) ease-out;
}
button.primary {
  background: var(--tint-fill);
  color: var(--on-tint);
}
button.quiet {
  background: none;
  color: var(--tint);
  padding-inline: var(--s-2);
}
button.small,
button.copy {
  padding: var(--s-1) var(--s-2);
  font-size: var(--t-small);
  line-height: var(--lh-small);
}
/* Beside the thing it copies rather than in a bar, and quiet, since copying is
   never the answer to what the page is asking. */
button.copy {
  background: none;
  color: var(--tint);
}
/* Two positions and one meaning each. Left is always the files. Right is always
 * whatever belongs to what is on screen. Nothing else lives on the bar, so the
 * name in the middle has the room it needs.
 *
 * The glyphs are drawn rather than typed: an emoji renders at whatever size and
 * weight the platform feels like, which is how a folder ended up twice the height
 * of the text beside it. */
button.bar-icon {
  background: none;
  width: var(--control-h);
  min-width: var(--control-h);
  padding: 0;
  color: var(--dim);
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
button.bar-icon svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
button.push {
  background: var(--tint-fill);
  color: var(--on-tint);
  font-weight: var(--w-title);
  font-size: var(--t-small);
  padding: 0 var(--s-3);
  flex: none;
}
button.wide {
  width: 100%;
  background: var(--raised-2);
}
/* This one opens a sheet over the page rather than swapping what is under the
 * bar, so it does not read as one of the view buttons beside it. The caret is
 * the part that says so: it points at where the sheet comes from. */
button.opens-sheet {
  background: var(--raised-2);
  color: var(--ink);
  padding: var(--s-1) var(--s-3);
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  margin-right: var(--s-1);
}
button.opens-sheet::after {
  content: "\25B4";
  font-size: var(--t-caption);
  color: var(--dim);
}
button.opens-sheet[aria-expanded="true"]::after {
  content: "\25BE";
}
select {
  appearance: none;
  padding-right: calc(var(--s-5) + var(--s-2));
}
/* The mark that says a field picks from a set: a downward triangle in the right padding, drawn on the
 * select's own background since a select takes no pseudo-element. */
select:not([multiple], [size]) {
  background-image: conic-gradient(from -45deg at 50% 100%, var(--dim) 90deg, transparent 0);
  background-repeat: no-repeat;
  background-size: var(--s-3) calc(var(--s-3) / 2);
  background-position: right var(--s-3) center;
}
select:not([multiple], [size]):is(:hover, :focus-visible) {
  background-image: conic-gradient(from -45deg at 50% 100%, var(--ink) 90deg, transparent 0);
}

/* The states, once, for everything a person can press. Hover lays a step of the ink over
 * whatever the element is, as an image over its own background, so a filled button and a bare
 * one take the same rule and nothing here knows what colour is underneath. */
@media (hover: hover) {
  :is(
    button,
    [role="button"],
    [role="tab"],
    [role="menuitem"],
    summary,
    .vtab-link,
    .tabs-link,
    #tabbar .tab,
    #tabbar-items > *,
    #bar-crumbs a
  ):hover:not(:disabled, [aria-disabled="true"]) {
    background-image: linear-gradient(var(--hover), var(--hover));
  }
  :is(button.bar-icon, .vtab-close, .tabs-close):hover:not(:disabled) {
    color: var(--ink);
  }
}
:is(
  button,
  [role="button"],
  [role="tab"],
  [role="menuitem"],
  summary,
  .vtab-link,
  .tabs-link,
  #tabbar .tab,
  #tabbar-items > *
):active:not(:disabled, [aria-disabled="true"]) {
  background-image: linear-gradient(var(--press), var(--press));
}
:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-off);
}
/* Inside a container that clips, a ring drawn outside would be cut off, so it is drawn in. */
:is(#bar, #opentabs, #tabbar, #overflow-menu, #account-menu, [data-fold]) :focus-visible {
  outline-offset: var(--focus-in);
}
:disabled,
[aria-disabled="true"] {
  opacity: .45;
  cursor: not-allowed;
}

/* The side panel, one primitive on both sides.
 *
 * It is an overlay: fixed under the bars, slid in from its own edge, floating above the page on
 * the one scrim. From 1100px up, where it carries `data-dock`, it is a layer in the stage beside
 * the reading pane instead, collapsed by its button rather than slid away; one without
 * `data-dock` stays an overlay at every width. Which side it is on is the `data-side` attribute
 * and nothing else: no rule below is keyed on which panel it is, and the two carry the same
 * header, the same close, the same swipe out. What each holds is content, styled as content.
 * A docked panel is a raised layer like `main`, with no border; the shade tells it apart. */
.panel {
  position: fixed;
  top: var(--bars);
  bottom: 0;
  width: min(340px, 86vw);
  z-index: 30;
  background: var(--raised);
  display: flex;
  flex-direction: column;
  box-shadow: var(--e-2);
  transition: transform var(--m-slow) var(--curve);
  padding-bottom: var(--floor);
}
.panel[data-side="left"] {
  left: 0;
  right: auto;
  border-radius: 0 var(--r-2) var(--r-2) 0;
  transform: translateX(-100%);
}
.panel[data-side="right"] {
  right: 0;
  left: auto;
  border-radius: var(--r-2) 0 0 var(--r-2);
  transform: translateX(100%);
}
.panel.in {
  transform: translateX(0);
}
.panel > header {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  padding: var(--pad);
  flex: none;
  touch-action: none;
}
@media (min-width: 1100px) {
  .panel[data-dock],
  .panel[data-dock][data-side="left"],
  .panel[data-dock][data-side="right"] {
    position: static;
    transform: none;
    width: 320px;
    flex: none;
    height: auto;
    z-index: auto;
    box-shadow: var(--e-0);
    border-radius: var(--r-2);
    padding-bottom: 0;
  }
  .panel[data-dock].collapsed {
    display: none;
  }
}

/* Belongs to the panels rather than to the narrow layout: both of them are
 * overlays at every width, and the right one had no backdrop on a wide screen. */
#backdrop {
  position: fixed;
  inset: var(--bars) 0 0 0;
  z-index: 20;
  background: var(--scrim);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--m-slow) ease-out;
}
#backdrop.on {
  opacity: 1;
  pointer-events: auto;
}
.panel-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
}
.panel-bar strong {
  font-size: var(--t-title);
}

/* The panels' buttons are tabs on their own edges, low, within a thumb's reach, riding out with
 * their panel while one is open over the page, from 600px up. Under 600px, a phone, they are
 * icons in the bar's row instead (below). They are drawn whatever the edge swipe holds
 * (`data-edge`, panels.js): the swipe is a gesture and a page with a panel has to say it has one. */
#bar-panel-left,
#bar-panel-right {
  position: fixed;
  z-index: 32;
  bottom: var(--handle-bottom, var(--s-4));
  width: var(--control-h);
  height: var(--control-h);
  background: var(--raised);
  box-shadow: var(--e-1);
  transition: left var(--m-slow) var(--curve), right var(--m-slow) var(--curve);
}
#bar-panel-left {
  left: var(--rail);
  border-radius: 0 var(--r-2) var(--r-2) 0;
}
#bar-panel-right {
  right: 0;
  border-radius: var(--r-2) 0 0 var(--r-2);
}
@media (max-width: 599px) {
  /* On a phone each button is an icon in the bar's row, where the markup has it, whatever the edge swipe
   * holds: a panel is an overlay nobody can see, and the icon is how a page says it has one. The tab
   * on an edge is for the widths where a bar is full of the applet's own actions. */
  #bar-panel-left,
  #bar-panel-right {
    position: static;
    z-index: auto;
    width: var(--control-h);
    height: auto;
    border-radius: var(--r-2);
    background: none;
    box-shadow: none;
    transition: none;
  }
  #bar-panel-left[aria-expanded="true"],
  #bar-panel-right[aria-expanded="true"] {
    color: var(--tint);
    background: var(--tint-wash);
  }
}
/* On a pad, which a hand holds by its lower sides, each button is a grip on its own edge at the height a
 * thumb rests, a third of the way up, and drawn as part of the frame: the edge of the
 * layer it opens, with a hairline and no shadow of its own. */
@media (min-width: 600px) and (pointer: coarse) {
  :root {
    --handle-bottom: max(var(--s-6), 30vh);
  }
  #bar-panel-left,
  #bar-panel-right {
    background: var(--raised-2);
    color: var(--dim);
    box-shadow: none;
    border: var(--bd);
  }
  #bar-panel-left {
    border-left: 0;
  }
  #bar-panel-right {
    border-right: 0;
  }
}
/* A docked panel is a column of the page, and its grip stands astride the column's outer edge, off its words */
@media (min-width: 1100px) and (pointer: coarse) {
  #bar-panel-left[aria-expanded="true"] {
    left: calc(var(--rail) + 320px - var(--hit) / 2);
  }
  #bar-panel-right[aria-expanded="true"] {
    right: calc(320px - var(--hit) / 2);
  }
}
/* A page is somewhere the panels are not: its buttons would show and open nothing */
:root:has(.page.in) :is(#bar-panel-left, #bar-panel-right) {
  display: none;
}
/* A panel is an overlay under 1100px, and with one panel out its button rides at the panel's edge:
 * from the rail on a pad. */
@media (max-width: 1099px) {
  /* with one panel out its button rides at the panel's edge, and the other side's steps up so the
   * two never meet in the middle of a narrow screen */
  #bar:has(#bar-panel-left[aria-expanded="true"]) #bar-panel-right,
  #bar:has(#bar-panel-right[aria-expanded="true"]) #bar-panel-left {
    bottom: calc(var(--handle-bottom) + var(--hit) + var(--s-2));
  }
  #bar-panel-left[aria-expanded="true"] {
    left: calc(var(--rail) + min(340px, 86vw));
  }
  #bar-panel-right[aria-expanded="true"] {
    right: min(340px, 86vw);
  }
}

/* The rows of a panel: every list and every tree in a side panel, and every tree elsewhere, one look.
 *
 * A row is a line of a list (`li`) or a folder of a tree (`summary`), dense, `--row-h` tall, so a
 * column of names reads as a column. A finger is not given the line's height but a pad past it, a
 * hit area of `--hit` under a coarse pointer or a narrow screen, which the next row's pad shares
 * where the two meet.
 *
 * The row that is current, the page showing or the item picked, says so with `aria-current` on
 * the row or on the link it holds, and is drawn once: one tint, the wash of the accent, across the
 * panel's whole width with no edge, since the backdrop of a row is a layer the width of the panel
 * and not the width of the text (a line of a list has it; a folder of a tree takes the hover of
 * every control). A tint a tree puts on a row is let go while it is current, so a
 * row never carries two colours. */
:is(.panel, [data-tree]) :is(ul, ol) {
  list-style: none;
  margin: 0;
  padding: 0;
}
:is(.panel, [data-tree]) :is(li:not(:has(> :is(ul, ol, details))), summary) {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-height: var(--row-h);
  padding: 0;
  border-radius: 0;
  font-size: var(--t-small);
  line-height: var(--lh-small);
}
.panel li:not(:has(> :is(ul, ol, details)))::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0 calc(-1 * var(--scrim-reach));
  background: none;
  pointer-events: none;
}
/* the panel clips the backdrop to its own width */
.panel-body {
  overflow-x: clip;
}
:is(.panel, [data-tree]) :is(li, summary) > a,
:is(.panel, [data-tree]) li > a[data-tree-row] {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-height: var(--row-h);
  min-width: 0;
  padding: 0;
  border-radius: 0;
}
@media (hover: hover) {
  .panel li:not(:has(> :is(ul, ol, details))):hover::before {
    background: var(--hover);
  }
}
/* the current row */
.panel li:is([aria-current]:not([aria-current="false"]), :has(> [aria-current]:not([aria-current="false"])))::before {
  background: var(--tint-wash);
}
.panel :is(li, summary):has(> [aria-current]:not([aria-current="false"])) > [data-tree-row][data-tree-tint],
.panel [data-tree-row][aria-current]:not([aria-current="false"])[data-tree-tint] {
  background: none;
}
@media (max-width: 820px), (pointer: coarse) {
  :is(.panel, [data-tree]) li > a::after,
  :is(.panel, [data-tree]) summary::after {
    content: "";
    position: absolute;
    inset: calc((var(--row-h) - var(--hit)) / 2) 0;
  }
}

/* Two conventions, and they are meant to feel different.
 *
 * A PAGE is somewhere you went. It slides in from the right, fills the screen,
 * is opaque, has no backdrop, and gives itself back through a Back chevron on
 * the left. Drills and Notes are pages. Its header sits on the ground and its body is a
 * raised layer on it, the way the stage is.
 *
 * A SHEET is something in front of what you were doing. It comes up from the
 * bottom, stops short of the top, has a grab handle and a dimmed backdrop, and
 * closes on the right. The file list is a sheet.
 *
 * Making both of them a full-screen overlay with a button in the corner was the
 * thing that read as arbitrary: same shape, two names, no way to guess which one
 * takes you somewhere and which one is a detour. */
.page {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--m-slow) var(--curve);
}
.page.in {
  transform: translateX(0);
}
.page > header {
  padding: var(--s-2) var(--s-3);
  display: flex;
  gap: var(--s-2);
  align-items: center;
  flex: none;
}
.page > header strong {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--t-body);
  font-weight: var(--w-title);
  text-align: center;
}
.page > header .back {
  background: none;
  color: var(--tint);
  padding: 0 var(--s-1) 0 0;
  min-height: 44px;
  font-size: var(--t-body);
  display: inline-flex;
  align-items: center;
  gap: calc(var(--s-1) / 2);
}
.page > header .back::before {
  content: "\2039";
  font-size: var(--t-display);
  line-height: 1;
}

/* The head of a view, drawn by the page shell as the first child of the stage's `main`: the way
 * back, the heading, the row of actions and the one slot of the wait and the failure. */
.page-head {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2) var(--s-3);
  padding: var(--s-2) var(--pad) var(--s-1);
}
.page-back {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  min-height: var(--control-h);
  min-width: var(--control-h);
  color: var(--tint);
  font-size: var(--t-small);
  line-height: var(--lh-small);
  text-decoration: none;
}
.page-back::before {
  content: "\2039";
  font-size: var(--t-display);
  line-height: 1;
}
.page-title {
  flex: 1 1 0;
  min-width: 0;
  margin: 0;
  font-size: var(--t-head);
  line-height: var(--lh-head);
  font-weight: var(--w-title);
  overflow-wrap: anywhere;
}
/* the view's row of actions sits under the head: the head and the row are ordered first in the `main`
 * that is a column, and no node of the view is moved */
#stage > main > .page-head {
  order: -2;
}
#stage > main > [data-page-actions] {
  order: -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2);
  margin: 0;
  padding: 0 var(--pad) var(--s-2);
}
.page-state {
  flex: 1 0 100%;
}
.page-state:empty {
  display: none;
}
.page-head[hidden] {
  display: none;
}
.page-error {
  margin: 0 0 var(--s-2);
  color: var(--bad);
  font-size: var(--t-body);
  line-height: var(--lh-body);
}
.page-pick {
  color: var(--dim);
}
/* a failure stands alone: no spinner and no composer is left under it */
#stage > main[data-page="error"] > :not(.page-head) {
  display: none;
}

/* The parts a page and a panel are built from, shared by every one of them.
 * A page is a header, a body and an action bar; a panel is a header, a body and
 * a foot. Nothing below is keyed on which page or panel it is in; a variant is a
 * data attribute on the element. */
.page-body {
  flex: 1;
  overflow: auto;
  padding: var(--pad);
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}
/* `safe` because plain centring in a scrolling flex column puts the overflow
   above the scroll origin, where nothing can reach it: the compare deck grew
   from three cards to four and the first one would have gone off the top with
   no way to scroll back to it. Safe centring falls back to flex-start the
   moment the content is taller than the box. */
/* A page's content is a centred column of at most 60rem, so a line does not run the
 * width of a laptop; on a phone the padding is the page's own and the column is the
 * screen. The percentage is the page's width, the body's containing block. The body is
 * a raised layer inset from the sides, with the big corners on top, and the action bar
 * under it continues it. */
.page > .page-body {
  --gutter: max(var(--pad), calc((100% - 60rem) / 2));
  padding-inline: var(--gutter);
  margin-inline: var(--s-2);
  background: var(--raised);
  border-radius: var(--r-3) var(--r-3) 0 0;
}
.page > .page-actions {
  margin-inline: var(--s-2);
}
.page-body[data-align="centre"] {
  justify-content: safe center;
}
/* One row per setting: the key and its control on a line, level, the control beside the
 * key rather than at the far edge of the page, the sentence and the source under it. A
 * select where the kind is a closed set, a field otherwise; which is a data attribute, and
 * nothing is keyed on the setting's name. */
.setting {
  display: grid;
  grid-template-columns: minmax(5rem, 9rem) minmax(0, 1fr);
  gap: var(--s-1) var(--s-3);
  align-items: center;
  align-content: start;
  padding-bottom: var(--s-3);
  border-bottom: var(--bd);
}
/* the key is a label, so it reads as one, in the page's own type and not in monospace */
.setting > code {
  font: var(--w-control) var(--t-body) / var(--lh-body) var(--ui);
  overflow-wrap: anywhere;
}
/* where a category is rows of settings, they take the width the page has: as many columns as hold a
 * row of a readable width, one on a phone */
#settings {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr));
  gap: var(--s-3) var(--s-5);
  align-items: start;
}
#settings > :not(.setting) {
  grid-column: 1 / -1;
}
.setting > small {
  grid-column: 1 / -1;
  color: var(--dim);
}
/* the slider has the column beside its label to itself, the label as wide as its word, and the
 * reading and the way back to one sit under it, so no row of three shares a phone's width */
.setting[data-kind="range"] {
  grid-template-columns: auto minmax(0, 1fr);
}
.setting[data-kind="range"] > input[type="range"] {
  min-width: 0;
  max-width: none;
  min-height: var(--control-h);
}
.setting-scale {
  grid-column: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
}
.setting > small[data-source="user"] {
  color: var(--tint);
}
.setting > input,
.setting > select {
  min-width: 140px;
  max-width: 50vw;
}
.setting > select {
  justify-self: start;
}
.setting[data-scope="repo"] > input,
.setting[data-scope="repo"] > select {
  opacity: .6;
}
/* One row per answer: what it was and when, the files it touched under it. The
 * same shape as a setting row and deliberately not the same class, since the two
 * would then drift into each other. */
.moment {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: calc(var(--s-1) / 2) var(--s-3);
  padding-bottom: var(--s-3);
  border-bottom: var(--bd);
}
.moment > b {
  font-weight: var(--w-control);
}
.moment > time,
.moment > small {
  color: var(--dim);
}
.moment > small {
  grid-column: 1 / -1;
  word-break: break-all;
}
.moment[data-sent="no"] > b::before {
  content: "\00b7\00a0";
  color: var(--tint);
}
#answers-state {
  color: var(--dim);
}
#answers-state[data-unsent="some"] {
  color: var(--tint);
}
.page-actions,
.panel-foot {
  flex: none;
  display: flex;
  gap: var(--s-2);
  padding: var(--s-2) var(--pad) calc(var(--s-2) + var(--floor));
  border-top: var(--bd);
  background: var(--raised);
}
.panel-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0 var(--pad) var(--pad);
}
/* a line of small dim text: a count in a header, where a card came from, what
 * the last answer did */
.meta {
  color: var(--dim);
  font-size: var(--t-small);
  margin: 0;
  flex: none;
  font-variant-numeric: tabular-nums;
}
.meta:empty {
  display: none;
}
.meta[data-keep] {
  min-height: 1.2em;
}
/* a block of text on a raised surface: what he wrote, the paragraph, the rewrite. It sits on a
 * layer, so it is a step above it. */
.card {
  margin: 0;
  padding: var(--s-4);
  background: var(--raised-2);
  border-radius: var(--radius);
  white-space: pre-wrap;
  font: var(--t-mono) / 1.55 var(--mono);
}
.card[data-tone="prose"] {
  padding: var(--s-5);
  font: var(--t-body) / 1.6 var(--ui);
}
/* his version of something, typed */
.draft {
  min-height: 8em;
  font: var(--t-mono) / 1.55 var(--mono);
}

/* Feedback. Every write says so, in the middle of the screen, briefly.
 *
 * The old note line was 12px and dim at the bottom of a column, which on a phone
 * is off screen: the save worked every time and looked like it had done nothing. */
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--s-5) + var(--floor));
  --above-actions: calc(80px + var(--floor));
  transform: translateX(-50%) translateY(8px);
  z-index: 40;
  background: var(--raised-2);
  border-radius: var(--r-2);
  padding: var(--s-3) var(--s-4);
  font-size: var(--t-control);
  max-width: min(90vw, 34rem);
  box-shadow: var(--e-2);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--m-base) ease-out, transform var(--m-base) var(--curve);
}
#toast.on {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  /* without this the toast is unclickable and Undo is decoration: the pointer
   * goes straight through to whatever sits behind it */
  pointer-events: auto;
}
#toast {
  display: flex;
  gap: var(--s-3);
  align-items: center;
}
.undo {
  background: none;
  color: var(--tint);
  font-weight: var(--w-title);
  padding: 0;
  min-height: 0;
  flex: none;
}
#toast.bad {
  box-shadow: var(--e-2), inset 0 0 0 var(--hair) var(--bad);
  color: var(--bad);
}

/* Waiting.
 *
 * A page that is waiting and a page that has nothing to say must not look alike. A wait
 * is an element carrying `data-loading`; a press that starts work is a control carrying
 * `aria-busy="true"`, which ends in `data-outcome`; the bar carries `data-busy` while the
 * frame's own door is in use. Everything here is drawn from those attributes, so the
 * answer to a press is on screen in the frame it was pressed in, before any script of the
 * frame's has run. `waiting.js` adds the clock: `data-wait` is `loading`, `slow` or
 * `stalled`, and the words and seconds of a wait. */
@keyframes wait-turn {
  to {
    transform: rotate(360deg);
  }
}
/* a wait draws nothing for its first quarter second, so a quick load does not flash */
@keyframes wait-in {
  from {
    opacity: 0;
  }
}
@keyframes wait-sweep {
  from {
    background-position: -70% 0;
  }
  to {
    background-position: 170% 0;
  }
}

/* ---- a wait ---- */
[data-loading] {
  color: var(--dim);
  animation: wait-in var(--m-fast) var(--m-slow) both;
}
[data-loading] .wait-mark {
  display: inline-block;
  width: 1em;
  height: 1em;
  margin-right: var(--s-2);
  vertical-align: -.15em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: var(--r-full);
  color: var(--tint);
  animation: wait-turn calc(var(--m-slow) * 3) linear infinite;
}
[data-loading] .wait-count {
  font-variant-numeric: tabular-nums;
}
/* stalled: the mark stops, closes into a ring and takes the warning colour, with its words */
[data-loading][data-wait="stalled"] {
  color: var(--warn);
}
[data-loading][data-wait="stalled"] .wait-mark {
  animation: none;
  border-right-color: currentColor;
  color: var(--warn);
}

/* ---- a press ---- */
[aria-busy="true"]:is(button, a, summary, [role="button"], [role="tab"], [role="menuitem"]):not([data-loading]) {
  pointer-events: none;
  cursor: progress;
}
/* a control drawn as a glyph turns the glyph where it stands; one with words only gains
 * the mark beside them */
[aria-busy="true"]:is(button, a, summary, [role="button"], [role="tab"], [role="menuitem"]):not([data-loading]):has(> svg) > svg {
  animation: wait-turn calc(var(--m-slow) * 3) linear infinite;
}
[aria-busy="true"]:is(button, a, summary, [role="button"], [role="tab"], [role="menuitem"]):not([data-loading]):not(:has(> svg))::before {
  content: "";
  display: inline-block;
  width: .9em;
  height: .9em;
  margin-right: var(--s-2);
  vertical-align: -.1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: var(--r-full);
  animation: wait-turn calc(var(--m-slow) * 3) linear infinite;
}
[aria-busy="true"][data-wait]:is(button, a, summary, [role="button"], [role="tab"], [role="menuitem"]):not([data-loading]) {
  color: var(--warn);
}
[aria-busy="true"][data-wait="stalled"]:is(button, a, summary, [role="button"], [role="tab"], [role="menuitem"]):not([data-loading]):has(> svg) > svg,
[aria-busy="true"][data-wait="stalled"]:is(button, a, summary, [role="button"], [role="tab"], [role="menuitem"]):not([data-loading]):not(:has(> svg))::before {
  animation: none;
}
[aria-busy="true"][data-wait="stalled"]:is(button, a, summary, [role="button"], [role="tab"], [role="menuitem"]):not([data-loading]):not(:has(> svg))::before {
  border-right-color: currentColor;
}

/* how it ended: a tick or a cross on the control's corner, which the frame clears */
[data-outcome]:is(button, a, summary, [role="button"], [role="tab"], [role="menuitem"]) {
  position: relative;
}
[data-outcome]:is(button, a, summary, [role="button"], [role="tab"], [role="menuitem"])::after {
  content: "✓";
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 calc(var(--s-1) / 2);
  border-radius: var(--r-full);
  background: var(--good);
  color: var(--on-tint);
  font: var(--w-title) var(--t-caption) / var(--lh-caption) var(--ui);
  text-align: center;
  pointer-events: none;
}
[data-outcome="failed"]:is(button, a, summary, [role="button"], [role="tab"], [role="menuitem"])::after {
  content: "✕";
  background: var(--bad);
}

/* ---- the bar: the frame's own door is in use ---- */
#bar {
  position: relative;
}
#bar[data-busy]::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, var(--tint), transparent) no-repeat;
  background-size: 40% 100%;
  animation: wait-sweep calc(var(--m-slow) * 4) linear infinite;
}
#bar[data-busy][data-wait="stalled"]::after {
  animation: none;
  background: var(--warn);
}

/* a reader who asks for less motion gets the marks held still; the words and the seconds
 * go on, so a wait is still told apart from a line that is meant to stand */
@media (prefers-reduced-motion: reduce) {
  [data-loading] .wait-mark,
  [aria-busy="true"] > svg,
  [aria-busy="true"]::before,
  #bar[data-busy]::after {
    animation: none !important;
  }
  #bar[data-busy]::after {
    background-position: 50% 0;
  }
}

/* The sheet, the second of the two conventions: in front of what you were doing,
 * up from the bottom, short of the top, with a grab handle and the backdrop. */
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: calc(var(--vvh, 100dvh) * .86);
  z-index: 30;
  background: var(--raised);
  border-radius: var(--r-3) var(--r-3) 0 0;
  box-shadow: var(--e-2);
  display: flex;
  flex-direction: column;
  padding: 0 var(--pad) calc(var(--pad) + var(--floor));
  transform: translateY(100%);
  /* the drag of the grabber, which adds to the slide and is let go back to nothing */
  translate: 0 var(--drag, 0px);
  transition: transform var(--m-slow) var(--curve), translate var(--m-slow) var(--curve);
}
.sheet.dragging {
  transition: none;
}
.sheet.in {
  transform: translateY(0);
}
/* The grabber is a strip the width of the sheet with the pill in it, and a finger's pad past the
 * strip, so it is hit and dragged where a thumb lands; nothing else in the sheet takes the drag. */
.sheet-grip {
  position: relative;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--s-6);
  margin: 0 calc(-1 * var(--pad));
  touch-action: none;
  cursor: grab;
}
.sheet-grip::before {
  content: "";
  width: 36px;
  height: 5px;
  border-radius: var(--r-full);
  background: var(--line-strong);
}
.sheet-grip::after {
  content: "";
  position: absolute;
  inset: calc((var(--s-6) - var(--hit)) / 2) 0;
}
@media (min-width: 821px) {
  .sheet {
    left: 50%;
    right: auto;
    width: min(480px, 90vw);
    transform: translate(-50%, 100%);
  }
  .sheet.in {
    transform: translate(-50%, 0);
  }
}

/* A sheet made for a view or a page: a header with its title and the way out, and a body
 * that scrolls under it. One over another is dimmed under by its own shadow, since the
 * frame has the one backdrop. */
.sheet.made:focus {
  outline: none;
}
.sheet.over {
  box-shadow: 0 0 0 var(--scrim-reach) var(--scrim), var(--e-2);
}
.sheet-head {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex: none;
  padding-bottom: var(--s-2);
}
.sheet-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--t-body);
  font-weight: var(--w-title);
}
.sheet-close,
.sheet-tab {
  min-height: 44px;
  min-width: 44px;
  padding: 0 var(--s-3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--tint);
  background: none;
  font-size: var(--t-control);
  white-space: nowrap;
}
.sheet-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.sheet-wait {
  margin: 0;
  padding: var(--s-3) 0;
}
/* a page in a sheet takes the height the sheet may have */
.sheet.sheet-framed {
  height: calc(var(--vvh, 100dvh) * .86);
}
.sheet-framed .sheet-body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sheet-page {
  flex: 1;
  width: 100%;
  min-height: 0;
  border: 0;
  border-radius: var(--r-1);
  /* a page in a frame is drawn on the browser's own white, whatever the theme */
  background: Canvas;
}

/* A menu at a point, and what offers one.
 *
 * A surface carrying `at-point` is placed by two custom properties the applet sets through the
 * style object, `--at-x` and `--at-y`, the point in CSS pixels. It is moved back in by its own
 * measured size where it would cross the edge, 8px short of it, so the move is the size it has
 * when drawn and nothing is measured by a script. */
.at-point {
  position: fixed;
  left: var(--at-x, 0px);
  top: var(--at-y, 0px);
  z-index: 60;
  max-width: calc(100vw - 16px);
  max-height: calc(100vh - 16px);
  max-height: calc(100dvh - 16px);
  overflow: auto;
  translate:
    max(calc(8px - var(--at-x, 0px)), min(0px, calc(100vw - 8px - var(--at-x, 0px) - 100%)))
    max(calc(8px - var(--at-y, 0px)), min(0px, calc(100vh - 8px - var(--at-y, 0px) - 100%)));
}
@supports (height: 1dvh) {
  .at-point {
    translate:
      max(calc(8px - var(--at-x, 0px)), min(0px, calc(100vw - 8px - var(--at-x, 0px) - 100%)))
      max(calc(8px - var(--at-y, 0px)), min(0px, calc(100dvh - 8px - var(--at-y, 0px) - 100%)));
  }
}
/* what offers a menu on a press and hold has the platform's own press and hold off under a finger:
 * the callout and the selection it opens, so the menu is the only thing that opens. A field inside
 * keeps its own. */
@media (pointer: coarse) {
  [data-context],
  [data-actions] {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
  }
  :is([data-context], [data-actions]) :is(input, textarea, [contenteditable]) {
    -webkit-touch-callout: default;
    -webkit-user-select: text;
    user-select: text;
  }
}
/* the menu the frame draws at a point: `openMenu` and the marks. A clear shade takes the next press. */
.menu-shade {
  position: fixed;
  inset: 0;
  z-index: 60;
}
.context-menu {
  list-style: none;
  margin: 0;
  padding: var(--s-1);
  min-width: 14rem;
  background: var(--raised);
  color: var(--ink);
  border-radius: var(--r-2);
  box-shadow: var(--e-1);
}
.menu-row {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  width: 100%;
  min-height: 36px;
  padding: var(--s-1) var(--s-2);
  border: 0;
  border-radius: var(--r-1);
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.menu-row:hover,
.menu-row:focus-visible {
  background: var(--hover);
}
@media (pointer: coarse) {
  .menu-row {
    min-height: 44px;
  }
}
.menu-row[aria-current="true"] {
  color: var(--tint);
  font-weight: var(--w-title);
}
/* a row may carry an icon before its words and the words of its key after them */
.menu-icon {
  flex: none;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.menu-label {
  flex: 1;
  min-width: 0;
}
.menu-keys {
  flex: none;
  margin-left: var(--s-4);
  color: var(--dim);
  font-size: var(--t-caption);
}

/* A mark: a reference, a ping or a link written in a text. Inline, wrapping with the words around it
 * and no taller than the line it is in; the pad of a thumb is a hit area past its box and no part
 * of its size. */
.mark {
  position: relative;
  padding: 0 var(--s-1);
  border-radius: var(--r-1);
  background: color-mix(in srgb, var(--tint) 16%, transparent);
  color: inherit;
  text-decoration: none;
  overflow-wrap: anywhere;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  cursor: pointer;
}
.mark:hover {
  background: color-mix(in srgb, var(--tint) 28%, transparent);
}
.mark:focus-visible,
a.form-pill-label:focus-visible {
  outline: 2px solid var(--tint);
  outline-offset: 1px;
}
.mark[data-mark="link"] {
  padding: 0;
  background: none;
  color: var(--tint);
  text-decoration: underline;
}
.mark.mine {
  font-weight: 600;
  box-shadow: inset 0 0 0 var(--hair) var(--tint);
}
.mark.unknown {
  background: color-mix(in srgb, var(--warn) 14%, transparent);
  box-shadow: inset 0 0 0 var(--hair) var(--warn);
}
@media (pointer: coarse) {
  .mark,
  [data-mark] {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
  }
  .mark::after,
  a.form-pill-label[data-mark]::after {
    content: "";
    position: absolute;
    inset: -14px -10px;
  }
  /* the label wraps its words, and clips nothing of the pad around it */
  a.form-pill-label[data-mark] {
    overflow: clip;
    overflow-clip-margin: var(--hit);
  }
  /* the pill is a caption tall, so its label reaches a thumb past a line of 16px by 16px each way */
  a.form-pill-label[data-mark]::after {
    inset: calc(-1 * var(--s-4)) calc(-1 * var(--s-3));
  }
}
/* on a phone a mark is set a step under the words it stands in, so a long name is not the loudest thing on the
 * line; the pad of a thumb is the same */
@media (max-width: 820px), (pointer: coarse) {
  .mark:not([data-mark="link"]) {
    font-size: var(--t-small);
  }
}
/* the pad of a mark at the edge of a view reaches past the screen and widens nothing, and a text
 * that holds marks has no scrollable overflow for it to be */
:where([data-view], [data-marks], :has(> [data-marks]), [data-marks] :is(p, li, dt, dd, label)) {
  overflow-x: clip;
}

/* Source text coloured by `highlight.js`: the runs it finds, in the frame's roles so that each
 * theme and accent carries them. Colour is never the only sign; a comment is also dim. */
.tok-keyword {
  color: var(--tint);
}
.tok-string {
  color: var(--good);
}
.tok-number {
  color: var(--warn);
}
.tok-comment {
  color: var(--dim);
  font-style: italic;
}

/* The settings page in categories: on a phone the list is the page and one category
 * drills in over it, from 700px up, a pad held upright among them, the list sits beside the category open. */
#settings-list {
  display: flex;
  flex-direction: column;
  gap: calc(var(--s-1) / 2);
}
#settings-list > .category {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--raised);
  border-radius: var(--r-1);
  text-align: left;
  text-transform: capitalize;
}
#settings-list > .category::after {
  content: "›";
  color: var(--dim);
}
#settings-list > .category[aria-current="true"] {
  color: var(--tint);
}
#settings-own > [hidden] {
  display: none;
}

@media (max-width: 699px) {
  #settings-page:not([data-open=""]) #settings-list {
    display: none;
  }
  #settings-page[data-open=""] .settings-open {
    display: none;
  }
}

@media (min-width: 700px) {
  .settings-split {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: var(--s-5);
    align-items: start;
  }
  .settings-open {
    display: flex;
    flex-direction: column;
  }
  #settings-list > .category::after {
    content: none;
  }
}

/* The danger zone: a red border around a column of rows, an action with what it does on the left and its
 * button on the right, and under a row the confirm that lists what will go. */
.danger-zone {
  border: 1px solid var(--bad);
  border-radius: var(--r-2, 8px);
  overflow: hidden;
}
.danger-zone > h3 {
  margin: 0;
  padding: var(--s-3) var(--s-4);
  color: var(--bad);
  border-bottom: 1px solid var(--bad);
}
.danger-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: var(--s-3) var(--s-4);
  padding: var(--s-3) var(--s-4);
}
.danger-row + .danger-row {
  border-top: 1px solid var(--line);
}
.danger-what {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
}
.danger-what small {
  color: var(--dim);
}
.danger-ask {
  color: var(--bad);
  border-color: var(--bad);
}
.danger-confirm {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}
.danger-lists {
  margin: 0;
  padding-left: var(--s-5);
}
.danger-buttons {
  display: flex;
  gap: var(--s-3);
  justify-content: flex-end;
}
.danger-go {
  background: var(--bad);
  color: #fff;
}
.danger-fail {
  color: var(--bad);
}
@media (max-width: 699px) {
  .danger-row {
    grid-template-columns: 1fr;
  }
  .danger-ask {
    justify-self: start;
  }
}

/* the 3d preview view: a canvas, a stats line and a Frame button, in whatever element holds it */
.preview3d {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
}
.preview3d-stage {
  position: relative;
  flex: 1;
  min-height: 200px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--raised);
}
.preview3d-stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}
.preview3d-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.preview3d-stats {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: var(--t-small);
  color: var(--dim);
}
.preview3d[data-state="error"] .preview3d-stats {
  color: var(--warn);
}
.preview3d-frame {
  min-height: var(--control-h);
  padding: 0 12px;
}

/* The tree: a row's icon, tint and marker, the palette they are drawn in, and the editor of the rules.
 *
 * The nine tints are in `00-tokens.css`, set for the dark theme and again for the light, so a row's
 * tint follows the theme with no work of whoever pinned it. A row is tinted as a
 * background at a low strength, `--tree-alpha`, which the frame raises or lowers for a custom colour
 * until the words stay readable; the icon and the marker take the full colour. */
[data-tree] [data-tree-row] {
  display: flex;
  width: 100%;
  align-items: center;
  gap: var(--s-2);
  border-radius: var(--r-1);
}
[data-tree] [data-tree-row][data-tree-tint] {
  background: color-mix(in srgb, var(--tree-tint) var(--tree-alpha, 16%), transparent);
}
.tree-icon {
  flex: none;
  display: inline-flex;
  width: 18px;
  height: 18px;
  color: var(--tree-tint, var(--dim));
}
.tree-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tree-marker {
  flex: none;
  margin-left: auto;
  padding: 0 var(--s-1);
  min-width: 14px;
  text-align: center;
  line-height: 1;
  color: var(--tree-tone, var(--dim));
}
.tree-marker[hidden] {
  display: none;
}
.tree-marker[data-glyph="dot"],
.tree-marker[data-glyph="ring"] {
  font-size: var(--t-caption);
}

/* the small popover for a custom colour */
.tree-pop {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  padding: var(--s-3);
}
.tree-pop input[type="color"] {
  width: 100%;
  height: 44px;
}
.tree-pop input[type="text"] {
  min-height: 44px;
}
.tree-pop-row {
  display: flex;
  gap: var(--s-2);
}
.tree-pop-row button {
  flex: 1;
  min-height: 44px;
}

/* the editor of the rules, a category of the settings page */
#tree-editor {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}
#tree-editor :is(button, select, input[type="text"]) {
  min-height: 44px;
}
#tree-editor .tree-rules {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}
#tree-editor .tree-rule {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-2);
  background: var(--raised-2);
  border-radius: var(--r-1);
}
#tree-editor .tree-rule-n {
  flex: none;
  min-width: 1.5em;
  color: var(--dim);
}
#tree-editor .tree-when {
  flex: 1 1 14rem;
  min-width: 0;
  font-family: var(--mono);
}
#tree-editor .tree-rule-pair,
#tree-editor .tree-rule-keys {
  display: flex;
  gap: var(--s-2);
}
#tree-editor .tree-rule-keys button {
  min-width: 44px;
}
#tree-editor .tree-rule-fault {
  flex: 1 1 100%;
  margin: 0;
}
#tree-editor .tree-rule-fault[hidden],
#tree-editor [hidden] {
  display: none;
}
#tree-editor .tree-test {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}
#tree-editor #tree-test-out {
  display: flex;
  flex-direction: column;
  gap: calc(var(--s-1) / 2);
  margin: 0;
}
#tree-editor .tree-pins {
  list-style: none;
  margin: 0;
  padding: 0;
}
#tree-editor .tree-pin {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 44px;
}
#tree-editor .tree-pin code {
  flex: 1;
  overflow-wrap: anywhere;
}
/* the glyph is drawn from the attribute so the row's words stay the words of the row */
.tree-marker::before {
  content: attr(data-char);
}

/* The editor and the annotations of a text: the bar and the boxes of `editor.js`, and the
 * highlights, the offer and the panel of `annotate.js`. Tokens only. */
.editor-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2);
  margin-bottom: var(--s-3);
}
.editor-bar button[aria-pressed="true"] {
  background: var(--tint-fill);
  color: var(--on-tint);
}
.editor-line {
  flex: 1 1 12rem;
  min-width: 0;
  color: var(--dim);
  font-size: var(--t-small);
  line-height: var(--lh-small);
}
.editor-box {
  width: 100%;
  min-height: 40vh;
  resize: vertical;
}
.editor-source {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: var(--t-mono) / 1.55 var(--mono);
}
.editor-preview {
  min-width: 0;
}
/* the applet's drawing, the box, the source and the preview: one is shown, by `data-shows` */
[data-editor] > textarea[data-source] {
  display: none;
}
[data-editor]:not([data-shows="applet"]) > :not(.editor-bar, .editor-box, .editor-source, .editor-preview) {
  display: none;
}
[data-editor]:not([data-shows="box"]) > .editor-box,
[data-editor]:not([data-shows="source"]) > .editor-source,
[data-editor]:not([data-shows="preview"]) > .editor-preview {
  display: none;
}

/* a highlight over a passage, one across every node it crosses */
mark.spot {
  background: color-mix(in srgb, var(--warn) 30%, transparent);
  color: inherit;
  border-radius: var(--r-1);
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  cursor: pointer;
}
mark.spot.noted {
  box-shadow: inset 0 calc(-1 * var(--ind)) 0 var(--warn);
}
mark.spot:focus-visible {
  outline: 2px solid var(--tint);
  outline-offset: 1px;
}
.annotate-pick,
.annotate-panel {
  position: fixed;
  z-index: 45;
  box-shadow: var(--e-1);
}
.annotate-pick {
  background: var(--tint-fill);
  color: var(--on-tint);
}
.annotate-panel {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  box-sizing: border-box;
  width: min(24rem, calc(100vw - var(--s-4)));
  padding: var(--s-3);
  background: var(--raised);
  color: var(--ink);
  border-radius: var(--r-2);
}
.annotate-quote {
  margin: 0;
  color: var(--dim);
  font-size: var(--t-small);
  line-height: var(--lh-small);
  max-height: 4.5em;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.annotate-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}
@media (pointer: coarse) {
  mark.spot {
    -webkit-touch-callout: none;
  }
}

/* The badge: a round button floating over the stage at a side and a height, carrying the
 * applet's menu. `badge.js` sets the side as a class and the height as `--badge-f`, a fraction
 * of the window; the height is held here inside the margins and the safe area, so a resize or a
 * turn of the screen keeps it on screen with no script. While it is dragged it follows the
 * pointer through `--badge-x`. The element the applet wrote as its menu is never drawn. */
[data-badge] {
  display: none !important;
}
.badge {
  --badge-m: var(--s-2);
  position: fixed;
  z-index: 50;
  inline-size: var(--control-h);
  block-size: var(--control-h);
  display: grid;
  place-items: center;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--raised);
  color: var(--ink);
  box-shadow: var(--e-1);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  top: clamp(
    calc(var(--badge-m) + env(safe-area-inset-top, 0px)),
    calc(var(--badge-f, 0.33) * 100dvh),
    calc(100dvh - var(--control-h) - var(--badge-m) - env(safe-area-inset-bottom, 0px))
  );
  transition: left 180ms ease-out, right 180ms ease-out, top 180ms ease-out;
}
.badge.on-left {
  left: calc(var(--badge-m) + env(safe-area-inset-left, 0px));
}
.badge.on-right {
  left: calc(100vw - var(--control-h) - var(--badge-m) - env(safe-area-inset-right, 0px));
}
.badge.dragging {
  left: var(--badge-x);
  transition: none;
  cursor: grabbing;
}
.badge svg {
  inline-size: 20px;
  block-size: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}
/* the unread notifications of an applet with no bar, on the badge's corner, coloured by the most
   pressing role as the bell's count is */
.badge-count {
  position: absolute;
  inset-block-start: -4px;
  inset-inline-end: -4px;
  min-inline-size: 18px;
  block-size: 18px;
  padding-inline: 4px;
  border-radius: var(--r-full);
  background: var(--raised-2);
  color: var(--dim);
  font-size: var(--t-caption);
  font-weight: var(--w-text);
  font-variant-numeric: tabular-nums;
  line-height: 18px;
  text-align: center;
  box-shadow: var(--e-1);
}
.badge-count[hidden] {
  display: none;
}
.badge[data-role="bad"] .badge-count {
  background: var(--bad);
  color: var(--on-tint);
}
.badge[data-role="warn"] .badge-count {
  color: var(--warn);
}
.badge[data-role="info"] .badge-count {
  color: var(--tint);
}
.badge:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-off);
}
@media (prefers-reduced-motion: reduce) {
  .badge {
    transition: none;
  }
}

/* The applets the instance serves, one row each, and the bar's switcher that opens
 * them. With one applet served there is nowhere to switch to, and the switcher is the
 * applet's name alone. */
#switcher-list a {
  display: block;
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-1);
  background: var(--raised-2);
  color: var(--ink);
  text-decoration: none;
  margin-bottom: var(--s-2);
}
#switcher-list a[aria-current="page"] {
  background: var(--tint-wash);
  box-shadow: inset var(--ind) 0 0 var(--tint);
}
button.switch {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  background: var(--raised-2);
  color: var(--ink);
  padding: var(--s-1) var(--s-2) var(--s-1) var(--s-3);
  min-height: var(--control-h);
  border-radius: var(--r-1);
  font-size: var(--t-small);
  font-weight: var(--w-title);
}
/* the mark that says it opens a list, rather than naming where you are */
button.switch .switch-mark {
  color: var(--tint);
  font-size: var(--t-caption);
}
.switch-name {
  font-size: var(--t-small);
  font-weight: var(--w-title);
}

/* A grid of one column is one column of the width its container has. A track left to size itself is
 * no narrower than the least width of its widest item, so a reference with no space in it, or a
 * control with a width of its own, made the column and the block around it wider than the screen.
 * `[data-view]` and `.coll`, which hold the others, say the same in their own rules. */
.ask-options,
.ask-refs,
.ask-text,
.board-cards,
.board-column,
.chart,
.chart-legend,
.counts-card,
.form-field,
.form-history,
.coll-list,
.row-main,
[data-deck],
.deck-card {
  grid-template-columns: minmax(0, 1fr);
}

/* the views: an item drawn by the view its element names, and the line that says
 * whether a change was kept. A card, a column and a tag are the system's: a card is a
 * step above its layer with the surface corners and no border, a tag is a small tinted
 * label with the control corners and never a pill. */
[data-view] {
  display: grid;
  /* one column of the element's own width: a track left to size itself is no narrower than the
   * least width of its widest item, which for a reference with no space in it is the reference */
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s-3);
  max-width: 44rem;
  overflow-wrap: anywhere;
}
/* the question is a quote: its sentence in the title size and weight on a raised ground with an
 * accent rule at its start, and its context open under it in the smaller ink */
.ask-quote {
  display: grid;
  gap: var(--s-2);
  margin: 0;
  padding: var(--s-3) var(--s-4);
  border-inline-start: var(--s-1) solid var(--tint);
  border-radius: var(--r-2);
  background: var(--raised-2);
}
.ask-asks {
  margin: 0;
  font-size: var(--t-title);
  line-height: var(--lh-title);
  font-weight: var(--w-title);
}
.ask-note {
  white-space: pre-wrap;
  font-size: var(--t-small);
  color: var(--dim);
}
.ask-more {
  justify-self: start;
  min-height: var(--control-h);
  padding: 0 var(--s-1);
  background: none;
  color: var(--tint);
}
.ask-recommended {
  flex: none;
  padding: 0 var(--s-2);
  border-radius: var(--r-1);
  background: var(--tint-wash);
  color: var(--tint);
  font-size: var(--t-caption);
}
/* what the question depends on, a line each with the way to it */
.ask-refs {
  display: grid;
  gap: var(--s-1);
  margin: 0;
  padding: 0;
  list-style: none;
}
.ask-ref {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--s-2);
  padding: var(--s-1) var(--s-2);
  border-left: var(--ind) solid var(--warn);
  background: var(--raised-2);
  border-radius: var(--r-1);
}
.ask-ref-why {
  color: var(--dim);
  font-size: var(--t-caption);
}
.ask-ref-open,
.view-state-open {
  background: none;
  color: var(--tint);
  text-align: left;
  min-height: var(--control-h);
  padding: 0 var(--s-1);
}
.ask-options {
  display: grid;
  gap: var(--s-2);
  margin: 0;
  padding: 0;
  list-style: none;
}
.ask-option {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-height: var(--control-h);
  padding: var(--s-1) var(--s-3);
  border: var(--bd);
  border-radius: var(--r-2);
  background: var(--raised-2);
}
.ask-pick {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex: 1;
  min-width: 0;
  min-height: var(--control-h);
  cursor: pointer;
}
.ask-option > .ask-label {
  flex: 1;
  min-width: 0;
}
.ask-label {
  overflow-wrap: anywhere;
}
.ask-score {
  flex: none;
  min-height: var(--control-h);
}
.ask-order {
  display: flex;
  flex: none;
  gap: var(--s-1);
}
.ask-move {
  min-width: var(--control-h);
  min-height: var(--control-h);
}
.ask-text {
  display: grid;
  gap: var(--s-1);
  font-size: var(--t-small);
  color: var(--dim);
}
.ask-words {
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  color: var(--ink);
}
.ask-actions {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  flex-wrap: wrap;
}
.ask-save {
  min-width: calc(var(--s-6) * 3);
  min-height: var(--control-h);
}
.ask-save[aria-disabled="true"] {
  cursor: default;
}
.view-state {
  margin: 0;
  min-height: var(--lh-caption);
  font-size: var(--t-caption);
  line-height: var(--lh-caption);
  color: var(--dim);
}
.view-state.bad {
  color: var(--bad);
}
/* one field in a cell says only a change that was refused */
[data-view="field"] > .view-state:not(.bad) {
  display: none;
}
/* the board: columns side by side, scrolling sideways inside the board where they are
 * wider than it, each card a link and a choice of column. A column is a step above the
 * layer and its cards are rows on it, so a column carries no border and a card none either. */
.board-columns {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(15rem, 1fr);
  gap: var(--s-3);
  overflow-x: auto;
  align-items: start;
}
.board-column {
  display: grid;
  align-content: start;
  gap: var(--s-2);
  min-width: 0;
  padding: var(--s-3);
  border-radius: var(--r-2);
  background: var(--raised-2);
}
.board-head {
  display: flex;
  justify-content: space-between;
  gap: var(--s-2);
  margin: 0;
  font-size: var(--t-small);
  line-height: var(--lh-small);
  font-weight: var(--w-title);
}
.board-count {
  color: var(--dim);
  font-weight: var(--w-text);
}
.board-cards {
  display: grid;
  gap: var(--s-2);
  margin: 0;
  padding: 0;
  list-style: none;
}
.board-status {
  font-size: var(--t-caption);
  overflow-wrap: anywhere;
}
.board-move {
  min-height: var(--control-h);
}
/* the form: a label over each field, and the history under them */
.form-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s-3);
}
.form-field {
  display: grid;
  min-width: 0;
  gap: var(--s-1);
}
.form-label {
  font-size: var(--t-small);
  color: var(--dim);
}
.form-note {
  margin: 0;
  font-size: var(--t-caption);
  line-height: var(--lh-caption);
  color: var(--dim);
}
.form-title {
  margin: 0;
}
.form-line,
.form-text,
.form-choice {
  box-sizing: border-box;
  width: 100%;
  min-height: var(--control-h);
  font: inherit;
  color: var(--ink);
}
.form-text {
  /* sized to what it holds by its control, so it never scrolls inside */
  overflow-y: hidden;
  resize: none;
}
/* the words of a text whose marks are live: the size and the edge of the box they stand in
 * place of, so a press that begins the edit changes nothing on the page but the caret */
.form-text-read {
  box-sizing: border-box;
  width: 100%;
  min-height: var(--control-h);
  padding: var(--s-3);
  font-family: var(--mono);
  font-size: var(--t-control);
  line-height: var(--lh-control);
  color: var(--ink);
  background: var(--bg);
  border-radius: var(--r-1);
  box-shadow: var(--ring-input);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  cursor: text;
}
.form-text-read:empty::before {
  content: attr(data-empty);
  color: var(--dim);
}
.form-history {
  display: grid;
  gap: var(--s-1);
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: var(--t-small);
}
.form-when {
  margin-right: var(--s-2);
  color: var(--dim);
}
/* the form's controls by kind: a number's steps, a slider and its value, a switch, and
 * pills and chips with the search that adds to them */
.form-number {
  display: flex;
  gap: var(--s-1);
  align-items: stretch;
}
.form-number-box,
.form-search-box,
.form-list-add {
  box-sizing: border-box;
  min-width: 0;
  min-height: var(--control-h);
  font: inherit;
  color: var(--ink);
}
.form-number-box {
  flex: 1;
  text-align: center;
}
.form-step {
  min-width: var(--control-h);
  min-height: var(--control-h);
  font: inherit;
}
/* a moment by the browser's own picker with a button for now, and a span as a box per
 * part with its unit beside it */
.form-date,
.form-time,
.form-datetime {
  box-sizing: border-box;
  min-width: 0;
  min-height: var(--control-h);
  font: inherit;
  color: var(--ink);
}
.form-moment {
  display: flex;
  gap: var(--s-1);
  align-items: stretch;
}
.form-moment .form-datetime {
  flex: 1;
}
.form-now {
  min-width: var(--control-h);
  min-height: var(--control-h);
  font: inherit;
}
.form-span {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-1) var(--s-3);
}
.form-span-part {
  display: flex;
  gap: var(--s-1);
  align-items: center;
  color: var(--dim);
}
.form-span-box {
  box-sizing: border-box;
  width: 5em;
  min-height: var(--control-h);
  font: inherit;
  color: var(--ink);
  text-align: right;
}
/* the colour kinds: a swatch opening the browser's own picker, and a row of them */
.form-colour,
.form-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  align-items: center;
}
.form-swatch {
  width: var(--s-6);
  height: var(--s-5);
  padding: 0;
  border: var(--bd-control);
  border-radius: var(--r-1);
  background: none;
  cursor: pointer;
}
.form-swatch:disabled {
  cursor: default;
}
/* a swatch beside the name of an option that is a colour: the colour itself, ringed in the ink so white and
 * black stand out on either theme; the name stays, as a colour is never all that says which */
.form-dot {
  flex: none;
  box-sizing: border-box;
  display: inline-block;
  width: var(--s-4);
  height: var(--s-4);
  border-radius: var(--r-full);
  background: var(--dot, none);
  box-shadow: inset 0 0 0 var(--hair) var(--dim);
}
.form-dot.none {
  box-shadow: none;
  outline: var(--hair) dashed var(--dim);
  outline-offset: calc(-1 * var(--hair));
}
.form-read-colour {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
}
.form-choice-colours {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  min-height: 0;
  width: auto;
}
.form-colour-option {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  min-height: var(--control-h);
  padding: 0 var(--s-3);
  border: var(--bd-control);
  border-radius: var(--r-2);
  background: var(--raised);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}
.form-colour-option[aria-checked="true"] {
  border-color: var(--tint);
  background: var(--tint-wash);
  color: var(--tint);
}
.form-match {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}
.form-pill > .form-dot {
  width: var(--s-3);
  height: var(--s-3);
}
.form-range {
  display: flex;
  gap: var(--s-3);
  align-items: center;
}
.form-range-slider {
  flex: 1;
  min-height: var(--control-h);
}
.form-range-value {
  min-width: 3ch;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.form-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: var(--control-h);
}
.form-toggle input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
}
/* the switch, here and on a checkbox the frame adopts: a track in the control edge colour that
 * turns to the accent fill, and a thumb of the one colour that reads on both */
.form-toggle-track,
input.adopted-switch {
  position: relative;
  width: calc(var(--s-6) + var(--s-3));
  height: calc(var(--s-5) + var(--s-1) / 2);
  border-radius: var(--r-full);
  background: var(--line-strong);
  transition: background-color var(--m-fast) ease-out;
}
.form-toggle-track::after,
input.adopted-switch::after {
  content: "";
  position: absolute;
  top: calc(var(--s-1) - var(--hair));
  left: calc(var(--s-1) - var(--hair));
  width: calc(var(--s-5) - var(--s-1));
  height: calc(var(--s-5) - var(--s-1));
  border-radius: var(--r-full);
  background: var(--on-tint);
  transition: transform var(--m-fast) var(--curve);
}
.form-toggle input:checked + .form-toggle-track,
input.adopted-switch:checked {
  background: var(--tint-fill);
}
.form-toggle input:checked + .form-toggle-track::after,
input.adopted-switch:checked::after {
  transform: translateX(calc(var(--s-4) + var(--s-1) / 2));
}
.form-toggle input:focus-visible + .form-toggle-track {
  outline: var(--focus-ring);
  outline-offset: var(--focus-off);
}
.form-link,
.form-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s-2);
}
.form-pills {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}
.form-pills:empty {
  display: none;
}
/* a pill is the tag of a reference or of a value the field holds, and the way out of it is a
 * control of its own: the tag keeps its small size and the reach around the control is made on a
 * touch screen */
.form-pill,
.form-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  max-width: 100%;
  padding: var(--s-1) var(--s-1) var(--s-1) var(--s-2);
  border-radius: var(--r-1);
  background: var(--raised-2);
  color: var(--dim);
  font-size: var(--t-caption);
  line-height: var(--lh-caption);
}
.form-pill {
  background: var(--tint-wash);
  color: var(--tint);
}
.form-pill.unknown {
  background: color-mix(in srgb, var(--warn) 16%, var(--raised-2));
  color: var(--warn);
  outline: var(--hair) dashed var(--warn);
  outline-offset: calc(-1 * var(--hair));
}
.form-pill-label {
  overflow: hidden;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}
a.form-pill-label {
  position: relative;
  color: inherit;
  text-decoration: none;
}
a.form-pill-label:hover {
  text-decoration: underline;
}
.form-pill-out {
  min-width: var(--s-5);
  min-height: var(--s-5);
  padding: 0;
  border: 0;
  border-radius: var(--r-full);
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.form-pill:not(:has(.form-pill-out)),
.form-chip:not(:has(.form-pill-out)) {
  padding-right: var(--s-2);
}
.form-search {
  position: relative;
}
.form-search-box {
  width: 100%;
}
.form-matches {
  position: absolute;
  z-index: 5;
  left: 0;
  right: 0;
  margin: var(--s-1) 0 0;
  padding: var(--s-1);
  list-style: none;
  background: var(--raised);
  border-radius: var(--r-2);
  box-shadow: var(--e-1);
  max-height: 18rem;
  overflow-y: auto;
}
.form-match {
  padding: var(--s-2);
  min-height: var(--control-h);
  border-radius: var(--r-1);
  cursor: pointer;
}
.form-match.on,
.form-match:hover {
  background: var(--raised-2);
}
.form-read:is(a) {
  color: var(--tint);
}
/* An option's description: a button at the option's end that opens a paragraph under it, wherever options
 * are listed (a choice, a search's matches, a question's options). The button is a thumb's size on a phone
 * and a small glyph elsewhere. */
.option-more {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: var(--control-h);
  min-height: var(--control-h);
  margin-left: auto;
  border: 0;
  border-radius: var(--r-2);
  background: none;
  color: var(--dim);
  font: inherit;
  cursor: pointer;
}
.option-more::before {
  content: "";
  width: 0.5em;
  height: 0.5em;
  border: solid currentcolor;
  border-width: 0 2px 2px 0;
  transform: translateY(-0.15em) rotate(45deg);
  transition: transform var(--m-fast, 120ms);
}
.option-more[aria-expanded="true"]::before {
  transform: translateY(0.1em) rotate(-135deg);
}
.option-more:hover,
.option-more:focus-visible {
  color: var(--ink);
}
.option-description {
  flex: 1 0 100%;
  margin: 0;
  padding: 0 var(--s-3) var(--s-2);
  color: var(--dim);
  overflow-wrap: anywhere;
}
.option-description[hidden] {
  display: none;
}
.form-option {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-1);
}
.form-choice-described {
  display: grid;
  gap: var(--s-2);
  min-height: 0;
  width: auto;
}
.form-radio-option {
  display: inline-flex;
  align-items: center;
  flex: 1;
  gap: var(--s-2);
  min-height: var(--control-h);
  padding: 0 var(--s-3);
  border: var(--bd-control);
  border-radius: var(--r-2);
  background: var(--raised);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.form-radio-option[aria-checked="true"] {
  border-color: var(--tint);
  background: var(--tint-wash);
  color: var(--tint);
}
.form-match,
.ask-option {
  flex-wrap: wrap;
}
/* a thumb's target on a phone is the control height, and the field is the size of a control
 * so a phone does not zoom into it */
@media (max-width: 820px), (pointer: coarse) {
  /* the pill stays the size of its words; its way out is a box of a thumb's size whose negative
   * margins take back what it has over, so the box holds its target and nothing stands outside it */
  .form-pill-out {
    min-width: var(--hit);
    min-height: var(--hit);
    margin: calc((var(--s-5) - var(--hit)) / 2) calc(-1 * var(--s-1)) calc((var(--s-5) - var(--hit)) / 2)
      calc((var(--s-5) - var(--hit)) / 2);
  }
  /* a pill takes no more room than a line of the words around it: the way out's box is the line, and the
   * pill puts nothing above or below it */
  .form-pill {
    min-height: var(--s-5);
    padding-block: 0;
  }
  /* the words of a pill wrap, and its box grows */
  .form-pill-label {
    white-space: normal;
    overflow-wrap: anywhere;
    text-overflow: clip;
  }
  a.row-title {
    display: flex;
    align-items: center;
    min-height: var(--control-h);
  }
  .ask-pick input {
    width: var(--s-5);
    height: var(--s-5);
  }
  .ask-words,
  .ask-score,
  .board-move,
  .form-line,
  .form-text,
  .form-choice,
  .form-number-box,
  .form-date,
  .form-time,
  .form-datetime,
  .form-span-box,
  .form-search-box,
  .form-list-add {
    font-size: var(--t-control);
  }
}
/* the counts: cards in a row that wraps, each a head with its small number, a chart and a
 * note. The bars are rows of a label, a track and a value; the ring is an svg of arcs
 * beside its legend. A tone is a colour for the part's bar, arc and swatch. */
.counts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
  gap: var(--s-3);
  margin: 0;
  padding: 0;
  list-style: none;
}
.counts-card {
  display: grid;
  align-content: start;
  gap: var(--s-2);
  min-width: 0;
  padding: var(--s-4);
  border-radius: var(--r-2);
  background: var(--raised-2);
}
.counts-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--s-2);
  margin: 0;
  font-size: var(--t-title);
  line-height: var(--lh-title);
  font-weight: var(--w-title);
}
.counts-number {
  font-size: var(--t-caption);
  line-height: var(--lh-caption);
  font-weight: var(--w-text);
  color: var(--dim);
}
.counts-note,
.counts-empty {
  margin: 0;
  font-size: var(--t-caption);
  color: var(--dim);
}
[data-tone="tint"] {
  --part: var(--tint);
}
[data-tone="good"] {
  --part: var(--good);
}
[data-tone="warn"] {
  --part: var(--warn);
}
[data-tone="bad"] {
  --part: var(--bad);
}
[data-tone="dim"] {
  --part: var(--dim);
}
/* the hues a declared choice's values take turns in, by their place among its options */
[data-hue="0"] {
  --part: var(--tint-purple);
}
[data-hue="1"] {
  --part: var(--tint-teal);
}
[data-hue="2"] {
  --part: var(--tint-pink);
}
[data-hue="3"] {
  --part: var(--tint-yellow);
}
[data-hue="4"] {
  --part: var(--tint-grey);
}
[data-hue="5"] {
  --part: var(--tint-blue);
}
[data-hue="6"] {
  --part: var(--tint-red);
}
.chart {
  display: grid;
  gap: var(--s-1);
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: var(--t-small);
}
.chart-row {
  display: grid;
  grid-template-columns: minmax(4rem, 8rem) 1fr auto;
  align-items: center;
  gap: var(--s-2);
}
.chart-label {
  overflow-wrap: anywhere;
}
.chart-track {
  height: var(--s-2);
  border-radius: var(--r-1);
  background: var(--raised);
  overflow: hidden;
}
.chart-fill {
  display: block;
  height: 100%;
  border-radius: var(--r-1);
  background: var(--part, var(--tint));
}
.chart-value {
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}
.chart-ringed {
  grid-template-columns: 6rem 1fr;
  align-items: center;
  gap: var(--s-3);
}
.chart-ring {
  width: 6rem;
  height: 6rem;
  transform: rotate(-90deg);
}
.chart-arc {
  fill: none;
  stroke: var(--part, var(--tint));
  stroke-width: 14;
}
.chart-legend {
  display: grid;
  gap: calc(var(--s-1) / 2);
  margin: 0;
  padding: 0;
  list-style: none;
}
/* the line: the drawing between the high and the low value, the first and the last label under it */
.chart-line {
  display: grid;
  gap: var(--s-1);
}
.chart-linesvg {
  width: 100%;
  height: auto;
  overflow: visible;
}
.chart-path {
  fill: none;
  stroke: var(--part, var(--tint));
  stroke-width: 1.2;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}
.chart-dot {
  fill: var(--part, var(--tint));
}
.chart-axis,
.chart-span {
  display: flex;
  justify-content: space-between;
  margin: 0;
  font-size: var(--t-caption);
  color: var(--dim);
}
.chart-key {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--s-2);
}
.chart-swatch {
  width: var(--s-3);
  height: var(--s-3);
  border-radius: var(--r-1);
  background: var(--part, var(--tint));
}
/* the stack: one bar split by state, the words that say what it counts above it and a legend of
 * the shapes below */
.chart-stack {
  display: grid;
  gap: var(--s-2);
}
.chart-headline {
  margin: 0;
  font-weight: var(--w-title);
}
.chart-segments {
  display: flex;
  height: var(--s-3);
  border-radius: var(--r-1);
  background: var(--raised);
  overflow: hidden;
}
.chart-segment {
  display: block;
  height: 100%;
  background: var(--part, var(--tint));
}
/* a segment is set off from its neighbour by a gap of the ground, so two of one tone are two */
.chart-segment + .chart-segment {
  border-inline-start: var(--ind) solid var(--raised-2);
}
.chart-glyph {
  color: var(--part, var(--tint));
  text-align: center;
}
/* the glyph of a state is drawn before the words of a tag, a chip or a group head that carries one */
[data-glyph]::before {
  content: attr(data-glyph) " ";
  color: var(--part, var(--tint));
}
@media (max-width: 820px), (pointer: coarse) {
  a.counts-title,
  a.chart-label {
    display: inline-flex;
    align-items: center;
    min-height: var(--control-h);
    min-width: var(--control-h);
  }
}
@media (max-width: 820px) {
  .counts {
    grid-template-columns: 1fr;
  }
}

/* a collection: the bar above the data, the rows in their presentations, and the controls the
 * frame enhances in place. A row is a compact line of the title, chips and status; every
 * control in them is a thumb's size on a phone and nothing runs past the screen. */
[data-view].coll,
[data-item].coll {
  max-width: none;
}
.coll {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s-3);
  min-width: 0;
}
.coll-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  align-items: center;
}
/* the presentations as a tray: the segments lie in a well, and the one showing is raised out of it */
.coll-select {
  gap: calc(var(--s-1) / 2);
  padding: calc(var(--s-1) / 2);
  border-radius: var(--r-tray);
  background: var(--raised-2);
}
.coll-mode,
.coll-dir {
  padding: var(--s-1) var(--s-3);
  min-height: var(--control-h);
  min-width: var(--control-h);
  border-radius: var(--r-1);
  background: none;
}
.coll-mode[aria-pressed="true"] {
  background: var(--raised);
  box-shadow: var(--e-1);
  font-weight: var(--w-title);
}
/* on a phone the presentations are one control: the icon of the one showing and a caret, a thumb's size,
 * and the others in a menu under it */
.coll-switch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  flex: none;
  min-height: var(--control-h);
  min-width: var(--control-h);
  padding: 0 var(--s-1);
  border-radius: var(--r-1);
  background: var(--raised-2);
  color: var(--ink);
}
.coll-switch svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.coll-switch-icon {
  width: var(--s-5);
  height: var(--s-5);
}
.coll-switch-caret {
  width: var(--s-4);
  height: var(--s-4);
  color: var(--dim);
}
/* beside the switch the search takes what is left, down to a few words, so the row holds at 320 */
.coll-bar:has(.coll-switch) .coll-search {
  flex-basis: 6rem;
}
.coll-search {
  flex: 1 1 12rem;
  min-width: 0;
}
.coll-group,
.coll-facet,
.coll-sort {
  min-width: 0;
  max-width: 100%;
}
/* a range on a day or moment column: its name and a from box and a to box */
.coll-range {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-1);
  min-width: 0;
  max-width: 100%;
}
.coll-range-name {
  color: var(--dim);
  font-size: var(--t-caption);
}
.coll-range input {
  min-width: 0;
  min-height: var(--control-h);
}
.coll-count {
  margin-left: auto;
  font-size: var(--t-caption);
  line-height: var(--lh-caption);
  color: var(--dim);
  white-space: nowrap;
}
.coll-view,
.coll-body {
  min-width: 0;
}
.coll-list {
  display: grid;
  gap: var(--s-2);
  margin: 0;
  padding: 0;
  list-style: none;
}
/* a row is a card: its own surface with an edge and corners, a space between it and the next, and
 * on its leading edge the colour of its state. The title and the chips are on the left and the
 * handle and the button of its properties on the right, each a finger's size. */
.row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 0 var(--s-1);
  align-items: center;
  min-width: 0;
  padding: var(--s-1) var(--s-1) var(--s-1) var(--s-3);
  border: var(--bd);
  border-inline-start: var(--s-1) solid var(--line-strong);
  border-radius: var(--r-2);
  background: var(--raised);
  box-shadow: var(--e-1);
}
.row[data-tone],
.row[data-hue] {
  border-inline-start-color: var(--part);
}
.row-main {
  grid-column: 1;
  grid-row: 1;
  display: grid;
  gap: var(--s-1);
  min-width: 0;
  padding: var(--s-1) 0;
}
/* in a column of a board the card is narrow: the title has its width, and under it the chips
 * stand on the left with the handle and the button on the right */
.board-column .row-main {
  display: contents;
}
.board-column .row-title {
  grid-column: 1 / -1;
  grid-row: 1;
  padding-top: var(--s-1);
}
.board-column .row-chips {
  grid-column: 1;
  grid-row: 2;
}
.board-column .board-status {
  grid-column: 1 / -1;
  grid-row: 3;
}
.board-column .row-grip,
.board-column .row-more {
  grid-row: 2;
}
.row-title {
  display: block;
  min-width: 0;
  padding: 0;
  border-radius: 0;
  background: none;
  color: var(--ink);
  font-weight: var(--w-title);
  text-align: left;
  text-decoration: none;
  overflow-wrap: anywhere;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
a.row-title {
  color: var(--ink);
}
@media (hover: hover) {
  a.row-title:hover {
    color: var(--tint);
  }
}
.row-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-1);
  min-width: 0;
}
.row-chips:empty {
  display: none;
}
/* a chip is a tag: a small label with the control corners, a step off its surface, never a pill.
 * Where it is a button it keeps that size and its reach under a finger is made around it. */
.coll .chip {
  padding: var(--s-1) var(--s-2);
  min-height: 0;
  box-sizing: border-box;
  border-radius: var(--r-1);
  background: var(--raised-2);
  color: var(--dim);
  font-size: var(--t-caption);
  line-height: var(--lh-caption);
  font-weight: var(--w-control);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* on a phone the words of a chip are all there: they wrap, and the tag grows */
@media (max-width: 820px), (pointer: coarse) {
  .coll .chip {
    white-space: normal;
    overflow-wrap: anywhere;
    text-overflow: clip;
    text-align: left;
  }
}
/* the pills of a card are one line each and of one height: what does not fit is cut, and the whole of it is the title */
.coll .row .chip {
  white-space: nowrap;
  overflow-wrap: normal;
  text-overflow: ellipsis;
}
/* a kind and a state are told by colour: the role a state names, else a hue of the kind's own,
 * a wash of it on the tag with the words in the ink, so the words are read the same on each */
.coll .chip[data-tone],
.coll .chip[data-hue] {
  background: color-mix(in srgb, var(--part) 24%, var(--raised));
  color: var(--ink);
}
.row-more,
.row-grip {
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  background: none;
  color: var(--dim);
  font-size: var(--t-title);
  line-height: var(--lh-title);
}
.row-grip {
  grid-column: 2;
  grid-row: 1;
  touch-action: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}
.row-more {
  grid-column: 3;
  grid-row: 1;
}
.row-detail {
  grid-column: 1 / -1;
  padding: var(--s-2) var(--s-1) var(--s-3);
}
.row.dragging {
  opacity: 0.35;
}
.row-detail {
  border-top: var(--bd);
}
.drag-ghost {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100;
  margin: 0;
  background: var(--raised);
  border-radius: var(--r-2);
  box-shadow: var(--e-2);
  pointer-events: none;
  list-style: none;
}
.drop-over {
  outline: var(--focus-ring);
  outline-offset: var(--focus-in);
  border-radius: var(--r-2);
}
.coll-more {
  width: 100%;
  margin-top: var(--s-2);
  min-height: 44px;
}
.coll-note {
  margin: 0 0 var(--s-2);
  font-size: var(--t-caption);
  color: var(--dim);
}
/* what a chart counts is a line of its own, in the ink, and not a caption */
.coll-chart .coll-note {
  font-size: var(--t-small);
  line-height: var(--lh-small);
  font-weight: var(--w-title);
  color: var(--ink);
}
/* a host page's own rules for a bare section or heading do not reach the groups and columns */
.coll section.group {
  display: block;
  flex: none;
  min-width: 0;
}
.coll section.board-column {
  display: grid;
  flex: none;
}
/* the groups: a heading that folds, its count, and the rows under it */
.group-title {
  margin: 0;
}
.group-head {
  display: flex;
  justify-content: space-between;
  width: 100%;
  min-height: 44px;
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-2);
  background: var(--raised-2);
  text-align: left;
  font-weight: var(--w-title);
}
/* the colour of a state stands on the edge of its heading, and in a wash over it */
.group-head[data-tone],
.group-head[data-hue],
.board-chip[data-tone],
.board-chip[data-hue] {
  border-inline-start: var(--s-1) solid var(--part);
  background: color-mix(in srgb, var(--part) 14%, var(--raised-2));
}
.board-column[data-tone],
.board-column[data-hue] {
  box-shadow: inset 0 var(--s-1) 0 var(--part);
}
.group-head::before {
  content: "\25b8";
  margin-right: var(--s-2);
  color: var(--dim);
}
.group-head[aria-expanded="true"]::before {
  content: "\25be";
}
.group-label {
  flex: 1;
}
.group-count {
  color: var(--dim);
  font-weight: var(--w-text);
}
/* the board on a phone: one column under a strip of chips, one a column */
.board-strip {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  margin-bottom: var(--s-2);
}
.board-chip {
  display: flex;
  gap: var(--s-2);
  align-items: center;
  min-height: var(--control-h);
  padding: var(--s-1) var(--s-3);
  border-radius: var(--r-1);
  background: var(--raised-2);
}
.board-chip[aria-pressed="true"] {
  background: var(--tint-fill);
  color: var(--on-tint);
}
.board-chip[aria-pressed="true"] .board-count {
  color: inherit;
}
.board-pager {
  display: flex;
  gap: var(--s-2);
  align-items: flex-start;
  position: relative;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
}
.coll .board-pager > section.board-column {
  flex: 0 0 calc(100% - var(--s-6));
  min-width: 0;
  scroll-snap-align: start;
}
/* the table: a column a property, and on a phone the same table in a box that scrolls sideways */
.coll-table-wrap {
  overflow-x: auto;
  border-radius: var(--r-2);
}
.coll-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--t-small);
}
.coll-table th,
.coll-table td {
  padding: var(--s-1) var(--s-2);
  text-align: left;
  vertical-align: top;
  border-bottom: var(--bd);
}
/* a cell that is not the title holds a short value and keeps it on a line, so the title is the column that wraps */
.coll-table td:not([data-title]) {
  white-space: nowrap;
}
.coll-table th {
  background: var(--raised-2);
  font-weight: var(--w-title);
}
.col-sort {
  padding: var(--s-1) 0;
  min-height: var(--control-h);
  background: none;
  font-weight: var(--w-title);
  color: var(--dim);
}
th[aria-sort="ascending"] .col-sort::after {
  content: " \2191";
}
th[aria-sort="descending"] .col-sort::after {
  content: " \2193";
}
.cell-edit {
  cursor: text;
  min-height: var(--s-5);
}
.coll-chart .chart-press {
  padding: 0;
  min-height: 44px;
  background: none;
  color: var(--tint);
  text-align: left;
}
/* the controls the frame enhances in place: a checkbox is a switch (its track and thumb are the
 * form's, in 75-views.css), and the row it sits in is a control's height */
input.adopted-switch {
  appearance: none;
  -webkit-appearance: none;
  padding: 0;
  min-height: 0;
  margin: calc((var(--control-h) - var(--s-5) - var(--s-1) / 2) / 2) 0;
  box-shadow: none;
  cursor: pointer;
}
@media (max-width: 820px) {
  .coll-table-wrap {
    overscroll-behavior-x: contain;
  }
  /* the title is held at the left while the rest of a row goes under it */
  .coll-table [data-title] {
    position: sticky;
    left: 0;
    z-index: 1;
    min-width: 8rem;
    max-width: 12rem;
    background: var(--raised);
    border-right: var(--bd);
  }
  .coll-table th[data-title] {
    background: var(--raised-2);
  }
  .coll-search {
    flex: 1 1 8rem;
  }
}
/* a finger reaches the controls of a collection whatever the width, as on a phone held sideways;
 * the controls take the height of `--control-h`, and a chip that is a button keeps its small size
 * and is reached by the pad around it, which `overflow-clip-margin` lets stand outside the tag */
@media (pointer: coarse) {
  .coll button.chip {
    position: relative;
    overflow: clip;
    overflow-clip-margin: var(--hit);
  }
  .coll button.chip::after {
    content: "";
    position: absolute;
    inset: calc(-1 * var(--s-3));
  }
}

/* The facets, the choice of group and the sort, in the sheet a phone's bar opens: one to a line at the
 * sheet's width. The button that opens it says how many are in force, in the tint. */
.coll-filters {
  display: grid;
  gap: var(--s-3);
  padding-bottom: var(--s-2);
}
.coll-filters > * {
  max-width: none;
}
.coll-filters > .coll-dir {
  justify-self: start;
}
.coll-preset {
  min-height: var(--control-h);
  padding: var(--s-1) var(--s-3);
  border: var(--bd);
  border-radius: var(--r-1);
  background: none;
}
.coll-preset[aria-pressed="true"] {
  border-color: var(--tint);
  background: var(--tint-wash);
  color: var(--tint);
  font-weight: var(--w-title);
}
.coll-filters > .coll-preset {
  justify-self: start;
}
.coll-filters-open[data-active] {
  color: var(--tint);
}
.coll-active:not(:empty) {
  padding: 0 var(--s-1);
  border-radius: var(--r-1);
  background: var(--tint-wash);
  font-size: var(--t-caption);
  line-height: var(--lh-caption);
}
.coll-saved {
  display: inline-flex;
  align-items: center;
  gap: 0;
}
.coll-saved > .coll-preset {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
.coll-saved > .coll-forget {
  min-height: var(--control-h);
  min-width: var(--control-h);
  border: var(--bd);
  border-left: 0;
  border-radius: 0 var(--r-1) var(--r-1) 0;
  background: none;
}
.coll-saved > .coll-preset:only-child {
  border-radius: var(--r-1);
}
.coll-save {
  min-height: var(--control-h);
  padding: var(--s-1) var(--s-3);
  border: var(--bd);
  border-radius: var(--r-1);
  background: none;
}
.coll-save-name {
  min-height: var(--control-h);
  max-width: 14ch;
}
.coll-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
  gap: var(--s-3);
  margin: 0;
  padding: 0;
  list-style: none;
}
.coll-tile {
  display: grid;
  gap: var(--s-1);
  align-content: start;
  min-width: 0;
}
.coll-tile > img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: var(--r-1);
  background: var(--tint-wash);
}
.coll-tile-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.coll-tile-facts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-1);
  font-size: var(--t-caption);
}
.coll-tile-fact {
  padding: 0 var(--s-1);
  border: var(--bd);
  border-radius: var(--r-1);
  background: none;
}
.coll-more-source {
  justify-self: start;
}

/* the deck: one card, its four grades under it, and the take back */
[data-deck] {
  display: grid;
  gap: var(--s-3);
  max-width: 36rem;
  margin: 0 auto;
  padding: var(--pad);
}
.deck-count {
  margin: 0;
  font-size: var(--t-small);
  color: var(--dim);
}
.deck-card {
  display: grid;
  gap: var(--s-3);
  min-height: 10rem;
  padding: var(--s-4);
  text-align: left;
  font: inherit;
  color: var(--ink);
  background: var(--raised-2);
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform var(--m-base) var(--curve), opacity var(--m-base) ease-out;
}
.deck-card:disabled {
  cursor: default;
}
.deck-front {
  font-size: var(--t-title);
}
.deck-back {
  padding-top: var(--s-3);
  border-top: var(--bd);
}
.deck-source {
  margin: 0;
  font-size: var(--t-caption);
  color: var(--dim);
}
.deck-card.left {
  transform: translateX(-40px) rotate(-3deg);
  opacity: 0;
}
.deck-card.right {
  transform: translateX(40px) rotate(3deg);
  opacity: 0;
}
.deck-grades {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--s-2);
}
.deck-grade.again {
  border-color: var(--bad);
}
.deck-grade.easy {
  border-color: var(--good);
}
.deck-undo {
  justify-self: start;
}

/* The job page: one row per job, its kind, its state and when it got there, opening to
 * what it was asked and what came of it. The state's colour is the one thing to read
 * at a glance, so it is the only colour on the row. */
.job {
  padding-bottom: var(--s-3);
  border-bottom: var(--bd);
}
.job > summary {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: var(--s-3);
  align-items: baseline;
  cursor: pointer;
}
.job > summary > b {
  font-weight: 500;
}
.job > summary > time,
.job-brief {
  color: var(--dim);
}
.job-state {
  color: var(--dim);
}
.job[data-state="queued"] .job-state,
.job[data-state="claimed"] .job-state {
  color: var(--tint);
}
.job[data-state="finished"] .job-state {
  color: var(--good);
}
.job[data-state="failed"] .job-state,
.job[data-state="lapsed"] .job-state {
  color: var(--bad);
}
.job-result {
  font-family: var(--mono);
  font-size: var(--t-mono);
  white-space: pre-wrap;
  word-break: break-word;
}
.job-needs {
  color: var(--warn);
}
