:root {
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  --ink: #17202a;
  --muted: #5d6a72;
  --panel: rgba(248, 249, 246, 0.92);
  --line: rgba(30, 39, 46, 0.16);
  --accent: #0f766e;
}

* {
  box-sizing: border-box;
}

html,
body,
#map {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  background: #c9d8cf;
}

.panel {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 2;
  width: min(360px, calc(100vw - 32px));
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 42px rgba(25, 31, 36, 0.16);
  backdrop-filter: blur(14px);
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 23px;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0;
}

.stats div {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.58);
}

dt {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
}

dd {
  margin: 0;
  overflow: hidden;
  font-size: 14px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.actions {
  display: grid;
  grid-template-columns: 42px repeat(2, 56px);
  gap: 8px;
}

button {
  width: 100%;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(15, 118, 110, 0.3);
  border-radius: 6px;
  color: #064e49;
  background: #f8fffc;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
}

button:hover {
  border-color: rgba(15, 118, 110, 0.72);
  background: #e5f7f1;
}

.attribution {
  position: fixed;
  right: 8px;
  bottom: 6px;
  z-index: 2;
  padding: 4px 7px;
  border-radius: 5px;
  color: #2b353b;
  background: rgba(255, 255, 255, 0.74);
  font-size: 11px;
}

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

.research-settings-wrap {
  position: fixed;
  top: 12px;
  right: 54px;
  z-index: 5;
}

.icon-button {
  width: 40px;
  height: 40px;
  border-color: rgba(23, 32, 42, 0.18);
  border-radius: 12px;
  color: var(--ink);
  background: rgba(250, 251, 248, 0.94);
  box-shadow: 0 8px 24px rgba(25, 31, 36, 0.14);
  font-size: 18px;
}

.research-settings {
  position: absolute;
  top: 48px;
  right: 0;
  width: 310px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(250, 251, 248, 0.97);
  box-shadow: 0 18px 48px rgba(25, 31, 36, 0.2);
  backdrop-filter: blur(18px);
}

.research-settings h2,
.research-progress h2 {
  margin: 0;
  font-size: 18px;
}

.level-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin-top: 14px;
}

.level-options label {
  position: relative;
  cursor: pointer;
}

.level-options input {
  position: absolute;
  opacity: 0;
}

.level-options span {
  min-height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  font-size: 13px;
  font-weight: 800;
}

.level-options input:checked + span {
  border-color: #0f8f83;
  color: #075f58;
  background: #e5f7f3;
}

.runtime-status {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.research-progress {
  position: fixed;
  top: 16px;
  left: 50%;
  z-index: 4;
  width: min(430px, calc(100vw - 40px));
  padding: 14px;
  transform: translateX(-50%);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(250, 251, 248, 0.96);
  box-shadow: 0 18px 48px rgba(25, 31, 36, 0.18);
  backdrop-filter: blur(18px);
}

.progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 9px;
}

.state-badge {
  padding: 5px 9px;
  border-radius: 999px;
  color: #07675f;
  background: #dff5ef;
  font-size: 11px;
  font-weight: 900;
}

.quiet-button {
  width: auto;
  height: 30px;
  padding: 0 10px;
  border-color: var(--line);
  color: var(--muted);
  background: #fff;
  font-size: 11px;
}

.progress-track {
  height: 4px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #dce9e5;
}

.progress-track i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 180ms ease;
}

#research-progress-message {
  margin: 9px 0;
  color: #344249;
  font-size: 12px;
  line-height: 1.45;
}

.research-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 0;
}

.research-stats div {
  min-width: 0;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
}

.research-stats dt {
  font-size: 10px;
}

.research-stats dd {
  font-size: 12px;
}

.file-status {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 10px;
}

.research-warning {
  margin: 9px 0 0;
  padding: 8px;
  border: 1px solid #e3bf78;
  border-radius: 8px;
  color: #785417;
  background: #fff8e8;
  font-size: 11px;
}

.prompt-composer {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 5;
  width: min(680px, calc(100vw - 40px));
  display: flex;
  gap: 10px;
  align-items: flex-end;
  padding: 9px 9px 9px 17px;
  transform: translateX(-50%);
  border: 1px solid rgba(23, 32, 42, 0.17);
  border-radius: 24px;
  background: rgba(252, 253, 250, 0.97);
  box-shadow: 0 18px 54px rgba(25, 31, 36, 0.24);
  backdrop-filter: blur(18px);
}

.prompt-composer textarea {
  width: 100%;
  min-height: 42px;
  max-height: 150px;
  padding: 11px 0 7px;
  resize: none;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font: inherit;
  font-size: 15px;
  line-height: 1.45;
}

.submit-button {
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: #0d7169;
  font-size: 20px;
}

.submit-button:disabled {
  cursor: wait;
  opacity: 0.5;
}

.border-test-legend {
  position: fixed;
  top: 16px;
  right: 52px;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(7, auto);
  gap: 8px 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 12px 30px rgba(25, 31, 36, 0.14);
  backdrop-filter: blur(14px);
  font-size: 11px;
  font-weight: 700;
}

.border-test-legend[hidden] {
  display: none;
}

.border-test-legend strong {
  grid-column: 1 / -1;
  font-size: 12px;
}

.border-test-legend span {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  white-space: nowrap;
}

.border-test-legend i {
  width: 14px;
  height: 3px;
  border-radius: 2px;
  background: var(--edge-colour);
}

.time-panel {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 2;
  width: min(360px, calc(100vw - 32px));
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 42px rgba(25, 31, 36, 0.16);
  backdrop-filter: blur(14px);
}

.time-panel[hidden] {
  display: none;
}

.time-panel h2 {
  margin: 0;
  font-size: 21px;
  line-height: 1.05;
}

.time-fields {
  display: grid;
  grid-template-columns: 0.85fr 1.2fr 0.8fr 0.8fr;
  gap: 8px;
}

.time-fields label {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.time-fields span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.time-fields input,
.time-fields select {
  width: 100%;
  height: 34px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
}

.time-fields input {
  padding: 0 8px;
}

.time-fields select {
  padding: 0 6px;
}

.time-slider {
  width: 100%;
  accent-color: var(--accent);
}

.boundary-sources {
  border-top: 1px solid var(--line);
  padding-top: 10px;
  color: var(--muted);
  font-size: 11px;
}

.boundary-sources summary {
  cursor: pointer;
  font-weight: 800;
}

.boundary-sources ol {
  max-height: 180px;
  margin: 9px 0 0;
  padding-left: 22px;
  overflow: auto;
}

.boundary-sources li {
  margin: 0 0 6px;
  line-height: 1.3;
}

.error {
  width: min(720px, calc(100vw - 32px));
  margin: 24px auto;
  padding: 16px;
  overflow: auto;
  border: 1px solid rgba(155, 44, 44, 0.25);
  border-radius: 8px;
  color: #4a1c1c;
  background: #fff7f7;
  white-space: pre-wrap;
}

.maplibregl-ctrl-bottom-left,
.maplibregl-ctrl-bottom-right {
  display: none;
}

@media (max-width: 640px) {
  .panel {
    top: 10px;
    left: 10px;
    width: calc(100vw - 20px);
    padding: 12px;
  }

  .stats {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 21px;
  }

  .time-panel {
    left: 10px;
    bottom: 10px;
    width: calc(100vw - 20px);
    padding: 12px;
  }

  .prompt-composer {
    bottom: 12px;
    width: calc(100vw - 20px);
  }

  .research-progress {
    top: 62px;
    width: calc(100vw - 20px);
  }

  .research-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .research-settings-wrap {
    top: 8px;
  }

  .panel {
    max-width: calc(100vw - 80px);
  }

  .time-panel h2 {
    font-size: 19px;
  }

  .border-test-legend {
    top: auto;
    right: 10px;
    bottom: 10px;
    left: 10px;
    grid-template-columns: repeat(7, 1fr);
  }
}
