* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #1a1b2e;
    --card: #232446;
    --accent: #6c5ce7;
    --accent-light: #a29bfe;
    --text: #e8e8f0;
    --text-muted: #9495b8;
    --green: #00b894;
    --green-bg: rgba(0, 184, 148, 0.15);
    --red: #e17055;
    --yellow: #fdcb6e;
    --radius: 12px;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    padding-bottom: 80px;
}

.header {
    background: linear-gradient(135deg, var(--card), #2d2366);
    padding: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.header h1 {
    font-size: 20px;
    font-weight: 700;
}

.btn-icon {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
}

.calorie-bar {
    background: var(--bg);
    border-radius: 8px;
    height: 32px;
    position: relative;
    overflow: hidden;
    margin-bottom: 8px;
}

.calorie-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--green), var(--accent));
    border-radius: 8px;
    transition: width 0.3s ease;
    width: 0%;
}

.calorie-bar-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.macro-row {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: var(--text-muted);
}

.macro-item {
    font-weight: 500;
}

.content {
    padding: 16px;
    max-width: 600px;
    margin: 0 auto;
}

.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tab {
    flex: 1;
    padding: 10px 12px;
    background: var(--card);
    border: none;
    border-radius: var(--radius);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.tab.active {
    background: var(--accent);
    color: white;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* Quick Foods */
.quick-foods {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 12px;
    margin-bottom: 12px;
    -webkit-overflow-scrolling: touch;
}

.quick-food-btn {
    padding: 8px 14px;
    background: var(--card);
    border: 1px solid var(--accent-light);
    border-radius: 20px;
    color: var(--text);
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.quick-food-btn:active {
    background: var(--accent);
    transform: scale(0.95);
}

/* Food Entries */
.entries { margin-bottom: 16px; }

.entry-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.entry-info {
    flex: 1;
}

.entry-name {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
}

.entry-meta {
    font-size: 11px;
    color: var(--text-muted);
}

.entry-calories {
    font-weight: 700;
    font-size: 16px;
    color: var(--accent-light);
    text-align: right;
}

.entry-macros {
    font-size: 10px;
    color: var(--text-muted);
}

.entry-delete {
    background: none;
    border: none;
    color: var(--red);
    font-size: 18px;
    cursor: pointer;
    padding: 0 0 0 12px;
}

/* Buttons */
.btn-primary {
    width: 100%;
    padding: 14px;
    background: var(--accent);
    border: none;
    border-radius: var(--radius);
    color: white;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary:active {
    transform: scale(0.98);
    opacity: 0.9;
}

.btn-secondary {
    width: 100%;
    padding: 14px;
    background: var(--card);
    border: 1px solid var(--text-muted);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: flex-end;
    z-index: 200;
}

.modal.hidden { display: none; }

.modal-content {
    background: var(--card);
    border-radius: 20px 20px 0 0;
    padding: 24px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content h2 {
    margin-bottom: 16px;
    font-size: 18px;
}

.modal-content input,
.modal-content select {
    width: 100%;
    padding: 12px;
    margin-bottom: 10px;
    background: var(--bg);
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
}

.modal-content input:focus,
.modal-content select:focus {
    outline: none;
    border-color: var(--accent);
}

.macro-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
}

/* Search Results */
.search-results {
    margin-bottom: 12px;
}

.search-result-item {
    padding: 10px;
    background: var(--bg);
    border-radius: 8px;
    margin-bottom: 6px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
}

.search-result-item:active {
    background: var(--accent);
}

/* Weight Tab */
.weight-form {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.weight-form input {
    flex: 1;
    padding: 12px;
    background: var(--card);
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--text);
    font-size: 16px;
}

.weight-chart {
    height: 150px;
    background: var(--card);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
    display: flex;
    align-items: flex-end;
    gap: 4px;
}

.weight-bar {
    flex: 1;
    background: linear-gradient(to top, var(--accent), var(--accent-light));
    border-radius: 4px 4px 0 0;
    min-height: 4px;
    transition: height 0.3s;
}

.measurements-section {
    background: var(--card);
    border-radius: var(--radius);
    padding: 16px;
    margin-top: 16px;
}

.measurements-section select,
.measurements-section input {
    width: 100%;
    padding: 10px;
    margin-bottom: 8px;
    background: var(--bg);
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--text);
}

.measurement-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--bg);
    font-size: 13px;
}

/* Achievements */
.achievements-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.achievement-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
    border: 1px solid transparent;
}

.achievement-card.unlocked {
    border-color: var(--accent-light);
    background: linear-gradient(135deg, var(--card), rgba(108,92,231,0.15));
}

.achievement-card.locked {
    opacity: 0.4;
}

.achievement-icon {
    font-size: 28px;
    margin-bottom: 8px;
}

.achievement-title {
    font-size: 13px;
    font-weight: 600;
}

.achievement-desc {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Leaderboard */
.leaderboard-item {
    background: var(--card);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.leaderboard-rank {
    font-size: 18px;
    font-weight: 800;
    color: var(--text-muted);
    width: 30px;
}

.leaderboard-item:nth-child(1) .leaderboard-rank { color: gold; }
.leaderboard-item:nth-child(2) .leaderboard-rank { color: silver; }
.leaderboard-item:nth-child(3) .leaderboard-rank { color: #cd7f32; }

.leaderboard-name {
    flex: 1;
    font-weight: 600;
    font-size: 14px;
}

.leaderboard-stats {
    text-align: right;
    font-size: 11px;
    color: var(--text-muted);
}

.leaderboard-streak {
    font-size: 16px;
    font-weight: 700;
    color: var(--yellow);
}

/* Weight History */
.weight-entry {
    background: var(--card);
    border-radius: var(--radius);
    padding: 10px 14px;
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
    font-size: 13px;
}

/* Animations */
@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.entry-card, .achievement-card, .leaderboard-item {
    animation: slideUp 0.2s ease;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 4px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 2px;
}
