:root {
  --pwa-safe-top: env(safe-area-inset-top, 0px);
  --pwa-safe-bottom: env(safe-area-inset-bottom, 0px);
}

html,
body {
  max-width: 100%;
}

.pwa-tool-dock {
  display: none;
}

@media (max-width: 760px) {
  html,
  body {
    overflow-x: clip;
  }

  input,
  select,
  textarea {
    font-size: 16px !important;
  }

  button,
  a {
    touch-action: manipulation;
  }

  body.pwa-standalone {
    min-height: 100svh;
    padding-bottom: calc(82px + var(--pwa-safe-bottom));
    overscroll-behavior-y: none;
  }

  body.pwa-standalone .site-header {
    top: max(8px, var(--pwa-safe-top));
  }

  .pwa-tool-dock {
    position: fixed;
    z-index: 99990;
    right: 10px;
    bottom: max(8px, var(--pwa-safe-bottom));
    left: 10px;
    min-height: 62px;
    padding: 7px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    border: 1px solid rgba(255, 255, 255, .78);
    border-radius: 20px;
    background: rgba(247, 245, 239, .96);
    box-shadow: 0 14px 42px rgba(12, 28, 18, .22);
    backdrop-filter: blur(18px) saturate(1.2);
  }

  body.pwa-standalone .pwa-tool-dock {
    display: grid;
  }

  .pwa-tool-dock a {
    min-width: 0;
    min-height: 48px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 3px;
    border-radius: 14px;
    color: #6f746f;
    text-decoration: none;
    font: 700 10px/1.15 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  }

  .pwa-tool-dock a span {
    font-size: 18px;
    line-height: 1;
  }

  .pwa-tool-dock a.is-active {
    color: #fff;
    background: #17371f;
  }

  .pwa-tool-dock a:focus-visible {
    outline: 2px solid #9ec63b;
    outline-offset: 1px;
  }
}

@media (display-mode: standalone) and (max-width: 760px) {
  .pwa-tool-dock {
    display: grid;
  }
}
