:root {
  --bg-page: #0a0a0a;
  --bg-app: #000000;
  --surface: #1c1c1e;
  --surface-elevated: #2c2c2e;
  --surface-soft: #141416;
  --text: #ffffff;
  --text-muted: #8e8e93;
  --text-subtle: #636366;
  --accent: #007aff;
  --accent-soft: rgba(0, 122, 255, 0.18);
  --accent-glow: rgba(0, 122, 255, 0.45);
  --success: #30d158;
  --warning: #ff9f0a;
  --border: rgba(255, 255, 255, 0.08);
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  --radius-xl: 20px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --font-sans: "Pretendard", "Apple SD Gothic Neo", "SF Pro Display", system-ui, sans-serif;
  --icon-sm: 15px;
  --icon-md: 18px;
  --icon-lg: 19px;
  --touch: 36px;
  /* iPhone 17 / 17 Pro — 402 × 874 pt @3x (1206 × 2622 px) */
  --app-width: 402px;
  --app-height: 874px;
  --device-radius: 55px;
  --device-bezel: 3px;
  --status-h: 56px;
  --header-h: 44px;
  --nav-h: 74px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html {
  /* iOS 기본 본문 크기(17pt)에 맞춘 웹 시뮬레이션 */
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg-page);
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px 32px;
}

.app-shell {
  width: var(--app-width);
  max-width: 100%;
  height: var(--app-height);
  max-height: var(--app-height);
  aspect-ratio: 402 / 874;
  background: var(--bg-app);
  border-radius: var(--device-radius);
  box-shadow: var(--shadow), 0 0 0 var(--device-bezel) rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  isolation: isolate;
}

/* iPhone 17 — Dynamic Island + status row */
.app-status {
  flex-shrink: 0;
  position: relative;
  min-height: 56px;
  height: 56px;
  padding: 0;
  color: var(--text);
  overflow: hidden;
}

.app-status__island {
  display: none;
}

.app-status__top-image {
  position: absolute;
  top: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: min(92%, 370px);
  height: auto;
  object-fit: contain;
  object-position: center top;
  z-index: 3;
  pointer-events: none;
}

.app-header {
  flex-shrink: 0;
  min-height: var(--header-h);
  padding: 4px 12px 8px;
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-app);
  z-index: 5;
}

.app-shell--tab-root .app-header {
  display: none;
}

.app-header__back {
  width: var(--touch);
  height: var(--touch);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text);
}

.app-header__back:active {
  background: var(--surface);
}

.app-header__back--hidden {
  visibility: hidden;
  pointer-events: none;
  width: 0;
  padding: 0;
  overflow: hidden;
}

.app-header__title {
  flex: 1;
  min-width: 0;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.app-header__trailing {
  display: flex;
  align-items: center;
  gap: 6px;
}

.app-header__action.is-hidden {
  display: none;
}

.app-main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 28px);
}

.app-main::-webkit-scrollbar {
  display: none;
}

.screen {
  padding: 0 20px 20px;
  min-height: 100%;
  animation: fadeIn 0.22s ease;
}

.screen--sub {
  padding-top: 16px;
  padding-bottom: 28px;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.app-nav {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: calc(20px + var(--safe-bottom));
  height: var(--nav-h);
  background: #000000;
  border: 1px solid var(--border);
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 6px 8px;
  z-index: 10;
}

.app-nav__btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 5px 2px;
  border-radius: 18px;
  color: var(--text-muted);
  font-size: 0.62rem;
  font-weight: 600;
  min-height: 54px;
}

.app-nav__pill {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  transition: background-color 0.18s ease, color 0.18s ease;
}

.app-nav__btn svg {
  width: var(--icon-md);
  height: var(--icon-md);
}

.app-nav__btn--active {
  color: var(--accent);
}

.app-nav__btn--active .app-nav__pill {
  background: #ffffff;
  color: #000000;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.app-nav__btn--active .app-nav__pill svg {
  stroke: #000000;
}

.app-nav__label {
  line-height: 1.15;
}

.app-home-indicator {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(7px + var(--safe-bottom));
  width: 134px;
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.42);
  z-index: 9;
  pointer-events: none;
}

/* iPhone 17 뷰포트(402pt) 이하: 기기 프레임 없이 풀스크린 */
@media (max-width: 402px) {
  .app-status {
    height: 56px;
    min-height: 56px;
  }

  .app-status__top-image {
    width: min(92%, 370px);
  }

  body {
    padding: 0;
  }

  .app-shell {
    border-radius: 0;
    box-shadow: none;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    max-width: none;
    width: 100%;
    aspect-ratio: auto;
  }

  .app-nav {
    left: 12px;
    right: 12px;
    bottom: calc(16px + var(--safe-bottom));
  }

  .app-home-indicator {
    bottom: calc(6px + var(--safe-bottom));
  }
}

/* 데스크톱: iPhone 17 단말기 프레임 */
@media (min-width: 403px) {
  body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(ellipse at 50% 0%, rgba(0, 122, 255, 0.06), transparent 55%);
  }
}
