html,
body {
  max-width: 100%;
  overflow-x: hidden;
  background: var(--bg);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", system-ui, sans-serif !important;
}

img,
svg,
canvas,
video {
  max-width: 100%;
}

.mobile-app-shell { min-height: 100dvh; }
.mobile-app-shell :focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, white); outline-offset: 2px; }
.mobile-app-shell form[aria-busy="true"] button[type="submit"] { pointer-events: none; opacity: 0.72; }
.app-bottom-nav { display: none; }
.profile-menu { position: relative; }
.profile-menu > summary { display: grid; width: 44px; height: 44px; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: var(--panel); color: var(--text); cursor: pointer; list-style: none; box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05); }
.profile-menu > summary::-webkit-details-marker { display: none; }
.profile-menu > summary svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.profile-menu-panel { position: absolute; z-index: 2200; top: calc(100% + 8px); right: 0; display: grid; width: min(290px, calc(100vw - 24px)); gap: 5px; padding: 8px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255, 255, 255, 0.96); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.16); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); }
.profile-menu-panel a,
.profile-menu-panel button { display: flex; width: 100%; min-height: 44px; align-items: center; justify-content: flex-start; border: 0; border-radius: 12px; padding: 10px 12px; background: transparent; color: var(--text); text-decoration: none; font: inherit; font-weight: 650; cursor: pointer; }
.profile-menu-panel a:hover,
.profile-menu-panel button:hover { background: var(--panel-2); }
.profile-menu-panel .menu-danger { color: var(--err); }
body.mobile-app-shell > main { border-radius: var(--radius-lg) !important; border-color: var(--line) !important; box-shadow: var(--shadow); }

@media (max-width: 767px) {
  html { overscroll-behavior-y: none; scroll-padding-bottom: 88px; -webkit-text-size-adjust: 100%; }
  body.mobile-app-shell { min-height: 100dvh; padding-bottom: calc(82px + env(safe-area-inset-bottom)); }
  body.mobile-app-shell .wrap { width: 100%; max-width: 100%; padding-top: max(12px, env(safe-area-inset-top)); overflow: clip; }
  body.mobile-app-shell > main { width: calc(100% - 24px) !important; margin: 12px auto !important; padding: 20px !important; border-radius: 22px !important; box-shadow: none; }
  body.mobile-app-shell h1 { text-wrap: balance; letter-spacing: -0.035em; }
  body.mobile-app-shell section { max-width: 100%; overflow-x: visible !important; border-radius: var(--radius); }
  body.mobile-app-shell table { display: block; width: 100%; min-width: 0 !important; border-collapse: separate; }
  body.mobile-app-shell table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  body.mobile-app-shell table tbody { display: grid; width: 100%; gap: 10px; }
  body.mobile-app-shell table tr { display: block; width: 100%; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); }
  body.mobile-app-shell table td { display: grid; grid-template-columns: minmax(88px, 0.75fr) minmax(0, 1.25fr); gap: 10px; width: 100%; padding: 10px 12px; border: 0; border-top: 1px solid var(--line, #d4d4cf); overflow-wrap: anywhere; }
  body.mobile-app-shell table td:first-child { border-top: 0; }
  body.mobile-app-shell table td::before { content: attr(data-label); color: var(--muted, #666660); font-size: 10px; font-weight: 800; letter-spacing: 0.055em; line-height: 1.4; text-transform: uppercase; }
  body.mobile-app-shell table td[colspan] { display: block; }
  body.mobile-app-shell table td[colspan]::before { display: none; }
  body.mobile-app-shell .chart-wrap { overflow-x: hidden !important; }
  body.mobile-app-shell .lap-chart { min-width: 0 !important; }
  body.mobile-app-shell pre { max-width: 100%; white-space: pre-wrap; overflow-wrap: anywhere; }
  body.mobile-app-shell input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
  body.mobile-app-shell select,
  body.mobile-app-shell textarea { max-width: 100%; min-height: 46px; font-size: 16px; }
  body.mobile-app-shell input[type="checkbox"],
  body.mobile-app-shell input[type="radio"] { width: 17px; height: 17px; min-height: 0; flex: 0 0 auto; }
  body.mobile-app-shell button,
  body.mobile-app-shell a { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
  body.mobile-app-shell button,
  body.mobile-app-shell .button-link,
  body.mobile-app-shell .action-link { min-height: 44px; border-radius: 12px; }
  body.mobile-app-shell button:active,
  body.mobile-app-shell .button-link:active,
  body.mobile-app-shell .action-link:active { transform: scale(0.985); }
  .app-bottom-nav { position: fixed; z-index: 2000; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); min-height: calc(64px + env(safe-area-inset-bottom)); padding: 5px 8px env(safe-area-inset-bottom); border-top: 1px solid var(--line); background: rgba(250, 250, 252, 0.92); box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.055); -webkit-backdrop-filter: blur(22px) saturate(180%); backdrop-filter: blur(22px) saturate(180%); }
  .app-bottom-nav a { display: grid; place-items: center; align-content: center; gap: 3px; min-width: 0; border-radius: 12px; color: var(--muted) !important; text-decoration: none; font-size: 10px; font-weight: 650; line-height: 1; }
  .app-bottom-nav a.active { color: var(--accent) !important; }
  .app-bottom-nav a.active::before { display: none; }
  .app-bottom-nav a:active { transform: scale(0.94); }
  .app-bottom-nav svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
  body.pwa-standalone .app-bottom-nav { bottom: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

