/* ==========================================================================
   components.css — the shared parts every view is built from.

   Class names here are the styling contract for the feature views (see
   docs/DESIGN.md in the repository root for the full list and usage). Feature
   stylesheets (left.css, read.css, console.css) compose these and add only
   what is specific to their views; they do not restyle these classes.

   Naming: block__element--modifier; states as .is-* or ARIA attributes. No
   name contains a token content blockers match (ad, log, banner, track, …),
   which is why the dialog component is `.modal` and switches have a `rail`.
   ========================================================================== */

/* --- box: left column frame with the original's header band --------------- */
.box {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--panel);
  border: var(--hairline) solid var(--line);
  border-radius: var(--radius-box);
  overflow: clip;
}

.box__band {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--band-h);
  padding: var(--space-1) var(--space-4);
  background: var(--band);
  border-bottom: var(--hairline) solid var(--line);
}

.box__title {
  font-family: var(--font-title);
  font-size: var(--text-lg);
  font-weight: 600;
  line-height: var(--leading-tight);
  color: var(--ink);
  /* Titles are labels, not content: they do not take part in text selection
     or the touch callout. Everything else on the page stays selectable. */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.box__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
}

@media (max-width: 759.98px) {
  .box__body {
    padding: var(--space-3);
    gap: var(--space-2);
  }
}

/* --- card: right column frame, title on a quiet top row -------------------- */
.card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--panel);
  border: var(--hairline) solid var(--line);
  border-radius: var(--radius-box);
}

.card__top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-3);
  min-height: calc(var(--control-h) + var(--space-4));
  padding: var(--space-3) var(--space-5) 0;
}

.card__title {
  font-family: var(--font-title);
  font-size: var(--text-lg);
  font-weight: 600;
  line-height: var(--leading-tight);
  color: var(--ink);
  min-width: 0;
}

.card__actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-left: auto;
}

.card__actions:empty {
  display: none;
}

.card__body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  gap: var(--space-3);
  min-width: 0;
  padding: var(--space-3) var(--space-5) var(--space-5);
}

@media (max-width: 759.98px) {
  .card__top {
    padding: var(--space-3) var(--space-3) 0;
  }

  .card__body {
    padding: var(--space-3);
  }
}

/* --- well: the tinted inner group ----------------------------------------- */
.well {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-width: 0;
  padding: var(--space-4);
  background: var(--well);
  border-radius: var(--radius-well);
}

/* Only multi-group sensors with labelled groups (SMT500) use this. */
.well__label {
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: var(--leading-tight);
  color: var(--ink-2);
}

@media (max-width: 759.98px) {
  .well {
    padding: var(--space-3);
  }
}

/* --- text helpers --------------------------------------------------------- */
.hint {
  font-size: var(--text-sm);
  line-height: 1.4;
  color: var(--ink-2);
  max-width: var(--measure);
}

/* Large condensed figures that are not readouts: the address, the port. */
.figure {
  font-family: var(--font-title);
  font-size: var(--text-2xl);
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums lining-nums;
  color: var(--ink);
}

.figure--md {
  font-size: var(--text-xl);
}

.unit {
  font-size: var(--text-md);
  font-weight: 500;
  color: var(--ink-2);
  white-space: nowrap;
}

/* Monospace text (hex only, per the type rules). JetBrains Mono turns `-->`
   and friends into arrows through contextual alternates; a protocol line must
   show the characters that were sent, so ligatures are off wherever it is used. */
.mono {
  font-family: var(--font-mono);
  font-size: var(--text-mono);
  font-variant-ligatures: none;
  font-feature-settings: 'calt' 0, 'liga' 0;
}

/* --- icon ----------------------------------------------------------------- */
.icon {
  flex: none;
  width: 18px;
  height: 18px;
}

/* --- buttons --------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--control-h);
  padding: var(--space-1) var(--space-4);
  border: var(--hairline) solid transparent;
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--text-md);
  font-weight: 500;
  line-height: 1.1;
  text-align: center;
  text-decoration: none;
  /* Labels wrap rather than overflow when a narrow cell squeezes a button;
     at normal widths every original label fits on one line. */
  text-wrap: balance;
  max-width: 100%;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    background-color var(--dur-ui) ease,
    border-color var(--dur-ui) ease,
    color var(--dur-ui) ease;
}

.btn--primary {
  background: var(--signal);
  color: var(--signal-ink);
}

.btn--primary:hover {
  background: var(--signal-hover);
  color: var(--signal-ink);
}

/* The workhorse: register buttons, Switch to …, Set new Modbus Adress. White
   on the tinted well, exactly where the original put its push buttons. */
.btn--secondary {
  background: var(--panel);
  border-color: var(--line-strong);
  color: var(--ink);
}

.btn--secondary:hover {
  border-color: var(--signal);
  color: var(--signal);
}

.btn--quiet {
  background: transparent;
  color: var(--signal);
}

.btn--quiet:hover {
  background: var(--signal-soft);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

/* A toggle button that is on (Poll running, a pressed theme toggle). */
.btn[aria-pressed='true'] {
  background: var(--signal-soft);
  border-color: var(--signal);
  color: var(--signal);
}

.btn--primary[aria-pressed='true'] {
  background: var(--signal-hover);
  color: var(--signal-ink);
}

.btn:disabled,
.btn[aria-disabled='true'] {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn--block {
  width: 100%;
}

/* Toolbar buttons that must stay on one line (Read all, Poll, Copy, Clear). */
.btn--nowrap {
  white-space: nowrap;
}

.btn--sm {
  min-height: var(--control-h-sm);
  padding: 0 var(--space-3);
  font-size: var(--text-sm);
}

.btn--icon {
  width: var(--control-h);
  padding: 0;
}

.btn--icon.btn--sm {
  width: var(--control-h-sm);
}

/* The theme toggle's pressed state is information, not an alarm: keep it quiet. */
.btn--quiet.btn--icon[aria-pressed='true'] {
  background: transparent;
  border-color: transparent;
}

/* Left-aligned label for wide buttons in a list (register buttons). */
.btn--start {
  justify-content: flex-start;
  text-align: left;
}

/* --- readout: the bold thing ----------------------------------------------- */
/*
   <output class="readout [is-reading|is-fresh|is-error]" aria-live="polite">
     <span class="readout__value">23.67</span>
   </output>
   <span class="unit">°C</span>

   Fixed size, so a value arriving never shifts the row. Right-aligned tabular
   figures, so consecutive values line up digit under digit.
   - .is-reading  value cleared, slim indeterminate bar along the bottom edge
   - .is-fresh    a 600 ms --fresh underline that fades (re-trigger: remove
                  the class, read el.offsetWidth, add it again)
   - .is-error    "Error" in --fault; nothing flashes
*/
.readout {
  position: relative;
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: flex-end;
  inline-size: var(--readout-w);
  max-inline-size: 100%;
  block-size: var(--readout-h);
  padding: 0 var(--space-3);
  overflow: hidden;
  background: var(--readout);
  border: var(--hairline) solid var(--line);
  border-radius: var(--radius-readout);
  box-shadow: var(--inset);
  color: var(--ink);
  font-family: var(--font-title);
  font-size: var(--text-2xl);
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums lining-nums;
  white-space: nowrap;
}

.readout__value {
  overflow: hidden;
  text-overflow: clip;
}

.readout.is-error {
  color: var(--fault);
}

/* fresh: underline that fades */
.readout::after {
  content: '';
  position: absolute;
  inset-inline: var(--space-2);
  bottom: 4px;
  height: 2px;
  border-radius: 1px;
  background: var(--fresh);
  opacity: 0;
  pointer-events: none;
}

.readout.is-fresh::after {
  animation: readout-fresh var(--dur-fresh) ease-out both;
}

@keyframes readout-fresh {
  0% {
    opacity: 1;
  }

  35% {
    opacity: 1;
  }

  100% {
    opacity: 0;
  }
}

/* reading: slim indeterminate bar */
.readout::before {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  width: 38%;
  height: 2px;
  background: var(--signal);
  opacity: 0;
  pointer-events: none;
}

.readout.is-reading::before {
  opacity: 1;
  animation: readout-sweep var(--dur-reading) var(--ease-out) infinite;
}

.readout.is-reading .readout__value {
  visibility: hidden;
}

@keyframes readout-sweep {
  from {
    transform: translateX(-100%);
  }

  to {
    transform: translateX(265%);
  }
}

@media (prefers-reduced-motion: reduce) {
  /* No sweep: a still bar across the whole edge says "waiting" just as well. */
  .readout.is-reading::before {
    width: 100%;
    animation: none;
    opacity: 0.6;
  }

  .readout.is-fresh::after {
    animation: none;
  }
}

/* --- form controls ---------------------------------------------------------- */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}

.field--inline {
  flex-direction: row;
  align-items: center;
  gap: var(--space-3);
}

.field__label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink-2);
}

.input,
.select {
  min-height: var(--control-h);
  min-width: 0;
  border: var(--hairline) solid var(--line-strong);
  border-radius: var(--radius-control);
  background: var(--readout);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--text-md);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  transition: border-color var(--dur-ui) ease;
}

.input {
  padding: 0 var(--space-3);
}

.input:hover,
.select:hover {
  border-color: var(--ink-2);
}

.input[aria-invalid='true'] {
  border-color: var(--fault);
}

.input:disabled,
.select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Native select, own chevron (two gradients, so it follows currentColor in
   both themes without an image per theme). */
.select {
  appearance: none;
  width: 100%;
  padding: 0 calc(var(--space-3) + 18px) 0 var(--space-3);
  background-color: var(--readout);
  background-image:
    linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position:
    calc(100% - 17px) 50%,
    calc(100% - 12px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}

/* Numeric stepper: [ − | 1 | + ] */
.stepper {
  display: inline-flex;
  align-items: stretch;
  min-height: var(--control-h);
  border: var(--hairline) solid var(--line-strong);
  border-radius: var(--radius-control);
  background: var(--readout);
  overflow: hidden;
}

.stepper:focus-within {
  border-color: var(--signal);
}

.stepper__btn {
  display: inline-grid;
  place-items: center;
  width: var(--control-h);
  padding: 0;
  border: 0;
  background: var(--panel);
  color: var(--ink-2);
  cursor: pointer;
  transition:
    background-color var(--dur-ui) ease,
    color var(--dur-ui) ease;
}

.stepper__btn:hover:not(:disabled) {
  background: var(--signal-soft);
  color: var(--signal);
}

.stepper__btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.stepper__btn:first-child {
  border-right: var(--hairline) solid var(--line);
}

.stepper__btn:last-child {
  border-left: var(--hairline) solid var(--line);
}

.stepper__btn:focus-visible {
  outline-offset: -3px;
}

.stepper__input {
  /* Grows when the stepper is stretched to a column's width. */
  flex: 1 1 auto;
  width: 4.5em;
  min-width: 3em;
  padding: 0 var(--space-2);
  border: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-title);
  font-size: var(--text-lg);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: center;
  appearance: textfield;
  -moz-appearance: textfield;
}

.stepper__input::-webkit-outer-spin-button,
.stepper__input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* The input is the stepper's one Tab stop (−/+ are skipped on purpose), so
   the shared ring goes round the whole control, not inside the bare digits;
   the border turning signal-blue (.stepper:focus-within) stays as a second
   cue. */
.stepper__input:focus-visible {
  outline: none;
}

.stepper:has(.stepper__input:focus-visible) {
  outline: 2px solid var(--signal);
  outline-offset: 2px;
}

/* Segmented control. Either radio inputs inside labels:
     <div class="segmented" role="radiogroup" aria-label="Transport">
       <label class="segmented__option"><input type="radio" …><span>Web Serial</span></label>
   or buttons with aria-pressed / aria-checked (role="radio"). */
.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 2px;
  padding: 2px;
  border: var(--hairline) solid var(--line-strong);
  border-radius: var(--radius-control);
  background: var(--panel);
}

.segmented__option {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  min-width: 0;
  min-height: calc(var(--control-h) - 6px);
  padding: 0 var(--space-2);
  border: 0;
  border-radius: calc(var(--radius-control) - 2px);
  background: transparent;
  color: var(--ink-2);
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1.1;
  text-align: center;
  cursor: pointer;
  transition:
    background-color var(--dur-ui) ease,
    color var(--dur-ui) ease;
}

.segmented__option > input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: inherit;
}

.segmented__option:hover {
  color: var(--ink);
}

/* Under a finger every option is a full 44px target: the frame drops its
   inner padding so the options fill it instead of sitting 6px short. */
@media (pointer: coarse), (max-width: 759.98px) {
  .segmented {
    gap: 0;
    padding: 0;
  }

  .segmented__option {
    min-height: var(--control-h);
  }

  /* The stepper's parts get the full height too; its frame grows by the
     two border pixels instead. */
  .stepper {
    min-height: calc(var(--control-h) + 2px);
  }
}

/* The chosen option carries a 1px signal ring (≥ 5.6:1 against the panel in
   both themes): the tint alone is ~1.2:1 and the colour change of the label
   ~1.1:1, too faint to say which one is on (WCAG 1.4.11) — and the app bar's
   theme control has icons only, so no bolder label helps there. The tint
   stays as the second cue. */
.segmented__option:has(> input:checked),
.segmented__option[aria-pressed='true'],
.segmented__option[aria-checked='true'] {
  background: var(--signal-soft);
  box-shadow: inset 0 0 0 1px var(--signal);
  color: var(--signal);
  font-weight: 600;
}

.segmented__option:has(> input:focus-visible) {
  outline: 2px solid var(--signal);
  outline-offset: 1px;
}

.segmented__option:has(> input:disabled),
.segmented__option:disabled,
.segmented__option[aria-disabled='true'] {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Switch (role="switch" button):
     <button class="switch" role="switch" aria-checked="false">
       <span class="switch__rail"><span class="switch__knob"></span></span>
     </button> */
.switch {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--control-h);
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

.switch__rail {
  position: relative;
  flex: none;
  width: 44px;
  height: 24px;
  border: var(--hairline) solid var(--line-strong);
  border-radius: 12px;
  background: var(--readout);
  transition:
    background-color var(--dur-ui) ease,
    border-color var(--dur-ui) ease;
}

.switch__knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--ink-2);
  transition:
    transform var(--dur-ui) var(--ease-out),
    background-color var(--dur-ui) ease;
}

.switch[aria-checked='true'] .switch__rail {
  background: var(--signal-soft);
  border-color: var(--signal);
}

.switch[aria-checked='true'] .switch__knob {
  transform: translateX(20px);
  background: var(--signal);
}

/* A switch whose "on" is a deviation from the default (parity NONE). */
.switch--caution[aria-checked='true'] .switch__rail {
  background: var(--caution-soft);
  border-color: var(--caution);
}

.switch--caution[aria-checked='true'] .switch__knob {
  background: var(--caution);
}

/* --- tabs ------------------------------------------------------------------- */
/*
   <div class="tabs">
     <div class="tabs__list" role="tablist" aria-label="…">
       <button class="tabs__tab" role="tab" aria-selected="true" aria-controls="…">Registers</button>
     </div>
     <div class="tabs__panel" role="tabpanel">…</div>
   </div>
*/
.tabs {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-width: 0;
}

.tabs__list {
  display: flex;
  gap: var(--space-1);
  border-bottom: var(--hairline) solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs__tab {
  position: relative;
  flex: none;
  min-height: var(--control-h);
  padding: 0 var(--space-3);
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font-size: var(--text-md);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}

.tabs__tab:hover {
  color: var(--ink);
}

.tabs__tab[aria-selected='true'] {
  color: var(--ink);
  font-weight: 600;
}

.tabs__tab[aria-selected='true']::after {
  content: '';
  position: absolute;
  left: var(--space-2);
  right: var(--space-2);
  bottom: -1px;
  height: 2px;
  border-radius: 1px;
  background: var(--signal);
}

.tabs__tab:focus-visible {
  outline-offset: -2px;
}

.tabs__panel {
  min-width: 0;
}

/* --- chips and status ------------------------------------------------------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: 24px;
  padding: 0 var(--space-2);
  border: var(--hairline) solid transparent;
  border-radius: var(--radius-readout);
  background: var(--well);
  color: var(--ink-2);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.chip .icon {
  width: 14px;
  height: 14px;
}

.chip--signal {
  background: var(--signal-soft);
  color: var(--signal);
}

.chip--fresh {
  background: var(--fresh-soft);
  color: var(--fresh);
}

.chip--caution {
  background: var(--caution-soft);
  border-color: var(--caution);
  color: var(--caution);
}

.chip--fault {
  background: var(--fault-soft);
  color: var(--fault);
}

/* Connection / mode dot: <span class="status-dot" data-status="connected"></span> */
.status-dot {
  display: inline-block;
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid var(--ink-2);
  background: transparent;
}

.status-dot[data-status='connected'],
.status-dot[data-status='modbus'] {
  border-color: var(--fresh);
  background: var(--fresh);
}

.status-dot[data-status='connecting'],
.status-dot[data-status='tbus'] {
  border-color: var(--caution);
  background: var(--caution);
}

.status-dot[data-status='error'] {
  border-color: var(--fault);
  background: var(--fault);
}

/* --- byte anatomy (the other bold thing) ------------------------------------ */
/*
   <span class="frame-bytes [frame-bytes--exception]">
     <span class="byte byte--addr">FD</span><span class="byte byte--fn">03</span>
     <span class="byte byte--data">00</span>…<span class="byte byte--crc">C0</span>
   </span>
   A quiet legend on demand: .byte-key (same tiles, small, with words).
*/
.frame-bytes {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 3px;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: var(--text-mono);
  font-weight: 500;
  line-height: 1;
  font-variant-ligatures: none;
  font-feature-settings: 'calt' 0, 'liga' 0;
}

.byte {
  display: inline-grid;
  place-items: center;
  min-width: calc(2ch + 8px);
  height: 22px;
  padding: 0 4px;
  border: var(--hairline) solid transparent;
  border-radius: var(--radius-tile);
  background: var(--byte-data-tile);
  color: var(--byte-data);
}

.byte--addr {
  background: var(--byte-addr-tile);
  color: var(--byte-addr);
}

.byte--fn {
  background: var(--byte-fn-tile);
  color: var(--byte-fn);
}

.byte--data {
  background: var(--byte-data-tile);
  color: var(--byte-data);
}

/* The CRC is the envelope, not the content: outlined, not filled. */
.byte--crc {
  background: var(--byte-crc-tile);
  border-color: var(--line);
  color: var(--byte-crc);
  font-weight: 400;
}

/* function | 0x80: the sensor answered with an exception. */
.frame-bytes--exception .byte--fn,
.byte--exception {
  background: var(--fault-soft);
  color: var(--fault);
}

.byte-key {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  color: var(--ink-2);
}

.byte-key__item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

.byte-key .byte {
  height: 18px;
  min-width: calc(2ch + 6px);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

/* --- modal (the <dialog> component) ----------------------------------------- */
/*
   <dialog class="modal" aria-labelledby="t">
     <div class="modal__band"><h2 class="modal__title" id="t">Advanced Settings</h2></div>
     <div class="modal__body">…</div>
     <div class="modal__actions"><button class="btn btn--secondary">Close Window</button></div>
   </dialog>
   Fade + scale in 120 ms on open and on close (where the browser can animate
   a closing dialog); instant with reduced motion.
*/
.modal {
  width: min(28rem, calc(100vw - 2 * var(--space-4)));
  max-height: calc(100dvh - 2 * var(--space-4));
  padding: 0;
  border: var(--hairline) solid var(--line);
  border-radius: var(--radius-box);
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--float-shadow);
  overflow: auto;
  opacity: 1;
  transform: none;
  transition:
    opacity var(--dur-dialog) ease,
    transform var(--dur-dialog) var(--ease-out),
    overlay var(--dur-dialog) allow-discrete,
    display var(--dur-dialog) allow-discrete;
}

.modal:not([open]) {
  opacity: 0;
  transform: scale(0.97);
}

@starting-style {
  .modal[open] {
    opacity: 0;
    transform: scale(0.97);
  }
}

.modal::backdrop {
  background: var(--scrim);
  opacity: 1;
  transition:
    opacity var(--dur-dialog) ease,
    overlay var(--dur-dialog) allow-discrete,
    display var(--dur-dialog) allow-discrete;
}

.modal:not([open])::backdrop {
  opacity: 0;
}

@starting-style {
  .modal[open]::backdrop {
    opacity: 0;
  }
}

.modal--wide {
  width: min(40rem, calc(100vw - 2 * var(--space-4)));
}

.modal__band {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--band-h);
  padding: var(--space-1) var(--space-5);
  background: var(--band);
  border-bottom: var(--hairline) solid var(--line);
}

.modal__title {
  font-family: var(--font-title);
  font-size: var(--text-lg);
  font-weight: 600;
  line-height: var(--leading-tight);
}

.modal__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-5);
}

.modal__actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: 0 var(--space-5) var(--space-5);
}

/* --- notice (startup / environment message under the app bar) --------------- */
.notice {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: var(--hairline) solid var(--line);
  border-radius: var(--radius-well);
  background: var(--panel);
  color: var(--ink);
  font-size: var(--text-sm);
}

.notice[data-kind='warn'] {
  border-color: var(--caution);
  background: var(--caution-soft);
}

.notice[data-kind='error'] {
  border-color: var(--fault);
  background: var(--fault-soft);
}

.notice__text {
  max-width: var(--measure);
  padding-top: 0.2em;
}

.notice__dismiss {
  flex: none;
  margin: -4px -6px -4px auto;
  font-size: var(--text-lg);
  color: var(--ink-2);
}

/* --- toasts ----------------------------------------------------------------- */
.toaster {
  position: fixed;
  right: var(--space-4);
  bottom: var(--space-4);
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-2);
  width: min(26rem, calc(100vw - 2 * var(--space-4)));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3) var(--space-2) var(--space-3) var(--space-3);
  border: var(--hairline) solid var(--line);
  border-radius: var(--radius-well);
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--float-shadow);
  font-size: var(--text-sm);
  line-height: 1.4;
  pointer-events: auto;
  transition:
    opacity var(--dur-dialog) ease,
    transform var(--dur-dialog) var(--ease-out);
}

.toast.is-entering,
.toast.is-leaving {
  opacity: 0;
  transform: translateY(6px);
}

.toast__icon {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: var(--radius-readout);
  background: var(--signal-soft);
  color: var(--signal);
}

.toast__icon .icon {
  width: 14px;
  height: 14px;
}

.toast--success .toast__icon {
  background: var(--fresh-soft);
  color: var(--fresh);
}

.toast--warn .toast__icon {
  background: var(--caution-soft);
  color: var(--caution);
}

.toast--error {
  border-color: var(--fault);
}

.toast--error .toast__icon {
  background: var(--fault-soft);
  color: var(--fault);
}

.toast__message {
  flex: 1 1 auto;
  min-width: 0;
  padding-top: 2px;
  overflow-wrap: anywhere;
}

.toast__close {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 28px;
  height: 28px;
  margin: -3px 0;
  padding: 0;
  border: 0;
  border-radius: var(--radius-readout);
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
}

.toast__close:hover {
  background: var(--well);
  color: var(--ink);
}

.toast__close .icon {
  width: 14px;
  height: 14px;
}

@media (max-width: 759.98px) {
  .toaster {
    left: var(--space-3);
    right: var(--space-3);
    bottom: var(--space-3);
    width: auto;
    align-items: stretch;
  }
}

/* Under a finger the × is a full 44px target: an error toast stays until it
   is dismissed, and this is the only way to clear it. The negative margins
   keep the toast as tall as before. */
@media (pointer: coarse), (max-width: 759.98px) {
  .toast__close {
    width: 44px;
    height: 44px;
    margin: -11px -6px -11px 0;
  }
}

/* --- skip link -------------------------------------------------------------- */
.skip-link {
  position: absolute;
  left: var(--space-2);
  top: -100px;
  z-index: 60;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-control);
  background: var(--signal);
  color: var(--signal-ink);
  font-weight: 500;
  text-decoration: none;
}

.skip-link:focus {
  top: var(--space-2);
  color: var(--signal-ink);
}

/* --- noscript --------------------------------------------------------------- */
.noscript {
  max-width: var(--measure);
  margin: var(--space-6) auto;
  padding: var(--space-5);
  border: var(--hairline) solid var(--caution);
  border-radius: var(--radius-box);
  background: var(--caution-soft);
}
