/* ==================== 基础变量 ==================== */
:root {
  --brand: #FF6B35;
  --brand-light: #FF8F5A;
  --brand-dark: #E85D25;
  --bg: #FFF8F0;
  --bg-card: #fff;
  --text: #3D2817;
  --text-sub: #8A6D5A;
  --border: rgba(255, 107, 53, 0.15);
  --shadow-sm: 0 2px 8px rgba(255, 107, 53, 0.08);
  --shadow-md: 0 6px 20px rgba(255, 107, 53, 0.15);
  --shadow-lg: 0 12px 40px rgba(255, 107, 53, 0.25);
  --tabbar-h: 60px;
  --topbar-h: 48px;
  --safe-bottom: env(safe-area-inset-bottom, 0);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Helvetica Neue', 'Microsoft YaHei', sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

/* ==================== 应用布局 ==================== */
#app {
  display: flex; flex-direction: column; height: 100vh;
  max-width: 520px; margin: 0 auto; background: var(--bg);
  position: relative; box-shadow: 0 0 40px rgba(0, 0, 0, 0.08);
}

/* ==================== 顶部栏 ==================== */
.topbar {
  height: var(--topbar-h); flex-shrink: 0;
  display: flex; align-items: center; padding: 0 12px;
  background: var(--bg); border-bottom: 1px solid var(--border); z-index: 10;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 4px; min-width: 80px; }
.topbar-right { justify-content: flex-end; }
.topbar-center { flex: 1; text-align: center; font-size: 16px; font-weight: 700; color: var(--brand); }
.city-btn {
  display: flex; align-items: center; gap: 4px; padding: 6px 10px;
  background: rgba(255, 107, 53, 0.08); border-radius: 20px;
  font-size: 13px; color: var(--text); transition: transform 0.15s;
}
.city-btn:active { transform: scale(0.95); }
.city-name { font-weight: 600; }
.city-arrow { font-size: 10px; color: var(--text-sub); }
.icon-btn {
  width: 32px; height: 32px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255, 107, 53, 0.08); color: var(--text-sub);
  font-size: 16px; font-weight: 600; transition: background 0.15s;
}
.icon-btn:active { background: rgba(255, 107, 53, 0.2); }

/* ==================== 主内容容器 ==================== */
.page-container {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom));
  position: relative;
}
.page-loading {
  height: 100%; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 12px; color: var(--text-sub); font-size: 14px;
}
.spinner {
  width: 32px; height: 32px; border: 3px solid rgba(255, 107, 53, 0.2);
  border-top-color: var(--brand); border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ==================== 底部 TabBar ==================== */
.tabbar {
  position: absolute; bottom: 0; left: 0; right: 0;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: flex; align-items: stretch; background: #fff;
  border-top: 1px solid var(--border); z-index: 10;
}
.tab-item {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 2px; color: #999; font-size: 10px;
  cursor: pointer; transition: color 0.15s, transform 0.15s;
}
.tab-item:active { transform: scale(0.9); }
.tab-item.active { color: var(--brand); }
.tab-icon { font-size: 22px; line-height: 1; }
.tab-label { font-size: 10px; font-weight: 500; }
.tab-ai .tab-icon {
  background: linear-gradient(135deg, #FF8F5A, #FF6B35);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; filter: drop-shadow(0 2px 4px rgba(255, 107, 53, 0.3));
}

/* ==================== Toast ==================== */
.toast {
  position: fixed; top: 40%; left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  background: rgba(0, 0, 0, 0.85); color: #fff;
  padding: 12px 20px; border-radius: 12px; font-size: 14px;
  z-index: 100; opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  max-width: 80%; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* ==================== 公用 ==================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px; border-radius: 100px; font-size: 14px; font-weight: 600;
  transition: transform 0.15s, box-shadow 0.15s;
}
.btn:active { transform: scale(0.96); }
.btn-primary {
  background: linear-gradient(135deg, var(--brand-light), var(--brand));
  color: #fff; box-shadow: var(--shadow-md);
}
.btn-outline { background: transparent; color: var(--brand); border: 1.5px solid var(--brand); }
.card { background: var(--bg-card); border-radius: 16px; padding: 16px; box-shadow: var(--shadow-sm); }

/* ==================== 首页（转盘）==================== */
.page-home { padding: 12px 16px 20px; display: flex; flex-direction: column; gap: 14px; }

.scene-tabs {
  display: flex; gap: 8px; background: #fff;
  border-radius: 100px; padding: 4px; box-shadow: var(--shadow-sm);
}
.scene-tab {
  flex: 1; text-align: center; padding: 8px 0; border-radius: 100px;
  font-size: 13px; font-weight: 600; color: var(--text-sub); transition: all 0.2s;
}
.scene-tab.active {
  background: linear-gradient(135deg, var(--brand-light), var(--brand));
  color: #fff; box-shadow: 0 4px 12px rgba(255, 107, 53, 0.3);
}

.period-bar { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0; scrollbar-width: none; }
.period-bar::-webkit-scrollbar { display: none; }
.period-item {
  flex-shrink: 0; padding: 8px 14px; background: #fff;
  border-radius: 100px; font-size: 12px; color: var(--text);
  border: 1px solid var(--border); transition: all 0.15s;
}
.period-item.active { background: var(--brand); color: #fff; border-color: var(--brand); }

.daily-tip {
  background: linear-gradient(135deg, rgba(255, 143, 90, 0.15), rgba(255, 107, 53, 0.08));
  border: 1px dashed var(--brand); border-radius: 12px;
  padding: 10px 14px; font-size: 13px; color: var(--text); line-height: 1.5; text-align: center;
}

/* 转盘 */
.wheel-section { display: flex; flex-direction: column; align-items: center; padding: 16px 0; gap: 14px; }
.wheel-wrap { position: relative; width: 300px; height: 300px; max-width: 85vw; max-height: 85vw; }
.wheel-canvas {
  width: 100%; height: 100%; border-radius: 50%; background: #fff;
  box-shadow: var(--shadow-lg), 0 0 0 4px #fff, 0 0 0 6px var(--brand);
  transition: transform 4s cubic-bezier(0.17, 0.67, 0.25, 1);
}
.wheel-pointer {
  position: absolute; top: -8px; left: 50%; transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 14px solid transparent; border-right: 14px solid transparent;
  border-top: 24px solid var(--brand);
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2)); z-index: 2;
}
.wheel-center-btn {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 80px; height: 80px; border-radius: 50%;
  background: linear-gradient(135deg, #fff, #FFF8F0);
  box-shadow: 0 4px 16px rgba(255, 107, 53, 0.3), inset 0 -4px 8px rgba(255, 107, 53, 0.1);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700; color: var(--brand);
  transition: transform 0.15s; user-select: none;
}
.wheel-center-btn:active { transform: translate(-50%, -50%) scale(0.92); }
.wheel-center-btn.spinning { pointer-events: none; opacity: 0.6; }

.wheel-hint { font-size: 12px; color: var(--text-sub); }

/* ==================== 结果面板（底部弹出）==================== */
.result-mask {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 50; opacity: 0; pointer-events: none;
  transition: opacity 0.25s;
}
.result-mask.show { opacity: 1; pointer-events: auto; }

.result-panel {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: #fff; border-radius: 20px 20px 0 0;
  padding: 20px 16px calc(20px + var(--safe-bottom));
  transform: translateY(100%); transition: transform 0.3s cubic-bezier(0.17, 0.67, 0.25, 1);
  max-height: 85%; overflow-y: auto;
}
..result-mask.show .result-panel { transform: translateY(0); }

.result-header { text-align: center; margin-bottom: 16px; }
.result-category { font-size: 22px; font-weight: 700; color: var(--brand); margin-bottom: 4px; }
.result-sub { font-size: 13px; color: var(--text-sub); }
.result-close {
  position: absolute; top: 12px; right: 12px;
  width: 28px; height: 28px; border-radius: 50%;
  background: rgba(0, 0, 0, 0.05); font-size: 16px; color: var(--text-sub);
  display: flex; align-items: center; justify-content: center;
}

.restaurant-list { display: flex; flex-direction: column; gap: 10px; }
.restaurant-card {
  display: flex; gap: 12px; padding: 12px;
  background: #fff; border-radius: 12px; border: 1px solid var(--border);
  transition: transform 0.15s;
}
.restaurant-card:active { transform: scale(0.98); }
.rest-thumb {
  width: 72px; height: 72px; border-radius: 10px; flex-shrink: 0;
  background: linear-gradient(135deg, rgba(255,143,90,0.2), rgba(255,107,53,0.1));
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; overflow: hidden;
}
.rest-thumb img { width: 100%; height: 100%; object-fit: cover; }
.rest-info { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.rest-name { font-size: 15px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rest-meta { font-size: 12px; color: var(--text-sub); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.rest-addr { font-size: 11px; color: var(--text-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rest-score { color: #FF6B35; font-weight: 600; }

.result-actions { display: flex; gap: 10px; margin-top: 16px; }
.result-actions .btn { flex: 1; }

/* ==================== 占位页 ==================== */
.page-placeholder {
  height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 12px; padding: 40px 20px; text-align: center;
}
.placeholder-emoji { font-size: 56px; opacity: 0.8; }
.placeholder-title { font-size: 18px; font-weight: 700; color: var(--text); }
.placeholder-desc { font-size: 13px; color: var(--text-sub); line-height: 1.6; max-width: 280px; }

/* ==================== 列表通用 ==================== */
.list-section { padding: 12px 16px; }
.section-title { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 10px; padding-left: 4px; display: flex; align-items: center; gap: 6px; }

/* ==================== 发现页 ==================== */
.page-discover { padding: 12px 0 24px; display: flex; flex-direction: column; gap: 18px; }
.discover-section { padding: 0 16px; }
.discover-section .section-title { font-size: 15px; }
.discover-section .section-sub { font-size: 12px; color: var(--text-sub); margin-left: auto; font-weight: 400; }

.cat-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
}
.cat-cell {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 4px; border-radius: 12px; background: var(--bg-card);
  border: 1px solid var(--border); transition: transform 0.15s, background 0.15s;
  cursor: pointer; text-align: center;
}
.cat-cell:active { transform: scale(0.94); background: rgba(255,107,53,0.08); }
.cat-emoji { font-size: 28px; line-height: 1; }
.cat-name { font-size: 12px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

.rank-list { display: flex; flex-direction: column; gap: 8px; }
.rank-card {
  display: flex; gap: 12px; align-items: center; padding: 10px 12px;
  background: var(--bg-card); border-radius: 12px; border: 1px solid var(--border);
  transition: transform 0.15s; cursor: pointer;
}
.rank-card:active { transform: scale(0.98); }
.rank-num {
  width: 26px; height: 26px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; font-family: 'SF Mono', Menlo, monospace;
  background: rgba(255,107,53,0.1); color: var(--brand);
}
.rank-card.top-1 .rank-num { background: linear-gradient(135deg,#FFD700,#FFA500); color:#fff; }
.rank-card.top-2 .rank-num { background: linear-gradient(135deg,#C0C0C0,#909090); color:#fff; }
.rank-card.top-3 .rank-num { background: linear-gradient(135deg,#CD7F32,#A0522D); color:#fff; }

.scroll-x {
  display: flex; gap: 10px; overflow-x: auto; padding: 4px 16px 8px;
  scrollbar-width: none;
}
.scroll-x::-webkit-scrollbar { display: none; }
.featured-card {
  flex: 0 0 156px; height: 100px; border-radius: 14px;
  background: linear-gradient(135deg, var(--brand-light), var(--brand));
  padding: 12px; color: #fff; display: flex; flex-direction: column;
  justify-content: space-between; cursor: pointer; transition: transform 0.15s;
  box-shadow: var(--shadow-sm);
}
.featured-card:active { transform: scale(0.97); }
.featured-name { font-size: 14px; font-weight: 700; line-height: 1.3; }
.featured-meta { font-size: 11px; opacity: 0.9; }

.skeleton-row {
  height: 78px; border-radius: 12px;
  background: linear-gradient(90deg, rgba(0,0,0,0.04) 0%, rgba(0,0,0,0.08) 50%, rgba(0,0,0,0.04) 100%);
  background-size: 200% 100%; animation: skeleton-shimmer 1.4s infinite;
}
@keyframes skeleton-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ==================== 搜索页 ==================== */
.page-search { padding: 12px 16px 20px; display: flex; flex-direction: column; gap: 14px; }
.search-bar {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-card); border: 1.5px solid var(--border); border-radius: 22px;
  padding: 8px 14px; transition: border-color 0.15s, box-shadow 0.15s;
}
.search-bar:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(255,107,53,0.12); }
.search-bar .search-icon { font-size: 15px; color: var(--text-sub); }
.search-input {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: 14px; color: var(--text); min-width: 0;
}
.search-input::placeholder { color: var(--text-sub); }
.search-clear {
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(0,0,0,0.08); color: var(--text-sub); font-size: 12px;
  display: none; align-items: center; justify-content: center; flex-shrink: 0;
}
.search-bar.has-value .search-clear { display: flex; }
.search-submit {
  flex-shrink: 0; padding: 5px 14px; border-radius: 18px;
  background: var(--brand); color: #fff; font-size: 13px; font-weight: 600;
  transition: transform 0.15s, opacity 0.15s;
}
.search-submit:active { transform: scale(0.95); }
.search-submit:disabled { opacity: 0.4; }

.tag-row { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-chip {
  padding: 6px 12px; border-radius: 16px;
  background: var(--bg-card); border: 1px solid var(--border);
  font-size: 12px; color: var(--text); cursor: pointer; transition: all 0.15s;
}
.tag-chip:active { transform: scale(0.94); }
.tag-chip.hot { background: rgba(255,107,53,0.08); border-color: rgba(255,107,53,0.3); color: var(--brand); }

.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.section-head .section-title { margin-bottom: 0; }
.text-action {
  font-size: 12px; color: var(--text-sub); cursor: pointer;
  padding: 4px 6px; border-radius: 6px; transition: background 0.15s;
}
.text-action:active { background: rgba(0,0,0,0.05); }

.search-results { display: flex; flex-direction: column; gap: 8px; }
.result-meta-line {
  font-size: 12px; color: var(--text-sub); padding: 4px 4px 0;
}
.empty-state {
  padding: 60px 24px; text-align: center; color: var(--text-sub);
}
.empty-state .empty-emoji { font-size: 44px; opacity: 0.6; margin-bottom: 8px; }
.empty-state .empty-title { font-size: 14px; color: var(--text); margin-bottom: 4px; font-weight: 600; }
.empty-state .empty-desc { font-size: 12px; line-height: 1.6; }

.load-more {
  margin-top: 12px; padding: 10px; text-align: center; font-size: 13px;
  color: var(--brand); background: var(--bg-card); border-radius: 10px;
  border: 1px solid var(--border); cursor: pointer; transition: background 0.15s;
}
.load-more:active { background: rgba(255,107,53,0.08); }
.load-more.disabled { color: var(--text-sub); cursor: default; }

/* ==================== 桌面大屏适配 ==================== */
@media (min-width: 768px) {
  #app { border-radius: 16px; margin: 12px auto; height: calc(100vh - 24px); }
}
