* {
  font-family: "Helvetica", "Arial", "sans-serif", "Century Gothic";
  touch-action: manipulation;
  -webkit-touch-callout: none;
}

:root {
  --margin: 15px;
  --background1: white;
  --fontcolor: rgb(0, 0, 0);
  --graphcolor: rgb(0, 0, 0);
  --graphcolorlight: rgba(0, 0, 0, 0.2);
  --selectcolor: rgb(239, 239, 239);
  --selectcolor_hover: rgb(221, 221, 221);
  --buttonwide: 150px;
  --buttonnormal: 90px;
  --linkcolor: rgb(3, 122, 255);
  --modalcolor: rgba(255, 255, 255, 0.55);
  --modalcolor_nobackdropfilter: rgba(255, 255, 255, 0.98);
  --modalpadding: 100px;
  --hoverline_color: rgb(0, 0, 0);
  --chart-grid: rgba(0, 0, 0, 0.12);
  --chart-tick: rgb(0, 0, 0);
}

[data-theme="dark"] {
  --background1: rgb(28, 28, 28);
  --fontcolor: rgb(240, 240, 240);
  --graphcolor: rgb(220, 220, 220);
  --graphcolorlight: rgba(150, 150, 150, 0.8);
  --selectcolor: rgb(99, 99, 99);
  --selectcolor_hover: rgb(70, 70, 70);
  --modalcolor: rgba(100, 100, 100, 0.6);
  --modalcolor_nobackdropfilter: rgb(45, 45, 45);
  --hoverline_color: rgb(175, 175, 175);
  --chart-grid: rgba(150, 150, 150, 0.2);
  --chart-tick: rgb(220, 220, 220);
}

@media (max-width: 600px) {
  :root {
    --margin: 0;
    --modalpadding: 0px;
    --buttonwide: 120px;
    --buttonnormal: 70px;
  }
}

html,
body {
  margin: 0;
  background-color: var(--background1);
  color: var(--fontcolor);
  -webkit-text-size-adjust: 100%;
}

body[data-fontsize="sm"] {
  font-size: 0.88rem;
}

body[data-fontsize="md"] {
  font-size: 1rem;
}

body[data-fontsize="lg"] {
  font-size: 1.08rem;
}

*,
.tick > text,
.legend,
.ylegend,
.ylegend2,
.xlegend,
.focus > text {
  color: var(--fontcolor);
  fill: var(--fontcolor);
}

#wrapper {
  position: relative;
  min-height: 101vh;
}

#logotable,
#main-content-table {
  width: 100%;
  border-collapse: collapse;
}

#logo {
  margin: var(--margin);
  height: 82px;
  border-radius: 4px;
  background: linear-gradient(180deg, rgba(34, 61, 89, 0.95) 0%, rgba(24, 39, 58, 0.98) 100%);
  overflow: hidden;
  position: relative;
}

#logo .inner {
  height: 100%;
  display: flex;
  align-items: center;
  padding-left: 20px;
  background:
    linear-gradient(125deg, rgba(255,255,255,0.12) 0%, rgba(255,255,255,0) 42%),
    linear-gradient(180deg, rgba(255,255,255,0.05) 0%, rgba(0,0,0,0.08) 100%);
}

#blur span {
  color: white;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.disclaimer,
.contact {
  margin: 0 var(--margin) 8px;
  text-align: center;
  font-size: 0.95em;
}

.disclaimer.red {
  color: #d44;
  font-weight: 700;
}

#flex-wrapper {
  display: flex;
  align-items: flex-start;
  gap: 0;
}

#main-content {
  flex: 1 1 auto;
  min-width: 0;
}

#contentid.content {
  padding: 0 var(--margin) 16px;
}

#slider-wrapper {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  margin: 0 0 12px;
}

.slidercontainer {
  display: flex;
  align-items: center;
  gap: 10px;
}

.shorter {
  width: 48px;
  font-weight: 700;
}

.sliderdiv {
  width: 180px;
}

.slider {
  width: 100%;
}

.parent {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 8px;
  margin-bottom: 10px;
}

.dropdown {
  position: relative;
  display: inline-block;
}

.dropbtn {
  min-width: var(--buttonnormal);
  padding: 9px 12px;
  border: 1px solid var(--graphcolorlight);
  background: var(--selectcolor);
  color: var(--fontcolor);
  font-size: 0.95rem;
  cursor: pointer;
}

.dropbtn.menu {
  min-width: var(--buttonwide);
}

.dropbtn.datemenu {
  min-width: 110px;
}

.dropbtn.smallbutton {
  min-width: 66px;
}

.dropbtn:hover,
.dropbtn:focus {
  background: var(--selectcolor_hover);
}

.dropbtn:focus-visible,
.station-button:focus-visible,
.station-input:focus-visible,
.maplocations:focus-visible,
.suggestion-button:focus-visible,
.quickstations button:focus-visible,
#map-btn:focus-visible,
.close:focus-visible,
.browser-option input:focus-visible,
.customgroup-item input:focus-visible,
.switch input:focus-visible + .toggleswitch,
.slider:focus-visible {
  outline: 2px solid var(--linkcolor);
  outline-offset: 2px;
}

.dropdown-content {
  display: none;
  position: absolute;
  z-index: 15;
  min-width: 180px;
  max-height: 320px;
  overflow: auto;
  background: var(--background1);
  border: 1px solid var(--graphcolorlight);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.24);
  text-align: left;
}

.dropdown-content.is-open {
  display: block;
}

.dropdown-content button,
.dropdown-content label,
.dropdown-content div {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: none;
  background: transparent;
  color: var(--fontcolor);
  text-align: left;
  cursor: pointer;
}

.dropdown-content button:hover,
.dropdown-content label:hover,
.dropdown-content div:hover {
  background: var(--selectcolor);
}

.browser-dropdown {
  min-width: 320px;
  max-width: min(90vw, 420px);
}

.browser-section-title {
  padding: 8px 10px 4px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--linkcolor);
}

.browser-option {
  display: flex !important;
  gap: 8px;
  align-items: flex-start;
}

.browser-option input {
  margin-top: 3px;
}

.browser-option-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.browser-option-meta {
  color: var(--graphcolor);
  opacity: 0.75;
  font-size: 0.82em;
}

#titleandgraphs {
  margin-top: 14px;
}

#titles {
  margin-bottom: 12px;
}

.title-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.maplocations {
  width: min(320px, 100%);
  padding: 8px 10px;
  border: 1px solid var(--graphcolorlight);
  background: var(--background1);
  color: var(--linkcolor);
  font-size: 1rem;
  font-weight: 700;
  appearance: none;
}

.ts-wrapper.station-select-shell {
  width: min(320px, 100%);
  min-width: min(320px, 100%);
  font-size: 1rem;
}

.ts-wrapper.station-select-shell.single .ts-control,
.ts-wrapper.station-select-shell .ts-dropdown {
  border: 1px solid var(--graphcolorlight);
  border-radius: 0;
  background: var(--background1);
  color: var(--fontcolor);
  box-shadow: none;
}

.ts-wrapper.station-select-shell.single .ts-control {
  min-height: 0;
  padding: 8px 10px;
}

.ts-wrapper.station-select-shell .ts-control input {
  color: var(--fontcolor);
}

.ts-wrapper.station-select-shell .ts-control .item {
  color: var(--linkcolor);
  font-weight: 700;
}

.ts-wrapper.station-select-shell.focus .ts-control,
.ts-wrapper.station-select-shell .ts-control:focus-within {
  outline: 2px solid var(--linkcolor);
  outline-offset: 2px;
}

.ts-wrapper.station-select-shell .ts-control input:focus-visible {
  outline: none;
}

.ts-wrapper.station-select-shell .ts-dropdown .selected,
.ts-wrapper.station-select-shell .ts-dropdown .option.selected {
  background: rgba(37, 99, 235, 0.26);
  color: #f8fbff;
}

.ts-wrapper.station-select-shell .ts-dropdown .active,
.ts-wrapper.station-select-shell .ts-dropdown .option.active {
  background: var(--selectcolor_hover);
  color: var(--fontcolor);
  box-shadow: inset 0 0 0 1px var(--linkcolor);
}

.station-input {
  width: min(320px, 100%);
  padding: 8px 10px;
  border: 1px solid var(--graphcolorlight);
  background: var(--background1);
  color: var(--fontcolor);
  font-size: 1rem;
}

.station-button {
  padding: 8px 12px;
  border: 1px solid var(--graphcolorlight);
  background: var(--selectcolor);
  color: var(--fontcolor);
}

.suggestions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: min(520px, 100%);
  margin-bottom: 8px;
}

.station-summary,
.view-status {
  min-height: 1.3em;
  margin-bottom: 6px;
  line-height: 1.35;
}

.station-summary {
  font-size: 0.92rem;
  color: var(--graphcolor);
}

.station-summary strong {
  color: var(--fontcolor);
}

.view-status {
  font-size: 0.84rem;
  color: var(--linkcolor);
}

.view-status.is-error {
  color: #d44;
}

.view-status.is-loading::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 8px;
  border: 2px solid rgba(127, 171, 255, 0.25);
  border-top-color: var(--linkcolor);
  border-radius: 50%;
  vertical-align: -1px;
  animation: spin 0.85s linear infinite;
}

.suggestion-button {
  padding: 8px 10px;
  border: 1px solid var(--graphcolorlight);
  background: var(--selectcolor);
  text-align: left;
}

.suggestion-button.is-active {
  background: var(--selectcolor_hover);
  outline: 1px solid var(--linkcolor);
}

.suggestion-button[aria-selected="true"] {
  background: var(--selectcolor_hover);
}

.suggestion-line {
  display: block;
}

.suggestion-line + .suggestion-line {
  font-size: 0.85em;
  opacity: 0.8;
}

.dateandinfo,
.boxwhiskerinfo {
  margin: 4px 0;
}

#boxwhiskerinfowrapper {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.boxwhiskerinfolink {
  color: var(--linkcolor);
  cursor: pointer;
}

#main {
  display: grid;
  grid-template-columns: repeat(var(--chart-columns, 2), minmax(0, 1fr));
  gap: 16px;
}

.chart-panel {
  border: 1px solid var(--graphcolorlight);
  background: var(--background1);
  padding: 12px;
  border-top-width: 3px;
}

.chart-panel.compact {
  padding-bottom: 8px;
}

.chart-panel.is-deterministic {
  border-top-color: rgba(242, 200, 102, 0.55);
}

.chart-panel.is-distribution {
  border-top-color: rgba(84, 163, 255, 0.55);
}

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

.chart-head-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chart-group-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--linkcolor);
}

.chart-title {
  margin: 0;
  font-size: 1.06rem;
  line-height: 1.25;
}

.chart-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}

.chart-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border: 1px solid var(--graphcolorlight);
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  background: var(--selectcolor);
}

.chart-badge.is-spread {
  border-color: rgba(84, 163, 255, 0.45);
}

.chart-badge.is-line {
  border-color: rgba(242, 200, 102, 0.4);
}

.chart-description {
  margin: 2px 0 0;
  opacity: 0.8;
  font-size: 0.84rem;
  line-height: 1.4;
}

.chart-meta {
  text-align: right;
  font-size: 0.82rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chart-frame {
  position: relative;
  height: var(--chart-height, 250px);
}

.chart-frame canvas {
  width: 100%;
  height: 100%;
}

.chart-note {
  margin: 2px 0 10px;
  font-size: 0.82rem;
  opacity: 0.72;
}

.chart-empty {
  padding: 32px 8px;
  text-align: center;
  opacity: 0.72;
}

#side-drawer {
  width: 0;
  overflow: hidden;
  transition: width 0.2s ease;
}

#side-drawer.show-drawer {
  width: 320px;
  margin-right: var(--margin);
}

#main-map.content {
  min-height: 100%;
  border-left: 1px solid var(--graphcolorlight);
  padding: 0 0 0 12px;
}

.drawer-section {
  margin-bottom: 18px;
}

.stationmapwrap {
  border: 1px solid var(--graphcolorlight);
  background:
    linear-gradient(180deg, rgba(83, 123, 168, 0.14) 0%, rgba(83, 123, 168, 0.04) 100%),
    var(--background1);
}

.stationmap {
  display: block;
  width: 100%;
  height: auto;
}

.stationmap-grid {
  stroke: var(--graphcolorlight);
  stroke-width: 1;
  stroke-dasharray: 4 6;
  opacity: 0.6;
}

.stationmap-frame {
  fill: rgba(93, 133, 179, 0.08);
  stroke: var(--graphcolorlight);
  stroke-width: 1.2;
}

.stationmap-label {
  fill: var(--graphcolor);
  font-size: 10px;
  opacity: 0.7;
}

.stationmap-marker {
  fill: #8ec8ff;
  stroke: #0d1a24;
  stroke-width: 1.2;
  cursor: pointer;
}

.stationmap-marker.is-active {
  fill: #ffbf52;
  stroke: #241406;
  stroke-width: 1.6;
}

.stationmap-text {
  fill: var(--fontcolor);
  font-size: 10px;
  font-weight: 700;
  paint-order: stroke;
  stroke: var(--background1);
  stroke-width: 3px;
  stroke-linejoin: round;
}

.stationmapstatus {
  margin-top: 8px;
  font-size: 0.85rem;
  line-height: 1.35;
  opacity: 0.86;
}

.drawer-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.drawer-subtitle {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.quickstations {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.quickstations button {
  padding: 7px 10px;
  border: 1px solid var(--graphcolorlight);
  background: var(--selectcolor);
}

.quickstations button.is-active {
  background: var(--linkcolor);
  color: white;
  border-color: var(--linkcolor);
}

.quickstations button.is-active:focus-visible {
  outline-color: white;
}

.drawerstatus {
  font-size: 0.9rem;
  line-height: 1.4;
}

#map-btn {
  position: sticky;
  top: 12px;
  align-self: flex-start;
  margin-right: var(--margin);
  padding: 10px 12px;
  border: 1px solid var(--graphcolorlight);
  background: var(--selectcolor);
  color: var(--fontcolor);
}

.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 30;
  padding-top: var(--modalpadding);
  background: var(--modalcolor);
  backdrop-filter: blur(2px);
}

.modal.is-open {
  display: block;
}

.modal-content {
  background: var(--modalcolor_nobackdropfilter);
  margin: auto;
  padding: 20px;
  border: 1px solid var(--graphcolorlight);
  width: min(900px, calc(100vw - 24px));
}

.close {
  float: right;
  font-size: 28px;
  font-weight: 700;
  cursor: pointer;
}

#settingstable {
  width: 100%;
  border-spacing: 6px;
}

#settingstable td {
  vertical-align: middle;
}

#settingstable tr > :nth-child(1) {
  width: 300px;
  text-align: left;
}

#settingstable tr > :nth-child(2) {
  width: 90px;
  text-align: center;
}

#settingstable tr > :nth-child(3) {
  text-align: center;
}

.settingstabletitle {
  font-weight: 700;
}

.setting-copy {
  text-align: left;
  font-size: 0.9em;
  opacity: 0.8;
}

.border {
  width: 20px;
  border: 2px solid var(--fontcolor);
  display: inline-block;
}

.center {
  display: inline-block;
  width: 160px;
}

.percentile-controls {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.percentile-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 8px;
}

.percentile-row label,
.percentile-value {
  font-size: 0.88em;
}

.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggleswitch {
  position: absolute;
  inset: 0;
  background-color: #777;
  transition: 0.2s;
}

.toggleswitch:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.2s;
}

input:checked + .toggleswitch {
  background-color: #2196f3;
}

input:checked + .toggleswitch:before {
  transform: translateX(24px);
}

.toggleswitch.round {
  border-radius: 24px;
}

.toggleswitch.round:before {
  border-radius: 50%;
}

.customgroupoptions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 8px;
  margin: 14px 0;
}

.customgroup-item {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 8px;
  border: 1px solid var(--graphcolorlight);
}

.customgroupactions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.is-hidden {
  display: none !important;
}

button:disabled,
select:disabled,
input:disabled {
  opacity: 0.58;
  cursor: wait;
}

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

  #flex-wrapper {
    flex-direction: column;
  }

  #side-drawer.show-drawer {
    width: auto;
    margin: 0 var(--margin) 12px;
  }

  #main-map.content {
    border-left: none;
    padding: 12px 0 0;
  }

  #map-btn {
    position: static;
    margin: 0 var(--margin) 12px;
  }

  .chart-head {
    flex-direction: column;
  }

  .chart-meta {
    width: 100%;
    text-align: left;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 10px;
  }
}

@media (max-width: 720px) {
  #contentid.content {
    padding: 0 10px 14px;
  }

  #logo {
    margin: 10px;
    height: 72px;
  }

  #blur span {
    font-size: 1.55rem;
  }

  #slider-wrapper {
    gap: 10px;
  }

  .slidercontainer {
    width: 100%;
    justify-content: space-between;
  }

  .sliderdiv {
    width: min(220px, 62vw);
  }

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

  .dropdown,
  .dropbtn,
  .dropbtn.menu,
  .dropbtn.datemenu,
  .dropbtn.smallbutton {
    width: 100%;
    min-width: 0;
  }

  .title-row > * {
    width: 100%;
  }

  .station-button {
    width: 100%;
  }

  .browser-dropdown {
    min-width: 0;
    width: min(92vw, 420px);
  }

  .suggestions {
    width: 100%;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
