:root {
  --tsp-shell-panel: #0f172a;
  --tsp-shell-panel-raised: #172033;
  --tsp-shell-border: rgba(103, 232, 249, 0.56);
  --tsp-shell-text: #e6f7ff;
  --tsp-shell-muted: #a8bac8;
  --tsp-shell-accent: #67e8f9;
}

.tsp-shell-popover {
  position: fixed;
  z-index: 2147483647;
  box-sizing: border-box;
  width: min(520px, calc(100vw - 24px));
  max-height: calc(100dvh - 96px);
  overflow: auto;
  border: 1px solid var(--tsp-shell-border);
  border-radius: 14px;
  padding: 18px;
  background-color: var(--tsp-shell-panel);
  background-image: none;
  color: var(--tsp-shell-text);
  box-shadow: 0 22px 64px rgba(0, 0, 0, 0.56);
  font-family: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  opacity: 1;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.tsp-shell-popover[data-kind="settings"] {
  width: min(400px, calc(100vw - 24px));
}

.tsp-shell-popover-arrow {
  position: absolute;
  top: -8px;
  left: var(--tsp-shell-arrow-left, 28px);
  z-index: 0;
  width: 16px;
  height: 16px;
  box-sizing: border-box;
  border-top: 1px solid var(--tsp-shell-border);
  border-left: 1px solid var(--tsp-shell-border);
  background-color: var(--tsp-shell-panel);
  transform: rotate(45deg);
}

.tsp-shell-popover-header,
.tsp-shell-popover-title,
.tsp-shell-tabs,
.tsp-theme-options {
  display: flex;
  align-items: center;
}

.tsp-shell-popover-header {
  position: relative;
  z-index: 1;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 13px;
  border-bottom: 1px solid rgba(103, 232, 249, 0.22);
}

.tsp-shell-popover-title {
  gap: 9px;
  min-width: 0;
}

.tsp-shell-popover-title h2 {
  margin: 0;
  color: var(--tsp-shell-accent);
  font-size: 19px;
  line-height: 1.3;
}

.tsp-shell-popover-icon {
  color: var(--tsp-shell-accent);
  font-size: 21px;
}

.tsp-shell-popover-close {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 9px;
  background: #243047;
  color: #cbd5e1;
  font-size: 23px;
  line-height: 1;
  cursor: pointer;
}

.tsp-shell-popover-close:hover,
.tsp-shell-popover-close:focus-visible {
  background: #334155;
  color: #fff;
  outline: 2px solid rgba(103, 232, 249, 0.48);
}

.tsp-shell-tabs {
  position: relative;
  z-index: 1;
  gap: 8px;
  margin: 14px 0 0;
}

.tsp-shell-tab {
  min-height: 38px;
  border: 1px solid #40506a;
  border-radius: 9px;
  padding: 7px 14px;
  background: #1b263a;
  color: #cbd5e1;
  font: 700 14px/1.2 inherit;
  cursor: pointer;
}

.tsp-shell-tab[aria-selected="true"] {
  border-color: #0891b2;
  background: #087b91;
  color: #fff;
}

.tsp-shell-tab:focus-visible {
  outline: 3px solid rgba(103, 232, 249, 0.35);
  outline-offset: 2px;
}

.tsp-shell-tab-panel {
  position: relative;
  z-index: 1;
  padding-top: 15px;
  color: var(--tsp-shell-text);
  font-size: 14px;
  line-height: 1.72;
}

.tsp-shell-tab-panel[hidden] {
  display: none;
}

.tsp-shell-tab-panel h3 {
  margin: 2px 0 8px;
  color: #cffafe;
  font-size: 16px;
}

.tsp-shell-tab-panel h4 {
  margin: 16px 0 5px;
  color: #bae6fd;
  font-size: 14px;
}

.tsp-shell-tab-panel p {
  margin: 6px 0 10px;
  color: var(--tsp-shell-muted);
}

.tsp-shell-tab-panel ol,
.tsp-shell-tab-panel ul {
  margin: 7px 0 11px;
  padding-left: 22px;
}

.tsp-shell-tab-panel li {
  margin: 5px 0;
}

.tsp-shell-notice {
  margin-top: 13px;
  border-left: 3px solid #22d3ee;
  border-radius: 7px;
  padding: 9px 11px;
  background: #17283a;
  color: #c6edf4;
}

.tsp-settings-section {
  position: relative;
  z-index: 1;
  padding-top: 16px;
}

.tsp-settings-section h3 {
  margin: 0;
  color: #cffafe;
  font-size: 16px;
}

.tsp-settings-section p {
  margin: 5px 0 13px;
  color: var(--tsp-shell-muted);
  font-size: 13px;
  line-height: 1.55;
}

.tsp-theme-options {
  gap: 10px;
}

.tsp-theme-option {
  flex: 1 1 0;
  display: grid;
  min-height: 84px;
  place-items: center;
  gap: 4px;
  border: 1px solid #40506a;
  border-radius: 11px;
  padding: 10px;
  background: #1b263a;
  color: #d8e4ec;
  font: 700 14px/1.25 inherit;
  cursor: pointer;
}

.tsp-theme-option span:first-child {
  font-size: 24px;
}

.tsp-theme-option[aria-pressed="true"] {
  border-color: #22d3ee;
  background: #0e6072;
  color: #fff;
  box-shadow: 0 0 0 2px rgba(34, 211, 238, 0.18);
}

.tsp-theme-option:focus-visible {
  outline: 3px solid rgba(103, 232, 249, 0.35);
  outline-offset: 2px;
}

/* The map toolbar and every panel it opens use a fully opaque surface. */
.tsp-map-toolbar,
.tsp-map-toolbar-collapsed > button,
.tsp-map-tool-panel,
.tsp-coordinate-convert-panel,
.tsp-map-layer-panel,
.tsp-map-context-menu,
.timespace-feedback-panel,
.timespace-feedback-arrow {
  background-color: #0f172a !important;
  background-image: none !important;
  opacity: 1 !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

.timespace-feedback-panel {
  right: auto !important;
}

.timespace-feedback-arrow {
  right: auto !important;
}

.tsp-site-header-title h1 {
  font-size: 32px !important;
  line-height: 1.15 !important;
}

.tsp-data-panel,
.tsp-mobile-data-drawer {
  container-name: tsp-data-panel;
  container-type: inline-size;
  min-width: 0;
}

.tsp-data-panel [data-radix-scroll-area-viewport] > div[style*="display: table"],
.tsp-mobile-data-drawer [data-radix-scroll-area-viewport] > div[style*="display: table"] {
  display: block !important;
  width: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
}

.tsp-evidence-asset-card {
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
}

.tsp-evidence-asset-card > .flex {
  min-width: 0;
  flex-wrap: wrap;
}

.tsp-evidence-asset-card > .flex > .flex-1 {
  flex: 1 1 180px;
}

.tsp-evidence-asset-actions {
  flex: 0 1 auto;
  min-width: 0;
}

.tsp-raster-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(124px, 1fr));
  gap: 7px 10px;
  min-width: 0;
}

.tsp-raster-control {
  display: block;
  min-width: 0;
  border-radius: 7px;
  padding: 5px 7px 6px;
  background: #111c30;
}

.tsp-raster-control input[type="range"] {
  display: block;
  width: 100%;
  min-width: 0;
  height: 16px;
  margin: 0;
  accent-color: #22d3ee;
}

@container tsp-data-panel (max-width: 460px) {
  .tsp-evidence-asset-card {
    padding: 8px !important;
  }

  .tsp-evidence-asset-card > .flex {
    gap: 7px !important;
  }

  .tsp-raster-controls {
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
    margin-top: 7px !important;
  }

  .tsp-raster-control {
    padding: 3px 6px 4px;
  }

  .tsp-raster-control > div {
    margin-bottom: 1px !important;
  }

  .tsp-raster-control input[type="range"] {
    height: 13px;
  }
}

html[data-tsp-theme="light"] {
  --tsp-shell-panel: #f8fbfc;
  --tsp-shell-panel-raised: #fff;
  --tsp-shell-border: #8bbeca;
  --tsp-shell-text: #173747;
  --tsp-shell-muted: #56717e;
  --tsp-shell-accent: #087b91;
  color-scheme: light;
}

html[data-tsp-theme="dark"] {
  color-scheme: dark;
}

html[data-tsp-theme="light"] body {
  background: #eaf2f5;
}

html[data-tsp-theme="light"] .tsp-app-shell {
  background: #eaf2f5 !important;
}

html[data-tsp-theme="light"] .tsp-app-shell > header,
html[data-tsp-theme="light"] .tsp-app-shell > footer,
html[data-tsp-theme="light"] .tsp-mobile-footer {
  border-color: #9ecbd4 !important;
  background: #f8fbfc !important;
  color: #173747 !important;
}

html[data-tsp-theme="light"] .tsp-app-shell > header > div.absolute.inset-0,
html[data-tsp-theme="light"] .tsp-app-shell > footer > div.absolute.inset-0,
html[data-tsp-theme="light"] .tsp-mobile-footer > div.absolute.inset-0 {
  background: none !important;
}

html[data-tsp-theme="light"] .tsp-site-header-actions button {
  color: #087b91 !important;
}

html[data-tsp-theme="light"] .tsp-site-header-actions button:hover,
html[data-tsp-theme="light"] .tsp-site-header-actions button:focus-visible {
  background: #dceef2 !important;
}

html[data-tsp-theme="light"] .tsp-data-rail,
html[data-tsp-theme="light"] .tsp-data-panel,
html[data-tsp-theme="light"] .tsp-mobile-data-drawer {
  border-color: #a7cdd5 !important;
  background: #f8fbfc !important;
  color: #173747 !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

html[data-tsp-theme="light"] .tsp-data-rail button,
html[data-tsp-theme="light"] .tsp-data-panel button,
html[data-tsp-theme="light"] .tsp-mobile-data-drawer button {
  color: #356373 !important;
}

html[data-tsp-theme="light"] .tsp-data-panel [class*="text-white"],
html[data-tsp-theme="light"] .tsp-mobile-data-drawer [class*="text-white"] {
  color: #173747 !important;
}

html[data-tsp-theme="light"] .tsp-data-panel [class*="text-slate-"],
html[data-tsp-theme="light"] .tsp-mobile-data-drawer [class*="text-slate-"] {
  color: #56717e !important;
}

html[data-tsp-theme="light"] .tsp-data-panel [class*="border-slate-"],
html[data-tsp-theme="light"] .tsp-mobile-data-drawer [class*="border-slate-"] {
  border-color: #b6cdd4 !important;
}

html[data-tsp-theme="light"] .tsp-data-panel [class*="bg-slate-8"],
html[data-tsp-theme="light"] .tsp-mobile-data-drawer [class*="bg-slate-8"] {
  background-color: #edf4f6 !important;
}

html[data-tsp-theme="light"] .tsp-data-panel button.bg-cyan-600,
html[data-tsp-theme="light"] .tsp-mobile-data-drawer button.bg-cyan-600 {
  background-color: #0891b2 !important;
  color: #fff !important;
}

html[data-tsp-theme="light"] .tsp-map-toolbar,
html[data-tsp-theme="light"] .tsp-map-toolbar-collapsed > button,
html[data-tsp-theme="light"] .tsp-map-tool-panel,
html[data-tsp-theme="light"] .tsp-coordinate-convert-panel,
html[data-tsp-theme="light"] .tsp-map-layer-panel,
html[data-tsp-theme="light"] .tsp-map-context-menu,
html[data-tsp-theme="light"] .timespace-feedback-panel,
html[data-tsp-theme="light"] .timespace-feedback-arrow {
  border-color: #8bbeca !important;
  background-color: #f8fbfc !important;
  color: #173747 !important;
}

html[data-tsp-theme="light"] .tsp-map-toolbar button {
  color: #087b91 !important;
}

html[data-tsp-theme="light"] .tsp-map-tool-panel [class*="text-slate-"],
html[data-tsp-theme="light"] .tsp-map-layer-panel [class*="text-slate-"],
html[data-tsp-theme="light"] .tsp-map-context-menu [class*="text-slate-"],
html[data-tsp-theme="light"] .timespace-feedback-panel p,
html[data-tsp-theme="light"] .timespace-feedback-panel span {
  color: #365967 !important;
  text-shadow: none !important;
}

@media (max-width: 1023px) {
  .tsp-site-header-title h1 {
    font-size: 24px !important;
  }

  .tsp-site-header-actions > button,
  .tsp-user-launcher[data-in-header="true"],
  .tsp-mobile-data-launcher,
  .tsp-map-toolbar button,
  .tsp-map-toolbar-collapsed > button,
  .leaflet-control-zoom a {
    min-width: 44px !important;
    min-height: 44px !important;
  }

  .tsp-site-header-actions > button,
  .tsp-map-toolbar button,
  .tsp-map-toolbar-collapsed > button {
    width: 44px !important;
    height: 44px !important;
  }

  .tsp-user-launcher[data-in-header="true"],
  .tsp-mobile-data-launcher {
    height: 44px !important;
  }

  .tsp-app-shell button[class~="rounded-full"][class~="h-10"][class~="w-10"] {
    width: 44px !important;
    height: 44px !important;
  }

  .tsp-app-shell button[class*="bg-slate-900/95"][class*="border-cyan-500/50"] {
    min-height: 44px !important;
  }

  .leaflet-control-zoom a {
    width: 44px !important;
    height: 44px !important;
    line-height: 44px !important;
  }
}

@media (max-width: 640px) {
  .tsp-site-header-title h1 {
    font-size: 18px !important;
  }
}

/* V114: compact mobile map chrome while preserving the desktop layout. */
.tsp-mobile-header-menu {
  display: none;
}

@media (max-width: 767px) {
  .tsp-app-shell > header {
    min-height: 48px !important;
    height: 48px !important;
    padding: 0 6px !important;
  }

  .tsp-app-shell > header > img {
    width: 28px !important;
    height: 28px !important;
  }

  .tsp-site-header-title {
    position: absolute !important;
    inset: 0 38px !important;
    display: flex !important;
    width: auto !important;
    padding: 0 !important;
    transform: none !important;
    justify-content: center !important;
    pointer-events: none;
  }

  .tsp-site-header-title h1 {
    width: auto !important;
    max-width: 100% !important;
    overflow: visible !important;
    color: #67e8f9;
    font-size: clamp(10px, 3.35vw, 15px) !important;
    line-height: 1.1 !important;
    letter-spacing: 0 !important;
    text-align: center !important;
    text-overflow: clip !important;
    white-space: nowrap !important;
  }

  .tsp-site-header-actions {
    position: absolute !important;
    top: 7px !important;
    right: 6px !important;
    z-index: 1200 !important;
    flex-direction: column !important;
    align-items: stretch !important;
    width: 32px !important;
    min-width: 32px !important;
    max-width: 172px !important;
    gap: 3px !important;
  }

  .tsp-mobile-header-menu {
    display: inline-flex !important;
    align-self: flex-end;
    align-items: center;
    justify-content: center;
    width: 32px !important;
    min-width: 32px !important;
    height: 32px !important;
    min-height: 32px !important;
    border: 1px solid rgba(103, 232, 249, 0.42);
    border-radius: 8px;
    padding: 0 !important;
    background: #0f172a;
    color: #67e8f9;
    font: 800 20px/1 system-ui, sans-serif;
  }

  .tsp-site-header-actions:not([data-mobile-open="true"]) > :not(.tsp-mobile-header-menu) {
    display: none !important;
  }

  .tsp-site-header-actions[data-mobile-open="true"] {
    width: 164px !important;
    padding: 4px !important;
    border: 1px solid rgba(103, 232, 249, 0.42);
    border-radius: 10px;
    background: #0f172a;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.42);
  }

  .tsp-site-header-actions[data-mobile-open="true"] #tsp-header-utility-slot,
  .tsp-site-header-actions[data-mobile-open="true"] #tsp-user-launcher-slot {
    display: flex !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    flex-direction: column !important;
    gap: 3px !important;
  }

  .tsp-site-header-actions[data-mobile-open="true"] .tsp-header-utility,
  .tsp-site-header-actions[data-mobile-open="true"] .tsp-user-launcher[data-in-header="true"],
  .tsp-site-header-actions[data-mobile-open="true"] > button:not(.tsp-mobile-header-menu) {
    display: flex !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    height: 30px !important;
    min-height: 30px !important;
    justify-content: center !important;
    border-radius: 7px !important;
    padding: 0 7px !important;
    font-size: 11px !important;
  }

  .tsp-mobile-data-launcher {
    top: 54px !important;
    left: 6px !important;
    min-width: 0 !important;
    min-height: 32px !important;
    height: 32px !important;
    border-radius: 8px !important;
    padding: 0 9px !important;
    font-size: 11px !important;
  }

  .tsp-mobile-data-launcher svg {
    width: 14px !important;
    height: 14px !important;
    margin-right: 5px !important;
  }

  .tsp-mobile-data-backdrop {
    background: rgba(0, 0, 0, 0.08) !important;
  }

  .tsp-mobile-data-drawer {
    top: 90px !important;
    right: auto !important;
    bottom: auto !important;
    left: 6px !important;
    width: min(78vw, 286px) !important;
    max-width: 286px !important;
    height: min(44dvh, 330px) !important;
    max-height: calc(100dvh - 132px) !important;
    border: 1px solid rgba(34, 211, 238, 0.46) !important;
    border-radius: 10px !important;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.5) !important;
  }

  .tsp-mobile-data-drawer > div:first-child {
    min-height: 30px !important;
    padding: 3px 6px !important;
  }

  .tsp-mobile-data-drawer button {
    min-width: 28px !important;
    min-height: 28px !important;
    font-size: 10px !important;
  }

  .tsp-mobile-data-drawer [role="tablist"] {
    margin: 3px 4px 0 !important;
    padding: 1px !important;
  }

  .tsp-mobile-data-drawer [role="tab"] {
    min-height: 32px !important;
    gap: 1px !important;
    padding: 2px 1px !important;
  }

  .tsp-mobile-data-drawer [role="tab"] svg {
    width: 12px !important;
    height: 12px !important;
  }

  .tsp-mobile-data-drawer [role="tab"] span {
    font-size: 9px !important;
  }

  .tsp-mobile-data-drawer [data-radix-scroll-area-viewport] .px-3.py-4 {
    padding: 5px !important;
  }

  .tsp-mobile-data-drawer input,
  .tsp-mobile-data-drawer select,
  .tsp-mobile-data-drawer textarea {
    min-height: 28px !important;
    padding: 3px 5px !important;
    font-size: 10px !important;
  }

  .tsp-mobile-data-drawer p,
  .tsp-mobile-data-drawer label,
  .tsp-mobile-data-drawer [class*="text-sm"],
  .tsp-mobile-data-drawer [class*="text-xs"] {
    font-size: 9px !important;
    line-height: 1.25 !important;
  }

  .tsp-map-toolbar,
  .tsp-map-toolbar-collapsed {
    top: auto !important;
    right: 6px !important;
    bottom: 32px !important;
  }

  .tsp-map-toolbar {
    max-height: min(58dvh, 360px) !important;
    gap: 1px !important;
    padding: 2px !important;
    border-radius: 8px !important;
  }

  .tsp-map-toolbar button,
  .tsp-map-toolbar-collapsed > button {
    width: 32px !important;
    min-width: 32px !important;
    height: 32px !important;
    min-height: 32px !important;
    border-radius: 6px !important;
    padding: 0 !important;
  }

  .tsp-map-toolbar button svg,
  .tsp-map-toolbar-collapsed > button svg {
    width: 15px !important;
    height: 15px !important;
  }

  .tsp-geolocation-control {
    top: auto !important;
    right: 6px !important;
    bottom: calc(38px + min(58dvh, 360px)) !important;
  }

  .tsp-geolocation-control button {
    width: 32px !important;
    min-width: 32px !important;
    height: 32px !important;
    min-height: 32px !important;
  }

  .tsp-map-tool-panel:not([data-drag-active="true"]),
  .tsp-map-tool-panel-wide:not([data-drag-active="true"]),
  .tsp-coordinate-convert-panel:not([data-drag-active="true"]) {
    top: 54px !important;
    right: 44px !important;
    left: auto !important;
  }

  .tsp-map-tool-panel,
  .tsp-map-tool-panel-wide,
  .tsp-coordinate-convert-panel {
    width: min(70vw, 260px) !important;
    max-width: calc(100vw - 54px) !important;
    max-height: min(58dvh, 360px) !important;
    border-radius: 9px !important;
    padding: 8px !important;
    font-size: 10px !important;
  }

  .tsp-map-tool-panel h2,
  .tsp-map-tool-panel h3,
  .tsp-map-tool-panel [class*="text-lg"],
  .tsp-map-tool-panel [class*="text-base"] {
    font-size: 12px !important;
    line-height: 1.25 !important;
  }

  .tsp-map-tool-panel p,
  .tsp-map-tool-panel label,
  .tsp-map-tool-panel span,
  .tsp-map-tool-panel [class*="text-sm"],
  .tsp-map-tool-panel [class*="text-xs"] {
    font-size: 10px !important;
    line-height: 1.3 !important;
  }

  .tsp-map-tool-panel button,
  .tsp-coordinate-convert-panel button {
    min-height: 28px !important;
    border-radius: 6px !important;
    padding: 3px 6px !important;
    font-size: 10px !important;
  }

  .tsp-map-tool-panel input,
  .tsp-map-tool-panel select,
  .tsp-map-tool-panel textarea,
  .tsp-coordinate-convert-panel input,
  .tsp-coordinate-convert-panel select,
  .tsp-coordinate-convert-panel textarea {
    min-height: 28px !important;
    padding: 3px 5px !important;
    font-size: 10px !important;
  }

  .tsp-map-tool-panel textarea,
  .tsp-coordinate-convert-panel textarea {
    max-height: 92px !important;
  }

  .tsp-map-tool-panel .mb-4,
  .tsp-map-tool-panel .mb-3,
  .tsp-map-tool-panel .mb-2 {
    margin-bottom: 5px !important;
  }

  .tsp-map-tool-panel .gap-4,
  .tsp-map-tool-panel .gap-3,
  .tsp-map-tool-panel .gap-2 {
    gap: 5px !important;
  }

  .tsp-shell-popover {
    width: min(82vw, 300px) !important;
    max-height: 62dvh !important;
    border-radius: 10px !important;
    padding: 9px !important;
    font-size: 11px !important;
  }

  .tsp-shell-popover-title h2 {
    font-size: 14px !important;
  }

  .tsp-shell-tab {
    min-height: 30px !important;
    padding: 4px 7px !important;
    font-size: 10px !important;
  }
}

html[data-tsp-theme="light"] .tsp-map-tool-panel input,
html[data-tsp-theme="light"] .tsp-map-tool-panel select,
html[data-tsp-theme="light"] .tsp-map-tool-panel textarea {
  border-color: #aac8d0 !important;
  background: #fff !important;
  color: #173747 !important;
}

html[data-tsp-theme="light"] .tsp-map-tool-panel [class*="bg-slate-8"],
html[data-tsp-theme="light"] .tsp-map-layer-panel [class*="bg-slate-8"] {
  background-color: #e7f1f4 !important;
}

html[data-tsp-theme="light"] .tsp-raster-control {
  background: #e7f1f4;
}

html[data-tsp-theme="light"] .timespace-compliance-footer,
html[data-tsp-theme="light"] .timespace-compliance-footer a {
  color: #426472 !important;
}

html[data-tsp-theme="light"] .tsp-shell-popover-close {
  background: #e4eef2;
  color: #315867;
}

html[data-tsp-theme="light"] .tsp-shell-tab,
html[data-tsp-theme="light"] .tsp-theme-option {
  border-color: #b7cfd7;
  background: #edf5f7;
  color: #315867;
}

html[data-tsp-theme="light"] .tsp-shell-tab[aria-selected="true"],
html[data-tsp-theme="light"] .tsp-theme-option[aria-pressed="true"] {
  border-color: #087b91;
  background: #087b91;
  color: #fff;
}

html[data-tsp-theme="light"] .tsp-shell-tab-panel h3,
html[data-tsp-theme="light"] .tsp-shell-tab-panel h4,
html[data-tsp-theme="light"] .tsp-settings-section h3 {
  color: #0b5365;
}

html[data-tsp-theme="light"] .tsp-shell-notice {
  background: #e6f4f7;
  color: #275664;
}

@media (max-width: 640px) {
  .tsp-shell-popover {
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 74px);
    padding: 14px;
  }

  .tsp-shell-popover[data-kind="settings"] {
    width: calc(100vw - 16px);
  }

  .tsp-shell-tabs {
    overflow-x: auto;
  }

  .tsp-shell-tab {
    flex: 1 0 auto;
  }

  .tsp-raster-controls {
    grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
    gap: 6px;
  }
}

@media (max-width: 767px) and (orientation: portrait) {
  .tsp-map-toolbar {
    max-height: calc(100% - 176px) !important;
    scrollbar-width: thin;
  }

  .tsp-mobile-data-drawer button {
    min-width: 44px !important;
    min-height: 44px !important;
  }

  .tsp-mobile-data-backdrop {
    background: rgba(0, 0, 0, 0.16) !important;
  }

  .tsp-mobile-data-drawer {
    left: 6px !important;
    right: 6px !important;
    top: auto !important;
    bottom: 50px !important;
    width: auto !important;
    max-width: none !important;
    height: min(52vh, 470px) !important;
    max-height: 52vh !important;
    border: 1px solid rgba(34, 211, 238, 0.45) !important;
    border-bottom: 0 !important;
    border-radius: 14px 14px 0 0;
    overflow: hidden;
  }

  .tsp-mobile-data-drawer > div:first-child {
    min-height: 38px;
    padding: 5px 9px !important;
  }

  .tsp-mobile-data-drawer [role="tablist"] {
    margin: 4px 6px 0 !important;
    padding: 2px !important;
  }

  .tsp-mobile-data-drawer [role="tab"] {
    gap: 1px !important;
    padding-top: 4px !important;
    padding-bottom: 4px !important;
  }

  .tsp-mobile-data-drawer [role="tab"] span {
    font-size: 11px !important;
    line-height: 1.05 !important;
  }

  .tsp-mobile-data-drawer [data-radix-scroll-area-viewport] .px-3.py-4 {
    padding: 7px !important;
  }

  .tsp-mobile-data-drawer .tsp-raster-controls {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 4px !important;
    margin-top: 7px !important;
  }

  .tsp-mobile-data-drawer .tsp-raster-control {
    padding: 3px 6px 4px;
  }

  .tsp-mobile-data-drawer .tsp-raster-control > div {
    margin-bottom: 1px !important;
  }

  .tsp-mobile-data-drawer .tsp-raster-control input[type="range"] {
    height: 13px;
  }
}

@media (max-width: 1023px) and (orientation: landscape) {
  .tsp-mobile-data-drawer {
    width: min(46vw, 420px) !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tsp-shell-popover *,
  .tsp-shell-popover {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}

/* 20260730: keep the embedded multi-source workbench readable at every viewport. */
.tsp-multisource-embed-header {
  display: grid !important;
  grid-template-columns: minmax(180px, 1fr) repeat(4, max-content);
  align-items: center;
}

.tsp-multisource-embed-title {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.tsp-multisource-embed-frame {
  min-width: 0;
  min-height: 0;
  flex: 1 1 auto;
}

/* The status card belongs beside the right toolbar, not underneath it. */
.tsp-geolocation-status {
  right: calc(100% + 12px) !important;
  width: max-content;
  max-width: calc(100vw - 96px) !important;
  white-space: normal !important;
}

.tsp-geolocation-status > div {
  white-space: nowrap;
}

.tsp-geolocation-error {
  min-width: min(180px, calc(100vw - 96px));
}

@media (max-width: 640px) {
  .tsp-multisource-embed-backdrop {
    padding: 0 !important;
  }

  .tsp-multisource-embed-shell {
    width: 100vw !important;
    height: 100dvh !important;
    max-width: 100vw !important;
    max-height: 100dvh !important;
    margin: 0 !important;
    border-radius: 0 !important;
  }

  .tsp-multisource-embed-header {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px !important;
    padding: 6px !important;
  }

  .tsp-multisource-embed-title {
    grid-column: 1 / -1;
    padding: 0 4px !important;
    font-size: 14px;
    line-height: 20px;
  }

  .tsp-multisource-embed-header > button {
    width: 100%;
    min-width: 0;
    padding-right: 4px !important;
    padding-left: 4px !important;
    font-size: 12px;
  }
}

/* Keep V114 mobile sizing last in the cascade. */
@media (max-width: 767px) {
  .tsp-site-header-actions > .tsp-mobile-header-menu {
    width: 32px !important;
    min-width: 32px !important;
    height: 32px !important;
    min-height: 32px !important;
  }

  .tsp-shell-popover,
  .tsp-shell-popover[data-kind="settings"] {
    width: min(82vw, 300px) !important;
    max-height: 62dvh !important;
    padding: 9px !important;
  }

  .tsp-map-toolbar {
    max-height: min(58dvh, 360px) !important;
  }

  .tsp-mobile-data-drawer button {
    min-width: 28px !important;
    min-height: 28px !important;
  }

  .tsp-mobile-data-backdrop {
    background: rgba(0, 0, 0, 0.08) !important;
  }

  .tsp-mobile-data-drawer {
    top: 90px !important;
    right: auto !important;
    bottom: auto !important;
    left: 6px !important;
    width: min(78vw, 286px) !important;
    max-width: 286px !important;
    height: min(44dvh, 330px) !important;
    max-height: calc(100dvh - 132px) !important;
    border: 1px solid rgba(34, 211, 238, 0.46) !important;
    border-radius: 10px !important;
  }

  .tsp-mobile-data-drawer > div:first-child {
    min-height: 30px !important;
    padding: 3px 6px !important;
  }

  .tsp-mobile-data-drawer [role="tablist"] {
    margin: 3px 4px 0 !important;
    padding: 1px !important;
  }

  .tsp-mobile-data-drawer [role="tab"] {
    min-height: 32px !important;
    gap: 1px !important;
    padding: 2px 1px !important;
  }

  .tsp-mobile-data-drawer [role="tab"] span {
    font-size: 9px !important;
  }

  .tsp-mobile-data-drawer [data-radix-scroll-area-viewport] .px-3.py-4 {
    padding: 5px !important;
  }
}
