:root {
  --primary: #d97706;
  --primary-dark: #b45309;
  --bg: #faf9f7;
  --card: #ffffff;
  --text: #2c2c2a;
  --muted: #78766f;
  --border: #e8e5df;
  --success: #16a34a;
  --danger: #dc2626;
  --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.6; font-size: 15px;
  -webkit-font-smoothing: antialiased;
}
input, textarea, button { font-family: inherit; font-size: inherit; }
[hidden] { display: none !important; }

/* 登录页 */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: linear-gradient(160deg, #fffbeb 0%, #faf9f7 60%); }
.auth-card { width: 100%; max-width: 380px; background: var(--card); padding: 36px 28px; border-radius: 20px; box-shadow: 0 8px 32px rgba(120,90,30,.08); }
.auth-logo { font-size: 48px; text-align: center; }
.auth-card h1 { text-align: center; font-size: 24px; margin: 8px 0 4px; }
.auth-sub { text-align: center; color: var(--muted); margin-bottom: 24px; font-size: 14px; }
.auth-tabs { display: flex; gap: 8px; margin-bottom: 20px; }
.auth-tabs .tab { flex: 1; padding: 10px; border: 1px solid var(--border); background: transparent; border-radius: 8px; cursor: pointer; color: var(--muted); }
.auth-tabs .tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.auth-card input { width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 12px; background: #fff; }
.auth-card input:focus { outline: none; border-color: var(--primary); }
.remember-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin: 2px 0 14px; cursor: pointer; }
.auth-card .remember-row input { width: 16px; height: 16px; margin: 0; accent-color: var(--primary); cursor: pointer; }
.error-msg { color: var(--danger); text-align: center; min-height: 20px; margin-top: 8px; font-size: 13px; }

/* 按钮 */
.btn-primary { width: 100%; padding: 13px; background: var(--primary); color: #fff; border: none; border-radius: 8px; font-weight: 600; cursor: pointer; transition: background .2s; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:active { transform: scale(.98); }
.btn-block { margin-top: 8px; }
.btn-text { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 13px; }
.btn-danger { background: #fef2f2; color: var(--danger); border: none; padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 13px; }

/* 主布局 */
.app { max-width: 640px; margin: 0 auto; min-height: 100vh; background: var(--bg); }
.header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; background: var(--primary); color: #fff; position: sticky; top: 0; z-index: 20; }
.header-title { font-size: 18px; font-weight: 600; }
.header-user { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.header-user .btn-text { color: #fff; opacity: .85; }
.nav { display: flex; background: #fff; border-bottom: 1px solid var(--border); position: sticky; top: 56px; z-index: 19; }
.nav-item { flex: 1; padding: 13px 0; border: none; background: none; color: var(--muted); cursor: pointer; font-size: 14px; position: relative; }
.nav-item.active { color: var(--primary); font-weight: 600; }
.nav-item.active::after { content: ''; position: absolute; bottom: 0; left: 25%; right: 25%; height: 3px; background: var(--primary); border-radius: 3px 3px 0 0; }
.main { padding: 16px; padding-bottom: 40px; }
.page { display: none; }
.page.active { display: block; }

/* 表单 */
.form-group { margin-bottom: 14px; position: relative; }
.form-group label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.form-group input, .form-group textarea { width: 100%; padding: 11px 12px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.form-group input:focus, .form-group textarea:focus { outline: none; border-color: var(--primary); }
.form-row { display: flex; gap: 10px; }
.form-row .form-group { flex: 1; }
.required { color: var(--danger); }
.suggestions { position: absolute; top: 100%; left: 0; right: 0; background: #fff; border: 1px solid var(--border); border-radius: 8px; z-index: 10; max-height: 200px; overflow-y: auto; box-shadow: 0 4px 16px rgba(0,0,0,.08); }
.suggestion-item { padding: 10px 12px; cursor: pointer; border-bottom: 1px solid var(--border); }
.suggestion-item:last-child { border-bottom: none; }
.suggestion-item:hover { background: #fffbeb; }
.suggestion-item .s-name { font-weight: 500; }
.suggestion-item .s-meta { font-size: 12px; color: var(--muted); }
.stars { display: flex; gap: 6px; }
.stars span { font-size: 28px; color: #ddd; cursor: pointer; transition: color .15s; }
.stars span.on { color: #fbbf24; }
.photo-preview img { max-width: 120px; max-height: 120px; border-radius: 8px; margin-top: 8px; }

/* 记录列表 */
.filter-bar { display: flex; gap: 8px; margin-bottom: 14px; }
.filter-btn { padding: 7px 16px; border: 1px solid var(--border); background: #fff; border-radius: 20px; cursor: pointer; font-size: 13px; color: var(--muted); }
.filter-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.history-list { display: flex; flex-direction: column; gap: 12px; }
.checkin-card { background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: 0 1px 4px rgba(0,0,0,.04); }
.checkin-head { display: flex; justify-content: space-between; align-items: start; }
.checkin-name { font-size: 16px; font-weight: 600; }
.checkin-user { font-size: 12px; color: var(--primary); }
.checkin-meta { font-size: 12px; color: var(--muted); margin-top: 4px; }
.checkin-rating { color: #fbbf24; font-size: 14px; }
.checkin-note { margin-top: 8px; font-size: 14px; color: #444; }
.checkin-photo { margin-top: 8px; }
.checkin-photo img { max-width: 100%; max-height: 200px; border-radius: 8px; }
.checkin-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-state .empty-icon { font-size: 48px; }
.empty-state .empty-icon-img { width: 56px; height: 68px; object-fit: contain; opacity: .55; margin: 0 auto 8px; display: block; }

/* 统计 */
.stats-content { display: flex; flex-direction: column; gap: 14px; }
.stat-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat-card { background: var(--card); padding: 16px; border-radius: var(--radius); text-align: center; }
.stat-card .num { font-size: 26px; font-weight: 700; color: var(--primary); }
.stat-card .label { font-size: 12px; color: var(--muted); margin-top: 2px; }
.chart-card { background: var(--card); padding: 16px; border-radius: var(--radius); }
.chart-card h3 { font-size: 14px; margin-bottom: 12px; font-weight: 600; }
.bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 13px; }
.bar-label { width: 72px; flex-shrink: 0; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { flex: 1; background: #f3f1ec; height: 18px; border-radius: 9px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--primary); border-radius: 9px; min-width: 2px; }
.bar-value { width: 30px; text-align: right; color: var(--muted); font-size: 12px; }

/* 徽章 */
.badges-header { margin-bottom: 16px; }
.badges-header h2 { font-size: 18px; }
.badges-header p { font-size: 13px; color: var(--muted); }
.badges-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.badge-card { background: var(--card); padding: 18px 12px; border-radius: var(--radius); text-align: center; box-shadow: 0 1px 4px rgba(0,0,0,.04); filter: grayscale(1); opacity: .5; }
.badge-card.unlocked { filter: none; opacity: 1; }
.badge-icon { font-size: 36px; }
.badge-name { font-weight: 600; margin-top: 6px; font-size: 14px; }
.badge-desc { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* Toast */
body.no-scroll { overflow: hidden; }
.toast { position: fixed; top: 16px; left: 50%; width: max-content; max-width: calc(100vw - 32px); display: flex; align-items: center; gap: 12px; padding: 13px 18px 13px 13px; border-radius: 14px; background: #fff; border: 1px solid var(--border); box-shadow: 0 8px 28px rgba(0,0,0,.16); z-index: 200; opacity: 0; transform: translateX(-50%) translateY(-20px) scale(.96); transition: opacity .22s ease, transform .22s cubic-bezier(.2,1.4,.4,1); pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
.toast-icon { width: 36px; height: 36px; flex-shrink: 0; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 700; color: #fff; }
.toast-text { min-width: 0; }
.toast-title { font-size: 14px; font-weight: 700; line-height: 1.3; margin-bottom: 2px; }
.toast-desc { font-size: 13px; line-height: 1.4; color: var(--muted); word-break: break-word; }
.toast-celebrate { border-color: #fbbf24; }
.toast-celebrate .toast-icon { background: linear-gradient(135deg, #fbbf24, #d97706); }
.toast-celebrate .toast-title { color: #b45309; }
.toast-error { border-color: #fca5a5; }
.toast-error .toast-icon { background: #dc2626; }
.toast-error .toast-title { color: #b91c1c; }
.toast-success { border-color: #86efac; }
.toast-success .toast-icon { background: #16a34a; }
.toast-success .toast-title { color: #15803d; }
.toast-hint { border-color: #93c5fd; }
.toast-hint .toast-icon { background: #3b82f6; }
.toast-hint .toast-title { color: #1d4ed8; }

/* ========== 图鉴 ========== */
.progress-card { background: linear-gradient(135deg, #d97706, #b45309); color: #fff; padding: 18px; border-radius: var(--radius); margin-bottom: 16px; }
.progress-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.progress-title { font-size: 14px; opacity: .9; }
.progress-sub { font-size: 20px; font-weight: 700; margin-top: 2px; }
.progress-percent { font-size: 26px; font-weight: 700; }
.progress-track { height: 8px; background: rgba(255,255,255,.25); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: #fff; border-radius: 4px; width: 0; transition: width .4s; }

.collection-toolbar { margin-bottom: 14px; }
.collection-toolbar input { width: 100%; padding: 11px 12px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.collection-toolbar input:focus { outline: none; border-color: var(--primary); }
.filter-bar.compact { margin: 10px 0 0; }
.filter-bar.compact .filter-btn { padding: 6px 14px; font-size: 12px; }

.progress-tip { font-size: 12px; opacity: .85; margin-top: 8px; }
.select-row { display: flex; gap: 8px; margin-top: 10px; }
.select-row select { flex: 1; padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text); font-size: 13px; }
.select-row select:focus { outline: none; border-color: var(--primary); }

.collection-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.beer-tile { aspect-ratio: 0.86; background: #f7f6f3; border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 5px; text-align: center; cursor: pointer; display: flex; flex-direction: column; align-items: center; transition: transform .15s, background .2s; position: relative; overflow: hidden; }
.beer-tile:active { transform: scale(.94); }
.beer-tile .tile-photo { width: 100%; flex: 1; min-height: 0; border-radius: 8px; overflow: hidden; display: flex; align-items: center; justify-content: center; position: relative; }
.beer-tile .tile-photo img { width: 100%; height: 100%; object-fit: cover; }
.beer-tile .tile-photo img[src="/static/beer-emoji-pc.png"] { object-fit: contain; padding: 4px; }
.beer-tile .tile-photo svg { width: 100%; height: 100%; }
.beer-tile.unlit .tile-photo { filter: grayscale(1); opacity: .42; }
.beer-tile .tile-name { font-size: 11px; color: var(--muted); margin-top: 6px; line-height: 1.3; max-height: 29px; overflow: hidden; word-break: break-all; }
.beer-tile .tile-brand { font-size: 10px; color: #b5b3ac; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.beer-tile.lit { background: #fffbeb; border-color: #fbbf24; }
.beer-tile.lit .tile-name { color: var(--text); font-weight: 500; }
.beer-tile .tile-seal { position: absolute; top: 10px; right: -4px; background: #dc2626; color: #fff; font-size: 11px; font-weight: 500; padding: 3px 8px; transform: rotate(14deg); border: 2px solid #fff; border-radius: 3px; box-shadow: 0 1px 3px rgba(0,0,0,.15); z-index: 2; }
.beer-tile .tile-rating { position: absolute; bottom: 38px; left: 0; right: 0; font-size: 10px; color: #d97706; letter-spacing: -1px; text-shadow: 0 1px 2px #fff; z-index: 2; }
.beer-tile.just-lit .tile-seal { animation: stampIn .35s cubic-bezier(.2,1.6,.5,1); }
@keyframes stampIn { 0% { transform: rotate(14deg) scale(2.4); opacity: 0; } 70% { transform: rotate(14deg) scale(.9); opacity: 1; } 100% { transform: rotate(14deg) scale(1); } }

.pagination { display: flex; justify-content: center; align-items: center; gap: 6px; margin-top: 18px; flex-wrap: wrap; }
.pagination button { min-width: 36px; height: 36px; padding: 0 10px; border: 0.5px solid var(--border); background: #fff; border-radius: 8px; cursor: pointer; font-size: 13px; color: var(--text); }
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination button:disabled { opacity: .4; cursor: default; }
.pagination .page-info { font-size: 12px; color: var(--muted); padding: 0 4px; }

.photo-upload-row { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; }
.detail-photo-box { width: 84px; height: 100px; flex-shrink: 0; border: 1px dashed var(--border-secondary); border-radius: 8px; display: flex; align-items: center; justify-content: center; overflow: hidden; background: var(--color-background-secondary); }
.detail-photo-box img { width: 100%; height: 100%; object-fit: cover; }
.detail-photo-box img[src="/static/beer-emoji-pc.png"] { object-fit: contain; padding: 6px; }
.detail-photo-box svg { width: 100%; height: 100%; }
.photo-upload-hint { flex: 1; font-size: 13px; }
.photo-upload-hint input { margin-top: 8px; font-size: 12px; width: 100%; }
.collection-empty { grid-column: 1/-1; text-align: center; padding: 50px 20px; color: var(--muted); }

/* 记录页工具区 */
.history-toolbar { margin-bottom: 12px; }
.btn-secondary { padding: 9px 16px; background: #fff; border: 1px solid var(--primary); color: var(--primary); border-radius: 8px; cursor: pointer; font-size: 13px; }
.custom-form { background: var(--card); padding: 14px; border-radius: var(--radius); margin-bottom: 14px; }

/* ========== 详情弹窗 ========== */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.detail-sheet { background: var(--card); width: 100%; max-width: 640px; border-radius: 20px 20px 0 0; max-height: 85vh; overflow-y: auto; animation: slideUp .2s ease-out; }
@keyframes slideUp { from { transform: translateY(30px); opacity: .5; } to { transform: translateY(0); opacity: 1; } }
.detail-head { display: flex; justify-content: space-between; align-items: start; padding: 20px 20px 14px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--card); }
.detail-name { font-size: 18px; font-weight: 600; }
.detail-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.btn-close { background: none; border: none; font-size: 26px; color: var(--muted); cursor: pointer; line-height: 1; }
.detail-body { padding: 18px 20px 30px; }
.overlay-center { align-items: center; padding: 16px; }
.sheet-centered { border-radius: 18px; max-height: 80vh; animation: popIn .22s ease-out; }
@keyframes popIn { from { transform: translateY(12px) scale(.97); opacity: .6; } to { transform: translateY(0) scale(1); opacity: 1; } }

/* ========== 日历签到 ========== */
.calendar-card { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; box-shadow: 0 1px 4px rgba(0,0,0,.04); }
.calendar-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.calendar-title { font-size: 16px; font-weight: 600; }
.cal-arrow { width: 34px; height: 34px; border: 1px solid var(--border); background: #fff; border-radius: 8px; font-size: 20px; cursor: pointer; color: var(--text); line-height: 1; }
.calendar-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-cell { aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; border-radius: 8px; position: relative; font-size: 13px; color: var(--muted); }
.cal-cell.empty { visibility: hidden; }
.cal-cell.has-drink { background: #fffbeb; border: 1px solid #fbbf24; color: var(--text); }
.cal-cell.today { outline: 2px solid var(--primary); outline-offset: -2px; }
.cal-day { line-height: 1; }
.cal-beer { display: flex; gap: 1px; margin-top: 3px; height: 12px; }
.cal-beer img { width: 13px; height: 15px; object-fit: contain; }
.cal-qty { font-size: 11px; color: var(--primary); font-weight: 600; margin-left: 1px; line-height: 1; }
.calendar-legend { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-top: 12px; flex-wrap: wrap; }
.legend-dot { width: 12px; height: 12px; background: #fffbeb; border: 1px solid #fbbf24; border-radius: 3px; display: inline-block; }
.legend-today { margin-left: 8px; padding: 1px 6px; border: 1px solid var(--primary); border-radius: 4px; color: var(--primary); }
.summary-line { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.summary-line:last-child { border-bottom: none; }
.summary-line strong { color: var(--primary); font-weight: 600; }

/* ========== 年月选择 + 打卡 ========== */
.calendar-title { background: none; border: none; cursor: pointer; padding: 4px 8px; border-radius: 6px; }
.calendar-title:hover { background: #fffbeb; }
.cal-cell[data-date] { cursor: pointer; }
.cal-cell[data-date]:hover { background: #f3f1ec; }
.cal-cell.has-drink[data-date]:hover { background: #fef3c7; }
.ym-sheet { max-width: 360px; margin: 0 auto 40vh; border-radius: 16px; }
.ym-body { padding: 18px 20px 26px; }
.ym-row { margin-bottom: 14px; }
.ym-row label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.ym-row select { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.chosen-beer { display: flex; align-items: center; gap: 8px; margin-top: 8px; padding: 8px 10px; background: #fffbeb; border: 1px solid #fbbf24; border-radius: 8px; font-size: 13px; }
.chosen-beer img { width: 22px; height: 26px; object-fit: contain; }
#checkinQty { max-width: 140px; }

@media (max-width: 400px) {
  .form-row { flex-direction: column; gap: 0; }
  .header-title { font-size: 16px; }
  .collection-grid { grid-template-columns: repeat(3, 1fr); gap: 7px; }
  .beer-tile .tile-icon { font-size: 24px; }
  .beer-tile .tile-name { font-size: 10px; }
}
