/* ============================================================================
   TTM component library — the spec's Component Patterns, implemented once.
   Pure token consumers (tokens.css is the only place a color may be defined).
   Spacing doctrine: structural spacing uses the --ttm-spacing-* scale;
   intra-component optical rhythm (.3/.6/.8/1.1rem …) is deliberate taste
   and stays literal — never introduce a new color or font literal though.
   Consumed by every surface: map chrome widgets (menu, gate, toasts, footer),
   dashboard primitives (card, kv, bar, badge, meter, table), and form
   components (buttons, input, select, switch, color, range).
   ========================================================================== */


  .ttm-card {
    background: var(--ttm-surface);
    border: 1px solid var(--ttm-border);
    border-radius: var(--radius-lg);
    padding: 1.1rem 1.25rem;
  }

  .ttm-badge {
    display: inline-block;
    font: 600 0.68rem/1 var(--ttm-font-mono);
    letter-spacing: .05em;
    text-transform: uppercase;
    border: 1px solid var(--ttm-border);
    border-radius: var(--radius-sm);
    padding: .25rem .5rem;
  }

  .ttm-badge--success { color: var(--ttm-success); border-color: var(--ttm-success); }

  .ttm-badge--warning { color: var(--ttm-warning); border-color: var(--ttm-warning); }

  .ttm-badge--danger  { color: var(--ttm-danger);  border-color: var(--ttm-danger); }

  .ttm-btn-primary, .ttm-btn-outline {
    font: 600 var(--ttm-fs-small)/1 var(--ttm-font-sans);
    border-radius: var(--radius-md);
    padding: .6rem 1rem;
    min-height: 44px;
    cursor: pointer;
    /* anchors dressed as buttons: no underline, centered label */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
  }

  .ttm-btn-primary { background: var(--ttm-accent-cta); color: var(--ttm-on-accent); border: none; }

  .ttm-btn-primary:hover { box-shadow: 0 0 20px color-mix(in srgb, var(--ttm-pink) 50%, transparent); }

  .ttm-btn-outline { background: transparent; color: var(--ttm-text); border: 1px solid var(--ttm-border); }

  .ttm-btn-outline:hover { background: var(--ttm-wash-hover); }

  .ttm-select select {
    appearance: none;
    -webkit-appearance: none;
    background: var(--ttm-surface-alt);
    color: var(--ttm-text);
    border: 1px solid var(--ttm-border);
    border-radius: var(--radius-sm);
    font: 500 var(--ttm-fs-small) var(--ttm-font-sans);
    padding: 0 2rem 0 .7rem;
    height: 40px;
    cursor: pointer;
  }

  .ttm-select::after {
    content: "▾";
    position: absolute;
    right: .65rem;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--ttm-text-muted);
    font-size: .8rem;
  }

  .ttm-select select:hover { background: var(--ttm-plum); border-color: var(--ttm-text-faint); }


  .ttm-switch { position: relative; display: inline-flex; align-items: center; cursor: pointer; }

  .ttm-switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }

  .ttm-switch .track {
    width: 40px;
    height: 22px;
    border-radius: 11px;
    background: var(--ttm-surface-alt);
    border: 1.5px solid var(--ttm-border);
    transition: background var(--ttm-transition-fast);
    position: relative;
  }

  .ttm-switch .track::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: var(--ttm-text-muted);
    transition: transform var(--ttm-transition-fast), background var(--ttm-transition-fast);
  }

  .ttm-switch input:checked + .track { background: color-mix(in srgb, var(--ttm-control) 30%, var(--ttm-surface-alt)); border-color: var(--ttm-control); }

  .ttm-switch input:checked + .track::after { transform: translateX(18px); background: var(--ttm-control); }

  .ttm-switch input:focus-visible + .track { outline: 2px solid var(--ttm-focus); outline-offset: 2px; }


  input[type="color"] {
    appearance: none;
    -webkit-appearance: none;
    width: 44px;
    height: 32px;
    padding: 2px;
    background: var(--ttm-surface-alt);
    border: 1px solid var(--ttm-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
  }

  input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }

  input[type="color"]::-webkit-color-swatch { border: none; border-radius: calc(var(--radius-sm) - 2px); }

  input[type="color"]:hover { border-color: var(--ttm-text-faint); }


  input[type="range"] {
    appearance: none;
    -webkit-appearance: none;
    height: 24px;
    background: transparent;
    cursor: pointer;
  }

  input[type="range"]::-webkit-slider-runnable-track {
    height: 6px;
    border-radius: 3px;
    background: var(--ttm-surface-alt);
    border: 1px solid var(--ttm-border-subtle);
  }

  input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    margin-top: -7px;
    border-radius: 50%;
    background: var(--ttm-control);
    border: 2px solid var(--ttm-bg);
  }

  input[type="range"]:focus-visible { outline: 2px solid var(--ttm-focus); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
    .ttm-switch .track, .ttm-switch .track::after { transition: none; }
  }


/* ── ttm-burger + ttm-menu (theme.js) — all routes + theme, collapsed ──
   the burger sits in the universal sitebar's tools cluster, in flow */
.ttm-burger {
  width: 44px;
  height: 44px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: var(--ttm-surface);
  border: 1.5px solid var(--ttm-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 0;
}
.ttm-burger span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--ttm-text);
  border-radius: 1px;
  transition: transform var(--ttm-transition-normal), opacity var(--ttm-transition-normal);
}
.ttm-burger[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.ttm-burger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.ttm-burger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.ttm-menu__backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  background: var(--ttm-overlay);
}
.ttm-menu {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-modal);
  width: min(100vw, 21rem);
  background: var(--ttm-surface);
  border-left: 1.5px solid var(--ttm-border);
  box-shadow: var(--ttm-shadow);
  padding: 0 1.1rem 1.25rem;
  overflow-y: auto;
  font-family: var(--ttm-font-sans);
  color: var(--ttm-text);
  transform: translateX(100%);
  visibility: hidden;
  /* visibility flips after the slide-out only; on open it must switch
     instantly so focus can move into the panel the same tick */
  transition: transform var(--ttm-transition-normal), visibility 0s var(--ttm-transition-normal);
}
.ttm-menu.is-open {
  transform: translateX(0);
  visibility: visible;
  transition: transform var(--ttm-transition-normal);
}
.ttm-menu__head {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--ttm-surface);
  border-bottom: 1.5px solid var(--ttm-border);
  margin: 0 -1.1rem 1rem;
  padding: .8rem 1.1rem;
  z-index: 1;
}
.ttm-menu__title {
  font: 600 var(--ttm-fs-caption)/1 var(--ttm-font-mono);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ttm-text-muted);
}
.ttm-menu__close {
  width: 44px;
  height: 44px;
  margin: -0.55rem -0.6rem -0.55rem 0;
  background: none;
  border: none;
  color: var(--ttm-text-muted);
  font-size: 1.3rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.ttm-menu__close:hover { color: var(--ttm-text); background: var(--ttm-wash-hover); }
.ttm-menu__backdrop {
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--ttm-transition-normal), visibility var(--ttm-transition-normal);
}
.ttm-menu__backdrop.is-open { opacity: 1; visibility: visible; }
@media (prefers-reduced-motion: reduce) {
  .ttm-menu, .ttm-menu__backdrop { transition: none; }
}
.ttm-menu__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.ttm-menu__group {
  font: 600 var(--ttm-fs-caption)/1 var(--ttm-font-mono);
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ttm-text-faint);
  margin: 1.1rem 0 .35rem;
  padding: 0 .75rem;
}
.ttm-menu__item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: .6rem .75rem;
  min-height: 44px;
  justify-content: center;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--ttm-text);
  border: 1.5px solid transparent;
}
.ttm-menu__item:hover { background: var(--ttm-surface-alt); }
.ttm-menu__item[aria-current="page"] {
  border-color: var(--ttm-control);
  background: var(--ttm-surface-alt);
}
.ttm-menu__name { font-weight: 600; font-size: var(--ttm-fs-small); }
.ttm-menu__desc { font-size: var(--ttm-fs-caption); color: var(--ttm-text-muted); }
.ttm-menu__theme {
  margin: 1.4rem 0 0;
  padding: .9rem .75rem .75rem;
  border: 1.5px solid var(--ttm-border);
  border-radius: var(--radius-sm);
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
}
.ttm-menu__theme legend {
  font: 600 var(--ttm-fs-caption)/1 var(--ttm-font-mono);
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ttm-text-faint);
  padding: 0 .3rem;
}
.ttm-menu__theme label {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1.5px solid var(--ttm-border);
  border-radius: var(--radius-sm);
  font-size: var(--ttm-fs-caption);
  font-weight: 600;
  cursor: pointer;
  color: var(--ttm-text-secondary);
}
.ttm-menu__theme input { position: absolute; opacity: 0; pointer-events: none; }
.ttm-menu__theme input:checked + span { color: var(--ttm-control); }
.ttm-menu__theme label:has(input:checked) { border-color: var(--ttm-control); color: var(--ttm-control); }
.ttm-menu__theme label:has(input:focus-visible) {
  outline: 2px solid var(--ttm-focus);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  .ttm-burger span { transition: none; }
}

/* ── ttm-toasts (toast.js) ── */
.ttm-toasts {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: var(--z-overlay);
  display: flex;
  flex-direction: column;
  gap: var(--ttm-spacing-sm);
  width: min(92vw, 22rem);
  pointer-events: none;
}
.ttm-toast {
  display: flex;
  align-items: center;
  gap: var(--ttm-spacing-sm);
  background: var(--ttm-surface);
  color: var(--ttm-text);
  border: 1.5px solid var(--ttm-border);
  border-left: 4px solid var(--ttm-info);
  border-radius: var(--radius-sm);
  box-shadow: var(--ttm-shadow);
  padding: .55rem .35rem .55rem .8rem;
  font: 400 var(--ttm-fs-small)/1.4 var(--ttm-font-sans);
  pointer-events: auto;
  animation: ttm-toast-in var(--ttm-anim-pop) ease;
}
.ttm-toast--success { border-left-color: var(--ttm-success); }
.ttm-toast--warning { border-left-color: var(--ttm-warning); }
.ttm-toast--danger  { border-left-color: var(--ttm-danger); }
.ttm-toast__msg { flex: 1; }
.ttm-toast__close {
  flex: none;
  width: 44px;
  height: 44px;
  margin: -0.55rem 0;
  background: none;
  border: none;
  color: var(--ttm-text-muted);
  font-size: 1.15rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.ttm-toast__close:hover { color: var(--ttm-text); background: var(--ttm-wash-hover); }
.ttm-toast--out { opacity: 0; transform: translateY(4px); transition: opacity var(--ttm-transition-normal), transform var(--ttm-transition-normal); }
@keyframes ttm-toast-in { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) {
  .ttm-toast { animation: none; }
  .ttm-toast--out { transition: none; }
}

/* ── Bernard's greeting in the menu (Special Elite loads via theme.js) ── */
.ttm-menu__bernard {
  display: block;
  margin: 0 0 var(--ttm-spacing-md);
  padding: .8rem .85rem;
  border: 1.5px solid var(--ttm-border);
  border-radius: var(--radius-sm);
  background: var(--ttm-bg-alt);
  text-decoration: none;
}
.ttm-menu__bernard .voice {
  font-family: var(--ttm-font-voice);
  font-size: .95rem;
  line-height: 1.5;
  color: var(--ttm-goldenrod); /* lamplit amber — Bernard's band */
}
.ttm-menu__bernard:hover { background: var(--ttm-surface-alt); }

/* ── Shortcut hints in the menu ── */
.ttm-menu__keys {
  margin: var(--ttm-spacing-md) 0 0;
  padding: .75rem;
  border-top: 1.5px solid var(--ttm-border-subtle);
  font: 400 var(--ttm-fs-caption)/1.9 var(--ttm-font-mono);
  color: var(--ttm-text-muted);
}
.ttm-kbd-hints { font: 400 var(--ttm-fs-caption)/1.9 var(--ttm-font-mono); }
.ttm-menu__keys kbd,
.ttm-kbd-hints kbd {
  display: inline-block;
  min-width: 1.35em;
  text-align: center;
  padding: .1em .35em;
  border: 1px solid var(--ttm-border);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
  background: var(--ttm-surface-alt);
  color: var(--ttm-text-secondary);
  font-family: var(--ttm-font-mono);
  font-size: .95em;
}

/* ── ttm-footer badge (required brand footer, TTM modes only) ── */
/* sits in the universal footer flow — never floats over content */
.ttm-footer-badge {
  display: block;
  margin-top: .6rem;
  font: 400 11px/1 var(--ttm-font-mono);
  color: var(--ttm-text-muted);
}
.ttm-footer-badge .heart { color: var(--ttm-hot-red); }
.ttm-footer-badge .brand-name { font-family: var(--ttm-font-serif); }

/* ── ttm-gate (stack.js) — spec dialog pattern ── */
.ttm-gate {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ttm-overlay);
  backdrop-filter: blur(4px);
}
.ttm-gate__card {
  background: var(--ttm-surface);
  color: var(--ttm-text);
  border: 1.5px solid var(--ttm-border);
  border-radius: var(--radius-md);
  box-shadow: var(--ttm-shadow);
  width: min(92vw, 26rem);
  padding: 1.75rem 1.75rem 1.4rem;
  font-family: var(--ttm-font-sans);
}
.ttm-gate__card h2 { margin: 0 0 .35rem; font-size: var(--ttm-fs-h4); }
.ttm-gate__card p { margin: .3rem 0 .9rem; font-size: var(--ttm-fs-small); color: var(--ttm-text-muted); }
.ttm-gate__card label {
  display: block;
  font-size: var(--ttm-fs-small);
  font-weight: 600;
  margin: 1.1rem 0 .4rem;
}
.ttm-gate__card input {
  width: 100%;
  box-sizing: border-box;
  background: var(--ttm-surface-alt);
  color: var(--ttm-text);
  border: 1.5px solid var(--ttm-border);
  border-radius: var(--radius-sm);
  font: 400 var(--ttm-fs-small)/1.2 var(--ttm-font-sans);
  padding: 0 .8rem;
  height: 44px; /* touch target, fixed — padding no longer stacks on top */
}
.ttm-gate__card input:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--ttm-surface), 0 0 0 4px var(--ttm-focus);
}
.ttm-gate__card input[aria-invalid="true"] { border-color: var(--ttm-danger); }
.ttm-gate__err { color: var(--ttm-danger); font-size: var(--ttm-fs-caption); margin: 0; }
.ttm-gate__err:not(:empty) { margin: .55rem 0 0; }
.ttm-gate__submit {
  margin-top: 1.35rem;
  width: 100%;
  height: 44px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--ttm-accent-cta);
  color: var(--ttm-on-accent);
  font: 600 15px/1 var(--ttm-font-sans);
  cursor: pointer;
}
.ttm-gate__submit:hover {
  box-shadow: 0 0 20px color-mix(in srgb, var(--ttm-pink) 50%, transparent);
}
.ttm-gate__fine { font-size: var(--ttm-fs-caption); color: var(--ttm-text-faint); margin: .85rem 0 0; line-height: 1.5; }

/* ── Collapsed header (TTM themes): brand + burger only; the topbar's
      action buttons live in the menu (theme.js proxies them) ── */
html[data-ttm-theme] .topbar .nav-group,
html[data-ttm-theme] .topbar #seg-manage {
  display: none;
}
html[data-ttm-theme] .topbar { overflow: visible; }
.ttm-menu__action {
  width: 100%;
  text-align: left;
  background: none;
  font: inherit;
  cursor: pointer;
}

/* ══ Page scaffolding — shared chrome for every page on this site ══
   (spec: layout lives in the component library; pages carry no inline
   styles and no duplicated <style> blocks) */
* { box-sizing: border-box; }
/* focus and scroll-into-view targets clear the sticky sitebar */
html { scroll-padding-top: 4.5rem; }
body.ttm-page {
  margin: 0;
  background: var(--ttm-bg);
  color: var(--ttm-text);
  font: 400 var(--ttm-fs-small)/1.55 var(--ttm-font-sans);
  padding: 1.5rem 1.25rem 4rem;
}
.ttm-main { max-width: 64rem; margin: 0 auto; }
.ttm-header { display: flex; align-items: baseline; gap: .8rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
/* iridescent rule under the header — the brand shimmer as a themed border */
.ttm-header::after {
  content: "";
  flex-basis: 100%;
  height: 2px;
  border-radius: 1px;
  background: linear-gradient(120deg,
    var(--ttm-irid-a), var(--ttm-irid-b), var(--ttm-irid-c),
    var(--ttm-irid-d), var(--ttm-irid-e), var(--ttm-irid-a));
  background-size: 400% 400%;
  animation: ttm-iridescence var(--ttm-anim-shimmer) ease infinite;
}
@keyframes ttm-iridescence {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
@media (prefers-reduced-motion: reduce) {
  .ttm-header::after { animation: none; }
}
.ttm-header h1 { font-size: var(--ttm-fs-h3); font-weight: 600; margin: 0; }
.ttm-crumb { font-family: var(--ttm-font-mono); font-size: var(--ttm-fs-caption); color: var(--ttm-text-muted); }
.ttm-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); grid-auto-flow: dense; gap: var(--ttm-spacing-md); }
.ttm-grid--wide { grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.full { grid-column: 1 / -1; }
.ttm-row { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: .7rem; }
.ttm-note { font-size: var(--ttm-fs-caption); color: var(--ttm-text-muted); }
.ttm-card__title {
  font: 600 var(--ttm-fs-caption)/1.3 var(--ttm-font-mono);
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ttm-text-muted);
  margin: 0 0 .5rem;
}
.ttm-footer {
  margin-top: 2.5rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--ttm-border);
  text-align: center;
  font: 400 var(--ttm-fs-small) var(--ttm-font-mono);
  color: var(--ttm-text-muted);
}
:focus-visible { outline: 2px solid var(--ttm-focus); outline-offset: 2px; }
::selection { background: var(--ttm-control); color: var(--ttm-on-accent); }

/* ── ttm-skip — skip-to-content link, first tab stop on every page ── */
.ttm-skip {
  position: fixed;
  top: var(--ttm-spacing-sm, .5rem);
  left: var(--ttm-spacing-sm, .5rem);
  z-index: calc(var(--z-overlay) + 1);
  padding: .55rem .9rem;
  background: var(--ttm-surface);
  color: var(--ttm-text);
  border: 1.5px solid var(--ttm-focus);
  border-radius: var(--radius-sm);
  font: 600 var(--ttm-fs-caption) var(--ttm-font-mono);
  text-decoration: none;
  transform: translateY(calc(-100% - 2rem));
}
.ttm-skip:focus-visible { transform: none; }
/* the skip target takes focus programmatically; never draw a ring on the page body */
.ttm-main:focus { outline: none; }
@media (prefers-reduced-motion: reduce) { * { transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; } }

/* ── layout utilities — the sanctioned way to compose without inline styles ── */
.ttm-inline { display: flex; align-items: center; gap: var(--ttm-spacing-sm); flex-wrap: wrap; }
.ttm-gap-top { margin-top: var(--ttm-spacing-md); }
.ttm-gap-top-sm { margin-top: var(--ttm-spacing-sm); }
.ttm-gap-bottom { margin-bottom: var(--ttm-spacing-md); }
.ttm-grow { flex: 1; }
.ttm-sans { font-family: var(--ttm-font-sans); }
.ttm-serif { font-family: var(--ttm-font-serif); }
.ttm-mono { font-family: var(--ttm-font-mono); }

/* badge accent modifiers — brand hue as data, not inline style */
.ttm-badge[data-ttm-accent="pink"] { color: var(--ttm-pink); border-color: var(--ttm-pink); }
.ttm-badge[data-ttm-accent="lime"] { color: var(--ttm-lime); border-color: var(--ttm-lime); }
.ttm-badge[data-ttm-accent="cyan"] { color: var(--ttm-cyan); border-color: var(--ttm-cyan); }
.ttm-badge[data-ttm-accent="hot-red"] { color: var(--ttm-hot-red); border-color: var(--ttm-hot-red); }
.ttm-badge[data-ttm-accent="goldenrod"] { color: var(--ttm-goldenrod); border-color: var(--ttm-goldenrod); }

/* verdict inks (test bench) — part of the system, not page-local CSS */
.ttm-pass { color: var(--ttm-success); font-weight: 700; }
.ttm-fail { color: var(--ttm-danger); font-weight: 700; }
.ttm-form label.ttm-note { display: block; margin: .55rem 0 .15rem; }
.ttm-form .ttm-input { width: 100%; box-sizing: border-box; }
.ttm-swatch-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--ttm-spacing-sm); }
.ttm-swatch-grid label { display: flex; flex-direction: column; gap: var(--ttm-spacing-xs); align-items: center; }
.ttm-select { position: relative; display: inline-block; }

/* ── ttm-input — mono text/url field, pairs with buttons in a ttm-srcbar ── */
.ttm-srcbar { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-bottom: 1.2rem; }
.ttm-input {
  background: var(--ttm-surface-alt);
  color: var(--ttm-text);
  border: 1px solid var(--ttm-border);
  border-radius: var(--radius-sm);
  font: 400 var(--ttm-fs-small) var(--ttm-font-mono);
  padding: 0 .7rem;
  height: 40px;
}
.ttm-srcbar .ttm-input { flex: 1 1 18rem; min-width: 0; }
textarea.ttm-input { height: auto; min-height: 6rem; padding: .55rem .7rem; resize: vertical; width: 100%; box-sizing: border-box; }

/* ── ttm-kv — label/value rows inside cards ── */
.ttm-kv { display: flex; justify-content: space-between; gap: .8rem; padding: .3rem 0; border-bottom: 1px solid var(--ttm-border-subtle); }
.ttm-kv:last-child { border-bottom: none; }
.ttm-kv .k { color: var(--ttm-text-secondary); }
.ttm-kv .v { font-family: var(--ttm-font-mono); }

/* ── ttm-table — data tables (admin) ── */
.ttm-tablewrap { overflow-x: auto; }
.ttm-table { width: 100%; border-collapse: collapse; font-size: var(--ttm-fs-caption); }
.ttm-table th {
  text-align: left;
  font-family: var(--ttm-font-mono);
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ttm-text-faint);
  padding: .35rem .5rem;
  border-bottom: 1px solid var(--ttm-border);
}
.ttm-table td { padding: .35rem .5rem; border-bottom: 1px solid var(--ttm-border-subtle); color: var(--ttm-text-secondary); }
.ttm-table td.mono { font-family: var(--ttm-font-mono); }

/* ── ttm-receipt — preformatted machine output (JSON, logs) ── */
.ttm-receipt {
  background: var(--ttm-bg-alt);
  border: 1px solid var(--ttm-border);
  border-radius: var(--radius-sm);
  font: 400 .74rem/1.5 var(--ttm-font-mono);
  padding: .8rem 1rem;
  overflow-x: auto;
}

/* ── ttm-sensor — hardware sensor rows (dashboard) ── */
.ttm-hw { display: flex; flex-direction: column; gap: .15rem; }
.ttm-hw h3 {
  margin: .6rem 0 .3rem;
  font: 600 var(--ttm-fs-caption)/1 var(--ttm-font-mono);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ttm-text-faint);
}
.ttm-sensor {
  display: grid;
  /* name · spark · meter · value · min · max — the app's data columns */
  grid-template-columns: 1fr 4.5rem 5rem 5.8rem 4.6rem 4.6rem;
  gap: .6rem;
  align-items: center;
  padding: .28rem 0;
  border-bottom: 1px solid var(--ttm-border-subtle);
  font-size: var(--ttm-fs-small);
}
.ttm-sensor:last-child { border-bottom: none; }
.ttm-sensor .nm { color: var(--ttm-text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ttm-sensor .val { font-family: var(--ttm-font-mono); font-variant-numeric: tabular-nums; text-align: right; }
.ttm-sensor .mn, .ttm-sensor .mx {
  font: 400 var(--ttm-fs-caption) var(--ttm-font-mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--ttm-text-faint);
}
/* the unfilled track is a lighter step of the fill's own ramp, so state
   reads across the whole bar, not just the filled part */
.ttm-sensor .meterbar {
  height: 8px;
  background: color-mix(in srgb, var(--ttm-lime) 14%, var(--ttm-surface-alt));
  border-radius: 4px;
  overflow: hidden;
}
.ttm-sensor .meterbar i {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: var(--ttm-lime);
  transition: width var(--ttm-transition-slow);
}
.ttm-sensor--group { border-bottom: none; }
.ttm-sensor--group .nm { color: var(--ttm-text-faint); font-size: var(--ttm-fs-caption); text-transform: uppercase; letter-spacing: .06em; }
.ttm-sensor--warn .meterbar { background: color-mix(in srgb, var(--ttm-warning) 16%, var(--ttm-surface-alt)); }
.ttm-sensor--hot .meterbar { background: color-mix(in srgb, var(--ttm-danger) 16%, var(--ttm-surface-alt)); }
.ttm-sensor--warn .meterbar i { background: var(--ttm-warning); }
.ttm-sensor--hot .meterbar i { background: var(--ttm-danger); }
.ttm-sensor--warn .val { color: var(--ttm-warning); }
.ttm-sensor--hot .val { color: var(--ttm-danger); }

/* ── GUI feature parity (dashboard) — the desktop application's View menu ──
   column variants: name+spark+meter always render; value/min/max toggle
   (View → Columns), the body class picks the matching grid template */
.gui-cols-3 .ttm-sensor { grid-template-columns: 1fr 4.5rem 5rem; }
.gui-cols-4 .ttm-sensor { grid-template-columns: 1fr 4.5rem 5rem 5.8rem; }
.gui-cols-5 .ttm-sensor { grid-template-columns: 1fr 4.5rem 5rem 5.8rem 4.6rem; }

/* hidden sensors render dimmed when View → Show Hidden Sensors is on */
.ttm-sensor.is-hidden { opacity: .45; }

/* manage mode — the desktop context menu folded into the name cell
   (scoped: outside manage mode the name keeps its ellipsis behavior) */
.gui-manage .ttm-sensor .nm { display: flex; align-items: center; gap: .35rem; min-width: 0; white-space: normal; }
.ttm-sensor .ctl { display: inline-flex; gap: 2px; flex: none; margin-left: auto; }
.ttm-minibtn {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: none;
  border: 1px solid var(--ttm-border);
  border-radius: var(--radius-sm);
  color: var(--ttm-text-muted);
  cursor: pointer;
}
.ttm-minibtn svg { width: 15px; height: 15px; display: block; }
.ttm-minibtn:hover { background: var(--ttm-wash-hover); color: var(--ttm-text); }
.ttm-minibtn[aria-pressed="true"] { color: var(--ttm-control); border-color: var(--ttm-control); }
.ttm-sensor .ttm-rename { height: 32px; flex: 1; min-width: 0; }

/* toolbar option cluster (°F · hidden · columns) */
.ttm-gui-opts { display: inline-flex; align-items: center; gap: .45rem; flex-wrap: wrap; margin-left: auto; }
.ttm-gui-opts .ttm-note { margin-right: .35rem; }

/* plot (GUI/PlotPanel.cs) — series in the brand hues, normalized per range */
.ttm-plot {
  width: 100%;
  height: 200px;
  margin-top: .5rem;
  background: var(--ttm-bg-alt);
  border: 1px solid var(--ttm-border-subtle);
  border-radius: var(--radius-sm);
}
.plot-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.ttm-plotchip { display: inline-flex; align-items: center; gap: .4rem; font: 400 var(--ttm-fs-caption) var(--ttm-font-mono); color: var(--ttm-text-secondary); }
.ttm-plotchip i { width: .65rem; height: .65rem; border-radius: 50%; background: currentColor; }
/* series hues after the chip base so the legend wears its series color */
.plot-s0 { stroke: var(--ttm-pink); color: var(--ttm-pink); }
.plot-s1 { stroke: var(--ttm-cyan); color: var(--ttm-cyan); }
.plot-s2 { stroke: var(--ttm-lime); color: var(--ttm-lime); }
.plot-s3 { stroke: var(--ttm-goldenrod); color: var(--ttm-goldenrod); }
.plot-s4 { stroke: var(--ttm-hot-red); color: var(--ttm-hot-red); }

/* gadget (GUI/SensorGadget.cs) — compact always-visible readout */
.ttm-gadget {
  position: fixed;
  left: 1.25rem;
  bottom: 1.25rem;
  z-index: var(--z-header);
  width: min(92vw, 16rem);
  background: var(--ttm-surface);
  border: 1.5px solid var(--ttm-border);
  border-radius: var(--radius-md);
  box-shadow: var(--ttm-shadow);
  padding: .6rem .8rem .7rem;
  font-family: var(--ttm-font-sans);
}
.ttm-gadget__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .2rem; }
.ttm-gadget__head .ttm-card__title { margin: 0; }
.ttm-gadget__close {
  width: 32px;
  height: 32px;
  margin: -.3rem -.4rem -.3rem 0;
  background: none;
  border: none;
  color: var(--ttm-text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.ttm-gadget__close:hover { color: var(--ttm-text); background: var(--ttm-wash-hover); }
/* inline variant — the same component in flow (gallery docs, embeds) */
.ttm-gadget--inline { position: static; width: auto; max-width: 16rem; }

/* fresh reading: one soft flash, token-timed; reduced motion collapses it */
@keyframes ttm-val-fresh { from { background: var(--ttm-wash-hover); } to { background: transparent; } }
.ttm-sensor .val.is-fresh { animation: ttm-val-fresh var(--ttm-anim-flash) ease-out 1; border-radius: var(--radius-sm); }

/* narrow screens: sparkline and min/max cede their columns before anything
   truncates — the value column is the one that always survives */
@media (max-width: 560px) {
  .ttm-sensor { grid-template-columns: 1fr 4rem 5.4rem; }
  .ttm-sensor .spark, .ttm-sensor .mn, .ttm-sensor .mx { display: none; }
  .ttm-sensor--group { grid-template-columns: 1fr; }
}

/* ── ttm-hero + ttm-tile — the dashboard's apex: machine identity, then
      stat tiles (label · value · trend). One hero figure per view. ── */
.ttm-hero { background: linear-gradient(160deg, var(--ttm-surface), var(--ttm-bg-alt)); }
.ttm-hero__head {
  display: flex;
  align-items: center;
  gap: var(--ttm-spacing-md);
  flex-wrap: wrap;
  margin-bottom: var(--ttm-spacing-md);
}
.ttm-hero__head b { font: 600 var(--ttm-fs-h3)/1.2 var(--ttm-font-mono); }
.ttm-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: var(--ttm-spacing-md);
}
.ttm-tile {
  display: flex;
  flex-direction: column;
  gap: var(--ttm-spacing-xs);
  padding: var(--ttm-spacing-md);
  background: var(--ttm-wash);
  border: 1px solid var(--ttm-border-subtle);
  border-radius: var(--radius-md);
  min-width: 0;
}
.ttm-tile__label {
  font: 400 var(--ttm-fs-caption) var(--ttm-font-mono);
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ttm-text-muted);
}
/* big standalone values read in proportional figures; tabular is for columns */
.ttm-tile__value {
  font: 600 var(--ttm-fs-h2)/1.1 var(--ttm-font-mono);
  color: var(--ttm-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ttm-tile--hero .ttm-tile__value { font-size: var(--ttm-fs-h1); }
.ttm-tile__value.warn { color: var(--ttm-warning); }
.ttm-tile__value.hot { color: var(--ttm-danger); }
.ttm-tile__sub { font: 400 var(--ttm-fs-caption) var(--ttm-font-mono); color: var(--ttm-text-muted); }
.ttm-tile__trend { width: 100%; height: 32px; margin-top: auto; }

/* ── spark — 2px line in the de-emphasis ink, end dot carries "now";
      no axes, no grid: the row label + value are the chart furniture ── */
.spark, .ttm-tile__trend { overflow: visible; }
.spark { width: 100%; height: 20px; }
.spark__line, .ttm-tile__trend .spark__line {
  fill: none;
  stroke: var(--ttm-text-faint);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}
.spark__dot { fill: var(--ttm-control); }
.spark__dot--warn { fill: var(--ttm-warning); }
.spark__dot--hot { fill: var(--ttm-danger); }

/* ── ttm-statrow — machine overview strip (dashboard hierarchy apex) ── */
.ttm-statrow { display: flex; flex-wrap: wrap; gap: var(--ttm-spacing-md) var(--ttm-spacing-xl); align-items: center; }
.ttm-statrow .stat { display: inline-flex; align-items: baseline; gap: var(--ttm-spacing-sm); }
.ttm-statrow .k { font: 400 var(--ttm-fs-caption) var(--ttm-font-mono); color: var(--ttm-text-muted); text-transform: uppercase; letter-spacing: .06em; }
.ttm-statrow b { font: 600 var(--ttm-fs-h4)/1.2 var(--ttm-font-mono); color: var(--ttm-text); }
.ttm-statrow b.warn { color: var(--ttm-warning); }
.ttm-statrow b.hot { color: var(--ttm-danger); }

/* ── ttm-details — native disclosure, token-styled ── */
.ttm-details > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: var(--ttm-spacing-sm); }
.ttm-details > summary::-webkit-details-marker { display: none; }
.ttm-details > summary::before { content: "▸"; color: var(--ttm-text-muted); transition: transform var(--ttm-transition-fast); }
.ttm-details[open] > summary::before { transform: rotate(90deg); }
.ttm-details > summary h2 { margin: 0; }
.ttm-details > summary:focus-visible { outline: 2px solid var(--ttm-focus); outline-offset: 2px; }

/* collapsible hardware blocks reuse the pattern at h3 level */
details.ttm-hw > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: var(--ttm-spacing-sm); }
details.ttm-hw > summary::-webkit-details-marker { display: none; }
details.ttm-hw > summary .dot { width: .6rem; height: .6rem; border-radius: 50%; background: var(--ttm-success); flex: none; }
details.ttm-hw > summary .dot.warn { background: var(--ttm-warning); }
details.ttm-hw > summary .dot.hot { background: var(--ttm-danger); }
details.ttm-hw > summary .n { margin-left: auto; font: 400 var(--ttm-fs-caption) var(--ttm-font-mono); color: var(--ttm-text-muted); }
details.ttm-hw > summary:focus-visible { outline: 2px solid var(--ttm-focus); outline-offset: 2px; }

/* ── ttm-modetoggle — light/dark flip in the sitebar (brand pattern) ── */
.ttm-modetoggle {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 50%;
  border: 1.5px solid var(--ttm-border);
  background: var(--ttm-surface);
  color: var(--ttm-text);
  cursor: pointer;
  transition: background var(--ttm-transition-fast), transform var(--ttm-transition-fast);
}
.ttm-modetoggle svg { width: 20px; height: 20px; display: block; }
.ttm-modetoggle:hover { background: var(--ttm-wash-hover); transform: rotate(15deg); }

/* ── ttm-sitebar — the universal site header (theme.js, every page):
      pure chrome, tools only (mode toggle + burger). No text — each
      page's hero header is the identity, and all navigation lives in
      the hamburger menu.
      Sticky; bleeds across body.ttm-page's padding so it spans full width. ── */
.ttm-sitebar {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  margin: -1.5rem -1.25rem 1.4rem;
  padding: .5rem 1.25rem;
  background: color-mix(in srgb, var(--ttm-bg) 92%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--ttm-border);
}
.ttm-sitebar__inner {
  max-width: 64rem;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: .9rem;
}
.ttm-sitebar__tools { margin-left: auto; display: inline-flex; align-items: center; gap: .5rem; min-height: 44px; }

/* ── visual pop — glow where the data is alive, gradients where it moves ── */
.ttm-badge--live {
  color: var(--ttm-success);
  border-color: var(--ttm-success);
  box-shadow: 0 0 12px color-mix(in srgb, var(--ttm-success) 45%, transparent);
}
/* heartbeat dot on the live badge — the room-across signal that data flows */
.ttm-badge--live::before {
  content: "";
  display: inline-block;
  width: .45em;
  height: .45em;
  margin-right: .45em;
  border-radius: 50%;
  background: var(--ttm-success);
  animation: ttm-pulse var(--ttm-anim-pulse) ease-in-out infinite;
}
@keyframes ttm-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .35; }
}
@media (prefers-reduced-motion: reduce) {
  .ttm-badge--live::before { animation: none; }
}
details.ttm-hw { transition: background var(--ttm-transition-fast); border-radius: var(--radius-sm); }
details.ttm-hw:hover { background: var(--ttm-wash); }
.ttm-sensor .meterbar i {
  background: linear-gradient(90deg, var(--ttm-cyan), var(--ttm-lime));
}
.ttm-sensor--warn .meterbar i { background: var(--ttm-warning); }
.ttm-sensor--hot .meterbar i {
  background: var(--ttm-danger);
  box-shadow: 0 0 8px color-mix(in srgb, var(--ttm-danger) 60%, transparent);
}
details.ttm-hw > summary:hover { background: var(--ttm-wash); border-radius: var(--radius-sm); }
.ttm-card { transition: border-color var(--ttm-transition-fast); }
.ttm-card:hover { border-color: color-mix(in srgb, var(--ttm-control) 35%, var(--ttm-border)); }

/* ── mobile scale — one standard pass, no page improvises its own ── */
@media (max-width: 560px) {
  .ttm-header h1 { font-size: var(--ttm-fs-h4); }
  .ttm-card { padding: .9rem 1rem; }
  .ttm-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
  .ttm-tile { padding: .7rem .8rem; }
  .ttm-tile__value { font-size: var(--ttm-fs-h3); }
  .ttm-tile--hero { grid-column: 1 / -1; }
  .ttm-tile--hero .ttm-tile__value { font-size: var(--ttm-fs-h2); }
}
