:root {
  --bg: #fbf6f1;
  --card: #ffffff;
  --text: #2b211c;
  --muted: #8a7b72;
  --line: #eadfd6;
  --brand: #e8603c;
  --brand-dark: #c94a29;
  --brand-soft: #fde7df;
  --ok: #2f9e6a;
  --star: #f4a62a;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
button, select, input, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--brand); color: #fff;
}
.topbar h1 { margin: 0; font-size: 19px; letter-spacing: 1px; }
.user { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.user img { width: 26px; height: 26px; border-radius: 50%; border: 2px solid rgba(255,255,255,.6); }

main { max-width: 640px; margin: 0 auto; padding: 12px 16px; }
.view { display: none; }
.view.active { display: block; }

.btn {
  border: 0; border-radius: 10px; padding: 10px 14px;
  background: var(--brand); color: #fff; font-weight: 600; cursor: pointer;
}
.btn:active { background: var(--brand-dark); }
.btn.ghost { background: var(--brand-soft); color: var(--brand-dark); }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.big { width: 100%; padding: 16px; font-size: 18px; border-radius: var(--radius); }
.btn.danger { background: #fbe3e3; color: #c0392b; }
.btn:disabled { opacity: .5; }

.select, input[type=text], input[type=search], textarea {
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: #fff; width: 100%;
}
.grow { flex: 1; }

.locbar { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.loc-label { flex: 1; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.controls { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.controls .select { width: auto; flex: 1; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; margin-bottom: 6px; scrollbar-width: none; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip {
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 5px 12px; font-size: 13px; white-space: nowrap; cursor: pointer;
}
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin: 4px 0 8px; }

.list { display: flex; flex-direction: column; gap: 10px; }
.card { background: var(--card); border-radius: var(--radius); padding: 12px 14px; box-shadow: 0 1px 3px rgba(80,40,20,.06); }
.place-top { display: flex; justify-content: space-between; gap: 8px; }
.place-name { font-weight: 700; font-size: 16px; }
.place-dist { color: var(--muted); font-size: 13px; white-space: nowrap; }
.place-meta { display: flex; flex-wrap: wrap; gap: 6px 10px; margin-top: 4px; font-size: 13px; color: var(--muted); }
.tag { background: var(--brand-soft); color: var(--brand-dark); border-radius: 6px; padding: 1px 7px; font-size: 12px; }
.stars { color: var(--star); font-weight: 600; }
.price { color: var(--ok); font-weight: 600; }
.place-addr { font-size: 12px; color: var(--muted); margin-top: 4px; }
.place-note { font-size: 13px; margin-top: 4px; }
.place-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; line-height: 1.7; }
.src { font-size: 11px; color: var(--muted); text-align: center; margin: 10px 0; }

.pool-head { display: flex; gap: 8px; margin-bottom: 8px; }
.pool-actions { display: flex; gap: 8px; margin-bottom: 8px; }
.pool-actions .btn { flex: 1; }

.form label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.form label .select, .form label input, .form label textarea { margin-top: 4px; color: var(--text); }
.hint { font-size: 12px; color: var(--muted); margin: 4px 0 0; }
.center { text-align: center; }

.slot {
  margin: 14px 0; border-radius: 20px; padding: 28px 16px; text-align: center;
  background: linear-gradient(135deg, #ffb36b, var(--brand)); color: #fff;
  min-height: 130px; display: flex; flex-direction: column; justify-content: center;
  box-shadow: 0 6px 18px rgba(232,96,60,.3);
}
.slot-name { font-size: 26px; font-weight: 800; line-height: 1.3; }
.slot-meta { font-size: 13px; opacity: .9; margin-top: 6px; }
.slot.spinning .slot-name { filter: blur(.4px); }
.slot.done { animation: pop .35s ease; }
@keyframes pop { 50% { transform: scale(1.05); } }
.result-actions { display: flex; gap: 8px; margin-top: 10px; }
.result-actions .btn { flex: 1; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab { flex: 1; border: 0; background: none; padding: 8px 0 10px; font-size: 12px; color: var(--muted); cursor: pointer; }
.tab span { display: block; font-size: 22px; }
.tab.active { color: var(--brand); font-weight: 700; }

.modal { position: fixed; inset: 0; z-index: 50; background: rgba(30,20,15,.45); display: flex; align-items: flex-end; justify-content: center; }
.modal-box {
  background: #fff; width: 100%; max-width: 640px; max-height: 88vh; overflow-y: auto;
  border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
}
.modal-box h3 { margin: 0 0 12px; }
.modal-btns { display: flex; gap: 8px; margin-top: 14px; }
.modal-btns .btn { flex: 1; }
.star-pick, .price-pick { display: flex; gap: 6px; margin-top: 4px; }
.star-pick button, .price-pick button {
  flex: 1; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 8px 0; cursor: pointer;
}
.star-pick button.on { background: #fff4df; border-color: var(--star); color: #b97400; }
.price-pick button.on { background: #e3f5ec; border-color: var(--ok); color: var(--ok); }
.opt-list button { display: block; width: 100%; text-align: left; margin-bottom: 6px; }

.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); z-index: 60;
  background: rgba(40,30,25,.9); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; max-width: 90%;
}
.loading {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  background: var(--bg); color: var(--muted);
}

.kwbar { display: flex; gap: 6px; margin-bottom: 10px; }
.kwbar input { flex: 1; }
.kw-banner { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px;
  background: var(--brand-soft); border-radius: 10px; padding: 8px 10px; font-size: 14px; }
.toggles { display: flex; gap: 14px; flex-wrap: wrap; }
.notice { background: #fff4df; color: #8a5a00; border-radius: 10px; padding: 8px 10px; font-size: 13px; margin: 4px 0 10px; }
.open { color: var(--ok); font-weight: 600; }
.closed { color: #a0948c; }
.mine { color: #b97400; }
.src-g { font-size: 11px; color: var(--muted); }
#rankChips { margin-bottom: 8px; }
.sec-title { font-size: 15px; margin: 18px 0 8px; color: var(--muted); }
.stat-row { display: flex; justify-content: space-between; align-items: baseline; }
.stat-big { font-size: 30px; font-weight: 800; color: var(--brand); }
.bar-row { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-top: 6px; }
.bar-row .lbl { width: 84px; flex-shrink: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .bar { height: 10px; border-radius: 5px; background: var(--brand); opacity: .8; }
.bar-row .n { color: var(--muted); }
.hist-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.hist-date { font-size: 12px; color: var(--muted); }
.icon-btn { border: 0; background: none; color: var(--muted); font-size: 16px; cursor: pointer; padding: 4px 8px; }
.form .toggle { display: flex; color: var(--muted); }
.form .toggle input { width: auto; margin: 0; }
