/**
 * @fileoverview Hive's frame (shell.js, workspace-bar.js): the fixed top bar (wordmark, the swarm's name, the kit's tabs
 * on a desk, the account), the swarm switcher and the account panel, and the phone's bottom
 * navigation (the kit app bar's bottom layout, held to 56 px). Does not own a page's own layout: a page keeps its
 * content clear of `--hive-top-h` and, under 760 px, `--hive-nav-h`.
 */

/* The bar is the page system's (web/system/page-system.css). It runs the window's width and stands in ONE place on
   every page, the Map included: its two insets are the page gutter's, so pressing a tab never moves the tabs under
   the pointer. (It once took the page column's edges on every page but the Map, and going from the Map to any other
   page at a wide window moved every tab 137 px.) A page keeps its own column under it. Its type is the kit's: the wordmark (600),
   the swarm's name and the tabs (500) at 14, a count at 12. Each part sets its own role's
   size, so the panels the bar opens keep theirs. */
.hive-top {
  position: fixed;
  inset: 0 0 auto;
  z-index: var(--gc-z-hud);
  display: flex;
  align-items: center;
  gap: var(--gc-space-4);
  block-size: var(--hive-top-h);
  padding: 0 var(--page-gutter);
  background: var(--hive-ground);
  box-shadow: inset 0 -1px 0 var(--hive-rule);
}

/* On a desk the wordmark a step above the tabs: the kit's name size at 600, on the bar's same 20 px line, so the bar's
   height and the tabs' places do not move. A phone's wordmark is as it was. */
@media (min-width: 760px) {
  .hive-top__wordmark {
    --type-brand-base-size: 16px;
    --type-brand-line: calc(20 / 16);
    --type-brand-weight: 600;
  }
}
.hive-top__place,
.hive-top__place-name {
  --type-lead-base-size: 14px;
  --type-lead-line: calc(20 / 14);
  --type-lead-weight: 500;
}
.hive-top__tabs {
  --type-nav-base-size: 14px;
  --type-nav-line: calc(20 / 14);
  --type-nav-weight: 500;
}

/* Wordmark, hairline, the swarm's name: where the person is. It gives way (the name shortens) before the tabs do. */
.hive-top__lead {
  display: flex;
  align-items: center;
  gap: var(--gc-space-3);
  flex: 0 1 auto;
  min-inline-size: 0;
}

.hive-top__brand {
  display: flex;
  align-items: center;
  flex: none;
  min-inline-size: var(--gc-touch);
  min-block-size: var(--gc-touch);
  margin-inline: calc(-1 * var(--gc-space-1));
  padding-inline: var(--gc-space-1);
  border-radius: var(--radius-md);
  color: var(--ink-primary);
  text-decoration: none;
}

.hive-top__brand:active {
  background: var(--gc-card-3);
}

.hive-top__wordmark {
  flex: none;
  padding-inline-end: 0.08em;
}

.hive-top__rule {
  flex: none;
  inline-size: 1px;
  block-size: 16px;
  background: var(--ink-control-edge);
}

/* The phone name always opens a panel. On a desk it is plain text when there is nowhere else to go. */
.hive-top__place {
  min-inline-size: 0;
  overflow: hidden;
  color: var(--ink-primary);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.hive-top__place--switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-inline-size: var(--gc-touch);
  max-inline-size: 100%;
  min-block-size: var(--gc-touch);
  margin-inline: calc(-1 * var(--gc-space-2));
  padding: 0 var(--gc-space-2);
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  transition: background-color var(--duration-100) var(--ease-out);
}

.hive-top__place-name {
  min-inline-size: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* `expand` in the name's own ink (icons.md laws 5 and 6): it points down at rest and turns a half while open. */
.hive-top__chevron {
  transition: transform var(--duration-150) var(--ease-out);
}

.hive-top__place--switch[aria-expanded='true'] {
  background: var(--gc-card-2);
}

.hive-top__place--switch[aria-expanded='true'] .hive-top__chevron {
  transform: rotate(180deg);
}

.hive-top__place--switch:active {
  background: var(--gc-card-3);
}

/* The kit's tabs, on links: the bar's full height, so the current tab's 3 px cream underline sits on the bar's edge. */
.hive-top__tabs {
  align-self: stretch;
  flex: none;
  box-shadow: none;
}

.hive-top__tabs .gc-tabs__tab {
  position: relative;
  min-block-size: 100%;
  color: var(--ink-2);
  text-decoration: none;
  transition: color var(--gc-dur-feedback) var(--gc-ease-out);
}

.hive-top__tabs .gc-tabs__tab[aria-current='page'] {
  color: var(--ink-primary);
}

.hive-top__tabs .gc-tabs__tab[aria-current='page']::after,
.hive-nav .gc-app-bar__tab[aria-current='page']::after {
  content: '';
  position: absolute;
  inset: auto 0 0;
  block-size: 2px;
  background: var(--ink-you);
}

.hive-top__tabs .gc-tabs__tab:active {
  color: var(--ink-primary);
}

.hive-top__end {
  display: flex;
  align-items: center;
  gap: var(--gc-space-3);
  flex: none;
  min-inline-size: 0;
  margin-inline-start: auto;
}

.hive-top__viewer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--gc-space-2);
  min-inline-size: var(--gc-touch);
  min-block-size: var(--gc-touch);
  padding: 0 var(--gc-space-1);
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--ink-context);
  white-space: nowrap;
}

.hive-top__viewer[aria-expanded='true'] {
  background: var(--gc-card-2);
}

.hive-top__viewer:active {
  background: var(--gc-card-3);
}

/* The reader's chip is the account control; their name is said in the panel it opens, not beside the chip. */
.hive-top__viewer-name { display: none; }

/* ── The bar: one line of type ──────────────────────────────────────────────────────────────────────────────────
   Every word in the bar stands on one baseline, and the bar sets it, not the words: the wordmark, the swarm's name,
   each tab and a count are items of ONE flex line aligned on their first baselines, so a word of another
   size (a count at 12) cannot ride above or below its neighbours. What is not a word
   (the hairline, the reader's chip) is centred on the bar. The tempting wrong edit is `align-items: center` on the
   bar or on a group inside it: centred boxes of different sizes put their words on different lines, which is the
   fault this replaced (three baselines in one 48 px bar).

   How it holds:
   - `::before` is the line itself: a word of no width in the tabs' own size, in a box as tall as the bar. It has the
     most above its baseline, so it stands at the bar's top and every word takes its baseline, tabs or no tabs.
   - The lead and the end are not boxes here (`display: contents`): a group that aligned its own items would centre
     its chip on the group, not on the bar.
   - A tab is one box (its rules are under "A desk: the tabs"): its word and its count stand on one baseline inside it.
   - The name stands further from the first tab than two tabs stand from each other, so it does not read as a tab.
   A phone's bar is the same line without the tabs (its destinations are the bottom bar's). */
.hive-top {
  /* A control in the bar: its target, and its face when pointed at (the kit's touch size, as before). */
  --bar-face-h: var(--gc-touch);

  align-items: baseline;
  gap: 0;
}

.hive-top::before {
  content: '\200b';
  flex: none;
  inline-size: 0;
  block-size: 100%;
  overflow: hidden;
  font: 500 14px / var(--hive-top-h) var(--type-body-family);
}

.hive-top__lead,
.hive-top__end { display: contents; }

/* A word with a face: its line centred in the face, its words on the bar's baseline. */
.hive-top__brand,
.hive-top__place--switch {
  display: grid;
  grid-auto-flow: column;
  align-items: baseline;
  align-content: center;
  box-sizing: border-box;
  min-block-size: 0;
  block-size: var(--bar-face-h);
  padding: 0 var(--gc-space-2);
}

.hive-top__brand { margin-inline: calc(-1 * var(--gc-space-2)); }

.hive-top__rule {
  align-self: center;
  margin-inline: var(--gc-space-3);
}

.hive-top__place {
  flex: 0 1 auto;
}

.hive-top__place--switch {
  grid-template-columns: 0 minmax(0, auto) auto;
  gap: 0;
  margin-inline: calc(-1 * var(--gc-space-2));
}

/* Words in a face keep the bar's own 14/20 line beside them, so their face stands where the wordmark's does (centred
   on the bar) and not where a shorter line would put it. */
.hive-top__place--switch::before {
  content: '\200b';
  inline-size: 0;
  overflow: hidden;
  font: 500 14px / 20px var(--type-body-family);
}

.hive-top__chevron {
  align-self: center;
  margin-inline-start: 6px;
}
/* The swarm's name on the tabs' own 20 px line, so the two make one row. */
.hive-top__place-name { line-height: 20px; }

/* The reader's chip: 22 px, its right edge the page column's own, so it ends where every card under it ends. */
.hive-top__viewer {
  align-self: center;
  min-inline-size: var(--bar-face-h);
  min-block-size: var(--bar-face-h);
  margin-inline: auto calc((22px - var(--bar-face-h)) / 2);
  padding: 0;
}
.hive-top__viewer > .hive-person {
  --hive-person-size: 22px;
  font: var(--text-head-label);
  letter-spacing: 0;
}

/* The one whole tally (workspace-bar.js `wholeTally`): at the bar's end before the reader's chip, its words on the bar's
   baseline, 16 px from the chip. It takes the bar's free room (the tabs keep their places) and never shrinks: the
   swarm's name gives way first. Its place stands, empty, until the first read answers. */
.hive-top__tally {
  display: flex;
  align-items: baseline;
  gap: var(--gc-space-4);
  flex: none;
  margin-inline-start: auto;
  color: var(--ink-2);
  white-space: nowrap;
}
.hive-top__tally + .hive-top__viewer { margin-inline-start: calc(16px - (var(--bar-face-h) - 22px) / 2); }
.hive-top__working > .session-mark {
  margin-inline-end: 6px;
  vertical-align: -2px;
}
.hive-top__working > [data-type='figure'] { color: var(--ink-1); }
/* What waits on the reader: the kit's red disc and its words, one link to the Queue, a full target that adds nothing
   to the line. */
.hive-top__waiting {
  padding-block: 12px;
  margin-block: -12px;
  border-radius: var(--radius-sm);
  color: var(--ink-1);
  text-decoration: none;
}
.hive-top__waiting > .hive-pill {
  margin: -4px 6px -4px 0;
  vertical-align: baseline;
}
.hive-top__waiting:focus-visible {
  outline: 2px solid var(--gc-focus);
  outline-offset: 2px;
}

/* A screen's Back is a mark and a word in one target: it is centred on the bar. */
.hive-top__back { align-self: center; }

/* A desk: the tabs. A tab is one box: its word and, when it has one, its count after the word inside the same box,
   with the same padding in every tab and one gap between two boxes. The count never stands in the space between two
   tabs, where it read as belonging to neither (seen on the owner's page). A tab is as wide as what it holds, so the
   tabs after it move when a count comes or goes. */
@media (min-width: 760px) {
  .hive-top {
    /* A tab's padding at each side, and from the swarm's name to the first tab's word (twice the space between two
       tabs' words, so the name does not read as a tab). */
    --bar-tab-pad: 10px;
    --bar-lead-gap: 38px;
  }

  .hive-top__brand { min-inline-size: 0; }

  .hive-top__tabs {
    align-self: baseline;
    gap: 4px;
    block-size: 100%;
    margin-inline-start: var(--bar-lead-gap);
  }
  .hive-top__place:not(.hive-top__place--switch) + .hive-top__tabs,
  .hive-top__lead:not(:has(.hive-top__place)) + .hive-top__tabs { margin-inline-start: calc(var(--bar-lead-gap) + var(--gc-space-2)); }

  .hive-top__tabs .gc-tabs__tab {
    z-index: 0;
    display: inline-grid;
    grid-auto-flow: column;
    align-items: baseline;
    align-content: center;
    justify-content: start;
    gap: 0 6px;
    min-block-size: 100%;
    padding: 0 var(--bar-tab-pad);
    border-radius: 0;
    line-height: 20px;
  }
  /* The room that held a count between two tabs is no box any more: the count is the tab's own second item. */
  .hive-top__slot { display: contents; }

  /* The box itself: 32 px of the bar's 48, a face when pointed at and a ring when focused by the keyboard. */
  .hive-top__tabs .gc-tabs__tab::before {
    content: '';
    position: absolute;
    inset: 8px 0;
    z-index: -1;
    border-radius: var(--corner-control);
    transition: background-color var(--duration-100) var(--ease-out);
  }
  .hive-top__tabs .gc-tabs__tab:focus-visible { box-shadow: none; }
  .hive-top__tabs .gc-tabs__tab:focus-visible::before { outline: 2px solid var(--ink-1); outline-offset: -2px; }

  /* The current tab's line is as wide as what the tab holds. */
  .hive-top__tabs .gc-tabs__tab[aria-current='page']::after { inset-inline: var(--bar-tab-pad); }
}

@media (min-width: 760px) and (hover: hover) and (pointer: fine) {
  .hive-top__tabs .gc-tabs__tab:hover::before { background: var(--face-quiet-hover); }
}

/* A narrow desk keeps the swarm's name: a tab's padding narrows (10 to 8 px) and the name stands 24 px from the first
   tab, so six tabs leave the name its first word at 760 px and each tab is at least 44 px wide. Where the name still
   has no room, workspace-bar.js cuts it after a whole word. */
@media (760px <= width < 1000px) {
  .hive-top {
    --bar-tab-pad: 8px;
    --bar-lead-gap: 24px;
  }
}

/* ── Panels: the switcher and the account ───────────────────────────────────────────────────────────── */

/* A sheet under the bar. It enters from 0.97 and transparent over 150 ms from its top edge, and leaves in 100 ms. */
.hive-switcher,
.hive-account,
.hive-coverage {
  position: fixed;
  inset: calc(var(--hive-top-h) + var(--gc-space-1)) auto auto;
  box-sizing: border-box;
  margin: 0;
  padding: var(--gc-space-1);
  border: 1px solid var(--gc-card-edge);
  border-radius: var(--radius-md);
  background: var(--gc-card);
  color: var(--ink-context);
  opacity: 0;
  transform: scale(0.97);
  transition-property: opacity, transform, overlay, display;
  transition-duration: var(--duration-100);
  transition-timing-function: ease-in;
  transition-behavior: allow-discrete;
}

.hive-switcher:popover-open,
.hive-account:popover-open,
.hive-coverage:popover-open {
  opacity: 1;
  transform: none;
  transition-duration: var(--duration-150);
  transition-timing-function: var(--ease-out);
}

@starting-style {
  .hive-switcher:popover-open,
  .hive-account:popover-open,
  .hive-coverage:popover-open {
    opacity: 0;
    transform: scale(0.97);
  }
}

.hive-switcher {
  inset-inline-start: var(--hive-switcher-start, var(--hive-gutter));
  inline-size: max-content;
  min-inline-size: 280px;
  max-inline-size: min(560px, calc(100vw - var(--hive-switcher-start, var(--hive-gutter)) - var(--hive-gutter)));
  max-block-size: 60dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  transform-origin: top left;
}

.hive-switcher__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* One row per swarm, 44 px: the name at body, the role at meta on the right. The current swarm's name is 600 with a
   2 px cream rule at the row's start; cream is never the colour of the words. */
.hive-switcher__row {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--gc-space-4);
  min-block-size: var(--gc-touch);
  padding: 10px var(--gc-space-3);
  border-radius: var(--radius-sm);
  color: var(--ink-primary);
  text-decoration: none;
}

.hive-switcher__row[aria-current='true'] .hive-switcher__name {
  font-weight: var(--type-lead-weight);
}

/* The desk's popover only: on a phone the list is the sheet's choice rows, whose ::before is the hairline (row.css). */
@media (min-width: 760px) {
  .hive-switcher__row[aria-current='true']::before {
    content: '';
    position: absolute;
    inset-block: var(--gc-space-1);
    inset-inline-start: 0;
    inline-size: 2px;
    border-radius: 0 1px 1px 0;
    background: var(--ink-you);
  }
}

.hive-switcher__name {
  flex: 1 1 auto;
  min-inline-size: 0;
  overflow-wrap: anywhere;
}

.hive-switcher__role {
  flex: none;
  color: var(--ink-proof);
}

.hive-switcher__tail:not([hidden]) {
  margin-block-start: var(--gc-space-1);
  padding-block-start: var(--gc-space-1);
  box-shadow: inset 0 1px 0 var(--gc-card-edge);
}

.hive-switcher__list[hidden] + .hive-switcher__tail {
  margin: 0;
  padding: 0;
  box-shadow: none;
}

.hive-switcher__status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gc-space-3);
  padding-inline-start: var(--gc-space-3);
}

.hive-switcher__note {
  margin: 0;
  color: var(--ink-proof);
}

/* Text buttons in the panels: More swarms, Retry, New swarm, Coverage, Sign out. */
.hive-switcher__action,
.hive-account__action {
  display: flex;
  align-items: center;
  flex: none;
  min-block-size: var(--gc-touch);
  padding: 0 var(--gc-space-3);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-context);
  text-align: start;
}

.hive-switcher__tail > .hive-switcher__action,
.hive-account__action {
  inline-size: 100%;
}

.hive-switcher[aria-busy='true'] .hive-switcher__action {
  color: var(--ink-proof);
  cursor: progress;
}

/* Rows scroll inside the sheet, so their ring is drawn inside them. */
.hive-switcher :is(.hive-switcher__row, .hive-switcher__action):focus-visible,
.hive-account__action:focus-visible {
  outline: 2px solid var(--gc-focus);
  outline-offset: -2px;
}

.hive-switcher__row:active,
.hive-switcher__action:active,
.hive-account__action:active {
  background: var(--gc-card-3);
}

/* Partial coverage is said here, quietly, and not in the bar: the coverage mark beside the Coverage entry's word, in
   coverage's amber, with no words. A choice row greys its icons, so the row's case is named to keep the amber. */
.hive-coverage__mark,
.hive-row__choice > .hive-coverage__mark {
  flex: none;
  color: var(--ink-notice);
}
.hive-account__coverage > .hive-coverage__mark { margin-inline-start: 6px; }
.hive-coverage__mark[hidden] { display: none; }

.hive-account {
  inset-inline-end: var(--hive-gutter);
  min-inline-size: 280px;
  max-inline-size: min(360px, calc(100vw - 2 * var(--hive-gutter)));
  transform-origin: top right;
}

.hive-account__name,
.hive-account__role {
  margin: 0;
  padding-inline: var(--gc-space-3);
  overflow-wrap: anywhere;
}

.hive-account__name {
  padding-block-start: var(--gc-space-2);
  color: var(--ink-primary);
}

.hive-account__role {
  color: var(--ink-proof);
}

/* The coverage panel sits under the account, which opens it. */
.hive-coverage {
  inset-inline-end: var(--hive-coverage-end, var(--hive-gutter));
  min-inline-size: 280px;
  max-inline-size: min(420px, calc(100vw - 2 * var(--hive-gutter)));
  max-block-size: 60dvh;
  padding: var(--gc-space-2) var(--gc-space-1);
  overflow-y: auto;
  overscroll-behavior: contain;
  transform-origin: top right;
}

.hive-coverage__title {
  margin: 0;
  padding-inline: var(--gc-space-3);
  color: var(--ink-primary);
  overflow-wrap: anywhere;
}

/* The title takes focus only so a screen reader starts the sheet there; it is not a control. */
.hive-coverage__title:focus {
  outline: none;
}

.hive-coverage__lines,
.hive-coverage__facts {
  display: grid;
  gap: var(--gc-space-2);
}

.hive-coverage__lines {
  margin-block-start: var(--gc-space-2);
}

.hive-coverage__facts:empty { display: none; }

.hive-coverage__line {
  margin: 0;
  padding-inline: var(--gc-space-3);
  color: var(--ink-context);
  overflow-wrap: anywhere;
}

.hive-coverage__action {
  display: flex;
  align-items: center;
  min-block-size: var(--gc-touch);
  padding-inline: var(--gc-space-3);
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--ink-primary);
  text-align: start;
}

.hive-coverage__action:focus-visible {
  outline: 2px solid var(--gc-focus);
  outline-offset: -2px;
}

.hive-coverage__action:active {
  background: var(--gc-card-3);
}

.hive-account__rule {
  block-size: 1px;
  margin: var(--gc-space-3) 0 var(--gc-space-1);
  background: var(--gc-card-edge);
}

.hive-account__create:not([hidden]) {
  display: grid;
  gap: var(--gc-space-1);
}

/* New swarm, opened: one field in place of the button, the same height, the refusal under it. */
.hive-account__field {
  inline-size: 100%;
  min-block-size: var(--gc-touch);
  margin: 0;
  padding: 0 var(--gc-space-3);
  border: 1px solid var(--ink-control-edge);
  border-radius: var(--radius-md);
  background: var(--hive-ground);
  color: var(--ink-primary);
}

.hive-account__field:focus-visible {
  outline: 2px solid var(--gc-focus);
  outline-offset: 0;
}

.hive-account__field[aria-busy='true'] {
  color: var(--ink-context);
  cursor: progress;
}

.hive-account__refusal {
  margin: 0;
  padding: 0 var(--gc-space-3) var(--gc-space-1);
  color: var(--ink-primary);
}

.hive-account__refusal:empty {
  display: none;
}

@media (hover: hover) and (pointer: fine) {
  .hive-top__tabs .gc-tabs__tab:not([aria-current='page']):hover {
    color: var(--ink-context);
  }

  .hive-top__brand:hover,
  .hive-top__place--switch:hover,
  .hive-coverage__action:hover,
  .hive-top__viewer:hover,
  .hive-switcher__row:hover,
  .hive-switcher__action:hover,
  .hive-account__action:hover {
    background: var(--gc-card-2);
  }

  .hive-switcher__action:hover,
  .hive-account__action:hover {
    color: var(--ink-primary);
  }
}

@media (prefers-reduced-motion: reduce) {
  .hive-switcher,
  .hive-account,
  .hive-coverage,
  .hive-switcher:popover-open,
  .hive-account:popover-open,
  .hive-coverage:popover-open {
    transform: none;
  }

  /* The chevron still says open or closed; it turns without moving through the half. */
  .hive-top__chevron {
    transition: none;
  }

  @starting-style {
    .hive-switcher:popover-open,
    .hive-account:popover-open,
    .hive-coverage:popover-open {
      transform: none;
    }
  }
}

/* ── Sheets on the ground ─────────────────────────────────────────────────────────────────────────────── */

/* Nothing is read on the dots: reading content outside a page's own layout sits on one sheet, 480 px wide on a desk,
   centred, its top edge a third of the way down the viewport; on a phone full width less the gutters, 96 px under the
   frame. Used by arrival (swarms.css) and by the wait between swarms. */
.hive-sheet {
  box-sizing: border-box;
  inline-size: min(480px, calc(100% - 2 * var(--hive-gutter)));
  margin: max(var(--gc-space-8), calc(100dvh / 3 - var(--hive-top-h))) auto var(--gc-space-8);
  padding: var(--gc-space-8);
  border: 1px solid var(--gc-card-edge);
  border-radius: var(--radius-md);
  background: var(--gc-card);
}

/* The wait between swarms: announced at once, drawn only once it has lasted 400 ms. */
.workspace__opening {
  color: var(--ink-primary);
  overflow-wrap: anywhere;
}

.workspace__opening:not([data-held]) {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* One state (state-sheet.js) on a sheet: what is true at title, in a status region that holds its line before the words
   arrive; a line of context under it when the state needs one; 24 px under that its one action. On a desk the page
   system sets its sizes, inks and card (page-system.css "A state"); what stands here is a phone's and the base. */
.state-sheet__status {
  min-block-size: calc(var(--type-title-base-size) * var(--type-title-line));
}

.state-sheet__title {
  margin: 0;
  color: var(--ink-primary);
  overflow-wrap: anywhere;
}

.state-sheet__context {
  margin: var(--gc-space-2) 0 0;
  color: var(--ink-context);
  overflow-wrap: anywhere;
}

/* The action is the page system's button (state-sheet.js, page-system.css `.hive-button`); here only where it stands. */
.state-sheet__action {
  margin: var(--gc-space-6) 0 0;
}

/* ── Phone ───────────────────────────────────────────────────────────────────────────────────────────── */

.hive-nav {
  display: none;
}

.hive-top__back,
.hive-account .hive-account__name > .hive-person {
  display: none;
}

/* The screen's Back in the shell's own head: the back icon and the place it returns to, a 44 px target. */
.hive-top__back {
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-inline-size: 44px;
  min-block-size: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink-primary);
}

/* The swarm list's tick is the phone sheet's (row.css); a desk marks the current swarm with its rule. */
@media (min-width: 760px) {
  .hive-switcher__row .hive-row__end { display: none; }
}

/* The frame's short sheets on a phone (More, coverage, the swarm's list; workspace-bar.js `frameSheets`), drawn by
   bottom-sheet.js. Their rows are the shared choice row (row.css); what follows is only what they borrow from the
   desk's popovers. */
@media (max-width: 759.98px) {
  .hive-more__account {
    position: relative;
    margin-block-start: var(--gc-space-2);
    margin-inline: calc(-1 * var(--hive-gutter));
  }

  /* One hairline over the reader and one between their rows, inset to the gutter as the rows' own are (row.css). */
  .hive-more__account::before,
  .hive-more__account .hive-account__create::before,
  .hive-more__account .workspace__sign-out::before {
    content: '';
    position: absolute;
    inset: 0 var(--hive-gutter) auto;
    block-size: 1px;
    background: var(--gc-card-edge);
  }

  .hive-more__account :is(.hive-account__create, .workspace__sign-out) { position: relative; }

  /* The reader: their chip and name, then their actions at the same measure as the choice rows. */
  .hive-more__account .hive-account__name {
    display: flex;
    align-items: center;
    gap: var(--gc-space-3);
    min-block-size: 56px;
    margin: 0;
    padding: var(--gc-space-3) var(--hive-gutter);
  }

  .hive-more__account .hive-account__role { margin: 0; padding: 0 var(--hive-gutter) var(--gc-space-3); color: var(--ink-proof); }
  .hive-more__account .hive-account__rule { display: none; }
  .hive-more__account .hive-account__create { padding: 0; }
  .hive-more__account .hive-account__create:not([hidden]) { display: block; }

  .hive-more__account .hive-account__action {
    display: flex;
    align-items: center;
    inline-size: 100%;
    min-block-size: 56px;
    padding: var(--gc-space-3) var(--hive-gutter);
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--ink-primary);
    text-align: start;
  }

  .hive-more__account .hive-account__action:active { background: var(--gc-card-3); }
  .hive-more__account .hive-account__coverage { display: none; }
  .hive-more__account .hive-account__field { margin: var(--gc-space-2) var(--hive-gutter); inline-size: calc(100% - 2 * var(--hive-gutter)); }
  .hive-more__account .hive-account__refusal { padding-inline: var(--hive-gutter); }

  /* The swarm's list as choice rows: the name on the first line, the role under it, the tick at the end. */
  .hive-bottom-sheet .hive-switcher__row { border-radius: 0; }
  .hive-bottom-sheet .hive-switcher__row .hive-row__choice { flex: initial; color: var(--ink-primary); }
  .hive-bottom-sheet .hive-switcher__tail { padding-block-start: var(--gc-space-2); box-shadow: none; }
  .hive-bottom-sheet .hive-switcher__action { min-block-size: 44px; }

  /* The actions in Coverage reach the window's edges. */
  .hive-bottom-sheet .hive-coverage__lines { margin: 0; }
  .hive-bottom-sheet .hive-coverage__line { padding-inline: 0; }
  .hive-bottom-sheet .hive-coverage__action {
    position: relative;
    margin-inline: calc(-1 * var(--hive-gutter));
    border-radius: 0;
  }

  .hive-bottom-sheet .hive-coverage__action::before {
    content: '';
    position: absolute;
    inset: 0 var(--hive-gutter) auto;
    block-size: 1px;
    background: var(--gc-card-edge);
  }

  .hive-switcher__list:not([hidden]) ~ .hive-switcher__coverage,
  .hive-switcher__tail:not([hidden]) + .hive-switcher__coverage { margin-block-start: var(--gc-space-3); }
}

@media (max-width: 759.98px) {
  .hive-top__tabs,
  .hive-top__viewer-name,
  .hive-top[data-swarm] .hive-top__viewer {
    display: none;
  }

  .hive-top[data-phone-screen] .hive-top__lead,
  .hive-top[data-phone-screen] .hive-top__viewer { display: none; }
  /* An opened exchange, a screen pushed over Exchanges: its Back stands at the left, where the wordmark and the swarm's
     name stand on the other pages, and the tally keeps the right end. Appended last to the bar, the Back once stood
     after the tally. */
  .hive-top[data-phone-screen] .hive-top__back {
    display: flex;
    order: -1;
  }

  .hive-sheet {
    inline-size: auto;
    margin: 96px var(--hive-gutter) var(--gc-space-8);
    padding: var(--gc-space-6);
  }

  /* The panels open under the bar, full width less the gutters. */
  .hive-switcher,
  .hive-account,
  .hive-coverage {
    inset-inline: var(--hive-gutter);
    inline-size: auto;
    min-inline-size: 0;
    max-inline-size: none;
    transform-origin: top center;
  }

  /* The kit app bar's bottom layout, held to the 56 px the phone's first viewport has room for. */
  .hive-nav.gc-app-bar[data-gc-layout='bottom'] {
    position: fixed;
    inset: auto 0 0;
    z-index: var(--gc-z-hud);
    display: flex;
    block-size: var(--hive-nav-h);
    padding: var(--gc-space-1) var(--gc-space-2);
  }

  .hive-nav.gc-app-bar[data-gc-layout='bottom'] .gc-app-bar__tab {
    gap: 3px;
    min-block-size: 48px;
    border: 0;
    background: transparent;
    text-decoration: none;
  }

  .hive-nav.gc-app-bar[data-gc-layout='bottom'] .gc-app-bar__glyph {
    block-size: 28px;
  }

  .hive-nav .gc-app-bar__tab[aria-current='page']::after { block-size: 2px; }
  .hive-nav .gc-app-bar__tab[aria-current='page'] .gc-app-bar__label { font-weight: var(--type-lead-weight); }

  /* Five places on the narrowest phones: each column is as wide as its word and the spare room is shared equally, so
     no two words touch. Equal fifths of 320 px ran "Queue 5" into "Decisions" and "Decisions" into "Exchanges". The
     kit's 56 px glyph box holds a chosen-tab capsule Hive does not draw (above), so here it is only as wide as its icon. */
  @media (max-width: 359.98px) {
    .hive-nav.gc-app-bar[data-gc-layout='bottom'] .gc-app-bar__tabs {
      grid-auto-columns: minmax(var(--gc-touch), auto);
    }

    .hive-nav.gc-app-bar[data-gc-layout='bottom'] .gc-app-bar__glyph {
      inline-size: auto;
    }
  }

  .hive-nav .gc-app-bar__glyph::before { display: none; }
  .hive-nav .gc-app-bar__label { color: var(--ink-proof); }
  .hive-nav .gc-app-bar__tab[aria-current='page'] .gc-app-bar__label { color: var(--ink-primary); }

  /* Each icon takes its word's ink (icons.md law 5): proof at rest, primary for the current place. */
  .hive-nav .hive-glyph {
    color: var(--ink-proof);
  }

  .hive-nav .gc-app-bar__tab[aria-current='page'] .hive-glyph {
    color: var(--ink-primary);
  }

  .hive-nav .gc-app-bar__tab:active .gc-app-bar__glyph {
    transform: scale(0.92);
  }
}

@media (hover: hover) and (pointer: fine) {
  .hive-nav .gc-app-bar__tab:not([aria-current='page']):hover :is(.hive-glyph, .gc-app-bar__label) {
    color: var(--ink-context);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
button, a { touch-action: manipulation; }
button { cursor: pointer; }
button:disabled { cursor: default; }
.workspace { min-block-size: 100dvh; padding-block-start: var(--hive-top-h); }
.workspace__content { min-inline-size: 0; }
.workspace__skip { position: fixed; top: 0; z-index: calc(var(--gc-z-hud) + 1); transform: translateY(-120%); min-height: var(--gc-touch); padding: 10px; background: var(--gc-card); }
.workspace__skip:focus { transform: translateY(0); }
.workspace__notice { margin: 0; padding: 7px 15px; background: var(--gc-card-2); color: var(--ink-notice); }
.workspace-message { margin: 10vh auto; padding: 24px; max-width: 430px; }
.workspace-message h1 { margin: 0 0 12px; }
.workspace-message button, .workspace-message input { min-height: var(--gc-touch); border-radius: var(--gc-radius-tag); padding: 8px 12px; }
.workspace-message button { background: var(--face-primary); border: 0; color: var(--ink-on-primary); font-weight: var(--type-lead-weight); }
.workspace-message input { background: var(--hive-ground); border: 1px solid var(--ink-control-edge); max-width: 100%; }
.workspace .area-map { height: calc(100dvh - var(--hive-top-h)); }

@media (max-width: 759.98px) {
  .workspace:has(.hive-nav:not([hidden])) { padding-block-end: var(--hive-nav-h); }
  /* A screen a page stands in the frame's `over` (screen.js) carries its own top and no bottom bar: the frame's two
     bars are not drawn behind it (shell.js `coverFrame` sets data-screen, and makes them inert). A screen that is a
     page (screen.js `keepsTabBar`, `data-screen-page`) ends at the tab bar's top edge, and the tab bar stays drawn and
     live under it, so the reader can always leave by a tab. */
  .workspace[data-screen] > .hive-top,
  .workspace[data-screen]:not([data-screen-page]) > .hive-nav { visibility: hidden; }
  .workspace .area-map { height: calc(100dvh - var(--hive-top-h) - var(--hive-nav-h)); }
}

/* More is the tab bar's own menu (ruled 26 Nov): while its list stands the tab bar stays drawn and live over the dimmed
   page (a press on another tab goes there, More's own closes the list), and the list's last row ends above the bar. */
@media (max-width: 759.98px) {
  :root:has(.hive-bottom-sheet[data-sheet="more"]:not([inert])) .hive-nav.gc-app-bar[data-gc-layout='bottom'] {
    z-index: calc(var(--gc-z-popover) + 1);
  }
  .hive-more { padding-block-end: var(--hive-nav-h); }
}

/* No Exchanges tab where nothing was asked of the reader or by them (shell.js `readAsked`): the desk's tab and More's row
   go; the address still opens the page. */
.hive-top__tabs .gc-tabs__tab[hidden],
.hive-more__place[hidden] { display: none; }

/* A phone's tally: the desk's, on the bar's one 52 px line at its end, so no phone page moves. The working mark and
   its figure, then the red disc, a 44 px target that leads to the Queue; the word `working` where the bar has room
   beside the swarm's whole name (`data-tally-compact` drops it first, workspace-bar.js `fitTop`). The words not
   shown stay in the accessible names. The Queue's count is the disc's alone: the bottom tab has none. */
@media (max-width: 759.98px) {
  .hive-top__tally {
    gap: var(--gc-space-1);
    padding-inline-start: var(--gc-space-3);
  }
  .hive-top__unit,
  .hive-top__waiting-words,
  .hive-top[data-tally-compact] .hive-top__word {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .hive-top__working > .session-mark { margin-inline-end: 4px; }
  .hive-top__waiting {
    display: inline-grid;
    place-items: center;
    min-inline-size: var(--gc-touch);
    min-block-size: var(--gc-touch);
    padding: 0;
    margin-block: -12px;
    margin-inline-end: calc((20px - var(--gc-touch)) / 2);
  }
  .hive-top__waiting > .hive-pill { margin: 0; }
}

/* Override `.gc-root` (system.css) variables directly so no 48px/108px dead bar padding remains in stage-only embed. */
:root[data-hive-embed='stage'],
:root[data-hive-embed='stage'] .gc-root {
  --hive-nav-h: 0px;
}
:root[data-hive-embed='stage']:not([data-hive-embed-view]),
:root[data-hive-embed='stage']:not([data-hive-embed-view]) .gc-root,
:root[data-hive-embed='stage'][data-hive-embed-view='map'],
:root[data-hive-embed='stage'][data-hive-embed-view='map'] .gc-root,
:root[data-hive-embed='stage'][data-hive-embed-view='run'],
:root[data-hive-embed='stage'][data-hive-embed-view='run'] .gc-root {
  --hive-top-h: 0px;
}
:root[data-hive-embed='stage'] .hive-nav,
:root[data-hive-embed='stage'] .hive-top__lead,
:root[data-hive-embed='stage'] .hive-top__brand,
:root[data-hive-embed='stage'] .hive-top__rule,
:root[data-hive-embed='stage'] .hive-top__place,
:root[data-hive-embed='stage'] .hive-top__end,
:root[data-hive-embed='stage'] .hive-top__tally,
:root[data-hive-embed='stage'] .hive-top__viewer,
:root[data-hive-embed='stage'] .hive-top__tabs .gc-tabs__tab:not([data-view='map']),
:root[data-hive-embed='stage']:not([data-hive-embed-view]) .hive-top,
:root[data-hive-embed='stage'][data-hive-embed-view='map'] .hive-top,
:root[data-hive-embed='stage'][data-hive-embed-view='run'] .hive-top {
  display: none;
}
:root[data-hive-embed='stage'] .hive-top__tabs {
  display: flex;
  margin-inline-start: 0;
}
:root[data-hive-embed='stage'] .workspace:has(.hive-nav:not([hidden])) {
  padding-block-end: 0;
}
