:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #121417;
  --muted: #6b7280;
  --line: #e6e8ec;
  --chip: #eff1f4;
  --bolt: #ffd400;
  --bolt-ink: #121417;
  --ink: #121417;
  --ink-fg: #ffd400;
  --ink-sub: rgba(255, 255, 255, .72);
  --link: #2563eb;
  --danger: #e5484d;
  --ok: #16a34a;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 16px rgba(16, 24, 40, .05);
  --radius: 18px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1013;
    --surface: #171a1f;
    --text: #f1f3f5;
    --muted: #9aa1ab;
    --line: #262a31;
    --chip: #22262d;
    --ink: #23272e;
    --ink-sub: var(--muted);
    --link: #7aa7ff;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, system-ui, 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

/* ---------- 상단바 ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px max(16px, calc((100% - 608px) / 2));
  padding-top: max(12px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
  text-decoration: none;
}

.brand img { width: 26px; height: 26px; }

body[data-view="home"] .brand { visibility: hidden; }

#nav { display: flex; gap: 6px; }

.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.nav-btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }

.badge {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

main {
  flex: 1;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 8px 16px 48px;
}

/* ---------- 첫 화면 ---------- */

.home {
  min-height: calc(100dvh - 130px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 44px;
  padding-bottom: 32px;
}

.hero { text-align: center; }

.logo {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  margin: 0 auto 18px;
  border-radius: 24px;
  background: var(--bolt);
  box-shadow: 0 12px 32px rgba(255, 212, 0, .35);
  animation: pyoing .9s cubic-bezier(.28, 1.6, .5, 1) both;
  cursor: pointer;
}

.logo.again { animation: none; }

/* 퓨잉~ 하고 튀어오르는 로고 */
@keyframes pyoing {
  0% { transform: translateY(40px) scale(.6, 1.3); opacity: 0; }
  35% { transform: translateY(-18px) scale(1.12, .9); opacity: 1; }
  55% { transform: translateY(0) scale(.94, 1.06); }
  75% { transform: translateY(-5px) scale(1.02, .98); }
  100% { transform: none; }
}

.logo img { width: 44px; height: 44px; }

.hero h1 {
  margin: 0;
  font-size: clamp(44px, 12vw, 60px);
  font-weight: 900;
  letter-spacing: -0.05em;
  line-height: 1.05;
}

.tagline { margin: 12px 0 0; font-size: 18px; font-weight: 600; color: var(--muted); }

.choices { display: grid; gap: 14px; }

@media (min-width: 560px) {
  .choices { grid-template-columns: 1fr 1fr; }
}

.choice {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 8px;
  min-height: 176px;
  padding: 26px;
  border-radius: 28px;
  text-decoration: none;
  transition: transform .12s ease, box-shadow .12s ease;
}

.choice strong { font-size: 44px; font-weight: 900; letter-spacing: -0.05em; line-height: 1; }
.choice span { font-size: 15px; font-weight: 600; }
.choice::after { content: '→'; position: absolute; top: 22px; right: 26px; font-size: 28px; font-weight: 700; }
.choice:active { transform: scale(.98); }

.choice.give { background: var(--ink); color: var(--ink-fg); }
.choice.give span { color: var(--ink-sub); }
.choice.take { background: var(--bolt); color: var(--bolt-ink); }
.choice.take span { opacity: .72; }

@media (hover: hover) {
  .choice:hover { transform: translateY(-3px); box-shadow: 0 14px 30px rgba(0, 0, 0, .12); }
}

/* ---------- 공통 페이지 ---------- */

.page h1 { margin: 8px 0 4px; font-size: 30px; font-weight: 800; letter-spacing: -0.04em; }
.sub { margin: 0; color: var(--muted); }

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 12px;
  margin-bottom: 16px;
}

.live { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; color: var(--muted); }

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  animation: pulse 1.6s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(22, 163, 74, .5); }
  70%, 100% { box-shadow: 0 0 0 8px rgba(22, 163, 74, 0); }
}

.empty {
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 48px 20px;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  text-align: center;
}

.empty p { margin: 0; }

/* ---------- 버튼 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 20px;
  border: 0;
  border-radius: 14px;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: transform .1s, opacity .1s;
}

.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--ink); color: var(--ink-fg); }
.btn.take { background: var(--bolt); color: var(--bolt-ink); }
.btn.ghost { background: var(--chip); color: var(--text); }
.btn.sm { padding: 10px 18px; border-radius: 12px; font-size: 15px; }
.btn.lg { padding: 18px 20px; font-size: 18px; border-radius: 16px; }
.btn.block { width: 100%; }

.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--link);
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* ---------- 일받기 목록 ---------- */

.jobs { display: grid; gap: 12px; margin-bottom: 16px; }

.job {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.job.fresh { animation: drop .45s ease, glow 2.6s ease; }

@keyframes drop { from { opacity: 0; transform: translateY(-12px); } }
@keyframes glow {
  0%, 45% { border-color: var(--bolt); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bolt) 50%, transparent); }
}

.job-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.job h3 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.35; }
.job-top time { flex: none; padding-top: 3px; font-size: 13px; color: var(--muted); }

.job-desc {
  display: -webkit-box;
  margin: 8px 0 0;
  overflow: hidden;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  font-size: 15px;
  color: color-mix(in srgb, var(--text) 82%, transparent);
  white-space: pre-line;
  cursor: pointer;
}

.job-desc.open { display: block; }

.job-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }

.chip {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--chip);
  font-size: 13px;
  font-weight: 600;
}

.chip.pay { background: color-mix(in srgb, var(--bolt) 32%, transparent); }
.chip.via-chat { color: var(--link); }
.chip.via-call { color: var(--muted); }

.job-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 14px;
  color: var(--muted);
}

.tag { font-size: 13px; font-weight: 700; color: var(--muted); }

/* ---------- 폼 ---------- */

.form { display: grid; gap: 18px; margin-top: 20px; }
.field { display: grid; gap: 8px; }
.label { display: flex; align-items: baseline; gap: 6px; font-size: 15px; font-weight: 700; }
.label em { font-size: 12px; font-style: normal; font-weight: 600; color: var(--muted); }
.label em.req { color: var(--danger); }

.two { display: grid; gap: 18px; }

@media (min-width: 440px) {
  .two { grid-template-columns: 1fr 1fr; gap: 12px; }
}

input,
textarea {
  width: 100%;
  padding: 14px 16px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  outline: none;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  transition: border-color .12s;
}

input:focus,
textarea:focus { border-color: var(--text); }
input::placeholder,
textarea::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
textarea { min-height: 110px; resize: vertical; }

.note {
  margin: 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--chip);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.note.ok { color: var(--text); }
.contact-slot { display: grid; gap: 10px; }

.form-error { margin: 0; color: var(--danger); font-size: 14px; font-weight: 600; }
.form-error:empty { display: none; }

/* ---------- 모달 ---------- */

.modal-back {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: end center;
  padding: 16px;
  background: rgba(10, 12, 16, .5);
  animation: fade .15s;
}

@media (min-width: 560px) {
  .modal-back { place-items: center; }
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 420px;
  padding: 30px 22px max(22px, env(safe-area-inset-bottom));
  border-radius: 24px;
  background: var(--surface);
  animation: up .2s ease;
}

.modal-x {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--muted);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

@keyframes fade { from { opacity: 0; } }
@keyframes up { from { opacity: 0; transform: translateY(20px); } }

.auth { display: grid; gap: 12px; }
.auth h2 { margin: 0; font-size: 23px; font-weight: 800; letter-spacing: -0.03em; }
.auth .sub { margin: -4px 0 6px; font-size: 15px; }
.auth .link { justify-self: center; margin-top: 4px; font-size: 14px; }

.contact { display: grid; gap: 10px; text-align: center; }
.contact h2 { margin: 0; font-size: 19px; font-weight: 700; }
.contact .sub { font-size: 14px; }
.phone { margin: 4px 0 8px; color: var(--text); font-size: 32px; font-weight: 800; letter-spacing: .01em; text-decoration: none; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.contact .link { justify-self: center; margin-top: 4px; font-size: 14px; }

/* ---------- 채팅 목록 ---------- */

.chats { display: grid; gap: 8px; margin-top: 16px; }

.chat-row {
  display: grid;
  gap: 2px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  color: inherit;
  text-decoration: none;
}

.chat-row .r1 { display: flex; align-items: baseline; gap: 8px; }
.chat-row .r1 strong { font-size: 16px; }
.chat-row .role { font-size: 12px; font-weight: 600; color: var(--muted); }
.chat-row .r1 time { margin-left: auto; font-size: 12px; color: var(--muted); }
.chat-row .r2 { overflow: hidden; font-size: 13px; color: var(--muted); white-space: nowrap; text-overflow: ellipsis; }
.chat-row .r3 { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.chat-row .last { flex: 1; overflow: hidden; font-size: 15px; white-space: nowrap; text-overflow: ellipsis; }
.chat-row.has-unread .last { font-weight: 700; }

/* ---------- 채팅방 ---------- */

body[data-view="chat"] { height: 100dvh; overflow: hidden; }
body[data-view="chat"] main { display: flex; flex-direction: column; min-height: 0; padding-bottom: 0; }

.chat { display: flex; flex: 1; flex-direction: column; min-height: 0; }

.chat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0 12px;
  border-bottom: 1px solid var(--line);
}

.chat-head .t { font-size: 17px; font-weight: 800; }
.chat-head .s { font-size: 13px; color: var(--muted); }

.back {
  display: grid;
  place-items: center;
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--chip);
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  text-decoration: none;
}

.msgs {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  padding: 16px 2px;
  overflow-y: auto;
}

.msg { display: flex; align-items: flex-end; gap: 6px; max-width: 82%; }
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }

.bubble {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  font-size: 15px;
  white-space: pre-wrap;
}

.msg.mine .bubble { border-color: transparent; border-bottom-right-radius: 6px; background: var(--bolt); color: var(--bolt-ink); }
.msg.theirs .bubble { border-bottom-left-radius: 6px; }
.msg time { flex: none; font-size: 11px; color: var(--muted); }

.chat-hint { margin: auto 0; color: var(--muted); font-size: 14px; text-align: center; }

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 0 max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}

.composer textarea { min-height: 0; max-height: 120px; padding: 12px 14px; resize: none; }
.composer .btn { flex: none; height: 50px; }

/* ---------- 토스트 ---------- */

#toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  z-index: 60;
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  overflow: hidden;
  border-radius: 14px;
  background: var(--text);
  color: var(--bg);
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 20px);
  transition: opacity .2s, transform .2s;
}

#toast.show { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }
#toast.clickable { cursor: pointer; }
body[data-view="chat"] #toast { bottom: 96px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- 쿠키·캐시 동의 ---------- */

.consent {
  position: fixed;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 40;
  width: min(608px, calc(100% - 32px));
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .14);
  transform: translateX(-50%);
  animation: up .25s ease;
}

.consent p { margin: 0; font-size: 14px; line-height: 1.6; }
.consent-actions { display: flex; align-items: center; justify-content: flex-end; gap: 14px; margin-top: 10px; }
.details { margin: 10px 0 0; padding-left: 18px; color: var(--muted); font-size: 13px; line-height: 1.7; }
body[data-view="chat"] .consent { bottom: 96px; }

.check-wrap { display: grid; gap: 6px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 0; accent-color: var(--text); }
.check-wrap .link.small, .link.small { justify-self: start; font-size: 13px; }

/* ---------- 위치 동의 · 내 정보 ---------- */

.consent-modal { display: grid; gap: 10px; }
.consent-modal h2 { margin: 0; font-size: 21px; font-weight: 800; letter-spacing: -0.03em; }
.consent-modal .sub { margin: -4px 0 0; }
.consent-modal .link.small { justify-self: center; margin-top: 2px; }

.terms {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
  margin: 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--chip);
  font-size: 13px;
  line-height: 1.5;
}

.terms dt { font-weight: 700; white-space: nowrap; }
.terms dd { margin: 0; color: var(--muted); }

.settings .set {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.settings .set h2 { margin: 0; font-size: 17px; font-weight: 800; }
.set-body { display: grid; gap: 10px; }
.set-value { margin: 0; font-size: 16px; font-weight: 600; }
.set-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.fine { margin: 0; color: var(--muted); font-size: 12px; }
.set-links { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 20px; }
.policy { margin: 0; padding-left: 18px; color: var(--muted); font-size: 14px; line-height: 1.7; }
.settings > .btn { margin-top: 20px; }

.guide h2 { margin: 0 0 12px; font-size: 21px; font-weight: 800; }
.guide ol { margin: 0 0 12px; padding-left: 20px; line-height: 1.9; }

/* ---------- 일받기: 내 주변 ---------- */

.controls { display: grid; gap: 10px; margin-bottom: 14px; }
.controls:empty { display: none; }

.seg { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; border-radius: 14px; background: var(--chip); }

.seg-btn {
  padding: 10px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.seg-btn.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }

.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }

.chip-btn {
  padding: 6px 12px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.chip-btn.on { border-color: var(--text); background: var(--text); color: var(--bg); }
.chips .base { margin-left: auto; color: var(--muted); font-size: 12px; text-decoration: none; }

.loc-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--bolt) 22%, var(--surface));
  font-size: 14px;
  font-weight: 600;
}

.loc-cta .btn { flex: none; }

/* 일주기: 일하는 곳 */
.spot-on {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  font-size: 15px;
}

.spot-place { flex: 1; font-weight: 700; }
.spot-place em { color: var(--muted); font-style: normal; font-weight: 500; }
.hint { margin: 0; color: var(--muted); font-size: 13px; }

/* ---------- 채팅: 사진 · 알림 ---------- */

.icon-btn {
  display: grid;
  place-items: center;
  flex: none;
  width: 50px;
  height: 50px;
  border: 0;
  border-radius: 14px;
  background: var(--chip);
  color: var(--text);
  cursor: pointer;
}

.icon-btn svg { width: 24px; height: 24px; }

.bubble.photo { padding: 3px; overflow: hidden; line-height: 0; }

.bubble.photo img {
  display: block;
  min-width: 80px;
  min-height: 80px;
  max-width: min(260px, 62vw);
  max-height: 320px;
  border-radius: 15px;
  background: var(--chip);
  object-fit: cover;
  cursor: zoom-in;
}

.msg.pending { opacity: .55; }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, .92);
  cursor: zoom-out;
  animation: fade .15s;
}

.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }

.push-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--bolt) 22%, var(--surface));
  font-size: 14px;
  font-weight: 600;
}

.push-bar > span { flex: 1; }
.push-bar .btn { flex: none; }

.bar-x {
  flex: none;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
