:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --ink: #1a1d21;
  --muted: #6b7280;
  --line: #e5e8eb;
  --mint: #D6F5EC;
  --accent: #0FB88A;
  --accent-ink: #067A56;
  --danger: #fa5252;
  --shadow: 0 2px 12px rgba(0,0,0,.06);
  --radius: 16px;
  --header-h: 56px;
  --tab-h: 64px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* hidden 속성이 .lock-screen/.ad-overlay/.modal 등 display 규칙에 덮이지 않도록 강제 */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard",
    "Malgun Gothic", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

/* ---------- 헤더 ---------- */
.app-header {
  position: sticky; top: 0; z-index: 20;
  height: var(--header-h);
  padding: 0 16px; padding-top: env(safe-area-inset-top);
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; font-size: 18px; letter-spacing: -.02em; display: flex; align-items: center; gap: 7px; }
.brand-mark { width: 24px; height: 24px; color: var(--accent); display: grid; place-items: center; }
.brand-mark svg { width: 24px; height: 24px; display: block; }
.brand-wm b { color: var(--accent-ink); }
.header-actions { display: flex; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  font-size: 13px; font-weight: 600; padding: 7px 12px; border-radius: 999px;
  cursor: pointer;
}
.chip-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip:active { transform: scale(.96); }

/* ---------- 본문 ---------- */
.view {
  min-height: calc(100dvh - var(--header-h) - var(--tab-h));
  padding: 16px 16px calc(24px + var(--tab-h));
  max-width: 640px; margin: 0 auto;
  animation: fade .25s ease;
}
@keyframes fade { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: none;} }

.page-title { font-size: 22px; font-weight: 800; letter-spacing: -.02em; margin: 4px 0 2px; }
.page-sub { color: var(--muted); font-size: 14px; margin: 0 0 16px; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); margin-bottom: 12px;
}
.card h3 { margin: 0 0 6px; font-size: 16px; }
.card p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.list-row { display: flex; align-items: center; gap: 12px; }
.list-row .emoji { font-size: 26px; }
.tag { display:inline-block; font-size:11px; font-weight:700; color: var(--accent-ink);
  background: #e6fcf5; padding: 3px 8px; border-radius: 999px; margin-bottom: 8px; }

/* 지도 자리 */
.map-holder {
  height: 320px; border-radius: var(--radius); border: 1px solid var(--line);
  background: repeating-linear-gradient(45deg,#eef1f3,#eef1f3 10px,#e9edf0 10px,#e9edf0 20px);
  display: flex; align-items: center; justify-content: center; text-align: center;
  color: var(--muted); font-size: 14px; margin-bottom: 12px;
}
.stock-row { display:flex; align-items:center; justify-content:space-between; }
.stock-badge { font-size:12px; font-weight:700; padding:4px 10px; border-radius:999px; }
.in { background:#e6fcf5; color: var(--accent-ink); }
.low { background:#fff4e6; color:#e8590c; }
.out { background:#fff5f5; color: var(--danger); }

/* ---------- 하단 탭 ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex; background: var(--surface); border-top: 1px solid var(--line);
}
.tab {
  flex: 1; border: 0; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 12px; font-weight: 600; color: var(--muted);
}
.tab-ico { font-size: 22px; filter: grayscale(.4); }
.tab.active { color: var(--accent-ink); }
.tab.active .tab-ico { filter: none; }

/* ---------- 광고 오버레이 ---------- */
.ad-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,.55); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.ad-card {
  width: 100%; max-width: 360px; background: #fff; border-radius: 20px; padding: 18px;
  animation: pop .2s ease;
}
@keyframes pop { from { transform: scale(.9); opacity: 0;} to { transform: none; opacity: 1;} }
.ad-label { font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: .1em; }
.ad-body { display: flex; gap: 14px; align-items: center; margin: 12px 0 16px; }
.ad-visual { font-size: 44px; }
.ad-text strong { display: block; margin-bottom: 4px; }
.ad-text p { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.45; }
.ad-close {
  width: 100%; padding: 12px; border: 0; border-radius: 12px;
  background: var(--ink); color: #fff; font-weight: 700; font-size: 15px; cursor: pointer;
}
.ad-close:disabled { background: #adb5bd; cursor: default; }

/* ---------- 모달 공통 ---------- */
.modal {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0,0,0,.5); display: flex; align-items: flex-end; justify-content: center;
}
.modal-card {
  width: 100%; max-width: 480px; background: #fff;
  border-radius: 22px 22px 0 0; padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
  position: relative; animation: sheet .25s ease;
}
@keyframes sheet { from { transform: translateY(100%);} to { transform: none;} }
.modal-x { position: absolute; top: 14px; right: 14px; border: 0; background: none; font-size: 18px; color: var(--muted); cursor: pointer; }
.modal-card h2 { margin: 0 0 4px; font-size: 20px; }
.modal-sub { margin: 0 0 18px; color: var(--muted); font-size: 14px; }

.plans { display: flex; gap: 10px; }
.plan {
  flex: 1; position: relative; text-align: left; cursor: pointer;
  border: 1.5px solid var(--line); border-radius: 14px; padding: 14px; background: #fff;
  display: flex; flex-direction: column; gap: 3px;
}
.plan-best { border-color: var(--accent); }
.plan-badge { position:absolute; top:-9px; right:12px; background: var(--accent); color:#fff;
  font-size:10px; font-weight:700; padding:3px 8px; border-radius:999px; }
.plan-name { font-weight: 700; font-size: 14px; }
.plan-price { font-size: 19px; font-weight: 800; letter-spacing: -.02em; }
.plan-note { font-size: 12px; color: var(--muted); }
.plan:active { transform: scale(.98); }
.modal-foot { margin: 16px 0 0; font-size: 12px; color: var(--muted); line-height: 1.5; }

.ios-steps { margin: 4px 0 0; padding-left: 20px; line-height: 2; font-size: 15px; }
.ios-share { display:inline-block; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + 20px); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 999px;
  font-size: 14px; font-weight: 600; z-index: 70; box-shadow: var(--shadow);
  animation: fade .2s ease;
}

/* ---------- 홈화면 실행 게이트(잠금화면) ---------- */
.lock-screen {
  position: fixed; inset: 0; z-index: 80;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  padding: 28px calc(24px + env(safe-area-inset-left)) calc(28px + env(safe-area-inset-bottom));
}
.lock-card {
  width: 100%; max-width: 360px; text-align: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 22px;
  padding: 30px 24px; box-shadow: var(--shadow); animation: pop .25s ease;
}
.lock-mark {
  display: inline-flex; width: 60px; height: 60px; margin-bottom: 16px;
  align-items: center; justify-content: center; border-radius: 18px;
  background: var(--accent); color: #fff;
}
.lock-mark svg { width: 34px; height: 34px; }
.lock-title { margin: 0 0 10px; font-size: 20px; font-weight: 800; letter-spacing: -.02em; }
.lock-sub { margin: 0 0 22px; font-size: 14px; color: var(--muted); line-height: 1.6; }
.lock-sub b { color: var(--ink); }
.lock-cta {
  width: 100%; padding: 14px; border: 0; border-radius: 14px; cursor: pointer;
  background: var(--accent); color: #fff; font-size: 16px; font-weight: 800;
  box-shadow: var(--shadow);
}
.lock-cta:active { transform: scale(.98); }
.lock-hint { margin: 14px 0 0; font-size: 12.5px; color: var(--muted); line-height: 1.55; }

@media (prefers-color-scheme: dark) {
  :root {
    --bg:#091210; --surface:#101A16; --ink:#E9F1EC; --muted:#86988F;
    --line:#1E2C26; --mint: rgba(47,214,166,.14);
    --accent:#2FD6A6; --accent-ink:#1BA883;
    --shadow: 0 2px 12px rgba(0,0,0,.45);
  }
  .chip { background:#16211C; }
  .ad-card, .modal-card { background:#101A16; }
  .tag, .in { background: rgba(47,214,166,.15); }
}
