* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Safe-area variables — fall back to 0 when not supported. */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  /* Mobile address-bar safe viewport height. dvh on supporting browsers,
     fallback to vh otherwise. */
  --app-height: 100dvh;
}

@supports not (height: 100dvh) {
  :root { --app-height: 100vh; }
}

html, body {
  width: 100%;
  height: var(--app-height);
  overflow: hidden;
  overscroll-behavior: none;
  overscroll-behavior-y: contain;
  font-family: sans-serif;
  /* Native-like: prevent text selection, pull-to-refresh, tap highlight */
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  /* Crisp text rendering */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Block iOS double-tap-to-zoom. */
  -ms-touch-action: manipulation;
}

body {
  display: flex;
  flex-direction: column;
  /* Honor notches / home-bar / pill so chrome doesn't get cut off when
     the page is launched as an installed PWA. The actual pixel offset
     lives on commander-app via these vars too — see component CSS. */
  padding-top: var(--safe-top);
  padding-right: var(--safe-right);
  padding-bottom: var(--safe-bottom);
  padding-left: var(--safe-left);
  background: #1a3a2a;  /* matches manifest background_color → no flash on PWA launch */
}

/* When running as an installed PWA, hide any "open in browser" affordance the
   app might surface, and disable selection more aggressively. */
:root[data-standalone="true"] body {
  /* prevent rubber-banding completely on iOS standalone */
  position: fixed;
  inset: 0;
}

/* Allow text selection in inputs and textareas */
input, textarea, [contenteditable] {
  user-select: text;
  -webkit-user-select: text;
}

/* Native-like: tactile button press */
button:active {
  transform: scale(0.97);
}

/* Momentum scrolling for scrollable containers */
[data-scroll] {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Respect system motion preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (prefers-color-scheme: dark) {
  body {
    background-color: #1a1a1a;
    color: #f0f0f0;
  }
}
