:root {
  --bg: #FBF5EC;
  --paper: #FFFDF9;
  --kraft: #E9D6B9;
  --ink: #2E2420;
  --muted: #8C7B6E;
  --line: #EFE3D2;
  --brand: #5B3A29;
  --accent: #E8875F;
  --mint: #8FA876;
  --picked: #FFF1E6;
  --shadow: 0 6px 20px rgba(91, 58, 41, 0.08);
  --radius: 20px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
[hidden] { display: none !important; }

.app { max-width: 480px; margin: 0 auto; padding: 0 16px calc(170px + var(--safe-b)); }

/* ---------- 헤더 ---------- */
.hero {
  position: relative;
  margin: 12px -4px 18px;
  padding: 22px 20px 20px;
  border-radius: 28px;
  background:
    radial-gradient(circle at 92% 12%, rgba(232, 135, 95, .22) 0 60px, transparent 61px),
    radial-gradient(circle at 80% 95%, rgba(143, 168, 118, .25) 0 46px, transparent 47px),
    var(--kraft);
  overflow: hidden;
}
.hero::after {
  content: '☕';
  position: absolute; right: 18px; top: 46px;
  font-size: 64px; transform: rotate(12deg);
  filter: drop-shadow(0 6px 10px rgba(0,0,0,.12));
}
.hero-top { display: flex; gap: 6px; }
.badge {
  display: inline-block; padding: 5px 10px; border-radius: 999px;
  background: rgba(255,255,255,.7); font-size: 12px; font-weight: 600; color: var(--brand);
}
.badge-test { background: #2E2420; color: #FFD9A8; }
.hero h1 { margin: 14px 0 6px; font-size: 30px; line-height: 1.15; font-weight: 800; color: var(--brand); }
.hero h1 em { font-style: normal; color: var(--accent); }
.hero .logo { font-size: 26px; }
.hero .sub { margin: 0; font-size: 14px; color: #6E5646; }

/* ---------- 나 ---------- */
.me-bar {
  display: flex; align-items: center; gap: 10px; margin: 0 0 6px; padding: 10px 12px;
  border-radius: 18px; background: var(--paper); border: 1.5px solid var(--line);
}
.me-face { font-size: 26px; }
.me-text { flex: 1; font-size: 14.5px; }
.me-text b { font-weight: 800; color: var(--brand); }
.me-change { font-size: 12px; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; padding: 6px 2px; }

/* ---------- 처음 한 번: 이름 고르기 ---------- */
.welcome {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px;
  background: var(--bg);
}
.welcome-card { width: 100%; max-width: 400px; text-align: center; animation: pop .25s ease-out; }
.welcome-icon { font-size: 52px; }
.welcome h2 { margin: 10px 0 6px; font-size: 28px; font-weight: 800; color: var(--brand); }
.welcome p { margin: 0 0 24px; color: var(--muted); font-size: 14.5px; line-height: 1.55; }
.who-chips { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.who-chip {
  padding: 18px 8px 16px; border-radius: 22px; background: var(--paper);
  border: 1.5px solid var(--line); font-weight: 800; font-size: 17px;
  box-shadow: var(--shadow); transition: transform .12s, background .12s;
}
.who-chip:active { transform: scale(.96); background: var(--picked); }
.who-chip .face { display: block; font-size: 38px; margin-bottom: 6px; }

/* ---------- 탭 ---------- */
.tabs {
  position: sticky; top: 0; z-index: 5;
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
  margin: 0 -16px; padding: 10px 16px;
  background: linear-gradient(var(--bg) 80%, rgba(251,245,236,0));
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none; padding: 9px 14px; border-radius: 999px; background: var(--paper);
  border: 1.5px solid var(--line); font-size: 14px; font-weight: 600; white-space: nowrap;
}
.tab[aria-current="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------- 메뉴 ---------- */
.cat { scroll-margin-top: 64px; margin-top: 14px; }
.cat-title { display: flex; align-items: center; gap: 8px; margin: 8px 2px 10px; font-size: 18px; font-weight: 800; }
.cat-title .dot { width: 10px; height: 10px; border-radius: 50%; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.item {
  position: relative; text-align: left;
  padding: 14px 14px 12px; border-radius: var(--radius);
  background: var(--paper); border: 1.5px solid var(--line);
  box-shadow: 0 1px 0 rgba(91,58,41,.04);
  transition: transform .12s, border-color .12s, background .12s;
  min-height: 132px; display: flex; flex-direction: column;
}
.item:active { transform: scale(.97); }
.item .ic {
  width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center;
  font-size: 26px; margin-bottom: 10px; background: var(--tint, #F6EEE3);
}
.item .nm { font-size: 15px; font-weight: 700; line-height: 1.25; word-break: keep-all; }
.item .en { font-size: 11.5px; color: var(--muted); margin-top: 2px; line-height: 1.3; }
.item .pr { margin-top: auto; padding-top: 8px; font-size: 14px; font-weight: 800; color: var(--brand); }
.item .best {
  position: absolute; top: 12px; right: 12px; padding: 3px 7px; border-radius: 999px;
  font-size: 10.5px; font-weight: 800; background: #FFE3D3; color: #C25A2E;
}
.item .who-tags { position: absolute; right: 10px; bottom: 10px; display: flex; gap: 3px; }
.item .who-tag {
  padding: 2px 6px; border-radius: 999px; font-size: 10.5px; font-weight: 700;
  background: var(--ink); color: #fff;
}
.item.mine { border-color: var(--accent); background: var(--picked); }
.item.mine::after {
  content: '✓'; position: absolute; top: 10px; right: 10px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent); color: #fff; font-weight: 800; font-size: 14px; display: grid; place-items: center;
}
.item.mine .best { display: none; }
/* ---------- 맨 아래 주문 현황 ---------- */
.summary { margin-top: 30px; }
.summary-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.summary-list li {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border-radius: 18px; background: var(--paper); border: 1.5px solid var(--line);
}
.summary-list li.me { border-color: var(--accent); background: var(--picked); }
.summary-list .face { font-size: 26px; }
.summary-list .who { width: 52px; flex: none; font-weight: 800; font-size: 14px; }
.summary-list .what { flex: 1; font-size: 14.5px; font-weight: 600; }
.summary-list .what small { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; font-weight: 500; }
.summary-list .what.empty { color: #C0B2A5; font-weight: 500; }
.summary-list .pr { font-weight: 800; font-size: 13.5px; color: var(--brand); }
.summary-total { margin: 12px 4px 0; text-align: right; font-size: 15px; font-weight: 800; color: var(--brand); }
.summary-total span { color: var(--muted); font-weight: 600; font-size: 13px; margin-right: 6px; }

.footnote { text-align: center; color: var(--muted); font-size: 12px; margin: 26px 0 0; }

/* ---------- 하단 주문 바 ---------- */
.cart {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  max-width: 480px; margin: 0 auto;
  padding: 10px 16px calc(14px + var(--safe-b));
  background: rgba(255, 253, 249, .96); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-radius: 24px 24px 0 0; box-shadow: 0 -8px 30px rgba(91,58,41,.12);
}
.cart-head { width: 100%; display: flex; align-items: center; gap: 10px; padding: 6px 4px 10px; }
.cart-title { font-weight: 700; font-size: 15px; }
.cart-title b { margin-left: 4px; color: var(--accent); }
.cart-total { margin-left: auto; font-weight: 800; color: var(--brand); }
.chev { transition: transform .2s; color: var(--muted); }
.cart.open .chev { transform: rotate(180deg); }
.cart-body { display: none; max-height: 46vh; overflow: auto; }
.cart.open .cart-body { display: block; }
.cart-list { list-style: none; margin: 0 0 8px; padding: 0; }
.cart-list li {
  display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px dashed var(--line);
}
.cart-list .nm { width: 56px; flex: none; font-weight: 700; font-size: 14px; }
.cart-list .pick { flex: 1; font-size: 14px; }
.cart-list .pick small { display: block; color: var(--muted); font-size: 12px; }
.cart-list .pick.empty { color: #C0B2A5; }
.cart-list .pr { font-weight: 700; font-size: 13px; color: var(--brand); }
.cart-note { margin: 4px 4px 10px; font-size: 12px; color: var(--muted); line-height: 1.5; }
.send {
  width: 100%; height: 54px; border-radius: 16px; background: var(--brand); color: #fff;
  font-size: 16px; font-weight: 800; display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .12s, opacity .12s;
}
.send:active { transform: scale(.98); }
.send:disabled { opacity: .35; }
.send.sent { background: var(--mint); }

/* ---------- 시트 ---------- */
.sheet-backdrop, .modal { position: fixed; inset: 0; z-index: 30; background: rgba(46,36,32,.38); }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 31; max-width: 480px; margin: 0 auto;
  padding: 10px 20px calc(20px + var(--safe-b)); background: var(--paper);
  border-radius: 28px 28px 0 0; text-align: center; animation: up .22s ease-out;
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet-grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 16px; }
.sheet-icon { width: 76px; height: 76px; margin: 0 auto 10px; border-radius: 24px; display: grid; place-items: center; font-size: 42px; background: var(--tint, #F6EEE3); }
.sheet h3 { margin: 0; font-size: 22px; font-weight: 800; }
.sheet-en { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.sheet-price { margin: 8px 0 16px; font-weight: 800; font-size: 18px; color: var(--brand); }
.memo { display: block; text-align: left; }
.memo span { font-size: 13px; font-weight: 700; }
.memo small { color: var(--muted); font-weight: 500; }
.memo input {
  width: 100%; margin-top: 6px; padding: 13px 14px; border-radius: 14px; border: 1.5px solid var(--line);
  background: #fff; font: inherit; font-size: 16px; outline: none;
}
.memo input:focus { border-color: var(--accent); }
.quick { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 18px; }
.quick button { padding: 7px 11px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); font-size: 13px; }
.sheet-actions, .modal-actions { display: flex; gap: 8px; }
.ghost, .primary { flex: 1; height: 52px; border-radius: 16px; font-weight: 800; font-size: 16px; }
.ghost { background: var(--bg); }
.primary { flex: 2; background: var(--accent); color: #fff; }
.primary.dark { background: var(--brand); }

/* ---------- 모달 ---------- */
.modal { display: grid; place-items: center; padding: 16px; z-index: 40; }
.modal-card {
  width: 100%; max-width: 400px; background: var(--paper); border-radius: 26px; padding: 22px 18px 18px;
  text-align: center; animation: pop .2s ease-out;
}
@keyframes pop { from { transform: scale(.94); opacity: 0; } }
.modal-icon { font-size: 44px; }
.modal-card h3 { white-space: pre-line; word-break: keep-all; margin: 6px 0 12px; font-size: 19px; font-weight: 800; }
.preview {
  text-align: left; white-space: pre-wrap; word-break: keep-all; margin: 0 0 16px;
  padding: 14px; border-radius: 16px; background: #EAF3E2; font: inherit; font-size: 13.5px; line-height: 1.55;
  max-height: 46vh; overflow: auto; position: relative;
}
.preview::before { content: '💬 문자 미리보기'; display: block; font-weight: 800; font-size: 12px; color: #5D7A48; margin-bottom: 6px; }

/* ---------- 토스트 ---------- */
.toast {
  position: fixed; left: 50%; top: 16px; z-index: 50; transform: translate(-50%, -80px);
  padding: 12px 16px; border-radius: 14px; background: var(--ink); color: #fff; font-size: 14px; font-weight: 600;
  transition: transform .25s; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { transform: translate(-50%, 0); }

@media (min-width: 420px) {
  .hero h1 { font-size: 34px; }
}
