@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&display=swap");

:root {
  --bg: #0d0b12;
  --bg-gradient: radial-gradient(120% 70% at 50% -8%, #221a38 0%, #0d0b12 58%);
  --surface: #17131f;
  --surface-alt: #1c1626;
  --line: #2a2338;
  --line-strong: #332a45;
  --ink: #f4f2f7;
  --sub: #a79fb8;
  --muted: #8f86a3;
  --faint: #6f6684;
  --accent: #a855f7;
  --accent-2: #7e22ce;
  --accent-tint: #d8b4fe;
  --accent-tint-2: #c084fc;
  --success-bg: #12241a;
  --success-border: #245638;
  --success-text: #86efac;
  --success-icon: #4ade80;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
}

#app {
  width: 100%;
  max-width: 440px;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg-gradient);
  position: relative;
  overflow-x: hidden;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  overflow-y: auto;
}
.screen.active { display: flex; }

button { font-family: inherit; }

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand-mark {
  width: 26px; height: 26px; border-radius: 8px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 4px 12px rgba(147,51,234,0.4);
  display: flex; align-items: center; justify-content: center;
}
.brand-name { font-size: 14px; font-weight: 800; letter-spacing: -0.01em; }

.tag {
  font-size: 11px; letter-spacing: 0.04em; color: #7a7190; font-weight: 600;
}

/* ---------- Onboarding (A) ---------- */
#screen-onboarding { padding: 56px 26px 30px; gap: 36px; }
.onboarding-top { display: flex; justify-content: space-between; align-items: center; }
.headline { font-size: 25px; font-weight: 800; line-height: 1.34; letter-spacing: -0.01em; }
.subline { font-size: 13px; color: var(--sub); margin-top: 8px; }
.feature-list { display: flex; flex-direction: column; gap: 22px; margin-top: 34px; }
.feature-row { display: flex; gap: 14px; align-items: flex-start; }
.feature-icon {
  width: 40px; height: 40px; border-radius: 11px; flex-shrink: 0;
  background: linear-gradient(160deg, #2a2040, #1c1626);
  border: 1px solid #3d2f57;
  box-shadow: 0 4px 14px rgba(0,0,0,0.3);
  display: flex; align-items: center; justify-content: center;
}
.feature-title { font-size: 14px; font-weight: 700; }
.feature-desc { font-size: 12px; color: var(--sub); line-height: 1.5; margin-top: 2px; }
.onboarding-bottom { margin-top: auto; padding-top: 20px; display: flex; flex-direction: column; gap: 20px; }

/* ---------- Buttons ---------- */
.btn-primary {
  padding: 16px; border-radius: 14px; border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 24px rgba(147,51,234,0.4);
  color: #fff; text-align: center; font-size: 16px; font-weight: 700;
}
.btn-secondary {
  padding: 14px; border-radius: 13px; cursor: pointer;
  border: 1px solid #3d2f57; background: rgba(147,51,234,0.08);
  color: var(--accent-tint); font-size: 14px; font-weight: 700; text-align: center;
}
.btn-ghost {
  padding: 12px 4px; border-radius: 13px; border: 1px solid #2a2338;
  background: rgba(255,255,255,0.03); color: #fff; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 11px;
}

/* ---------- Input form (B) ---------- */
#screen-input { padding: 64px 24px 24px; }
.form-body { display: flex; flex-direction: column; gap: 24px; flex: 1; }
.field-label { font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: 0.02em; }
.field-group { display: flex; flex-direction: column; gap: 9px; }
.segmented { display: flex; gap: 2px; padding: 4px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.segmented button {
  flex: 1; text-align: center; padding: 9px 0; border-radius: 9px; border: none;
  background: none; color: var(--muted); font-size: 13px; cursor: pointer;
}
.segmented button.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 4px 10px rgba(147,51,234,0.35); color: #fff; font-weight: 700;
}
.text-input, .input-like {
  display: flex; align-items: center; gap: 10px; padding: 14px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  font-size: 15px; color: var(--ink);
}
.text-input input {
  border: none; background: none; outline: none; color: var(--ink);
  font-size: 15px; font-family: inherit; width: 100%;
}
.text-input input::placeholder { color: var(--faint); }
.won-prefix { font-weight: 700; color: #7a7190; }
.row-2 { display: flex; gap: 12px; }
.row-2 > * { flex: 1; }
.hint { font-size: 11px; color: var(--faint); }
.invite-banner {
  font-size: 12px; color: var(--accent-tint); background: rgba(147,51,234,0.1);
  border: 1px solid #3d2f57; border-radius: 12px; padding: 10px 14px; line-height: 1.5;
}
.input-bottom { padding-top: 6px; display: flex; flex-direction: column; gap: 12px; }
.center-note { text-align: center; font-size: 11px; color: var(--faint); }
select.plain-select {
  border: none; background: none; outline: none; color: var(--ink);
  font-size: 15px; font-family: inherit; width: 100%; appearance: none;
}

/* ---------- Timer (C) ---------- */
#screen-timer { }
.timer-topbar { display: flex; justify-content: space-between; align-items: center; padding: 56px 20px 0; }
.settings-btn {
  height: 30px; padding: 0 12px; border-radius: 9px; background: rgba(255,255,255,0.04);
  border: 1px solid #2a2338; color: var(--sub); font-size: 12px; font-weight: 600;
  font-family: inherit; cursor: pointer;
}
.timer-body { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 18px 24px 0; }
.live-pill {
  display: flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px;
  background: #1e1730; border: 1px solid #3d2f57;
}
.live-dot { width: 6px; height: 6px; border-radius: 999px; background: var(--accent-tint-2); animation: pulse-dot 1.6s ease-in-out infinite; }
@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.live-label { font-size: 11px; font-weight: 700; color: var(--accent-tint); letter-spacing: 0.06em; }
.big-amount { font-size: 46px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.timer-sub { margin-top: -12px; font-size: 13px; color: var(--sub); text-align: center; }
.progress-wrap { width: 100%; display: flex; flex-direction: column; gap: 7px; margin-top: 8px; }
.progress-track { width: 100%; height: 10px; border-radius: 999px; background: #1a1522; border: 1px solid #241b33; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent-tint-2), var(--accent-2)); transition: width 0.3s ease; }
.progress-labels { display: flex; justify-content: space-between; font-size: 11px; color: var(--faint); }
.month-to-date {
  font-size: 12px; color: var(--muted); text-align: center; margin-top: 6px;
  padding: 8px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line);
}
.timer-actions { padding: 20px 24px 30px; display: flex; gap: 10px; }
.timer-actions > * { flex: 1; }

/* ---------- Overlays (Compare sheet / Share modal) ---------- */
.overlay {
  position: absolute; inset: 0; display: none; flex-direction: column; justify-content: flex-end;
  background: rgba(0,0,0,0.55); z-index: 20;
}
.overlay.active { display: flex; }
.sheet {
  background: linear-gradient(180deg, #1c1626, #17131f);
  border-radius: 22px 22px 0 0; padding: 14px 20px 28px; display: flex; flex-direction: column; gap: 16px;
  box-shadow: 0 -24px 60px rgba(0,0,0,0.5); border-top: 1px solid var(--line-strong);
}
.sheet-handle { width: 36px; height: 4px; border-radius: 999px; background: var(--line-strong); align-self: center; }
.sheet-header { display: flex; justify-content: space-between; align-items: center; }
.sheet-title { font-size: 15px; font-weight: 700; }
.close-btn { background: none; border: none; cursor: pointer; color: var(--sub); display: flex; }

/* ---------- 친구 초대 모달 (E) ---------- */
.invite-body { display: flex; flex-direction: column; gap: 18px; padding: 4px 0 6px; }
.invite-intro { font-size: 13px; color: var(--sub); line-height: 1.5; }
#invite-form { gap: 12px; }
.invite-result { display: flex; flex-direction: column; gap: 14px; }
.invite-nickname-label { font-size: 13px; color: var(--sub); }
.invite-nickname-label span { color: var(--accent-tint); font-weight: 700; }
.invite-link-box {
  padding: 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  font-size: 13px; color: var(--ink); word-break: break-all;
}
.share-actions { display: flex; gap: 10px; width: 100%; }
.share-actions > * { flex: 1; }

/* ---------- 다른 사람 염탐 (C) ---------- */
.peek-empty-cta {
  width: 100%; margin-top: 10px; display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 26px 20px; border-radius: 18px; text-align: center;
  background: linear-gradient(160deg, #251c38, #1a1626); border: 1.5px solid #3d2f57;
}
.peek-empty-icon { font-size: 30px; }
.peek-empty-title { font-size: 15px; font-weight: 700; line-height: 1.45; }
.peek-empty-cta .btn-primary { width: 100%; }

.peek-section { width: 100%; margin-top: 4px; display: flex; flex-direction: column; gap: 10px; }
.peek-header {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; font-weight: 700; color: var(--muted);
}
.peek-add-btn {
  border: 1px solid #3d2f57; background: rgba(147,51,234,0.1); color: var(--accent-tint);
  font-size: 11px; font-weight: 700; padding: 5px 10px; border-radius: 999px; cursor: pointer;
}
.peek-list { display: flex; flex-direction: column; gap: 8px; }
.peek-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line);
}
.peek-row-left { display: flex; align-items: center; gap: 8px; }
.peek-name { font-size: 13px; font-weight: 600; color: var(--ink); }
.peek-amount { font-size: 14px; font-weight: 800; color: var(--accent-tint-2); font-variant-numeric: tabular-nums; }
.peek-status {
  font-size: 9px; font-weight: 800; letter-spacing: 0.04em; padding: 2px 6px; border-radius: 999px;
}
.peek-status.live { background: rgba(74,222,128,0.15); color: #4ade80; }
.peek-status.off { background: rgba(255,255,255,0.06); color: var(--faint); }
.toast {
  position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #1c1626; border: 1px solid var(--line-strong); color: var(--ink);
  padding: 10px 16px; border-radius: 999px; font-size: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  opacity: 0; pointer-events: none; transition: opacity 0.25s ease; z-index: 40; white-space: nowrap;
}
.toast.show { opacity: 1; }

/* ---------- Notifications preview (F) — dev-only reference screen ---------- */
#screen-notif-preview { background: radial-gradient(120% 60% at 50% -8%, #2c1d44 0%, #0d0b12 62%); align-items: center; }
.lock-clock { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 112px 0 30px; }
.lock-time { font-size: 58px; font-weight: 300; color: #fff; font-variant-numeric: tabular-nums; }
.lock-date { font-size: 13px; color: var(--sub); }
.notif-list { width: 100%; padding: 0 16px; display: flex; flex-direction: column; gap: 10px; }
.notif-card { background: rgba(250,249,251,0.95); border-radius: 17px; padding: 12px 14px; display: flex; gap: 10px; box-shadow: 0 10px 26px rgba(0,0,0,0.4); }
.notif-icon { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.notif-app { font-size: 11px; font-weight: 600; color: #78716c; }
.notif-time { font-size: 11px; color: #a8a29e; }
.notif-title { font-size: 13px; font-weight: 700; color: #1c1917; }
.notif-body { font-size: 12px; color: #57534e; }

@media (min-width: 460px) {
  #app { margin: 24px 0; min-height: calc(100vh - 48px); min-height: calc(100dvh - 48px); border-radius: 28px; overflow: hidden; box-shadow: 0 30px 80px rgba(0,0,0,0.6); }
  body { align-items: flex-start; }
}
