:root {
  color-scheme: light;
  --ink: #17212b;
  --muted: #617184;
  --panel: rgba(255, 252, 245, 0.88);
  --panel-solid: #fffaf1;
  --border: rgba(35, 45, 55, 0.14);
  --accent: #6944aa;
  --accent-dark: #3d276f;
  --ocean: #d7e8f1;
  --shadow: 0 20px 70px rgba(33, 48, 63, 0.16);
  --app-viewport-height: 100vh;
  --app-safe-top: 0px;
  --app-safe-bottom: 0px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

@supports (height: 100dvh) {
  :root {
    --app-viewport-height: 100dvh;
  }
}

@supports (padding-bottom: env(safe-area-inset-bottom)) {
  :root {
    --app-safe-top: env(safe-area-inset-top);
    --app-safe-bottom: env(safe-area-inset-bottom);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 10%, rgba(105, 68, 170, 0.18), transparent 28rem),
    radial-gradient(circle at 80% 0%, rgba(28, 126, 158, 0.16), transparent 32rem),
    linear-gradient(135deg, #eef6fb, #f9f0df 72%);
}

button,
input {
  font: inherit;
}

button {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.76);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.45rem 0.7rem;
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease, opacity 140ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  background: white;
  border-color: rgba(105, 68, 170, 0.35);
}

button:disabled {
  cursor: default;
  opacity: 0.42;
}

.app-shell {
  width: min(1600px, 100vw);
  height: var(--app-viewport-height);
  min-height: 0;
  margin: 0 auto;
  padding: 1rem;
  overflow: hidden;
}

.map-stage {
  position: relative;
  height: calc(var(--app-viewport-height) - 2rem);
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: 2rem;
  overflow: hidden;
  box-shadow: var(--shadow);
  background: var(--ocean);
}

#map-canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.map-stage.is-map-draggable #map-canvas,
.map-stage.is-globe-draggable #map-canvas {
  cursor: grab;
}

.map-stage.is-map-dragging #map-canvas,
.map-stage.is-globe-dragging #map-canvas {
  cursor: grabbing;
}

.card {
  border: 1px solid var(--border);
  border-radius: 1.25rem;
  background: var(--panel);
  box-shadow: 0 10px 30px rgba(33, 48, 63, 0.08);
  backdrop-filter: blur(16px);
}

.eyebrow {
  display: block;
  color: var(--accent-dark);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.projection-readout-card {
  position: absolute;
  z-index: 6;
  top: calc(1rem + var(--app-safe-top));
  left: 1rem;
  width: min(43rem, calc(100% - 2rem));
  padding: 0.88rem clamp(0.95rem, 2vw, 1.2rem) 0.82rem;
}

.projection-readout-header {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: flex-start;
}

.readout-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 0.45rem;
  align-items: center;
}

.help-button {
  display: grid;
  width: 2.45rem;
  height: 2.45rem;
  padding: 0;
  place-items: center;
  border-color: rgba(255, 255, 255, 0.62);
  background: rgba(255, 255, 255, 0.82);
  color: var(--accent-dark);
  font-size: 1.05rem;
  font-weight: 900;
  box-shadow: 0 8px 24px rgba(33, 48, 63, 0.12);
  backdrop-filter: blur(12px);
}

.globe-toggle {
  display: grid;
  width: 2.45rem;
  height: 2.45rem;
  min-width: 0;
  padding: 0;
  place-items: center;
  border-color: rgba(255, 255, 255, 0.62);
  background: rgba(255, 255, 255, 0.82);
  color: var(--accent-dark);
  font-size: 1.12rem;
  font-weight: 850;
  box-shadow: 0 8px 24px rgba(33, 48, 63, 0.12);
  backdrop-filter: blur(12px);
}

.reset-button {
  height: 2.45rem;
  min-width: 4.85rem;
  border-color: rgba(255, 255, 255, 0.62);
  background: rgba(255, 255, 255, 0.82);
  color: rgba(23, 33, 43, 0.76);
  font-weight: 780;
  box-shadow: 0 8px 24px rgba(33, 48, 63, 0.12);
  backdrop-filter: blur(12px);
}

.globe-toggle[aria-pressed="true"] {
  border-color: rgba(105, 68, 170, 0.42);
  background: rgba(105, 68, 170, 0.13);
}

.zoom-control {
  position: absolute;
  z-index: 5;
  top: 1rem;
  right: 1rem;
  display: grid;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 8px 24px rgba(33, 48, 63, 0.12);
  backdrop-filter: blur(12px);
}

.zoom-control[hidden] {
  display: none;
}

.zoom-control button {
  width: 2.6rem;
  height: 2.35rem;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: 1.35rem;
  font-weight: 760;
  line-height: 1;
}

.zoom-control button + button {
  border-top: 1px solid var(--border);
}

.layer-control {
  display: grid;
  gap: 0.58rem;
  margin-top: 0.62rem;
  padding: 0.75rem 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.layer-control label {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  color: rgba(23, 33, 43, 0.86);
  font-size: 0.93rem;
  font-weight: 650;
}

.map-slider-card {
  position: absolute;
  z-index: 6;
  left: 0.75rem;
  right: 0.75rem;
  bottom: calc(1rem + var(--app-safe-bottom));
  padding: 0.72rem clamp(1.05rem, 2vw, 1.45rem) 0.68rem;
}

.projection-heading-block {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.projection-title {
  margin-top: 0.1rem;
  font-size: clamp(1.02rem, 1.85vw, 1.55rem);
  line-height: 1.12;
  letter-spacing: -0.035em;
  overflow-wrap: break-word;
}

.projection-info-button {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: left;
}

.projection-info-button:hover:not(:disabled) {
  transform: none;
  background: transparent;
  border-color: transparent;
}

#projection-name {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.28rem 0.48rem;
  align-items: center;
  max-width: 100%;
}

.projection-name-text {
  border-bottom: 2px dotted rgba(105, 68, 170, 0.5);
  text-decoration: none;
  text-underline-offset: 0.12em;
  overflow-wrap: anywhere;
}

.projection-part {
  display: inline-flex;
  gap: 0.35rem;
  align-items: baseline;
  min-width: 0;
  white-space: nowrap;
}

.projection-weight {
  display: inline-flex;
  align-items: center;
  min-height: 1.25em;
  padding: 0.08rem 0.34rem 0.1rem;
  border: 1px solid rgba(105, 68, 170, 0.18);
  border-radius: 999px;
  background: rgba(105, 68, 170, 0.11);
  color: var(--accent-dark);
  font-size: 0.63em;
  font-weight: 880;
  letter-spacing: 0.015em;
  vertical-align: 0.08em;
}

.projection-arrow {
  display: inline-grid;
  width: 1.8rem;
  height: 1.15rem;
  place-items: center;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(105, 68, 170, 0.08), rgba(28, 126, 158, 0.14));
  color: var(--accent-dark);
  font-size: 0.82em;
  font-weight: 900;
  line-height: 1;
}

#projection-summary {
  max-width: 68rem;
  height: 2.72rem;
  overflow: hidden;
  margin-top: 0.5rem;
  margin-bottom: 0.65rem;
  color: var(--muted);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-height: 1.42;
}

.blend-readout {
  display: inline-flex;
  margin: 0 0 0.65rem;
  padding: 0.42rem 0.58rem;
  border-radius: 999px;
  background: rgba(105, 68, 170, 0.10);
  color: var(--accent-dark);
  font-size: 0.82rem;
  font-weight: 750;
}

.blend-readout[hidden] {
  display: none;
}

#projection-slider {
  --slider-track-height: 0.72rem;
  --slider-thumb-size: 2.05rem;
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 2.75rem;
  margin: 0;
  background: transparent;
  accent-color: var(--accent);
  cursor: grab;
  touch-action: pan-x;
}

#projection-slider:active {
  cursor: grabbing;
}

#projection-slider::-webkit-slider-runnable-track {
  height: var(--slider-track-height);
  border: 1px solid rgba(105, 68, 170, 0.18);
  border-radius: 999px;
  background:
    linear-gradient(90deg, rgba(105, 68, 170, 0.82), rgba(28, 126, 158, 0.74)),
    rgba(255, 255, 255, 0.72);
  box-shadow: inset 0 1px 3px rgba(23, 33, 43, 0.16);
}

#projection-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: var(--slider-thumb-size);
  height: var(--slider-thumb-size);
  margin-top: calc((var(--slider-track-height) - var(--slider-thumb-size)) / 2);
  border: 4px solid var(--accent);
  border-radius: 50%;
  background: #fffaf1;
  box-shadow: 0 8px 22px rgba(33, 48, 63, 0.26);
}

#projection-slider::-moz-range-track {
  height: var(--slider-track-height);
  border: 1px solid rgba(105, 68, 170, 0.18);
  border-radius: 999px;
  background:
    linear-gradient(90deg, rgba(105, 68, 170, 0.82), rgba(28, 126, 158, 0.74)),
    rgba(255, 255, 255, 0.72);
  box-shadow: inset 0 1px 3px rgba(23, 33, 43, 0.16);
}

#projection-slider::-moz-range-thumb {
  width: var(--slider-thumb-size);
  height: var(--slider-thumb-size);
  border: 4px solid var(--accent);
  border-radius: 50%;
  background: #fffaf1;
  box-shadow: 0 8px 22px rgba(33, 48, 63, 0.26);
}

#projection-slider:focus-visible {
  outline: none;
}

#projection-slider:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 5px rgba(105, 68, 170, 0.2), 0 8px 22px rgba(33, 48, 63, 0.26);
}

#projection-slider:focus-visible::-moz-range-thumb {
  box-shadow: 0 0 0 5px rgba(105, 68, 170, 0.2), 0 8px 22px rgba(33, 48, 63, 0.26);
}

.anchor-ticks {
  position: relative;
  height: 2.85rem;
  margin: 0.28rem 1.85rem 0;
}

.anchor-tick {
  position: absolute;
  top: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 6rem;
  margin-left: -3rem;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  user-select: none;
  cursor: pointer;
}

.anchor-tick:hover:not(:disabled) {
  transform: none;
  background: transparent;
  border-color: transparent;
  color: var(--accent-dark);
}

.anchor-tick.is-edge-start {
  align-items: flex-start;
  width: 7rem;
  margin-left: -1.85rem;
}

.anchor-tick.is-edge-end {
  align-items: flex-end;
  width: 7rem;
  margin-left: -5.15rem;
}

.tick-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 5px rgba(105, 68, 170, 0.10);
}

.tick-label {
  margin-top: 0.36rem;
  font-size: 0.69rem;
  font-weight: 720;
  line-height: 1.04;
  text-align: center;
}

.anchor-tick.is-edge-start .tick-label {
  text-align: left;
}

.anchor-tick.is-edge-end .tick-label {
  text-align: right;
}

.projection-popover {
  position: absolute;
  z-index: 7;
  left: clamp(1rem, 3vw, 2.25rem);
  bottom: clamp(9.8rem, 23vh, 13.5rem);
  width: min(30rem, calc(100% - 2rem));
  padding: 1.05rem 1.15rem 1rem;
}

.projection-popover[hidden] {
  display: none;
}

.projection-popover h2 {
  margin: 0.28rem 2rem 0.62rem 0;
  font-size: clamp(1.35rem, 3.5vw, 2rem);
  line-height: 1;
  letter-spacing: -0.045em;
}

.projection-popover p {
  color: var(--muted);
  line-height: 1.52;
}

.projection-popover-note {
  margin-top: 0.72rem;
  padding-top: 0.72rem;
  border-top: 1px solid var(--border);
  color: rgba(61, 39, 111, 0.82) !important;
  font-size: 0.92rem;
  font-weight: 650;
}

.popover-close {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  display: grid;
  width: 2rem;
  height: 2rem;
  padding: 0;
  place-items: center;
  font-size: 1.15rem;
  line-height: 1;
}

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

.help-dialog {
  width: min(42rem, calc(100vw - 2rem));
  max-height: min(42rem, calc(100vh - 2rem));
  overflow-y: auto;
  padding: 1.35rem;
  border: 1px solid var(--border);
  border-radius: 1.35rem;
  background: var(--panel-solid);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.help-dialog::backdrop {
  background: rgba(20, 29, 40, 0.34);
  backdrop-filter: blur(4px);
}

.help-dialog h3 {
  margin-top: 1.1rem;
  font-size: 1rem;
  letter-spacing: -0.02em;
}

.help-dialog p {
  margin-top: 0.45rem;
  color: var(--muted);
  line-height: 1.55;
}

.repo-link {
  display: inline-flex;
  gap: 0.48rem;
  align-items: center;
  margin-top: 1.15rem;
  color: var(--accent-dark);
  font-weight: 780;
  text-decoration: none;
}

.repo-link:hover {
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.dialog-close {
  position: absolute;
  top: 0.9rem;
  right: 0.9rem;
  display: grid;
  width: 2.2rem;
  height: 2.2rem;
  padding: 0;
  place-items: center;
  font-size: 1.3rem;
  line-height: 1;
}

@media (max-width: 900px) {
  .app-shell {
    height: var(--app-viewport-height);
    padding: 0;
  }

  .map-stage {
    height: var(--app-viewport-height);
    min-height: 0;
    border: 0;
    border-radius: 0;
  }

  #map-canvas {
    height: 100%;
    min-height: 0;
  }

  .map-slider-card {
    left: 0.55rem;
    right: 0.55rem;
    bottom: calc(0.75rem + var(--app-safe-bottom));
    padding: 0.62rem 0.9rem 0.58rem;
  }
}

@media (max-width: 640px) {
  #map-canvas {
    min-height: 0;
  }

  .projection-readout-card {
    top: calc(0.58rem + var(--app-safe-top));
    left: 0.58rem;
    right: 0.58rem;
    width: auto;
    padding: 0.62rem 0.68rem 0.58rem;
    border-radius: 1rem;
  }

  .projection-readout-header {
    gap: 0.5rem;
    align-items: flex-start;
  }

  .readout-actions {
    gap: 0.34rem;
  }

  .help-button,
  .globe-toggle {
    width: 2.35rem;
    height: 2.35rem;
  }

  .globe-toggle {
    min-width: 0;
  }

  .reset-button {
    display: none;
  }

  .eyebrow {
    font-size: 0.63rem;
    letter-spacing: 0.1em;
  }

  .map-slider-card {
    left: 0.58rem;
    right: 0.58rem;
    bottom: calc(0.58rem + var(--app-safe-bottom));
    padding: 0.54rem 0.72rem 0.5rem;
    border-radius: 1rem;
  }

  .projection-title {
    font-size: clamp(0.96rem, 4.2vw, 1.12rem);
    line-height: 1.08;
  }

  #projection-name {
    gap: 0.22rem 0.34rem;
  }

  .projection-arrow {
    width: 1.45rem;
  }

  #projection-summary {
    display: -webkit-box;
    height: 2.2rem;
    margin-top: 0.34rem;
    margin-bottom: 0;
    font-size: 0.78rem;
    line-height: 1.34;
    -webkit-line-clamp: 2;
  }

  .blend-readout {
    display: none !important;
  }

  #projection-slider {
    --slider-track-height: 0.78rem;
    --slider-thumb-size: 2.32rem;
    height: 3.1rem;
  }

  .anchor-ticks {
    display: none;
  }

  .projection-popover {
    left: 0.58rem;
    right: 0.58rem;
    bottom: calc(5.1rem + var(--app-safe-bottom));
    width: auto;
    max-height: min(22rem, calc(var(--app-viewport-height) - 9.8rem - var(--app-safe-bottom)));
    overflow-y: auto;
  }
}
