@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

:root {
    --bg: #0a0a0c;
    --bg-elevated: #14141a;
    --card: #1a1a22;
    --card-hover: #22222c;
    --border: rgba(255, 255, 255, 0.06);
    --border-strong: rgba(255, 255, 255, 0.12);

    --text: #ffffff;
    --text-muted: #a1a1aa;
    --text-dim: #71717a;

    --primary: #c7ff5a;
    --primary-glow: rgba(199, 255, 90, 0.25);
    --primary-text: #0a0a0c;
    --gradient-primary: linear-gradient(135deg, #84ff00 0%, #c7ff5a 100%);
    --gradient-warm: linear-gradient(135deg, #ff8a00 0%, #ffd700 100%);
    --gradient-cool: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    --gradient-danger: linear-gradient(135deg, #f43f5e 0%, #fb923c 100%);

    --danger: #f43f5e;
    --warning: #fbbf24;
    --info: #60a5fa;

    --radius-lg: 24px;
    --radius: 18px;
    --radius-sm: 12px;
    --radius-pill: 999px;

    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 40px var(--primary-glow);
}

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

html, body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    letter-spacing: -0.01em;
}

body {
    background:
        radial-gradient(circle at 20% 0%, rgba(199, 255, 90, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 80% 100%, rgba(124, 58, 237, 0.06) 0%, transparent 50%),
        var(--bg);
    background-attachment: fixed;
}

button { font-family: inherit; }
input, textarea { font-family: inherit; color: var(--text); }

.app {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100dvh;
    padding-bottom: 100px;
    position: relative;
}

/* ===== Auth Screen ===== */
.auth-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    padding: 32px;
}

.auth-logo {
    font-size: 64px;
    margin-bottom: 16px;
    filter: drop-shadow(0 0 30px var(--primary-glow));
}

.auth-title {
    font-size: 36px;
    font-weight: 800;
    letter-spacing: -0.03em;
    margin-bottom: 6px;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

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

.auth-form {
    width: 100%;
    max-width: 340px;
}

.auth-form input {
    width: 100%;
    padding: 16px 20px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    margin-bottom: 12px;
    outline: none;
    transition: all 0.2s;
}

.auth-form input:focus {
    border-color: var(--primary);
    background: var(--card-hover);
}

.auth-form input::placeholder { color: var(--text-dim); }

/* ===== Buttons ===== */
.btn {
    width: 100%;
    padding: 16px 24px;
    border: none;
    border-radius: var(--radius-pill);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.2s, opacity 0.2s;
    letter-spacing: -0.01em;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
    background: var(--gradient-primary);
    color: var(--primary-text);
    box-shadow: 0 4px 16px var(--primary-glow);
}

.btn-primary:hover:not(:disabled) { box-shadow: 0 6px 24px var(--primary-glow); }

.btn-secondary {
    background: transparent;
    color: var(--primary);
    margin-top: 8px;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-strong);
    color: var(--text);
}

.btn-danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid rgba(244, 63, 94, 0.3);
}

.auth-error {
    color: var(--danger);
    font-size: 13px;
    margin-bottom: 12px;
    text-align: center;
}

/* ===== Header ===== */
.header {
    padding: 24px 24px 8px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.header h1 {
    font-size: 32px;
    font-weight: 800;
    letter-spacing: -0.03em;
}

.header-date {
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.streak-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--gradient-warm);
    color: #1a0a00;
    padding: 8px 14px;
    border-radius: var(--radius-pill);
    font-weight: 800;
    font-size: 13px;
    box-shadow: 0 4px 16px rgba(255, 138, 0, 0.3);
}

/* ===== Date Nav ===== */
.date-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 8px 24px 12px;
}

.date-nav button {
    background: var(--card);
    border: 1px solid var(--border);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 14px;
    cursor: pointer;
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.date-nav button:hover { background: var(--card-hover); }

.date-nav .date-display {
    font-size: 14px;
    font-weight: 600;
    min-width: 140px;
    text-align: center;
    color: var(--text-muted);
}

/* ===== Calorie Ring ===== */
.calorie-ring-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 24px 24px;
}

.calorie-ring {
    position: relative;
    width: 220px;
    height: 220px;
    filter: drop-shadow(0 0 40px var(--primary-glow));
}

.calorie-ring svg {
    transform: rotate(-90deg);
    width: 220px;
    height: 220px;
}

.calorie-ring circle {
    fill: none;
    stroke-width: 14;
    stroke-linecap: round;
}

.ring-bg { stroke: rgba(255, 255, 255, 0.05); }

.ring-fill {
    stroke: url(#ring-gradient);
    transition: stroke-dashoffset 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.ring-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.ring-calories {
    font-size: 48px;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.04em;
    font-feature-settings: 'tnum';
}

.ring-label {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 6px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 600;
}

.ring-target {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 8px;
    font-weight: 500;
}

.ring-target.over { color: var(--danger); }

/* ===== Macro Bar ===== */
.macro-bar {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 0 24px 16px;
}

.macro-item {
    flex: 1;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 12px;
    text-align: center;
}

.macro-value {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.02em;
    font-feature-settings: 'tnum';
}

.macro-label {
    font-size: 11px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
    margin-top: 4px;
}

/* ===== Section Title ===== */
.section-title {
    font-size: 11px;
    font-weight: 700;
    padding: 20px 24px 10px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

/* ===== Swipe Container ===== */
.swipe-container {
    position: relative;
    margin: 0 16px 8px;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--card);
}

.swipe-action {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 88px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    cursor: pointer;
    z-index: 0;
    user-select: none;
    -webkit-user-select: none;
}

.swipe-action-edit {
    right: 0;
    background: var(--gradient-primary);
    color: var(--primary-text);
}

.swipe-action-delete {
    left: 0;
    background: var(--gradient-danger);
    color: white;
}

.swipe-container.show-edit .meal-card {
    transform: translateX(-88px);
}

.swipe-container.show-delete .meal-card {
    transform: translateX(88px);
}

.swipe-container .meal-card {
    margin: 0;
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 1;
}

.swipe-container.swiping .meal-card {
    transition: none;
}

/* ===== Meal Cards ===== */
.meal-card {
    background: var(--card);
    padding: 16px 18px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.meal-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--gradient-primary);
}

.meal-card.fruehstueck::before { background: var(--gradient-warm); }
.meal-card.mittag::before { background: linear-gradient(135deg, #f97316 0%, #fb923c 100%); }
.meal-card.abendessen::before { background: var(--gradient-cool); }
.meal-card.snack::before { background: linear-gradient(135deg, #a855f7 0%, #ec4899 100%); }

.meal-card:hover { background: var(--card-hover); }
.meal-card:active { transform: scale(0.98); }

.meal-info { flex: 1; min-width: 0; }

.meal-info h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.meal-meta {
    font-size: 12px;
    color: var(--text-dim);
    font-feature-settings: 'tnum';
}

.meal-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    margin-left: 12px;
}

.meal-calories {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.02em;
    font-feature-settings: 'tnum';
}

.health-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 700;
    font-feature-settings: 'tnum';
}

.health-good { background: rgba(199, 255, 90, 0.15); color: var(--primary); }
.health-mid { background: rgba(251, 191, 36, 0.15); color: var(--warning); }
.health-bad { background: rgba(244, 63, 94, 0.15); color: var(--danger); }

.delete-btn {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 14px;
    padding: 2px 6px;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.delete-btn:hover { opacity: 1; color: var(--danger); }

@media (hover: none) {
    .delete-btn { display: none; }
}

/* ===== Exercise Card ===== */
.exercise-card {
    background: var(--card);
    margin: 0 16px 8px;
    padding: 14px 18px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.exercise-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(135deg, #06b6d4 0%, #3b82f6 100%);
}

.exercise-burned {
    font-size: 18px;
    font-weight: 800;
    color: #06b6d4;
    letter-spacing: -0.02em;
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 40px 24px;
    color: var(--text-dim);
}

.empty-state .icon {
    font-size: 56px;
    margin-bottom: 12px;
    opacity: 0.3;
}

.empty-state p {
    font-size: 14px;
    color: var(--text-muted);
}

/* ===== Add Exercise (subtle) ===== */
.add-exercise-link {
    display: block;
    margin: 24px auto 0;
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    padding: 10px 18px;
    border-radius: var(--radius-pill);
    transition: all 0.2s;
}

.add-exercise-link:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: var(--card-hover);
}

/* ===== Bottom Nav ===== */
.bottom-nav {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 32px);
    max-width: 400px;
    background: rgba(26, 26, 34, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    display: flex;
    justify-content: space-around;
    padding: 8px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    z-index: 100;
    box-shadow: var(--shadow);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 8px 4px;
    font-size: 10px;
    font-weight: 600;
    border-radius: var(--radius-pill);
    transition: all 0.2s;
    letter-spacing: 0.02em;
}

.nav-item.active {
    color: var(--primary-text);
    background: var(--gradient-primary);
}

.nav-item .nav-icon {
    font-size: 18px;
    transition: transform 0.2s;
}

.nav-item.active .nav-icon { transform: scale(1.1); }

/* ===== Input Page ===== */
.input-page { padding: 16px 24px 24px; }

.input-modes {
    display: flex;
    gap: 10px;
    margin-bottom: 24px;
}

.input-mode-btn {
    flex: 1;
    padding: 18px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    transition: all 0.2s;
}

.input-mode-btn.active {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(199, 255, 90, 0.06);
    box-shadow: 0 0 20px rgba(199, 255, 90, 0.1);
}

.input-mode-btn .mode-icon { font-size: 24px; }

/* ===== Category Pills ===== */
.category-select {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.cat-btn {
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--card);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s;
}

.cat-btn.active {
    border-color: var(--primary);
    background: rgba(199, 255, 90, 0.12);
    color: var(--primary);
}

/* ===== Input Areas ===== */
.input-area textarea {
    width: 100%;
    padding: 16px 18px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 15px;
    resize: vertical;
    min-height: 110px;
    outline: none;
    transition: border-color 0.2s;
}

.input-area textarea:focus { border-color: var(--primary); }
.input-area textarea::placeholder { color: var(--text-dim); }

/* ===== Voice Recording ===== */
.voice-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 20px;
}

.record-btn {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    border: none;
    background: var(--gradient-primary);
    color: var(--primary-text);
    font-size: 36px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 40px var(--primary-glow);
}

.record-btn.recording {
    background: var(--gradient-danger);
    box-shadow: 0 0 40px rgba(244, 63, 94, 0.4);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(244,63,94,0.4); }
    50% { transform: scale(1.05); box-shadow: 0 0 0 24px rgba(244,63,94,0); }
}

.voice-status {
    margin-top: 20px;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
}

/* ===== Photo ===== */
.photo-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 0;
}

.photo-upload-btn {
    width: 100%;
    padding: 48px 20px;
    border: 1.5px dashed var(--border-strong);
    border-radius: var(--radius);
    background: var(--card);
    cursor: pointer;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
}

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

.photo-upload-btn .upload-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 8px;
}

.photo-preview {
    width: 100%;
    max-height: 280px;
    object-fit: cover;
    border-radius: var(--radius);
    margin-bottom: 16px;
}

/* ===== Result Card ===== */
.result-card {
    background: var(--card);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-top: 20px;
    box-shadow: var(--shadow);
}

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

.result-macros {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

.result-macro {
    text-align: center;
    padding: 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.result-macro .value {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.02em;
    font-feature-settings: 'tnum';
}

.result-macro .label {
    font-size: 11px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
    margin-top: 2px;
}

.result-health {
    padding: 14px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 13px;
    line-height: 1.5;
}

.result-actions {
    display: flex;
    gap: 10px;
}

.result-actions .btn { flex: 1; padding: 14px; font-size: 14px; }

/* ===== Stats Page ===== */
.stats-page { padding: 16px 24px 24px; }

.streak-detail {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.streak-stat {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
}

.streak-stat .value {
    font-size: 36px;
    font-weight: 800;
    letter-spacing: -0.03em;
    background: var(--gradient-warm);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.streak-stat .label {
    font-size: 11px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
    margin-top: 4px;
}

.target-line-container {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

.target-line-container h3 {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin-bottom: 16px;
}

.week-chart {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    height: 160px;
    gap: 6px;
}

.chart-bar-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    justify-content: flex-end;
}

.chart-bar {
    width: 100%;
    max-width: 32px;
    border-radius: 6px 6px 0 0;
    transition: height 0.5s ease;
    min-height: 4px;
}

.chart-bar.under { background: var(--gradient-primary); }
.chart-bar.over { background: var(--gradient-danger); }
.chart-bar.on-target { background: var(--gradient-cool); }

.chart-label {
    font-size: 10px;
    color: var(--text-dim);
    margin-top: 6px;
    font-weight: 600;
    text-transform: uppercase;
}

.chart-value {
    font-size: 10px;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--text-muted);
    font-feature-settings: 'tnum';
}

/* ===== Leaderboard ===== */
.leaderboard-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

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

.lb-entry {
    display: flex;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.lb-entry:last-child { border: none; }

.lb-rank {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    margin-right: 12px;
    color: var(--text-muted);
}

.lb-rank.first {
    background: var(--gradient-warm);
    color: #1a0a00;
    border: none;
}

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

.lb-name.is-self { color: var(--primary); }

.lb-stats {
    text-align: right;
    font-size: 12px;
    color: var(--text-muted);
    font-feature-settings: 'tnum';
}

.lb-deviation {
    font-weight: 700;
    font-size: 13px;
    color: var(--text);
    margin-top: 2px;
}

/* ===== Profile ===== */
.profile-page { padding: 16px 24px 24px; }

.profile-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

.profile-card h3 {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

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

.profile-field label {
    display: block;
    font-size: 12px;
    color: var(--text-dim);
    margin-bottom: 6px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.profile-field input {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s;
}

.profile-field input:focus { border-color: var(--primary); }
.profile-field input:disabled { opacity: 0.6; }

.toggle-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    font-size: 14px;
}

.toggle {
    width: 48px;
    height: 28px;
    border-radius: 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    cursor: pointer;
    position: relative;
    transition: background 0.2s;
}

.toggle.active { background: var(--gradient-primary); border-color: transparent; }

.toggle::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    top: 3px;
    left: 3px;
    transition: transform 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.toggle.active::after { transform: translateX(20px); }

/* ===== Toast ===== */
.toast {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: var(--card);
    border: 1px solid var(--border-strong);
    color: var(--text);
    padding: 14px 24px;
    border-radius: var(--radius-pill);
    font-size: 14px;
    font-weight: 600;
    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 90%;
    text-align: center;
    box-shadow: var(--shadow);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.toast.show { transform: translateX(-50%) translateY(0); }

.toast.error {
    background: var(--gradient-danger);
    color: white;
    border-color: transparent;
}

.toast.success {
    background: var(--gradient-primary);
    color: var(--primary-text);
    border-color: transparent;
}

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

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

/* ===== Page show/hide ===== */
.page { display: none; animation: fadein 0.3s; }
.page.active { display: block; }
.auth-screen { display: none; }
.auth-screen.active { display: flex; }
.main-app { display: none; }
.main-app.active { display: block; }

@keyframes fadein { from { opacity: 0; transform: translateY(8px); } }

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 200;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    animation: fadein 0.2s;
}

@keyframes slideup {
    from { transform: translateY(100%); }
}

.modal {
    background: var(--card);
    border: 1px solid var(--border-strong);
    border-bottom: none;
    width: 100%;
    max-width: 480px;
    max-height: 92dvh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    display: flex;
    flex-direction: column;
    animation: slideup 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 4px;
    background: var(--border-strong);
    border-radius: 2px;
}

.modal-header h3 { font-size: 17px; font-weight: 700; }

.modal-close {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-muted);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-body {
    padding: 20px 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    gap: 10px;
    padding: 16px 24px;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
}

.modal-footer .btn { flex: 1; padding: 14px; font-size: 14px; }

.modal-body .result-macro input {
    width: 100%;
    border: none;
    background: transparent;
    text-align: center;
    font-size: 22px;
    font-weight: 800;
    outline: none;
    color: var(--text);
    -moz-appearance: textfield;
    font-feature-settings: 'tnum';
}

.modal-body .result-macro input::-webkit-outer-spin-button,
.modal-body .result-macro input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

#edit-portion {
    width: 100%;
    accent-color: var(--primary);
    margin-top: 4px;
}

.portion-presets {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.portion-presets button {
    flex: 1;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--bg-elevated);
    color: var(--text);
    cursor: pointer;
    font-weight: 700;
    font-size: 13px;
    transition: all 0.2s;
}

.portion-presets button:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.hidden { display: none !important; }

/* ===== Responsive ===== */
@media (min-width: 768px) {
    .app { max-width: 520px; }
}
