/* Raindrop Simulator: UI chrome over the canvas stage.
   Desktop (≥ 900px): docked parameter drawer, floating cards, centered playback bar.
   Mobile (< 900px, .is-mobile): slim top bar, bottom dock, bottom sheets. */

:root {
  --ink: #0F2438;
  --ink-2: #1A3B52;
  --surface: rgba(26, 59, 82, .82);
  --surface-2: rgba(22, 50, 72, .94);
  --well: rgba(15, 36, 56, .55);
  --line: rgba(220, 240, 250, .12);
  --line-2: rgba(220, 240, 250, .2);
  --paper: #DCF0FA;
  --paper-2: rgba(220, 240, 250, .86);
  --muted: #9CC3D5;
  --rain: #6AB8D8;
  --rain-2: #97CDE4;
  --glow: #DCF0FA;
  --amber: #FFB547;
  --mint: #8DD4B7;
  --rose: #E8B5C7;
  --gold: #F5C542;
  --violet: #A78BFA;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --t: 220ms;
  --r: 16px;
  --r-sm: 10px;
  --shadow: 0 12px 32px rgba(6, 16, 26, .38), 0 1px 0 rgba(220, 240, 250, .04) inset;
  --sa-t: env(safe-area-inset-top, 0px);
  --sa-r: env(safe-area-inset-right, 0px);
  --sa-b: env(safe-area-inset-bottom, 0px);
  --sa-l: env(safe-area-inset-left, 0px);
  /* Raindrop design system type: Manrope (display) + Albert Sans (body). No monospace in the
     system, so figures and labels use Albert Sans with tabular numbers. */
  --mono: 'Albert Sans', system-ui, -apple-system, sans-serif;
  --sans: 'Albert Sans', system-ui, -apple-system, sans-serif;
  --display: 'Manrope', system-ui, -apple-system, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  color: var(--paper);
  font: 14px/1.45 var(--sans);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  background:
    radial-gradient(1100px 760px at 88% -12%, rgba(106, 184, 216, .17), transparent 62%),
    radial-gradient(900px 640px at -8% 112%, rgba(255, 181, 71, .09), transparent 60%),
    linear-gradient(180deg, var(--ink) 0%, var(--ink-2) 100%);
  background-color: var(--ink);
}

#stage { position: fixed; inset: 0; touch-action: none; }
#ui { position: fixed; inset: 0; pointer-events: none; z-index: 1; }
/* The chrome takes no browser gestures, so a pinch that starts on it doesn't zoom the whole
   page (and push the dock off-screen); scrollable bodies still pan vertically. */
.topbar > *, .bar, .zoom, .eigen, .info-card, .panel { touch-action: none; }
.panel-body, .info-text { touch-action: pan-y; }

/* ---------- primitives ---------- */

.rd { --drawer-w: 320px; --drawer-space: 0px; --pad: 16px; }
.rd.is-desktop.open-params { --drawer-space: calc(var(--drawer-w) + 28px); }

.surface, .panel, .card, .bar, .zoom, .tb-left, .tb-right, .hud {
  background: var(--surface);
  -webkit-backdrop-filter: blur(14px) saturate(1.25);
  backdrop-filter: blur(14px) saturate(1.25);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}

.eyebrow {
  font: 500 11px/1 var(--mono);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
}
.eyebrow-amber { color: var(--amber); }

.btn {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  margin: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  border-radius: var(--r-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 12px;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  transition: background var(--t) var(--ease), color var(--t) var(--ease), opacity var(--t) var(--ease), transform var(--t) var(--ease);
}
.btn:hover { background: rgba(220, 240, 250, .08); }
.btn:active { transform: scale(.96); }
.btn:focus-visible, .scrub:focus-visible, .sc-item:focus-visible, .segc-opt:focus-visible, .link:focus-visible {
  outline: 2px solid var(--rain-2);
  outline-offset: 2px;
}
.btn[disabled] { opacity: .32; cursor: default; pointer-events: none; }
.btn[aria-pressed="true"] { background: rgba(106, 184, 216, .18); color: var(--glow); }
.btn.small { min-height: 30px; padding: 0 10px; font-size: 13px; }
.icon-btn { width: 36px; height: 36px; padding: 0; flex: none; }
.ghost { color: var(--paper-2); }
.primary-soft {
  background: rgba(106, 184, 216, .2);
  color: var(--glow);
  border: 1px solid rgba(151, 205, 228, .38);
  border-radius: 999px;
  padding: 0 14px 0 10px;
  font-weight: 600;
  font-size: 13px;
}
.primary-soft:hover { background: rgba(106, 184, 216, .32); }
.primary-soft .ic { width: 16px; height: 16px; }

.ic { display: inline-flex; width: 18px; height: 18px; flex: none; }
.ic svg { width: 100%; height: 100%; display: block; }
.grow { flex: 1; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

/* segmented control with a sliding pill */
.segc {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--n), minmax(0, 1fr));
  background: var(--well);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 3px;
  isolation: isolate;
}
.segc-pill {
  position: absolute;
  top: 3px; bottom: 3px; left: 3px;
  width: calc((100% - 6px) / var(--n));
  transform: translateX(calc(var(--i, 0) * 100%));
  background: rgba(106, 184, 216, .24);
  border: 1px solid rgba(151, 205, 228, .55);
  border-radius: 8px;
  box-shadow: 0 0 16px rgba(106, 184, 216, .25);
  transition: transform 240ms var(--ease);
  z-index: -1;
}
.segc-opt {
  appearance: none;
  border: 0;
  background: none;
  color: var(--muted);
  font: 500 13px/1 var(--sans);
  padding: 0 12px;
  min-height: 30px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  touch-action: manipulation;
  transition: color var(--t) var(--ease);
}
.segc-opt:hover { color: var(--paper); }
.segc-opt[aria-checked="true"] { color: var(--paper); }
.segc-short { display: none; }
.segc-full { width: 100%; }

/* ---------- top bar ---------- */

.topbar {
  position: absolute;
  top: calc(12px + var(--sa-t));
  left: calc(var(--pad) + var(--sa-l));
  right: calc(var(--pad) + var(--sa-r));
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.tb-left { display: flex; align-items: center; gap: 4px; padding: 4px; min-width: 0; }
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px 0 10px;
  height: 44px;
  border-right: 1px solid var(--line);
  white-space: nowrap;
}
.brand .drop { width: 15px; height: 17px; display: inline-flex; }
.brand .drop img { width: 100%; height: 100%; object-fit: contain; }
.brand-word { font: 600 12.5px/1 var(--mono); letter-spacing: .16em; text-transform: uppercase; }
.brand-sub { font: 500 12.5px/1 var(--mono); letter-spacing: .08em; color: var(--muted); }
.sc-group { display: flex; align-items: center; min-width: 0; }
.scenario-btn { min-height: 44px; padding: 0 10px 0 12px; gap: 10px; text-align: left; min-width: 0; }
.sc-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.sc-eyebrow { font: 500 9.5px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.sc-title {
  font: 600 14.5px/1.15 var(--display);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}
.scenario-btn .chev { color: var(--muted); transition: transform var(--t) var(--ease); }
.scenario-btn[aria-expanded="true"] .chev { transform: rotate(180deg); }
.info-btn { color: var(--muted); }
.info-btn:hover { color: var(--paper); }
.rd.open-info .info-btn { color: var(--amber); }

.hud {
  display: flex;
  align-items: stretch;
  margin: 0 auto;
  padding: 0 4px;
  height: 54px;
}
.stat {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  padding: 0 14px;
  min-width: 76px;
  border-left: 1px solid var(--line);
}
.stat:first-child { border-left: 0; }
.stat-k { font: 500 9.5px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.stat-v {
  font: 500 15px/1 var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--paper);
  white-space: nowrap;
  transition: color 300ms var(--ease);
}
.stat-supply { min-width: 104px; }
.stat-mint { min-width: 92px; }
.stat.live .stat-v { color: var(--rain-2); }
.stat-alpha .stat-k { text-transform: none; font-size: 11px; }

.tb-right { display: flex; align-items: center; gap: 2px; padding: 4px; }
/* desktop: the HUD sits over the playback bar's center line, clamped (by ui.js) between the
   scenario group and the right-hand buttons */
.rd.is-desktop .hud {
  position: absolute;
  top: 50%;
  left: clamp(var(--hud-lo, 50%), calc(50% - var(--drawer-space) / 2), var(--hud-hi, 50%));
  transform: translate(-50%, -50%);
  margin: 0;
  transition: left 260ms var(--ease);
}
.rd.is-desktop .tb-right { margin-left: auto; }
.tb-right .btn { min-height: 44px; padding: 0 14px 0 12px; font-weight: 500; font-size: 13.5px; }

/* ---------- floating cards (desktop) ---------- */

.panel, .card {
  position: absolute;
  pointer-events: auto;
  color: var(--paper);
  transition: opacity var(--t) var(--ease), transform 260ms var(--ease), visibility 0s linear 260ms;
}
.panel:not(.open), .info-card:not(.open) {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.panel.open, .info-card.open { transition: opacity var(--t) var(--ease), transform 260ms var(--ease), visibility 0s; }

.panel { display: flex; flex-direction: column; overflow: hidden; }
.panel-head { display: flex; align-items: center; gap: 8px; padding: 14px 10px 12px 18px; border-bottom: 1px solid var(--line); flex: none; }
.panel-titles { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.panel-title { margin: 0; font: 600 16px/1.2 var(--display); display: flex; align-items: center; min-width: 0; }
.title-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel-close { color: var(--muted); }
.panel-close:hover { color: var(--paper); }
.panel-body {
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding: 4px 18px 18px;
  flex: 1;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(220, 240, 250, .18) transparent;
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 14px), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 14px), transparent);
}
.panel-body::-webkit-scrollbar { width: 8px; }
.panel-body::-webkit-scrollbar-thumb { background: rgba(220, 240, 250, .16); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
.sheet-handle { display: none; }

/* parameters drawer */
.panel-params {
  top: calc(var(--top-h, 78px) + 12px);
  right: calc(var(--pad) + var(--sa-r));
  bottom: calc(16px + var(--sa-b));
  width: var(--drawer-w);
  transform: translateX(calc(100% + 32px));
}
.panel-params.open { transform: none; }

/* scenario picker popover */
.panel-picker {
  top: calc(var(--top-h, 78px) + 8px);
  left: calc(var(--pad) + var(--sa-l));
  width: 420px;
  max-height: calc(100dvh - var(--top-h, 78px) - 32px);
  background: var(--surface-2);
  transform: translateY(-8px) scale(.985);
  transform-origin: top left;
  z-index: 5;
}
.panel-picker.open { transform: none; }
.panel-picker .panel-body { padding: 6px 10px 12px; }

/* inspector */
.panel-inspector {
  top: calc(var(--top-h, 78px) + 12px);
  left: calc(var(--pad) + var(--sa-l));
  width: 320px;
  max-height: calc(100dvh - var(--top-h, 78px) - var(--dock-h, 160px) - 36px);
  transform: translateX(-12px);
}
.rd.is-desktop.open-eigen .panel-inspector { max-height: calc(100dvh - var(--top-h, 78px) - var(--dock-h, 160px) - var(--eigen-h, 0px) - 48px); }
.panel-inspector.open { transform: none; }

/* legend */
.panel-legend {
  top: calc(var(--top-h, 78px) + 12px);
  right: calc(var(--pad) + var(--sa-r) + var(--drawer-space));
  width: 300px;
  max-height: calc(100dvh - var(--top-h, 78px) - var(--dock-h, 160px) - 36px);
  transform: translateY(-8px);
  transition: opacity var(--t) var(--ease), transform 260ms var(--ease), right 260ms var(--ease), visibility 0s linear 260ms;
}
.panel-legend.open { transform: none; transition: opacity var(--t) var(--ease), transform 260ms var(--ease), right 260ms var(--ease), visibility 0s; }

/* what to watch */
.info-card {
  top: calc(var(--top-h, 78px) + 12px);
  left: calc(var(--pad) + var(--sa-l));
  width: 380px;
  padding: 14px 16px 14px 18px;
  transform: translateY(-8px);
  border-color: rgba(255, 181, 71, .28);
}
.info-card.open { transform: none; }
/* never taller than the room above the EigenTrust panel; the text scrolls instead */
.rd.is-desktop .info-card { display: flex; flex-direction: column; max-height: calc(100dvh - var(--top-h, 78px) - var(--dock-h, 160px) - 36px); }
.rd.is-desktop.open-eigen .info-card { max-height: calc(100dvh - var(--top-h, 78px) - var(--dock-h, 160px) - var(--eigen-h, 0px) - 48px); }
.info-card > * { flex: none; }
.info-card .info-text { flex: 0 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
/* Fade the last line while more text is scrolled out of view (the card is height-capped). */
.rd.is-desktop .info-text.more-below { -webkit-mask-image: linear-gradient(#000 calc(100% - 28px), transparent); mask-image: linear-gradient(#000 calc(100% - 28px), transparent); }
.info-head { display: flex; align-items: center; justify-content: space-between; margin: -4px -6px 4px 0; }
.info-title { margin: 0 0 6px; font: 600 19px/1.25 var(--display); letter-spacing: -.01em; }
.info-text { margin: 0; color: var(--paper-2); font-size: 14px; line-height: 1.55; }
.info-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; }
.info-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag {
  font: 500 10px/1 var(--mono);
  letter-spacing: .12em;
  text-transform: uppercase;
  padding: 5px 8px;
  border-radius: 999px;
  color: var(--amber);
  background: rgba(255, 181, 71, .1);
  border: 1px solid rgba(255, 181, 71, .25);
}
.tag-muted { color: var(--muted); background: rgba(156, 195, 213, .08); border-color: var(--line); }

/* ---------- parameter controls ---------- */

.section { padding: 14px 0 2px; border-bottom: 1px solid var(--line); }
.section:last-of-type { border-bottom: 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.row { margin-bottom: 18px; display: block; }
.row-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.row-label { font: 500 13.5px/1.3 var(--sans); color: var(--paper); white-space: pre; }
.help { margin: 7px 0 0; font-size: 12.5px; line-height: 1.45; color: var(--muted); display: block; }
.issuance-row .slider-row { margin: 12px 0 0; }
.issuance-row .slider-row .row-label { color: var(--paper-2); font-size: 12.5px; }

.num {
  width: 78px;
  flex: none;
  background: var(--well);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--paper);
  font: 500 13px/1 var(--mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
  padding: 7px 9px;
  outline: none;
  transition: border-color var(--t) var(--ease);
}
.num:focus { border-color: var(--rain-2); }

.range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 24px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  touch-action: pan-y;
  --p: 50%;
}
.range:focus { outline: none; }
.range::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--rain) var(--p), rgba(220, 240, 250, .14) var(--p));
}
.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  margin-top: -7px;
  border-radius: 50%;
  background: var(--paper);
  border: 0;
  box-shadow: 0 0 0 4px rgba(106, 184, 216, .28), 0 2px 6px rgba(0, 0, 0, .35);
  transition: box-shadow var(--t) var(--ease);
}
.range:hover::-webkit-slider-thumb, .range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 6px rgba(106, 184, 216, .36), 0 2px 6px rgba(0, 0, 0, .35); }
.range::-moz-range-track { height: 4px; border-radius: 2px; background: rgba(220, 240, 250, .14); }
.range::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--rain); }
.range::-moz-range-thumb { width: 18px; height: 18px; border: 0; border-radius: 50%; background: var(--paper); box-shadow: 0 0 0 4px rgba(106, 184, 216, .28); }

.switch-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; cursor: pointer; }
.row-main { display: flex; flex-direction: column; min-width: 0; }
.row-main .help { margin-top: 3px; }
.switch { position: relative; flex: none; margin-top: 1px; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch-track {
  display: block;
  width: 40px; height: 24px;
  border-radius: 12px;
  background: rgba(220, 240, 250, .16);
  position: relative;
  transition: background var(--t) var(--ease);
}
.switch-thumb {
  position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .35);
  transition: transform var(--t) var(--ease);
}
.switch input:checked + .switch-track { background: var(--rain); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--rain-2); outline-offset: 2px; }

.params-foot { display: flex; align-items: center; gap: 10px; padding-top: 14px; }
.reset-btn { border: 1px solid var(--line); }
.reset-btn .ic { width: 15px; height: 15px; }
.params-foot .modified { display: none; font-size: 12px; color: var(--amber); align-items: center; gap: 6px; }
.params-foot .modified::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--amber); }
.panel-params.is-modified .modified { display: inline-flex; }
.panel-params.is-modified .reset-btn { border-color: rgba(255, 181, 71, .45); color: var(--amber); }

.shortcuts { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.shortcuts summary {
  list-style: none;
  display: flex; align-items: center; gap: 8px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--muted);
}
.shortcuts summary::-webkit-details-marker { display: none; }
.shortcuts summary .ic { width: 16px; height: 16px; }
.shortcuts dl { display: grid; grid-template-columns: auto 1fr; gap: 7px 12px; margin: 12px 0 0; font-size: 12.5px; }
.shortcuts dt { margin: 0; }
.shortcuts dd { margin: 0; color: var(--paper-2); align-self: center; }
kbd {
  display: inline-block;
  min-width: 22px;
  text-align: center;
  font: 500 11px/1 var(--mono);
  padding: 4px 6px;
  border-radius: 6px;
  background: var(--well);
  border: 1px solid var(--line-2);
  color: var(--paper);
}
.rd.is-mobile .shortcuts { display: none; }

/* ---------- scenario list ---------- */

.sc-group-block { padding: 10px 0 2px; }
.sc-group-block + .sc-group-block { border-top: 1px solid var(--line); margin-top: 6px; }
.sc-group-head { display: flex; align-items: baseline; gap: 10px; padding: 4px 8px 8px; }
.sc-group-blurb { font-size: 12px; color: var(--muted); opacity: .8; }
.sc-group-block:has([data-tag="basics"]) .eyebrow { color: var(--rain-2); }
.sc-group-block:has([data-tag="dynamics"]) .eyebrow { color: var(--mint); }
.sc-group-block:has([data-tag="attacks"]) .eyebrow { color: var(--rose); }
.sc-group-block:has([data-tag="sandbox"]) .eyebrow { color: var(--gold); }
.sc-item {
  display: grid;
  grid-template-columns: 26px 1fr 18px;
  gap: 8px;
  align-items: start;
  width: 100%;
  text-align: left;
  padding: 10px 10px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--paper);
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
  transition: background var(--t) var(--ease);
}
.sc-item:hover { background: rgba(220, 240, 250, .06); }
.sc-item.active { background: rgba(106, 184, 216, .14); box-shadow: inset 0 0 0 1px rgba(151, 205, 228, .3); }
.sc-num { font: 500 11px/1 var(--mono); color: var(--muted); padding-top: 4px; font-variant-numeric: tabular-nums; }
.sc-item-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.sc-item-title { font: 600 14.5px/1.3 var(--display); }
.sc-item-sum { font-size: 12.5px; line-height: 1.4; color: var(--muted); }
.sc-check { color: var(--rain-2); opacity: 0; margin-top: 2px; }
.sc-item.active .sc-check { opacity: 1; }

/* ---------- inspector ---------- */

.swatch { width: 11px; height: 11px; border-radius: 50%; margin-right: 9px; flex: none; background: var(--paper); box-shadow: 0 0 0 3px rgba(220, 240, 250, .1); }
.swatch.tone-rain { background: var(--rain); }
.swatch.tone-amber { background: var(--amber); }
.swatch.tone-mint { background: var(--mint); }
.swatch.tone-rose { background: var(--rose); }
.swatch.tone-gold { background: var(--gold); }
.swatch.tone-violet { background: var(--violet); }
.panel-inspector .panel-body { padding-top: 12px; }
.ins-hero { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px 10px; margin-bottom: 12px; }
.ins-bal { display: flex; align-items: baseline; gap: 7px; }
.ins-big { font: 600 30px/1 var(--display); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.ins-unit { font: 500 10.5px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.ins-gain {
  display: inline-flex; align-items: center; gap: 6px;
  font: 500 12px/1 var(--mono);
  padding: 6px 9px;
  border-radius: 999px;
  white-space: nowrap;
  color: var(--mint);
  background: rgba(141, 212, 183, .12);
  border: 1px solid rgba(141, 212, 183, .28);
}
.ins-gain .arrow { font-size: 9px; }
.ins-gain[data-dir="down"] { color: var(--rose); background: rgba(232, 181, 199, .12); border-color: rgba(232, 181, 199, .3); }
.ins-gain[data-dir="flat"] { color: var(--muted); background: rgba(156, 195, 213, .08); border-color: var(--line); }
.ins-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  margin: 0 0 12px;
}
.ins-stat { background: rgba(18, 43, 64, .9); padding: 9px 11px; }
.ins-stat dt { font: 500 9.5px/1.2 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.ins-stat .sym { text-transform: none; letter-spacing: 0; color: var(--rain-2); }
.ins-stat dd { margin: 5px 0 0; font: 500 15px/1 var(--mono); font-variant-numeric: tabular-nums; }
.keeps {
  margin: 0 0 12px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--paper-2);
  background: rgba(255, 181, 71, .08);
  border: 1px solid rgba(255, 181, 71, .26);
  border-radius: 10px;
  padding: 8px 10px;
}
.keeps b { color: var(--amber); font-weight: 600; }
.ins-section { margin-bottom: 12px; }
.ins-section .section-head { margin-bottom: 6px; }
.count { font: 500 11px/1 var(--mono); color: var(--muted); }
.links { list-style: none; margin: 0 -8px; padding: 0; }
.link {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) 64px 46px;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 34px;
  padding: 4px 8px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--paper);
  font: inherit;
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
}
.link:hover { background: rgba(220, 240, 250, .06); }
.link-dir { color: var(--amber); font-family: var(--mono); }
.link-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-bar { height: 4px; border-radius: 2px; background: rgba(220, 240, 250, .1); overflow: hidden; }
.link-bar i { display: block; height: 100%; background: var(--amber); border-radius: 2px; }
.link-pct { font: 500 12px/1 var(--mono); color: var(--paper-2); text-align: right; font-variant-numeric: tabular-nums; }
.empty, .muted-note { margin: 0; font-size: 13px; color: var(--muted); }
.ins-spark { margin-top: 4px; }
.ins-spark .section-head { margin-bottom: 6px; }
.ins-spark-v { font: 500 12px/1 var(--mono); color: var(--rain-2); white-space: nowrap; }
.spark { position: relative; height: 48px; background: var(--well); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.spark-in { position: absolute; inset: 7px 10px 0; }
.spark svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.spark .area { fill: rgba(106, 184, 216, .16); }
.spark .line { fill: none; stroke: var(--rain-2); stroke-width: 1.6; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.spark-dot {
  position: absolute;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--glow);
  box-shadow: 0 0 8px var(--rain-2);
  transform: translate(-50%, -50%);
}
.ins-note { margin: 12px 0 0; font-size: 12.5px; color: var(--muted); font-style: italic; }

/* ---------- legend ---------- */

.legend-list { list-style: none; margin: 0; padding: 12px 0 4px; display: flex; flex-direction: column; gap: 8px; }
.legend-list li { display: grid; grid-template-columns: 26px 1fr; gap: 10px; align-items: center; font-size: 12.5px; line-height: 1.45; color: var(--muted); }
.legend-list b { color: var(--paper); font-weight: 600; }
.glyph { width: 26px; height: 26px; display: block; }
.glyph svg { width: 100%; height: 100%; display: block; }
.panel-legend .section-head { margin: 14px 0 8px; }
.legend-kinds { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; font-size: 12.5px; color: var(--paper-2); }
.legend-kinds li { display: flex; align-items: center; gap: 8px; }
.legend-kinds .seg { width: 18px; height: 8px; border-radius: 2px; flex: none; background: var(--k); }

/* ---------- zoom ---------- */

.zoom {
  position: absolute;
  right: calc(var(--pad) + var(--sa-r) + var(--drawer-space));
  bottom: calc(var(--dock-h, 160px) + 12px);
  display: flex;
  flex-direction: column;
  padding: 3px;
  gap: 2px;
  border-radius: 12px;
  pointer-events: auto;
  transition: right 260ms var(--ease), opacity var(--t) var(--ease);
}
.zoom .btn { color: var(--paper-2); }
.rd.is-desktop.open-legend .zoom { right: calc(var(--pad) + var(--sa-r) + var(--drawer-space) + 308px); }

/* ---------- EigenTrust panel ---------- */

.eigen {
  left: calc(var(--pad) + var(--sa-l));
  bottom: calc(var(--dock-h, 160px) + 12px);
  width: 304px;
  padding: 12px 14px 14px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(8px);
  border-color: rgba(151, 205, 228, .24);
}
.eigen.open { opacity: 1; visibility: visible; pointer-events: auto; transform: none; transition: opacity var(--t) var(--ease), transform 260ms var(--ease), visibility 0s; }
.et-head { display: flex; align-items: center; gap: 8px; margin: -4px -6px 8px 0; min-height: 30px; }
.et-head .eyebrow { color: var(--glow); }
.et-mode {
  font: 500 9.5px/1 var(--mono);
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: 4px 7px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  color: var(--muted);
}
.eigen.preview .et-mode { color: var(--amber); border-color: rgba(255, 181, 71, .35); }
.et-status { display: none; margin-left: auto; font: 600 10px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; white-space: nowrap; }
.et-status.show { display: inline; }
.et-status[data-state="converged"] { color: var(--mint); }
.et-status[data-state="maxed"] { color: var(--rose); }
.et-head .icon-btn { width: 30px; height: 30px; min-height: 30px; color: var(--muted); }
.et-head .icon-btn .ic { width: 16px; height: 16px; }

.et-formula {
  font: 500 16px/1.3 var(--mono);
  letter-spacing: .01em;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--well);
  border: 1px solid var(--line);
  white-space: nowrap;
  text-align: center;
}
.et-g { color: var(--glow); }
.et-op { color: var(--muted); }
.t-anchor { color: var(--amber); }
.t-flow { color: var(--rain-2); }
.et-a { font-size: 13px; opacity: .9; }
.et-a::after { content: '·'; margin: 0 2px; opacity: .7; }
.et-c sup { font-size: .6em; }
.et-key { display: flex; flex-direction: column; gap: 3px; margin: 8px 0 0; font-size: 11.5px; color: var(--muted); }
.et-key span { display: flex; align-items: center; gap: 7px; }
.et-key i { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.k-anchor { background: var(--amber); }
.k-flow { background: var(--rain-2); box-shadow: 0 0 6px var(--rain-2); }
.et-phase {
  font: 500 13px/1.35 var(--sans);
  color: var(--paper);
  min-height: 18px;
  margin: 10px 0 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.et-lbl { font: 500 10px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.et-iter { display: grid; grid-template-columns: auto auto 1fr; align-items: center; gap: 10px; margin-bottom: 7px; }
.et-k { font: 500 13px/1 var(--mono); font-variant-numeric: tabular-nums; min-width: 58px; }
.et-progress { height: 4px; border-radius: 2px; background: rgba(220, 240, 250, .1); overflow: hidden; }
.et-progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--rain), var(--rain-2)); border-radius: 2px; }
.et-resrow { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 7px; font: 500 13px/1 var(--mono); font-variant-numeric: tabular-nums; }
.et-res { min-width: 56px; }
.et-res.ok { color: var(--mint); }
.et-vs { color: var(--muted); font-size: 11px; }
.et-eps { color: var(--amber); white-space: nowrap; }
.et-spark-wrap { position: relative; margin-top: 10px; border-radius: 10px; background: var(--well); border: 1px solid var(--line); overflow: hidden; }
.et-spark { display: block; width: 100%; height: 60px; }
.et-spark .all { fill: none; stroke: rgba(220, 240, 250, .16); stroke-width: 1.5; stroke-linejoin: round; }
.et-spark .done { fill: none; stroke: var(--rain-2); stroke-width: 2; stroke-linejoin: round; }
.et-spark .eps { stroke: var(--amber); stroke-width: 1; stroke-dasharray: 3 3; opacity: .75; }
.et-spark .dot { fill: var(--glow); filter: drop-shadow(0 0 4px var(--rain-2)); }
.et-axis {
  display: flex; justify-content: space-between;
  padding: 7px 9px 0;
  font: 500 9.5px/1 var(--mono); color: var(--muted); letter-spacing: .04em;
  pointer-events: none;
}
.et-sym { text-transform: none; letter-spacing: 0; font-size: 12px; }
.et-fixed { display: none; margin: 10px 0 0; padding: 8px 10px; border-radius: 10px; background: var(--well); border: 1px solid var(--line); font-size: 12px; line-height: 1.45; color: var(--paper-2); }
.eigen.fixed-point .et-fixed { display: block; }
.eigen.fixed-point .et-spark-wrap { display: none; }
.et-eps-label { color: var(--amber); }

.et-summary {
  display: none;
  color: var(--paper);
  font: 500 12.5px/1.2 var(--mono);
  align-items: center;
  gap: 8px;
}
.et-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--rain-2); box-shadow: 0 0 8px var(--rain-2); flex: none; }
.et-summary[data-state="converged"] .et-dot { background: var(--mint); box-shadow: 0 0 8px var(--mint); }
.et-summary[data-state="maxed"] .et-dot { background: var(--rose); box-shadow: 0 0 8px var(--rose); }
.et-sum-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }

/* instant mode during a rain: the formula plus a one-line result instead of the per-iteration rows */
.eigen.instant:not(.preview) .et-summary { display: flex; margin-top: 10px; }
.eigen.instant:not(.preview) .et-iter,
.eigen.instant:not(.preview) .et-resrow,
.eigen.instant:not(.preview) .et-spark-wrap,
.eigen.instant:not(.preview) .et-phase { display: none; }

/* ---------- dock: caption + playback bar ---------- */

.dock {
  position: absolute;
  left: calc(var(--pad) + var(--sa-l));
  right: calc(var(--pad) + var(--sa-r) + var(--drawer-space));
  bottom: calc(16px + var(--sa-b));
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  transition: right 260ms var(--ease);
}
.caption {
  position: relative;
  width: 100%;
  max-width: 820px;
  height: 50px; /* two lines reserved so the dock height (and stage insets) stay put */
  margin-bottom: 10px;
  pointer-events: none;
}
.cap-inner {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  margin: 0;
  text-align: center;
  font: 500 17px/1.42 var(--display);
  letter-spacing: -.005em;
  color: var(--paper);
  text-shadow: 0 1px 2px rgba(15, 36, 56, .95), 0 0 18px rgba(15, 36, 56, .95), 0 0 36px rgba(15, 36, 56, .8);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-wrap: balance;
}
.bar-head { display: flex; align-items: center; min-height: 26px; padding-top: 6px; }
.cap-kind {
  --k: var(--muted);
  display: inline-block;
  padding: 4px 7px 3px;
  border-radius: 6px;
  font: 500 10px/1 var(--mono);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--k);
  background: rgba(15, 36, 56, .6);
  border: 1px solid color-mix(in srgb, var(--k) 45%, transparent);
  text-shadow: none;
}
.cap-phase { opacity: .85; }
.bar-head[data-kind="rain"] .cap-kind { --k: var(--rain-2); }
.bar-head[data-kind="trust"] .cap-kind { --k: var(--amber); }
.bar-head[data-kind="join"] .cap-kind { --k: var(--mint); }
.bar-head[data-kind="transfer"] .cap-kind { --k: var(--gold); }
.caption[data-kind="start"] .cap-text { color: var(--paper-2); }

.bar {
  position: relative;
  z-index: 2;
  pointer-events: auto;
  width: 100%;
  max-width: 880px;
  padding: 6px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.scrub-row { display: flex; align-items: center; gap: 12px; }

/* scrubber: one segment per step */
.k-rain { --k: var(--rain); }
.k-trust { --k: var(--amber); }
.k-join { --k: var(--mint); }
.k-transfer { --k: var(--gold); }
.k-note { --k: rgba(156, 195, 213, .75); }
.scrub {
  position: relative;
  flex: 1;
  height: 30px;
  display: flex;
  align-items: center;
  cursor: pointer;
  touch-action: none;
  outline: none;
  border-radius: 6px;
}
.track { position: relative; flex: 1; height: 8px; transition: height 160ms var(--ease); }
.scrub:hover .track, .scrub.dragging .track { height: 10px; }
.segs { position: absolute; inset: 0; display: flex; gap: var(--gap, 2px); }
.segs .seg { flex: 1 1 0; min-width: 0; height: 100%; border-radius: 2px; background: var(--k); }
.segs .seg.extra { transform: scaleY(.45); border-radius: 1px; }
.segs-base .seg { opacity: .26; }
.segs-lit { will-change: clip-path; }
.legend-kinds .seg.extra { transform: scaleY(.5); }
.script-end {
  position: absolute;
  top: -5px; bottom: -5px;
  width: 2px;
  margin-left: -1px;
  border-radius: 1px;
  background: var(--muted);
  opacity: .7;
}
.knob {
  position: absolute;
  top: 50%;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--paper);
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 4px rgba(106, 184, 216, .3), 0 2px 8px rgba(0, 0, 0, .45);
  pointer-events: none;
}
.scrub.dragging .knob { box-shadow: 0 0 0 7px rgba(106, 184, 216, .35), 0 2px 8px rgba(0, 0, 0, .45); }
.tip {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 0;
  width: max-content;
  max-width: 280px;
  transform: translateX(-50%) translateY(4px);
  padding: 8px 11px 9px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms var(--ease), transform 140ms var(--ease);
  z-index: 3;
}
.tip.show { opacity: 1; transform: translateX(-50%); }
.tip-title { display: block; font: 500 10px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: 5px; }
.tip[data-kind="rain"] .tip-title { color: var(--rain-2); }
.tip[data-kind="trust"] .tip-title { color: var(--amber); }
.tip[data-kind="join"] .tip-title { color: var(--mint); }
.tip[data-kind="transfer"] .tip-title { color: var(--gold); }
.tip-text { display: block; font-size: 13px; line-height: 1.4; color: var(--paper); }

.controls { display: flex; align-items: center; gap: 12px; min-height: 52px; }
.transport { display: flex; align-items: center; gap: 2px; }
.transport .icon-btn { width: 40px; height: 40px; color: var(--paper-2); }
.transport .icon-btn .ic { width: 20px; height: 20px; }
.play-btn {
  width: 50px; height: 50px;
  padding: 0;
  margin: 0 6px;
  border-radius: 50%;
  background: var(--rain);
  color: #fff;
  box-shadow: 0 6px 20px rgba(106, 184, 216, .45), inset 0 1px 0 rgba(255, 255, 255, .25);
}
.play-btn:hover { background: #7FC2DE; }
.play-btn svg { width: 22px; height: 22px; }
.play-btn.playing { box-shadow: 0 0 0 5px rgba(106, 184, 216, .18), 0 6px 20px rgba(106, 184, 216, .45); }
.speed-btn {
  min-width: 48px;
  min-height: 34px;
  margin-left: 6px;
  padding: 0 8px;
  font: 500 13px/1 var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--paper-2);
  border: 1px solid var(--line);
}
.counter { font: 500 12px/1 var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.mode { margin-left: auto; display: flex; align-items: center; gap: 10px; min-width: 0; }
.mode-label { display: flex; align-items: center; gap: 2px; font: 500 11px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--glow); white-space: nowrap; }
.mode-et-short { display: none; }
.mode-info { width: 30px; height: 30px; min-height: 30px; color: var(--muted); }
.mode-info .ic { width: 16px; height: 16px; }
.mode-info:hover, .mode-info[aria-pressed="true"] { color: var(--glow); }
.mode-info[aria-pressed="true"] { background: rgba(151, 205, 228, .14); }
.mode-seg .segc-opt { min-height: 34px; padding: 0 14px; font-size: 13px; }

/* ---------- mid-width desktop ---------- */

@media (max-width: 1320px) {
  .rd.is-desktop .tb-right .btn-label { display: none; }
  .rd.is-desktop .tb-right .btn { padding: 0; width: 44px; }
  .rd.is-desktop .stat { padding: 0 11px; min-width: 64px; }
  .rd.is-desktop .stat-supply { min-width: 92px; }
  .rd.is-desktop .stat-mint { min-width: 82px; }
}
@media (max-width: 1120px) {
  .rd.is-desktop .brand-sub { display: none; }
  .rd.is-desktop .sc-title { max-width: 200px; }
  .rd.is-desktop .counter { display: none; }
  .rd.is-desktop .mode-seg .segc-opt { padding: 0 10px; }
}
@media (max-width: 999.98px) {
  .rd.is-desktop .mode-label .mode-et { display: none; }
  .rd.is-desktop .mode-label .mode-et-short { display: inline; }
}
/* short desktop windows, or the inspector sharing the left column: slimmer EigenTrust panel */
@media (max-height: 860px) {
  .rd.is-desktop .et-key { display: none; }
  .rd.is-desktop .et-formula { padding: 8px 10px; }
}
.rd.is-desktop.open-inspector .et-key { display: none; }
@media (max-height: 800px) {
  .rd.is-desktop.open-inspector .eigen .et-spark-wrap { display: none; }
}

/* ---------- mobile ---------- */

.rd.is-mobile { --pad: 10px; }
.rd.is-mobile .topbar {
  top: calc(8px + var(--sa-t));
  flex-wrap: wrap;
  gap: 6px;
}
.rd.is-mobile .tb-left { flex: 1; padding: 2px; border-radius: 14px; }
.rd.is-mobile .brand { padding: 0 8px 0 12px; height: 44px; }
.rd.is-mobile .brand-word, .rd.is-mobile .brand-sub { display: none; }
.rd.is-mobile .sc-group { flex: 1; }
.rd.is-mobile .scenario-btn { flex: 1; justify-content: space-between; padding: 0 6px 0 10px; }
.rd.is-mobile .sc-eyebrow { display: none; }
.rd.is-mobile .sc-title {
  max-width: none;
  font-size: 13.5px;
  line-height: 1.2;
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.rd.is-mobile .info-btn, .rd.is-mobile .tb-right .btn { width: 44px; height: 44px; min-height: 44px; padding: 0; }
.rd.is-mobile .tb-right { padding: 2px; border-radius: 14px; }
.rd.is-mobile .btn-label { display: none; }
.rd.is-mobile .hud {
  order: 3;
  flex-basis: 100%;
  height: 34px;
  margin: 0;
  padding: 0 2px;
  border-radius: 12px;
  justify-content: space-between;
}
.rd.is-mobile .stat {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  min-width: 0;
  flex: 1 1 auto;
  justify-content: center;
}
.rd.is-mobile .stat-k { font-size: 9px; letter-spacing: .1em; }
.rd.is-mobile .stat-v { font-size: 12.5px; }
.rd.is-mobile .stat-mint .stat-k { font-size: 0; }
.rd.is-mobile .stat-mint .stat-k::before { content: 'Mint'; font-size: 9px; }

.rd.is-mobile .dock {
  left: 0; right: 0; bottom: 0;
  padding: 0 calc(8px + var(--sa-r)) calc(8px + var(--sa-b)) calc(8px + var(--sa-l));
}
.rd.is-mobile .caption { height: 44px; margin-bottom: 8px; padding: 0 8px; }
.rd.is-mobile .cap-inner { font-size: 15px; line-height: 1.42; left: 8px; right: 8px; }
.rd.is-mobile .cap-kind { font-size: 9px; padding: 3px 6px 2px; }
.rd.is-mobile .bar-head { min-height: 22px; padding-top: 8px; }
.rd.is-mobile .bar { max-width: 720px; padding: 0 10px 6px; border-radius: 18px; }
.rd.is-mobile .scrub { height: 44px; margin-bottom: -4px; }
.rd.is-mobile .controls { gap: 6px; min-height: 52px; justify-content: space-between; }
.rd.is-mobile .transport { gap: 0; }
.rd.is-mobile .transport .icon-btn { width: 44px; height: 44px; }
.rd.is-mobile .play-btn { width: 50px; height: 50px; margin: 0 2px; }
.rd.is-mobile .speed-btn { min-width: 44px; min-height: 44px; margin-left: 2px; border-color: transparent; }
.rd.is-mobile .counter { display: none; }
.rd.is-mobile .mode { margin-left: 0; flex-direction: column; align-items: stretch; gap: 3px; }
.rd.is-mobile .mode-label { font-size: 8.5px; letter-spacing: .16em; justify-content: center; gap: 0; height: 12px; }
/* a small (i) in the label row; its hit area is 44px wide but only about 22px tall, so it
   stays clear of the scrubber's track above and the toggle below */
.rd.is-mobile .mode-info { position: relative; width: 22px; height: 18px; min-height: 18px; margin: -3px 0; }
.rd.is-mobile .mode-info .ic { width: 13px; height: 13px; }
.rd.is-mobile .mode-info::after { content: ''; position: absolute; inset: -2px -11px -2px; }
.rd.is-mobile .mode-seg { padding: 2px; border-radius: 10px; }
.rd.is-mobile .mode-seg .segc-pill { top: 2px; bottom: 2px; left: 2px; width: calc((100% - 4px) / var(--n)); }
.rd.is-mobile .mode-seg .segc-opt { position: relative; min-height: 36px; padding: 0 10px; font-size: 12.5px; }
.rd.is-mobile .mode-seg .segc-opt::after { content: ''; position: absolute; inset: -4px 0; } /* 44px hit area */
.rd.is-mobile .mode-seg .segc-long { display: none; }
.rd.is-mobile .mode-seg .segc-short { display: inline; }
@media (min-width: 600px) {
  .rd.is-mobile .brand-word { display: inline; }
  .rd.is-mobile .brand { padding-right: 14px; }
  .rd.is-mobile .mode-seg .segc-long { display: inline; }
  .rd.is-mobile .mode-seg .segc-short { display: none; }
}
@media (max-width: 419.98px) {
  .rd.is-mobile .tp-restart { display: none; }
  .rd.is-mobile .scenario-btn .chev { display: none; } /* the whole button opens the picker */
}
@media (max-width: 359.98px) {
  .rd.is-mobile .speed-btn { display: none; }
}

/* bottom sheets */
.rd.is-mobile .panel {
  position: fixed;
  top: auto;
  right: auto;
  bottom: 0;
  left: 50%;
  width: min(100%, 640px);
  /* at most 60% of the screen, so the graph stays usable above an open sheet */
  max-height: min(60dvh, calc(100dvh - var(--top-h, 60px) - 24px));
  border-radius: 20px 20px 0 0;
  border-bottom: 0;
  background: var(--surface-2);
  padding-bottom: var(--sa-b);
  transform: translate(-50%, calc(100% + 16px));
  z-index: 10;
  box-shadow: 0 -12px 40px rgba(6, 16, 26, .5);
}
.rd.is-mobile .panel.open { transform: translate(-50%, 0); }
.rd.is-mobile .panel.dragging { transition: none; }
.rd.is-mobile .panel.open.dragging { transform: translate(-50%, var(--drag, 0px)); }
.rd.is-mobile .panel-inspector { max-height: min(55dvh, calc(100dvh - var(--top-h, 60px) - 24px)); }
.rd.is-mobile .sheet-handle { display: flex; justify-content: center; padding: 8px 0 0; flex: none; touch-action: none; cursor: grab; }
.rd.is-mobile .sheet-handle span { width: 38px; height: 4px; border-radius: 2px; background: rgba(220, 240, 250, .28); }
.rd.is-mobile .panel-head { padding: 6px 8px 10px 18px; touch-action: none; }
.rd.is-mobile .panel-close { width: 44px; height: 44px; }
.rd.is-mobile .panel-picker .panel-body { padding: 4px 8px 16px; }
.rd.is-mobile .sc-item { padding: 12px 10px; }
.rd.is-mobile .link { min-height: 44px; }
.rd.is-mobile .num { font-size: 16px; padding: 7px 9px; width: 88px; } /* ≥16px stops iOS focus zoom */
.rd.is-mobile .range { height: 36px; }
.rd.is-mobile .switch-row { min-height: 44px; }
.rd.is-mobile .segc-full .segc-opt { min-height: 38px; }

.rd.is-mobile .info-card {
  /* between the top bar and the dock, never under the dock's controls; the text scrolls */
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - var(--top-h, 100px) - var(--dock-h, 160px) - 16px);
  top: calc(var(--top-h, 100px) + 8px);
  left: calc(10px + var(--sa-l));
  right: calc(10px + var(--sa-r));
  width: auto;
  max-width: 560px;
  padding: 12px 14px 12px 16px;
}
.rd.is-mobile .info-title { font-size: 17px; }
.rd.is-mobile .info-text { font-size: 13.5px; max-height: 28dvh; overflow-y: auto; overscroll-behavior: contain; }
.rd.is-mobile .info-go { min-height: 40px; }
.info-more { display: none; margin-right: auto; padding: 0 10px; min-height: 40px; color: var(--rain-2); font-size: 13.5px; font-weight: 600; }
.info-more:hover { color: var(--paper); }
/* Short portrait phones: clamp the description so the graph still fits below the card.
   "More" takes the tags' place in the footer, so the card gets no taller. */
@media (max-height: 760px) and (orientation: portrait) {
  .rd.is-mobile .info-card { z-index: 4; }
  .rd.is-mobile .info-card:not(.expanded) .info-text {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    overflow: hidden;
  }
  .rd.is-mobile .info-card.clipped .info-more { display: inline-flex; margin-left: -10px; }
  .rd.is-mobile .info-card.clipped .info-tags { display: none; }
  .rd.is-mobile .info-foot { margin-top: 8px; }
}

.rd.is-mobile .zoom {
  right: calc(10px + var(--sa-r));
  bottom: calc(var(--dock-h, 170px) + 8px);
  border-radius: 12px;
  padding: 2px;
}
.rd.is-mobile .zoom .z-in, .rd.is-mobile .zoom .z-out { display: none; }
.rd.is-mobile .zoom .btn { width: 44px; height: 44px; }
.rd.is-mobile.open-eigen .zoom { opacity: 0; pointer-events: none; }

/* EigenTrust: a compact panel above the dock, opened from the (i) by the mode toggle */
.rd.is-mobile .eigen {
  left: calc(10px + var(--sa-l));
  right: calc(10px + var(--sa-r));
  bottom: calc(var(--dock-h, 170px) + 8px);
  width: auto;
  max-width: 480px;
  border-radius: 16px;
  padding: 10px 12px 12px;
}
.rd.is-mobile .eigen .et-head .icon-btn { width: 40px; height: 40px; }
.rd.is-mobile .eigen .et-key,
.rd.is-mobile .eigen .et-phase { display: none; }
.rd.is-mobile .eigen .et-formula { font-size: 14px; padding: 8px 10px; margin-bottom: 10px; }

/* landscape phones: one-row top bar and dock, sheets at the right so the graph stays in view */
@media (max-height: 500px) {
  .rd.is-mobile .hud { order: 0; flex: none; flex-basis: auto; height: 48px; border-radius: 14px; }
  .rd.is-mobile .stat-alpha { display: none; } /* α is in Parameters */
  .rd.is-mobile .caption { height: 22px; margin-bottom: 6px; }
  .rd.is-mobile .cap-inner { font-size: 14px; -webkit-line-clamp: 1; }
  /* one row: transport | step chip over the scrubber | mode toggle */
  .rd.is-mobile .bar { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; column-gap: 8px; row-gap: 0; padding: 0 10px; }
  .rd.is-mobile .controls { display: contents; }
  .rd.is-mobile .transport { grid-column: 1; grid-row: 1 / 3; }
  .rd.is-mobile .bar-head { grid-column: 2; grid-row: 1; min-height: 0; padding-top: 6px; position: relative; z-index: 1; pointer-events: none; }
  .rd.is-mobile .cap-kind { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .rd.is-mobile .scrub-row { grid-column: 2; grid-row: 2; min-width: 0; }
  .rd.is-mobile .scrub { height: 40px; margin: -10px 0 0; } /* the chip overlaps the top of its touch zone */
  .rd.is-mobile .mode { grid-column: 3; grid-row: 1 / 3; flex-direction: row; align-items: center; }
  .rd.is-mobile .mode-info::after { inset: -11px -4px -11px -6px; }
  .rd.is-mobile .mode-label .mode-et { display: none; } /* no room for a second line in a one-row dock */
  .rd.is-mobile .mode-seg .segc-long { display: none; }
  .rd.is-mobile .mode-seg .segc-short { display: inline; }
  .rd.is-mobile .info-text { max-height: 22dvh; }
  .rd.is-mobile .eigen { max-width: min(400px, 50vw); } /* the graph sits beside it */
}
@media (max-height: 500px) and (max-width: 799.98px) {
  .rd.is-mobile .stat-mint { display: none; }
}
@media (max-height: 500px) and (min-width: 600px) {
  .rd.is-mobile .panel {
    left: auto;
    right: calc(10px + var(--sa-r));
    top: calc(var(--top-h, 60px) + 8px);
    bottom: calc(var(--dock-h, 90px) + 8px);
    width: min(360px, 48vw);
    max-height: none;
    padding-bottom: 0;
    border: 1px solid var(--line);
    border-radius: var(--r);
    transform: translateX(calc(100% + 24px));
  }
  .rd.is-mobile .panel.open, .rd.is-mobile .panel.open.dragging { transform: none; }
  .rd.is-mobile .sheet-handle { display: none; }
}

/* ---------- motion ---------- */

@media (prefers-reduced-motion: reduce) {
  :root { --t: 1ms; }
  .panel, .card, .segc-pill, .dock, .zoom, .eigen { transition-duration: 1ms !important; }
}
