.app-bg {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 15% 25%, rgba(45, 108, 223, 0.25) 0%, transparent 45%),
    radial-gradient(circle at 85% 75%, rgba(245, 181, 68, 0.12) 0%, transparent 45%),
    linear-gradient(135deg, #0E2C6B 0%, #1A4A9E 100%);
  z-index: -1;
}

.app-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 24px 24px;
  pointer-events: none;
}

.page-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  padding: 18px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: white;
  gap: 16px;
}

.page-header-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.page-header-brand .lfm-mark-img {
  height: 38px;
  width: auto;
  padding: 6px 10px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}

.page-header-title {
  font-size: 13px;
  opacity: 0.85;
  letter-spacing: 0.02em;
}

.page-header-title strong {
  display: block;
  font-size: 15px;
  font-weight: 600;
  opacity: 1;
  letter-spacing: -0.01em;
}

.page-header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.page-header-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: 999px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.18);
  color: white;
  font-size: 12px;
  font-weight: 500;
  backdrop-filter: blur(8px);
  transition: background var(--dur-fast) var(--ease-out);
}

.page-header-btn:hover {
  background: rgba(255,255,255,0.2);
}

.page-stage {
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* === iPhone 15 Pro Frame === */
.iphone-frame {
  position: relative;
  width: 430px;
  height: 880px;
  border-radius: 55px;
  background: linear-gradient(145deg, #2a2a2c 0%, #1a1a1c 30%, #1a1a1c 70%, #2a2a2c 100%);
  padding: 14px;
  box-shadow:
    0 30px 60px -20px rgba(0,0,0,0.5),
    0 18px 36px -18px rgba(0,0,0,0.3),
    inset 0 0 0 2px rgba(255,255,255,0.05);
  transition: transform var(--dur-base) var(--ease-out);
}

.iphone-frame::before {
  /* titanium edge */
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 51px;
  background: linear-gradient(145deg, #4a4a4d, #2a2a2c 40%, #2a2a2c 60%, #4a4a4d);
  z-index: 0;
}

.iphone-screen {
  position: relative;
  z-index: 1;
  width: 393px;
  height: 852px;
  border-radius: 47px;
  overflow: hidden;
  background: var(--gray-50);
  margin: 0 auto;
}

/* Physical buttons */
.iphone-frame .btn-silence {
  position: absolute;
  left: -2px;
  top: 110px;
  width: 4px;
  height: 28px;
  background: #1a1a1c;
  border-radius: 2px 0 0 2px;
}

.iphone-frame .btn-action {
  position: absolute;
  left: -3px;
  top: 155px;
  width: 4px;
  height: 32px;
  background: linear-gradient(90deg, #888, #555);
  border-radius: 2px 0 0 2px;
}

.iphone-frame .btn-vol-up {
  position: absolute;
  left: -3px;
  top: 210px;
  width: 4px;
  height: 60px;
  background: linear-gradient(90deg, #888, #555);
  border-radius: 2px 0 0 2px;
}

.iphone-frame .btn-vol-down {
  position: absolute;
  left: -3px;
  top: 285px;
  width: 4px;
  height: 60px;
  background: linear-gradient(90deg, #888, #555);
  border-radius: 2px 0 0 2px;
}

.iphone-frame .btn-side {
  position: absolute;
  right: -3px;
  top: 200px;
  width: 4px;
  height: 100px;
  background: linear-gradient(270deg, #888, #555);
  border-radius: 0 2px 2px 0;
}

/* Persistent global status bar — wraps around the Dynamic Island */
.global-status-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50px;
  padding: 16px 30px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 95;
  pointer-events: none;
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-950);
  transition: color var(--dur-base) var(--ease-out);
}

.global-status-bar .time {
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.global-status-bar .indicators {
  display: flex;
  align-items: center;
  gap: 6px;
}

body[data-status="light"] .global-status-bar { color: white; }

/* Persistent notification bell */
.global-notif {
  position: absolute;
  top: 56px;
  right: 16px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--lfm-blue-800);
  z-index: 96;
  box-shadow: 0 2px 8px rgba(8, 29, 82, 0.08);
  transition: transform var(--dur-fast) var(--ease-out), background var(--dur-fast);
}

.global-notif:hover {
  background: white;
  transform: scale(1.05);
}

.global-notif:active {
  transform: scale(0.95);
}

.global-notif .badge-count {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  background: var(--error);
  color: white;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid white;
  animation: pulse-badge 2s ease-in-out infinite;
}

.global-notif .badge-count[hidden] {
  display: none;
}

/* Hide the global bell on screens that manage their own chrome or have a right-side
   header action (which would visually collide with the bell) */
.iphone-screen:has(.screen > .splash) .global-notif,
.iphone-screen:has(.screen > .auth) .global-notif,
.iphone-screen:has(.screen .profile-head) .global-notif,
.iphone-screen:has(.screen > .chat-page) .global-notif,
.iphone-screen:has(.screen > .webview-page) .global-notif,
.iphone-screen:has(.screen .app-header-action) .global-notif {
  display: none;
}

/* Dynamic Island */
.dynamic-island {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: 120px;
  height: 35px;
  background: #000;
  border-radius: 18px;
  z-index: 100;
  pointer-events: none;
}

/* Home indicator */
.home-indicator {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 135px;
  height: 5px;
  background: rgba(0,0,0,0.4);
  border-radius: 3px;
  z-index: 100;
  pointer-events: none;
}

.iphone-screen.dark-content .home-indicator,
body[data-status="light"] .home-indicator {
  background: rgba(255,255,255,0.5);
}

/* Status bar */
.status-bar {
  position: relative;
  height: 50px;
  padding: 16px 32px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 16px;
  font-weight: 600;
  color: var(--status-bar-color);
  z-index: 10;
  pointer-events: none;
}

.status-bar .time {
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  padding-left: 4px;
}

.status-bar .indicators {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-right: 8px;
}

.status-bar .indicators svg {
  display: block;
}

.status-bar.light {
  --status-bar-color: white;
}

/* Screen content area — directly scrollable */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  background: var(--gray-50);
  padding-top: 50px;
}

.screen.has-tabbar {
  padding-bottom: 84px;
}

/* Some flows manage their own header (auth, webview, splash) and need no top padding */
.screen.no-top,
.screen:has(> .webview-page),
.screen:has(> .splash),
.screen:has(> .auth),
.screen:has(> .chat-page),
.screen:has(> .sim-step-page) {
  padding-top: 0;
}

/* Chat page must fill the visible screen height even though .screen scrolls */
.screen:has(> .chat-page) {
  overflow: hidden;
}
.screen > .chat-page {
  height: 100%;
}

.screen-body {
  /* legacy hook — content is now scrollable on .screen itself */
}

.screen.dark {
  background: var(--lfm-blue-900);
  color: white;
}

/* Demo panel */
.demo-panel {
  position: fixed;
  right: 24px;
  top: 50%;
  transform: translateY(-50%);
  width: 280px;
  background: rgba(255,255,255,0.97);
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  backdrop-filter: blur(16px);
  z-index: 200;
  font-size: 13px;
  max-height: 80vh;
  overflow-y: auto;
}

.demo-panel h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray-500);
  margin-bottom: 12px;
  font-weight: 600;
}

.demo-panel section {
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--gray-100);
}

.demo-panel section:last-child {
  border-bottom: none;
}

.demo-panel .demo-btn {
  display: block;
  width: 100%;
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--lfm-blue-50);
  color: var(--lfm-blue-800);
  font-size: 12.5px;
  font-weight: 500;
  margin-bottom: 6px;
  text-align: left;
  transition: background var(--dur-fast) var(--ease-out);
}

.demo-panel .demo-btn:hover {
  background: var(--lfm-blue-200);
}

.demo-panel .demo-btn.danger {
  background: #fee;
  color: var(--error);
}

.demo-panel .demo-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 13px;
}

.demo-panel .demo-toggle input {
  appearance: none;
  width: 36px;
  height: 22px;
  background: var(--gray-300);
  border-radius: 999px;
  position: relative;
  transition: background var(--dur-fast);
  cursor: pointer;
}

.demo-panel .demo-toggle input::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  transition: transform var(--dur-fast);
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.demo-panel .demo-toggle input:checked {
  background: var(--lfm-blue-700);
}

.demo-panel .demo-toggle input:checked::after {
  transform: translateX(14px);
}

.demo-panel .legend {
  font-size: 11px;
  color: var(--gray-500);
  font-style: italic;
  text-align: center;
  margin-top: 8px;
}

.demo-toggle-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: white;
  color: var(--lfm-blue-800);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 201;
}

/* Responsive */
@media (max-width: 1100px) {
  .demo-panel {
    display: none;
  }
  .demo-toggle-btn {
    display: flex;
  }
  .demo-panel.open {
    display: block;
    right: 12px;
    top: auto;
    bottom: 100px;
    transform: none;
  }
}

@media (max-height: 920px) {
  .iphone-frame { transform: scale(0.92); }
}
@media (max-height: 860px) {
  .iphone-frame { transform: scale(0.85); }
}
@media (max-height: 780px) {
  .iphone-frame { transform: scale(0.78); }
}
@media (max-height: 700px) {
  .iphone-frame { transform: scale(0.70); }
}
@media (max-height: 640px) {
  .iphone-frame { transform: scale(0.62); }
}
@media (max-height: 580px) {
  .iphone-frame { transform: scale(0.55); }
}

@media (max-width: 768px) {
  .page-header {
    display: none;
  }
  .iphone-frame {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    padding: 0;
    transform: none !important;
    box-shadow: none;
  }
  .iphone-frame::before {
    display: none;
  }
  .iphone-screen {
    width: 100%;
    height: 100%;
    border-radius: 0;
  }
  .dynamic-island, .home-indicator,
  .btn-silence, .btn-action, .btn-vol-up, .btn-vol-down, .btn-side {
    display: none;
  }
}
