:root {
    --bg: var(--tg-theme-bg-color, #1a1a2e);
    --text: var(--tg-theme-text-color, #e0e0e0);
    --hint: var(--tg-theme-hint-color, #8a8a9e);
    --link: var(--tg-theme-link-color, #5b9ef4);
    --btn: var(--tg-theme-button-color, #5b9ef4);
    --btn-text: var(--tg-theme-button-text-color, #ffffff);
    --secondary-bg: var(--tg-theme-secondary-bg-color, #232340);
    --card-bg: var(--tg-theme-secondary-bg-color, #232340);
    --border: rgba(255,255,255,0.08);
    --protein: #ef6c6c;
    --fat: #f0c75e;
    --carbs: #5bc0eb;
    --calories: #6ee76e;
    --danger: #ef4444;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* Tabs */
.tabs {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 0 4px;
}

.tab {
    flex: 1;
    padding: 12px 4px;
    background: none;
    border: none;
    color: var(--hint);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.tab.active {
    color: var(--btn);
    border-bottom-color: var(--btn);
}

/* Pages */
.page { display: none; padding: 12px; }
.page.active { display: block; }

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
}

.card h2 {
    font-size: 16px;
    margin-bottom: 12px;
    font-weight: 600;
}

.card h3 {
    font-size: 14px;
    margin-bottom: 8px;
    color: var(--hint);
    font-weight: 500;
}

/* Calorie ring */
.calories-ring-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 180px;
}

.ring-text {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.ring-value {
    font-size: 32px;
    font-weight: 700;
}

.ring-label {
    font-size: 13px;
    color: var(--hint);
}

/* Macros */
.macros-row {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.macro-card {
    flex: 1;
    background: var(--card-bg);
    border-radius: 12px;
    padding: 12px;
    text-align: center;
}

.macro-label {
    font-size: 11px;
    color: var(--hint);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.macro-value {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 6px;
}

.protein .macro-value { color: var(--protein); }
.fat .macro-value { color: var(--fat); }
.carbs .macro-value { color: var(--carbs); }

.macro-bar {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 4px;
}

.bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.5s ease;
    width: 0%;
}

.protein .bar-fill { background: var(--protein); }
.fat .bar-fill { background: var(--fat); }
.carbs .bar-fill { background: var(--carbs); }

.macro-goal {
    font-size: 11px;
    color: var(--hint);
}

/* Vitamins */
.vitamins-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.vitamin-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.vitamin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.vitamin-name {
    font-size: 13px;
    font-weight: 500;
}

.vitamin-value {
    font-size: 11px;
    color: var(--hint);
}

.vitamin-bar {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.vitamin-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.5s ease;
}

.vitamin-pct {
    font-size: 11px;
    color: var(--hint);
    text-align: right;
}

/* Meal list */
.meal-list { }

.meal-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.meal-item:last-child { border-bottom: none; }

.meal-info {
    flex: 1;
}

.meal-name {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 2px;
}

.meal-time {
    font-size: 12px;
    color: var(--hint);
}

.meal-time-tag {
    display: inline-block;
    background: rgba(91,158,244,0.15);
    color: var(--link);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    margin-right: 4px;
}

.meal-cal {
    font-size: 16px;
    font-weight: 600;
    white-space: nowrap;
    margin-left: 12px;
}

.meal-macros {
    font-size: 11px;
    color: var(--hint);
}

.meal-date-header {
    font-size: 13px;
    font-weight: 600;
    color: var(--hint);
    padding: 12px 0 6px;
    border-bottom: 1px solid var(--border);
}

.empty {
    text-align: center;
    color: var(--hint);
    padding: 24px;
    font-size: 14px;
}

/* Streak */
.streak-card {
    text-align: center;
    padding: 20px;
}

.streak-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.streak-fire {
    font-size: 28px;
}

.streak-count {
    font-size: 36px;
    font-weight: 800;
    color: var(--calories);
}

.streak-label {
    font-size: 14px;
    color: var(--hint);
}

.streak-record {
    font-size: 12px;
    color: var(--hint);
    margin-top: 4px;
}

/* Stats grid */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.stat-item {
    background: rgba(255,255,255,0.04);
    border-radius: 8px;
    padding: 10px;
    text-align: center;
}

.stat-value {
    font-size: 22px;
    font-weight: 700;
}

.stat-label {
    font-size: 11px;
    color: var(--hint);
    margin-top: 2px;
}

.stat-item.cal .stat-value { color: var(--calories); }
.stat-item.prot .stat-value { color: var(--protein); }
.stat-item.fat .stat-value { color: var(--fat); }
.stat-item.carbs .stat-value { color: var(--carbs); }

/* Delete button */
.meal-delete {
    background: none;
    border: none;
    color: var(--danger);
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    opacity: 0.6;
}
.meal-delete:hover { opacity: 1; }

/* Charts */
.chart-wrap { position: relative; width: 100%; }

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-thumb { background: var(--hint); border-radius: 2px; }
