:root {
  --pwa-safe-top: env(safe-area-inset-top, 0px);
  --pwa-safe-right: env(safe-area-inset-right, 0px);
  --pwa-safe-bottom: env(safe-area-inset-bottom, 0px);
  --pwa-safe-left: env(safe-area-inset-left, 0px);
  --pwa-app-bar: 56px;
  --pwa-tab-bar: 64px;
  --pwa-surface: #ffffff;
  --pwa-canvas: #f3f5f8;
  --pwa-ink: #131b23;
  --pwa-muted: #66717c;
  --pwa-line: #dce1e8;
  --pwa-brand: #2658e8;
  --pwa-night: #101a2c;
}

html.is-tool-pwa-root {
  min-height: 100%;
  overflow-x: clip;
  background: var(--pwa-canvas);
  color-scheme: light;
}

body.is-tool-pwa {
  min-height: 100dvh;
  min-height: var(--pwa-viewport-height, 100dvh);
  overflow-x: clip;
  scroll-padding-top: calc(var(--pwa-app-bar) + var(--pwa-safe-top) + 12px);
  scroll-padding-bottom: calc(var(--pwa-tab-bar) + var(--pwa-safe-bottom) + 12px);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: rgba(38, 88, 232, .14);
}

body.is-tool-pwa img,
body.is-tool-pwa canvas,
body.is-tool-pwa svg {
  max-width: 100%;
}

body.is-tool-pwa input,
body.is-tool-pwa select,
body.is-tool-pwa textarea {
  max-width: 100%;
  font-size: max(16px, 1em);
}

body.is-tool-pwa button,
body.is-tool-pwa a,
body.is-tool-pwa summary,
body.is-tool-pwa input[type="range"] {
  touch-action: manipulation;
}

body.is-tool-pwa button:disabled,
body.is-tool-pwa [aria-disabled="true"] {
  cursor: not-allowed;
  opacity: .5;
}

body.is-tool-pwa button[aria-busy="true"] {
  cursor: progress;
  opacity: .72;
}

body.is-tool-pwa :focus-visible {
  outline: 3px solid rgba(38, 88, 232, .28);
  outline-offset: 2px;
}

.pwa-app-bar,
.pwa-app-tabs,
.pwa-install-sheet,
.pwa-toast {
  display: none;
}

.pwa-app-bar {
  position: sticky;
  z-index: 700;
  top: 0;
  min-height: calc(var(--pwa-app-bar) + var(--pwa-safe-top));
  padding: var(--pwa-safe-top) var(--pwa-safe-right) 0 var(--pwa-safe-left);
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  background: rgba(16, 26, 44, .98);
  color: #fff;
  box-shadow: 0 1px 0 rgba(16, 26, 44, .14);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}

.pwa-app-bar__inner {
  height: var(--pwa-app-bar);
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 48px;
  align-items: center;
  gap: 4px;
  padding: 0 6px;
}

.pwa-app-bar__slot,
.pwa-app-bar__action {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  justify-self: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #fff;
  font: 700 12px/1 Poppins, Arial, sans-serif;
  text-decoration: none;
  cursor: pointer;
}

.pwa-app-bar__slot:active,
.pwa-app-bar__action:active,
.pwa-app-tabs a:active,
.pwa-sheet__button:active {
  background: rgba(255, 255, 255, .12);
  transform: scale(.97);
}

.pwa-app-bar__slot img {
  width: 32px;
  height: 32px;
  border-radius: 8px;
}

.pwa-app-bar__slot span {
  font-size: 25px;
  font-weight: 400;
  line-height: 1;
}

.pwa-app-bar__title {
  min-width: 0;
  text-align: center;
}

.pwa-app-bar__title small,
.pwa-app-bar__title strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pwa-app-bar__title small {
  color: #9fc0ff;
  font-size: 9px;
  font-weight: 700;
  line-height: 1.2;
  text-transform: uppercase;
}

.pwa-app-bar__title strong {
  margin-top: 3px;
  color: #fff;
  font-size: 13px;
  line-height: 1.2;
}

.pwa-app-bar__action {
  width: auto;
  max-width: 54px;
  padding: 0 8px;
  color: #dbe6ff;
  font-size: 10px;
}

.pwa-app-bar__action[hidden] {
  display: none;
}

.pwa-app-bar__action.is-ready {
  border: 1px solid rgba(159, 192, 255, .48);
  background: rgba(38, 88, 232, .3);
  color: #fff;
}

.pwa-app-tabs {
  position: fixed;
  z-index: 720;
  right: 0;
  bottom: 0;
  left: 0;
  min-height: calc(var(--pwa-tab-bar) + var(--pwa-safe-bottom));
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 6px max(8px, var(--pwa-safe-right)) var(--pwa-safe-bottom) max(8px, var(--pwa-safe-left));
  border-top: 1px solid var(--pwa-line);
  background: rgba(255, 255, 255, .97);
  box-shadow: 0 -10px 30px rgba(19, 27, 35, .08);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}

.pwa-app-tabs a {
  min-width: 0;
  min-height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-radius: 8px;
  color: #68717a;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
  text-decoration: none;
}

.pwa-app-tabs a[aria-current="page"] {
  background: #edf2ff;
  color: var(--pwa-brand);
}

.pwa-app-tabs b {
  min-height: 20px;
  font-size: 18px;
  font-weight: 500;
  line-height: 20px;
}

.pwa-app-tabs .pwa-app-tabs__download {
  color: var(--pwa-brand);
}

.pwa-toast {
  position: fixed;
  z-index: 780;
  top: calc(var(--pwa-safe-top) + var(--pwa-app-bar) + 10px);
  left: 50%;
  width: min(calc(100% - 28px), 420px);
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 8px;
  background: #101a2c;
  color: #fff;
  box-shadow: 0 14px 36px rgba(16, 26, 44, .2);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -8px);
  transition: opacity .18s ease, transform .18s ease;
}

.pwa-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.pwa-toast.is-error {
  background: #8f2530;
}

.pwa-toast.is-success {
  background: #17653d;
}

.pwa-install-sheet {
  position: fixed;
  z-index: 800;
  inset: 0;
  align-items: end;
  justify-content: center;
  padding: 20px max(12px, var(--pwa-safe-right)) calc(12px + var(--pwa-safe-bottom)) max(12px, var(--pwa-safe-left));
  background: rgba(8, 15, 27, .55);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}

.pwa-install-sheet.is-open {
  display: flex;
}

.pwa-sheet__panel {
  width: min(100%, 480px);
  max-height: min(560px, calc(100dvh - var(--pwa-safe-top) - 32px));
  overflow: auto;
  overscroll-behavior: contain;
  padding: 18px;
  border-radius: 8px;
  background: #fff;
  color: var(--pwa-ink);
  box-shadow: 0 24px 70px rgba(8, 15, 27, .24);
}

.pwa-sheet__head {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 10px;
}

.pwa-sheet__head img {
  width: 42px;
  height: 42px;
  border-radius: 10px;
}

.pwa-sheet__head h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

.pwa-sheet__close {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 8px;
  background: #eef1f5;
  color: #27313b;
  font-size: 22px;
  cursor: pointer;
}

.pwa-sheet__steps {
  display: grid;
  gap: 12px;
  margin: 18px 0;
  padding: 0;
  list-style: none;
}

.pwa-sheet__steps li {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  color: #4f5a65;
  font-size: 13px;
  line-height: 1.55;
}

.pwa-sheet__steps b {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #edf2ff;
  color: var(--pwa-brand);
  font-size: 12px;
}

.pwa-sheet__button {
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  background: var(--pwa-brand);
  color: #fff;
  font: 700 13px Poppins, Arial, sans-serif;
  cursor: pointer;
}

body.pwa-dialog-open {
  overflow: hidden;
}

@media (max-width: 800px), (display-mode: standalone) {
  body.is-tool-pwa {
    padding-bottom: calc(var(--pwa-tab-bar) + var(--pwa-safe-bottom));
    background: var(--pwa-canvas);
  }

  body.is-tool-pwa > .seo-header,
  body.is-tool-pwa > .seo-footer,
  body.is-tool-pwa .calc-app-cta {
    display: none;
  }

  .pwa-app-bar {
    display: block;
  }

  .pwa-app-tabs {
    display: grid;
  }

  .pwa-toast {
    display: flex;
  }

  body.is-tool-pwa .site-width {
    width: 100%;
    max-width: none;
    padding-right: max(14px, var(--pwa-safe-right));
    padding-left: max(14px, var(--pwa-safe-left));
  }

  body.is-tool-pwa .tools-hub-hero,
  body.is-tool-pwa .calc-intro,
  body.is-tool-pwa .advanced-hero,
  body.is-tool-pwa .assessment-hero,
  body.is-tool-pwa .comparison-hero,
  body.is-tool-pwa .photo-check-hero,
  body.is-tool-pwa .mission-hero,
  body.is-tool-pwa .database-hero {
    min-height: 0;
    padding: 14px 0 12px;
    border-bottom: 1px solid var(--pwa-line);
    background: #fff;
    color: var(--pwa-ink);
  }

  body.is-tool-pwa .calc-breadcrumb,
  body.is-tool-pwa .advanced-kicker,
  body.is-tool-pwa .comparison-kicker,
  body.is-tool-pwa .assessment-kicker,
  body.is-tool-pwa .photo-check-kicker,
  body.is-tool-pwa .mission-kicker,
  body.is-tool-pwa .tools-hub-hero .section-kicker,
  body.is-tool-pwa .database-hero > div > p:first-child {
    display: none;
  }

  body.is-tool-pwa .tools-hub-hero h1,
  body.is-tool-pwa .calc-intro h1,
  body.is-tool-pwa .advanced-hero h1,
  body.is-tool-pwa .assessment-hero h1,
  body.is-tool-pwa .comparison-hero h1,
  body.is-tool-pwa .photo-check-hero h1,
  body.is-tool-pwa .mission-hero h1,
  body.is-tool-pwa .database-hero h1 {
    margin: 0;
    color: var(--pwa-ink);
    font-size: 24px;
    line-height: 1.18;
  }

  body.is-tool-pwa .advanced-hero h1 em,
  body.is-tool-pwa .assessment-hero h1 em,
  body.is-tool-pwa .comparison-hero h1 em,
  body.is-tool-pwa .photo-check-hero h1 em,
  body.is-tool-pwa .mission-hero h1 em,
  body.is-tool-pwa .database-hero h1 em {
    color: var(--pwa-brand);
  }

  body.is-tool-pwa .tools-hub-hero p:last-child,
  body.is-tool-pwa .calc-intro p:last-child,
  body.is-tool-pwa .advanced-hero p:last-child,
  body.is-tool-pwa .assessment-hero p:last-child,
  body.is-tool-pwa .comparison-hero p:last-child,
  body.is-tool-pwa .photo-check-hero p:last-child,
  body.is-tool-pwa .mission-hero p:last-child,
  body.is-tool-pwa .database-hero > div > p:last-child {
    display: -webkit-box;
    overflow: hidden;
    margin: 6px 0 0;
    color: var(--pwa-muted);
    font-size: 12px;
    line-height: 1.5;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  body.is-tool-pwa .tools-hub,
  body.is-tool-pwa .calc-workspace,
  body.is-tool-pwa .advanced-workspace,
  body.is-tool-pwa .assessment-workspace,
  body.is-tool-pwa .comparison-workspace,
  body.is-tool-pwa .photo-check-workspace,
  body.is-tool-pwa .mission-workspace,
  body.is-tool-pwa .database-main,
  body.is-tool-pwa .distant-workspace {
    padding-top: 12px;
    padding-bottom: 24px;
  }

  body.is-tool-pwa .calc-form,
  body.is-tool-pwa .calc-results,
  body.is-tool-pwa .advanced-controls,
  body.is-tool-pwa .advanced-summary,
  body.is-tool-pwa .assessment-form,
  body.is-tool-pwa .assessment-results,
  body.is-tool-pwa .comparison-controls,
  body.is-tool-pwa .comparison-card,
  body.is-tool-pwa .photo-check-panel,
  body.is-tool-pwa .photo-check-results,
  body.is-tool-pwa .mission-form,
  body.is-tool-pwa .mission-results,
  body.is-tool-pwa .database-toolbar,
  body.is-tool-pwa .database-card,
  body.is-tool-pwa .tool-panel {
    border-radius: 8px;
    box-shadow: none;
  }

  body.is-tool-pwa .calc-field input,
  body.is-tool-pwa .calc-field select,
  body.is-tool-pwa .advanced-field input,
  body.is-tool-pwa .advanced-field select,
  body.is-tool-pwa .assessment-field input,
  body.is-tool-pwa .assessment-field select,
  body.is-tool-pwa .comparison-field select,
  body.is-tool-pwa .mission-field input,
  body.is-tool-pwa .mission-field select,
  body.is-tool-pwa .database-toolbar input,
  body.is-tool-pwa .database-toolbar select {
    min-height: 48px;
  }

  body.is-tool-pwa button,
  body.is-tool-pwa summary,
  body.is-tool-pwa input[type="file"]::file-selector-button {
    min-height: 44px;
  }

  body.is-tool-pwa .tools-browser {
    position: sticky;
    z-index: 20;
    top: calc(var(--pwa-app-bar) + var(--pwa-safe-top));
    margin: -12px 0 6px;
    padding: 12px 0 10px;
    background: var(--pwa-canvas);
  }

  body.is-tool-pwa .tools-hub-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
    overflow: hidden;
    border: 1px solid var(--pwa-line);
    border-radius: 8px;
    background: #fff;
  }

  body.is-tool-pwa .tools-hub-card {
    min-height: 0;
    padding: 14px 16px;
    border: 0;
    border-bottom: 1px solid #e6e9ee;
    border-radius: 0;
    background: #fff;
    transform: none;
  }

  body.is-tool-pwa .tools-hub-card:last-of-type {
    border-bottom: 0;
  }

  body.is-tool-pwa .tools-hub-card span {
    font-size: 9px;
  }

  body.is-tool-pwa .tools-hub-card h2 {
    margin: 4px 0 3px;
    font-size: 16px;
    line-height: 1.3;
  }

  body.is-tool-pwa .tools-hub-card p {
    display: -webkit-box;
    overflow: hidden;
    color: #697480;
    font-size: 11px;
    line-height: 1.45;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  body.is-tool-pwa .tools-hub-card b,
  body.is-tool-pwa .tools-hub-note {
    display: none;
  }

  body.is-tool-pwa .tools-empty,
  body.is-tool-pwa .database-empty {
    min-height: 180px;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 24px;
    color: var(--pwa-muted);
    text-align: center;
  }

  body.is-tool-pwa #distant-map {
    height: min(46dvh, 430px);
    min-height: 300px;
  }

  body.is-tool-pwa .leaflet-touch .leaflet-bar a,
  body.is-tool-pwa .leaflet-control-zoom a {
    width: 44px;
    height: 44px;
    line-height: 44px;
  }

  body.is-tool-pwa .leaflet-touch .leaflet-control-layers-toggle {
    width: 44px;
    height: 44px;
  }
}

body.is-tool-pwa.is-standalone {
  min-height: var(--pwa-viewport-height, 100dvh);
  overscroll-behavior-y: contain;
}

body.is-tool-pwa.is-standalone .pwa-app-bar,
body.is-tool-pwa.is-standalone .pwa-app-tabs,
body.is-tool-pwa.is-standalone .pwa-toast {
  display: flex;
}

body.is-tool-pwa.is-standalone .pwa-app-bar {
  display: block;
}

body.is-tool-pwa.is-standalone .pwa-app-tabs {
  display: grid;
}

body.is-tool-pwa.is-standalone .tools-hub-hero,
body.is-tool-pwa.is-standalone .calc-intro,
body.is-tool-pwa.is-standalone .advanced-hero,
body.is-tool-pwa.is-standalone .assessment-hero,
body.is-tool-pwa.is-standalone .comparison-hero,
body.is-tool-pwa.is-standalone .photo-check-hero,
body.is-tool-pwa.is-standalone .mission-hero,
body.is-tool-pwa.is-standalone .database-hero,
body.is-tool-pwa.is-standalone .calc-content,
body.is-tool-pwa.is-standalone .calc-related,
body.is-tool-pwa.is-standalone .advanced-content,
body.is-tool-pwa.is-standalone .advanced-related,
body.is-tool-pwa.is-standalone .assessment-content,
body.is-tool-pwa.is-standalone .assessment-related,
body.is-tool-pwa.is-standalone .comparison-content,
body.is-tool-pwa.is-standalone .comparison-related,
body.is-tool-pwa.is-standalone .photo-check-content,
body.is-tool-pwa.is-standalone .photo-check-related,
body.is-tool-pwa.is-standalone .mission-content,
body.is-tool-pwa.is-standalone .mission-related,
body.is-tool-pwa.is-standalone .database-content,
body.is-tool-pwa.is-standalone .calc-app-cta,
body.is-tool-pwa.is-standalone > .seo-footer {
  display: none;
}

body.is-tool-pwa.is-standalone main {
  min-height: calc(var(--pwa-viewport-height, 100dvh) - var(--pwa-app-bar) - var(--pwa-safe-top) - var(--pwa-tab-bar) - var(--pwa-safe-bottom));
}

body.is-tool-pwa.is-keyboard-open {
  padding-bottom: 0;
  scroll-padding-bottom: 16px;
}

body.is-tool-pwa.is-keyboard-open .pwa-app-tabs {
  display: none;
}

@media (orientation: landscape) and (max-height: 520px) {
  :root {
    --pwa-app-bar: 48px;
    --pwa-tab-bar: 54px;
  }

  .pwa-app-tabs {
    padding-top: 3px;
  }

  .pwa-app-tabs a {
    min-height: 46px;
  }

  .pwa-app-tabs b {
    font-size: 16px;
  }

  body.is-tool-pwa .tools-hub-hero p:last-child,
  body.is-tool-pwa .calc-intro p:last-child,
  body.is-tool-pwa .advanced-hero p:last-child,
  body.is-tool-pwa .assessment-hero p:last-child,
  body.is-tool-pwa .comparison-hero p:last-child,
  body.is-tool-pwa .photo-check-hero p:last-child,
  body.is-tool-pwa .mission-hero p:last-child,
  body.is-tool-pwa .database-hero > div > p:last-child {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pwa-toast,
  .pwa-app-bar__slot,
  .pwa-app-bar__action,
  .pwa-app-tabs a,
  .pwa-sheet__button {
    scroll-behavior: auto;
    transition: none;
  }

  body.is-tool-pwa *,
  body.is-tool-pwa *::before,
  body.is-tool-pwa *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}
