/* The phone's one stylesheet (UX stage 6). Linked LAST in the head, after every shell sheet and every page's own (`extra_css`), so it
 * wins an equal selector. ONE media block, ONE breakpoint: under 768 px. Colours, shadows and radii are tokens; edges are logical
 * properties. Rules that need the script (bar.js) are written under `html.shell-bar` and nowhere else: a page where the script
 * did not load keeps the plain <details>.
 *
 * This task holds the part every sheet of the bar shares: the bar's height, the sheet's place and its grab mark, and the veil.
 * The bar's own entries, the centre and the frame are later tasks of the stage, in this same block.
 */
@media (max-width: 767px) {
  /* The bar's height, said once, only where the bar is printed: the server prints the class `has-bar` on <html> (base_shell.html).
     Every reader of the variable gives it a fall-back. */
  html.has-bar {
    --bar-height: 56px;
  }

  /* THE FRAME (Task 4): the bar stands with the header in the stack. Above the drawers (10100), their backdrop and the area scrim (10099)
     and My Day's sheets (10050); below the header (10200), the report form and the keys dialog (10300), the peek (10250) and the toasts
     (10400). Every drawer and bottom sheet ends at var(--bar-height, 0px), so nothing lies under it and the timer in its centre is in
     view above every form. The nav is already `position: fixed` (shell.css); this replaces its 50. `nav.` makes it more specific than
     shell.css's `.shell-bottom-tabs`, whatever the order of the sheets. */
  nav.shell-bottom-tabs {
    z-index: var(--z-bar);
  }

  /* A sheet that rises from the bar (the centre's, More's): it stands on the bar's top, above the keyboard's lift, never over the
     header, and scrolls inside itself. No class is needed: it works with the script absent (the <details> opens it). */
  nav.shell-bottom-tabs .shell-sheet {
    position: fixed;
    inset-inline: 0;
    inset-block-end: calc(var(--bar-height, 56px) + var(--sheet-lift, 0px));
    max-height: calc(100vh - var(--header-height) - var(--bar-height, 56px) - var(--sheet-lift, 0px) - 8px);
    max-height: calc(100dvh - var(--header-height) - var(--bar-height, 56px) - var(--sheet-lift, 0px) - 8px);
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--panel-drop-bg);
    border-start-start-radius: var(--radius-lg);
    border-start-end-radius: var(--radius-lg);
    box-shadow: var(--shadow-sheet);
    z-index: 2;
  }

  /* The grab mark: drawn, not a control. */
  nav.shell-bottom-tabs .shell-sheet::before {
    content: "";
    display: block;
    inline-size: 44px;
    block-size: 5px;
    margin-block: 8px;
    margin-inline: auto;
    border-radius: var(--radius-full);
    background: var(--line);
  }

  /* The veil behind an open sheet: between the header and the bar, under the sheet. Only with the script (it is the script that shows
     it); the sheet itself needs none. */
  html.shell-bar nav.shell-bottom-tabs .shell-sheet__veil {
    position: fixed;
    inset-block: var(--header-height) var(--bar-height, 56px);
    inset-inline: 0;
    background: var(--sheet-veil);
    z-index: 1;
  }

  html.shell-bar nav.shell-bottom-tabs .shell-sheet__veil[hidden] {
    display: none;
  }

  /* ── The bar's entries (Task 3) ───────────────────────────────────────────────────────────────────────────────────── */

  /* Every entry is a 44 by 44 target, whatever the pointer, and as high as the bar. */
  nav.shell-bottom-tabs .shell-tab {
    align-self: stretch;
    min-block-size: 44px;
    min-inline-size: 44px;
  }

  /* The lit entry: a whole border and the lift (the menu row's own tokens). */
  nav.shell-bottom-tabs .shell-tab--active {
    border: var(--tab-lit-border);
    box-shadow: var(--tab-lit-shadow);
  }

  /* The label: 12 px, one line, an ellipsis (the entry's `title` and `aria-label` hold the whole word). Moved from shell.css. */
  nav.shell-bottom-tabs .shell-tab__label {
    display: block;
    font-size: 12px;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-inline-size: 100%;
  }

  /* The icon: 20 px. Moved from shell.css. */
  nav.shell-bottom-tabs .shell-tab__icon {
    font-size: 20px;
  }

  /* The Inbox's number: 12 px text, 20 px high, at the entry's inline end (a tile of the sheet carries it the same way). */
  nav.shell-bottom-tabs .shell-tab__badge {
    inset-block-start: 2px;
    inset-inline-end: 2px;
    min-inline-size: 20px;
    block-size: 20px;
    font-size: 12px;
    line-height: 1;
  }

  /* A page's own count on its entry (UX stage 6 Task 7: My Day's Needs you, `places.PAGE_COUNTS`). The span is the shell's markup on every
     page, empty and `hidden` until bar.js shows it above 0, so the sheet hides it (0,3,1: it beats the display of the rule above and the
     base rule of shell.css). Brand blue, not the Inbox's red: it counts work that needs the person, not unread notices. The words that
     name it for a screen reader are drawn off-screen while shown. */
  nav.shell-bottom-tabs .shell-tab__badge[hidden] {
    display: none;
  }

  nav.shell-bottom-tabs .shell-tab__badge--owed {
    background: var(--brand-primary);
    color: var(--on-brand);
  }

  nav.shell-bottom-tabs .shell-tab__owed-words:not([hidden]) {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  /* The two slots of the bar that hold a <details> (More) or a button a later task prints (the centre): each shares the bar's
     width as an entry does, and its summary fills it. */
  nav.shell-bottom-tabs .shell-bar__slot {
    display: flex;
    flex: 1;
  }

  nav.shell-bottom-tabs .shell-bar__slot > summary {
    flex: 1;
    list-style: none;
    cursor: pointer;
  }

  nav.shell-bottom-tabs .shell-bar__slot > summary::-webkit-details-marker {
    display: none;
  }

  /* A closed <details> that is a flex box must still hide its sheet (some engines show the content of a flex <details>). */
  nav.shell-bottom-tabs details.shell-bar__slot:not([open]) > .shell-sheet {
    display: none;
  }

  /* ── More's sheet (Task 3) ────────────────────────────────────────────────────────────────────────────────────────── */

  /* The tiles: the rest of the row, then the pins; three columns. */
  nav.shell-bottom-tabs .shell-sheet__tiles {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--sp-2);
    margin: 0;
    padding: 0 var(--sp-3) var(--sp-2);
    list-style: none;
  }

  /* A tile fills its cell, so the tiles of one row are as high as the tallest (a wrapped name). */
  nav.shell-bottom-tabs .shell-sheet__tiles > li {
    display: flex;
  }

  nav.shell-bottom-tabs .shell-sheet__tile {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--sp-1);
    min-block-size: 64px;
    padding: var(--sp-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--bg-1);
    color: var(--ink);
    text-align: center;
    text-decoration: none;
  }

  nav.shell-bottom-tabs .shell-sheet__tile > i:first-child {
    font-size: 20px;
  }

  nav.shell-bottom-tabs .shell-sheet__tile--current {
    border: var(--tab-lit-border);
    box-shadow: var(--tab-lit-shadow);
    background: var(--bar-bg);
    color: var(--brand-primary);
  }

  nav.shell-bottom-tabs .shell-sheet__name {
    font-size: 14px;
    line-height: 1.25;
    overflow-wrap: anywhere;
  }

  /* A pin: its mark at the tile's top inline end, and the sentence for a screen reader, visually hidden. */
  nav.shell-bottom-tabs .shell-sheet__pin {
    position: absolute;
    inset-block-start: 4px;
    inset-inline-end: 4px;
    font-size: 12px;
  }

  nav.shell-bottom-tabs .shell-sheet__pinned {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  /* The groups: a heading and rows of 44 px at least; name 14 px, its line 12 px. */
  nav.shell-bottom-tabs .shell-sheet__group {
    margin: var(--sp-3) 0 var(--sp-1);
    padding: 0 var(--sp-4);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.3;
    color: var(--ink-soft);
  }

  nav.shell-bottom-tabs .shell-sheet__rows {
    margin: 0;
    padding: 0 var(--sp-2);
    list-style: none;
  }

  nav.shell-bottom-tabs .shell-sheet__row {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    min-block-size: 44px;
    padding: var(--sp-2);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    color: var(--ink);
    text-decoration: none;
  }

  nav.shell-bottom-tabs .shell-sheet__row--current {
    border: var(--tab-lit-border);
    box-shadow: var(--tab-lit-shadow);
    color: var(--brand-primary);
  }

  nav.shell-bottom-tabs .shell-sheet__icon {
    flex: none;
    inline-size: 24px;
    font-size: 20px;
    text-align: center;
  }

  nav.shell-bottom-tabs .shell-sheet__text {
    display: flex;
    flex-direction: column;
    min-inline-size: 0;
  }

  nav.shell-bottom-tabs .shell-sheet__row .shell-more__name {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
  }

  nav.shell-bottom-tabs .shell-sheet__row small {
    font-size: 12px;
    line-height: 1.35;
    color: var(--ink-soft);
  }

  /* The Inbox row's number stands right after the name (menu.css styles it from 768 up only). */
  nav.shell-bottom-tabs .shell-sheet__row .shell-more__badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    min-inline-size: 20px;
    block-size: 20px;
    margin-inline-start: var(--sp-2);
    padding-inline: var(--sp-1);
    border-radius: var(--radius-full);
    background: var(--danger);
    color: var(--on-brand);
    font-size: 12px;
    font-weight: 700;
    vertical-align: middle;
  }

  /* The sentence that says whose list it is. */
  nav.shell-bottom-tabs .shell-sheet__note {
    margin: var(--sp-3) 0 0;
    padding: 0 var(--sp-4) var(--sp-4);
    font-size: 12px;
    line-height: 1.4;
    color: var(--ink-soft);
  }

  /* ── The frame, for sheets this stage does not rebuild (Task 4, Ruling 9) ──────────────────────────────────────────── */

  /* The Tools page's round button opens the page's own side panel: it clears the bar by 12 px, as the shell's own round button does
     (bottom 68 px = bar 56 + 12). The page's own rule `.tools-mobile-toggle` (0,1,0, in a <style> after this sheet) loses to this (0,2,1). */
  html.has-bar .tools-mobile-toggle {
    bottom: calc(var(--bar-height, 56px) + 12px);
  }

  /* Studio's slide strip and zoom control come from its BUILT sheet (static/studio/studio.css, built from another source, not rebuilt
     here): `.slide-strip` (0,1,0) and `.editor-shell__float-zoom` (0,1,0) lose to these (0,2,1). The RTL twin of the zoom
     (`.editor-shell--rtl .editor-shell__float-zoom`, 0,2,0) sets only the side, so its bottom is this one too. */
  html.has-bar .slide-strip {
    bottom: var(--bar-height, 56px);
  }

  html.has-bar .editor-shell__float-zoom {
    bottom: calc(var(--bar-height, 56px) + 16px);
  }

  /* ── The timer at the centre of the bar (Task 5) ──────────────────────────────────────────────────────────────────── */

  /* The header stays 90 px high on a phone, a timer running or not: the pill lives in the centre's sheet, so its row is gone. Only
     where the bar is printed (`has-bar`, the server's) AND its script runs (`shell-bar`): without the script the pill is still in
     the header and shell.css's 126 px stands. Beats `html.has-timer-pill` and `html.has-timer-pill .shell-topbar` (shell.css, 1023). */
  html.shell-bar.has-bar.has-timer-pill {
    --header-height: 90px;
  }

  html.shell-bar.has-bar.has-timer-pill .shell-topbar {
    padding-bottom: 0;
  }

  /* No frame of the pill in the header before the script moves it into the sheet (the id: it beats any rule of the pill's own). */
  html.shell-bar.has-bar .shell-topbar > #timer-pill {
    display: none;
  }

  /* THE CENTRE BUTTON: 48 px high INSIDE the 56 px bar (it does not stand proud of it: that would cover the last 18 px of every
     page), up to its slot's width, in the middle of it. It is a plus in a brand circle while nothing runs; the rules below draw the
     other states from `html[data-timer-state]` (the server prints it, timer-pill.js keeps it). No colour tells a state alone: each
     has its own mark or the clock, and its own spoken name. */
  nav.shell-bottom-tabs .shell-bar__slot--centre > .shell-bar__centre {
    position: relative;
    flex: 0 1 auto;
    align-self: center;
    margin-inline: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    box-sizing: border-box;
    inline-size: 48px;
    block-size: 48px;
    min-inline-size: 48px;
    max-inline-size: 100%;
    padding: 0;
    border: 1px solid transparent;
    border-radius: var(--radius-full);
    background: var(--brand-primary);
    color: var(--on-brand);
    cursor: pointer;
  }

  nav.shell-bottom-tabs .shell-bar__slot--centre > .shell-bar__centre:focus-visible {
    outline: 2px solid var(--brand-primary);
    outline-offset: 2px;
  }

  nav.shell-bottom-tabs details[open] > .shell-bar__centre {
    box-shadow: var(--tab-lit-shadow);
  }

  /* The marks: the plus is drawn while idle (and with no attribute at all); every other mark and the clock wait for their state. */
  nav.shell-bottom-tabs .shell-bar__mark {
    font-size: 24px;
    line-height: 1;
  }

  nav.shell-bottom-tabs .shell-bar__mark--paused,
  nav.shell-bottom-tabs .shell-bar__mark--system,
  nav.shell-bottom-tabs .shell-bar__mark--asked {
    display: none;
  }

  /* The clock's room (Ruling 21): the running and the paused button take 4 px of inline padding from 360 px up, so the first and the last
     digit do not touch the border; at 320 px none (the fit just below). The one media block has no second query, so the padding is
     a clamp of the window's width: 0 at 320 px, one pixel more per 10 px, 4 px from 360 px. */
  /* The clock is the pill's own mirror (timer-pill.js writes it each second): mono 12 px (the floor), 600. It is always EIGHT
     characters ("01:23:45"): 8 x 0.6 x 12 = 57.6 px, and the button at 320 px is at most (320 - 2 x 4) / 5 = 62.4 px wide with its two
     1 px borders and no inline padding: it fits whole. At 13 px it was 62.4 px of text and lost its last digit. */
  nav.shell-bottom-tabs .shell-bar__clock {
    display: none;
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
  }

  /* The pulsing dot of a running timer (the pill's own keyframes), and the dot of another timer waiting for confirmation. */
  nav.shell-bottom-tabs .shell-bar__pulse {
    display: none;
    flex: none;
    inline-size: 8px;
    block-size: 8px;
    border-radius: var(--radius-full);
    background: currentColor;
    animation: timer-pill-pulse 1.6s ease-in-out infinite;
  }

  nav.shell-bottom-tabs .shell-bar__owes {
    display: none;
    position: absolute;
    inset-block-start: 0;
    inset-inline-end: 0;
    box-sizing: border-box;
    inline-size: 12px;
    block-size: 12px;
    border: 2px solid var(--bar-bg);
    border-radius: var(--radius-full);
    background: var(--danger);
  }

  html[data-timer-owes="1"] nav.shell-bottom-tabs .shell-bar__owes {
    display: block;
  }

  /* RUNNING: the clock in green with the pulsing dot. */
  html[data-timer-state="running"] nav.shell-bottom-tabs .shell-bar__centre {
    inline-size: auto;
    padding-inline: clamp(0px, calc((100vw - 320px) / 10), 4px);
    background: var(--success-bg);
    border-color: var(--success-border);
    color: var(--success-ink);
  }

  html[data-timer-state="running"] nav.shell-bottom-tabs .shell-bar__clock {
    display: block;
  }

  html[data-timer-state="running"] nav.shell-bottom-tabs .shell-bar__pulse {
    display: block;
  }

  /* PAUSED by the person: the stopped clock and the pause mark, in amber. */
  html[data-timer-state="paused"] nav.shell-bottom-tabs .shell-bar__centre {
    inline-size: auto;
    padding-inline: clamp(0px, calc((100vw - 320px) / 10), 4px);
    background: var(--warning-bg);
    border-color: var(--warning-border);
    color: var(--warning-ink);
  }

  html[data-timer-state="paused"] nav.shell-bottom-tabs .shell-bar__clock {
    display: block;
  }

  html[data-timer-state="paused"] nav.shell-bottom-tabs .shell-bar__mark--paused {
    display: block;
    font-size: 16px;
  }

  /* PAUSED BY THE SYSTEM ("!") and ASKING whether the person is still working ("?"): amber, one mark. */
  html[data-timer-state="paused_by_system"] nav.shell-bottom-tabs .shell-bar__centre,
  html[data-timer-state="asked"] nav.shell-bottom-tabs .shell-bar__centre {
    background: var(--warning-bg);
    border-color: var(--warning-border);
    color: var(--warning-ink);
  }

  html[data-timer-state="paused_by_system"] nav.shell-bottom-tabs .shell-bar__mark--system,
  html[data-timer-state="asked"] nav.shell-bottom-tabs .shell-bar__mark--asked {
    display: block;
  }

  /* The plus gives way in every state but idle. */
  html[data-timer-state="running"] nav.shell-bottom-tabs .shell-bar__mark--plus,
  html[data-timer-state="paused"] nav.shell-bottom-tabs .shell-bar__mark--plus,
  html[data-timer-state="paused_by_system"] nav.shell-bottom-tabs .shell-bar__mark--plus,
  html[data-timer-state="asked"] nav.shell-bottom-tabs .shell-bar__mark--plus {
    display: none;
  }

  /* The names: ONE per state, visually hidden, read by a screen reader. Shown by the state attribute alone, no script names it. */
  nav.shell-bottom-tabs .shell-bar__name {
    display: none;
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  html:not([data-timer-state]) nav.shell-bottom-tabs .shell-bar__name--idle,
  html[data-timer-state="idle"] nav.shell-bottom-tabs .shell-bar__name--idle,
  html[data-timer-state="running"] nav.shell-bottom-tabs .shell-bar__name--running,
  html[data-timer-state="paused"] nav.shell-bottom-tabs .shell-bar__name--paused,
  html[data-timer-state="paused_by_system"] nav.shell-bottom-tabs .shell-bar__name--system,
  html[data-timer-state="asked"] nav.shell-bottom-tabs .shell-bar__name--asked {
    display: block;
  }

  /* THE CENTRE SHEET: the timer itself first (stage 1's own pill, moved here by bar.js), shown while the state is not idle and only
     where the script runs and the bar is here: that is the only place the pill is moved into. */
  nav.shell-bottom-tabs .shell-sheet__timer {
    display: none;
    padding: var(--sp-2) var(--sp-3) var(--sp-3);
  }

  html.shell-bar.has-bar:not([data-timer-state="idle"]) nav.shell-bottom-tabs .shell-sheet__timer {
    display: block;
  }

  /* A tile that is a button (Start timer) looks as the links beside it. */
  nav.shell-bottom-tabs button.shell-sheet__tile {
    inline-size: 100%;
    font: inherit;
    cursor: pointer;
  }

  /* THE PILL INSIDE THE SHEET. Stage 1's rule `html.has-timer-pill .timer-pill` (shell.css, 1023: position absolute at the header's
     foot) is more specific than a plain `.timer-pill`; these two selectors are more specific still, so the pill sits in the sheet's
     flow, wraps, and speaks in whole words. The pill gets no class from the script: it is styled by where it is. */
  html.shell-bar.has-bar .shell-sheet .timer-pill,
  html.shell-bar.has-bar.has-timer-pill .shell-sheet .timer-pill {
    position: static;
    gap: var(--sp-3);
    flex-wrap: wrap;
    white-space: normal;
    box-sizing: border-box;
    max-inline-size: 100%;
    border-radius: var(--radius-lg);
  }

  /* The clock itself never breaks (the walk saw "00:0 / 2:24" once the name was let wrap). */
  html.shell-bar.has-bar .shell-sheet .timer-pill__clock {
    flex: none;
    white-space: nowrap;
    overflow-wrap: normal;
  }

  /* A long name (a project's, in either script) wraps inside the sheet instead of running past its edge: the clock-and-name button
     takes the row's width and breaks its words; the Pause and Stop buttons stay beside it. (The walk saw a 399 px button in a 342 px sheet.) */
  html.shell-bar.has-bar .shell-sheet .timer-pill__who {
    flex: 1 1 0;
    flex-wrap: wrap;
    white-space: normal;
    text-align: start;
    overflow-wrap: anywhere;
  }

  /* The longer text of each state and the absence question are shown here (shell.css shows them from 1800 px only). */
  html.shell-bar.has-bar .shell-sheet .timer-pill__full,
  html.shell-bar.has-bar .shell-sheet .timer-pill__ask {
    display: inline;
  }

  /* No text of the pill is under 12 px here (shell.css has 11.2 and 11.5); its glyphs are 14 px. The running timer's NAME (the work's
     code) is read in the sheet as a sentence, not as a code: the body face at 14 px in the ink, on its own full-width line under the
     clock (shell.css's brand-blue monospace 12 px wrapped word by word in the narrow column: three lines in English, five in Arabic). */
  html.shell-bar.has-bar .shell-sheet .timer-pill__code {
    flex-basis: 100%;
    max-inline-size: 100%;
    font-family: inherit;
    font-size: 14px;
    color: var(--ink);
    white-space: normal;
    overflow: visible;
    overflow-wrap: anywhere;
  }

  html.shell-bar.has-bar .shell-sheet .timer-pill__badge {
    font-size: 12px;
  }

  html.shell-bar.has-bar .shell-sheet .timer-pill__btn--pause,
  html.shell-bar.has-bar .shell-sheet .timer-pill__btn--stop,
  html.shell-bar.has-bar .shell-sheet .timer-pill__play,
  html.shell-bar.has-bar .shell-sheet .timer-pill__icon {
    font-size: 14px;
  }

  /* Every control of the pill is a 44 px target, a real one: the invisible extensions of shell.css's 1023 block are not needed. */
  html.shell-bar.has-bar .shell-sheet .timer-pill__btn,
  html.shell-bar.has-bar .shell-sheet .timer-pill__who,
  html.shell-bar.has-bar .shell-sheet .timer-pill__open,
  html.shell-bar.has-bar .shell-sheet .timer-pill__badge {
    box-sizing: border-box;
    min-block-size: 44px;
    min-inline-size: 44px;
  }

  html.shell-bar.has-bar .shell-sheet .timer-pill__btn::after,
  html.shell-bar.has-bar .shell-sheet .timer-pill__who::after,
  html.shell-bar.has-bar .shell-sheet .timer-pill__badge::after {
    content: none;
  }

  /* ── Add a to-do, Report an issue and Messages behind the centre (Task 6) ─────────────────────────────────────────── */

  /* A tile only the script can work (Add a to-do folds a form; Messages presses the messenger's button) is drawn only where the
     script runs AND the bar is here (`html.shell-bar.has-bar`). Without the script the form is simply there and the messenger's own
     button is still on the page: a dead control is worse than an absent one. Report an issue is a real link and is always drawn. */
  /* `> li` of the tiles is `display: flex` above, (0,2,2); these are (0,3,1) and (0,5,1), so they beat it by the child combinator's
     extra class, and the shown tile keeps its flex (it fills its cell like the others). */
  nav.shell-bottom-tabs .shell-sheet__tiles > .shell-sheet__script-only {
    display: none;
  }

  html.shell-bar.has-bar nav.shell-bottom-tabs .shell-sheet__tiles > .shell-sheet__script-only {
    display: flex;
  }

  /* The to-do's line: under the tiles, one field and Add. With the script it is folded away until its tile is pressed (`data-open`);
     without it the form is always shown. The field is 16 px, so a phone does not zoom on focus; everything is a 44 px target. */
  nav.shell-bottom-tabs .shell-sheet__todo {
    margin: 0;
    padding: var(--sp-1) var(--sp-3) var(--sp-3);
  }

  html.shell-bar.has-bar nav.shell-bottom-tabs .shell-sheet__todo:not([data-open]) {
    display: none;
  }

  nav.shell-bottom-tabs .shell-sheet__todo-label {
    display: block;
    margin-block-end: var(--sp-1);
    font-size: 14px;
    line-height: 1.3;
    color: var(--ink);
  }

  nav.shell-bottom-tabs .shell-sheet__todo-row {
    display: flex;
    gap: var(--sp-2);
  }

  nav.shell-bottom-tabs .shell-sheet__todo-field {
    flex: 1 1 auto;
    min-inline-size: 0;
    min-block-size: 44px;
    box-sizing: border-box;
    padding-inline: var(--sp-3);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--bg-1);
    color: var(--ink);
    font: inherit;
    font-size: 16px;
  }

  nav.shell-bottom-tabs .shell-sheet__todo-add {
    flex: none;
    min-block-size: 44px;
    min-inline-size: 44px;
    box-sizing: border-box;
    padding-inline: var(--sp-4);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    background: var(--brand-primary);
    color: var(--on-brand);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
  }

  /* The answer: both sentences are in the markup; the one `data-say` names is shown (bar.js sets it; it writes no text). */
  nav.shell-bottom-tabs .shell-sheet__todo-say {
    margin: var(--sp-2) 0 0;
    font-size: 12px;
    line-height: 1.4;
    color: var(--ink-soft);
  }

  nav.shell-bottom-tabs .shell-sheet__todo-say > span {
    display: none;
  }

  nav.shell-bottom-tabs .shell-sheet__todo-say[data-say="ok"] > [data-todo-say="ok"],
  nav.shell-bottom-tabs .shell-sheet__todo-say[data-say="failed"] > [data-todo-say="failed"] {
    display: block;
  }

  nav.shell-bottom-tabs .shell-sheet__todo-say[data-say="failed"] {
    color: var(--danger);
  }

  /* The Messages tile's number: the messenger's badge, mirrored by bar.js as `data-count` and printed here (0 shows nothing). */
  nav.shell-bottom-tabs .shell-sheet__count {
    display: none;
  }

  nav.shell-bottom-tabs .shell-sheet__count:not([data-count="0"]) {
    display: inline-flex;
    position: absolute;
    inset-block-start: 4px;
    inset-inline-end: 4px;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    min-inline-size: 20px;
    block-size: 20px;
    padding-inline: var(--sp-1);
    border-radius: var(--radius-full);
    background: var(--danger);
    color: var(--on-brand);
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
  }

  nav.shell-bottom-tabs .shell-sheet__count:not([data-count="0"])::before {
    content: attr(data-count);
  }

  /* The unread messages stay in sight with the sheet closed: a small dot at the centre button's TOP INLINE START corner (the other
     waiting timer's dot is at the inline end), just outside the circle's box, so it never covers the clock's digits, at 320 px or
     any width. An empty `content`, so nothing is added to the button's spoken name (the number is read on the Messages tile). Only
     where the script wrote the number (`data-owed`, bar.js) and the bar is here: without the script the floating button is still
     there with its own number. */
  html.shell-bar.has-bar nav.shell-bottom-tabs .shell-bar__centre[data-owed]:not([data-owed="0"])::after {
    content: "";
    position: absolute;
    inset-block-start: -2px;
    inset-inline-start: -2px;
    box-sizing: border-box;
    inline-size: 12px;
    block-size: 12px;
    border: 2px solid var(--bar-bg);
    border-radius: var(--radius-full);
    background: var(--brand-primary);
  }

  /* ── The messenger on a phone (Task 6) ────────────────────────────────────────────────────────────────────────────────
     Its floating button goes (the Messages tile presses it) ONLY where the script runs, the bar is here AND the script has found the
     tile (`data-in-bar`, set by bar.js): a phone whose script failed keeps the button. Specificity: (0,5,1) against `.messenger-fab`
     (0,1,0), widget.css. The panel needs none of that: it stands between the header and the bar, whatever the script did. Against
     widget.css's `.messenger-panel` (0,1,0), its 480 px rule (0,1,0), shell.css's 767 rule (0,1,0) and stage 5's mirror
     `html[dir="rtl"] .messenger-panel` (0,2,1), this selector is (0,3,1): `html[dir]` is what lets it beat the mirror, in both
     directions, by the edges' logical properties. From 768 px up none of this applies. */
  html.shell-bar.has-bar .messenger-widget[data-in-bar] .messenger-fab {
    display: none;
  }

  html[dir] .messenger-widget .messenger-panel {
    position: fixed;
    inset-inline: 8px;
    inset-block: calc(var(--header-height) + 8px) calc(var(--bar-height, 56px) + 8px);
    width: auto;
    height: auto;
    max-height: none;
  }

  /* The panel's own way out (the floating button is gone): 44 by 44 at the panel's top inline end; the headers leave it room. widget.css
     hides it from 768 px up, where the round button closes the panel. */
  .messenger-widget .messenger-close {
    position: absolute;
    inset-block-start: 0;
    inset-inline-end: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    inline-size: 44px;
    block-size: 44px;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    color: var(--ink);
    font-size: 20px;
    cursor: pointer;
  }

  .messenger-widget .messenger-header {
    padding-inline-end: 52px;
  }

  /* ── The header, its panels and the toasts on a phone (Task 8) ────────────────────────────────────────────────────────
     Nothing here waits for the script: sizes, texts and places apply whether bar.js ran or not. (The 320 px arithmetic of the header
     counts it WITHOUT the timer's pill, which leaves under `html.shell-bar.has-bar`; no rule below assumes that, so none is scoped,
     except the last three, which are the no-script case's alone and say so.)
     Every rule is a single class (0,1,0) against the same class in shell.css, which loads before this sheet: equal, so this one wins. */

  /* The five controls of the header are 44 by 44 targets, whatever the pointer; an icon keeps its drawn size. Stage 5's
     `(pointer: coarse)` rule in shell.css says the same for the bells and the picture; it stays (it holds from 768 px up too). */
  .shell-search-trigger,
  .shell-lang__btn,
  .notification-bell-btn,
  .admin-notification-bell-btn,
  .shell-user-chip {
    min-block-size: 44px;
    min-inline-size: 44px;
  }

  .shell-search-trigger,
  .shell-user-chip {
    justify-content: center;
  }

  /* The language form's own side margins go: five 44 px controls and four 2 px gaps must fit 320 px (8 + 62 + 8 + 220 + 8 + 8 = 314). */
  .shell-lang {
    margin: 0;
  }

  /* The picture: 44 px high is 62 px wide at the file's 1169 by 826. */
  .shell-logo__img {
    height: 44px;
  }

  /* The three header panels hang from the WINDOW, 8 px in from both edges, between the header and the bar: none passes the screen.
     `html[dir] .shell-dropdown` (0,2,1) equals shell.css's `html[dir="rtl"] .shell-dropdown` (0,2,1) and loads after it, so the
     account menu's Arabic `left: 0; right: auto` loses; the two bells' `.notification-dropdown` and `.admin-notification-dropdown`
     (0,1,0) equal shell.css's own (0,1,0) and also load after it. The panels stay inside the header's stacking context: above the
     bar's sheets. The bells' inline `overflow-y: auto` is kept; their position, top, width and max-height left the templates. */
  .notification-dropdown,
  .admin-notification-dropdown,
  html[dir] .shell-dropdown {
    position: fixed;
    inset-block-start: calc(var(--header-height) + 4px);
    inset-inline: 8px;
    width: auto;
    max-width: none;
    max-height: calc(100vh - var(--header-height) - var(--bar-height, 56px) - 16px);
    max-height: calc(100dvh - var(--header-height) - var(--bar-height, 56px) - 16px);
    overflow-y: auto;
  }

  /* The account menu's entries wrap on a phone (stage 5's `white-space: nowrap`, `.shell-dropdown__item` (0,1,0), holds from 768 px
     up): this rule is the same (0,1,0) and loads after it. */
  .shell-dropdown__item {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  /* The toasts fill the window less 8 px each side. `[dir] .toast-container` (0,2,0) beats animations.css's
     `[dir="rtl"] .toast-container` (0,2,0) by loading after it; `#ws-toast-container` (1,0,0) equals shell.css's. `#toast-container`
     is printed by `frontend/base.html`, which extends the shell (so this sheet loads on its 368 templates): in Arabic site.css's
     `html[dir="rtl"] #toast-container` (1,1,1: `left: 16px`) beats its own phone rule (1,0,0), so a long toast ran from 16 px to the
     screen's right edge. `html[dir] #toast-container` is (1,1,1) too and loads later: it wins in both directions. */
  #ws-toast-container,
  [dir] .toast-container,
  html[dir] #toast-container {
    inset-inline: 8px;
    width: auto;
    max-width: none;
  }

  /* No text of the shell under 12 px (P4): the bells' number (a badge that is shown; the bar's own number is sized above, by
     `nav.shell-bottom-tabs .shell-tab__badge` (0,2,1)), the side menu's lock, number and section titles, and the search window's
     key caps, section titles and type tags. The two bells' number is `.shell-actions .notification-badge` (0,2,0), the selector of
     shell.css's whole badge: equal, and this sheet loads later. */
  .shell-actions .notification-badge,
  .shell-actions .admin-notification-badge,
  .shell-sidebar__lock,
  .shell-sidebar__badge,
  .shell-sidebar__section-title,
  .cp-kbd,
  .cp-kbd-plus,
  .cp-section-title,
  .cp-result__type,
  .ws-toast__hint {
    font-size: 12px;
  }

  /* The search window's own `<style>` stands in the page's body, AFTER this sheet, and wins a tie: the window's id lifts these two
     over it (1,1,0 against 0,1,0). */
  #command-palette .cp-tab__hint,
  #command-palette .cp-create-badge {
    font-size: 12px;
  }

  /* After 12 px the window's five key hints are wider than the 288 px of a 320 px phone: they wrap onto a second line. */
  .cp-footer {
    flex-wrap: wrap;
    gap: var(--sp-2) var(--sp-4);
  }

  /* The pill's own text, where the pill is still in the header (the script has not run): 12 px. The pause and stop buttons carry a
     glyph while the timer runs but WORDS ("Stop now", "Keep timing") after an absence (timer-pill.js), so they are text too; only the
     play triangle (a glyph in every state) keeps its drawn size. */
  .timer-pill__code,
  .timer-pill__badge,
  .timer-pill__btn--pause,
  .timer-pill__btn--stop {
    font-size: 12px;
  }

  /* Without the script an IDLE pill is a sixth control in a row that is 366 px wide for the administrator at 320 px: the picture and
     Sign out behind it would be cut. The header wraps as it does for a running timer (shell.css, `html.has-timer-pill`): 126 px, the
     pill on the second line. `:has()` is allowed HERE only (a browser without it keeps the cut row that was accepted before: never
     worse). Never under `html.shell-bar`: with the script the pill is in the centre sheet and the header is 90 px. A page with no pill
     (a member with no role, the external auditor) holds no `.timer-pill--idle` and is not matched. Specificity (0,2,1) against
     `:root`'s `--header-height` (0,1,0). */
  html:not(.shell-bar):has(.timer-pill--idle) {
    --header-height: 126px;
  }

  html:not(.shell-bar):has(.timer-pill--idle) .shell-topbar {
    padding-block-end: 36px;
  }

  html:not(.shell-bar):has(.timer-pill--idle) .timer-pill {
    position: absolute;
    inset-block-end: 2px;
    inset-inline-end: var(--sp-2);
  }
}
