:root {
    --accent: #ff4757;
    --text: #2f3542;
    --bg-gradient-start: #cfd9df;
    --bg-gradient-end: #e2ebf0;
}

/* 基础设置 */
body, html {
    margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-image: linear-gradient(to top, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    padding-top: env(safe-area-inset-top); touch-action: none;
}
#webgl { position: fixed; top: 0; left: 0; z-index: 1; outline: none; }

/* 导航 */
#top-bar {
    position: fixed; top: max(30px, env(safe-area-inset-top) + 20px); left: 30px; 
    z-index: 100; cursor: pointer; display: flex; align-items: center; gap: 10px;
    color: var(--text); transition: color 0.5s; padding: 10px;
}
.logo { font-weight: 800; letter-spacing: 2px; font-size: 1.2rem; }
.logo span { color: var(--accent); }
.hint-text { font-size: 0.9rem; opacity: 0; transform: translateX(-10px); transition: 0.3s ease; }
body.view-mode #top-bar { color: white; text-shadow: 0 2px 10px rgba(0,0,0,0.2); }
@media (hover: hover) { body.view-mode #top-bar:hover .hint-text { opacity: 1; transform: translateX(0); } }

/* Iframe */
#content-layer {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    z-index: 50; pointer-events: none; opacity: 0; transition: opacity 0.8s ease;
    background: rgba(255, 255, 255, 0.95);
}
body.iframe-mode #content-layer { pointer-events: auto; opacity: 1; }
#main-frame { width: 100%; height: 100%; border: none; }

/* 健康面板 (玻璃拟态) */
#health-panel {
    position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(0.9);
    width: 90%; max-width: 360px; max-height: 85vh; overflow-y: auto;
    background: rgba(255, 255, 255, 0.9); backdrop-filter: blur(25px); -webkit-backdrop-filter: blur(25px);
    border: 1px solid rgba(255,255,255,0.6); border-radius: 24px; padding: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15); z-index: 200;
    opacity: 0; pointer-events: none; transition: 0.5s cubic-bezier(0.19, 1, 0.22, 1);
}
#health-panel.active { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%) scale(1); }

.panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
.panel-header h3 { margin: 0; font-size: 1.1rem; color: #333; }
.settings-btn { font-size: 12px; background: #eee; border: none; padding: 4px 8px; border-radius: 4px; cursor: pointer; }
.close-btn { background: none; border: none; font-size: 24px; color: #999; cursor: pointer; }

/* 仪表盘 */
#nutrition-dashboard { background: #f8f9fa; border-radius: 12px; padding: 15px; margin-bottom: 15px; }
.progress-row { margin-bottom: 10px; }
.label { font-size: 12px; color: #666; margin-bottom: 4px; display: flex; justify-content: space-between; }
.bar-bg { width: 100%; height: 10px; background: #e0e0e0; border-radius: 5px; overflow: hidden; }
.bar-fill { height: 100%; background: #ff4757; transition: width 0.5s; }
.macro-stats { display: flex; gap: 10px; }
.macro-item { flex: 1; }
.bar-bg.mini { height: 6px; }
.mini-val { font-size: 10px; color: #999; text-align: right; margin-top: 2px; }
.p-color { background: #4a90e2; } .c-color { background: #f1c40f; } .f-color { background: #2ecc71; }

/* Tab 与 输入 */
.input-tabs { display: flex; gap: 8px; margin-bottom: 10px; }
.tab-btn { flex: 1; padding: 8px; border: none; background: #eee; border-radius: 8px; cursor: pointer; font-size: 12px; }
.tab-btn.active { background: var(--accent); color: white; font-weight: bold; }
.input-group { display: flex; gap: 10px; }
.input-group input { flex: 1; border: 1px solid #ddd; padding: 8px; border-radius: 8px; }
.add-btn { background: var(--accent); color: white; border: none; padding: 0 20px; border-radius: 8px; font-weight: bold; }

/* AI 输入区 */
.ai-input-wrapper { display: flex; gap: 8px; align-items: flex-end; }
#ai-input { flex: 1; border: 1px solid #eee; border-radius: 12px; padding: 10px; font-family: inherit; resize: none; background: #f9f9f9; }
#ai-input:focus { outline: 2px solid #a8c0ff; background: white; }
.ai-send-btn { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; border: none; border-radius: 12px; padding: 0 15px; height: 56px; font-weight: bold; box-shadow: 0 4px 10px rgba(118, 75, 162, 0.3); }

/* AI 结果气泡 */
#ai-result { margin-top: 10px; animation: popIn 0.3s ease; }
.ai-bubble { background: #fff; border: 1px solid #e0e0e0; border-radius: 12px; padding: 12px; box-shadow: 0 4px 15px rgba(0,0,0,0.05); }
#ai-reply-text { font-size: 13px; color: #555; margin-bottom: 8px; }
.ai-tags { display: flex; gap: 5px; flex-wrap: wrap; }
.tag { font-size: 11px; background: #f0f0f0; padding: 3px 6px; border-radius: 4px; color: #666; }
@keyframes popIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* 搜索列表 */
.search-box { position: relative; }
#food-search { width: 100%; padding: 10px; border: 1px solid #eee; border-radius: 8px; box-sizing: border-box; }
#search-results { position: absolute; top: 100%; width: 100%; background: white; border: 1px solid #eee; z-index: 10; display: none; max-height: 150px; overflow-y: auto; box-shadow: 0 5px 15px rgba(0,0,0,0.1); }
.search-item { padding: 10px; border-bottom: 1px solid #f5f5f5; cursor: pointer; font-size: 13px; }

/* 历史列表 */
.divider { border: 0; border-top: 1px dashed #ddd; margin: 15px 0; }
#record-list-container { max-height: 180px; overflow-y: auto; }
#record-list { list-style: none; padding: 0; margin: 0; }
.record-item { display: flex; justify-content: space-between; align-items: center; background: rgba(255,255,255,0.5); padding: 8px; border-radius: 8px; margin-bottom: 5px; font-size: 12px; }
.delete-btn { background: none; border: none; cursor: pointer; font-size: 14px; opacity: 0.5; }
.delete-btn:hover { opacity: 1; color: red; }

/* 设置层 */
#settings-layer { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(255,255,255,0.98); z-index: 20; padding: 20px; box-sizing: border-box; display: flex; flex-direction: column; gap: 10px; border-radius: 24px; }
.save-btn { background: var(--accent); color: white; border: none; padding: 10px; border-radius: 8px; cursor: pointer; }
.cancel-btn { border: none; padding: 10px; border-radius: 8px; cursor: pointer; }