/* Structures portal styles. Colours, type, spacing, radii and shadows come from tokens.css (Span design system). */

*,
*::before,
*::after {
  box-sizing: border-box;
}
body {
  margin: 0;
}
[hidden] {
  display: none !important;
}

.ds {
  min-height: 100vh;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 26px;
}
.ds a {
  color: var(--primary);
}
.ds a:hover {
  color: var(--ink);
}
.ds button:focus-visible,
.ds a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.night-only {
  display: none;
}
.ds.th-night .night-only {
  display: inline;
}

/* Type roles */
.label {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.title {
  margin: 0;
  font-family: var(--font-pixel);
  font-size: clamp(36px, 6vw, 48px);
  line-height: 1.08;
  font-weight: 700;
}
.h2 {
  margin: 0;
  font-family: var(--font-pixel);
  font-size: 28px;
  line-height: 32px;
  font-weight: 600;
}
.h3 {
  margin: 0;
  font-family: var(--font-pixel);
  font-size: 22px;
  line-height: 26px;
  font-weight: 600;
}
.muted {
  color: var(--ink-muted);
}
.small {
  font-size: 14px;
  line-height: 20px;
}
.dest {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 16px;
  color: var(--ink-muted);
  overflow-wrap: anywhere;
}

/* Window: raised paper, 3px frame, 2px outer ring, hard drop */
.window {
  background: var(--surface-raised);
  border: 3px solid var(--frame);
  border-radius: var(--radius-window);
  box-shadow:
    0 0 0 2px var(--frame-outer),
    0 4px 0 2px var(--frame-outer);
}

/* Header */
.site-header {
  background: var(--surface-raised);
  border-bottom: 3px solid var(--frame);
  box-shadow: var(--shadow-press);
}
.site-header-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 clamp(16px, 3.4vw, 48px);
  min-height: 64px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 28px;
}
site-header {
  display: block;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  text-decoration: none;
}
.brand-name {
  font-family: var(--font-pixel);
  font-weight: 700;
  font-size: 22px;
  line-height: 26px;
  color: var(--ink);
}
.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.nav-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  background: var(--primary);
  color: var(--on-primary) !important;
  text-decoration: none;
  font-family: var(--font-pixel);
  font-size: 16px;
  line-height: 20px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 2px solid var(--frame-outer);
  border-radius: var(--radius-window);
  box-shadow: var(--shadow-press);
}
.nav-tab .glyph {
  font-size: 11px;
}
/* Pages other than the current one: outlined like the inactive menu tabs */
.nav-tab:not([aria-current]) {
  background: var(--surface-raised);
  color: var(--ink) !important;
  border-color: var(--primary);
}
.nav-tab:not([aria-current]):hover {
  background: var(--primary-tint);
}
.nav-tab:active {
  transform: translateY(2px);
  box-shadow: none;
}

/* Page */
.page {
  max-width: 2000px;
  margin: 0 auto;
  padding: 40px 16px 64px;
  display: flex;
  flex-direction: column;
}
.intro {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}
.intro .lead {
  margin: 0;
  max-width: 54ch;
  line-height: 1.4;
  color: var(--ink-muted);
  text-wrap: pretty;
}
/* The home page keeps its intro tight so the town sits close under it */
#structures.page {
  padding-top: 24px;
}
#structures .intro {
  gap: 6px;
  margin-bottom: 8px;
}
.author-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  /* Keeps the 44px touch target without opening gaps around the link */
  margin: -10px 0 -6px;
  font-size: 13px;
  text-underline-offset: 4px;
}

/* Top screen */
.device-top {
  padding: clamp(10px, 2.4vw, 22px);
}
.bezel {
  background: var(--frame-outer);
  padding: 4px;
  border-radius: var(--radius-sm);
}
.scene {
  position: relative;
  aspect-ratio: 592 / 268;
  overflow: hidden;
  /* clip, unlike hidden, cannot be scrolled by focusing a hit button, which would undo the camera */
  overflow: clip;
  background: #8fd3a4;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.scene:focus {
  outline: none;
}
.scene:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}
/* The map and its hit buttons; on portrait phones it is wider than the scene and pans (follow() in movement.js) */
.map-stage {
  position: relative;
  height: 100%;
}
.world {
  shape-rendering: crispEdges;
  cursor: pointer;
  display: block;
  width: 100%;
  height: 100%;
}
.world text {
  font-family: var(--font-pixel);
  font-weight: 600;
}
.px {
  shape-rendering: crispEdges;
}
.overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.hit {
  position: absolute;
  display: block;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  pointer-events: auto;
  border-radius: 0;
  -webkit-tap-highlight-color: transparent;
}
.hit:focus {
  outline: none;
}
.hit:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 2px #fcfcf4;
}

.tip {
  position: absolute;
  width: 250px;
  max-width: 74%;
  pointer-events: none;
  padding: 10px 14px;
  color: var(--ink);
}
.tip-name {
  font-family: var(--font-pixel);
  font-size: 18px;
  line-height: 24px;
  font-weight: 500;
}
.tip-short {
  font-size: 14px;
  line-height: 20px;
  color: var(--ink-muted);
  margin-top: 2px;
}
.tip-tool {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
}

.dialog {
  position: absolute;
  left: 3%;
  right: 3%;
  bottom: 5%;
  pointer-events: auto;
  text-align: left;
  cursor: pointer;
  min-height: 64px;
  padding: 12px 44px 14px 18px;
  font-family: var(--font-pixel);
  font-size: clamp(15px, 2.4vw, 20px);
  line-height: 1.4;
  font-weight: 500;
  color: var(--ink);
}
.dialog-more {
  position: absolute;
  right: 16px;
  bottom: 10px;
  color: var(--accent);
  font-size: 14px;
}

/* "Open its tool?" prompt after selecting a component */
.ask {
  position: absolute;
  left: 3%;
  right: 3%;
  bottom: 5%;
  pointer-events: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 16px;
  padding: 10px 14px 10px 18px;
  color: var(--ink);
}
.ask-text {
  flex: 1 1 220px;
  margin: 0;
  font-family: var(--font-pixel);
  font-size: clamp(15px, 2.4vw, 20px);
  line-height: 1.3;
  font-weight: 500;
  text-wrap: pretty;
}
.ask-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}
.ask .btn {
  align-self: center;
}
.ask .btn,
.ask .textbtn {
  white-space: nowrap;
}
.ask .btn[hidden] {
  display: none;
}
.toast {
  position: absolute;
  left: 12px;
  top: 12px;
  max-width: calc(100% - 24px);
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 6px 6px 14px;
  font-family: var(--font-pixel);
  font-size: 17px;
  line-height: 24px;
  font-weight: 500;
  color: var(--ink);
}
.mini-btn {
  flex: none;
  min-height: 36px;
  padding: 0 10px;
  border: 2px solid var(--frame-outer);
  background: var(--surface-raised);
  color: var(--ink);
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-family: var(--font-pixel);
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  box-shadow: var(--shadow-press);
}
.quiz {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(600px, calc(100% - 24px));
  max-height: calc(100% - 16px);
  overflow: auto;
  pointer-events: auto;
  padding: 14px 18px 12px;
  color: var(--ink);
}
.quiz-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.quiz-q {
  margin: 8px 0 12px;
  font-size: 17px;
  line-height: 24px;
  font-weight: 600;
  text-wrap: pretty;
}
.quiz-opts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
  gap: 10px;
}
.quiz-opt {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 8px 12px;
  text-align: left;
  cursor: pointer;
  border: 2px solid var(--frame-outer);
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  color: var(--ink);
  box-shadow: var(--shadow-press);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 20px;
}
.quiz-opt:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.quiz-opt:disabled {
  cursor: default;
  box-shadow: none;
}
.quiz-opt.is-right {
  background: var(--primary);
  color: var(--on-primary);
}
.quiz-opt.is-wrong {
  background: var(--accent);
  color: var(--on-accent);
}
.quiz-key {
  flex: none;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 2px solid currentColor;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
}
.quiz-fb {
  margin: 10px 0 0;
  font-size: 15px;
  line-height: 22px;
}
.quiz-fb:empty {
  display: none;
}
.quiz-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 10px;
}
.room-label {
  position: absolute;
  left: 10px;
  top: 10px;
  margin: 0;
  padding: 2px 10px;
  background: var(--surface-raised);
  color: var(--ink);
  border: 2px solid var(--frame-outer);
  border-radius: var(--radius-sm);
  font-family: var(--font-pixel);
  font-size: 16px;
  line-height: 26px;
  font-weight: 600;
}
.exit-btn {
  position: absolute;
  right: 10px;
  top: 10px;
  pointer-events: auto;
}

/* Controls */
.controls {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr) 118px;
  align-items: center;
  gap: 16px 20px;
  margin-top: 16px;
}
.dpad {
  display: grid;
  grid-template-columns: repeat(3, 44px);
  grid-template-rows: repeat(3, 44px);
}
.pad {
  background: var(--surface-sunken);
  color: var(--ink);
  border: 2px solid var(--frame-outer);
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
.pad-up {
  border-bottom: 0;
  border-radius: 6px 6px 0 0;
  grid-column: 2;
  grid-row: 1;
}
.pad-left {
  border-right: 0;
  border-radius: 6px 0 0 6px;
  grid-column: 1;
  grid-row: 2;
}
.pad-center {
  background: var(--surface-sunken);
  grid-column: 2;
  grid-row: 2;
}
.pad-right {
  border-left: 0;
  border-radius: 0 6px 6px 0;
  grid-column: 3;
  grid-row: 2;
}
.pad-down {
  border-top: 0;
  border-radius: 0 0 6px 6px;
  grid-column: 2;
  grid-row: 3;
}
.help {
  margin: 0;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 18px;
  color: var(--ink-muted);
}
.help-mobile {
  display: none;
}
.ab {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  height: 76px;
}
.round {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2px solid var(--frame-outer);
  box-shadow: 0 3px 0 var(--frame-outer);
  font-family: var(--font-pixel);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}
.round {
  display: grid;
  place-items: center;
}
.glyph-px {
  width: 15px;
  height: 15px;
  fill: currentColor;
  shape-rendering: crispEdges;
}
.round-b {
  margin-top: 22px;
  background: var(--primary);
  color: var(--on-primary);
}
.round-a {
  background: var(--accent);
  color: var(--on-accent);
}

/* The screen width is set from the viewport height so the whole device (screen plus the 132px
   control row and about 100px of frame) fits on screen at 100% zoom. Both screens share that width. */
.page {
  --device-w: calc(max(720px, (100svh - 250px) * 592 / 268) + 2 * clamp(10px, 2.4vw, 22px) + 14px);
}
.device-top,
.hinge,
.touch {
  width: 100%;
  max-width: var(--device-w);
  align-self: center;
}
.hinge {
  display: flex;
  justify-content: space-between;
  padding: 0 22%;
  height: 18px;
}
.hinge span {
  width: 18%;
  height: 100%;
  background: var(--frame-outer);
}

/* Bottom screen */
.touch {
  padding: clamp(10px, 2.4vw, 18px);
}
#tools {
  scroll-margin-top: 16px;
}
.tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.tab {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 8px;
  background: var(--surface-raised);
  color: var(--ink);
  border: 2px solid var(--primary);
  border-radius: var(--radius-window);
  box-shadow: var(--shadow-press);
  font-family: var(--font-pixel);
  font-size: 15px;
  line-height: 18px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
}
.tab.is-active {
  background: var(--primary);
  color: var(--on-primary);
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(230px, 100%), 1fr));
  gap: 16px;
}
.card {
  background: var(--surface-raised);
  border: 3px solid var(--frame);
  border-radius: var(--radius-window);
  box-shadow: var(--shadow-window);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.card.is-linked[data-tool='stm'] {
  border-color: var(--stm);
}
.card.is-linked[data-tool='spanwise'] {
  border-color: var(--sw);
}
.elev-wrap {
  background: var(--surface-sunken);
  border-bottom: 3px solid var(--frame);
  padding: 10px 12px;
  color: var(--ink);
}
.elev {
  display: block;
  width: 100%;
  height: auto;
  max-height: 156px;
}
.elev path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
}
.elev .dash {
  stroke: var(--accent);
  stroke-dasharray: 4 3;
}
.card-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}
.card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.card-desc {
  margin: 0;
  font-size: 15px;
  line-height: 22px;
  color: var(--ink-muted);
}
.card-actions {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 12px;
}

.badge-ph {
  font-family: var(--font-pixel);
  font-weight: 600;
  font-size: 12px;
  line-height: 1;
  text-transform: uppercase;
  background: var(--surface-sunken);
  color: var(--ink-muted);
  border: 1px solid var(--line);
  padding: 5px 7px;
  border-radius: var(--radius-sm);
}
.badge-ok {
  font-family: var(--font-pixel);
  font-weight: 600;
  font-size: 12px;
  line-height: 1;
  text-transform: uppercase;
  border: 2px solid var(--ok);
  color: var(--ok);
  padding: 3px 6px;
  border-radius: var(--radius-sm);
}
.badge-soon {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 11px;
  line-height: 1;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 2px solid var(--soon);
  color: var(--ink);
  padding: 4px 6px;
  border-radius: var(--radius-sm);
}

.btn {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 16px;
  text-decoration: none;
  font-family: var(--font-pixel);
  font-weight: 600;
  font-size: 15px;
  line-height: 18px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 2px solid var(--frame-outer);
  border-radius: var(--radius-window);
  box-shadow: var(--shadow-press);
  cursor: pointer;
}
.btn:hover {
  filter: brightness(1.06);
}
.btn-primary,
.ds a.btn-primary,
.ds a.btn-primary:hover {
  background: var(--primary);
  color: var(--on-primary);
}
.btn-accent,
.ds a.btn-accent,
.ds a.btn-accent:hover {
  background: var(--accent);
  color: var(--on-accent);
}
.btn-lg {
  min-height: 52px;
  padding: 0 22px;
  font-size: 18px;
  line-height: 20px;
}

/* Inspector panel */
.detail {
  border: 3px solid var(--frame);
  border-radius: var(--radius-window);
  overflow: hidden;
  background: var(--surface-raised);
}
.detail-empty {
  padding: 20px 22px 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.detail-empty p:last-child {
  margin: 0;
}
.detail-head {
  padding: 16px 22px 14px;
  border-bottom: 3px solid var(--frame-outer);
  background: var(--soon);
  color: var(--surface-raised);
}
.detail-head .label {
  color: inherit;
}
.detail-head .h2 {
  margin-top: 6px;
}
.detail-head[data-tool='stm'] {
  background: var(--stm);
  color: var(--on-stm);
}
.detail-head[data-tool='spanwise'] {
  background: var(--sw);
  color: var(--on-sw);
}
.detail-body {
  padding: 18px 22px 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.detail-body > p {
  margin: 0;
  text-wrap: pretty;
}
.inspector-field {
  display: grid;
  gap: 8px;
}
.inspector-field p {
  margin: 0;
}
.map-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  line-height: 20px;
}
.pill {
  padding: 4px 10px;
  border: 2px solid var(--frame-outer);
  border-radius: var(--radius-sm);
  font-weight: 500;
  background: var(--surface-raised);
}
.pill-tool {
  border-color: var(--soon);
  background: var(--soon-tint);
  font-weight: 600;
}
.pill-tool[data-tool='stm'] {
  border-color: var(--stm);
  background: var(--stm-tint);
}
.pill-tool[data-tool='spanwise'] {
  border-color: var(--sw);
  background: var(--sw-tint);
}
.arrow {
  color: var(--accent);
  font-size: 14px;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}
.note {
  margin: 0;
  font-size: 14px;
  line-height: 20px;
  color: var(--ink-muted);
  border-top: 2px solid var(--line);
  padding-top: 14px;
}
.textbtn {
  border: 0;
  background: transparent;
  padding: 6px 0;
  min-height: 44px;
  font-family: var(--font-pixel);
  font-size: 16px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--ink-muted);
  cursor: pointer;
}
.textbtn:hover {
  color: var(--ink);
  text-decoration: underline;
}

/* Maps tab */
.map-groups {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.map-group > .label {
  margin-bottom: 8px;
}
.comp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr));
  gap: 12px;
}
.chip {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 8px 14px;
  text-align: left;
  background: var(--surface-raised);
  border: 2px solid var(--frame);
  border-radius: var(--radius-window);
  box-shadow: var(--shadow-press);
  font: inherit;
  color: var(--ink);
  cursor: pointer;
}
.chip-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.chip-name {
  font-family: var(--font-pixel);
  font-weight: 500;
  font-size: 17px;
  line-height: 22px;
}
.chip-tool {
  font-size: 13px;
  line-height: 18px;
  color: var(--ink-muted);
}
.chip.is-selected {
  background: var(--soon-tint);
  border-color: var(--soon);
}
.chip.is-selected[data-tool='stm'] {
  background: var(--stm-tint);
  border-color: var(--stm);
}
.chip.is-selected[data-tool='spanwise'] {
  background: var(--sw-tint);
  border-color: var(--sw);
}
.swatch {
  width: 12px;
  height: 12px;
  flex: none;
  border-radius: 2px;
  background: var(--soon);
}
.swatch[data-tool='stm'] {
  background: var(--stm);
}
.swatch[data-tool='spanwise'] {
  background: var(--sw);
}
.swatch[data-tool='place'] {
  background: var(--primary);
}

.chip:hover {
  background: var(--primary-tint);
}
.btn:active,
.pad:active,
.round:active,
.quiz-opt:active,
.tab:active,
.chip:active,
.mini-btn:active {
  transform: translateY(2px);
  box-shadow: none;
}

.footnote {
  margin: 28px 0 0;
  text-align: center;
  font-size: 13px;
  line-height: 18px;
  color: var(--ink-muted);
}

/* Tool overview pages */
/* About page */
.about {
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.about-sec {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.about-sec p {
  margin: 0;
  text-wrap: pretty;
}
.about-me {
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
.about-bio {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.about-bio p {
  margin: 0;
  text-wrap: pretty;
}
/* Ammar's picture at a whole-number scale (5x its 23 x 46 pixels) on its own beige, so every pixel stays crisp */
.about-photo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 168px;
  height: 260px;
  background: #e9dcc0;
  border: 3px solid var(--frame);
  border-radius: var(--radius-sm);
}
.about-photo img {
  display: block;
  width: 115px;
  height: 230px;
  image-rendering: pixelated;
}
.about-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.about-tools {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(230px, 100%), 1fr));
  gap: 16px;
}
.about-tool {
  padding-left: 14px;
  border-left: 4px solid var(--stm);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.about-tool[data-tool='spanwise'] {
  border-left-color: var(--sw);
}
.about-list {
  margin: 0;
  padding-left: 22px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.site-footer {
  padding: 8px 16px 40px;
  text-align: center;
}
@media (max-width: 640px) {
  .site-header-inner {
    padding: 0 16px 12px;
    gap: 0;
  }
  .brand {
    min-height: 56px;
  }
  .nav {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }
  .nav-tab {
    justify-content: center;
    padding: 0 8px;
    font-size: 14px;
    letter-spacing: 0.02em;
    gap: 4px;
  }
  .page {
    padding-top: 20px;
  }
  .controls {
    grid-template-columns: 132px minmax(0, 1fr);
    gap: 12px;
  }
  .ab {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    gap: 10px;
  }
  .round {
    width: 48px;
    height: 48px;
  }
  .help {
    grid-row: 2;
    grid-column: 1 / -1;
  }
  .help-desktop {
    display: none;
  }
  .help-mobile {
    display: inline;
  }
  .tabs {
    gap: 6px;
  }
  .tab {
    font-size: 13px;
    letter-spacing: 0;
    padding: 0 4px;
    gap: 4px;
  }
  .cards {
    grid-template-columns: minmax(0, 1fr);
  }
  .detail-head,
  .detail-body,
  .detail-empty {
    padding: 16px;
  }
  .about-me,
  .about-tools {
    grid-template-columns: minmax(0, 1fr);
  }
}
/* Portrait phones: the full map would be a thin strip, so show 320 of its 592 units, taller, and follow the engineer */
@media (max-width: 640px) and (orientation: portrait) {
  .scene {
    aspect-ratio: 320 / 268;
  }
  .map-stage {
    width: calc(592 / 320 * 100%);
  }
  /* The room name and Exit share one row at this width */
  .room-label {
    left: 8px;
    top: 8px;
    padding: 2px 8px;
    font-size: 13px;
    line-height: 24px;
  }
  .exit-btn {
    right: 8px;
    top: 8px;
    min-height: 32px;
    padding: 0 8px;
    font-size: 12px;
  }
  .ask {
    left: 2%;
    right: 2%;
    bottom: 3%;
    padding: 6px 10px;
  }
  .ask-text {
    font-size: 14px;
  }
  .ask-actions {
    width: 100%;
    justify-content: space-between;
  }
  .ask .btn {
    min-height: 40px;
    padding: 6px 12px;
    font-size: 13px;
  }
  .ask .textbtn {
    min-height: 40px;
    font-size: 14px;
  }
}

.ph-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px clamp(16px, 3.4vw, 48px);
}
.ph-card {
  width: 100%;
  max-width: 560px;
  overflow: hidden;
}
.ph-head {
  padding: 18px 24px;
  border-bottom: 3px solid var(--frame-outer);
}
.ph-head[data-tool='stm'] {
  background: var(--stm);
  color: var(--on-stm);
}
.ph-head[data-tool='spanwise'] {
  background: var(--sw);
  color: var(--on-sw);
}
.ph-head h1 {
  margin: 12px 0 0;
  font-family: var(--font-pixel);
  font-size: 36px;
  line-height: 40px;
  font-weight: 700;
}
.ph-body {
  padding: 20px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.ph-body p {
  margin: 0;
}
.ph-section {
  display: grid;
  gap: 8px;
}
.ph-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.ph-body .note {
  margin-top: 4px;
}
/* Overviews with a feature list and a video get room for a readable player */
.ph-card-wide {
  max-width: 760px;
}
.ph-list {
  margin: 0;
  padding-left: 22px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-wrap: pretty;
}
/* Inputs and outputs side by side, stacked on narrow screens */
.ph-io {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px 24px;
}
.ph-io .h3 {
  margin: 0 0 6px;
}
.ph-video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--frame-outer);
  border: 3px solid var(--frame);
  border-radius: var(--radius-sm);
}

/* SVG world classes */
.plq {
  font-size: 5px;
  fill: #24262e;
  text-anchor: middle;
  letter-spacing: 0.3px;
}
.boom-u {
  fill: none;
  stroke: #24262e;
  stroke-width: 4;
}
.boom {
  fill: none;
  stroke: #d9a21b;
  stroke-width: 2;
}
.lace-u {
  fill: none;
  stroke: #24262e;
  stroke-width: 2.5;
}
.lace {
  fill: none;
  stroke: #f2c94c;
  stroke-width: 1;
}
.wire {
  fill: none;
  stroke: #24262e;
  stroke-width: 1;
}
.hl-u {
  fill: none;
  stroke: #24262e;
  stroke-width: 3;
  opacity: 0.6;
}
.hl {
  fill: none;
  stroke-width: 1;
  stroke-dasharray: 2 2;
}
.sel-u {
  fill: none;
  stroke: #24262e;
  stroke-width: 3;
}
.sel {
  fill: none;
  stroke-width: 1;
}
.self {
  opacity: 0.22;
  animation: pulse 1.8s steps(6) infinite;
}
.brk-u {
  fill: none;
  stroke: #24262e;
  stroke-width: 4;
}
.brk {
  fill: none;
  stroke-width: 2;
}

/* Step-based motion */
.flow {
  animation: flow 4s steps(24) infinite;
}
.drift {
  animation: drift 116s steps(436) infinite;
}
.sway {
  animation: sway 5s steps(1) infinite;
}
.sway2 {
  animation: sway 6s steps(1) infinite;
  animation-delay: -2.5s;
}
.bob {
  animation: bob 1.4s steps(1) infinite;
}
.bob2 {
  animation: bob2 0.9s steps(1) infinite;
}
.blink {
  animation: blink 1s steps(1) infinite;
}
.lift {
  animation: lift 7s steps(1) infinite;
}
@keyframes flow {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(24px);
  }
}
@keyframes drift {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(872px);
  }
}
@keyframes sway {
  0%,
  100% {
    transform: translateX(0);
  }
  50% {
    transform: translateX(1px);
  }
}
@keyframes bob {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-1px);
  }
}
@keyframes bob2 {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(2px);
  }
}
@keyframes blink {
  50% {
    opacity: 0.25;
  }
}
@keyframes pulse {
  0%,
  100% {
    opacity: 0.14;
  }
  50% {
    opacity: 0.32;
  }
}
@keyframes lift {
  0%,
  40% {
    transform: translateY(0);
  }
  45%,
  90% {
    transform: translateY(2px);
  }
}
.rm .flow,
.rm .drift,
.rm .sway,
.rm .sway2,
.rm .bob,
.rm .bob2,
.rm .blink,
.rm .self,
.rm .lift {
  animation: none !important;
}
@media (prefers-reduced-motion: reduce) {
  .flow,
  .drift,
  .sway,
  .sway2,
  .bob,
  .bob2,
  .blink,
  .self,
  .lift {
    animation: none !important;
  }
}
