:root {
    --bg: #ece3d9;
    --card: #fdf8f3;
    --panel: #ffffff;
    --ink: #2b2118;
    --ink-soft: #7a6a5c;
    --line: #f0e6da;
    --brand: #e2673a;
    --brand-soft: #fdf0e9;
    --danger: #c0392b;
    --ok: #2e7d32;
    --warn: #b26a00;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body {
    margin: 0; padding: 0;
    background: var(--bg);
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
    color: var(--ink);
    height: 100%;
}
#app { display: flex; flex-direction: column; height: 100vh; max-width: 560px; margin: 0 auto; background: var(--card); box-shadow: 0 0 30px rgba(60,40,20,0.1); }

/* 同步状态条 */
.sync-banner {
    flex-shrink: 0; padding: 8px 16px; font-size: 13px; text-align: center; position: relative; z-index: 10;
}
.sync-info { background: #eef3fb; color: #34507a; }
.sync-pending { background: #fdf6e6; color: var(--warn); }
.sync-done { background: #eaf5ea; color: var(--ok); }
.sync-error { background: #fdeceb; color: var(--danger); }

/* 视图 */
.view { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.page { padding: 16px 16px 24px; }
.page-center { display: flex; align-items: center; justify-content: center; min-height: 100%; }

/* TabBar */
.tabbar {
    flex-shrink: 0; display: flex; border-top: 1px solid var(--line); background: var(--panel);
    padding-bottom: env(safe-area-inset-bottom);
}
.tab {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; padding: 8px 0 10px; background: transparent; border: 0; cursor: pointer;
    color: #9c8b7d; font-size: 12px;
}
.tab-icon { font-size: 20px; line-height: 1; }
.tab-on { color: var(--brand); font-weight: 600; }

/* 通用 */
.hero { display: flex; align-items: center; justify-content: space-between; padding: 4px 0 14px; }
.hero-title { font-size: 22px; font-weight: 700; }
.hero-sub { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }
.card { background: var(--panel); border-radius: 12px; padding: 14px; margin-bottom: 12px; border: 1px solid var(--line); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; margin: 20px auto; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; padding: 40px 20px; }
.empty-title { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.empty-desc { font-size: 13px; color: var(--ink-soft); line-height: 1.6; }
.empty-actions { margin-top: 16px; display: flex; gap: 10px; justify-content: center; }

/* 按钮 */
.btn {
    display: inline-block; padding: 10px 18px; border-radius: 8px; border: 0; cursor: pointer;
    font-size: 14px; font-weight: 600; transition: opacity 0.15s;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-ghost { background: transparent; color: var(--brand); border: 1px solid var(--brand); }
.btn-block { display: block; width: 100%; margin-bottom: 10px; }
.btn-inline { padding: 8px 14px; font-size: 13px; }

/* 输入 */
.input {
    width: 100%; padding: 11px 14px; border-radius: 8px; border: 1px solid var(--line);
    font-size: 15px; background: var(--panel); color: var(--ink); outline: none; margin-bottom: 4px;
}
.input:focus { border-color: var(--brand); }
.field-label { display: block; font-size: 13px; color: var(--ink-soft); margin: 12px 0 6px; }
.form-msg { color: var(--danger); font-size: 13px; margin: 8px 0; }

/* 登录 */
.login-card { width: 100%; max-width: 360px; padding: 32px 24px; background: var(--panel); border-radius: 16px; }
.login-brand { font-size: 22px; font-weight: 700; text-align: center; }
.login-sub { font-size: 13px; color: var(--ink-soft); text-align: center; margin: 6px 0 24px; }
.login-note { font-size: 12px; color: var(--ink-soft); text-align: center; margin-top: 16px; }
.status-title { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.status-text { font-size: 13px; color: var(--ink-soft); line-height: 1.6; }
#login-status { background: var(--brand-soft); border-radius: 8px; padding: 14px; margin-bottom: 16px; }
.code-row { display: flex; gap: 10px; }
.code-row .input { flex: 1; }
.code-row .btn { flex-shrink: 0; }

/* 标签 / 筛选 */
.seg { display: flex; gap: 6px; background: var(--line); border-radius: 10px; padding: 4px; margin-bottom: 14px; }
.seg-btn { flex: 1; padding: 8px 0; border: 0; border-radius: 8px; background: transparent; color: var(--ink-soft); font-size: 14px; cursor: pointer; }
.seg-on { background: var(--panel); color: var(--brand); font-weight: 600; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip { padding: 6px 14px; border-radius: 20px; background: var(--panel); border: 1px solid var(--line); font-size: 13px; cursor: pointer; color: var(--ink-soft); }
.chip-on { background: var(--brand); border-color: var(--brand); color: #fff; }
.search { position: relative; margin-bottom: 12px; }
.search .input { padding-left: 38px; }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); opacity: 0.5; }

/* 菜谱卡片 */
.recipe-card { display: flex; gap: 12px; background: var(--panel); border-radius: 12px; padding: 12px; margin-bottom: 10px; border: 1px solid var(--line); cursor: pointer; }
.recipe-cover { width: 76px; height: 76px; border-radius: 10px; object-fit: cover; flex-shrink: 0; background: #f4ede3; }
.recipe-cover-empty { display: flex; align-items: center; justify-content: center; font-size: 28px; }
.recipe-body { flex: 1; min-width: 0; }
.recipe-name { font-size: 16px; font-weight: 600; }
.recipe-desc { font-size: 13px; color: var(--ink-soft); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recipe-meta { font-size: 12px; color: var(--ink-soft); }
.recipe-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; }
.tag { display: inline-block; font-size: 11px; color: var(--brand); background: var(--brand-soft); padding: 2px 8px; border-radius: 4px; margin-right: 4px; margin-top: 4px; }
.scope-chip { font-size: 11px; color: var(--ink-soft); border: 1px solid var(--line); padding: 1px 6px; border-radius: 4px; margin-left: 6px; }
.pool-chip { font-size: 12px; color: var(--brand); border: 1px solid var(--brand); padding: 3px 10px; border-radius: 14px; cursor: pointer; }
.pool-chip-on { background: var(--brand); color: #fff; }

/* 点菜 */
.dish-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.dish-name { font-size: 16px; font-weight: 600; }
.dish-count { font-size: 15px; font-weight: 700; color: var(--brand); }
.dish-members { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.member-chip { font-size: 12px; background: var(--line); padding: 3px 10px; border-radius: 12px; }
.member-self { background: var(--brand-soft); color: var(--brand); }
.dish-notes { font-size: 12px; color: var(--ink-soft); }
.note { margin-top: 2px; }
.member-item { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); }
.member-item:last-child { border-bottom: 0; }
.member-item-main { display: flex; flex-direction: column; gap: 2px; }
.member-item-side { display: flex; align-items: center; gap: 10px; }
.meta { font-size: 12px; color: var(--ink-soft); }
.link-danger { background: transparent; border: 0; color: var(--danger); font-size: 13px; cursor: pointer; padding: 0; }

/* 详情 */
.detail-hero { margin: -16px -16px 14px; }
.detail-cover { width: 100%; height: 220px; object-fit: cover; background: #f4ede3; }
.detail-title { font-size: 22px; font-weight: 700; padding: 0 16px; margin-top: 12px; }
.detail-meta { font-size: 13px; color: var(--ink-soft); padding: 0 16px; margin-top: 4px; }
.section-title { font-size: 15px; font-weight: 700; margin: 18px 0 10px; }
.step-row { display: flex; gap: 10px; margin-bottom: 10px; }
.step-index { width: 22px; height: 22px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 13px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.step-img { width: 100%; max-width: 220px; border-radius: 8px; margin-top: 6px; }
.ing-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.comment-item { padding: 10px 0; border-bottom: 1px solid var(--line); }
.comment-head { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink-soft); margin-bottom: 4px; }

/* Toast / Modal */
.toast {
    position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%);
    max-width: 78%; padding: 10px 18px; border-radius: 8px; background: rgba(0,0,0,0.78); color: #fff;
    font-size: 14px; z-index: 99; text-align: center;
}
.toast-success { background: rgba(46,125,50,0.9); }
.modal-mask {
    position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 100;
    display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal { background: #fff; border-radius: 14px; padding: 20px; width: 100%; max-width: 340px; }
.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 10px; }
.modal-content { font-size: 14px; color: var(--ink-soft); line-height: 1.6; white-space: pre-wrap; }
.modal-input { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; margin-top: 12px; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions .btn { flex: 1; }

/* 编辑页 */
.edit-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.row-input { display: flex; gap: 8px; margin-bottom: 8px; }
.row-input .input { margin-bottom: 0; }
.row-input .input:first-child { flex: 2; }
.row-input .input:nth-child(2) { flex: 3; }
.step-edit { border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-bottom: 10px; }
.add-btn { color: var(--brand); background: transparent; border: 0; cursor: pointer; font-size: 13px; font-weight: 600; padding: 6px 0; }
.remove-btn { color: var(--danger); background: transparent; border: 0; cursor: pointer; font-size: 13px; }

/* 成员 */
.member-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); }
.member-row:last-child { border-bottom: 0; }
.role-badge { font-size: 11px; padding: 2px 8px; border-radius: 4px; background: var(--brand-soft); color: var(--brand); }
.role-badge-admin { background: #e8f0fb; color: #34507a; }

/* 我的 */
.profile-head { display: flex; align-items: center; gap: 14px; padding: 8px 0 18px; }
.avatar { width: 60px; height: 60px; border-radius: 50%; background: var(--brand-soft); display: flex; align-items: center; justify-content: center; font-size: 28px; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.stat-row { display: flex; text-align: center; margin: 12px 0; }
.stat { flex: 1; }
.stat-num { font-size: 20px; font-weight: 700; }
.stat-label { font-size: 12px; color: var(--ink-soft); }
.cell { display: flex; align-items: center; justify-content: space-between; padding: 14px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.cell:last-child { border-bottom: 0; }
.cell-title { font-size: 15px; }
.cell-sub { font-size: 12px; color: var(--ink-soft); }
.cell-arrow { color: var(--ink-soft); }

/* 审核 */
.review-item { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line); }
.review-info { display: flex; flex-direction: column; gap: 2px; }
.review-actions { display: flex; gap: 8px; }
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 6px; border: 0; cursor: pointer; font-weight: 600; }
.btn-ok { background: var(--ok); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }

/* 选择器 */
.picker-mask { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 90; display: flex; align-items: flex-end; }
.picker-sheet { background: #fff; border-radius: 16px 16px 0 0; padding: 16px; width: 100%; max-height: 70vh; overflow-y: auto; }
.picker-title { font-size: 16px; font-weight: 700; text-align: center; margin-bottom: 12px; }
.picker-item { display: flex; gap: 12px; align-items: center; padding: 10px; border-radius: 10px; cursor: pointer; }
.picker-item:active { background: var(--brand-soft); }
.picker-cover { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; }
.picker-cover-empty { display: flex; align-items: center; justify-content: center; background: #f4ede3; font-size: 22px; }
.picker-name { font-size: 15px; font-weight: 600; }
.picker-meta { font-size: 12px; color: var(--ink-soft); }
