/* =============================================
   NutricIA - CSS Variables
   ============================================= */
:root {
    --primary: #2d8659;
    --primary-dark: #236b47;
    --primary-light: #e8f5ee;
    --primary-hover: #34996a;
    --bg: #f5f5f0;
    --bg-card: #ffffff;
    --bg-secondary: #f0f0eb;
    --text: #1a1a1a;
    --text-light: #666;
    --text-muted: #999;
    --border: #e0e0d8;
    --border-light: #eeeeea;
    --radius: 14px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
    --success: #27ae60;
    --danger: #e74c3c;
    --danger-light: #fdf0ee;
    --warning: #f39c12;
    --chat-user: #2d8659;
    --chat-bot: #c8e6c9;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --header-height: 52px;
    --bottom-nav-height: 60px;
}

/* =============================================
   Global Reset & Base
   ============================================= */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    height: 100%;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
    height: 100%;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#app {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.screen {
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

input, select, textarea, button {
    font-family: inherit;
    font-size: inherit;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text);
    outline: none;
    transition: border-color 0.2s;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
}

textarea {
    resize: vertical;
    min-height: 60px;
}

/* =============================================
   Buttons
   ============================================= */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    white-space: nowrap;
}

.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:active { transform: scale(0.97); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    background: var(--bg-secondary);
    color: var(--text);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-secondary:hover { background: var(--border); }

.btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    background: var(--danger);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-danger:hover { background: #c0392b; }

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
}

.text-muted {
    color: var(--text-muted);
    font-size: 14px;
    text-align: center;
    padding: 16px;
}

/* =============================================
   Auth Screens (Login / Register)
   ============================================= */
#screen-login, #screen-register {
    background: linear-gradient(135deg, #e8f5ee 0%, #f5f5f0 50%, #fff 100%);
}

.auth-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 32px 24px;
    max-width: 380px;
    margin: 0 auto;
    width: 100%;
}

.auth-logo {
    margin-bottom: 8px;
    animation: bounceIn 0.6s ease-out;
}

.auth-logo img {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
}

.auth-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
}

.auth-subtitle {
    color: var(--text-light);
    margin-bottom: 32px;
    font-size: 15px;
}

.auth-form {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.auth-form .btn-primary {
    margin-top: 8px;
    width: 100%;
}

.auth-error {
    color: var(--danger);
    font-size: 14px;
    text-align: center;
    min-height: 20px;
    margin-top: 8px;
}

.auth-switch {
    margin-top: 24px;
    color: var(--text-light);
    font-size: 14px;
}

.auth-switch a {
    font-weight: 600;
}

/* =============================================
   Onboarding Carousel
   ============================================= */
#screen-onboarding {
    background: linear-gradient(135deg, #e8f5ee 0%, #f5f5f0 100%);
}

.onboarding-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0 24px;
    max-width: 480px;
    margin: 0 auto;
    width: 100%;
    overflow-y: auto;
}

.carousel {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.carousel-slide {
    display: none;
    text-align: center;
    padding: 24px 0;
    width: 100%;
    animation: fadeIn 0.3s ease;
}

.carousel-slide.active {
    display: block;
}

.slide-icon {
    font-size: 56px;
    margin-bottom: 16px;
}

.carousel-slide h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text);
}

.carousel-slide p {
    color: var(--text-light);
    margin-bottom: 24px;
    font-size: 15px;
}

.slide-input {
    text-align: left;
    margin-bottom: 16px;
}

.slide-input label {
    display: block;
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 6px;
    color: var(--text);
}

.option-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-top: 8px;
}

.option-grid.small {
    gap: 6px;
}

.option-btn {
    padding: 10px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.option-btn:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.option-btn.selected {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
}

.option-btn.small {
    padding: 6px 12px;
    font-size: 13px;
    border-radius: var(--radius-sm);
}

.onb-skip-link {
    display: inline-block;
    margin-top: 16px;
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    font-size: 14px;
    text-decoration: underline;
}

.onb-skip-link:hover {
    color: var(--primary);
}

.carousel-nav {
    padding: 20px 0 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.carousel-dots {
    display: flex;
    gap: 8px;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border);
    transition: all 0.3s;
}

.dot.active {
    background: var(--primary);
    width: 24px;
    border-radius: 4px;
}

.carousel-nav .btn-primary {
    width: 100%;
    max-width: 300px;
}

/* =============================================
   App Header
   ============================================= */
.app-header {
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 16px;
    padding-top: calc(10px + env(safe-area-inset-top, 0px));
    flex-shrink: 0;
    z-index: 100;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-icon {
    background: transparent;
    border: none;
    font-size: 22px;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 8px;
    line-height: 1;
    transition: background 0.2s;
}

.btn-icon:hover {
    background: rgba(255,255,255,0.2);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: #fff;
}

.header-brand:hover {
    text-decoration: none;
}

.header-logo {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.header-title {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
}

/* =============================================
   Bottom Navigation
   ============================================= */
.bottom-nav {
    display: flex;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding-bottom: 2px;
    flex-shrink: 0;
    z-index: 100;
}

.bottom-tab-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--text-light);
    transition: background .2s, color .2s;
    -webkit-tap-highlight-color: transparent;
    padding: 7px 4px 3px;
    margin: 3px 2px 0;
    border-radius: 8px;
}

.bottom-tab-btn.active {
    background: rgba(45, 134, 89, 0.1);
    color: var(--primary);
}

.bottom-tab-icon {
    font-size: 20px;
    line-height: 1;
}

.bottom-tab-label {
    font-size: 11px;
    font-weight: 500;
}

/* =============================================
   Tab Content
   ============================================= */
.tab-content {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.tab-pane {
    display: none;
    position: absolute;
    inset: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.tab-pane.active {
    display: flex;
    flex-direction: column;
}

/* =============================================
   Chat Tab
   ============================================= */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    -webkit-overflow-scrolling: touch;
}

.msg {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.5;
    word-wrap: break-word;
    position: relative;
    animation: slideUp 0.25s ease;
}

.msg p { margin: 0 0 8px; }
.msg p:last-child { margin-bottom: 0; }
.msg ul, .msg ol { margin: 4px 0 8px 18px; }
.msg code { background: rgba(0,0,0,0.06); padding: 2px 5px; border-radius: 4px; font-size: 13px; }
.msg pre { background: rgba(0,0,0,0.06); padding: 10px; border-radius: 8px; overflow-x: auto; margin: 8px 0; }
.msg pre code { background: none; padding: 0; }
.msg a { color: var(--primary-dark); text-decoration: underline; }

.msg-user {
    align-self: flex-end;
    background: var(--chat-user);
    color: #fff;
    border-bottom-right-radius: 6px;
}

.msg-bot {
    align-self: flex-start;
    background: var(--chat-bot);
    color: var(--text);
    border-bottom-left-radius: 6px;
}

.msg-time {
    display: block;
    font-size: 11px;
    margin-top: 6px;
    opacity: 0.6;
}

.msg-user .msg-time { text-align: right; }

.chat-input-area {
    flex-shrink: 0;
    border-top: 1px solid var(--border);
    background: var(--bg-card);
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 4px 8px;
    align-items: center;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
    animation: typingDot 1.4s infinite both;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

.chat-form {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.chat-form textarea {
    flex: 1;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: 20px;
    resize: none;
    max-height: 112px;
    line-height: 1.4;
    font-size: 15px;
    min-height: unset;
}

.chat-form textarea:focus {
    border-color: var(--primary);
}

.btn-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
}

.btn-send:hover { background: var(--primary-hover); }

/* =============================================
   Weight Tab
   ============================================= */
.weight-section {
    padding: 20px 16px;
}

.section-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 12px;
}

.weight-chart-wrap {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    height: 240px;
    position: relative;
}

.goal-info {
    background: var(--primary-light);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-bottom: 16px;
}

.goal-text {
    font-weight: 600;
    font-size: 15px;
    color: var(--primary-dark);
}

.goal-hint {
    font-size: 13px;
    color: var(--text-light);
    margin-top: 2px;
}

.weight-actions {
    margin-bottom: 12px;
}

.weight-prompt {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}

.weight-question {
    font-weight: 600;
    margin-bottom: 10px;
    font-size: 15px;
}

.weight-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.weight-form input[type="number"] {
    flex: 1;
    max-width: 120px;
    font-size: 16px;
    padding: 10px 12px;
}

.weight-form input[type="date"] {
    flex: 1;
}

.weight-goal-actions {
    margin-bottom: 16px;
    text-align: center;
}

.weight-history {
    margin-top: 8px;
}

.weight-record {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.weight-record-date {
    flex: 1;
    font-size: 14px;
    color: var(--text-light);
}

.weight-record-value {
    font-weight: 600;
    font-size: 15px;
    margin-right: 12px;
}

.weight-record-delete {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.weight-record-delete:hover { opacity: 1; }

/* =============================================
   Meals Tab
   ============================================= */
.meals-section {
    padding: 20px 16px;
}

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

.meals-search {
    margin-bottom: 16px;
}

.meals-search-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 10px;
}

.meals-search-row input {
    flex: 1;
    min-width: 0;
    margin-bottom: 0;
}

.meals-search input {
    margin-bottom: 0;
}

.meals-filters {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.filter-group label {
    font-size: 13px;
    color: var(--text-light);
    font-weight: 500;
}

.filter-group select {
    width: auto;
    padding: 6px 10px;
    font-size: 13px;
    border-radius: var(--radius-xs);
}

.filter-fav-btn {
    padding: 6px 10px;
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-xs);
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
}

.filter-fav-btn.active {
    background: #fff8e1;
    border-color: #f39c12;
}

.filter-like-btns {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.filter-like-btn {
    background: var(--bg-input);
    border: 1.5px solid var(--border);
    border-radius: 20px;
    padding: 4px 10px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-like-btn.selected {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.cal-filters {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin: 8px 0;
}

.meal-card-last-used {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.meals-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.meal-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 14px 16px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}

.meal-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.meal-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.meal-card-name {
    font-weight: 600;
    font-size: 15px;
    flex: 1;
    margin-right: 8px;
}

.meal-card-fav {
    font-size: 18px;
    cursor: pointer;
    opacity: 0.3;
    transition: opacity 0.2s;
}

.meal-card-fav.active {
    opacity: 1;
}

.meal-card-fav:hover { opacity: 0.8; }

.meal-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 6px;
}

.meal-type-tag {
    display: inline-block;
    padding: 3px 8px;
    background: var(--primary-light);
    color: var(--primary-dark);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.meal-like-tag {
    display: inline-block;
    padding: 3px 8px;
    font-size: 12px;
}

.meal-card-ingredients {
    font-size: 13px;
    color: var(--text-light);
    line-height: 1.4;
}

.meals-empty {
    text-align: center;
    padding: 40px 16px;
    color: var(--text-light);
}

.meals-empty p:first-child {
    font-size: 16px;
    margin-bottom: 4px;
}

.meals-empty p:last-child {
    font-size: 24px;
}

/* =============================================
   Calendar Tab
   ============================================= */
.calendar-section {
    padding: 20px 16px;
    overflow-y: auto;
    flex: 1;
}

.calendar-days {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cal-day-box {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 14px 16px;
    box-shadow: var(--shadow);
}

.cal-day-today {
    border: 2px solid var(--primary);
}

.cal-day-past {
    opacity: 0.6;
}

.cal-day-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.cal-day-name {
    font-weight: 600;
    font-size: 15px;
    text-transform: capitalize;
}

.cal-day-date {
    font-size: 13px;
    color: var(--text-light);
}

.cal-day-tag {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
}

.cal-day-tag-today {
    background: var(--primary);
    color: #fff;
}

.cal-day-tag-tomorrow {
    background: var(--primary-light);
    color: var(--primary-dark);
}

.cal-day-header-spacer {
    flex: 1;
}

.cal-day-note-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 2px 4px;
    border-radius: var(--radius-sm);
    line-height: 1;
    opacity: 0.6;
    transition: opacity 0.15s;
}

.cal-day-note-btn:hover {
    opacity: 1;
    background: var(--bg-secondary);
}

.cal-day-note {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    font-size: 13px;
    color: var(--text-light);
    font-style: italic;
    padding: 6px 10px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.cal-day-note-with-margin {
    margin-bottom: 8px;
}

.cal-day-note-icon {
    font-size: 14px;
    flex-shrink: 0;
    margin-top: 1px;
}

.cal-slots {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cal-slot {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
}

.cal-slot-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-light);
    min-width: 90px;
    white-space: nowrap;
}

.cal-slot-items {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.cal-meal-chip {
    display: inline-block;
    padding: 4px 10px;
    background: var(--primary-light);
    color: var(--primary-dark);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.cal-meal-chip:hover {
    background: var(--primary);
    color: #fff;
}

.cal-slot-add {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1.5px dashed var(--border);
    background: none;
    color: var(--text-light);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
}

.cal-slot-add:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

.cal-slot-empty {
    cursor: pointer;
    transition: background 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.cal-slot-empty:hover {
    background: var(--primary-light);
}

.cal-slot-empty:active {
    background: var(--primary-light);
    opacity: 0.85;
}

/* =============================================
   Settings Tab
   ============================================= */
.settings-section {
    padding: 20px 16px;
}

.settings-section h2 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 20px;
}

.settings-group {
    margin-bottom: 24px;
}

.settings-group h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
}

.settings-grid {
    justify-content: flex-start;
}

.setting-item {
    margin-bottom: 10px;
}

.setting-item input {
    max-width: 300px;
}

.settings-save-msg {
    margin-top: 12px;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    min-height: 20px;
}

.settings-error {
    color: var(--danger);
    font-size: 14px;
    margin: 8px 0;
    min-height: 20px;
}

.settings-section .btn-primary {
    width: 100%;
    max-width: 300px;
}

.settings-section .btn-danger {
    width: 100%;
}

/* =============================================
   Modals
   ============================================= */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

.modal-card {
    background: var(--bg-card);
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 24px 20px;
    width: 100%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
    padding-bottom: calc(24px + var(--safe-bottom));
}

.modal-card-large {
    max-height: 90vh;
}

.modal-card h3 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 16px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

.form-field {
    margin-bottom: 14px;
}

.form-field label {
    display: block;
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 6px;
}

/* =============================================
   Meal Form Modal
   ============================================= */
.meal-form {
    display: flex;
    flex-direction: column;
}

.like-selector {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.like-btn {
    padding: 6px 14px;
    border: 2px solid var(--border);
    border-radius: 20px;
    background: var(--bg-card);
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.like-btn:hover {
    border-color: var(--primary);
}

.like-btn.selected {
    border-color: var(--primary);
    background: var(--primary-light);
    font-weight: 600;
}

/* =============================================
   Meal Detail Modal
   ============================================= */
.meal-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.meal-detail-header h3 {
    flex: 1;
    margin-right: 12px;
}

.fav-btn {
    font-size: 24px;
    background: none;
    border: none;
    cursor: pointer;
    opacity: 0.3;
    transition: opacity 0.2s, transform 0.2s;
}

.fav-btn.active {
    opacity: 1;
}

.fav-btn:hover {
    transform: scale(1.15);
}

.meal-detail-content {
    margin-bottom: 8px;
}

.meal-detail-content h4 {
    font-size: 14px;
    font-weight: 600;
    margin: 12px 0 6px;
    color: var(--primary-dark);
}

.meal-detail-content p {
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
}

.meal-detail-content a {
    word-break: break-all;
}

.meal-ingredients-list {
    margin: 0 0 8px 18px;
    padding: 0;
    font-size: 14px;
    line-height: 1.7;
    color: var(--text);
}

.recipe-steps {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.recipe-step {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.recipe-step:last-child {
    border-bottom: none;
}

.recipe-step p {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
}

.meal-detail-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.meal-utensils {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.meal-utensil-tag {
    font-size: 12px;
    padding: 3px 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-light);
}

.cal-entry-meta {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.cal-move-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-light);
    line-height: 1.4;
    transition: background 0.15s, color 0.15s;
}

.cal-move-btn:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* =============================================
   Calendar Add Modal
   ============================================= */
.cal-add-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 16px;
    border-bottom: 2px solid var(--border);
}

.cal-tab-btn {
    flex: 1;
    padding: 10px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-light);
    transition: all 0.2s;
}

.cal-tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.cal-tab-pane {
    animation: fadeIn 0.2s ease;
}

.cal-meals-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 300px;
    overflow-y: auto;
    margin-top: 10px;
}

.cal-meal-option {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.2s;
}

.cal-meal-option:hover {
    background: var(--primary-light);
}

.cal-meal-option-name {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
}

.cal-meal-option-like {
    margin-right: 6px;
    font-size: 14px;
}

.cal-meal-option-fav {
    font-size: 14px;
}

.cal-ia-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 16px 0;
}

.cal-ia-option {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
}

.cal-ia-option input[type="checkbox"] {
    width: auto;
}

/* =============================================
   Loading States
   ============================================= */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* =============================================
   Animations
   ============================================= */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(40px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes bounceIn {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.05); }
    70% { transform: scale(0.9); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes typingDot {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* =============================================
   Responsive: Tablet+
   ============================================= */
@media (min-width: 600px) {
    .modal-card {
        border-radius: var(--radius);
        margin: auto;
        max-width: 480px;
    }

    .modal-overlay {
        align-items: center;
    }

    .auth-container {
        max-width: 420px;
    }

    .chat-messages {
        padding: 24px;
    }

    .msg {
        max-width: 70%;
    }

    .weight-form {
        max-width: 500px;
    }

    .meals-filters {
        flex-wrap: nowrap;
    }

    .cal-day-box {
        padding: 16px 20px;
    }
}

@media (min-width: 768px) {
    :root {
        --bottom-nav-height: 64px;
    }

    .bottom-tab-icon { font-size: 22px; }
    .bottom-tab-label { font-size: 12px; }
}

/* =============================================
   Dark mode support (optional prefers-color-scheme)
   ============================================= */
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #1a1a1a;
        --bg-card: #2a2a2a;
        --bg-secondary: #222;
        --text: #f0f0f0;
        --text-light: #aaa;
        --text-muted: #888;
        --border: #3a3a3a;
        --border-light: #333;
        --chat-bot: #2a3a2e;
        --primary-light: #1a3a28;
        --shadow: 0 2px 12px rgba(0,0,0,0.3);
        --shadow-lg: 0 8px 32px rgba(0,0,0,0.4);
    }

    #screen-login, #screen-register {
        background: linear-gradient(135deg, #1a3a28 0%, #1a1a1a 100%);
    }

    #screen-onboarding {
        background: linear-gradient(135deg, #1a3a28 0%, #1a1a1a 100%);
    }

    .option-btn.selected {
        background: var(--primary);
        border-color: var(--primary);
        color: #fff;
    }

    .meal-type-tag {
        background: var(--primary-light);
        color: var(--primary);
    }

    .cal-meal-chip {
        background: var(--primary-light);
        color: #8fbc8f;
    }

    .cal-meal-chip:hover {
        background: var(--primary);
        color: #fff;
    }

    .like-btn.selected {
        background: var(--primary-light);
    }

    .msg-user {
        background: var(--primary-dark);
    }

    .weight-chart-wrap {
        background: var(--bg-card);
    }

    .cal-meal-option:hover {
        background: #1a3a28;
    }

    .filter-fav-btn.active {
        background: #3a3520;
        border-color: #f39c12;
    }
}

/* =============================================
   Scrollbar styling (webkit)
   ============================================= */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

/* =============================================
   Selection color
   ============================================= */
::selection {
    background: var(--primary);
    color: #fff;
}

/* =============================================
   Toast notification
   ============================================= */
#app-toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(30, 30, 30, 0.9);
    color: #fff;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 0.9rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
    z-index: 9999;
}
#app-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* =============================================
   PWA Install
   ============================================= */
.pwa-install-steps ol { margin: 12px 0; padding-left: 20px; }
.pwa-install-steps li { margin-bottom: 8px; font-size: 15px; line-height: 1.5; }
.pwa-note { font-size: 13px; color: var(--text-light); margin-top: 8px; }

.btn-pwa-login {
    margin-top: 20px;
    background: none;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 20px;
    font-size: 14px;
    color: var(--text-light);
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}
.btn-pwa-login:hover { border-color: var(--primary); color: var(--primary); }

.modal-fullscreen {
    position: fixed; inset: 0; z-index: 1000;
    background: var(--bg); display: flex; flex-direction: column;
}
.modal-fullscreen-inner {
    flex: 1; display: flex; flex-direction: column;
    padding: 16px; max-width: 600px; margin: 0 auto; width: 100%;
    overflow-y: auto;
}
.modal-fullscreen-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 16px; gap: 8px;
}
.modal-fullscreen-header h3 { font-size: 18px; font-weight: 700; flex: 1; }
.btn-modal-close {
    background: none; border: none; font-size: 20px;
    cursor: pointer; color: var(--text-light); padding: 4px;
    line-height: 1; flex-shrink: 0;
}
