:root {
  color-scheme: dark;
  --bg: #101418;
  --panel: #171d22;
  --panel-2: #20272d;
  --ink: #f6f8f8;
  --muted: #aebbc1;
  --line: rgba(255, 255, 255, 0.12);
  --blue: #145cff;
  --cyan: #13c9e8;
  --green: #29d36b;
  --yellow: #f2cd36;
  --red: #f04c43;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.34);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(140deg, rgba(19, 201, 232, 0.13), transparent 36%),
    linear-gradient(220deg, rgba(41, 211, 107, 0.1), transparent 42%),
    var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(100%, 460px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 14px 14px 28px;
}

.hero {
  position: relative;
  min-height: 132px;
  overflow: hidden;
  border-radius: 8px;
  box-shadow: 0 16px 46px rgba(0, 0, 0, 0.28);
  background:
    linear-gradient(145deg, rgba(19, 201, 232, 0.18), transparent 52%),
    #13344a;
  border: 1px solid #1d4e69;
}

.hero img {
  display: none;
}

.hero-shade {
  display: none;
}

.hero-content {
  position: absolute;
  inset: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
}

.kicker,
.eyebrow {
  margin: 0 0 6px;
  color: var(--cyan);
  font-size: 0.76rem;
  font-weight: 760;
  text-transform: uppercase;
}

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

h1 {
  max-width: 24ch;
  margin-bottom: 0;
  font-size: 1.05rem;
  line-height: 1.08;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.35rem;
}

h3 {
  margin-bottom: 0;
  font-size: 1.05rem;
}

.hero-status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(15, 20, 24, 0.72);
  color: #fff;
  font-size: 0.9rem;
}

.status-dot {
  position: relative;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  border-radius: 50%;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.28), transparent 46%),
    var(--orb-color, var(--green));
  box-shadow:
    0 0 0 5px color-mix(in srgb, var(--orb-color, var(--green)) 18%, transparent),
    0 0 18px color-mix(in srgb, var(--orb-color, var(--green)) 34%, transparent);
  overflow: hidden;
}

.status-dot::after {
  content: "";
  position: absolute;
  inset: 5px 4px auto;
  height: 2px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.68);
  opacity: 0.72;
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 14px 0;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(16, 20, 24, 0.88);
  backdrop-filter: blur(14px);
}

.tabs-main {
  min-width: 0;
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.tab-button,
.icon-button {
  min-height: 42px;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.tab-button.active {
  color: var(--ink);
  background: var(--panel-2);
}

.icon-button {
  width: 42px;
  color: var(--ink);
  background: var(--panel-2);
  font-size: 1.35rem;
}

.settings-tab-button {
  position: relative;
  width: 48px;
  min-height: 48px;
  flex: 0 0 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  background: var(--panel-2);
  font-size: 1.35rem;
}

.settings-tab-button:hover,
.settings-tab-button:focus-visible {
  background: color-mix(in srgb, var(--panel-2) 76%, #2d3940);
  outline: 0;
}

.settings-tab-button::after {
  content: attr(data-tooltip);
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  min-width: max-content;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: rgba(16, 20, 24, 0.96);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.24);
  font-size: 0.76rem;
  line-height: 1;
  opacity: 0;
  transform: translateY(4px);
  pointer-events: none;
  transition: opacity 120ms ease, transform 120ms ease;
}

.settings-tab-button:hover::after,
.settings-tab-button:focus-visible::after {
  opacity: 1;
  transform: translateY(0);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin: 18px 0 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  max-width: 142px;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toolbar {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.compact-select {
  min-height: 30px;
  max-width: 74px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: var(--panel);
  font-size: 0.78rem;
  outline: 0;
}

.station-grid,
.alert-list,
.picker-list,
.settings-grid {
  display: grid;
  gap: 10px;
}

.settings-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.settings-controls {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.settings-controls label {
  gap: 6px;
}

.auth-form,
.auth-signed-in {
  display: grid;
  gap: 10px;
}

.auth-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
}

.auth-form input {
  width: 100%;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(10, 14, 18, 0.78);
}

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

.station-group-heading {
  margin: 0 0 8px;
  color: var(--cyan);
  font-size: 0.76rem;
  font-weight: 760;
  text-transform: uppercase;
}

.station-group {
  display: grid;
  gap: 0;
}

.station-group-grid {
  display: grid;
  gap: 10px;
}

.area-panel {
  margin-bottom: 12px;
}

.map-controls-grid > .area-panel {
  margin-bottom: 0;
}

.compact-panel {
  min-width: 0;
  height: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
}

.map-controls-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(260px, 0.95fr);
  gap: 10px;
  margin-bottom: 12px;
  align-items: stretch;
}

.map-side-controls {
  display: grid;
  gap: 10px;
  height: 100%;
  align-content: stretch;
}

.area-label,
.area-summary {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.area-selector {
  display: grid;
  grid-template-columns: minmax(88px, auto) minmax(0, 1fr);
  gap: 8px;
  align-items: start;
}

.area-section {
  display: grid;
  gap: 5px;
}

.area-section-global {
  align-content: start;
  min-width: 88px;
}

.area-section-countries {
  min-width: 0;
}

.area-section-regions {
  grid-column: 1 / -1;
}

.area-section-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
}

.area-selector-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 1px;
}

.map-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.compact-toolbar {
  margin-bottom: 0;
  align-items: stretch;
}

.compact-toolbar .map-action {
  min-height: 36px;
  padding: 0 10px;
}

.compact-toolbar .pill {
  align-self: center;
  min-height: 28px;
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 12px;
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.76rem;
}

.map-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.map-legend-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.85);
}

.map-legend-dot.real {
  background: var(--green);
}

.map-legend-dot.model {
  background: #7aa7ff;
  border-style: dashed;
}

.map-legend-dot.dart {
  background: #8e74ff;
  border-style: dashed;
}

.map-legend-dot.other {
  background: #6f8da1;
}

.map-action {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel-2);
  cursor: pointer;
}

.map-action.secondary {
  background: var(--panel);
}

.area-chip {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: var(--panel);
  font-size: 0.76rem;
  white-space: nowrap;
  cursor: pointer;
}

.area-chip.active {
  background: var(--panel-2);
  border-color: rgba(255, 255, 255, 0.28);
}

.station-card,
.alert-card,
.picker-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent), var(--panel);
}

.station-card {
  position: relative;
  min-height: 210px;
  overflow: hidden;
  padding: 18px;
}

.station-card-actions {
  display: inline-flex;
  gap: 6px;
  margin-top: 10px;
}

.station-remove,
.station-map {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(16, 20, 24, 0.72);
  cursor: pointer;
}

.station-map:hover,
.station-map:focus-visible,
.station-remove:hover,
.station-remove:focus-visible {
  color: var(--ink);
  background: rgba(32, 39, 45, 0.96);
  outline: 0;
}

.orb-wrap {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 58px;
  aspect-ratio: 1;
}

.orb,
.orb-reflection {
  position: absolute;
  inset: 0;
  border-radius: 50%;
}

.orb {
  display: grid;
  place-items: center;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.2), transparent 44%),
    radial-gradient(circle at 42% 58%, color-mix(in srgb, var(--orb-color) 78%, #ffffff) 0 18%, transparent 42%),
    color-mix(in srgb, var(--orb-color) 76%, #17323a);
  border: 1px solid color-mix(in srgb, var(--orb-color) 24%, rgba(255, 255, 255, 0.22));
  box-shadow:
    0 0 0 8px color-mix(in srgb, var(--orb-color) 10%, transparent),
    0 10px 28px rgba(0, 0, 0, 0.24);
  overflow: hidden;
}

.orb::before,
.orb::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.orb::before {
  top: 10px;
  left: 13px;
  width: 14px;
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.28);
}

.orb::after {
  left: 15px;
  right: 15px;
  bottom: 18px;
  height: 3px;
  border-radius: 999px;
  background: rgba(247, 255, 255, 0.74);
  box-shadow:
    0 7px 0 rgba(247, 255, 255, 0.28),
    0 -7px 0 rgba(247, 255, 255, 0.2);
}

.orb-reflection {
  display: none;
}

.station-main {
  display: block;
  padding-right: 74px;
  min-height: 76px;
}

.station-id {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.78rem;
}

.picker-summary {
  margin: 6px 0 0;
  color: var(--ink);
  font-size: 0.82rem;
  opacity: 0.88;
}

.station-state {
  display: inline-flex;
  align-items: center;
  max-width: 178px;
  margin-top: 10px;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  font-size: 0.76rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.station-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.4;
}

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

.metrics div {
  min-height: 58px;
  padding: 9px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.14);
}

dt {
  color: var(--muted);
  font-size: 0.68rem;
}

dd {
  margin: 4px 0 0;
  font-size: 0.94rem;
  font-weight: 760;
}

.search-box {
  display: grid;
  gap: 6px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.74rem;
}

.search-box input {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  color: var(--ink);
  background: var(--panel);
}

.inline-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.inline-toggle input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--cyan);
}

.map-frame {
  position: relative;
  margin-bottom: 12px;
}

.real-map {
  height: 320px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background-color: #6ca2b8;
}

.leaflet-container {
  background: #6ca2b8;
  font: inherit;
}

.leaflet-control-zoom a {
  color: #0f1418;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: #171d22;
  color: var(--ink);
}

.leaflet-popup-content {
  margin: 10px 12px;
  font-size: 0.82rem;
}

.map-overlay-controls {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 800;
  display: grid;
  gap: 6px;
}

.map-overlay-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.map-overlay-button {
  min-width: 38px;
  min-height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(24, 32, 38, 0.92);
  cursor: pointer;
}

.buoy-popup {
  display: grid;
  gap: 6px;
}

.buoy-popup-hint {
  color: var(--muted);
  font-size: 0.72rem;
}

.buoy-popup-button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: var(--panel-2);
  cursor: pointer;
}

.buoy-tooltip {
  border: 0;
  border-radius: 999px;
  background: rgba(24, 32, 38, 0.92);
  color: var(--ink);
  box-shadow: none;
  font-size: 0.72rem;
  font-weight: 700;
 }

.buoy-tooltip::before {
  display: none;
}

.map-pin.selected::after {
  content: "";
  position: absolute;
  inset: -8px;
  border: 2px solid var(--pin-color);
  border-radius: 50%;
}

.picker-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  min-height: 72px;
  padding: 12px;
}

.picker-item p {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.82rem;
}

.select-button {
  min-width: 92px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: var(--panel-2);
  cursor: pointer;
}

.select-button.selected {
  background: var(--green);
  color: #071108;
}

.alert-card {
  padding: 14px;
}

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

.alert-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.alert-controls label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.76rem;
}

.alert-controls input {
  width: 100%;
  min-height: 42px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.18);
}

.alert-status {
  margin: 12px 0 0;
}

.switch {
  position: relative;
  width: 50px;
  height: 30px;
}

.switch input {
  position: absolute;
  opacity: 0;
}

.switch span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
}

.switch span::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  transition: transform 160ms ease;
}

.switch input:checked + span {
  background: var(--green);
}

.switch input:checked + span::after {
  transform: translateX(20px);
}

@media (min-width: 760px) {
  .app-shell {
    width: min(100%, 920px);
  }

  .hero {
    min-height: 132px;
  }

  h1 {
    max-width: 30ch;
    font-size: 1.05rem;
  }

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

  .station-group-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .map-panel {
    height: 360px;
  }
}

@media (max-width: 760px) {
  .map-controls-grid {
    grid-template-columns: 1fr;
  }

  .settings-grid,
  .settings-controls {
    grid-template-columns: 1fr;
  }

  .area-selector {
    grid-template-columns: 1fr;
  }

  .area-section-regions {
    grid-column: auto;
  }

  .compact-toolbar {
    flex-wrap: wrap;
  }

  .compact-toolbar .map-action {
    flex: 1 1 220px;
  }
}
