: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);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

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);
  min-height: 100vh;
  margin: 0 auto;
  padding: 1rem;
}

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

#map-canvas {
  display: block;
  width: 100%;
  height: calc(100vh - 2rem);
  min-height: 640px;
  touch-action: none;
}

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

.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;
}

.top-left-control {
  position: absolute;
  z-index: 5;
  top: 1rem;
  left: 1rem;
  display: flex;
  gap: 0.55rem;
  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,
.reset-button {
  min-width: 5.35rem;
  height: 2.45rem;
  border-color: rgba(255, 255, 255, 0.62);
  background: rgba(255, 255, 255, 0.82);
  color: var(--accent-dark);
  font-weight: 850;
  box-shadow: 0 8px 24px rgba(33, 48, 63, 0.12);
  backdrop-filter: blur(12px);
}

.reset-button {
  min-width: 4.85rem;
  color: rgba(23, 33, 43, 0.76);
  font-weight: 780;
}

.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 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: 5;
  left: 0.75rem;
  right: 0.75rem;
  bottom: 1rem;
  padding: 0.9rem clamp(1.05rem, 2vw, 1.45rem) 0.82rem;
}

.map-slider-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  min-height: 3.05rem;
  margin-bottom: 0.38rem;
}

.projection-heading-block {
  min-width: 0;
}

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;
}

.projection-info-button {
  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;
}

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

.projection-part {
  display: inline-flex;
  gap: 0.35rem;
  align-items: baseline;
  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.85rem;
  overflow: hidden;
  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 {
  display: block;
  width: 100%;
  accent-color: var(--accent);
}

.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 {
    padding: 0;
  }

  .map-stage {
    min-height: 100vh;
    border: 0;
    border-radius: 0;
  }

  #map-canvas {
    height: 100vh;
    min-height: 560px;
  }

  .map-slider-card {
    left: 0.55rem;
    right: 0.55rem;
    bottom: 0.75rem;
  }
}

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

  .top-left-control {
    top: 0.75rem;
    left: 0.75rem;
  }

  .globe-toggle {
    min-width: 4.9rem;
  }

  .reset-button {
    min-width: 4.25rem;
  }

  .zoom-control {
    top: 0.75rem;
    right: 0.75rem;
  }

  .map-slider-header {
    align-items: center;
    min-height: 2.9rem;
  }

  .projection-title {
    font-size: clamp(0.96rem, 4.4vw, 1.2rem);
  }

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

  .projection-arrow {
    width: 1.45rem;
  }

  #projection-summary {
    display: none;
  }

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

  .anchor-ticks {
    display: none;
  }

  .projection-popover {
    left: 0.75rem;
    right: 0.75rem;
    bottom: 8.6rem;
    width: auto;
  }
}
