:root {
  color-scheme: dark;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

#app {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: 100vh;
  height: 100dvh;
}

#panel {
  padding: 16px;
  border-right: 1px solid #2f3338;
  background: #111315;
  overflow-y: auto;
  min-height: 0;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.panel-heading h1 {
  margin: 0 0 4px;
}

.panel-toggle,
.panel-fab {
  flex-shrink: 0;
  background: #2a2f36;
  border: 1px solid #4a5159;
  color: #e6edf3;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  cursor: pointer;
}

.panel-toggle:hover,
.panel-fab:hover {
  background: #343b44;
}

.panel-fab {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 900;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

#app.panel-collapsed {
  grid-template-columns: 1fr;
}

#app.panel-collapsed #panel {
  display: none;
}

h1 {
  margin: 0 0 4px;
  font-size: 22px;
}

h2 {
  margin: 20px 0 8px;
  font-size: 14px;
}

.muted {
  color: #a9b0b7;
  font-size: 13px;
}

#locateBtn {
  margin-top: 10px;
  background: #1f6feb;
  border: 0;
  color: white;
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
}

#locateBtn:disabled {
  opacity: 0.6;
  cursor: wait;
}

.color-controls {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #2f3338;
}

.color-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 14px;
}

.color-row input[type="color"] {
  width: 44px;
  height: 28px;
  padding: 2px;
  border: 1px solid #7e858d;
  border-radius: 6px;
  background: #1a1d21;
  cursor: pointer;
}

.province-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 14px;
  font-size: 14px;
}

.province-row select {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #4a5159;
  background: #1a1d21;
  color: #e6edf3;
  font-size: 14px;
}

.toggle-row {
  display: block;
  margin-top: 14px;
  font-size: 14px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 14px;
}

.swatch {
  width: 20px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid #7e858d;
}

.swatch.crown {
  background: #ef9a9a;
  opacity: 0.85;
}

.swatch.not-crown {
  background: rgba(125, 125, 125, 0.35);
}

.swatch.wmu {
  background: transparent;
  border-color: #4fc3f7;
  border-style: dashed;
}

.inspect {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid #2f3338;
}

#selectionState {
  line-height: 1.45;
  font-size: 13px;
}

#selectionState a {
  color: #79c0ff;
}

.selection-divider {
  border: 0;
  border-top: 1px solid #2f3338;
  margin: 10px 0;
}

.selection-disclaimer {
  margin: 4px 0 8px;
  padding: 8px 10px;
  border: 1px solid #8a6d1d;
  border-radius: 6px;
  background: rgba(255, 193, 7, 0.14);
  color: #f3df9a;
  line-height: 1.45;
}

.selection-disclaimer strong {
  color: #ffd866;
}

.disclaimer {
  margin-top: 18px;
  padding: 10px 12px;
  border: 1px solid #8a6d1d;
  border-radius: 6px;
  background: rgba(255, 193, 7, 0.14);
  font-size: 12px;
  color: #f3df9a;
  line-height: 1.45;
}

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

.popup-content {
  color: #111315;
  font-size: 12px;
}

.popup-disclaimer {
  margin: 4px 0 8px;
  padding: 8px 10px;
  border: 1px solid #c9a227;
  border-radius: 6px;
  background: #fff8e1;
  color: #5c4a00;
  line-height: 1.45;
}

.popup-directions {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #ddd;
}

.popup-directions a {
  color: #1a56db;
  font-weight: 600;
}

.feedback-btn {
  display: block;
  width: 100%;
  margin-top: 14px;
  background: #2a2f36;
  border: 1px solid #4a5159;
  color: #e6edf3;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  cursor: pointer;
}

.feedback-btn:hover {
  background: #343b44;
}

.feedback-fab {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 900;
  background: #2a2f36;
  border: 1px solid #4a5159;
  color: #e6edf3;
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

.feedback-fab:hover {
  background: #343b44;
}

body.feedback-open {
  overflow: hidden;
}

.feedback-dialog {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 16px;
}

.feedback-dialog[hidden] {
  display: none;
}

.feedback-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.feedback-panel {
  position: relative;
  width: min(100%, 420px);
  background: #111315;
  border: 1px solid #2f3338;
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

.feedback-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.feedback-header h2 {
  margin: 0;
  font-size: 18px;
}

.feedback-close {
  background: transparent;
  border: 0;
  color: #a9b0b7;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

.feedback-close:hover {
  color: #e6edf3;
}

.feedback-intro {
  margin: 0 0 14px;
}

.feedback-field {
  display: block;
  margin-bottom: 12px;
  font-size: 14px;
}

.feedback-field > span {
  display: block;
  margin-bottom: 6px;
}

.feedback-field select,
.feedback-field textarea,
.feedback-field input {
  width: 100%;
  background: #1a1d21;
  border: 1px solid #4a5159;
  border-radius: 8px;
  color: #e6edf3;
  padding: 8px 10px;
  font: inherit;
}

.feedback-field textarea {
  resize: vertical;
  min-height: 96px;
}

.feedback-field select:focus,
.feedback-field textarea:focus,
.feedback-field input:focus {
  outline: 2px solid #1f6feb;
  outline-offset: 1px;
}

.feedback-status {
  margin: 0 0 12px;
  font-size: 13px;
}

.feedback-status.success {
  color: #7ee787;
}

.feedback-status.error {
  color: #ff7b72;
}

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

.feedback-cancel,
.feedback-submit {
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
  cursor: pointer;
}

.feedback-cancel {
  background: #2a2f36;
  border: 1px solid #4a5159;
  color: #e6edf3;
}

.feedback-cancel:hover {
  background: #343b44;
}

.feedback-submit {
  background: #1f6feb;
  border: 0;
  color: white;
}

.feedback-submit:hover:not(:disabled) {
  background: #388bfd;
}

.feedback-submit:disabled {
  opacity: 0.6;
  cursor: wait;
}

@media (max-width: 900px) {
  #app {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
  }

  #panel {
    position: fixed;
    inset: 0;
    z-index: 1000;
    width: 100%;
    max-height: 100vh;
    max-height: 100dvh;
    border-right: 0;
    border-bottom: 0;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  }

  #app.panel-collapsed #panel {
    display: none;
  }

  #map {
    grid-row: 1;
    min-height: 100vh;
    min-height: 100dvh;
  }
}
