/* --------------------------------------------------------------------------------
   Night Shift product layer.

   Anything genuinely specific to this app lives here as --ns-* / .ns-*. Overriding a
   --gm-* value in place would create invisible drift across products, so we don't
   (SPEC §6.2).

   Phone first throughout: the most important screen is not a desk, it is a phone at
   03:00 — one-handed, no zoom, and never a horizontally scrolling page.
   -------------------------------------------------------------------------------- */

:root {
  --ns-max-width: 68rem;
  --ns-row-gap: var(--gm-space-3);
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--gm-bg-base);
  color: var(--gm-text-primary);
  font-family: var(--gm-font-sans, Inter, system-ui, sans-serif);
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

/* Sticky footer: the shell is at least as tall as the viewport and lays out as a column, so
   the footer sits on the window's bottom edge on a short page and after the content on a long
   one. dvh first, because on mobile 100vh includes the browser chrome and would push the
   footer just out of view. */
.ns-shell {
  max-width: var(--ns-max-width); margin: 0 auto; padding: var(--gm-space-4);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex; flex-direction: column;
}
/* Grows to fill whatever the header and footer leave, and is itself a column so a page can
   centre its content vertically (the login screen does). */
#main { flex: 1 0 auto; display: flex; flex-direction: column; }

/* ---- Header ---------------------------------------------------------------- */

/* One optical row. Baseline alignment was the bug: a padded button and bare text links have
   different box heights, so their baselines land at different heights and the links appear to
   float above the button. Everything in the bar is centred on a shared axis instead, and the
   items that are boxes (links, button) get the same height so their edges line up too. */
.ns-header {
  display: flex; flex-wrap: wrap; gap: var(--gm-space-3) var(--gm-space-5);
  align-items: center; justify-content: space-between;
  padding: var(--gm-space-3) 0; border-bottom: 1px solid var(--gm-border-subtle);
}
.ns-header__brand {
  /* The glow below is absolutely positioned against this box; without `relative` it resolves
     against an ancestor and lands nowhere near the moon. */
  position: relative;
  display: inline-flex; align-items: center; gap: var(--gm-space-2);
  min-height: 44px;
  font-weight: 650; letter-spacing: -0.01em; text-decoration: none; color: inherit;
}
/* The crescent's visual mass sits low-left inside its box, so a hair of optical nudging aligns
   it with the cap height of the wordmark instead of its bounding box. */
.ns-moon { flex: none; color: var(--gm-accent); translate: 0 -1px; }

/* Navigation. Real space between the items: they were one padding-width apart, which reads as one
   long word — the first thing anyone needs from a nav bar is where one label ends and the next
   begins. Each link is a 44px-high box, so the row has one shared centre line and every link is a
   proper touch target rather than a bare word. */
.ns-header__nav { display: flex; align-items: center; gap: var(--gm-space-6); flex-wrap: wrap; }
.ns-header__nav a {
  display: inline-flex; align-items: center; min-height: 44px;
  color: var(--gm-text-secondary); text-decoration: none; border-radius: var(--gm-radius-sm, 4px);
}
.ns-header__nav a:hover { color: var(--gm-text-primary); }
.ns-header__nav a[aria-current="page"] { color: var(--gm-text-primary); font-weight: 600; }

/* Home link hover: the moon comes up. Dim green at rest, full moonlight on hover.
   The glow is a round pseudo-element behind the icon, NOT a filter on the SVG: stacked
   drop-shadows on an inline SVG rendered as a hard-edged rectangle the size of the element box,
   which looked like a yellow background rather than moonlight. A radial gradient is round by
   construction and cannot be clipped to a box. */
:root { --ns-moonlight: #ffd45c; }
.ns-header__brand::before {
  content: "";
  position: absolute; left: -12px; top: 50%; translate: 0 -50%;
  width: 44px; height: 44px; border-radius: 50%;
  /* Long, gentle falloff: a short one leaves a visible circle edge, which reads as a disc rather
     than light. */
  background: radial-gradient(circle,
    rgba(255, 216, 110, 0.80) 0%,
    rgba(255, 202, 60, 0.46) 26%,
    rgba(255, 186, 20, 0.22) 44%,
    rgba(255, 176, 0, 0.08) 62%,
    rgba(255, 176, 0, 0.02) 78%,
    transparent 100%);
  /* A round box-shadow on top of the gradient carries the bloom further out than a gradient can
     without banding — and unlike a filter it cannot be clipped to a rectangle. */
  box-shadow: 0 0 26px 6px rgba(255, 198, 48, 0.22);
  /* Behind the icon, above the header background. */
  z-index: -1;
  opacity: 0; pointer-events: none;
  transition: opacity var(--gm-duration-base) var(--gm-ease-out);
}
.ns-header__brand:hover::before,
.ns-header__brand:focus-visible::before { opacity: 1; }
.ns-header__brand .ns-moon {
  transition: color var(--gm-duration-base) var(--gm-ease-out);
}
.ns-header__brand:hover .ns-moon,
.ns-header__brand:focus-visible .ns-moon { color: var(--ns-moonlight); }
/* The wordmark warms with it, so the glow reads as one gesture instead of a loose icon. */
.ns-header__brand span { transition: color var(--gm-duration-base) var(--gm-ease-out); }
.ns-header__brand:hover span,
.ns-header__brand:focus-visible span { color: var(--ns-moonlight); }
@media (prefers-reduced-motion: reduce) {
  /* Keep the state change — it carries focus information — but drop the fade. */
  .ns-header__brand::before, .ns-header__brand .ns-moon, .ns-header__brand span { transition: none; }
}

/* ---- Filters ----------------------------------------------------------------- */

.ns-filters { display: flex; gap: var(--gm-space-2); flex-wrap: wrap; margin: 0 0 var(--gm-space-5); }
.ns-filter {
  display: inline-flex; gap: var(--gm-space-2); align-items: center;
  padding: var(--gm-space-2) var(--gm-space-3);
  border: 1px solid var(--gm-border-subtle); border-radius: var(--gm-radius-full, 999px);
  color: var(--gm-text-secondary); text-decoration: none; font-size: 0.875rem;
  min-height: 44px; /* thumb target, web scope minimum */
}
.ns-filter:hover { color: var(--gm-text-primary); }
.ns-filter[aria-current="page"] {
  color: var(--gm-text-primary); border-color: var(--gm-accent); font-weight: 600;
}
/* An exhausted alert must never be something you have to go looking for. */
.ns-filter--exhausted[data-nonzero="true"] {
  border-color: var(--ns-severity-critical); color: var(--gm-text-primary);
}
.ns-filter__count { font-variant-numeric: tabular-nums; opacity: 0.8; }

/* ---- Alert list -------------------------------------------------------------- */

.ns-search { display: flex; gap: var(--gm-space-2); flex-wrap: wrap; margin: 0 0 var(--gm-space-4); }
.ns-search input[type="search"] { flex: 1 1 16rem; width: auto; }
.ns-bulk { margin: 0 0 var(--gm-space-3); }

.ns-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--ns-row-gap); }
.ns-row {
  display: grid; gap: var(--gm-space-2) var(--gm-space-3);
  /* A fixed severity column: "CRITICAL" and "ERROR" are different widths, and with an auto column
     every title started somewhere else — a ragged left edge down the one list that is read fastest. */
  grid-template-columns: auto 6.5rem 1fr auto;
  /* Centre, not start: a badge and a line of text have different heights, and aligning their tops
     leaves the badge visibly high. */
  align-items: center;
  padding: var(--gm-space-3) var(--gm-space-4);
  border: 1px solid var(--gm-border-subtle); border-radius: var(--gm-radius-md, 8px);
  background: var(--gm-bg-elevated, transparent);
}
/* The team's tint (Team#color) layered over the tile's own background, so contrast with the
   canvas is kept and only the hue says whose alert it is. */
.ns-row--team { background-image: linear-gradient(var(--ns-team-color), var(--ns-team-color)); }
.ns-row > .ns-badge:first-of-type { justify-self: start; }
/* The bulk checkbox spans the row, so the meta line below still starts under the title. */
.ns-row__check {
  grid-row: 1 / span 2; display: grid; place-items: center;
  min-width: 44px; min-height: 44px; margin: calc(-1 * var(--gm-space-2)); cursor: pointer;
}
.ns-row__check input { width: 1.125rem; height: 1.125rem; margin: 0; accent-color: var(--gm-accent); }
.ns-row:hover { border-color: var(--gm-accent); }
.ns-row__link { color: var(--gm-text-primary); text-decoration: none; font-weight: 600; font-size: 1.0625rem; }
.ns-row__link:hover { text-decoration: underline; }
.ns-row__meta {
  /* Starts under the title, not under the severity badge — the meta belongs to the title. */
  grid-column: 3 / -1; display: flex; flex-wrap: wrap; gap: var(--gm-space-3);
  color: var(--gm-text-secondary); font-size: 0.8125rem;
}
.ns-row__meta time, .ns-row__age { font-variant-numeric: tabular-nums; }
/* Separated by a dot rather than by space alone: "Infra uptime_kuma 2 months old" read as one phrase. */
.ns-row__meta > * + *::before { content: "·"; margin-right: var(--gm-space-3); opacity: 0.6; }

/* Severity and status are NEVER colour alone — the badge always carries text (SPEC §6.2).
   Colour is the redundant cue, not the message. */
.ns-badge {
  display: inline-flex; align-items: center; gap: var(--gm-space-1);
  padding: 2px var(--gm-space-2); border-radius: var(--gm-radius-sm, 4px);
  font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  border: 1px solid currentColor; white-space: nowrap;
}
:root {
  --ns-severity-critical: #c0392b;
  --ns-severity-error: #d35400;
  --ns-severity-warning: #b7950b;
  --ns-severity-info: #2874a6;
}
.ns-severity--critical { color: var(--ns-severity-critical); }
.ns-severity--error    { color: var(--ns-severity-error); }
.ns-severity--warning  { color: var(--ns-severity-warning); }
.ns-severity--info     { color: var(--ns-severity-info); }

/* ---- Alert detail ------------------------------------------------------------ */

/* A quiet kicker line above the title: severity and status as badges, the team as plain text, with
   room before the headline instead of crowding it. */
.ns-detail__kicker {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--gm-space-2);
  margin: 0 0 var(--gm-space-2);
  color: var(--gm-text-secondary); font-size: 0.875rem;
}
.ns-detail__head { margin: var(--gm-space-5) 0 var(--gm-space-8); }
/* Previous / next through the list, above the alert it belongs to; the position says how far. */
.ns-detail__nav { display: flex; flex-wrap: wrap; align-items: center; gap: var(--gm-space-3); margin-bottom: var(--gm-space-5); }
/* Thumb-sized: this is how someone goes through alerts on a phone at night. */
.ns-detail__nav .ns-seg__item { min-height: 44px; padding: 0 var(--gm-space-4); }
.ns-detail__position { font-size: 0.875rem; color: var(--gm-text-secondary); font-variant-numeric: tabular-nums; }
.ns-seg__item[aria-disabled="true"] { opacity: 0.4; cursor: default; }
.ns-detail__title { font-size: 1.75rem; line-height: 1.2; letter-spacing: -0.015em; margin: 0 0 var(--gm-space-5); text-wrap: balance; }
.ns-detail__actions { display: flex; flex-wrap: wrap; gap: var(--gm-space-2); margin: 0; }
.ns-detail__actions form { margin: 0; }
/* A link among buttons (the work item) takes the buttons' box, so the row keeps one height. */
.gm .ns-detail__actions > a.gm-web-btn, .gm .ns-detail__actions button.gm-web-btn { height: 44px; min-height: 44px; display: inline-flex; align-items: center; box-sizing: border-box; }

/* Wide content scrolls inside its own container — the page never scrolls sideways. */
.ns-scroll-x { overflow-x: auto; }
.ns-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.ns-table th, .ns-table td {
  text-align: left; padding: var(--gm-space-2) var(--gm-space-3);
  border-bottom: 1px solid var(--gm-border-subtle); white-space: nowrap;
  vertical-align: middle; /* rows carry controls of different heights */
}
.ns-table th {
  font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--gm-text-secondary); padding-bottom: var(--gm-space-2);
}
.ns-table tbody tr:last-child td { border-bottom: 0; }
/* First and last cells align with the section edge instead of floating inside padding. */
.ns-table th:first-child, .ns-table td:first-child { padding-left: 0; }
.ns-table th:last-child, .ns-table td:last-child { padding-right: 0; }
/* The action column hugs the right edge and shrinks to its content, so the columns that carry
   information get the width. */
.ns-table td:last-child.ns-cell-actions,
.ns-table th:last-child.ns-cell-actions { width: 1%; text-align: right; }
/* Numbers align on their digits and use tabular figures, so a column of them can be compared at a
   glance rather than read. */
.ns-num { font-variant-numeric: tabular-nums; }
/* Written with the table in the selector because `.ns-table th` would otherwise win on specificity
   and keep everything left-aligned. */
.ns-table th.ns-num, .ns-table td.ns-num { text-align: right; padding-right: var(--gm-space-5); }

/* What happened, on a rail: the same shape as the escalation ladder, so "what will happen" and
   "what happened" read alike. Time in a fixed column, a dot on the rail, the event after it. */
.ns-timeline { list-style: none; margin: 0; padding: 0; display: grid; }
.ns-timeline li {
  position: relative;
  display: grid; grid-template-columns: 8.5rem 1fr; gap: var(--gm-space-5);
  padding: var(--gm-space-2) 0;
  font-size: 0.9375rem;
}
.ns-timeline li::before {
  content: ""; position: absolute; left: calc(8.5rem + var(--gm-space-5) / 2 - 1px); top: 0; bottom: 0;
  border-left: 1px solid var(--gm-border-default);
}
.ns-timeline li:first-child::before { top: 1.1rem; }
.ns-timeline li:last-child::before { bottom: calc(100% - 1.1rem); }
.ns-timeline li::after {
  content: ""; position: absolute; left: calc(8.5rem + var(--gm-space-5) / 2 - 4px); top: calc(1.1rem - 3px);
  width: 7px; height: 7px; border-radius: 50%; background: var(--gm-accent);
}
.ns-timeline time { color: var(--gm-text-secondary); font-variant-numeric: tabular-nums; font-size: 0.875rem; }

/* ---- Language switch ---------------------------------------------------------
   Two links rather than a dropdown: with two languages a select costs a click and hides the current
   state. Sits in the footer because it is a preference, not navigation. */

.ns-lang { display: flex; align-items: center; gap: var(--gm-space-1); }
.ns-lang__form { margin: 0; }
/* Both states share one box, or the active language sits a couple of pixels above the other and
   the pair reads as broken rather than as a choice. */
.ns-lang__current, .gm .ns-lang__link {
  display: inline-flex; align-items: center; justify-content: center;
  height: 32px; min-height: 32px; padding: 0 var(--gm-space-2); margin: 0;
  font-family: inherit; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.04em; line-height: 1;
  border: 1px solid transparent; background: transparent; border-radius: var(--gm-radius-sm, 4px);
}
.ns-lang__current { border-color: var(--gm-border-subtle); }
.ns-lang__current { color: var(--gm-text-primary); }
.gm .ns-lang__link { color: var(--gm-text-secondary); cursor: pointer; }
.gm .ns-lang__link:hover { color: var(--gm-accent); }

/* ---- Hover never moves anything ---------------------------------------------
   Not implemented here, and deliberately so: the `transform: translateY(-1px)` hover lifts were
   REMOVED from the vendored design-system CSS instead of being overridden
   (app/assets/stylesheets/gm/components/buttons.css). An override would have meant fighting the
   system's specificity forever and re-losing that fight with every new variant. spec/vendored_css_spec.rb
   fails if a re-copy from the style guide brings them back. */

/* ---- Login ------------------------------------------------------------------
   One action on the whole page, so it is centred in the viewport instead of stuck
   under the top edge. */

.ns-login {
  /* Fills <main>, then centres inside it — so "centred" stays centred whatever the window height. */
  position: relative;
  flex: 1 0 auto;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  gap: var(--gm-space-5); text-align: center;
}
.ns-login__title {
  display: flex; align-items: center; gap: var(--gm-space-3);
  margin: 0; font-size: 2rem; letter-spacing: -0.02em;
}
/* The sky sits behind the panel; the content keeps its own layer so the form is never under a
   canvas. pointer-events: none, so the one control on this page stays clickable. */
.ns-login__sky { position: absolute; inset: 0; pointer-events: none; z-index: 0; }
.ns-login > :not(.ns-login__sky) { position: relative; z-index: 1; }

.ns-login__form { display: grid; gap: var(--gm-space-3); justify-items: center; }
.ns-login__button { min-width: 18rem; min-height: 52px; }
/* Checked by default, so the row reads as a statement rather than a question. */
.ns-login__remember {
  display: inline-flex; align-items: center; gap: var(--gm-space-2);
  color: var(--gm-text-secondary); font-size: 0.875rem; cursor: pointer;
}
.ns-login__remember input { accent-color: var(--gm-accent-fill, var(--gm-accent)); }

@media (max-width: 40rem) {
  .ns-login__title { font-size: 1.625rem; }
  .ns-login__button { min-width: 0; width: 100%; }
}

/* ---- Ack page (the 03:00 screen) ------------------------------------------- */

.ns-ack { max-width: 34rem; margin: 0 auto; padding: var(--gm-space-5) var(--gm-space-4); }
.ns-ack__severity { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.ns-ack__title { font-size: 1.5rem; line-height: 1.25; margin: var(--gm-space-3) 0 var(--gm-space-4); }
/* One label column for every fact list in the app (--ns-label-w), so labels and values line up
   down the page instead of shifting per section. */
:root { --ns-label-w: 11rem; }
.ns-ack__meta, .ns-facts {
  display: grid; grid-template-columns: var(--ns-label-w) 1fr;
  gap: var(--gm-space-2) var(--gm-space-4);
  font-size: 0.9375rem; margin: 0 0 var(--gm-space-4);
}
.ns-ack__meta dt, .ns-facts dt { color: var(--gm-text-secondary); }
.ns-ack__meta dd, .ns-facts dd {
  margin: 0; display: flex; align-items: center; gap: var(--gm-space-2); flex-wrap: wrap;
}
/* Thumb-sized, full width, hard to miss half-awake. */
.ns-ack__button, .ns-ack__button button { width: 100%; min-height: 56px; font-size: 1.0625rem; }
.ns-ack__hint, .ns-ack__done { color: var(--gm-text-secondary); font-size: 0.875rem; }

/* ---- Page head --------------------------------------------------------------
   Title and its actions on one line, so the actions read as belonging to the title rather than
   floating in the gap below it. */

.ns-page-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: var(--gm-space-3);
  margin: var(--gm-space-5) 0 var(--gm-space-6);
}
.ns-page-head h1 { margin: 0; font-size: 1.625rem; line-height: 1.2; letter-spacing: -0.015em; }
.ns-page-head { margin-bottom: var(--gm-space-6); }
/* Title plus its state badge, on one baseline-centred row. */
.ns-page-head__titles { display: flex; flex-wrap: wrap; align-items: center; gap: var(--gm-space-3); }
/* The team page's head in the tint its alerts carry in the list (.ns-row--team), as a tile of
   its own so the colour has an edge to sit inside. */
.ns-page-head--team {
  padding: var(--gm-space-4);
  border: 1px solid var(--gm-border-subtle); border-radius: var(--gm-radius-md, 8px);
  background: var(--gm-bg-elevated, transparent) linear-gradient(var(--ns-team-color), var(--ns-team-color));
}

/* ---- Panels -------------------------------------------------------------------
   One frame for every group on every page: a head that says what the group is, a body that
   shows its state, and a foot that adds to it. Air alone did not separate groups — an add-form
   ran straight into the next heading and read as part of it. Panels are the style guide's web card
   surface (--gm-bg-elevated, subtle border, --gm-radius-lg) and are never nested: whatever sits
   inside drops its own frame. */

:root { --ns-panel-pad: var(--gm-space-6); }
@media (max-width: 40rem) { :root { --ns-panel-pad: var(--gm-space-4); } }

.ns-panel {
  margin: 0 0 var(--gm-space-6);
  background: var(--gm-bg-elevated);
  border: 1px solid var(--gm-border-subtle);
  border-radius: var(--gm-radius-lg, 12px);
  /* Clips the foot's tint and the rota's rows to the radius. min-width: 0 keeps a wide table's
     scroll container inside the grid track instead of stretching it. */
  overflow: hidden; min-width: 0;
}
.ns-panel:last-child { margin-bottom: 0; }
.ns-panel__head {
  display: grid; gap: var(--gm-space-1);
  padding: var(--gm-space-5) var(--ns-panel-pad) var(--gm-space-4);
}
.ns-panel__head h2 { margin: 0; font-size: 1.125rem; line-height: 1.3; letter-spacing: -0.01em; }
/* One line of purpose under the heading, at reading measure. */
.ns-panel__sub { margin: 0; max-width: 68ch; font-size: 0.875rem; color: var(--gm-text-secondary); }
.ns-panel__body { padding: 0 var(--ns-panel-pad) var(--gm-space-6); }
/* A body that follows a full-bleed element (the rota) starts with its own air. */
.ns-panel__body--ruled { padding-top: var(--gm-space-5); }
.ns-panel__body > :last-child { margin-bottom: 0; }
/* The foot is a tray: a step darker than the panel, so "add one" reads as a different act from
   "what is there", and the form's own dashed rule is no longer needed. */
.ns-panel__foot {
  padding: var(--gm-space-5) var(--ns-panel-pad) var(--gm-space-6);
  border-top: 1px solid var(--gm-border-subtle);
  background: color-mix(in srgb, var(--gm-bg-base) 55%, var(--gm-bg-elevated));
}
.ns-panel__foot-heading { margin: 0 0 var(--gm-space-3); font-size: 0.9375rem; font-weight: 600; }
.ns-panel__foot .ns-form-row { margin-top: 0; padding-top: 0; border-top: 0; }
/* The lead panel gets the larger heading; plumbing gets less voice. */
.ns-panel--lead .ns-panel__head h2 { font-size: 1.25rem; }
.ns-panel--quiet .ns-panel__head h2 { font-size: 1.0625rem; }
.ns-panel .ns-subhead { margin-bottom: var(--gm-space-3); }
.ns-panel .ns-empty--inline { margin: 0 0 var(--gm-space-4); }

/* ---- Glance strip ----------------------------------------------------------------
   Right now, before any configuration: who is on duty, who is next, what the first page does.
   Three equal cells because they are three answers of equal rank. */

.ns-glance {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0 0 var(--gm-space-8);
  border: 1px solid var(--gm-border-subtle); border-radius: var(--gm-radius-lg, 12px);
  overflow: hidden;
}
.ns-glance__item { margin: 0; padding: var(--gm-space-4) var(--gm-space-5); min-width: 0; }
.ns-glance__item + .ns-glance__item { border-left: 1px solid var(--gm-border-subtle); }
.ns-glance dt { font-size: 0.8125rem; color: var(--gm-text-secondary); margin-bottom: var(--gm-space-1); }
.ns-glance dd { margin: 0; }
.ns-glance__value { font-size: 1.0625rem; font-weight: 600; line-height: 1.35; }
.ns-glance__value--quiet { font-weight: 400; color: var(--gm-text-secondary); }
.ns-glance__detail { font-size: 0.875rem; color: var(--gm-text-secondary); font-variant-numeric: tabular-nums; }
/* A gap right now: the warning colour on the frame of this one cell, the words inside it. */
.ns-glance__item--warn { box-shadow: inset 0 3px 0 var(--ns-severity-warning); }
.ns-glance__item--warn .ns-glance__value { color: var(--ns-severity-warning); }
@media (max-width: 40rem) {
  .ns-glance { grid-template-columns: 1fr; }
  .ns-glance__item + .ns-glance__item { border-left: 0; border-top: 1px solid var(--gm-border-subtle); }
}

/* ---- Escalation ladder ------------------------------------------------------------
   A sequence on a rail. The offset leads each rung in its own column, a node sits on the rail,
   the target and its ordered channels follow, the row action stays quiet at the end. The bounded
   repeat and the give-up close the rail — hollow and square nodes, so the end of the ladder looks
   like an end rather than like the ladder simply stopping. */

.ns-ladder {
  list-style: none; margin: 0; padding: 0;
  --ns-ladder-when: 7.5rem;
  --ns-ladder-node: 1.5rem;
  /* One width for the actions of every rung, so "Edit" lines up whether or not "Remove" follows. */
  --ns-ladder-act: 12rem;
}
.ns-ladder__rung {
  position: relative;
  display: grid; grid-template-columns: var(--ns-ladder-when) var(--ns-ladder-node) minmax(0, 1fr) var(--ns-ladder-act);
  gap: 0 var(--gm-space-4); align-items: start;
  padding: var(--gm-space-3) 0;
}
/* The rail runs through the node column; the first rung starts it at its node, the last ends it. */
.ns-ladder__rung::before {
  content: ""; position: absolute; top: 0; bottom: 0;
  left: calc(var(--ns-ladder-when) + var(--gm-space-4) + var(--ns-ladder-node) / 2 - 1px);
  border-left: 2px solid var(--gm-border-default);
}
.ns-ladder__rung:first-child::before { top: 1.45rem; }
.ns-ladder__rung:last-child::before { bottom: calc(100% - 1.45rem); }
/* From the repeat on, the rail is dashed: what follows is not another rung, it is the loop. */
.ns-ladder__rung--repeat::before, .ns-ladder__rung--end::before { border-left-style: dashed; }

.ns-ladder__when {
  padding-top: 0.2rem; text-align: right;
  font-size: 1rem; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap;
  color: var(--gm-text-primary);
}
.ns-ladder__node {
  position: relative; z-index: 1; justify-self: center; margin-top: 0.55rem;
  width: 0.875rem; height: 0.875rem; border-radius: 50%;
  background: var(--gm-accent); box-shadow: 0 0 0 4px var(--gm-bg-elevated);
}
.ns-ladder__what { display: grid; gap: var(--gm-space-2); }
.ns-ladder__target { margin: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 var(--gm-space-2); }
.ns-ladder__target strong { font-size: 1.0625rem; font-weight: 600; }
.ns-ladder__hint { font-size: 0.875rem; color: var(--gm-text-secondary); }
.ns-ladder__channels { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--gm-space-2); }
.ns-ladder__act { align-self: start; display: flex; gap: var(--gm-space-2); }
/* Each rung's Turbo Frame steps out of the box tree, so the rung's grid still sees its four cells. */
.ns-ladder__rung > turbo-frame { display: contents; }
/* A rung being edited: the form takes the target and action columns together. */
.ns-ladder__what--form { grid-column: 3 / -1; }
.ns-ladder__what--form .ns-form-row { margin-top: 0; padding-top: 0; border-top: 0; }
.ns-form-error { flex: 1 0 100%; margin: 0; color: var(--gm-danger); font-weight: 600; }
.ns-ladder__note { margin: 0; padding-top: 0.2rem; max-width: 62ch; font-size: 0.9375rem; color: var(--gm-text-secondary); }

/* The closing rungs speak quieter: the offset column names the phase, not a time. */
.ns-ladder__rung--repeat .ns-ladder__when, .ns-ladder__rung--end .ns-ladder__when {
  font-size: 0.875rem; font-weight: 500; color: var(--gm-text-secondary);
}
.ns-ladder__rung--repeat .ns-ladder__node {
  background: var(--gm-bg-elevated); box-shadow: inset 0 0 0 2px var(--gm-accent), 0 0 0 4px var(--gm-bg-elevated);
}
.ns-ladder__rung--end .ns-ladder__node {
  border-radius: 2px; background: var(--gm-text-secondary);
}

/* A channel in its place in the order: the number is the priority the sender walks. */
.ns-chip {
  display: inline-flex; align-items: center; gap: var(--gm-space-2);
  min-height: 28px; padding: 0 var(--gm-space-3) 0 4px;
  border: 1px solid var(--gm-border-default); border-radius: var(--gm-radius-pill, 999px);
  font-size: 0.875rem; line-height: 1;
}
.ns-chip__n {
  display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%;
  background: rgba(135, 215, 182, 0.18); color: var(--gm-text-primary);
  font-size: 0.75rem; font-weight: 700; font-variant-numeric: tabular-nums;
}

@media (max-width: 40rem) {
  /* Offset above the content on a phone; the rail moves to the left edge. */
  .ns-ladder { --ns-ladder-when: 0rem; --ns-ladder-node: 1rem; }
  .ns-ladder__rung { grid-template-columns: var(--ns-ladder-node) minmax(0, 1fr) auto; gap: var(--gm-space-1) var(--gm-space-3); }
  .ns-ladder__rung::before { left: calc(var(--ns-ladder-node) / 2 - 1px); }
  .ns-ladder__when { grid-column: 2; grid-row: 1; text-align: left; padding-top: 0.1rem; }
  .ns-ladder__node { grid-column: 1; grid-row: 1; margin-top: 0.4rem; }
  .ns-ladder__what { grid-column: 2 / -1; }
  .ns-ladder__act { grid-column: 3; grid-row: 1; }
  .ns-ladder__what--form { grid-column: 2 / -1; }
}

/* ---- Small form and table pieces ------------------------------------------------ */

/* Example text in an empty field must not pass for a filled-in value: the styleguide's muted text
   is a bright mint on the deep green, nearly as loud as an entry. Dimmed and slanted, it reads as
   "for instance". The accessibility mode keeps the full strength. */
.gm input::placeholder, .gm textarea::placeholder { opacity: 0.55; font-style: italic; }
[data-mode="accessible"] .gm input::placeholder, [data-mode="accessible"] .gm textarea::placeholder { opacity: 1; }

/* Channel checkboxes as toggle chips: the box stays (keyboard, screen readers), the chip shows
   the state as a filled outline too, so the chosen set reads at a glance. */
.ns-fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
/* Five chips get a row of their own: beside the other fields they wrapped to two lines and pulled
   every label out of line. The submit then closes the form on the line below, where it reads as
   the end of the form rather than as a sixth field. */
.ns-form-row .ns-fieldset { flex: 1 0 100%; max-width: none; }
.ns-fieldset legend { padding: 0; }
.ns-check-chip {
  display: inline-flex; align-items: center; gap: var(--gm-space-2);
  min-height: 44px; padding: 0 var(--gm-space-3);
  border: 1px solid var(--gm-border-subtle); border-radius: var(--gm-radius-md, 8px);
  font-size: 0.875rem; color: var(--gm-text-secondary); cursor: pointer;
}
.ns-check-chip:has(input:checked) {
  border-color: var(--gm-accent); color: var(--gm-text-primary); background: rgba(135, 215, 182, 0.12);
}
.ns-check-chip:has(input:focus-visible) { outline: 2px solid var(--gm-accent); outline-offset: 1px; }
.ns-form-row .ns-check-chip { display: inline-flex; margin: 0; font-size: 0.875rem; color: var(--gm-text-secondary); }
.ns-form-row .ns-check-chip:has(input:checked) { color: var(--gm-text-primary); }
.ns-form-row .ns-check-chip input { height: auto; min-height: 0; }

/* Folded history: a quiet summary line that says how much is inside. */
.ns-disclosure { margin-top: var(--gm-space-5); }
.ns-disclosure > summary {
  display: inline-flex; align-items: center; gap: var(--gm-space-2); min-height: 44px;
  cursor: pointer; color: var(--gm-text-secondary); font-size: 0.9375rem; font-weight: 500;
  list-style: none;
}
.ns-disclosure > summary::-webkit-details-marker { display: none; }
.ns-disclosure > summary::before {
  content: ""; width: 0.45rem; height: 0.45rem; margin-right: var(--gm-space-1);
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  rotate: -45deg; transition: rotate var(--gm-duration-base, 160ms) var(--gm-ease-out, ease-out);
}
.ns-disclosure[open] > summary::before { rotate: 45deg; }
.ns-disclosure > summary:hover { color: var(--gm-text-primary); }
@media (prefers-reduced-motion: reduce) { .ns-disclosure > summary::before { transition: none; } }

/* Members: one row per person, the state badge beside the name, Remove quiet at the row's end. */
.ns-members { list-style: none; margin: 0; padding: 0; }
.ns-members__row {
  display: flex; align-items: center; gap: var(--gm-space-2) var(--gm-space-3);
  min-height: 48px; border-bottom: 1px solid var(--gm-border-subtle);
}
.ns-members__row:last-child { border-bottom: 0; }
.ns-members__name { font-weight: 500; }
.ns-members__act { margin: 0 0 0 auto; }

.ns-cell-name { display: inline-flex; align-items: center; gap: var(--gm-space-2); }

/* Good states get a badge too, in the success colour — a row of states where only the bad ones
   are marked makes "fine" look like "unknown". */
.ns-badge--ok { color: var(--gm-success); }
.ns-delivery--delivered { color: var(--gm-success); }
.ns-delivery--failed    { color: var(--gm-danger); }
.ns-delivery--skipped   { color: var(--ns-severity-warning); }
.ns-delivery--pending   { color: var(--gm-text-secondary); }

/* ---- Alert detail layout ----------------------------------------------------------
   Deliveries and timeline in the main column, reference facts in an aside. On a phone the facts
   come first (DOM order), four short lines before the long lists. */

.ns-detail__grid { display: grid; gap: var(--gm-space-6); align-items: start; }
.ns-detail__main { min-width: 0; }
/* The grid gap separates the facts from the main column; a panel margin on top doubled it. */
.ns-detail__facts { margin: 0; }
@media (min-width: 62rem) {
  .ns-detail__grid { grid-template-columns: minmax(0, 1fr) 18rem; }
  .ns-detail__facts { grid-column: 2; grid-row: 1; }
  .ns-detail__main { grid-column: 1; grid-row: 1; }
}

/* On the team list the person on duty is the lead fact, so it gets the primary colour. */
.ns-card-row__duty { color: var(--gm-text-primary); }

/* ---- Sections --------------------------------------------------------------- */

/* One rhythm for the whole page: equal air between sections, a tight bond between a
   heading and the thing it labels. Uneven gaps are most of what reads as "noise". */
.ns-section { margin: 0 0 var(--gm-space-7, 3rem); }
/* The bottom margin above already separates sections; adding a top margin as well stacked them to
   six rem of dead air. Only the cases that genuinely lacked air get it: a section following the
   page head, or following a row of buttons. */
.ns-page-head + .ns-section { margin-top: var(--gm-space-5); }
.ns-detail__actions + .ns-section { margin-top: var(--gm-space-6); }
.ns-section > h2 {
  font-size: 0.8125rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--gm-text-secondary);
  margin: 0 0 var(--gm-space-3);
}

/* ---- Action rows ------------------------------------------------------------
   Rails' button_to renders a <form>, which is block-level — that is why page actions
   stacked instead of sitting side by side. One row, one gap, forms stripped of margin. */

.ns-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--gm-space-2); }
.ns-actions form { margin: 0; }
.ns-actions--end { justify-content: flex-end; }
/* Inside a table cell the actions never wrap: a second line doubles the row height and breaks
   the horizontal rhythm of the whole table. The cell scrolls with the table instead. */
.ns-cell-actions .ns-actions { flex-wrap: nowrap; justify-content: flex-end; }

/* Row-level actions are secondary by definition: they belong to one line of a table, not to
   the page. Full-size buttons in every row made each row 60px tall and gave a "Remove" the
   same visual weight as the primary action. Quiet text controls instead — scoped with .gm to
   win against the style guide's own `.gm .gm-web-btn`. */
.gm .ns-btn-quiet {
  min-height: 32px; height: auto; padding: 0 var(--gm-space-2);
  background: transparent; border-color: transparent;
  color: var(--gm-text-secondary); font-size: 0.8125rem; font-weight: 500;
}
.gm .ns-btn-quiet:hover { color: var(--gm-text-primary); border-color: var(--gm-border-subtle); }

/* ---- Forms ------------------------------------------------------------------
   The style guide styles text/number/url/select but not the date-time inputs, so those
   rendered as raw browser widgets — white boxes in a dark UI. Same treatment here, from the
   same tokens. (Worth upstreaming; noted in TODO.md.) */

.gm input[type="datetime-local"],
.gm input[type="date"],
.gm input[type="time"] {
  font: inherit; color: var(--gm-text-primary);
  background: var(--gm-bg-elevated, transparent);
  border: 1px solid var(--gm-border-subtle); border-radius: var(--gm-radius-sm, 4px);
  padding: var(--gm-space-2) var(--gm-space-3);
  min-height: 40px;
}
.gm input[type="datetime-local"]:focus,
.gm input[type="date"]:focus,
.gm input[type="time"]:focus { outline: 2px solid var(--gm-accent); outline-offset: 1px; }
/* The native calendar glyph is near-black on our dark surface without this. */
.gm input[type="datetime-local"]::-webkit-calendar-picker-indicator,
.gm input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(1) opacity(0.6); }

/* An add-row form: labels on one line, controls on the next, everything sharing both.
   Replaces the old flex row, where a five-line checkbox stack dragged the other labels out
   of alignment. */
.ns-form-row {
  display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--gm-space-4) var(--gm-space-3);
  margin-top: var(--gm-space-4); padding-top: var(--gm-space-4);
  border-top: 1px dashed var(--gm-border-subtle);
}
.ns-form-row .gm-field { margin: 0; }
/* Top-aligned since fields carry hints of different lengths; the submit drops by one label line
   (--ns-label-line) so it still sits level with the controls. */
:root { --ns-label-line: calc(0.75rem * 1.5 + var(--gm-space-1) * 2); }
.ns-form-row > input[type="submit"], .ns-form-row > .gm-web-btn { margin-top: var(--ns-label-line); }
/* Save and Cancel on a line of their own, under fields that end the row: no label to level with,
   so no drop — and both buttons in one box, so they share a baseline. */
.ns-form-row > .ns-form-row__actions { flex: 1 0 100%; }
/* A hint wraps to its field's width instead of widening it: inline-size containment gives the
   paragraph no intrinsic width of its own. Fields that carry one get enough room to be read. */
.ns-form-row .ns-field-hint { margin: 0; contain: inline-size; }
.ns-form-row .gm-field:has(> .ns-field-hint) { flex: 0 1 15rem; }
.ns-form-row .ns-form-row__grow:has(> .ns-field-hint) { flex: 1 1 15rem; }
.ns-form-row .ns-fieldset:has(> .ns-field-hint) { flex: 1 0 100%; }
/* After a full-row fieldset the submit starts its own line and needs no label offset. */
.ns-form-row > .ns-fieldset + input[type="submit"] { margin-top: 0; }
.ns-form-row .gm-field:has(> .ns-field-hint) select,
.ns-form-row .gm-field:has(> .ns-field-hint) input:not([type="checkbox"]) { width: 100%; min-width: 0; }
/* Add forms start closed, inside their panel's foot: the page reads as configuration, not as four
   open forms. The foot tray already separates list and action, so the disclosure needs no rule of
   its own — its summary is the foot's heading, with a chevron that says it opens. */
.ns-add > summary {
  display: inline-flex; align-items: center; gap: var(--gm-space-2);
  min-height: 44px; margin: calc(var(--gm-space-3) * -1) 0; /* a thumb-sized target, same footprint */
  width: fit-content; cursor: pointer; list-style: none;
}
.ns-add > summary::-webkit-details-marker { display: none; }
.ns-add > summary::before {
  content: ""; width: 0.45rem; height: 0.45rem; margin-right: var(--gm-space-1);
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  rotate: -45deg; transition: rotate var(--gm-duration-base, 160ms) var(--gm-ease-out, ease-out);
}
.ns-add[open] > summary::before { rotate: 45deg; }
.ns-add > summary:hover { color: var(--gm-accent); }
@media (prefers-reduced-motion: reduce) { .ns-add > summary::before { transition: none; } }
.ns-add > .ns-form-row { margin-top: var(--gm-space-4); padding-top: 0; border-top: 0; }
.ns-panel__foot:has(.ns-add:not([open])) { padding-bottom: var(--gm-space-5); }
.ns-form-row .gm-field-label,
.ns-form-row label { display: block; margin-bottom: var(--gm-space-1);
  font-size: 0.75rem; color: var(--gm-text-secondary); }
/* Same box height for every control, borders included — the labels sit on top of them, so a
   4px difference in height is a 4px difference in label baseline. 44px is the design system's
   own control height; forcing a smaller box clipped the select's descenders. */
.ns-form-row input, .ns-form-row select, .ns-form-row .gm-web-btn {
  height: 44px; min-height: 44px; padding-top: 0; padding-bottom: 0; box-sizing: border-box;
}
/* Selects size to their longest option instead of stretching to 100% of the row. */
.ns-form-row select { width: auto; min-width: 13rem; padding-inline: var(--gm-space-3); }
/* A minute count needs a few characters, not a third of the row — but enough that its label
   fits above it without dictating the column width. */
.ns-form-row input[type="number"] { width: 8rem; }
.ns-form-row .gm-field { gap: var(--gm-space-1); }
.ns-form-row__grow { flex: 1 1 12rem; max-width: 24rem; }
/* One explanatory line for the whole row, so no single label has to carry it. */
.ns-form-row__hint {
  flex: 1 0 100%; margin: 0; font-size: 0.75rem; color: var(--gm-text-secondary);
}

/* Checkboxes in a row, each label inline with its box — as a column it was taller than every
   other control and broke the row. */
.ns-checks { display: flex; flex-wrap: wrap; gap: var(--gm-space-1) var(--gm-space-3); }
.ns-checks label {
  display: inline-flex; align-items: center; gap: var(--gm-space-1);
  margin: 0; min-height: 40px;
  font-size: 0.875rem; color: var(--gm-text-primary);
}
.ns-checks input { margin: 0; accent-color: var(--gm-accent-fill, var(--gm-accent)); }
.ns-token {
  font-family: var(--gm-font-mono, ui-monospace, monospace); word-break: break-all;
  padding: var(--gm-space-3); border: 1px dashed var(--gm-accent); border-radius: var(--gm-radius-sm, 4px);
}
.ns-empty { color: var(--gm-text-secondary); padding: var(--gm-space-5) 0; }

/* ---- Footer ----------------------------------------------------------------- */

.ns-footer {
  /* auto is what pins it down: it absorbs the leftover space above the footer. */
  margin-top: auto;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: var(--gm-space-3);
  /* Extra bottom room so a flash bar — which is fixed to the window — cannot sit on top of
     the colophon. */
  padding: var(--gm-space-6, 2.5rem) 0 var(--gm-space-7, 3rem);
  border-top: 1px solid var(--gm-border-subtle);
}
.ns-colophon { color: var(--gm-text-secondary); font-size: 0.75rem; }

/* ---- Record list (teams) -----------------------------------------------------
   Its own two-column shape rather than the alert grid: identity on the left, counts on the
   right, and the whole row is the target — a name-sized click area is a needless miss at 03:00. */

.ns-cards { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--gm-space-2); }
.ns-card-row {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: var(--gm-space-2) var(--gm-space-4);
  padding: var(--gm-space-3) var(--gm-space-4);
  border: 1px solid var(--gm-border-subtle); border-radius: var(--gm-radius-md, 8px);
  background: var(--gm-bg-elevated, transparent);
}
/* The team's tint on /teams, as on its alerts (.ns-row--team). Below .ns-card-row on purpose: that
   rule's background shorthand resets background-image, and above it the tint is silently dropped. */
.ns-card-row--team { background-image: linear-gradient(var(--ns-team-color), var(--ns-team-color)); }
/* What sits on a team tint. The tints are strong and of every hue (Team#color), so the green
   link colour and the coloured badge outlines that read on the canvas vanish on some of them —
   orange "error" on terracotta, gold "not configured" on gold. Names go white; badges and buttons
   carry a plate of the canvas, so each keeps the contrast it was designed with. `.gm` in front
   because the design system's own link and button rules are scoped under it and would win. */
.gm .ns-row--team .ns-row__link, .gm .ns-card-row--team .ns-card-row__name { color: var(--gm-text-primary); }
.ns-row--team .ns-badge, .ns-card-row--team .ns-badge, .ns-page-head--team .ns-badge { background: var(--gm-bg-base); }
.gm .ns-page-head--team .gm-web-btn-secondary { background: var(--gm-bg-base); }
.ns-card-row:hover { border-color: var(--gm-accent); }
.ns-card-row__name {
  display: inline-flex; align-items: center; gap: var(--gm-space-2);
  font-weight: 600; color: inherit; text-decoration: none;
}
.ns-card-row__name::after { content: ""; position: absolute; inset: 0; } /* whole row clickable */
.ns-card-row { position: relative; }
.ns-card-row__meta {
  display: flex; flex-wrap: wrap; gap: var(--gm-space-4);
  color: var(--gm-text-secondary); font-size: 0.8125rem; font-variant-numeric: tabular-nums;
}

/* ---- Single-record form ------------------------------------------------------
   A field as wide as the page is unreadable and implies the content should be long. One
   column at a comfortable measure, consistent vertical rhythm, and an explicit way out. */

.ns-form { max-width: 34rem; }
.ns-form .gm-field { margin-bottom: var(--gm-space-5); gap: var(--gm-space-1); }
.ns-form input, .ns-form select, .ns-form textarea { width: 100%; }
/* A submit is not a field: full column width made "Save" look like an input. */
.ns-form input[type="submit"], .ns-form__actions input[type="submit"] { width: auto; }
.ns-form__hint {
  margin: var(--gm-space-1) 0 0; font-size: 0.75rem; color: var(--gm-text-secondary);
}
.ns-form__actions {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--gm-space-3);
  margin-top: var(--gm-space-5);
}
.ns-form__actions form { margin: 0; }

/* ---- Profile layout ----------------------------------------------------------
   Two groups, not five equal slabs: the channels (the only thing here with unfinished work) and the
   account reference beside them. Rhythm is deliberate — tight inside a channel, generous between
   groups, and more space above a heading than below it, so the eye lands on group boundaries.

   Sequence on narrow screens is the task order: channels first, account after. */

.ns-profile { display: grid; gap: var(--gm-space-5); align-items: start; }
@media (min-width: 62rem) {
  .ns-profile {
    /* The task column gets the width; the aside gets just enough to stay readable. */
    grid-template-columns: minmax(0, 1.7fr) minmax(17rem, 0.8fr);
    gap: var(--gm-space-5);
  }
}
/* min-width: 0 is load-bearing: without it the 60-character connection link stretches this grid
   track and pushes the aside off the viewport. */
.ns-profile__main { min-width: 0; }
/* 65–75ch measure, so the explanation reads as prose rather than as a banner. */
.ns-lede { margin: 0 0 var(--gm-space-6); max-width: 68ch; color: var(--gm-text-secondary); }
.ns-lede--flush { margin: 0; }

/* One hairline per channel, no card: proximity carries the grouping, the rule only marks where one
   channel ends. Cards here would turn three unequal things into three equal-looking boxes. */
.ns-channel { padding: var(--gm-space-6) 0 var(--gm-space-5); border-top: 1px solid var(--gm-border-subtle); }
.ns-channel:first-of-type { padding-top: 0; border-top: 0; }
.ns-channel:last-of-type { padding-bottom: 0; }
.ns-channel__head {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--gm-space-3);
  margin-bottom: var(--gm-space-3);
}
.ns-channel__head h3 { margin: 0; font-size: 1rem; letter-spacing: -0.005em; }
.ns-channel > p { margin: 0 0 var(--gm-space-2); max-width: 68ch; }
.ns-channel .ns-steps { margin-bottom: var(--gm-space-5); }
.ns-channel .gm-alert { margin-bottom: var(--gm-space-4); }

/* The aside is two groups under the same heading level as the channels: settings, then account.
   Tight inside a group, a rule and generous space between them. */
.ns-profile__aside { display: grid; gap: var(--gm-space-5); align-content: start; }
.ns-aside__group { margin: 0; }
.ns-aside__body { display: grid; gap: var(--gm-space-6); align-content: start; }
.ns-subhead {
  margin: 0 0 var(--gm-space-2);
  font-size: 0.9375rem; font-weight: 600; color: var(--gm-text-primary);
}
.ns-setting .ns-form__hint { margin-top: var(--gm-space-2); }
/* Label above value: at aside width a 11rem label column would leave no room for the value. */
.ns-facts--stacked { grid-template-columns: 1fr; gap: 0; font-size: 0.9375rem; }
.ns-facts--stacked dt { margin-top: var(--gm-space-2); font-size: 0.8125rem; }
.ns-facts--stacked dt:first-child { margin-top: 0; }
.ns-facts--stacked dd { word-break: break-word; }

/* A single-field form does not need a column of its own. */
.ns-form--inline {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--gm-space-3); max-width: none;
}
/* Grows into the row but keeps Save beside it, down to phone and aside width. */
.ns-form--inline .gm-field { margin: 0; flex: 1 1 12rem; max-width: 22rem; }
.ns-form--inline .gm-web-btn { height: 44px; }

/* ---- Telegram binding --------------------------------------------------------
   The one page where the content has to leave the screen: the link belongs on the phone in
   someone's pocket. QR beside the link, both given room. */

.ns-telegram-bind {
  display: flex; flex-wrap: wrap; gap: var(--gm-space-5);
  align-items: flex-start; margin-top: var(--gm-space-4);
}
.ns-telegram-bind__link { flex: 1 1 22rem; min-width: 0; }
.ns-qr { margin: 0; flex: 0 0 auto; text-align: center; }
.ns-qr svg { width: 168px; height: 168px; display: block; border-radius: var(--gm-radius-sm, 4px); }
.ns-qr figcaption {
  margin-top: var(--gm-space-2); font-size: 0.75rem; color: var(--gm-text-secondary);
}
/* Numbered because it is a sequence someone follows on two devices. */
.ns-steps { margin: 0 0 var(--gm-space-4); padding-left: 1.4em; display: grid; gap: var(--gm-space-2); }
.ns-steps li { padding-left: var(--gm-space-1); }
/* The link stays selectable and wraps instead of overflowing — it is 60+ characters. */
.ns-token__link { color: var(--gm-accent); word-break: break-all; }

/* The style guide's alert is a row container; our alert boxes carry a title, a body and a hint,
   which ended up as three columns reading like a sidebar. One column, normal flow. */
.gm .gm-alert { display: block; }
.gm .gm-alert > * + * { margin-top: var(--gm-space-2); }
.gm .gm-alert p { margin: 0; }

/* ---- Small pieces ----------------------------------------------------------- */

/* Names as a wrapped row of their own, each with room to carry a state badge. */
.ns-people { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--gm-space-2) var(--gm-space-4); }
.ns-people li { display: inline-flex; align-items: center; gap: var(--gm-space-2); }

/* Timestamps and identifiers: tabular so columns of them line up character by character. */
.ns-time { font-variant-numeric: tabular-nums; color: var(--gm-text-secondary); white-space: nowrap; }
.ns-table td.ns-time, .ns-table th.ns-time { text-align: right; }
.ns-code {
  font-family: var(--gm-font-mono, ui-monospace, monospace); font-size: 0.8125rem;
  color: var(--gm-text-secondary);
}

/* The one-time token stays put and stays legible — it exists to be copied. */
/* Under its source row, spanning the table: the cell drops the table's nowrap so the URL wraps
   instead of pushing the table sideways. */
.ns-table .ns-token-row td { white-space: normal; padding: 0 0 var(--gm-space-4); border-bottom: 1px solid var(--gm-border-subtle); }
/* On a phone the table scrolls sideways inside its container and is wider than the screen. The
   reveal takes the container's visible width (cqi) and sticks to its left edge, so the URL and the
   copy buttons stay on screen instead of scrolling off with the columns. */
.ns-scroll-x:has(.ns-token-reveal) { container-type: inline-size; }
.ns-token-reveal { margin: 0; position: sticky; left: 0; width: 100cqi; box-sizing: border-box; }
.ns-token-reveal__line {
  display: grid; grid-template-columns: 5rem minmax(0, 1fr) 10rem; align-items: center;
  gap: var(--gm-space-2) var(--gm-space-3);
}
.ns-token-reveal__label { font-size: 0.8125rem; color: var(--gm-text-secondary); }
/* One button column for both lines, so the two values end at the same edge. */
.ns-token-reveal__line .gm-web-btn { width: 100%; }
.ns-token-reveal .ns-token { margin: 0; padding: var(--gm-space-2) var(--gm-space-3); font-size: 0.8125rem; }
@media (max-width: 40rem) {
  .ns-token-reveal__line { grid-template-columns: 1fr; }
}

/* Available to screen readers, invisible on screen — for the header of an action column, which
   needs no visible label but must not be an empty cell. */
.ns-visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* ---- Flashes ---------------------------------------------------------------
   A fixed bar at the bottom, like rollmonkey and deployed: it can auto-dismiss
   without shifting the layout, and on a phone it sits where the thumb already is.
   Colours are chosen apart from the severity palette above, so a green flash can
   never be mistaken for an alert severity. */

.ns-flash-region {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; flex-direction: column;
}
.ns-flash {
  padding: var(--gm-space-3) var(--gm-space-4);
  text-align: center; font-size: 0.875rem; font-weight: 600;
  color: #fff; cursor: pointer;
  animation: ns-flash-in 260ms cubic-bezier(0.22, 1, 0.36, 1);
}
.ns-flash--notice { background: #256029; }
.ns-flash--alert  { background: #a02622; }
@keyframes ns-flash-in { from { transform: translateY(100%); } to { transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { .ns-flash { animation: none; } }

@media (max-width: 40rem) {
  /* A fixed label column would take nearly half a phone's width; stack instead. */
  .ns-ack__meta, .ns-facts { grid-template-columns: 1fr; gap: 0; }
  .ns-ack__meta dt, .ns-facts dt { margin-top: var(--gm-space-3); font-size: 0.8125rem; }
  .ns-ack__meta dt:first-child, .ns-facts dt:first-child { margin-top: 0; }
  /* Stacked, left-aligned: a wrapped nav pushed to the right edge reads as debris. */
  .ns-header { justify-content: flex-start; row-gap: 0; }
  .ns-row { grid-template-columns: auto auto 1fr; }
  .ns-row__check { grid-row: 1 / span 3; }
  /* The rail moves to the left edge; time above the event. */
  .ns-timeline li { grid-template-columns: 1fr; gap: 0; padding-left: var(--gm-space-5); }
  .ns-timeline li::before { left: 3px; }
  .ns-timeline li::after { left: 0; }
  .ns-ack { padding: var(--gm-space-4) var(--gm-space-3); }
}

/* ---- Rota: who is on duty, as a picture -----------------------------------------
   Lifted from planner's board, minus what does not apply here: one lane per person, a track
   with a hairline per day, bars placed by percent of the window (nothing measured, nothing to
   drift), the current instant as a line through every row. On a phone the panel scrolls
   sideways inside .ns-scroll-x; the page never does. Colour and hatching are redundant cues —
   every gap and overlap also carries a title and is counted in the summary line above. */

.ns-rota-nav {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--gm-space-3) var(--gm-space-4);
  padding: 0 var(--ns-panel-pad) var(--gm-space-3);
}
/* The range is the toolbar's title: which days am I looking at. */
.ns-rota-nav__range { font-weight: 600; font-variant-numeric: tabular-nums; }
.ns-rota-nav__window { margin-left: auto; }

/* A segmented control: one outlined group, items divided by hairlines, the current one filled.
   Reads as one control with parts, where loose quiet buttons read as three unrelated links. */
.ns-seg {
  display: inline-flex; align-items: stretch;
  border: 1px solid var(--gm-border-default); border-radius: var(--gm-radius-md, 8px);
  overflow: hidden;
}
.ns-seg__item {
  display: inline-flex; align-items: center; min-height: 36px; padding: 0 var(--gm-space-3);
  color: var(--gm-text-secondary); text-decoration: none; font-size: 0.875rem; white-space: nowrap;
}
.ns-seg__item + .ns-seg__item { border-left: 1px solid var(--gm-border-default); }
.ns-seg__item:hover { color: var(--gm-text-primary); background: rgba(255, 255, 255, 0.04); }
.ns-seg__item[aria-current="page"] {
  color: var(--gm-text-primary); font-weight: 600; background: rgba(135, 215, 182, 0.16);
}
.ns-seg__item:focus-visible { outline: 2px solid var(--gm-accent); outline-offset: -2px; }

.ns-rota__summary {
  margin: 0; padding: 0 var(--ns-panel-pad) var(--gm-space-4);
  font-size: 0.9375rem; color: var(--gm-text-secondary);
}
/* A gap in the window is the one verdict worth colour — the words already say it. */
.ns-rota__summary--warn { color: var(--gm-text-primary); }
.ns-rota__summary--warn::before {
  content: ""; display: inline-block; width: 0.625rem; height: 0.625rem; margin-right: var(--gm-space-2);
  border-radius: 2px; vertical-align: 0.05em;
  background: repeating-linear-gradient(135deg, var(--ns-severity-warning) 0 2px, transparent 2px 4px);
  box-shadow: inset 0 0 0 1px var(--ns-severity-warning);
}

/* Inside its panel the rota has no frame of its own — a box in a box — and runs edge to edge,
   ruled off above and below. */
.ns-rota-frame { border-top: 1px solid var(--gm-border-subtle); border-bottom: 1px solid var(--gm-border-subtle); }
.ns-rota {
  /* Fourteen day columns have a floor; below it the panel scrolls, the page does not. */
  min-width: 44rem;
  font-size: 0.875rem;
}
.ns-rota__row { display: flex; align-items: stretch; min-height: 2.75rem; border-top: 1px solid var(--gm-border-subtle); }
.ns-rota__row--head { min-height: 1.75rem; border-top: 0; }
.ns-rota__row--coverage { min-height: 2.75rem; }
.ns-rota__label {
  flex: 0 0 12.5rem; min-width: 0;
  display: flex; flex-direction: column; justify-content: center; gap: 1px;
  padding: 0 var(--gm-space-3) 0 var(--ns-panel-pad);
  border-right: 1px solid var(--gm-border-subtle);
  color: var(--gm-text-primary);
}
.ns-rota__row--coverage .ns-rota__label {
  font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--gm-text-secondary);
}
.ns-rota__name { max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 600; }
/* A second, small line under the name — a badge beside it did not fit the label column. */
.ns-rota__flag { font-size: 0.75rem; color: var(--ns-severity-warning); line-height: 1.2; }
/* Nobody in this window: the name steps back so the people on duty lead. */
.ns-rota__lane[data-idle="true"] .ns-rota__name { font-weight: 500; color: var(--gm-text-secondary); }
/* The row under the pointer answers, so a bar can be traced back to its name across a wide track.
   A wash only — hover never moves anything. */
.ns-rota__lane:hover { background: rgba(255, 255, 255, 0.04); }
.ns-rota__track {
  flex: 1; position: relative; min-width: 0;
  /* One hairline per day column, drawn by the background so it costs no elements. */
  background-image: linear-gradient(90deg, var(--gm-border-subtle) 1px, transparent 1px);
  background-size: calc(100% / var(--ns-rota-days, 14)) 100%;
}
.ns-rota__track--head { display: flex; background: none; }
/* Weekday small over the date: the date is what someone scans for, so it carries the size. */
.ns-rota__day {
  flex: 1; min-width: 0; padding: var(--gm-space-2) 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.15;
  text-align: center; overflow: hidden; white-space: nowrap;
  color: var(--gm-text-secondary);
}
.ns-rota__dow { font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.ns-rota__date { font-size: 0.8125rem; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--gm-text-primary); }
.ns-rota__row--head { min-height: 3rem; }
.ns-rota__day--today { box-shadow: inset 0 -2px 0 var(--ns-moonlight); }
.ns-rota__day--today .ns-rota__dow, .ns-rota__day--today .ns-rota__date { color: var(--ns-moonlight); }
/* Today, tinted down every row — the column the eye returns to. */
.ns-rota__todaycol { position: absolute; top: 0; bottom: 0; pointer-events: none; background: rgba(255, 212, 92, 0.05); }
/* Weekends are what an on-call rota is about, so they are visible in every row, not only in
   the header. Under everything else. */
.ns-rota__day--weekend, .ns-rota__weekend { background: rgba(0, 0, 0, 0.18); }
.ns-rota__weekend { position: absolute; top: 0; bottom: 0; pointer-events: none; }

/* The current instant: a line through every row, named once in the header. */
.ns-rota__now {
  position: absolute; top: 0; bottom: 0; width: 0;
  border-left: 2px solid var(--ns-moonlight); pointer-events: none; z-index: 3;
}
/* Named once, on a plate at the top of the coverage row where the line enters the picture. */
.ns-rota__nowlabel {
  position: absolute; top: 2px; translate: -50% 0; z-index: 4;
  padding: 0 5px; border-radius: 3px; line-height: 1.4;
  font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  background: var(--ns-moonlight); color: #1a1400;
}

/* A shift. The bar's own text shows up only when the bar is wide enough to carry it; the title
   always has the full times. A bar cut by the window edge loses its rounding on that side, so it
   visibly runs on rather than ending. */
.ns-rota__bar {
  position: absolute; top: 8px; bottom: 8px; z-index: 1;
  display: flex; align-items: center; padding: 0 var(--gm-space-2);
  border-radius: var(--gm-radius-sm, 4px);
  background: var(--gm-accent-fill, var(--gm-accent)); color: var(--gm-text-inverse, #fff);
  font-size: 0.75rem; font-weight: 500; font-variant-numeric: tabular-nums;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14);
}
.ns-rota__bar--cut-left { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.ns-rota__bar--cut-right { border-top-right-radius: 0; border-bottom-right-radius: 0; }
/* The grab zones at a bar's ends. Inside the bar (it clips), wide enough for a mouse, marked by a
   grip line on hover — colour only, nothing moves (SPEC §6.3). Mouse and pen only, like drawing. */
.ns-rota__edge { position: absolute; top: 0; bottom: 0; width: 8px; cursor: ew-resize; touch-action: none; }
.ns-rota__edge--start { left: 0; }
.ns-rota__edge--end { right: 0; }
.ns-rota__edge::after {
  content: ""; position: absolute; top: 25%; bottom: 25%; left: 3px; width: 2px; border-radius: 1px;
  background: transparent;
}
.ns-rota__bar:hover .ns-rota__edge::after, .ns-rota__bar--resizing .ns-rota__edge::after { background: rgba(255, 255, 255, 0.55); }
.ns-rota__bar--resizing { z-index: 3; outline: 2px dashed var(--ns-moonlight); outline-offset: 1px; }
.ns-rota__bartext { overflow: hidden; text-overflow: ellipsis; }
/* While an edge is dragged: the times it will save, on a plate above the bar — the moonlight of
   the draft and the outline, so it reads as "not saved yet". Above the lane's top rule, over the
   row above, because inside the lane it would cover the bar it describes. */
.ns-rota__readout {
  position: absolute; top: -0.75rem; z-index: 4; pointer-events: none;
  padding: 1px 6px; border-radius: 3px; white-space: nowrap;
  font-size: 0.75rem; font-weight: 700; font-variant-numeric: tabular-nums;
  background: var(--ns-moonlight); color: #1a1400;
}

/* Coverage: how many people are on duty. Covered is quiet; a gap is hatched in the warning
   colour, an overlap tinted blue — and both say what they are, in the segment when it is wide
   enough and in the title always. */
.ns-rota__cover {
  position: absolute; top: 20px; bottom: 8px; z-index: 1;
  display: flex; align-items: center; justify-content: center;
  border-radius: 3px; overflow: hidden; white-space: nowrap;
  font-size: 0.625rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
}
.ns-rota__cover--ok { background: rgba(93, 202, 165, 0.28); }
.ns-rota__cover--gap {
  background: repeating-linear-gradient(135deg, var(--ns-severity-warning) 0 3px, transparent 3px 8px);
  box-shadow: inset 0 0 0 1px var(--ns-severity-warning);
  color: var(--gm-text-primary);
}
.ns-rota__cover--overlap {
  background: rgba(93, 185, 232, 0.35);
  box-shadow: inset 0 0 0 1px var(--gm-info, #5db9e8);
  color: var(--gm-text-primary);
}
/* The word sits on a small plate so it stays legible over the hatching. */
.ns-rota__cover--gap span, .ns-rota__cover--overlap span {
  padding: 0 var(--gm-space-1); border-radius: 2px; background: var(--gm-bg-elevated, #0a4a3c);
}
.ns-rota__empty { margin: 0; padding: var(--gm-space-4) var(--ns-panel-pad); color: var(--gm-text-secondary); }

/* Drawing. A member's lane takes a crosshair; the draft is an outline in moonlight — clearly not a
   saved shift — and carries its times until the form below confirms it. */
.ns-rota__track[data-rota-draw-target="track"] { cursor: crosshair; touch-action: pan-x pan-y; user-select: none; }
.ns-rota__draft {
  position: absolute; top: 6px; bottom: 6px; z-index: 2; pointer-events: none;
  display: flex; align-items: center; padding: 0 var(--gm-space-2); overflow: hidden; white-space: nowrap;
  border: 2px dashed var(--ns-moonlight); border-radius: var(--gm-radius-sm, 4px);
  background: rgba(255, 212, 92, 0.14); color: var(--ns-moonlight);
  font-size: 0.75rem; font-weight: 600; font-variant-numeric: tabular-nums;
}
.ns-rota__howto { margin-left: auto; font-style: italic; }
@media (hover: none) { .ns-rota__howto { display: none; } }

/* The key to the three marks, under the picture. */
.ns-rota__legend {
  list-style: none; margin: 0; padding: var(--gm-space-3) var(--ns-panel-pad);
  display: flex; flex-wrap: wrap; gap: var(--gm-space-2) var(--gm-space-5);
  font-size: 0.8125rem; color: var(--gm-text-secondary);
}
.ns-rota__legend li { display: inline-flex; align-items: center; gap: var(--gm-space-2); }
.ns-rota__swatch { width: 1.25rem; height: 0.75rem; border-radius: 3px; }
.ns-rota__swatch--shift { background: var(--gm-accent-fill, var(--gm-accent)); }
.ns-rota__swatch--gap {
  background: repeating-linear-gradient(135deg, var(--ns-severity-warning) 0 3px, transparent 3px 7px);
  box-shadow: inset 0 0 0 1px var(--ns-severity-warning);
}
.ns-rota__swatch--overlap { background: rgba(93, 185, 232, 0.35); box-shadow: inset 0 0 0 1px var(--gm-info, #5db9e8); }
.ns-rota__swatch--vacation {
  background: repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.16) 0 2px, transparent 2px 6px);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28);
}

/* Time off from go~vacation: a quiet band the whole height of the lane, under the shift bars. Not
   in the warning colour — being away is normal; a shift inside it is the problem, and that bar
   says so itself. */
.ns-rota__vacation {
  position: absolute; top: 2px; bottom: 2px; z-index: 0; pointer-events: none; overflow: hidden;
  border-radius: var(--gm-radius-sm, 4px);
  background: repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.10) 0 2px, transparent 2px 7px);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22);
}
/* A shift inside a vacation: the bar keeps its colour and gains a warning frame and a mark, so
   the fact does not rest on colour alone (the title and the summary say it in words). */
.ns-rota__bar--clash { box-shadow: inset 0 0 0 2px var(--ns-severity-warning); }
.ns-rota__bar--clash::before { content: "!"; margin-right: var(--gm-space-1); font-weight: 800; color: var(--ns-severity-warning); }

@media (max-width: 40rem) {
  /* The window picker under the arrows, not squeezed beside them. */
  .ns-rota-nav__window { margin-left: 0; }
  .ns-rota__label { flex-basis: 9rem; }
}
