/* ==================== 全局样式（移动端优先） ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #67c23a;
    --primary-dark: #529b2e;
    --primary-light: #e1f3d8;
    --success: #67c23a;
    --warning: #e6a23c;
    --danger: #f56c6c;
    --bg: #f5f7fa;
    --card-bg: #ffffff;
    --text: #303133;
    --text-secondary: #909399;
    --text-muted: #c0c4cc;
    --border: #e4e7ed;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
    --radius: 12px;
    --radius-sm: 8px;
    --touch-target: 44px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
    background: #f5f7fa;
    min-height: 100vh;
    color: var(--text);
    line-height: 1.5;
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
    padding-bottom: 80px; /* 底部导航留白 */
}

/* ==================== 底部导航栏 ==================== */
.tab-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    display: flex;
    border-top: 1px solid var(--border);
    z-index: 200;
    padding-bottom: env(safe-area-inset-bottom, 0);
    box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
}

.tab-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6px 4px;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 10px;
    transition: color 0.2s;
    min-height: var(--touch-target);
    gap: 2px;
}

.tab-item svg {
    width: 22px;
    height: 22px;
}

.tab-item.active {
    color: var(--primary);
}

.tab-badge {
    position: absolute;
    top: 4px;
    right: 50%;
    transform: translateX(18px);
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    min-width: 16px;
    height: 16px;
    line-height: 16px;
    text-align: center;
    border-radius: 8px;
    padding: 0 4px;
}

/* ==================== 顶部导航 ==================== */
.header {
    background: linear-gradient(135deg, #66bb6a 0%, #43a047 100%);
    color: #fff;
    padding: 8px 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 15px;
    font-weight: 700;
}

.logo svg {
    width: 22px;
    height: 22px;
}

/* ==================== 日期按钮行 ==================== */
.date-btn-row {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 10px;
}

.date-nav-btn {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    cursor: pointer;
    font-size: 16px;
    color: var(--text);
    min-height: var(--touch-target);
    min-width: var(--touch-target);
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.date-display-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    min-height: var(--touch-target);
}

.date-display-btn svg {
    flex-shrink: 0;
}

/* 模式选择器中的消耗标签 */
.mode-cost {
    font-size: 10px;
    background: #fef0f0;
    color: var(--danger);
    padding: 1px 5px;
    border-radius: 8px;
    font-weight: 600;
    margin-left: 2px;
}

.mode-btn.active .mode-cost {
    background: #fde2e2;
}

/* 免费识别徽章 */
.free-recog-badge {
    text-align: center;
    margin-top: 8px;
    padding: 8px 12px;
    background: linear-gradient(135deg, #fff9c4 0%, #fff3e0 100%);
    border: 1px solid #ffe082;
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: #e65100;
    animation: slideUp 0.3s ease;
}

.free-recog-badge strong {
    font-size: 16px;
    color: #f57c00;
}

/* 退出按钮小号 */
.btn-logout-sm {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 11px;
    flex-shrink: 0;
    min-height: 30px;
}

/* ==================== 主体布局 ==================== */
.main-container {
    margin: 12px 8px;
}

.content-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ==================== AI 助手悬浮按钮 ==================== */
.ai-fab {
    position: fixed;
    right: 16px;
    bottom: 100px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #43a047 0%, #66bb6a 100%);
    border: none;
    cursor: grab;
    z-index: 300;
    box-shadow: 0 4px 16px rgba(67, 160, 71, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    transition: transform 0.2s, box-shadow 0.2s;
    color: #fff;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}
.ai-fab:active {
    cursor: grabbing;
}
.ai-fab-pulse {
    animation: aiFabPulse 2s infinite;
}
@keyframes aiFabPulse {
    0%, 100% { box-shadow: 0 4px 16px rgba(67, 160, 71, 0.4); }
    50% { box-shadow: 0 4px 24px rgba(67, 160, 71, 0.7); }
}

/* ==================== AI 聊天面板 ==================== */
.ai-chat-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 400;
    display: none;
    align-items: flex-end;
}
.ai-chat-overlay.open {
    display: flex;
    animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.ai-chat-panel {
    width: 100%;
    max-width: 420px;
    height: 75vh;
    max-height: 600px;
    background: #fff;
    border-radius: 20px 20px 0 0;
    display: flex;
    flex-direction: column;
    margin: 0 auto;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
    animation: slideUp 0.3s ease;
}
@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.ai-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.ai-chat-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}
.ai-chat-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #43a047, #66bb6a);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}
.ai-chat-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}
.ai-chat-subtitle {
    font-size: 11px;
    color: var(--text-secondary);
}
.ai-chat-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--bg);
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ai-chat-clear {
    padding: 4px 10px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: none;
    color: var(--text-secondary);
    font-size: 11px;
    cursor: pointer;
    margin-right: 8px;
}

/* 思考模式切换按钮 */
.ai-chat-think-mode {
    padding: 4px 10px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: none;
    color: var(--primary);
    font-size: 11px;
    cursor: pointer;
    margin-right: 6px;
    transition: all 0.2s;
    white-space: nowrap;
}
.ai-chat-think-mode:hover {
    border-color: var(--primary);
    background: rgba(67, 160, 71, 0.08);
}
.ai-chat-think-mode.ai-chat-think-deep {
    color: #e65100;
    border-color: #e65100;
    background: rgba(230, 81, 0, 0.08);
}
.ai-chat-think-mode.ai-chat-think-deep:hover {
    background: rgba(230, 81, 0, 0.15);
}

.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.ai-chat-messages::-webkit-scrollbar {
    width: 4px;
}
.ai-chat-messages::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

.ai-msg {
    display: flex;
    gap: 8px;
    max-width: 85%;
    animation: msgIn 0.3s ease;
}
@keyframes msgIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.ai-msg-bot {
    align-self: flex-start;
}
.ai-msg-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}
.ai-msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}
.ai-msg-bot .ai-msg-avatar {
    background: #e8f5e9;
}
.ai-msg-user .ai-msg-avatar {
    background: var(--primary-light);
}
.ai-msg-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.6;
    word-break: break-word;
}
.ai-msg-bot .ai-msg-bubble {
    background: #f5f7fa;
    color: var(--text);
    border-radius: 4px 16px 16px 16px;
}
.ai-msg-user .ai-msg-bubble {
    background: var(--primary);
    color: #fff;
    border-radius: 16px 4px 16px 16px;
}

/* 快捷问题建议 */
.ai-quick-questions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 16px 12px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}
.ai-quick-btn {
    padding: 6px 12px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: #fff;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}
.ai-quick-btn:active {
    background: var(--primary-light);
    color: var(--primary-dark);
    border-color: var(--primary);
}
.ai-quick-btn-recipe {
    background: linear-gradient(135deg, #fff8e1, #fff3cd);
    border-color: #ffc107;
    color: #e65100;
    font-weight: 600;
}
.ai-quick-btn-recipe:active {
    background: linear-gradient(135deg, #ffecb3, #ffe082);
}

/* 减脂食谱卡片 */
.recipe-card {
    max-width: 320px;
    padding: 14px 16px !important;
}
.recipe-title {
    font-size: 16px;
    font-weight: 700;
    color: #e65100;
    margin-bottom: 8px;
    text-align: center;
}
.recipe-total {
    font-size: 13px;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 6px;
}
.recipe-total strong {
    color: #2e7d32;
    font-size: 16px;
}
.recipe-advice {
    font-size: 12px;
    color: #666;
    background: #f0f9ff;
    border-radius: 8px;
    padding: 6px 10px;
    margin-bottom: 12px;
}
.recipe-meals {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.recipe-meal {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px;
    background: #fafafa;
}
.recipe-meal-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}
.recipe-meal-type {
    font-weight: 700;
    font-size: 13px;
    color: var(--primary-dark);
    background: var(--primary-light);
    padding: 2px 8px;
    border-radius: 10px;
}
.recipe-meal-tips {
    font-size: 11px;
    color: #999;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.recipe-items {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.recipe-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    padding: 4px 0;
    border-bottom: 1px dashed #eee;
}
.recipe-item:last-child {
    border-bottom: none;
}
.recipe-item-name {
    flex: 1;
    color: var(--text);
    font-weight: 500;
}
.recipe-item-amount {
    color: #888;
    font-size: 12px;
}
.recipe-item-cal {
    color: #e65100;
    font-weight: 600;
    font-size: 12px;
    white-space: nowrap;
}
.recipe-disclaimer {
    font-size: 10px;
    color: #bbb;
    text-align: center;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid #eee;
}

/* 输入区域 */
.ai-chat-input-wrap {
    display: flex;
    gap: 8px;
    padding: 10px 16px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    padding-bottom: max(10px, env(safe-area-inset-bottom, 0));
}
.ai-chat-input {
    flex: 1;
    padding: 10px 14px;
    border-radius: 20px;
    border: 1px solid var(--border);
    font-size: 14px;
    outline: none;
    background: var(--bg);
    color: var(--text);
    min-height: 40px;
    transition: border-color 0.2s;
}
.ai-chat-input:focus {
    border-color: var(--primary);
    background: #fff;
}
.ai-chat-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--primary);
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.ai-chat-send:active {
    background: var(--primary-dark);
}
.ai-chat-send:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
}

/* 打字动画 */
.ai-typing {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}
.ai-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: typingDot 1.4s infinite;
}
.ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingDot {
    0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
    30% { opacity: 1; transform: scale(1); }
}

/* ==================== AI 角色设置弹窗 ==================== */
.persona-modal {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}
.persona-modal-bg {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.4);
}
.persona-modal-card {
    position: relative;
    width: 100%;
    max-width: 420px;
    max-height: 75vh;
    background: #fff;
    border-radius: 20px 20px 0 0;
    padding: 20px 20px 30px;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}
.persona-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.persona-modal-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}
.persona-modal-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--bg);
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.persona-modal-current {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: linear-gradient(135deg, #e8f5e9, #c8e6c9);
    border-radius: 12px;
    margin-bottom: 16px;
}
.pmc-icon {
    font-size: 36px;
}
.pmc-text {
    font-size: 14px;
    color: var(--text);
}
.pmc-text strong {
    color: var(--primary-dark);
}
.persona-modal-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}
.persona-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.persona-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 12px;
    border: 2px solid var(--border);
    border-radius: 14px;
    background: #fff;
    cursor: pointer;
    transition: all 0.2s;
}
.persona-option:active {
    transform: scale(0.97);
}
.persona-option.active {
    border-color: var(--primary);
    background: rgba(67, 160, 71, 0.06);
}
.persona-option-icon {
    font-size: 32px;
    flex-shrink: 0;
}
.persona-option-name {
    font-size: 15px;
    font-weight: 500;
    color: var(--text);
}
.persona-option.active .persona-option-name {
    color: var(--primary);
}

