/* The theme, in one place for all four pages.
 *
 * Every page carried an identical `:root` block, so a colour change meant four
 * edits and a theme was impossible. They now link this instead, and switching
 * is setting `data-theme` on <html> - which ui/theme.mjs and theme-boot.js do,
 * and persists.
 *
 * The variable NAMES are the contract. A theme may only re-point them; any
 * page rule that hardcodes a colour instead of using one of these will not
 * follow the theme, which is the single rule to keep when editing the pages.
 *
 * Typography is shared rather than themed: the scale below is what gives the
 * pages a consistent voice, and a theme that changed it would look like a
 * different product rather than the same one in different clothes.
 *
 * The values are Nordic's Blueprint Design System (Figma, "Blueprint Design
 * System UI Library"), read from its variables.
 */

/* GT Eesti Display, Nordic's typeface, under Nordic's web licence: the
   foundry's WOFF2 web files, served unmodified, as the licence requires.
   Blueprint sets everything in two cuts, Light and Regular, and no italics, so
   these are the only two files. A weight above 400 is not asked for anywhere
   in the chat page; the browser would synthesise it from Regular. `swap`
   shows the fallback sans until the file has loaded. */
@font-face { font-family: "GT Eesti Display"; font-weight: 300; font-style: normal;
             font-display: swap; src: url("assets/gt-eesti-display-light.woff2") format("woff2"); }
@font-face { font-family: "GT Eesti Display"; font-weight: 400; font-style: normal;
             font-display: swap; src: url("assets/gt-eesti-display-regular.woff2") format("woff2"); }
/* PragmataPro Regular, the code face Blueprint uses, from Nordic's design
   resources: the web file unmodified, as its licence requires, and only
   through @font-face. Not preloaded: at 1.9 MB it is fetched only when a page
   shows code. */
@font-face { font-family: "PragmataPro"; font-weight: 400; font-style: normal;
             font-display: swap; src: url("assets/pragmatapro-regular.woff2") format("woff2"); }

/* Version 1.010's contextual alternates rewrote technical text: "sht4x" became
   "sht4×", "MITM" "MI™" and "(1)" a circled digit. 2.000 does not, but keeps the
   feature, so it stays off: a later file must not bring the rewriting back.
   Important, because every `font:` shorthand in the pages would otherwise
   reset it to normal. */
*, *::before, *::after { font-variant-ligatures: no-contextual !important; }
/* Code and identifiers, in --mono: every ligature off as well, so "->", "!="
   and "//" read as typed. PragmataPro has no standard ligatures and its
   contextual alternates (which rewrite "MITM") are off above, so a --mono rule
   missing from this list still reads as typed. */
code, pre, kbd, samp, .pp-name, .pp-table thead th, .pcard[data-section="Pins"] .phint,
.pcount, .gs-meta, .gc-meta, .pin-bus, .pin-pad, .srow .sm,
.srow .bus, header .engine, .issue { font-variant-ligatures: none !important; }

:root {
  /* ── Type ── */
  /* Nordic's typefaces, served from ui/assets (the @font-face rules above). */
  --mono: "PragmataPro", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: "GT Eesti Display", "Segoe UI Variable Text", system-ui, -apple-system,
          "Segoe UI", Roboto, sans-serif;
  --serif: ui-serif, "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  /* The wordmark, separately themeable from body text, so a theme built on
     another face can say so without naming a face in `.brand h1`. */
  --display: var(--sans);
  --display-weight: var(--fw-regular);
  --display-track: 0;
  /* The type scale the owner approved on 12 Nov, on Blueprint's two weights
     and with letter-spacing 0 and no uppercase: one size and leading pair per
     role, in rem (1rem = 16px) so browser zoom and the user's font size apply.
     Light only from 15px up; everything smaller is Regular. Phones (below
     600px) step up, in the media rule after :root. */
  --fs-prose: .9375rem;  --lh-prose: 1.375rem;    /* 15/22: chat text, fields, dialog text */
  --fs-label: .875rem;   --lh-label: 1.1875rem;   /* 14/19: buttons, chips, rows */
  --fs-hint: .75rem;     --lh-hint: 1rem;         /* 12/16: hints, notes, badges */
  --fs-title: 1.375rem;  --lh-title: 1.8125rem;   /* 22/29: dialog titles */
  --fs-heading: 1rem;    --lh-heading: 1.3125rem; /* 16/21: headings in dialogs, the app name */
  --fs-code: .8125rem;   --lh-code: 1.1875rem;    /* 13/19: code and identifiers */
  --fw-light: 300; --fw-regular: 400;
  /* The roles as `font` values. */
  --font-h3: var(--fw-light) var(--fs-title)/var(--lh-title) var(--sans);
  --font-h5: var(--fw-regular) var(--fs-heading)/var(--lh-heading) var(--sans);
  --font-prose: var(--fw-light) var(--fs-prose)/var(--lh-prose) var(--sans);
  --font-body-lg: var(--fw-light) var(--fs-prose)/var(--lh-prose) var(--sans);
  --font-label-lg: var(--fw-regular) var(--fs-label)/var(--lh-label) var(--sans);
  --font-hint: var(--fw-regular) var(--fs-hint)/var(--lh-hint) var(--sans);
  --font-code: var(--fw-regular) var(--fs-code)/var(--lh-code) var(--mono);
  /* Blueprint's spacing scale (Semantic/Small-0,5 to Medium-2, then the larger
     Foundation steps). */
  --space-s05: 2px;
  --space-s1: 4px; --space-s2: 8px; --space-s3: 12px; --space-s4: 16px;
  --space-s5: 20px; --space-s6: 24px; --space-s7: 28px; --space-m1: 32px; --space-m2: 40px;
  --space-m3: 40px; --space-m4: 48px; --space-m5: 48px; --space-l1: 64px;
  --space-l2: 80px; --space-l3: 96px; --space-l4: 128px;
  /* Blueprint's corners (Corner Radius): controls and cards are square, an
     in-line notification is 4, a modal 8, a badge fully round. A chat bubble
     has no Blueprint component; it takes 4, a local exception. `--radius` is a
     card or control and `--radius-sm` something inline. */
  --radius: 0; --radius-sm: 0; --radius-pill: 999px; --radius-bubble: 4px;
  --radius-notice: 4px; --radius-modal: 8px;
  /* Border as one value, so a theme can change its WEIGHT and not just its
     colour. The reference design that prompted this is all hairlines. */
  --border: 1px solid var(--line);

  /* ── Nordic (the default, and for now the only theme) ──
     Blueprint's colour variables: white surfaces on Light Grey hairlines,
     Nordic Blue for primary actions and selection, Nordic Lake for links and
     secondary actions, Nordic Dark Grey for text, flat and square.
     Fill/Base and Background/Primary #ffffff (the page is white too),
     Fill/Neutral #f0f3f3, Border/Secondary #d9e1e2, Content/Primary #333f48,
     Content/Secondary #6f787e, Button/Fill/Primary-Default #00a2c6,
     Content/Supportive #0077c8, Button/Fill/Flat-Default-Hover #e5f1fa.
     --ok, --warn and --err are darker than Blueprint's status colours, which
     are badge fills and icons, so that they pass as text on white and on
     their own pale grounds. */
  --bg: #ffffff; --surface: #ffffff; --surface2: #f0f3f3; --line: #d9e1e2;
  --fg: #333f48; --muted: #6f787e; --faint: #999ea4;
  --accent: #00a2c6; --accent-strong: #0077c8; --accent-soft: #e5f1fa;
  --ok: #3c8a2e; --ok-soft: #eef6e7; --warn: #b8620f; --warn-soft: #fff4dc;
  --err: #c22b4a; --err-soft: #fbe8ec;
  /* Buttons: the focus border (Button/Border/Focus), the disabled fill and
     text (Button/Fill/Disabled, Content/Disabled), and the lighter slice at
     the right end of a primary button (Button/Fill/On-Primary-Default). */
  --focus: #0032a0; --on-accent: #ffffff;
  --disabled-bg: #d9e1e2; --disabled-fg: #9eaab2;
  --accent-slice: #33b4d1;
  /* A text field's focus: Input's 2px Nordic Blue border, drawn inside the
     1px border so the field does not move. */
  --focus-field: inset 0 0 0 1px var(--accent);
  /* A neutral icon button under the pointer (Button/Fill/Flat-Subtle-Hover). */
  --hover-neutral: #eaebec;
  /* A pale-blue chip under the pointer: one step darker on Nordic Lake's
     tone ramp than --accent-soft. Not a Blueprint value. */
  --accent-soft-hover: #cde4f4;
  /* Behind a modal (Overlay/Dark). */
  --overlay: #0000002b;
  /* Borders for status boxes, derived so every theme gets its own. */
  --ok-line: color-mix(in srgb, var(--ok) 25%, var(--surface));
  --warn-line: color-mix(in srgb, var(--warn) 30%, var(--surface));
  --err-line: color-mix(in srgb, var(--err) 25%, var(--surface));
  /* Flat: Blueprint separates surfaces by hairlines, not depth, and its cards
     and modals carry no shadow; the overlay sets a modal apart. Kept as a
     transparent shadow rather than `none` so a rule that adds to it still
     parses. */
  --shadow: 0 0 0 transparent;
  --shadow-modal: var(--shadow);
  /* The dark code panel and scrollbars, which base.css painted in the old
     warm browns. The panel is the reference's dark chip colour. */
  --code-bg: #333f48; --code-line: #47515a; --code-fg: #eaebed;
  --scroll-thumb: #c9ced4;
  /* The ground behind the header, which every page draws identically. A
     variable of its own so a theme can give the header a different tone from
     the working area below it; by default it is the page ground. */
  --header-bg: var(--bg);
  /* Header chrome can diverge from the page below it, for example a dark band.
     These alias the page tokens by default so existing header rules keep
     working until a theme re-points them. */
  --header-fg: var(--fg);
  --header-muted: var(--muted);
  --header-faint: var(--faint);
  --header-warn: var(--warn);
  --header-chrome-line: var(--line);
  --header-chrome-surface: var(--surface);
  --header-chrome-surface2: var(--surface2);
  /* The project column on the chat page; a variable so a theme can tint the
     panel without a literal in a page rule. */
  --panel-bg: var(--bg);
  /* The AI mark is a dark chip with the glyph knocked out of it; the source
     asset is black-on-white and inverted, so this wants to be near-black. */
  --ai-chip: #333f48;
}

/* Phones: text a step larger, the dialog title a step smaller. Fields stay at
   16px or more here, as iOS Safari zooms into a field set smaller. */
@media (max-width: 599px) {
  :root { --fs-prose: 1rem; --lh-prose: 1.5rem; --fs-label: .9375rem; --lh-label: 1.25rem;
          --fs-hint: .8125rem; --lh-hint: 1.125rem; --fs-title: 1.25rem; --lh-title: 1.625rem;
          --fs-code: .875rem; --lh-code: 1.25rem; }
}

/* The product subtitle, beside the wordmark. Shared rather than copied into
   each page's <style>, where `.brand` itself still lives in four copies - a
   rule maintained in four places is a rule that will differ in four places.

   Secondary to the wordmark: body text in Light, header foreground ink.
   It sits inside `.brand` after the wordmark, not in the nav row where the old
   pipeline tagline competed for width — and the header has room for it now that
   the tagline and Nordic plate are gone. */
.brand .sub { font: var(--font-hint); color: var(--header-fg); white-space: nowrap;
              margin-left: var(--space-s3); padding-left: var(--space-s3);
              border-left: 1px solid var(--header-chrome-line); }

header { color: var(--header-fg); }

/* The header's development controls, behind the cog (see ui/headtools.mjs for
   which ones and why the offline badge is not among them). Here rather than in
   a page's own <style> because the header is copied into all four, and a rule
   maintained in four places is a rule that will differ in four places.

   `display: none` rather than visibility or a zero width: the row is a flex
   container, so anything that leaves a box behind leaves its gap behind too,
   and the point is a header with nothing in it. */
.headtools { display: none; align-items: center; gap: 10px; }
/* `flex` and not `inline-flex`: the group is itself a flex item of
   `.head-right`, and a flex item's display is blockified - `inline-flex` would
   compute to `flex` anyway and only make the declaration read as a lie. */
.head-right[data-tools="on"] .headtools { display: flex; }
/* Last in the row and after the collapsible group, so the cog is the
   rightmost thing in the header on every page regardless of what that page
   put in the row. */
.headcog { display: inline-flex; align-items: center; justify-content: center;
           margin-left: 4px; width: 26px; height: 26px; padding: 0;
           border: 1px solid transparent; border-radius: var(--radius);
           background: none; color: var(--header-muted); cursor: pointer; }
/* Hidden until the user is known to be an admin (ui/headtools.mjs); the rule
   above sets a display, which would otherwise win over the attribute. */
.headcog[hidden] { display: none; }
.headcog:hover { color: var(--accent-strong); background: var(--hover-neutral); }
.headcog[aria-expanded="true"] { color: var(--accent-strong);
                                 border-color: var(--header-chrome-line);
                                 background: var(--header-chrome-surface2); }
/* Focus has to be visible on its own: the hover and expanded states both
   change colour, so colour alone cannot say "focused". */
.headcog:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
/* Who is signed in (ui/headtools.mjs): inside the cog's group, and quiet. */
.whoami { font: var(--font-hint); color: var(--header-muted); white-space: nowrap; }
/* Sign out, beside the name: a link to Easy Auth's route, drawn as a button. */
.sign-out { display: inline-flex; align-items: center; padding: 4px 11px;
            border: 1px solid var(--header-chrome-line); border-radius: var(--radius);
            background: var(--header-chrome-surface); color: var(--header-fg);
            font: var(--font-label-lg); white-space: nowrap; text-decoration: none; cursor: pointer; }
.sign-out:hover { border-color: var(--accent); color: var(--accent-strong); }
.sign-out:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
@media (forced-colors: active) {
  .sign-out { border-color: ButtonText; }
}
/* Read by a screen reader, not drawn. */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden;
           clip-path: inset(50%); white-space: nowrap; }

/* ── Sensor picker ──
 *
 * Offered on demand in chat. Every colour is a theme token: the picker is large enough to
 * be its own surface, and a warm-page literal becomes glare in Nordic dark.
 */
.searchbar { margin-bottom: var(--space-s2); }
.sensorbox {
  max-height: 240px; overflow-y: auto; overflow-x: hidden;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface);
}
.srow {
  display: flex; align-items: center; gap: var(--space-s3); padding: var(--space-s2) var(--space-s3);
  border-bottom: 1px solid var(--surface2); cursor: pointer; font: var(--font-label-lg);
}
.srow:last-child { border-bottom: 0; }
.srow:hover { background: var(--surface2); }
.srow input { margin: 0; accent-color: var(--accent); }
.srow input:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.srow .sm {
  color: var(--fg); font: var(--font-code);
}
.srow .sd {
  color: var(--muted); flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.srow .star { color: var(--accent); font-size: var(--fs-hint); }
.srow .bus {
  font-family: var(--mono); font-size: var(--fs-hint); color: var(--muted);
  border: 1px solid var(--line); border-radius: var(--radius-pill);
  padding: 1px 5px;
}
.srow mark {
  background: var(--accent-soft); color: var(--accent-strong);
  padding: 0 1px; border-radius: var(--radius-sm);
}
.shead {
  padding: var(--space-s2) var(--space-s3); font: var(--font-label-lg);
  color: var(--muted); background: var(--surface2);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 1;
}
.selcount { font: var(--font-hint); color: var(--muted); margin-top: var(--space-s2); }
.sensor-empty { padding: var(--space-s3); color: var(--faint); font: var(--font-hint); }

/* ── Nordic shapes, where the pages hardcoded a radius ──
 *
 * About fifty `border-radius: <n>px` rules in the page stylesheets do not read
 * --radius, so a square theme would not reach them. Until they are
 * variabilised, these reach the containers and buttons that carry the look.
 * `:root` in front of each selector outranks the page's own rule, which is
 * loaded after this file. Badges keep their round ends, as in Blueprint.
 */
:root .card,
:root .pcard,
:root .pnote,
:root .result,
:root .valbar,
:root pre,
:root .section,
:root .flash,
:root .composer input,
:root input[type=text],
:root input[type=number],
:root select { border-radius: var(--radius); }
/* Primary and secondary actions are square on myNordic ("Invite a colleague"). */
:root .composer button,
:root .btn,
:root .head-button,
:root .survey-send,
:root .survey-skip,
:root .survey-reopen,
:root .feedback-send,
:root .feedback-skip { border-radius: var(--radius); }
/* A selected tab is outlined in the primary colour on white, not filled. */
:root .tabbar button[aria-selected="true"] {
  background: var(--surface); color: var(--fg);
  border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent);
}

/* ── Buttons, as in the design system (Figma, Core: Buttons) ──
 *
 * Primary: Nordic Blue with white text and a lighter slice at the right end;
 * hover keeps the colour; focus adds a dark blue border; disabled is Light
 * Grey with grey text.
 * Secondary: white with a Nordic Lake border and text, filled Lake on hover.
 */
:root .btn.primary,
:root .composer button,
:root .survey-send,
:root .feedback-send,
:root .report-send {
  background-color: var(--accent); color: var(--on-accent); border: 1px solid var(--accent);
  background-image: linear-gradient(110deg, transparent 0 86%, var(--accent-slice) 86%);
}
:root .btn.primary:hover:not(:disabled),
:root .composer button:hover:not(:disabled),
:root .survey-send:hover:not(:disabled),
:root .feedback-send:hover:not(:disabled),
:root .report-send:hover:not(:disabled) { background-color: var(--accent); filter: none; }
:root .btn.primary:disabled,
:root .composer button:disabled,
:root .survey-send:disabled,
:root .feedback-send:disabled,
:root .report-send:disabled {
  background: var(--disabled-bg); color: var(--disabled-fg);
  border-color: var(--disabled-bg); opacity: 1;
}
:root .btn.ghost,
:root .head-button,
:root .survey-reopen {
  background: var(--surface); color: var(--accent-strong);
  border: 1px solid var(--accent-strong); box-shadow: none;
}
:root .btn.ghost:hover:not(:disabled),
:root .head-button:hover:not(:disabled),
:root .survey-reopen:hover:not(:disabled) {
  background: var(--accent-strong); color: var(--on-accent); border-color: var(--accent-strong);
}
:root .btn:focus-visible,
:root .composer button:focus-visible,
:root .report-send:focus-visible,
:root .head-button:focus-visible,
:root .survey-send:focus-visible,
:root .survey-skip:focus-visible,
:root .survey-reopen:focus-visible,
:root .feedback-send:focus-visible,
:root .feedback-skip:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; }

/* Tertiary: text in Nordic Lake, a pale blue ground on hover. "Report a
   problem" is an action, not secondary text, so it is one; so are Skip in
   the survey and in a reply's rating. */
:root .report-problem,
:root .survey-skip,
:root .feedback-skip { color: var(--accent-strong); border-radius: var(--radius); }
:root .report-problem:hover,
:root .survey-skip:hover,
:root .feedback-skip:hover { color: var(--accent-strong); background: var(--accent-soft); }
:root .report-problem:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; }

/* Sign out, square like every other control. */
:root .sign-out { border-radius: var(--radius); }
:root .sign-out:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; }

/* A reply's rating, on its own line under the bubble: the gutter beside the
   bubble is too narrow for the question, and a faded control was the one
   people overlooked. The question gives way before it wraps. */
:root .feedback-controls {
  flex-basis: calc(100% - var(--ai-indent)); width: auto; min-width: 0;
  justify-content: flex-start; margin: -4px 0 0 var(--ai-indent); opacity: 1;
}
:root .feedback-ask {
  min-width: 0; margin-right: 6px; overflow: hidden; white-space: nowrap;
  text-overflow: ellipsis; color: var(--muted); font: var(--font-hint);
}
:root .feedback-thumb { flex-shrink: 0; }
:root .airow .feedback-note {
  box-sizing: border-box; padding-left: var(--ai-indent); text-align: left;
}
@media (max-width: 359px) {
  :root .feedback-ask { display: none; }
}

/* Section labels in Nordic Dark Grey: Label/Regular/Medium in sentence case,
   as Blueprint has no uppercase or tracked style. Hints and empty states
   under them stay grey. */
:root .section > h3,
:root .ptitle,
:root .case-sec { color: var(--fg); }

/* The chat's answer chips, as myNordic's "Popular" picks: square, a pale
   blue ground, dark text, no border until the pointer is on them. */
:root .pills .pill {
  border-radius: var(--radius); background: var(--accent-soft); color: var(--fg);
  border-color: var(--accent-soft); box-shadow: none;
}
:root .pills .pill:hover { background: var(--accent-soft-hover); border-color: var(--accent-soft-hover); }
:root .pills .pill:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

/* The user's own messages on the same pale blue with dark text, so the one
   strong blue in the chat is Send, the primary action. */
:root .bubble.user { background: var(--accent-soft); color: var(--fg); }
:root .bubble.user a { color: var(--accent-strong); }
:root .bubble.user code { background: var(--surface); }

/* ── Alternative themes ──
 *
 * None for now: Nordic, in :root above, is the only theme. A later one (a dark
 * Nordic variant, from the Figma design system) goes here as a
 * `[data-theme="<id>"]` block that re-points every palette variable in :root,
 * plus its id in ui/theme.mjs and ui/theme-boot.js. The theme picker appears
 * on its own once there are two.
 */

/* ── The theme picker itself ── */
.themepick { display: inline-flex; align-items: center; gap: 6px;
             font: var(--font-hint); color: var(--header-muted); }
.themepick select {
  font: inherit; padding: 3px 7px;
  border: 1px solid var(--header-chrome-line); border-radius: var(--radius);
  background: var(--header-chrome-surface); color: var(--header-fg); cursor: pointer;
}
