/* LoadStone application styles. Shared design tokens live in css/theme.css. */
body {
  min-height: 100vh;
  padding: clamp(14px, 3vw, 28px);
  padding-top: calc(clamp(14px, 3vw, 28px) + 58px);
}

body:not(.app-ready) main {
  display: none;
}

main {
  width: min(100%, 500px);
  margin: 0 auto;
}

body.desktop-session {
  min-height: 100vh;
  padding: 53px 0 0;
  overflow: hidden;
}

body.desktop-session main {
  width: 100%;
  height: calc(100vh - 53px);
  margin: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

body.desktop-session main > .pill,
body.desktop-session main > h1,
body.desktop-session main > .subhead {
  display: none;
}

h1 {
  margin: 10px 0 8px;
  letter-spacing: 0;
}

.subhead {
  max-width: 760px;
  margin: 0 0 20px;
}

.site-brand {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 60;
  min-height: 53px;
  padding: 0 clamp(14px, 3vw, 28px);
  border-bottom: 1px solid var(--border);
  background: color-mix(in oklab, var(--surface-base) 72%, transparent);
  backdrop-filter: saturate(1.8) blur(24px);
  -webkit-backdrop-filter: saturate(1.8) blur(24px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  min-height: 53px;
  font-weight: 600;
  font-size: 14.5px;
  line-height: 22.5px;
  letter-spacing: 0;
  color: var(--text-primary);
  text-decoration: none;
  transition: opacity var(--ease);
}

.brand:hover {
  opacity: 0.75;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-md);
  background: var(--surface-inset);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 22px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  flex: 0 0 auto;
}

.brand-name {
  font-size: 14.5px;
  line-height: 22.5px;
  white-space: nowrap;
}

.brand-name span,
.brand-separator,
.brand-product {
  color: var(--text-secondary);
}

.brand-name span {
  opacity: 0.4;
}

.brand-product {
  font-size: 12px;
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 34px;
  min-width: 34px;
  height: 34px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-inset);
  color: var(--text-secondary);
  transition:
    background var(--ease),
    border-color var(--ease),
    color var(--ease),
    transform var(--ease-fast);
}

.theme-toggle:hover {
  border-color: var(--border-hover);
  background: var(--surface-hover);
  color: var(--text-primary);
}

.theme-toggle:active {
  transform: translateY(1px);
}

.theme-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

[data-theme="dark"] .theme-icon--moon,
[data-theme="light"] .theme-icon--sun {
  display: none;
}

.app {
  display: block;
}

body.desktop-session .app {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) clamp(300px, 30vw, 390px);
  gap: 0;
  min-height: 0;
  height: 100%;
  grid-row: 1 / -1;
}

.globe-panel,
.control-panel {
  box-shadow: var(--shadow-panel);
}

.globe-panel {
  position: fixed;
  top: calc(53px + clamp(12px, 3vw, 24px));
  bottom: clamp(12px, 3vw, 24px);
  left: clamp(12px, 3vw, 24px);
  z-index: 20;
  width: min(720px, calc(100vw - 24px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  opacity: 0;
  pointer-events: none;
  transform: translateX(calc(-100% - 32px));
  transition: opacity var(--ease), transform var(--ease);
}

.globe-panel.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

body.desktop-session .globe-panel {
  position: relative;
  inset: auto;
  z-index: 1;
  width: auto;
  min-width: 0;
  height: 100%;
  border-radius: 0;
  border-width: 0 1px 0 0;
  opacity: 1;
  pointer-events: auto;
  transform: none;
  box-shadow: none;
}

body.desktop-session .globe-panel:hover {
  transform: none;
}

body.desktop-session .globe-scrim {
  display: none;
}

body.desktop-session .globe-panel .panel-actions #closeGlobe {
  display: none;
}

body.desktop-session .map-toggle {
  display: none;
}

.globe-scrim {
  position: fixed;
  inset: 0;
  z-index: 15;
  background: var(--scrim);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--ease);
}

.globe-scrim.is-open {
  opacity: 1;
  pointer-events: auto;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.panel-title {
  min-width: 0;
}

.panel-title strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
}

.panel-title span {
  color: var(--text-secondary);
  font-size: 12.5px;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.icon-btn {
  width: 42px;
  min-width: 42px;
  padding: 0;
  justify-content: center;
}

.globe-stage {
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: var(--surface-inset);
}

#globe {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.control-panel {
  padding: 18px;
}

body.desktop-session .control-panel {
  height: 100%;
  min-width: 0;
  overflow: auto;
  border-radius: 0;
  border: 0;
  box-shadow: none;
}

.stack {
  display: grid;
  gap: 18px;
}

.section {
  display: grid;
  gap: 10px;
  padding: 0;
  border-top: 0;
}

.section + .section {
  padding-top: 2px;
}

.section--quiet {
  gap: 8px;
}

label,
.label {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-inset);
  color: var(--text-primary);
  padding: 9px 11px;
}

input:focus,
select:focus {
  border-color: var(--border-hover);
  outline: none;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.mode {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-inset);
}

.mode button {
  min-height: 38px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
}

.mode button.is-active {
  background: var(--accent-muted);
  color: var(--accent-hover);
}

.readout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  overflow: visible;
  border: 1px solid color-mix(in oklab, var(--border) 82%, transparent);
  border-radius: var(--radius-md);
  background: color-mix(in oklab, var(--border) 82%, transparent);
}

.metric {
  position: relative;
  min-width: 0;
  padding: 12px;
  background: var(--surface-inset);
}

.metric:first-child {
  border-top-left-radius: calc(var(--radius-md) - 1px);
}

.metric:nth-child(2) {
  border-top-right-radius: calc(var(--radius-md) - 1px);
}

.metric:nth-last-child(2) {
  border-bottom-left-radius: calc(var(--radius-md) - 1px);
}

.metric:last-child {
  border-bottom-right-radius: calc(var(--radius-md) - 1px);
}

.metric-label {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 17px;
  min-width: 0;
}

.info-tip {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 17px;
  min-width: 17px;
  height: 17px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: var(--surface-inset);
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

.info-tip::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  z-index: 4;
  width: min(240px, 70vw);
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-base);
  color: var(--text-secondary);
  box-shadow: var(--shadow-panel);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
  text-transform: none;
  translate: -50% 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--ease-fast), translate var(--ease-fast);
}

.info-tip:hover::after,
.info-tip.is-open::after,
.info-tip:focus::after,
.info-tip:focus-visible::after {
  translate: -50% 0;
  opacity: 1;
}

.metric strong {
  display: block;
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: clamp(21px, 5vw, 30px);
  font-weight: 600;
  line-height: 1.05;
}

.metric-time {
  display: grid;
  gap: 2px;
  margin-top: 8px;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.25;
}

.metric-time__label {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.metric.is-active {
  background: var(--accent-soft);
}

.metric.is-active .label,
.metric.is-active strong {
  color: var(--accent-hover);
}

.compass {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 1px solid var(--border);
  border-radius: 50%;
  background:
    linear-gradient(var(--surface-inset), var(--surface-inset)) padding-box,
    conic-gradient(from 0deg, var(--accent-muted), var(--border), var(--accent-muted)) border-box;
  position: relative;
  overflow: hidden;
}

.desktop-bearing {
  display: none;
}

body.desktop-session .phone-reticle {
  display: none;
}

body.desktop-session .desktop-bearing {
  display: grid;
}

body:not(.desktop-session) .bearing-metric {
  display: none;
}

body:not(.desktop-session) .distance-metric {
  grid-column: 1 / -1;
  border-top-left-radius: calc(var(--radius-md) - 1px);
  border-top-right-radius: calc(var(--radius-md) - 1px);
}

body:not(.desktop-session) #throughDistanceMetric {
  border-bottom-left-radius: calc(var(--radius-md) - 1px);
}

.desktop-compass {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 54px;
  gap: 12px;
  align-items: stretch;
}

.bearing-dial {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 1px solid var(--border);
  border-radius: 50%;
  background:
    linear-gradient(var(--surface-inset), var(--surface-inset)) padding-box,
    conic-gradient(from 0deg, var(--accent-muted), var(--border), var(--accent-muted)) border-box;
  overflow: hidden;
}

.desktop-pitch {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  justify-items: center;
  gap: 7px;
  min-height: 0;
  padding: 6px 0;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
}

.desktop-pitch__rail {
  --desktop-pitch-offset: 0%;
  position: relative;
  width: 2px;
  min-height: 0;
  border-radius: var(--radius-pill);
  background: var(--border-strong);
}

.desktop-pitch__zero {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 26px;
  height: 1px;
  background: var(--accent-hover);
  opacity: 0.7;
  translate: -50% -50%;
}

.desktop-pitch__marker {
  position: absolute;
  left: 50%;
  top: calc(50% + var(--desktop-pitch-offset));
  width: 13px;
  height: 13px;
  border: 2px solid var(--accent-hover);
  border-radius: 50%;
  background: var(--surface-inset);
  translate: -50% -50%;
}

.desktop-pitch strong {
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.15;
  text-align: center;
}

.bearing-dial::before {
  content: "";
  position: absolute;
  inset: 18%;
  border: 1px solid var(--border);
  border-radius: 50%;
}

.cardinal {
  position: absolute;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
}

.cardinal--n {
  top: 12px;
}

.cardinal--e {
  right: 14px;
}

.cardinal--s {
  bottom: 12px;
}

.cardinal--w {
  left: 14px;
}

.bearing-needle {
  width: 5px;
  height: 38%;
  border-radius: var(--radius-pill);
  background: var(--accent-hover);
  transform-origin: 50% 92%;
  translate: 0 -41%;
}

.bearing-label {
  position: absolute;
  bottom: 18%;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 13px;
}

.needle {
  width: 5px;
  height: 38%;
  border-radius: var(--radius-pill);
  background: var(--accent-hover);
  transform-origin: 50% 92%;
  translate: 0 -41%;
  transition: transform var(--ease-fast);
}

.compass::before {
  content: "";
  position: absolute;
  inset: 18%;
  border: 1px solid var(--border);
  border-radius: 50%;
  box-shadow:
    0 0 0 1px rgba(148, 163, 184, 0.04),
    inset 0 0 0 1px rgba(148, 163, 184, 0.04);
}

.compass::after {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  border: 1px solid var(--accent);
  border-radius: 50%;
  background: var(--surface-inset);
}

.reticle-readout {
  position: absolute;
  z-index: 1;
  display: grid;
  justify-items: center;
  gap: 2px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  line-height: 1.1;
  pointer-events: none;
}

.reticle-readout span {
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.reticle-readout strong {
  max-width: 96px;
  color: var(--text-primary);
  font-size: clamp(13px, 3.8vw, 17px);
  font-weight: 600;
  text-align: center;
}

.reticle-readout--bearing {
  bottom: 22%;
  left: 50%;
  translate: -50% 0;
}

.reticle-readout--turn {
  top: 50%;
  left: 12%;
  translate: 0 -50%;
}

.reticle-readout--pitch {
  top: 50%;
  right: 6px;
  width: 62px;
  translate: 0 -50%;
}

.reticle-readout--pitch strong {
  font-size: clamp(11px, 3vw, 13px);
}

.turn-zero {
  position: absolute;
  left: 50%;
  top: 18%;
  width: 1px;
  height: 34px;
  background: var(--accent-hover);
  opacity: 0.7;
  translate: -50% 0;
}

.pitch-rail {
  --pitch-offset: 0%;
  position: absolute;
  right: 22%;
  top: 19%;
  bottom: 19%;
  width: 2px;
  border-radius: var(--radius-pill);
  background: var(--border-strong);
}

.pitch-rail::before,
.pitch-rail::after {
  position: absolute;
  left: 50%;
  translate: -50% 0;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
}

.pitch-rail::before {
  content: "UP";
  top: -17px;
}

.pitch-rail::after {
  content: "DN";
  bottom: -17px;
}

.pitch-marker {
  position: absolute;
  left: 50%;
  top: calc(50% + var(--pitch-offset));
  width: 14px;
  height: 14px;
  border: 2px solid var(--accent-hover);
  border-radius: 50%;
  background: var(--surface-inset);
  translate: -50% -50%;
}

.pitch-zero {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 28px;
  height: 1px;
  background: var(--accent-hover);
  opacity: 0.7;
  translate: -50% -50%;
}

.pitch-label {
  position: absolute;
  right: 8px;
  bottom: 10px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 10px;
}

.guide {
  min-height: 0;
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid color-mix(in oklab, var(--border) 78%, transparent);
  background: color-mix(in oklab, var(--accent-soft) 52%, var(--surface-inset));
  color: var(--text-primary);
  line-height: 1.45;
}

.status-line {
  color: var(--text-secondary);
  font-size: 13px;
}

.status-panel {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid color-mix(in oklab, var(--border) 78%, transparent);
  border-radius: var(--radius-md);
  background: var(--surface-inset);
}

.accuracy-note {
  padding: 12px;
  border: 1px solid color-mix(in oklab, var(--border) 78%, transparent);
  border-radius: var(--radius-md);
  background: var(--surface-inset);
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.45;
}

.accuracy-note summary {
  cursor: pointer;
  color: var(--text-primary);
  font-weight: 600;
}

.accuracy-note p {
  margin: 8px 0 0;
}

.sky-readout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  overflow: hidden;
  border: 1px solid color-mix(in oklab, var(--border) 82%, transparent);
  border-radius: var(--radius-md);
  background: color-mix(in oklab, var(--border) 82%, transparent);
}

.sky-card {
  padding: 12px;
  background: var(--surface-inset);
}

.sky-card:first-child {
  border-top-left-radius: calc(var(--radius-md) - 1px);
  border-bottom-left-radius: calc(var(--radius-md) - 1px);
}

.sky-card:last-child {
  border-top-right-radius: calc(var(--radius-md) - 1px);
  border-bottom-right-radius: calc(var(--radius-md) - 1px);
}

.sky-card strong {
  display: block;
  margin: 4px 0 2px;
  font-weight: 600;
}

.sky-card span {
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 12px;
}

.warn {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  color: var(--text-secondary);
  line-height: 1.45;
}

body.setup-explained .gate-card > .warn {
  margin-top: 12px;
}

body:not(.setup-explained) .gate-card > .warn {
  display: none;
}

.permission-gate {
  min-height: calc(100vh - clamp(14px, 3vw, 28px) * 2);
  display: grid;
  align-items: start;
  justify-items: center;
  padding-top: 0;
}

body.app-ready .permission-gate {
  display: none;
}

.gate-card {
  width: min(100%, 860px);
  padding: 18px;
  box-shadow: var(--shadow-panel);
}

.gate-card > .pill {
  justify-self: start;
  width: fit-content;
}

body:not(.setup-explained) .gate-card {
  background: transparent;
  border-color: transparent;
  border-radius: 0;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

body:not(.setup-explained) .gate-card:hover {
  transform: none;
  border-color: transparent;
  box-shadow: none;
}

.gate-card h1 {
  margin: 12px 0 10px;
}

[hidden] {
  display: none !important;
}

.gate-explainer {
  display: grid;
  grid-template-columns: 1fr;
  gap: 22px;
  align-items: center;
  margin-top: 18px;
  color: var(--text-secondary);
}

.gate-copy {
  display: grid;
  gap: 20px;
}

.gate-copy p {
  margin: 0;
}

.gate-copy__lead {
  color: var(--text-primary);
  font-size: clamp(18px, 2vw, 24px);
  line-height: 1.35;
}

.gate-start-panel {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 18px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: color-mix(in oklab, var(--surface-inset), transparent 18%);
}

.gate-start-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: var(--surface-hover);
  color: var(--text-secondary);
}

.gate-start-icon svg {
  width: 23px;
  height: 23px;
}

.gate-start-panel strong,
.gate-start-panel span {
  display: block;
}

.gate-start-panel strong {
  color: var(--text-primary);
  font-weight: 600;
}

.gate-start-panel span {
  margin-top: 3px;
  color: var(--text-secondary);
  font-size: 13px;
}

.gate-steps {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: gate-step;
}

.gate-steps li {
  counter-increment: gate-step;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  column-gap: 10px;
  row-gap: 2px;
  align-items: start;
}

.gate-steps span {
  grid-row: 1 / 3;
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: var(--surface-inset);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 12px;
}

.gate-steps span::before {
  content: counter(gate-step);
}

.gate-steps strong {
  color: var(--text-primary);
  font-weight: 600;
}

.gate-steps small {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.4;
}

.gate-visual {
  position: relative;
  justify-self: center;
  width: min(100%, 420px);
  aspect-ratio: 1;
  overflow: hidden;
}

#menuGlobe {
  display: block;
  width: 100%;
  height: 100%;
}

.gate-actions {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

body.setup-explained .gate-actions {
  margin-top: 0;
}

.gate-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-inset);
}

.gate-action strong {
  display: block;
  font-weight: 600;
}

.gate-action span {
  color: var(--text-secondary);
  font-size: 13px;
}

.gate-action.is-ready {
  opacity: 0.5;
}

.gate-action.is-ready strong,
.gate-action.is-ready span {
  color: var(--text-muted);
}

body.setup-desktop #gateSensorRow {
  display: none;
}

.manual-location {
  display: none;
  gap: 10px;
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-inset);
}

.manual-location.is-open {
  display: grid;
}

.manual-location .btn {
  width: 100%;
  justify-content: center;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.map-toggle {
  width: 100%;
  min-width: 44px;
  min-height: 44px;
  justify-content: center;
  margin-bottom: 14px;
}

@media (max-width: 860px) {
  .globe-panel {
    right: 12px;
    width: auto;
  }

  .gate-explainer {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 861px) {
  .permission-gate {
    min-height: calc(100vh - 53px - clamp(14px, 3vw, 28px));
    align-items: start;
  }

  body:not(.setup-explained) .gate-card {
    width: min(1080px, calc(100vw - clamp(48px, 8vw, 140px)));
    display: grid;
    align-content: center;
    padding: clamp(20px, 4vw, 52px) 0;
  }

  body.setup-explained .gate-card {
    width: min(100%, 520px);
    min-height: auto;
    padding: 18px;
  }

  body:not(.setup-explained) .gate-card h1 {
    font-size: clamp(34px, 4vw, 56px);
    line-height: 1.02;
  }

  body.setup-explained .gate-card h1 {
    font-size: 30px;
    line-height: 1.08;
  }

  .gate-explainer {
    grid-template-columns: minmax(420px, 0.88fr) minmax(320px, 0.72fr);
    gap: 22px;
  }

  .gate-visual {
    width: min(38vw, 430px);
  }
}

@media (max-width: 520px) {
  .panel-head,
  .field-grid,
  .readout {
    grid-template-columns: 1fr;
  }

  .gate-explainer {
    grid-template-columns: 1fr;
  }

  .gate-visual {
    order: -1;
    width: min(86vw, 320px);
  }

  .gate-start-panel {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .gate-start-panel .btn {
    grid-column: 1 / -1;
    width: 100%;
    justify-content: center;
  }

  .panel-head {
    display: grid;
  }
}
