/* GlobalFlows — dark spare instrument; BubblinCrude viewport lessons */
:root {
  --bg: #0b0e13;
  --bg2: #12171f;
  --bg3: #1a212c;
  --line: #2a3342;
  --text: #e8edf5;
  --muted: #8b97a8;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --sans: "IBM Plex Sans", system-ui, sans-serif;
  --ease: #3dcea7;
  --neutral: #e6b84d;
  --tight: #e86a5c;
  --accent: #6aa7ff;
  --pick: #e6b84d;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --pwa-fill-h: 100%;
  --pwa-extra-b: 0px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-text-size-adjust: 100%;
  max-width: 100%;
  min-height: 100%;
  /* No overflow here: overflow-x + visible-y pairs to auto and breaks sticky + scroll-spy. */
}

html.pwa-standalone,
html.pwa-standalone body {
  height: calc(var(--pwa-fill-h) + var(--pwa-extra-b));
  min-height: calc(var(--pwa-fill-h) + var(--pwa-extra-b));
}

.app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  padding: 0 calc(4px + var(--safe-r)) calc(6px + var(--safe-b))
    calc(4px + var(--safe-l));
  gap: 6px;
  max-width: 100%;
  width: 100%;
  margin: 0;
  overflow: visible;
}

.topbar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  /* Safe area lives on the stuck pin once brand scrolls away */
  padding: var(--safe-t) 0 0;
  flex-shrink: 0;
}

.topbar-title {
  display: flex;
  flex-direction: row;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  text-align: center;
  min-width: 0;
  flex-wrap: wrap;
}

.brand-title {
  margin: 0;
  font-family: Michroma, "IBM Plex Sans", system-ui, sans-serif;
  font-size: 22px;
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 26px;
  white-space: nowrap;
}

.build-badge {
  flex: 0 0 auto;
  font: 600 0.62rem var(--mono);
  letter-spacing: 0.04em;
  text-transform: lowercase;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
  line-height: 1.2;
}

.dials-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  width: 100%;
}

.topbar-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.nav-link {
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 5px 12px;
  font: 500 0.78rem var(--sans);
  cursor: pointer;
}

.nav-link-sm {
  padding: 3px 9px;
  font-size: 0.68rem;
}

.nav-link-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  text-decoration: none;
  line-height: 0;
}

.nav-link-icon img {
  display: block;
  width: 16px;
  height: 16px;
  border-radius: 0;
  background: transparent;
}

.nav-link:active {
  transform: scale(0.98);
}

.dlg-body h4 {
  margin: 14px 0 6px;
  font-size: 0.85rem;
}

.glossary {
  margin: 0 0 10px;
  display: grid;
  gap: 8px;
}

.glossary > div {
  display: grid;
  gap: 2px;
}

.glossary dt {
  margin: 0;
  color: var(--accent);
  font-weight: 600;
  font-size: 0.78rem;
}

.glossary dd {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
}

.dlg-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 4px;
}

.light-members {
  overflow: hidden;
  max-height: min(28vh, 200px);
  margin: 6px 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.light-members table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.72rem;
}

.light-members th,
.light-members td {
  padding: 4px 6px;
  text-align: right;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.light-members th:first-child,
.light-members td:first-child {
  text-align: left;
}

.light-members th {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.6rem;
  text-transform: uppercase;
  position: sticky;
  top: 0;
  background: var(--bg2);
}

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg3);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 12px;
  font: 500 0.8rem var(--sans);
  cursor: pointer;
}

/* Quiet text action — not a second Close */
.btn.link {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  padding: 7px 4px;
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: color-mix(in srgb, var(--muted) 45%, transparent);
}

.btn.link:hover,
.btn.link:focus-visible {
  color: var(--text);
  text-decoration-color: color-mix(in srgb, var(--text) 55%, transparent);
}

.btn:active {
  transform: scale(0.98);
}

.sentence {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.88rem;
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: -0.01em;
  cursor: pointer;
  outline: none;
}

.sentence:focus,
.sentence:focus-visible {
  outline: none;
  border-color: var(--line);
}

.dials-band {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  min-width: 0;
}

/* Brand / 1·2·5 / regime scroll away; lights → tabs → series title stick. */
.pin-stack {
  position: sticky;
  top: var(--safe-t);
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  width: auto;
  min-width: 0;
  flex-shrink: 0;
  padding: 4px 0 6px;
  margin: 0 calc(-1 * (4px + var(--safe-r))) 0 calc(-1 * (4px + var(--safe-l)));
  padding-left: calc(4px + var(--safe-l));
  padding-right: calc(4px + var(--safe-r));
  background: var(--bg);
  box-shadow: 0 1px 0 var(--line);
  overflow: visible;
}

.pin-stack .lights {
  overflow: visible;
  /* keep focus ring from clipping at the pin edge */
  padding: 1px;
}

/* Cover notch while pin is stuck (layout-neutral). */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--safe-t);
  background: var(--bg);
  z-index: 40;
  pointer-events: none;
}

.regime-horizon {
  display: flex;
  gap: 3px;
  flex-shrink: 0;
}

.regime-horizon .btn.tiny-btn {
  padding: 5px 9px;
  font-size: 0.78rem;
  border-radius: 7px;
  min-width: 2.1rem;
}

.regime-today {
  display: block;
  margin: 0;
  padding: 6px 8px;
  font: inherit;
  font-size: 0.8rem;
  line-height: 1.35;
  text-align: left;
  color: var(--text);
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 8px;
  width: 100%;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.regime-today:focus,
.regime-today:focus-visible {
  outline: 2px solid var(--accent, #3b82f6);
  outline-offset: 1px;
}

.regime-today[hidden] {
  display: none;
}

.regime-today .regime-kicker {
  display: block;
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 2px;
}

.sentence strong {
  font-weight: 600;
}

.sentence strong[data-state="easing"] {
  color: var(--ease);
}
.sentence strong[data-state="neutral"] {
  color: var(--neutral);
}
.sentence strong[data-state="tight"] {
  color: var(--tight);
}
.sentence strong[data-state="empty"] {
  color: var(--muted);
}

/* Five dials: compact cards, packed left (all widths). */
.lights {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 72px));
  gap: 5px;
  width: max-content;
  max-width: 100%;
  align-self: start;
  padding: 0;
  background: transparent;
  border: none;
  overflow: visible;
}

.light {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 13px 5px;
  min-height: 89px;
  min-width: 0;
  cursor: pointer;
  text-align: center;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: inherit;
  font: inherit;
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  z-index: 1;
}

.light[data-focus="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 70%, transparent);
}

.light:last-child {
  border-bottom: 1px solid var(--line);
}

.light .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin: 0 0 3px;
  box-shadow: 0 0 8px currentColor;
  flex-shrink: 0;
}

.light[data-state="easing"] .dot {
  background: var(--ease);
  color: var(--ease);
}
.light[data-state="neutral"] .dot {
  background: var(--neutral);
  color: var(--neutral);
}
.light[data-state="tight"] .dot {
  background: var(--tight);
  color: var(--tight);
}
.light[data-state="empty"] .dot {
  background: #445;
  color: #445;
  box-shadow: none;
}

.light .lbl {
  font-size: 0.52rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.light .word {
  font-size: 0.72rem;
  font-weight: 600;
  margin: 0;
  white-space: nowrap;
  line-height: 1.1;
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.light .score {
  font-family: var(--mono);
  font-size: 0.58rem;
  color: var(--muted);
  margin: 0;
  line-height: 1;
  text-align: center;
  min-width: 0;
}

@media (min-width: 721px) {
  .lights {
    grid-template-columns: repeat(5, 89px);
  }

  .light .lbl {
    font-size: 0.58rem;
  }

  .light .word {
    font-size: 0.76rem;
  }

  .light .score {
    font-size: 0.62rem;
  }
}

.sentence .sent-flags {
  display: block;
  margin-top: 4px;
  font-size: 0.78rem;
  line-height: 1.35;
  white-space: normal;
}

.sentence strong.sent-flag {
  display: block;
  font-weight: 600;
  margin-top: 2px;
}

.dlg-body .sent-story {
  margin: 0 0 8px;
  font-size: 0.9rem;
  line-height: 1.4;
}

.dlg-body .sent-kicker {
  margin: 8px 0 2px;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.dlg-body .sent-foot {
  margin: 8px 0 0;
}

.dlg-body .sent-explain {
  margin: 0;
  padding: 3px 0;
  border-bottom: 1px solid var(--line);
}

.dlg-body .sent-explain:last-of-type {
  border-bottom: none;
}

.dlg-body .sent-explain-title {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.35;
}

.dlg-body .sent-hint {
  font-weight: 400;
  font-size: 0.78rem;
}

.dlg-body .sent-explain p {
  margin: 0;
}

.dlg-body .sent-explain-flag {
  border-bottom: 1px solid var(--line);
  padding-top: 4px;
}

.dlg-body .sent-explain-flag:last-of-type {
  border-bottom: none;
}

.dlg-body strong[data-state="easing"] {
  color: var(--ease);
}
.dlg-body strong[data-state="neutral"] {
  color: var(--neutral);
}
.dlg-body strong[data-state="tight"] {
  color: var(--tight);
}

.layer-tabs {
  display: flex;
  flex-wrap: nowrap;
  gap: 1px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0 0 2px;
  width: 100%;
  min-width: 0;
  scrollbar-width: none;
}

.layer-tabs::-webkit-scrollbar {
  display: none;
}

.layer-tabs button {
  flex: 1 1 0;
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 2px;
  font: 500 0.68rem var(--sans);
  letter-spacing: -0.02em;
  cursor: pointer;
  white-space: nowrap;
  text-align: center;
}

.layer-tabs button[aria-selected="true"] {
  color: var(--text);
  border-color: var(--accent);
  background: var(--bg3);
  box-shadow: none;
}

.layer-tabs button[data-scroll-on="true"] {
  color: var(--text);
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 18%, var(--bg2));
}

.main {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  flex: 0 0 auto;
  min-height: 0;
}

.market-buckets {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 4px 2px 2px;
}

.market-buckets[hidden] {
  display: none;
}

.btn.tiny-btn.compare-go {
  border-color: var(--accent);
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 22%, var(--bg2));
}

.btn.tiny-btn.compare-done {
  border-color: var(--line);
}

.btn.tiny-btn.danger {
  border-color: color-mix(in srgb, var(--tight) 45%, var(--line));
  color: color-mix(in srgb, var(--tight) 70%, var(--text));
}

.btn.tiny-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.heat-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex: 0 0 auto;
}

.heat-controls .ctrl-group {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 1px;
  border-radius: 7px;
  background: color-mix(in srgb, var(--bg3) 80%, transparent);
  border: 1px solid var(--line);
}

.heat-controls .ctrl-group[hidden] {
  display: none;
}

.heat-controls .ctrl-group .btn.tiny-btn {
  border-color: transparent;
  background: transparent;
}

.heat-controls .ctrl-group .btn.tiny-btn[aria-pressed="true"],
.heat-controls .ctrl-group .btn.tiny-btn.compare-go {
  background: color-mix(in srgb, var(--accent) 18%, var(--bg2));
  border-color: transparent;
}

.heat-controls .ctrl-group .btn.tiny-btn.danger {
  border-color: transparent;
}

.name-cell {
  cursor: pointer;
}

.heatmap-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding-left: 2px;
  padding-right: 2px;
}

.heatmap-titles {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.heatmap-head h2 {
  margin: 0;
  font-size: 1rem;
}

.street-hint {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: 500 0.72rem var(--sans);
  padding: 0;
  margin: 0;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--muted) 45%, transparent);
  text-underline-offset: 2px;
}

.street-hint:active {
  color: var(--accent);
}

.street-hint[hidden] {
  display: none;
}

.title-live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.title-live[hidden] {
  display: none;
}

.title-age {
  font: 500 0.78rem var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.btn-refresh {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--bg2);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.btn-refresh svg {
  width: 12px;
  height: 12px;
  display: block;
}

.btn-refresh:active {
  color: var(--text);
  border-color: var(--accent);
}

.btn-refresh:disabled {
  cursor: default;
  opacity: 0.55;
}

.btn-refresh.is-loading svg {
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .btn-refresh.is-loading svg {
    animation: none;
  }
}

.dur-group {
  display: flex;
  gap: 2px;
}

.btn.tiny-btn {
  padding: 3px 6px;
  font-size: 0.68rem;
  border-radius: 6px;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.btn.tiny-btn[aria-pressed="true"] {
  border-color: var(--line);
  background: var(--bg3);
  color: var(--text);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--text) 18%, transparent);
}

.chart-cell {
  padding: 2px 4px !important;
  vertical-align: middle;
  /* Let the spark shrink inside a fixed table — canvas width=600 was blowing the row right. */
  width: 62%;
  max-width: 0;
  white-space: normal;
}

.spark-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 32px;
  overflow: hidden;
  cursor: pointer;
}

.spark-wrap canvas.spark {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  width: 100%;
  height: 32px;
  background: transparent;
}

.spark-chg {
  flex: 0 0 3.6em;
  width: 3.6em;
  text-align: right;
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  line-height: 1;
  pointer-events: none;
}

.spark-chg[data-dir="up"] {
  color: var(--ease);
}

.spark-chg[data-dir="down"] {
  color: var(--tight);
}

.spark-chg[data-dir="flat"] {
  color: var(--muted);
}

.spark-msg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  font-size: 0.65rem;
  pointer-events: none;
}

.spark-msg:empty {
  display: none;
}

.tiny {
  font-size: 0.75rem;
}

.muted {
  color: var(--muted);
}

.table-scroll {
  /* Prefer clip so x:auto does not force y:auto (sticky/spy regression). */
  overflow-x: auto;
  overflow-y: clip;
  margin-top: 4px;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

@supports not (overflow: clip) {
  .table-scroll {
    /* Older WebKit: avoid creating a vertical scrollport; allow x swipe only via touch. */
    overflow: visible;
  }
}

.heat {
  width: 100%;
  max-width: 100%;
  table-layout: fixed;
  /* separate: collapse breaks position:sticky on th in WebKit */
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.72rem;
}

.heat th,
.heat td {
  padding: 3px 5px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

.heat th:first-child,
.heat td:first-child {
  text-align: left;
  position: sticky;
  left: 0;
  background: var(--bg);
  z-index: 1;
  padding-left: 4px;
  width: 38%;
  /* no max-width — must match .heat-colhead Name column */
  overflow: hidden;
  text-overflow: ellipsis;
}

.heat th:last-child,
.heat td:last-child {
  padding-right: 4px;
}

.heat th {
  /* Layout-only — visible labels are #heatColhead in the pin. */
  height: 0;
  max-height: 0;
  padding: 0;
  border: 0;
  margin: 0;
  overflow: hidden;
  line-height: 0;
  font-size: 0;
  color: transparent;
  position: static;
  background: transparent;
  box-shadow: none;
}

.heat th:first-child {
  z-index: 1;
}

html {
  scroll-padding-top: var(--pin-h, 0px);
}

.heat-colhead {
  display: grid;
  grid-template-columns: minmax(0, 38%) 1fr 1fr 1fr;
  gap: 0;
  width: 100%;
  padding: 4px 4px 6px;
  margin: 0;
  color: var(--muted);
  font: 500 0.6rem var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  border-top: 1px solid var(--line);
  background: var(--bg);
}

.heat-colhead[data-mode="charts"] {
  grid-template-columns: minmax(0, 38%) 1fr;
}

.heat-colhead span {
  text-align: right;
  padding: 0 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.heat-colhead span:first-child {
  text-align: left;
  padding-left: 4px;
}

.heat .th-full {
  display: none;
}

@media (min-width: 560px) {
  .heat .th-abbr {
    display: none;
  }
  .heat .th-full {
    display: inline;
  }
}

.heat th:first-child {
  z-index: 3;
}

.heat tbody tr {
  cursor: pointer;
}

.heat tbody tr[data-voter] td:first-child {
  box-shadow: inset 3px 0 0 var(--accent);
}

.heat tbody tr[data-voter] td {
  background: color-mix(in srgb, var(--accent) 7%, var(--bg2));
}

.heat tbody tr[data-voter] td:first-child {
  background: color-mix(in srgb, var(--accent) 10%, var(--bg2));
}

.heat tbody tr:hover td {
  background: var(--bg3);
}

.heat tbody tr[data-voter]:hover td {
  background: color-mix(in srgb, var(--accent) 14%, var(--bg3));
}

.heat tbody tr:hover td:first-child {
  background: var(--bg3);
}

.heat tbody tr[data-voter]:hover td:first-child {
  background: color-mix(in srgb, var(--accent) 16%, var(--bg3));
}

/* Pick tint (amber) — third state vs none / blue vote; wins when both. */
.heat tbody tr[data-compare] td {
  background: color-mix(in srgb, var(--pick) 9%, var(--bg2));
}

.heat tbody tr[data-compare] td:first-child {
  box-shadow: inset 3px 0 0 var(--pick);
  background: color-mix(in srgb, var(--pick) 12%, var(--bg2));
}

.heat tbody tr[data-compare]:hover td {
  background: color-mix(in srgb, var(--pick) 14%, var(--bg3));
}

.heat tbody tr[data-compare]:hover td:first-child {
  background: color-mix(in srgb, var(--pick) 16%, var(--bg3));
}

.heat .name-stack {
  display: inline-block;
  vertical-align: middle;
  max-width: 100%;
}

.heat .name {
  font-weight: 500;
}

.heat .sub {
  display: block;
  font-size: 0.65rem;
  color: var(--muted);
  font-weight: 400;
}

.heat a {
  color: var(--accent);
  text-decoration: none;
}

.z-pos {
  color: var(--ease);
}
.z-neg {
  color: var(--tight);
}
.z-mid {
  color: var(--neutral);
}
.empty {
  color: var(--muted);
  font-style: italic;
}

.cell-heat {
  border-radius: 3px;
  padding: 1px 3px;
  font-family: var(--mono);
  font-size: 0.68rem;
}

.dlg {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg2);
  color: var(--text);
  padding: 0;
  max-width: min(520px, calc(100% - 24px));
}

/* Tap sheets: no scroll — content clips; background locked via body.dlg-open */
.dlg-tap[open] {
  overflow: hidden;
  max-height: min(85dvh, calc(100dvh - var(--safe-t) - var(--safe-b) - 24px));
}

.dlg-tap[open] form {
  overflow: hidden;
  max-height: inherit;
  display: flex;
  flex-direction: column;
}

.dlg-tap[open] .dlg-body {
  overflow: hidden;
  margin-bottom: 10px;
  flex: 1 1 auto;
  min-height: 0;
}

body.dlg-open {
  position: fixed;
  left: 0;
  right: 0;
  width: 100%;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
}

html:has(body.dlg-open) {
  overflow: hidden;
  overscroll-behavior: none;
}

body.dlg-open .app {
  overflow: hidden;
  pointer-events: none;
}

body.dlg-open dialog {
  pointer-events: auto;
}

/* Regime topsheet: phone-wide, tall enough to read — not a collapsed strip */
#dlgSentence[open] {
  position: fixed !important;
  inset: unset !important;
  top: calc(var(--safe-t) + 8px) !important;
  left: 50% !important;
  right: auto !important;
  bottom: auto !important;
  transform: translateX(-50%) !important;
  margin: 0 !important;
  width: min(680px, calc(100vw - 16px)) !important;
  max-width: min(680px, calc(100vw - 16px)) !important;
  height: calc(100dvh - var(--safe-t) - var(--safe-b) - 16px) !important;
  max-height: calc(100dvh - var(--safe-t) - var(--safe-b) - 16px) !important;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#dlgSentence[open] form {
  overflow: hidden;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  padding: 0;
}

#dlgSentence[open] > form > h3 {
  flex: 0 0 auto;
  margin: 0;
  padding: 14px 18px 8px;
  font-size: 1.05rem;
}

#dlgSentence[open] .dlg-body {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  flex: 1 1 auto;
  min-height: 0;
  margin-bottom: 0;
  padding: 4px 18px 14px;
  font-size: 0.92rem;
  line-height: 1.42;
}

#dlgSentence[open] .dlg-actions {
  flex: 0 0 auto;
  padding: 10px 18px calc(14px + var(--safe-b));
}

.dlg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 10px 0 12px;
}

.dlg-head h3 {
  margin: 0;
  flex: 1;
  min-width: 0;
  font-size: 1rem;
}

.dlg-x {
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  width: 30px;
  height: 30px;
  padding: 0;
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

.dlg-topsheet .dlg-body {
  margin-bottom: 0;
  padding: 4px 12px 10px;
  font-size: 0.82rem;
  line-height: 1.3;
  overflow: visible;
}

.dlg-topsheet form {
  padding: 0;
}

.dlg::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.dlg form {
  padding: 16px;
}

.dlg h3 {
  margin: 0 0 10px;
}

.dlg-body {
  font-size: 0.88rem;
  line-height: 1.45;
  margin-bottom: 14px;
}

.dlg-body .light-teach {
  margin: 0 0 8px;
  font-size: 0.86rem;
  line-height: 1.4;
  color: var(--text);
}

.dlg-body .series-blurb {
  margin: 0 0 6px;
  font-size: 0.82rem;
  line-height: 1.35;
  color: var(--text);
}

.dlg-body .series-vote {
  margin: 0 0 8px;
  font-size: 0.8rem;
  line-height: 1.35;
  color: var(--text);
}

.dlg-body .series-vote strong {
  color: var(--accent);
}

.dlg-body .series-meta {
  margin: 0 0 8px;
  font-size: 0.72rem;
  color: var(--muted);
}

.dlg-body .series-meta code {
  font-size: 0.72rem;
}

.dlg-body .series-stats {
  margin: 0;
  display: grid;
  gap: 4px;
}

.dlg-body .series-stats > div {
  display: grid;
  grid-template-columns: 5.5em 1fr;
  gap: 8px;
  align-items: baseline;
  font-size: 0.8rem;
  line-height: 1.3;
}

.dlg-body .series-stats dt {
  margin: 0;
  color: var(--accent);
  font-weight: 500;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.dlg-body .series-stats dd {
  margin: 0;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.76rem;
}

.dlg-body ol {
  padding-left: 1.2rem;
}

.dlg-body code {
  font-family: var(--mono);
  font-size: 0.8rem;
  background: var(--bg3);
  padding: 1px 5px;
  border-radius: 4px;
}

.dlg-body a,
.dlg a {
  color: #9ec5ff;
  text-decoration: underline;
  text-underline-offset: 2px;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.dlg-body a:focus,
.dlg-body a:focus-visible,
.dlg a:focus,
.dlg a:focus-visible {
  outline: none;
  box-shadow: none;
}

.dlg-body a:active,
.dlg a:active {
  color: #c5dcff;
}

/* —— About page —— */
.page-about {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background:
    radial-gradient(120% 80% at 10% -10%, rgba(61, 206, 167, 0.09), transparent 55%),
    radial-gradient(90% 70% at 100% 0%, rgba(106, 167, 255, 0.08), transparent 50%),
    radial-gradient(80% 50% at 50% 100%, rgba(232, 106, 92, 0.05), transparent 55%),
    var(--bg);
  min-height: 100%;
}

.about-shell {
  max-width: 42rem;
  margin: 0 auto;
  padding: 0 calc(14px + var(--safe-r)) calc(28px + var(--safe-b))
    calc(14px + var(--safe-l));
}

.about-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(10px + var(--safe-t)) 0 8px;
  position: sticky;
  top: 0;
  z-index: 5;
  background: linear-gradient(
    to bottom,
    rgba(11, 14, 19, 0.96) 55%,
    rgba(11, 14, 19, 0)
  );
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.about-back {
  font: 500 0.8rem var(--sans);
  color: var(--accent);
  text-decoration: none;
  letter-spacing: 0.01em;
}

.about-back:hover {
  color: #c5dcff;
}

.about-top-mark {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.about-top-mark .dot,
.about-legend .swatch {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.dot.ease,
.swatch.ease {
  background: var(--ease);
}
.dot.mid,
.swatch.mid {
  background: var(--neutral);
}
.dot.tight,
.swatch.tight {
  background: var(--tight);
}

.about-hero {
  padding: 18px 0 8px;
}

.about-kicker {
  margin: 0 0 10px;
  font: 500 0.7rem var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.about-brand {
  margin: 0 0 14px;
  font-family: Michroma, "IBM Plex Sans", system-ui, sans-serif;
  font-size: clamp(1.55rem, 6vw, 2.05rem);
  font-weight: 400;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.about-lede {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.5;
  color: #c5cedc;
  max-width: 34rem;
}

.about-block {
  margin: 0;
  padding: 28px 0 8px;
  scroll-margin-top: 56px;
}

.about-block + .about-block {
  border-top: 1px solid rgba(42, 51, 66, 0.65);
}

.about-block h2 {
  margin: 0 0 12px;
  font-family: Michroma, "IBM Plex Sans", system-ui, sans-serif;
  font-size: 0.95rem;
  font-weight: 400;
  letter-spacing: -0.02em;
  color: var(--text);
}

.about-block > p {
  margin: 0 0 14px;
  font-size: 0.95rem;
  line-height: 1.55;
  color: #b7c0cf;
}

.about-chain {
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.about-chain li {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 8px;
  border-radius: 8px;
  background: rgba(18, 23, 31, 0.85);
  border: 1px solid var(--line);
  min-width: 0;
}

.chain-label {
  font: 600 0.68rem var(--mono);
  letter-spacing: 0.02em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chain-sub {
  font-size: 0.65rem;
  line-height: 1.25;
  color: var(--muted);
}

.about-doors {
  display: grid;
  gap: 10px;
}

@media (min-width: 560px) {
  .about-doors {
    grid-template-columns: repeat(3, 1fr);
  }
}

.about-door {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: linear-gradient(160deg, rgba(26, 33, 44, 0.9), rgba(18, 23, 31, 0.55));
}

.about-door h3 {
  margin: 0 0 6px;
  font: 600 0.85rem var(--sans);
  color: var(--accent);
}

.about-door p {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--muted);
}

.about-steps {
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
}

.about-steps li {
  padding: 10px 12px;
  border-left: 2px solid var(--accent);
  background: rgba(18, 23, 31, 0.55);
  font-size: 0.88rem;
  line-height: 1.45;
  color: #b7c0cf;
}

.about-steps strong {
  color: var(--text);
}

.about-legend {
  display: grid;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--muted);
}

.about-legend span {
  display: flex;
  align-items: center;
  gap: 8px;
}

.about-grid-2 {
  display: grid;
  gap: 10px;
}

@media (min-width: 560px) {
  .about-grid-2 {
    grid-template-columns: 1fr 1fr;
  }
}

.about-panel {
  padding: 14px 14px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(18, 23, 31, 0.7);
}

.about-panel h3 {
  margin: 0 0 8px;
  font: 600 0.82rem var(--sans);
  color: var(--neutral);
}

.about-panel p {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--muted);
}

.about-read {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: read;
  display: grid;
  gap: 12px;
}

.about-read li {
  counter-increment: read;
  display: grid;
  grid-template-columns: 2rem 1fr;
  gap: 10px;
  align-items: start;
}

.about-read li::before {
  content: counter(read, decimal-leading-zero);
  font: 600 0.75rem var(--mono);
  color: var(--ease);
  padding-top: 2px;
}

.about-read strong {
  display: block;
  font-size: 0.9rem;
  color: var(--text);
  margin-bottom: 2px;
}

.about-read span {
  display: block;
  font-size: 0.84rem;
  line-height: 1.45;
  color: var(--muted);
}

.about-status {
  display: grid;
  gap: 10px;
  margin-top: 4px;
}

@media (min-width: 560px) {
  .about-status {
    grid-template-columns: repeat(3, 1fr);
  }
}

.about-status > div {
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(18, 23, 31, 0.75);
  min-width: 0;
}

.status-label {
  display: block;
  font: 500 0.65rem var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

.status-value {
  display: block;
  font: 500 0.85rem var(--mono);
  color: var(--text);
  word-break: break-word;
}

.status-value.is-ok {
  color: var(--ease);
}

.status-value.is-bad {
  color: var(--tight);
}

.about-formula p {
  margin: 0 0 12px;
  font-size: 0.9rem;
  line-height: 1.5;
  color: #b7c0cf;
}

.formula-dl {
  margin: 0 0 12px;
  display: grid;
  gap: 10px;
}

.formula-dl > div {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(11, 14, 19, 0.55);
}

.formula-dl dt {
  margin: 0 0 4px;
  font: 600 0.72rem var(--mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
}

.formula-dl dd {
  margin: 0;
}

.formula-dl code {
  font: 500 0.78rem var(--mono);
  color: var(--text);
  word-break: break-word;
}

.about-gloss-head {
  margin: 22px 0 10px;
  font: 600 0.72rem var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.about-block .glossary {
  margin: 0 0 4px;
  display: grid;
  gap: 12px;
}

.about-block .glossary > div {
  display: grid;
  gap: 4px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(42, 51, 66, 0.45);
}

.about-block .glossary > div:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.about-block .glossary dt {
  margin: 0;
  font: 600 0.88rem var(--sans);
  color: var(--text);
}

.about-block .glossary dd {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--muted);
}

.about-honest {
  margin: 0 0 18px;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
}

.about-honest li {
  position: relative;
  padding: 0 0 0 14px;
  font-size: 0.9rem;
  line-height: 1.5;
  color: #b7c0cf;
}

.about-honest li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ease);
}

.about-foot {
  margin: 8px 0 0;
  font: 500 0.72rem var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.about-main .muted.tiny {
  font-size: 0.78rem;
  line-height: 1.4;
}

@media (max-width: 420px) {
  .about-chain {
    grid-template-columns: 1fr 1fr;
  }
  .about-chain li:last-child {
    grid-column: 1 / -1;
  }
}

