/* =====================================================================
   PickMe 聚餐盲盒 — Design System
   Warm, appetizing palette · mobile-first · accessible
   ===================================================================== */

:root {
  /* ---- Color tokens ---- */
  --bg: #FFF9F4;
  --bg-blob: #FFE9DE;
  --surface: #FFFFFF;
  --surface-2: #FFF3EC;
  --ink: #2A211C;
  --ink-soft: #5B5048;
  --muted: #998B80;
  --line: #F1E4D9;
  --line-strong: #E7D5C6;

  --primary: #FF6B4A;
  --primary-press: #EC5536;
  --primary-soft: #FFE6DC;
  --accent: #FFC24B;

  --success: #2FAE83;
  --danger: #E5604D;
  --danger-soft: #FCE4DF;

  /* category tints */
  --cat-hotpot-bg: #FFE3DA;  --cat-hotpot-fg: #C2410C;
  --cat-jp-bg: #DCEEFB;      --cat-jp-fg: #1D6FB8;
  --cat-bbq-bg: #FBE2CF;     --cat-bbq-fg: #B45309;
  --cat-fishhot-bg: #D6F0E8;  --cat-fishhot-fg: #0F766E;
  --cat-sichuan-bg: #FBD9D5; --cat-sichuan-fg: #C0392B;
  --cat-west-bg: #E4E7FB;    --cat-west-fg: #4F46E5;
  --cat-tea-bg: #F3E3D3;     --cat-tea-fg: #92623A;
  --cat-other-bg: #ECE7E0;   --cat-other-fg: #6B6258;

  /* ---- Typography ---- */
  --font-display: "Outfit", "Noto Sans SC", system-ui, sans-serif;
  --font-body: "Noto Sans SC", "Outfit", system-ui, sans-serif;

  /* ---- Spacing (4px base) ---- */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px;
  --s-5: 20px; --s-6: 24px; --s-8: 32px; --s-10: 40px; --s-12: 48px;

  /* ---- Radius ---- */
  --r-sm: 10px; --r-md: 14px; --r-lg: 20px; --r-xl: 28px; --r-pill: 999px;

  /* ---- Shadow (warm-tinted) ---- */
  --sh-sm: 0 1px 2px rgba(120, 70, 40, .06), 0 2px 6px rgba(120, 70, 40, .05);
  --sh-md: 0 6px 18px rgba(150, 80, 40, .10);
  --sh-lg: 0 18px 40px rgba(150, 80, 40, .16);

  --ease: cubic-bezier(.16, 1, .3, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg);
  background-image:
    radial-gradient(60vw 60vw at 85% -10%, var(--bg-blob) 0%, transparent 55%),
    radial-gradient(50vw 50vw at -10% 110%, #FFEFE2 0%, transparent 50%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}

h1, h2, h3 { font-family: var(--font-display); margin: 0; letter-spacing: -.01em; }

button { font-family: inherit; }

.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 60;
  background: var(--ink); color: #fff; padding: 10px 14px; border-radius: var(--r-sm);
  text-decoration: none; transition: top .2s var(--ease);
}
.skip-link:focus { top: 12px; }

:focus-visible {
  outline: 2.5px solid var(--primary);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ===================== Header ===================== */
.app-header {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--s-3) var(--s-5);
  padding-top: calc(var(--s-3) + env(safe-area-inset-top));
  background: rgba(255, 249, 244, .82);
  backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: var(--s-2); }
.brand-mark {
  display: grid; place-items: center;
  width: 38px; height: 38px; border-radius: 12px;
  color: var(--primary);
  background: var(--primary-soft);
}
.brand-text { font-family: var(--font-display); font-weight: 800; font-size: 19px; line-height: 1; display: flex; flex-direction: column; gap: 3px; }
.brand-text small { font-family: var(--font-body); font-weight: 500; font-size: 11px; color: var(--muted); letter-spacing: .14em; }

.icon-btn {
  display: grid; place-items: center;
  width: 42px; height: 42px; min-width: 42px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--ink-soft);
  cursor: pointer; transition: all .18s var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); border-color: var(--line-strong); }
.icon-btn:active { transform: scale(.96); }

/* ===================== Layout ===================== */
.app-main { max-width: 560px; margin: 0 auto; padding: var(--s-5); }
.view { animation: viewIn .35s var(--ease); }
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ===================== Buttons ===================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: 46px; padding: 0 var(--s-5);
  border: 1px solid transparent; border-radius: var(--r-md);
  font-size: 15px; font-weight: 600; cursor: pointer;
  transition: transform .16s var(--ease), background .18s var(--ease), box-shadow .18s var(--ease), border-color .18s var(--ease);
  user-select: none;
}
.btn:active { transform: scale(.975); }
.btn:disabled { opacity: .55; pointer-events: none; }

.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 6px 16px rgba(255, 107, 74, .35); }
.btn-primary:hover { background: var(--primary-press); box-shadow: 0 10px 22px rgba(255, 107, 74, .42); }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--muted); }
.btn-lg { min-height: 58px; font-size: 17px; font-weight: 700; }
.btn-block { width: 100%; }

/* ===================== Pick view ===================== */
.pick-hero { display: flex; flex-direction: column; align-items: center; text-align: center; padding: var(--s-6) 0 var(--s-2); }
.pick-eyebrow { margin: 0 0 var(--s-6); font-size: 15px; color: var(--muted); font-weight: 500; }

.blindbox-stage { position: relative; height: 200px; display: grid; place-items: center; margin-bottom: var(--s-4); }
.blindbox { position: relative; width: 168px; height: 168px; }
.box-glow {
  position: absolute; inset: -22px; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 194, 75, .55), transparent 70%);
  opacity: .55; filter: blur(6px);
  animation: glowPulse 3.4s ease-in-out infinite;
}
@keyframes glowPulse { 0%,100% { opacity: .45; transform: scale(.96); } 50% { opacity: .8; transform: scale(1.04); } }

.box-body {
  position: absolute; left: 18px; bottom: 14px; width: 132px; height: 108px;
  background: linear-gradient(160deg, #FF7E60, #FF5E3D);
  border-radius: 16px 16px 18px 18px;
  box-shadow: inset 0 2px 6px rgba(255,255,255,.25), var(--sh-md);
  overflow: hidden;
}
.box-ribbon-v { position: absolute; left: 50%; top: 0; width: 22px; height: 100%; transform: translateX(-50%); background: rgba(255,255,255,.92); }
.box-ribbon-h { position: absolute; left: 0; top: 50%; width: 100%; height: 18px; transform: translateY(-50%); background: rgba(255,255,255,.92); }
.box-bow {
  position: absolute; left: 50%; top: -10px; width: 34px; height: 34px; transform: translateX(-50%);
  background: var(--accent); border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  box-shadow: 0 4px 10px rgba(180,120,30,.35);
}
.box-lid {
  position: absolute; left: 10px; top: 18px; width: 148px; height: 40px;
  background: linear-gradient(160deg, #FF8E72, #FF6B4A);
  border-radius: 12px;
  box-shadow: inset 0 2px 4px rgba(255,255,255,.3), var(--sh-sm);
  transform-origin: 50% 100%;
  transition: transform .5s var(--ease-spring), opacity .3s ease;
  z-index: 2;
}

/* opening animation */
.blindbox.is-opening { animation: boxShake .5s ease; }
@keyframes boxShake {
  0%,100% { transform: translateX(0) rotate(0); }
  15% { transform: translateX(-6px) rotate(-3deg); }
  30% { transform: translateX(6px) rotate(3deg); }
  45% { transform: translateX(-5px) rotate(-2deg); }
  60% { transform: translateX(5px) rotate(2deg); }
  80% { transform: translateX(-2px) rotate(-1deg); }
}
.blindbox.is-opening .box-lid { transform: translateY(-46px) rotate(-10deg); opacity: 0; }
.blindbox.is-open .box-lid { transform: translateY(-60px) rotate(-14deg); opacity: 0; }

.pick-meta { margin: 0 0 var(--s-5); font-size: 14px; color: var(--ink-soft); font-weight: 500; }
.pick-meta b { color: var(--primary); font-weight: 800; }

/* category filter chips */
.cat-filter { display: flex; flex-wrap: wrap; gap: var(--s-2); justify-content: center; margin-bottom: var(--s-6); max-width: 420px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; min-height: 38px;
  border: 1px solid var(--line-strong); border-radius: var(--r-pill);
  background: var(--surface); color: var(--ink-soft);
  font-size: 13.5px; font-weight: 600; cursor: pointer;
  transition: all .16s var(--ease);
}
.chip:hover { border-color: var(--muted); }
.chip.is-active { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip .chip-dot { width: 8px; height: 8px; border-radius: 50%; }

/* ===================== Result card ===================== */
.result-card {
  position: relative; margin-top: var(--s-4); padding: var(--s-6);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-xl); box-shadow: var(--sh-lg);
  text-align: center; overflow: hidden;
  animation: resultIn .5s var(--ease-spring);
}
@keyframes resultIn { from { opacity: 0; transform: translateY(18px) scale(.96); } to { opacity: 1; transform: none; } }
.result-card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 6px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}
.result-tag { display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: .12em; color: var(--muted); }
.result-cat { display: inline-block; margin-left: 8px; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: var(--r-pill); }
.result-name { font-size: 30px; font-weight: 800; margin: var(--s-3) 0 var(--s-2); line-height: 1.2; }
.result-note { margin: 0 0 var(--s-2); color: var(--ink-soft); font-size: 15px; }
.result-loc { display: inline-flex; align-items: center; gap: 6px; margin: 0; color: var(--muted); font-size: 13.5px; }
.result-loc svg { flex: none; }
.result-actions { display: flex; gap: var(--s-3); margin-top: var(--s-6); }
.result-actions .btn { flex: 1; }

/* ===================== Library view ===================== */
.library-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s-4); }
.library-title { font-size: 26px; font-weight: 800; }
.library-tools { margin-bottom: var(--s-4); }
.search {
  display: flex; align-items: center; gap: var(--s-2);
  padding: 0 var(--s-4); height: 48px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-md);
  color: var(--muted); transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}
.search:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.search input { flex: 1; border: 0; background: none; outline: none; font-size: 15px; color: var(--ink); font-family: inherit; }
.search input::placeholder { color: var(--muted); }

.stat-row { display: flex; gap: var(--s-3); margin-bottom: var(--s-5); }
.stat {
  flex: 1; display: flex; flex-direction: column; gap: 2px;
  padding: var(--s-4); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); box-shadow: var(--sh-sm);
}
.stat-num { font-family: var(--font-display); font-size: 26px; font-weight: 800; color: var(--ink); }
.stat-label { font-size: 12.5px; color: var(--muted); font-weight: 500; }

.rest-grid { display: grid; grid-template-columns: 1fr; gap: var(--s-3); }
.rest-card {
  display: flex; align-items: flex-start; gap: var(--s-3);
  padding: var(--s-4); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--sh-sm);
  transition: transform .16s var(--ease), box-shadow .18s var(--ease), border-color .18s var(--ease);
  animation: cardIn .32s var(--ease) both;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.rest-card:hover { transform: translateY(-2px); box-shadow: var(--sh-md); border-color: var(--line-strong); }
.rest-main { flex: 1; min-width: 0; }
.rest-name { font-size: 17px; font-weight: 700; display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.rest-cat { font-size: 11.5px; font-weight: 700; padding: 2px 9px; border-radius: var(--r-pill); flex: none; }
.rest-note { margin: 6px 0 0; font-size: 13.5px; color: var(--ink-soft); }
.rest-loc { display: inline-flex; align-items: center; gap: 5px; margin: 6px 0 0; font-size: 12.5px; color: var(--muted); }
.rest-loc svg { flex: none; }
.src { font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: var(--r-pill); flex: none; line-height: 1.5; }
.src-seed { background: #FFF1DC; color: #B26A00; }
.src-temp { background: var(--surface-2); color: var(--muted); }
.about-body code, .empty-state code { font-family: var(--font-display); font-size: .92em; background: var(--surface-2); color: var(--primary-press); padding: 1px 6px; border-radius: 6px; }
.rest-loc svg { flex: none; }
.rest-ops { display: flex; flex-direction: column; gap: var(--s-2); }
.op-btn {
  display: grid; place-items: center; width: 38px; height: 38px; min-width: 38px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
  color: var(--muted); cursor: pointer; transition: all .16s var(--ease);
}
.op-btn:hover { background: var(--surface-2); color: var(--ink); }
.op-btn.danger:hover { background: var(--danger-soft); color: var(--danger); border-color: #F3C4BB; }
.op-btn:active { transform: scale(.94); }

/* empty state */
.empty-state { text-align: center; padding: var(--s-12) var(--s-5); }
.empty-illu { display: inline-grid; place-items: center; width: 120px; height: 120px; border-radius: 50%; background: var(--surface-2); margin-bottom: var(--s-4); }
.empty-state h3 { font-size: 19px; font-weight: 700; margin-bottom: var(--s-2); }
.empty-state p { color: var(--ink-soft); font-size: 14.5px; margin: 0 auto var(--s-5); max-width: 320px; line-height: 1.6; }

/* ===================== Bottom nav ===================== */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; gap: var(--s-2); justify-content: center;
  max-width: 560px; margin: 0 auto;
  padding: var(--s-2) var(--s-5) calc(var(--s-2) + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 62%, transparent);
}
.nav-btn {
  flex: 1; max-width: 200px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: var(--s-2) 0; min-height: 56px;
  border: 1px solid var(--line); border-radius: 16px;
  background: var(--surface); color: var(--muted);
  font-size: 12px; font-weight: 600; cursor: pointer;
  transition: all .18s var(--ease);
}
.nav-btn svg { transition: transform .2s var(--ease); }
.nav-btn.is-active { color: var(--primary); border-color: var(--primary-soft); background: var(--primary-soft); }
.nav-btn.is-active svg { transform: translateY(-1px); }
.nav-btn:active { transform: scale(.97); }

/* ===================== Modal ===================== */
.modal-root { position: fixed; inset: 0; z-index: 80; display: grid; place-items: end center; }
.modal-root[hidden] { display: none; }
.modal-scrim { position: absolute; inset: 0; background: rgba(42, 33, 28, .42); backdrop-filter: blur(2px); animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal-panel {
  position: relative; width: 100%; max-width: 560px;
  background: var(--bg); border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--sh-lg); padding: var(--s-5);
  padding-bottom: calc(var(--s-5) + env(safe-area-inset-bottom));
  animation: sheetUp .32s var(--ease);
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s-4); }
.modal-head h2 { font-size: 20px; font-weight: 800; }
.modal-body { display: flex; flex-direction: column; gap: var(--s-4); }
.field { display: flex; flex-direction: column; gap: var(--s-2); }
.field label { font-size: 13.5px; font-weight: 600; color: var(--ink-soft); }
.req { color: var(--danger); }
.field input, .field textarea, .field select {
  width: 100%; padding: 12px 14px; font-size: 15px; font-family: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-md);
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}
.field textarea { resize: vertical; min-height: 56px; }
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}
.field-err { color: var(--danger); font-size: 12.5px; font-weight: 500; }
.field.has-error input { border-color: var(--danger); }

.select-wrap { position: relative; }
.select-wrap select { appearance: none; -webkit-appearance: none; padding-right: 40px; cursor: pointer; }
.select-caret { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }

.modal-actions { display: flex; gap: var(--s-3); margin-top: var(--s-2); }
.modal-actions .btn { flex: 1; }

/* about */
.about-body { gap: var(--s-4); }
.about-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s-4); counter-reset: step; }
.about-steps li { display: flex; gap: var(--s-3); align-items: flex-start; }
.about-steps li::before {
  counter-increment: step; content: counter(step);
  flex: none; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; font-family: var(--font-display); font-weight: 800; font-size: 14px;
  background: var(--primary); color: #fff;
}
.about-steps strong { display: block; font-size: 15px; margin-bottom: 2px; }
.about-steps span { font-size: 13.5px; color: var(--ink-soft); line-height: 1.55; }
.about-note { font-size: 12.5px; color: var(--muted); line-height: 1.6; background: var(--surface-2); padding: var(--s-3) var(--s-4); border-radius: var(--r-md); margin: 0; }

/* ===================== Toast ===================== */
.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(10px);
  z-index: 90; max-width: 90vw;
  padding: 12px 20px; background: var(--ink); color: #fff;
  font-size: 14px; font-weight: 600; border-radius: var(--r-pill);
  box-shadow: var(--sh-lg); opacity: 0; pointer-events: none;
  transition: opacity .25s var(--ease), transform .25s var(--ease);
}
.toast.is-show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-action {
  margin-left: var(--s-3); padding: 6px 14px; min-height: 34px;
  border: 1.5px solid rgba(255,255,255,.5); border-radius: var(--r-pill);
  background: transparent; color: #fff; font-size: 13px; font-weight: 700; cursor: pointer;
  transition: background .16s var(--ease);
}
.toast-action:hover { background: rgba(255,255,255,.16); }
.toast-action:active { transform: scale(.96); }

/* ===================== Responsive ===================== */
@media (min-width: 600px) {
  .rest-grid { grid-template-columns: 1fr 1fr; }
  .modal-root { place-items: center; }
  .modal-panel { border-radius: var(--r-xl); }
  @keyframes sheetUp { from { transform: translateY(16px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
}

/* ===================== Reduced motion ===================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .box-glow { animation: none; }
  .blindbox.is-opening { animation: none; }
}
