/* --- GLOBAL RESET & NATIVE FEEL --- */
* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  background: #ffffff;
  
  /* Make it feel like an app, not a document */
  -webkit-user-select: none; /* Disable text selection */
  user-select: none;
  -webkit-touch-callout: none; /* Disable long-press context menu */
}

/* Remove the blue/grey tap highlight on mobile */
button, a, div, input, label, span {
  -webkit-tap-highlight-color: transparent;
}

/* Re-enable text selection for inputs so users can type/edit */
input, textarea {
  -webkit-user-select: text;
  user-select: text;
}

/* --- DESKTOP DEMO FRAME (The Phone Look) --- */
.page-wrap {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.device {
  position: relative;
  width: 430px;
  max-width: 95vw;
  aspect-ratio: 430/932;
  background: #fff;
  border-radius: 56px;
  box-shadow: 0 30px 80px rgba(0,0,0,.45);
  padding: 16px;
}

/* The Notch */
.device::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 14px;
  transform: translateX(-50%);
  width: 160px;
  height: 34px;
  background: #f4f4f4;
  border-radius: 20px;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.06);
  z-index: 10;
}

.screen {
  position: absolute;
  left: 16px;
  right: 16px;
  top: 56px;
  bottom: 16px;
  border-radius: 42px;
  overflow: hidden;
  background: #fff;
}

/* Floating Back Button (for desktop navigation) */
.back-btn {
  position: absolute;
  left: 22px;
  top: 20px;
  z-index: 20;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: rgba(255,255,255,.75);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(0,0,0,.06);
  cursor: pointer;
  transition: background 0.2s;
}

.back-btn:hover {
  background: rgba(255,255,255,.92);
}

.back-btn svg {
  width: 18px;
  height: 18px;
  opacity: .8;
}

/* Tablet adjustments */
@media (max-width: 520px) {
  .device { border-radius: 44px; }
  .screen { border-radius: 32px; }
}

/* iOS Safari/Chrome viewport helper */
@supports (-webkit-touch-callout: none) {
  html, body { height: -webkit-fill-available; }
}

/* --- MOBILE MODE (Real App Behavior) --- */
/* When on a real phone (max-width 480px), remove the frame */
@media (max-width: 480px) {
  html, body {
    background: #ffffff;
    width: 100%;
    max-width: 100%;
    height: 100%;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
  }

  .page-wrap {
    width: 100%;
    min-height: 100vh;
    padding: 0;
    align-items: stretch;
    justify-content: stretch;
  }

  .device {
    position: relative;
    width: 100%;
    max-width: none;
    height: 100dvh; /* Dynamic viewport height for modern browsers */
    min-height: 100dvh;
    margin: 0;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
    aspect-ratio: auto;
    background: #fff;
  }

  /* Fallback for older browsers without dvh support */
  @supports not (height: 100dvh) {
    .device { height: 100vh; min-height: 100vh; }
  }

  .device::before {
    display: none; /* Hide the notch on real phones */
  }

  .screen {
    position: relative;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
  }

  /* Hide the demo back button on mobile (use app navigation instead) */
  #st-back-btn {
    display: none;
  }

  /* Safe Area Handling (iPhone X/11/12/13/14/15/16) */
  .content, main, .page-content, .form, form {
    padding-bottom: calc(100px + env(safe-area-inset-bottom));
  }
}