/* ============================================================================
   Under the Cloak — visual system

   The palette is metallurgical, and it carries meaning rather than decorating.
   Brass is a held key. Verdigris is what brass becomes once it is exposed —
   so it marks the values that are public on purpose. Rust is failure.
   Steel is structure. Nothing is coloured for flavour; if something is brass,
   it is because a person is holding it.
   ========================================================================== */

:root {
  /* ground */
  --ink:        #0E1116;
  --ink-2:      #141922;
  --ink-3:      #1B212C;
  --ink-4:      #222A37;

  /* structure */
  --steel:      #29323F;
  --steel-lit:  #3B4757;

  /* semantic: custody */
  --brass:      #C9A227;
  --brass-lit:  #E8C65A;
  --brass-dim:  #6B5714;
  --verdigris:  #4FB3A5;
  --verdigris-dim: #24534D;
  --rust:       #C05B4D;
  --rust-dim:   #5A2A24;

  /* text */
  --paper:      #E8E6E1;
  --paper-dim:  #99A1B0;
  --paper-faint:#657084;

  /* type */
  --sans: 'Archivo', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  /* metrics */
  --rail-h: 54px;
  --nav-w: 236px;
  --insp-w: 380px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  font-variation-settings: 'wdth' 100, 'wght' 400;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* A faint machined texture so the ground is not a flat void. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    radial-gradient(ellipse 90% 55% at 50% -10%, rgba(201, 162, 39, 0.07), transparent 70%),
    linear-gradient(to bottom, rgba(79, 179, 165, 0.035), transparent 40%);
}

::selection { background: var(--brass); color: var(--ink); }

/* ── scrollbars ──────────────────────────────────────────────────────────── */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--steel);
  border: 3px solid transparent;
  background-clip: content-box;
  border-radius: 99px;
}
*::-webkit-scrollbar-thumb:hover { background: var(--steel-lit); background-clip: content-box; }

/* ── app shell ───────────────────────────────────────────────────────────── */
.shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: var(--rail-h) 1fr;
  grid-template-columns: var(--nav-w) 1fr;
  grid-template-areas: 'rail rail' 'nav main';
  height: 100vh;
  min-width: 0;
  overflow: hidden;
}

.rail {
  grid-area: rail;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 18px;
  min-width: 0;
  overflow: hidden;
  border-bottom: 1px solid var(--steel);
  background: linear-gradient(to bottom, var(--ink-2), var(--ink));
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}

/* The mono mark is white on transparent, so it only works on a dark ground. */
.brand-logo {
  width: 23px;
  height: 23px;
  flex: none;
  display: block;
}
.brand-mark {
  white-space: nowrap;
  font-family: var(--sans);
  font-variation-settings: 'wdth' 112, 'wght' 700;
  font-size: 15px;
  letter-spacing: 0.01em;
  color: var(--paper);
}
.brand-sub {
  font-size: 11.5px;
  color: var(--paper-faint);
  font-variation-settings: 'wdth' 92, 'wght' 400;
}

.rail-spacer { flex: 1; }

.rail-note {
  font-size: 11.5px;
  color: var(--paper-faint);
  display: flex;
  align-items: center;
  gap: 7px;
}

/* ── nav ─────────────────────────────────────────────────────────────────── */
.nav {
  grid-area: nav;
  border-right: 1px solid var(--steel);
  background: var(--ink-2);
  overflow-y: auto;
  padding: 14px 0 28px;
}

.nav-group + .nav-group { margin-top: 22px; }

.nav-group-label {
  padding: 0 18px 7px;
  font-size: 11px;
  color: var(--paper-faint);
  font-variation-settings: 'wdth' 90, 'wght' 500;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 8px 18px;
  border: 0;
  background: none;
  color: var(--paper-dim);
  font: inherit;
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
  position: relative;
  transition: color 0.14s var(--ease), background 0.14s var(--ease);
}
.nav-item:hover { color: var(--paper); background: rgba(255, 255, 255, 0.028); }
.nav-item[aria-current='true'] {
  color: var(--paper);
  background: rgba(201, 162, 39, 0.07);
  font-variation-settings: 'wdth' 100, 'wght' 600;
}
.nav-item[aria-current='true']::before {
  content: '';
  position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 2px;
  background: var(--brass);
}
.nav-item-hint {
  margin-left: auto;
  font-size: 10.5px;
  color: var(--paper-faint);
  font-variation-settings: 'wdth' 88;
}

.nav-icon { width: 15px; height: 15px; flex: none; opacity: 0.85; }

/* ── main / stage ────────────────────────────────────────────────────────── */
.main {
  grid-area: main;
  display: grid;
  grid-template-columns: 1fr 0;
  min-width: 0;
  min-height: 0;
  transition: grid-template-columns 0.28s var(--ease);
}
.main[data-inspector='open'] { grid-template-columns: 1fr var(--insp-w); }

.stage {
  overflow-y: auto;
  min-width: 0;
  padding: 30px 36px 72px;
}

.stage-head { max-width: 74ch; margin-bottom: 26px; }

.stage-title {
  font-size: clamp(22px, 2.6vw, 31px);
  font-variation-settings: 'wdth' 118, 'wght' 700;
  line-height: 1.1;
  letter-spacing: -0.015em;
  margin: 0 0 9px;
}

.stage-lede {
  margin: 0;
  color: var(--paper-dim);
  font-size: 15px;
  line-height: 1.62;
  max-width: 68ch;
}

.section { margin-top: 38px; }
.section-title {
  font-size: 12.5px;
  color: var(--paper-dim);
  font-variation-settings: 'wdth' 96, 'wght' 600;
  margin: 0 0 13px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--steel);
}

/* ── inspector ───────────────────────────────────────────────────────────── */
.inspector {
  border-left: 1px solid var(--steel);
  background: var(--ink-2);
  overflow-y: auto;
  min-width: 0;
}
.main[data-inspector='closed'] .inspector { display: none; }

.insp-head {
  position: sticky;
  top: 0;
  background: var(--ink-2);
  border-bottom: 1px solid var(--steel);
  padding: 16px 18px 13px;
  z-index: 2;
}
.insp-kicker {
  font-size: 11px;
  color: var(--paper-faint);
  margin-bottom: 5px;
  font-variation-settings: 'wdth' 90;
}
.insp-title {
  margin: 0;
  font-size: 17px;
  font-variation-settings: 'wdth' 108, 'wght' 660;
  line-height: 1.25;
}
.insp-close {
  position: absolute;
  top: 13px; right: 13px;
  width: 25px; height: 25px;
  display: grid; place-items: center;
  border: 1px solid var(--steel);
  border-radius: 5px;
  background: transparent;
  color: var(--paper-faint);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  transition: color 0.14s, border-color 0.14s;
}
.insp-close:hover { color: var(--paper); border-color: var(--steel-lit); }

.insp-body { padding: 16px 18px 40px; }
.insp-section + .insp-section { margin-top: 20px; }
.insp-label {
  font-size: 11px;
  color: var(--paper-faint);
  margin-bottom: 6px;
  font-variation-settings: 'wdth' 90, 'wght' 500;
}
.insp-text { margin: 0; color: var(--paper-dim); line-height: 1.6; font-size: 13.5px; }
.insp-text + .insp-text { margin-top: 9px; }
.insp-text strong { color: var(--paper); font-variation-settings: 'wght' 600; }

/* ── data rows ───────────────────────────────────────────────────────────── */
.drow {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid rgba(41, 50, 63, 0.55);
  font-size: 13px;
}
.drow:last-child { border-bottom: 0; }
.drow dt { color: var(--paper-faint); }
.drow dd { margin: 0; color: var(--paper); min-width: 0; word-break: break-word; }

/* ── code ────────────────────────────────────────────────────────────────── */
.mono { font-family: var(--mono); font-size: 0.92em; }

.code-ref {
  display: inline-block;
  max-width: 100%;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--verdigris);
  background: rgba(79, 179, 165, 0.09);
  border: 1px solid var(--verdigris-dim);
  border-radius: 4px;
  padding: 2px 7px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}

.code-block {
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.66;
  color: var(--paper);
  background: var(--ink);
  border: 1px solid var(--steel);
  border-left: 2px solid var(--brass-dim);
  border-radius: 5px;
  padding: 11px 13px;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
}

/* ── chips ───────────────────────────────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  padding: 2.5px 8px;
  border-radius: 99px;
  border: 1px solid var(--steel);
  color: var(--paper-dim);
  white-space: nowrap;
  font-variation-settings: 'wdth' 94, 'wght' 500;
}
.chip-brass { color: var(--brass-lit); border-color: var(--brass-dim); background: rgba(201, 162, 39, 0.08); }
.chip-verd  { color: var(--verdigris); border-color: var(--verdigris-dim); background: rgba(79, 179, 165, 0.08); }
.chip-rust  { color: var(--rust); border-color: var(--rust-dim); background: rgba(192, 91, 77, 0.08); }

.chip-dot { width: 5px; height: 5px; border-radius: 99px; background: currentColor; flex: none; }

/* ── panels ──────────────────────────────────────────────────────────────── */
.panel {
  background: var(--ink-2);
  border: 1px solid var(--steel);
  border-radius: 8px;
  padding: 17px 19px;
}
.panel-tight { padding: 13px 15px; }

.panel-brass { border-color: var(--brass-dim); background: rgba(201, 162, 39, 0.045); }
.panel-rust  { border-color: var(--rust-dim);  background: rgba(192, 91, 77, 0.045); }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(268px, 1fr)); gap: 13px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(212px, 1fr)); gap: 13px; }

/* ── the boundary diagram (map view) ─────────────────────────────────────── */
.boundary {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 132px 1fr;
  gap: 0;
  align-items: stretch;
  border: 1px solid var(--steel);
  border-radius: 10px;
  overflow: hidden;
  background: var(--ink-2);
}
@media (max-width: 900px) {
  .boundary { grid-template-columns: 1fr; }
}

.zone-side { padding: 20px; min-width: 0; }

.zone-device {
  background:
    radial-gradient(ellipse 80% 100% at 20% 50%, rgba(201, 162, 39, 0.09), transparent 72%),
    var(--ink-2);
  border-right: 1px solid var(--steel);
}
.zone-server {
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,0.014) 0 2px, transparent 2px 7px),
    var(--ink);
  border-left: 1px solid var(--steel);
}
@media (max-width: 900px) {
  .zone-device, .zone-server { border: 0; border-bottom: 1px solid var(--steel); }
}

.zone-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.zone-name {
  font-size: 13px;
  font-variation-settings: 'wdth' 104, 'wght' 650;
  margin: 0;
}
.zone-blurb { font-size: 12.5px; color: var(--paper-faint); margin: 0 0 15px; line-height: 1.55; }

.zone-items { display: flex; flex-direction: column; gap: 6px; }

.zone-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  text-align: left;
  padding: 8px 11px;
  border-radius: 6px;
  border: 1px solid var(--steel);
  background: var(--ink-3);
  color: var(--paper);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  transition: border-color 0.15s var(--ease), transform 0.15s var(--ease), background 0.15s var(--ease);
}
.zone-item:hover { border-color: var(--steel-lit); background: var(--ink-4); transform: translateX(2px); }
.zone-item .zi-name { font-variation-settings: 'wght' 550; }
.zone-item .zi-form { margin-left: auto; font-size: 11px; color: var(--paper-faint); font-family: var(--mono); }

.zone-item.is-held  { border-left: 2px solid var(--brass); }
.zone-item.is-opaque { border-left: 2px solid var(--steel-lit); color: var(--paper-dim); }
.zone-item.is-public { border-left: 2px solid var(--verdigris); }

/* the wire */
.wire {
  position: relative;
  display: grid;
  place-items: center;
  background: var(--ink);
  overflow: hidden;
}
@media (max-width: 900px) {
  .wire { min-height: 118px; }
}

.wire-rule {
  position: absolute;
  top: 0; bottom: 0; left: 50%;
  width: 1px;
  background: repeating-linear-gradient(to bottom, var(--steel) 0 5px, transparent 5px 11px);
}

.wire-label {
  position: relative;
  font-size: 10.5px;
  color: var(--paper-faint);
  writing-mode: vertical-rl;
  letter-spacing: 0.08em;
  font-variation-settings: 'wdth' 88;
  background: var(--ink);
  padding: 9px 0;
}
@media (max-width: 900px) {
  .wire-label { writing-mode: horizontal-tb; padding: 0 9px; }
  .wire-rule { top: 50%; left: 0; right: 0; bottom: auto; width: auto; height: 1px;
    background: repeating-linear-gradient(to right, var(--steel) 0 5px, transparent 5px 11px); }
}

.packet {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 99px;
  background: var(--ink-3);
  border: 1px solid var(--brass-dim);
  color: var(--brass-lit);
  font-family: var(--mono);
  font-size: 11px;
  white-space: nowrap;
  box-shadow: 0 0 22px rgba(201, 162, 39, 0.22);
  animation: packet-fall 5.2s var(--ease) infinite;
}
@media (max-width: 900px) {
  .packet { animation-name: packet-slide; left: 0; top: 50%; }
}

@keyframes packet-fall {
  0%        { top: -14%; opacity: 0; }
  12%       { opacity: 1; }
  86%       { opacity: 1; }
  100%      { top: 104%; opacity: 0; }
}
@keyframes packet-slide {
  0%   { left: -22%; opacity: 0; transform: translateY(-50%); }
  12%  { opacity: 1; }
  86%  { opacity: 1; }
  100% { left: 104%; opacity: 0; transform: translateY(-50%); }
}

/* ── key graph ───────────────────────────────────────────────────────────── */
.graph-wrap {
  border: 1px solid var(--steel);
  border-radius: 10px;
  background: var(--ink-2);
  overflow: auto;
}
.graph-svg { display: block; min-width: 940px; }

.gnode { cursor: pointer; }
.gnode rect {
  fill: var(--ink-3);
  stroke: var(--steel);
  stroke-width: 1;
  transition: stroke 0.16s var(--ease), fill 0.16s var(--ease);
}
.gnode:hover rect { stroke: var(--steel-lit); fill: var(--ink-4); }
.gnode text { fill: var(--paper); font-size: 12px; font-variation-settings: 'wght' 550; pointer-events: none; }
.gnode .gsub { fill: var(--paper-faint); font-size: 10px; font-family: var(--mono); font-variation-settings: 'wght' 400; }

.gnode[data-kind='human']   rect { stroke: var(--brass-dim); }
.gnode[data-kind='data']    rect { stroke: var(--verdigris-dim); }
.gnode[data-keystone='true'] rect { stroke: var(--brass); fill: rgba(201, 162, 39, 0.09); }

.gnode[data-lit='true'] rect { stroke: var(--brass-lit); fill: rgba(201, 162, 39, 0.16); }
.gnode[data-lit='true'] text { fill: var(--paper); }
.gnode[data-dim='true'] { opacity: 0.26; }

.gedge {
  stroke: var(--steel-lit);
  stroke-width: 1.4;
  fill: none;
  marker-end: url(#arrow);
  transition: stroke 0.16s var(--ease), opacity 0.16s var(--ease);
}
.gedge[data-lit='true'] { stroke: var(--brass-lit); stroke-width: 2.1; marker-end: url(#arrow-lit); }
.gedge[data-dim='true'] { opacity: 0.16; }
.gedge[data-dashed='true'] { stroke-dasharray: 5 4; }

.gboundary {
  fill: none;
  stroke: var(--steel);
  stroke-width: 1;
  stroke-dasharray: 4 4;
}
.gboundary-label { fill: var(--paper-faint); font-size: 10.5px; font-variation-settings: 'wdth' 88; }

/* ── flow player ─────────────────────────────────────────────────────────── */
.flow-layout { display: grid; grid-template-columns: 236px 1fr; gap: 22px; align-items: start; }
@media (max-width: 980px) { .flow-layout { grid-template-columns: 1fr; } }

.flow-list { display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; }
@media (max-width: 980px) { .flow-list { position: static; flex-direction: row; flex-wrap: wrap; } }

.flow-tab {
  text-align: left;
  padding: 9px 12px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: none;
  color: var(--paper-dim);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s var(--ease);
}
.flow-tab:hover { color: var(--paper); background: rgba(255,255,255,0.03); }
.flow-tab[aria-selected='true'] {
  color: var(--paper);
  background: var(--ink-3);
  border-color: var(--steel);
  font-variation-settings: 'wght' 620;
}

.steps { display: flex; flex-direction: column; gap: 0; }

.step {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 15px;
  padding: 0 0 3px;
  position: relative;
  opacity: 0.34;
  transition: opacity 0.3s var(--ease);
}
.step[data-state='seen']   { opacity: 0.62; }
.step[data-state='active'] { opacity: 1; }

.step-gutter { display: flex; flex-direction: column; align-items: center; }

.step-dot {
  width: 11px; height: 11px;
  border-radius: 99px;
  border: 1.5px solid var(--steel-lit);
  background: var(--ink);
  margin-top: 5px;
  flex: none;
  transition: all 0.24s var(--ease);
}
.step[data-state='seen'] .step-dot   { background: var(--steel-lit); }
.step[data-state='active'] .step-dot {
  border-color: var(--brass);
  background: var(--brass);
  box-shadow: 0 0 0 4px rgba(201, 162, 39, 0.16);
}

.step-line { flex: 1; width: 1px; background: var(--steel); margin: 5px 0 0; min-height: 14px; }
.step:last-child .step-line { display: none; }

.step-body { padding-bottom: 20px; min-width: 0; }

.step-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; flex-wrap: wrap; }

.step-actor {
  font-size: 10.5px;
  padding: 1.5px 7px;
  border-radius: 4px;
  font-variation-settings: 'wdth' 90, 'wght' 600;
  border: 1px solid;
}
.step-actor[data-actor='user']   { color: var(--paper-dim);  border-color: var(--steel); }
.step-actor[data-actor='device'] { color: var(--brass-lit);  border-color: var(--brass-dim);  background: rgba(201,162,39,.08); }
.step-actor[data-actor='wire']   { color: var(--verdigris);  border-color: var(--verdigris-dim); background: rgba(79,179,165,.08); }
.step-actor[data-actor='server'] { color: var(--paper-faint); border-color: var(--steel); background: rgba(255,255,255,.02); }

.step-title { margin: 0 0 6px; font-size: 14.5px; font-variation-settings: 'wght' 620; line-height: 1.35; }
.step-detail { margin: 0; color: var(--paper-dim); font-size: 13.5px; line-height: 1.6; max-width: 66ch; }
.step-compute { margin: 9px 0 0; max-width: 80ch; }

.player {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 14px;
  border: 1px solid var(--steel);
  border-radius: 8px;
  background: var(--ink-2);
  margin-bottom: 20px;
  position: sticky;
  top: 0;
  z-index: 3;
}

.pbtn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 13px;
  border-radius: 6px;
  border: 1px solid var(--steel);
  background: var(--ink-3);
  color: var(--paper);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.14s var(--ease);
}
.pbtn:hover:not(:disabled) { border-color: var(--steel-lit); background: var(--ink-4); }
.pbtn:disabled { opacity: 0.38; cursor: not-allowed; }
.pbtn-primary {
  border-color: var(--brass-dim);
  background: rgba(201, 162, 39, 0.13);
  color: var(--brass-lit);
  font-variation-settings: 'wght' 600;
}
.pbtn-primary:hover:not(:disabled) { background: rgba(201, 162, 39, 0.2); border-color: var(--brass); }

.pcount { margin-left: auto; font-family: var(--mono); font-size: 12px; color: var(--paper-faint); }

.ptrack { height: 2px; background: var(--steel); border-radius: 99px; flex: 1; max-width: 190px; overflow: hidden; }
.pfill { height: 100%; background: var(--brass); transition: width 0.3s var(--ease); }

/* ── matrix ──────────────────────────────────────────────────────────────── */
.matrix { width: 100%; border-collapse: collapse; font-size: 13px; }
.matrix th, .matrix td { padding: 10px 13px; text-align: left; border-bottom: 1px solid var(--steel); }
.matrix thead th {
  color: var(--paper-dim);
  font-variation-settings: 'wdth' 96, 'wght' 600;
  font-size: 12.5px;
  border-bottom-color: var(--steel-lit);
}
.matrix tbody tr { transition: background 0.13s; }
.matrix tbody tr:hover { background: rgba(255,255,255,0.022); }
.matrix td.cell-yes { color: var(--brass-lit); }
.matrix td.cell-no  { color: var(--paper-faint); opacity: 0.45; }
.matrix .rowhead { font-variation-settings: 'wght' 620; color: var(--paper); }

/* ── catalogue ───────────────────────────────────────────────────────────
   Built for scanning, not reading: tighter rows, smaller type, and a header
   that stays put so the columns never lose their labels.                   */
.cat-controls {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 13px;
  flex-wrap: wrap;
}

.cat-input {
  flex: 1;
  min-width: 190px;
  border: 1px solid var(--steel);
  border-radius: 7px;
  background: var(--ink-2);
  color: var(--paper);
  font: inherit;
  font-size: 14px;
  padding: 9px 13px;
  outline: none;
  transition: border-color 0.14s var(--ease);
}
.cat-input:focus { border-color: var(--brass-dim); }
.cat-input::placeholder { color: var(--paper-faint); }

.cat-wrap {
  border: 1px solid var(--steel);
  border-radius: 9px;
  overflow: auto;
  max-height: calc(100vh - 268px);
  background: var(--ink-2);
}

.cat {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  min-width: 900px;
}

.cat thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  text-align: left;
  padding: 8px 12px;
  background: var(--ink-3);
  color: var(--paper-dim);
  font-size: 11.5px;
  font-variation-settings: 'wdth' 94, 'wght' 600;
  border-bottom: 1px solid var(--steel-lit);
  white-space: nowrap;
}

.cat td {
  padding: 6px 12px;
  border-bottom: 1px solid rgba(41, 50, 63, 0.5);
  vertical-align: top;
  line-height: 1.45;
}

.cat-row { transition: background 0.1s; }
.cat-row[data-clickable='true'] { cursor: pointer; }
.cat-row:hover { background: rgba(255, 255, 255, 0.03); }
.cat-row[data-clickable='true']:hover .cat-name { color: var(--brass-lit); }

.cat-name {
  color: var(--paper);
  font-variation-settings: 'wght' 580;
  transition: color 0.12s;
}
.cat-name.mono { font-size: 12px; font-variation-settings: normal; }

.cat-dim { color: var(--paper-faint); font-size: 11.5px; }
.cat-note { color: var(--paper-dim); font-size: 12px; }

.cat-extra {
  display: block;
  margin-top: 2px;
  color: var(--paper-faint);
  font-size: 11.5px;
}

.cat-group td {
  background: var(--ink);
  color: var(--brass-lit);
  font-size: 11px;
  font-variation-settings: 'wdth' 92, 'wght' 650;
  letter-spacing: 0.04em;
  padding: 6px 12px;
  border-bottom: 1px solid var(--steel);
  position: sticky;
  top: 33px;
  z-index: 1;
}

@media (max-width: 820px) {
  .cat-wrap { max-height: none; }
}

/* ── command palette ─────────────────────────────────────────────────────── */
.kbd {
  display: inline-flex;
  align-items: center;
  padding: 1.5px 6px;
  border-radius: 4px;
  border: 1px solid var(--steel);
  border-bottom-width: 2px;
  background: var(--ink-3);
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--paper-dim);
}

.palette-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(6, 8, 11, 0.72);
  backdrop-filter: blur(3px);
  z-index: 60;
  display: grid;
  place-items: start center;
  padding-top: 12vh;
}
.palette-backdrop[hidden] { display: none; }

.palette {
  width: min(620px, 92vw);
  background: var(--ink-2);
  border: 1px solid var(--steel-lit);
  border-radius: 11px;
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.62);
  overflow: hidden;
}

.palette-input {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--steel);
  background: transparent;
  color: var(--paper);
  font: inherit;
  font-size: 15px;
  padding: 15px 18px;
  outline: none;
}
.palette-input::placeholder { color: var(--paper-faint); }

.palette-results { max-height: 52vh; overflow-y: auto; padding: 6px; }

.presult {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--paper);
  font: inherit;
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
}
.presult[data-active='true'] { background: rgba(201, 162, 39, 0.12); }
.presult-sub { margin-left: auto; font-size: 11px; color: var(--paper-faint); }
.presult-kind {
  font-size: 10px;
  padding: 1.5px 6px;
  border-radius: 4px;
  border: 1px solid var(--steel);
  color: var(--paper-faint);
  flex: none;
}

.palette-empty { padding: 26px; text-align: center; color: var(--paper-faint); font-size: 13px; }

/* ── toggle ──────────────────────────────────────────────────────────────── */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 6px 12px;
  border: 1px solid var(--steel);
  border-radius: 99px;
  background: var(--ink-2);
  color: var(--paper-dim);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  transition: all 0.15s var(--ease);
}
.toggle:hover { border-color: var(--steel-lit); color: var(--paper); }
.toggle[aria-pressed='true'] {
  border-color: var(--rust-dim);
  background: rgba(192, 91, 77, 0.1);
  color: var(--rust);
}
.toggle-track {
  width: 26px; height: 14px;
  border-radius: 99px;
  background: var(--steel);
  position: relative;
  flex: none;
  transition: background 0.2s var(--ease);
}
.toggle[aria-pressed='true'] .toggle-track { background: var(--rust-dim); }
.toggle-thumb {
  position: absolute;
  top: 2px; left: 2px;
  width: 10px; height: 10px;
  border-radius: 99px;
  background: var(--paper-dim);
  transition: transform 0.2s var(--ease), background 0.2s var(--ease);
}
.toggle[aria-pressed='true'] .toggle-thumb { transform: translateX(12px); background: var(--rust); }

/* redaction */
.redacted {
  color: transparent !important;
  background: var(--steel);
  border-radius: 3px;
  user-select: none;
  position: relative;
}
.redacted::after {
  content: 'opaque';
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-family: var(--mono);
  color: var(--paper-faint);
}

/* ── misc ────────────────────────────────────────────────────────────────── */
.lede-rule {
  width: 46px; height: 2px;
  background: var(--brass);
  margin: 0 0 17px;
  border: 0;
}

.hint {
  font-size: 12.5px;
  color: var(--paper-faint);
  display: flex;
  align-items: center;
  gap: 7px;
}

a { color: var(--verdigris); }

button:focus-visible,
a:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--brass-lit);
  outline-offset: 2px;
  border-radius: 4px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ── responsive ──────────────────────────────────────────────────────────── */
.nav-toggle { display: none; }

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; grid-template-areas: 'rail' 'main'; }
  /* The rail carries three optional labels that do not fit a phone. */
  .rail-note, .brand-sub { display: none; }
  .rail { gap: 12px; padding: 0 12px; }
  #palette-open span:not(.kbd) { display: none; }
  .stage-title { overflow-wrap: break-word; }
  .nav {
    position: fixed;
    top: var(--rail-h); bottom: 0; left: 0;
    width: var(--nav-w);
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.24s var(--ease);
    box-shadow: 12px 0 40px rgba(0,0,0,0.4);
  }
  .shell[data-nav='open'] .nav { transform: translateX(0); }
  .nav-toggle { display: inline-grid; }
  .stage { padding: 22px 18px 64px; }
  .main[data-inspector='open'] { grid-template-columns: 1fr; }
  .inspector {
    position: fixed;
    top: var(--rail-h); bottom: 0; right: 0;
    width: min(var(--insp-w), 92vw);
    z-index: 45;
    box-shadow: -12px 0 40px rgba(0,0,0,0.45);
  }
  .flow-layout { grid-template-columns: 1fr; }
}

/* ── reduced motion ──────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .packet { animation: none; top: 44%; opacity: 1; }
}
