/* iOS-ish dark UI. Без градиентов. */
@font-face {
    font-family: "SF Pro Text";
    src: url("fonts/SFProText-Light.ttf") format("truetype");
    font-weight: 300;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "SF Pro Text";
    src: url("fonts/SFProText-LightItalic.ttf") format("truetype");
    font-weight: 300;
    font-style: italic;
    font-display: swap;
}
@font-face {
    font-family: "SF Pro Text";
    src: url("fonts/SFProText-Regular.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "SF Pro Text";
    src: url("fonts/SFProText-RegularItalic.ttf") format("truetype");
    font-weight: 400;
    font-style: italic;
    font-display: swap;
}
@font-face {
    font-family: "SF Pro Text";
    src: url("fonts/SFProText-Medium.ttf") format("truetype");
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "SF Pro Text";
    src: url("fonts/SFProText-MediumItalic.ttf") format("truetype");
    font-weight: 500;
    font-style: italic;
    font-display: swap;
}
@font-face {
    font-family: "SF Pro Text";
    src: url("fonts/SFProText-Semibold.ttf") format("truetype");
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "SF Pro Text";
    src: url("fonts/SFProText-SemiboldItalic.ttf") format("truetype");
    font-weight: 600;
    font-style: italic;
    font-display: swap;
}
@font-face {
    font-family: "SF Pro Text";
    src: url("fonts/SFProText-Bold.ttf") format("truetype");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "SF Pro Text";
    src: url("fonts/SFProText-BoldItalic.ttf") format("truetype");
    font-weight: 700;
    font-style: italic;
    font-display: swap;
}
@font-face {
    font-family: "SF Pro Text";
    src: url("fonts/SFProText-Heavy.ttf") format("truetype");
    font-weight: 800;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "SF Pro Text";
    src: url("fonts/SFProText-HeavyItalic.ttf") format("truetype");
    font-weight: 800;
    font-style: italic;
    font-display: swap;
}

:root {
    --bg: #0b0b0d;
    --bg-elev: #121216;
    --card: #15151b;
    --card2: #1a1a22;
    --text: #f3f4f6;
    --muted: rgba(243, 244, 246, 0.72);
    --muted2: rgba(243, 244, 246, 0.56);
    --border: rgba(255, 255, 255, 0.08);
    --divider: rgba(255, 255, 255, 0.1);
    --shadow: 0 10px 26px rgba(0, 0, 0, 0.45);
    --shadow2: 0 6px 16px rgba(0, 0, 0, 0.38);

    --accent: #0a84ff;
    --accent-base: #0a84ff;
    --success: #34c759;
    --warning: #ffd60a;
    --info: #5ac8fa;
    --danger: #ff453a;

    --bg-pattern-dot: rgba(255, 255, 255, 0.045);
    --bg-pattern-line: rgba(255, 255, 255, 0.028);
    --bg-glow-1: color-mix(in oklab, var(--accent) 20%, transparent);
    --bg-glow-2: color-mix(in oklab, var(--info) 14%, transparent);

    --radius: 18px;
    --radius2: 22px;

    --container: 420px;

    --safe-top: env(safe-area-inset-top);
    --safe-bot: env(safe-area-inset-bottom);

    color-scheme: dark;
}

@media (prefers-color-scheme: light) {
    :root {
        --bg: #e9edf3;
        --bg-elev: #f3f6fb;
        --card: #fdfdff;
        --card2: #f2f5fb;
        --text: #111114;
        --muted: rgba(17, 17, 20, 0.68);
        --muted2: rgba(17, 17, 20, 0.52);
        --border: rgba(15, 23, 42, 0.14);
        --divider: rgba(15, 23, 42, 0.16);
        --shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
        --shadow2: 0 6px 14px rgba(15, 23, 42, 0.07);
        --bg-pattern-dot: rgba(17, 24, 39, 0.12);
        --bg-pattern-line: rgba(17, 24, 39, 0.075);
        --bg-glow-1: color-mix(in oklab, var(--accent) 24%, white);
        --bg-glow-2: color-mix(in oklab, var(--info) 20%, white);

        color-scheme: light;
    }
}

/* Manual theme override */
:root[data-theme="dark"] {
    --bg: #0b0b0d;
    --bg-elev: #121216;
    --card: #15151b;
    --card2: #1a1a22;
    --text: #f3f4f6;
    --muted: rgba(243, 244, 246, 0.72);
    --muted2: rgba(243, 244, 246, 0.56);
    --border: rgba(255, 255, 255, 0.08);
    --divider: rgba(255, 255, 255, 0.1);
    --shadow: 0 10px 26px rgba(0, 0, 0, 0.45);
    --shadow2: 0 6px 16px rgba(0, 0, 0, 0.38);
    --accent: var(--accent-base);
    --bg-pattern-dot: rgba(255, 255, 255, 0.045);
    --bg-pattern-line: rgba(255, 255, 255, 0.028);
    --bg-glow-1: color-mix(in oklab, var(--accent) 20%, transparent);
    --bg-glow-2: color-mix(in oklab, var(--info) 14%, transparent);
    color-scheme: dark;
}

:root[data-theme="light"] {
    --bg: #e9edf3;
    --bg-elev: #f3f6fb;
    --card: #fdfdff;
    --card2: #f2f5fb;
    --text: #111114;
    --muted: rgba(17, 17, 20, 0.68);
    --muted2: rgba(17, 17, 20, 0.52);
    --border: rgba(15, 23, 42, 0.14);
    --divider: rgba(15, 23, 42, 0.16);
    --shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
    --shadow2: 0 6px 14px rgba(15, 23, 42, 0.07);
    --accent: var(--accent-base);
    --bg-pattern-dot: rgba(17, 24, 39, 0.12);
    --bg-pattern-line: rgba(17, 24, 39, 0.075);
    --bg-glow-1: color-mix(in oklab, var(--accent) 24%, white);
    --bg-glow-2: color-mix(in oklab, var(--info) 20%, white);
    color-scheme: light;
}

* {
    box-sizing: border-box;
}
html,
body {
    height: 100%;
}
body {
    margin: 0;
    font-family: "SF Pro Text", system-ui, -apple-system, "Segoe UI", Arial,
        sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: none;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
}

.gate {
    position: fixed;
    inset: 0;
    padding: 18px;
    padding-top: calc(18px + var(--safe-top));
    padding-bottom: calc(18px + var(--safe-bot));
    display: grid;
    place-items: center;
    z-index: 999;
    background: color-mix(in oklab, var(--bg) 92%, transparent);
    backdrop-filter: blur(10px);
}
.gate-card {
    width: min(var(--container), 100%);
    border-radius: 26px;
    border: 1px solid var(--border);
    background: var(--card);
    box-shadow: var(--shadow);
    padding: 16px;
}
.gate-title {
    font-size: 18px;
    font-weight: 900;
    letter-spacing: 0.2px;
}
.gate-text {
    margin-top: 8px;
    color: var(--muted);
    line-height: 1.45;
}
.gate-actions {
    margin-top: 14px;
    display: flex;
    gap: 10px;
}

.app-bg {
    position: fixed;
    inset: 0;
    background-color: var(--bg);
    background-image:
        radial-gradient(circle at 1px 1px, var(--bg-pattern-dot) 1.15px, transparent 1.15px),
        repeating-linear-gradient(
            45deg,
            transparent 0,
            transparent 26px,
            var(--bg-pattern-line) 26px,
            var(--bg-pattern-line) 27px
        ),
        repeating-linear-gradient(
            -45deg,
            transparent 0,
            transparent 26px,
            var(--bg-pattern-line) 26px,
            var(--bg-pattern-line) 27px
        ),
        radial-gradient(90% 70% at 10% 0%, var(--bg-glow-1), transparent 68%),
        radial-gradient(95% 80% at 100% 100%, var(--bg-glow-2), transparent 72%);
    background-size: 22px 22px, auto, auto, auto, auto;
}

.app-shell {
    position: relative;
    max-width: var(--container);
    width: min(var(--container), 100%);
    margin: 0 auto;
    min-height: 100vh;
    height: auto;
    padding: 0 14px;
    padding-top: calc(8px + var(--safe-top));
    padding-bottom: calc(98px + var(--safe-bot));
    display: flex;
    flex-direction: column;
}
.app-shell.no-tabbar {
    padding-bottom: calc(16px + var(--safe-bot));
}

.topbar {
    position: sticky;
    top: var(--safe-top);
    z-index: 10;
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 16px;
    backdrop-filter: none;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.title {
    margin: 0;
    font-weight: 750;
    font-size: 22px;
    letter-spacing: 0.2px;
}

.topbar-actions {
    display: flex;
    gap: 8px;
}

.icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: color-mix(in oklab, var(--card) 70%, transparent);
    color: var(--text);
    display: grid;
    place-items: center;
    box-shadow: var(--shadow2);
    transition:
        transform 0.12s ease,
        background 0.12s ease,
        border-color 0.12s ease,
        opacity 0.12s ease;
}
.icon-btn svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    opacity: 0.92;
}
.icon-btn:active {
    transform: scale(0.98);
}
.icon-btn:hover {
    background: color-mix(in oklab, var(--card2) 75%, transparent);
}
.icon-btn:focus-visible {
    outline: 2px solid color-mix(in oklab, var(--accent) 85%, white);
    outline-offset: 2px;
}

.content {
    padding-top: 8px;
    flex: 0 0 auto;
    overflow: visible;
    position: relative;
}

.screen {
    display: none;
    animation: fadein 0.18s ease;
    position: relative;
    min-height: 100%;
}
.screen.active {
    display: block;
}
@keyframes fadein {
    from {
        opacity: 0;
        transform: translateY(3px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.row {
    display: flex;
    align-items: center;
    justify-content: center;
}
.row.space {
    justify-content: space-between;
}
.row.end {
    justify-content: flex-end;
}
.screen-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    width: 100%;
    margin: 6px 0 12px;
}
.screen-actions .btn {
    width: 100%;
    justify-content: center;
}
.screen-actions .btn-ic {
    width: 18px;
    height: 18px;
    display: grid;
    place-items: center;
}
#btnShoppingList {
    grid-column: 1 / -1;
}
@media (max-width: 360px) {
    .screen-actions {
        grid-template-columns: 1fr;
    }
    #btnShoppingList {
        grid-column: auto;
    }
}
.row.wrap {
    flex-wrap: wrap;
}
.gap {
    gap: 10px;
}
.mt8 {
    margin-top: 8px;
}
.mt10 {
    margin-top: 10px;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius2);
    padding: 14px;
    box-shadow: var(--shadow2);
}

.card-title {
    font-weight: 700;
    margin-bottom: 10px;
    letter-spacing: 0.2px;
}
.result-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.result-card .card-title {
    margin-bottom: 0;
}
.card-subtitle {
    font-weight: 650;
    margin: 4px 0 8px;
}

.photo-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}
.photo-actions + .row {
    margin-top: 8px;
}
.photo-result-actions {
    margin-top: 10px;
    margin-bottom: 4px;
}
.small {
    font-size: 12px;
}
.muted {
    color: var(--muted);
}
.unit {
    font-size: 13px;
    color: var(--muted);
    font-weight: 650;
}

.divider {
    height: 1px;
    background: var(--divider);
    margin: 12px 0;
    border-radius: 999px;
}

/* Home */
.home-user {
    display: flex;
    align-items: center;
    gap: 12px;
}
.home-user-meta {
    min-width: 0;
    flex: 1;
}
.home-user-name {
    font-weight: 800;
    letter-spacing: 0.2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.home-user-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

#homeTodayBadge,
#homePlanBadgeLarge {
    display: none;
}

.avatar {
    width: 44px;
    height: 44px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: color-mix(in oklab, var(--card2) 70%, transparent);
    overflow: hidden;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
}
.avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.avatar-fallback {
    font-weight: 900;
    color: var(--muted);
}

.home-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-top: 10px;
}
.stat {
    border: 1px solid var(--border);
    background: color-mix(in oklab, var(--card2) 70%, transparent);
    border-radius: 16px;
    padding: 10px;
}
.stat-num {
    margin-top: 2px;
    font-size: 18px;
    font-weight: 850;
}

.home-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}
.home-plan-features {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}
.home-plan-features .plan-chip {
    border: 1px solid var(--border);
    background: color-mix(in oklab, var(--card2) 75%, transparent);
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 650;
}
.mini-action {
    width: 100%;
    border: 1px solid var(--border);
    background: color-mix(in oklab, var(--card2) 70%, transparent);
    color: var(--text);
    border-radius: 16px;
    padding: 12px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    text-align: left;
    box-shadow: none;
}
.mini-action:active {
    transform: scale(0.99);
}
.mini-action-ic {
    width: 34px;
    height: 34px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: color-mix(in oklab, var(--bg) 70%, transparent);
    border: 1px solid var(--border);
}
.mini-action-ic svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    opacity: 0.95;
}

.plans-grid {
    display: grid;
    gap: 12px;
    margin-top: 12px;
}
.plan-card {
    border: 1px solid var(--border);
    background: color-mix(in oklab, var(--card2) 70%, transparent);
    border-radius: 18px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    cursor: pointer;
    transition: border-color 0.2s ease, transform 0.15s ease;
    width: 100%;
    text-align: left;
    appearance: none;
}
.plan-card:hover {
    transform: translateY(-1px);
}
.plan-card.active {
    border-color: color-mix(in oklab, var(--accent) 75%, var(--border));
    box-shadow: 0 0 0 1px color-mix(in oklab, var(--accent) 35%, transparent);
}
.plan-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.plan-title {
    font-weight: 800;
}
.plan-price {
    font-size: 20px;
    font-weight: 900;
}
.plan-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 999px;
    background: color-mix(in oklab, var(--accent) 25%, transparent);
    border: 1px solid color-mix(in oklab, var(--accent) 35%, transparent);
}
.plan-features {
    display: grid;
    gap: 8px;
}
.plan-features .feature {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}
.plan-features .feature::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--accent);
    display: inline-block;
}

.checkout-summary {
    display: grid;
    gap: 8px;
    margin-top: 8px;
}
.checkout-summary .line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 14px;
}
.checkout-summary .line strong {
    font-weight: 800;
}

.screen-lock {
    position: relative;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 8px 0 0;
    background: transparent;
    backdrop-filter: none;
    z-index: 1;
}
.screen.locked > :not(.screen-lock) {
    display: none;
}
.lock-card {
    width: 100%;
    max-width: 360px;
    text-align: left;
    border: 1px solid var(--border);
    background: var(--card);
    border-radius: 18px;
    padding: 16px;
}
.lock-title {
    font-weight: 800;
    font-size: 16px;
    margin-bottom: 6px;
}

.btn {
    border: 1px solid var(--border);
    background: var(--card2);
    color: var(--text);
    border-radius: 16px;
    padding: 12px 14px;
    font-weight: 700;
    letter-spacing: 0.2px;
    width: 100%;
    box-shadow: var(--shadow2);
    transition:
        transform 0.12s ease,
        opacity 0.12s ease,
        background 0.12s ease,
        border-color 0.12s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}
.btn.loading {
    position: relative;
    opacity: 0.75;
    pointer-events: none;
}
.btn.loading::after {
    content: "";
    width: 14px;
    height: 14px;
    border: 2px solid color-mix(in oklab, var(--text) 40%, transparent);
    border-top-color: var(--text);
    border-radius: 50%;
    display: inline-block;
    margin-left: 8px;
    animation: spin 0.9s linear infinite;
}
.btn:hover {
    background: color-mix(in oklab, var(--card2) 88%, white);
}
.btn:active {
    transform: scale(0.985);
}
.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.btn.primary {
    background: var(--accent);
    border-color: color-mix(in oklab, var(--accent) 70%, black);
    color: #fff;
}
.btn.primary:hover {
    background: color-mix(in oklab, var(--accent) 86%, white);
}
.btn.danger {
    background: var(--danger);
    border-color: color-mix(in oklab, var(--danger) 70%, black);
    color: #fff;
}
.btn.danger:hover {
    background: color-mix(in oklab, var(--danger) 86%, white);
}
.btn.secondary {
    background: var(--card2);
}
.btn.ghost {
    background: transparent;
    border-color: var(--border);
    box-shadow: none;
}
.btn.link {
    width: auto;
    padding: 8px 10px;
    border: 0;
    background: transparent;
    color: var(--muted);
    box-shadow: none;
}
.btn.inline {
    width: auto;
    padding: 8px 12px;
}

/* Keep meal/workout quick actions visible even if old markup with .ghost is cached */
#btnNewMealPlan,
#btnShoppingList,
#btnNewWorkoutPlan {
    background: var(--card2);
    border-color: var(--border);
    color: var(--text);
    box-shadow: var(--shadow2);
}

.btn.link:hover {
    color: var(--text);
    background: color-mix(in oklab, var(--card2) 65%, transparent);
    border-radius: 12px;
}
.btn-ic svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    display: block;
}

.btn:focus-visible {
    outline: 2px solid color-mix(in oklab, var(--accent) 85%, white);
    outline-offset: 2px;
}

/* Scanner */
.scanner {
    margin: 10px 0 12px;
    width: 100%;
    aspect-ratio: 1/1;
    border-radius: 22px;
    background: #0a0a0d;
    border: none;
    overflow: hidden;
    position: relative;
}
.scanner-inner {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
}
.scanner-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.scanner-frame {
    position: absolute;
    inset: 12px;
    border-radius: 16px;
    border: none;
    box-shadow: none;
    pointer-events: none;
}
.scanner-hint {
    position: absolute;
    left: 14px;
    right: 14px;
    bottom: 14px;
    font-size: 13px;
    color: #f3f4f6;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.16);
    padding: 10px 12px;
    border-radius: 14px;
    backdrop-filter: blur(10px);
}

.hidden {
    display: none !important;
}

/* Chips */
.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.chip {
    font-size: 12px;
    font-weight: 650;
    color: var(--text);
    padding: 8px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: color-mix(in oklab, var(--card2) 80%, transparent);
}

/* Check as chip */
.chips-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
}
.chip-check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    padding: 8px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: color-mix(in oklab, var(--card2) 78%, transparent);
    color: var(--text);
    user-select: none;
    cursor: pointer;
}
.chip-check input {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: color-mix(in oklab, var(--card2) 80%, transparent);
    display: grid;
    place-content: center;
    flex: 0 0 auto;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}
.chip-check input::after {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 3px;
    background: var(--accent);
    transform: scale(0);
    transition: transform 0.12s ease-out;
}
.chip-check input:checked {
    border-color: color-mix(in oklab, var(--accent) 55%, var(--border));
    background: color-mix(in oklab, var(--accent) 18%, var(--card2));
}
.chip-check input:checked::after {
    transform: scale(1);
}

/* List */
.list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.list-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 10px;
    background: color-mix(in oklab, var(--card2) 70%, transparent);
    border: 1px solid var(--border);
    border-radius: 16px;
}
.list-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.list-right {
    text-align: right;
}
.badge {
    font-size: 11px;
    color: var(--muted);
}

/* Macro */
.big-number {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: 0.3px;
    margin-top: 4px;
}
.macro-top {
    display: grid;
    grid-template-columns: 1fr;
    align-items: center;
    gap: 12px;
}
.macro-left {
    min-width: 0;
}
.macro-cards {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}
.result-card #resTags {
    margin-top: 2px;
}
.macro-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 10px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: color-mix(in oklab, var(--card2) 70%, transparent);
}
.macro-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    flex: 0 0 auto;
}
.macro-dot.protein {
    background: var(--info);
}
.macro-dot.fat {
    background: var(--warning);
}
.macro-dot.carbs {
    background: var(--success);
}
.macro-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.macro-value {
    font-weight: 800;
    font-size: 13px;
}
.macro-label {
    font-size: 11px;
    color: var(--muted);
}
.loader {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 2px;
}
.loader-text {
    font-size: 13px;
    color: var(--muted);
}
.loader-sub {
    margin-left: 40px;
    font-size: 12px;
    color: var(--muted2);
}
.spinner {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 3px solid color-mix(in oklab, var(--muted) 45%, transparent);
    border-top-color: var(--accent);
    animation: spin 0.8s linear infinite;
}
.spinner.sm {
    width: 14px;
    height: 14px;
    border-width: 2px;
}
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}
.macro-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 10px;
}
.meal-summary {
    position: relative;
    overflow: hidden;
}
.meal-summary::before {
    content: "";
    position: absolute;
    left: -30%;
    top: -60%;
    width: 160%;
    height: 120%;
    background: none;
    pointer-events: none;
}
.meal-summary .card-title,
.meal-summary .muted,
.meal-summary .meal-boost,
.meal-summary .macro-row,
.meal-summary #mealTips {
    position: relative;
    z-index: 1;
}
.meal-summary #mealTips {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 12px;
}
.meal-summary #mealTips .chip {
    border-radius: 16px;
    padding: 12px 14px 12px 36px;
    border: 1px solid color-mix(in oklab, var(--accent) 18%, var(--border));
    background: linear-gradient(135deg, color-mix(in oklab, var(--accent) 14%, var(--card2)), color-mix(in oklab, var(--card) 65%, transparent));
    position: relative;
    font-size: 13px;
    font-weight: 700;
}
.meal-summary #mealTips .chip::before {
    content: "";
    position: absolute;
    left: 12px;
    top: 50%;
    width: 8px;
    height: 8px;
    border-radius: 999px;
    transform: translateY(-50%);
    background: linear-gradient(135deg, var(--accent), var(--info));
    box-shadow: 0 0 6px color-mix(in oklab, var(--accent) 55%, transparent);
}
.meal-boost {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--muted);
    margin-top: 6px;
}
.meal-boost .boost-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--accent), var(--info));
    box-shadow: 0 0 6px color-mix(in oklab, var(--accent) 45%, transparent);
}
.pill {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: color-mix(in oklab, var(--card2) 75%, transparent);
    font-size: 13px;
    font-weight: 700;
}
.pill b {
    font-weight: 800;
}

/* Fields */
.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 10px;
}
.field span {
    font-size: 12px;
    color: var(--muted);
    font-weight: 650;
}
input,
select,
textarea {
    width: 100%;
    padding: 12px 12px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: color-mix(in oklab, var(--card2) 86%, transparent);
    color: var(--text);
    outline: none;
    font-size: 14px;
    box-shadow: none;
}
select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23b7bcc4' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6l6-6'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px 16px;
    padding-right: 36px;
}
select::-ms-expand {
    display: none;
}
textarea {
    resize: none;
    min-height: 92px;
}
input::placeholder,
textarea::placeholder {
    color: color-mix(in oklab, var(--muted) 85%, transparent);
}
input:focus,
select:focus,
textarea:focus {
    border-color: color-mix(in oklab, var(--accent) 70%, white);
}

.grid2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

/* Segmented */
.segmented {
    display: flex;
    background: color-mix(in oklab, var(--card2) 70%, transparent);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 4px;
    gap: 4px;
}
.seg {
    flex: 1;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--muted);
    padding: 10px 10px;
    font-weight: 750;
    font-size: 12px;
    cursor: pointer;
    transition:
        background 0.12s ease,
        color 0.12s ease,
        transform 0.12s ease;
}
.seg:hover {
    color: var(--text);
}
.seg:active {
    transform: scale(0.99);
}
.seg.active {
    background: color-mix(in oklab, var(--card) 80%, transparent);
    color: var(--text);
    box-shadow: var(--shadow2);
}

.settings-theme {
    border: 0;
    background: transparent;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
}

/* Accordion */
.accordion {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}
details {
    border: 1px solid var(--border);
    border-radius: 16px;
    background: color-mix(in oklab, var(--card2) 70%, transparent);
    overflow: hidden;
}
summary {
    list-style: none;
    padding: 12px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
summary::-webkit-details-marker {
    display: none;
}
.sum-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.sum-title {
    font-weight: 800;
}
.sum-sub {
    font-size: 12px;
    color: var(--muted);
}
.sum-ic {
    width: 28px;
    height: 28px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: color-mix(in oklab, var(--card) 72%, transparent);
    display: grid;
    place-items: center;
}
.sum-ic svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    fill: none;
    opacity: 0.92;
}
.details-body {
    padding: 0 12px 12px;
}
.meal-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 10px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: color-mix(in oklab, var(--card) 70%, transparent);
    margin-top: 8px;
}
.meal-row.clickable {
    cursor: pointer;
}
.meal-row.clickable:hover {
    border-color: color-mix(in oklab, var(--accent) 30%, var(--border));
    background: color-mix(in oklab, var(--card2) 65%, transparent);
}
.meal-left {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}
.meal-title {
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 6px;
}
.meal-text {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.35;
}
.meal-right {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-end;
    flex: 0 0 auto;
}
.kcal {
    font-weight: 900;
    font-size: 12px;
    color: var(--text);
}
.replace-btn {
    border: 1px solid var(--border);
    background: transparent;
    color: var(--muted);
    border-radius: 12px;
    padding: 8px 10px;
    font-weight: 750;
    font-size: 12px;
    cursor: pointer;
}
.replace-btn.loading {
    opacity: 0.8;
    cursor: default;
}
.meal-row.swap-out {
    opacity: 0.5;
    transform: translateY(2px);
}
.meal-row.swap-in {
    animation: swapIn 0.22s ease;
}
@keyframes swapIn {
    from {
        opacity: 0.2;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
.replace-btn:hover {
    color: var(--text);
    background: color-mix(in oklab, var(--card2) 65%, transparent);
}
.replace-btn:active {
    transform: scale(0.99);
}
.meal-ic {
    width: 22px;
    height: 22px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    background: color-mix(in oklab, var(--card2) 75%, transparent);
    color: var(--text);
}
.meal-ic svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
}
.meal-ic.breakfast {
    color: var(--warning);
    background: color-mix(in oklab, var(--warning) 18%, var(--card2));
}
.meal-ic.lunch {
    color: var(--info);
    background: color-mix(in oklab, var(--info) 18%, var(--card2));
}
.meal-ic.snack {
    color: var(--accent);
    background: color-mix(in oklab, var(--accent) 16%, var(--card2));
}
.meal-ic.dinner {
    color: var(--success);
    background: color-mix(in oklab, var(--success) 16%, var(--card2));
}
.meal-detail-img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    border-radius: 16px;
    border: 1px solid var(--border);
    margin-bottom: 10px;
}
.meal-detail-meta {
    font-size: 12px;
    color: var(--muted);
    margin-top: 6px;
}
.recipe-body {
    font-size: 13px;
    line-height: 1.55;
    color: var(--text);
}
.recipe-body p {
    margin: 8px 0;
}
.recipe-body h3,
.recipe-body h4 {
    margin: 12px 0 6px;
    font-size: 14px;
}
.recipe-body img {
    width: 100%;
    height: auto;
    border-radius: 12px;
    border: 1px solid var(--border);
    margin: 8px 0;
}

/* History */
.history {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.history-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: 18px;
    border: 1px solid var(--border);
    background: color-mix(in oklab, var(--card2) 70%, transparent);
    cursor: pointer;
    transition:
        transform 0.12s ease,
        background 0.12s ease;
}
.history-item:hover {
    background: color-mix(in oklab, var(--card2) 80%, transparent);
}
.history-item:active {
    transform: scale(0.99);
}
.thumb {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: #0b0b0d;
    border: 1px solid var(--border);
    object-fit: cover;
    flex: 0 0 auto;
}
.hi-main {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.hi-title {
    font-weight: 800;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.hi-sub {
    font-size: 12px;
    color: var(--muted);
}
.hi-kcal {
    margin-left: auto;
    font-weight: 900;
    font-size: 12px;
    color: var(--text);
    padding: 8px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: color-mix(in oklab, var(--card) 70%, transparent);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 72px;
    white-space: nowrap;
    line-height: 1;
}

.empty {
    padding: 10px 6px 0;
    font-size: 12px;
}

/* Workout cards */
.day-card {
    padding: 12px;
    border-radius: 18px;
    border: 0;
    background: transparent;
    box-shadow: none;
}
.day-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
}
.day-title {
    font-weight: 900;
}
.day-sub {
    font-size: 12px;
    color: var(--muted);
}
.exercise {
    margin-top: 12px;
    padding: 12px;
    border-radius: 16px;
    border: 1px solid color-mix(in oklab, var(--border) 85%, transparent);
    background: color-mix(in oklab, var(--card2) 82%, transparent);
    box-shadow: var(--shadow2);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.ex-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.ex-name {
    font-weight: 800;
    font-size: 14px;
}
.ex-meta {
    font-size: 12px;
    color: var(--muted);
    text-align: right;
    padding: 6px 8px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: color-mix(in oklab, var(--card2) 70%, transparent);
    min-width: 78px;
}
.ex-actions {
    display: flex;
    justify-content: flex-start;
}
.exercise-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.step-params {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}
.step-param {
    border: 1px solid var(--border);
    border-radius: 14px;
    background: color-mix(in oklab, var(--card2) 74%, transparent);
    padding: 10px 8px;
    text-align: center;
}
.step-param-value {
    font-weight: 850;
    font-size: 16px;
    line-height: 1.1;
}
.step-param-label {
    margin-top: 4px;
    font-size: 11px;
    color: var(--muted);
}
.steps-list {
    display: grid;
    gap: 12px;
}
.step-gallery {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 8px;
}
.step-videos {
    display: grid;
    gap: 10px;
}
.step-video-frame {
    width: 100%;
    aspect-ratio: 16 / 9;
    border: 0;
    border-radius: 12px;
    background: #0b0b0d;
}
.step-card {
    display: grid;
    gap: 10px;
    padding: 12px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: color-mix(in oklab, var(--card2) 80%, transparent);
}
.step-photo {
    width: 100%;
    height: 160px;
    object-fit: cover;
    border-radius: 12px;
    background: #0b0b0d;
}
.step-row {
    display: grid;
    grid-template-columns: 28px 1fr;
    gap: 10px;
    align-items: start;
}
.step-num {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 12px;
    font-weight: 800;
    line-height: 1;
}
.step-text {
    font-size: 14px;
    line-height: 1.4;
}
.media-btn {
    border: 1px solid var(--border);
    background: transparent;
    border-radius: 16px;
    padding: 0;
    overflow: hidden;
    cursor: pointer;
    width: 100%;
}
.media-thumb {
    width: 100%;
    height: 140px;
    object-fit: cover;
    display: block;
    background: #0b0b0d;
}
.media-ph {
    height: 140px;
    display: grid;
    place-items: center;
    color: var(--muted);
    background: #0b0b0d;
}
.media-ph svg {
    width: 34px;
    height: 34px;
    stroke: currentColor;
    fill: none;
    opacity: 0.85;
}
.media-cap {
    padding: 10px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: var(--text);
    background: color-mix(in oklab, var(--card) 72%, transparent);
}
.media-cap span {
    font-size: 12px;
    color: var(--muted);
}

/* Tabbar */
.tabbar {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(12px + var(--safe-bot));
    width: min(calc(var(--container) - 28px), calc(100% - 28px));
    padding: 10px;
    display: flex;
    gap: 6px;
    background: color-mix(in oklab, var(--bg) 80%, transparent);
    backdrop-filter: blur(14px);
    border: 1px solid var(--border);
    border-radius: 26px;
    box-shadow: var(--shadow);
    z-index: 20;
}
.tab {
    flex: 1;
    position: relative;
    border: 0;
    background: transparent;
    color: var(--muted);
    border-radius: 18px;
    padding: 6px 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    box-shadow: none;
    transition:
        transform 0.12s ease,
        color 0.12s ease;
}
.tab:hover {
    color: var(--text);
}
.tab:active {
    transform: scale(0.99);
}
.tab.active {
    color: var(--text);
}
.tab-ic {
    width: 44px;
    height: 44px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    border: 1px solid transparent;
}
.tab.active .tab-ic {
    background: color-mix(in oklab, var(--accent) 22%, var(--card2));
    border-color: color-mix(in oklab, var(--accent) 50%, var(--border));
}
.tab-ic svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    fill: none;
    opacity: 0.95;
}
.tab-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Modal */
.modal-root {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 50;
}
.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 14px;
    padding-bottom: calc(14px + var(--safe-bot));
    pointer-events: auto;
    animation: modalIn 0.14s ease;
}
@keyframes modalIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal {
    width: min(var(--container), 100%);
    border-radius: 26px;
    border: 1px solid var(--border);
    background: var(--card);
    box-shadow: var(--shadow);
    overflow: hidden;
    max-height: calc(100vh - 60px);
    display: flex;
    flex-direction: column;
}
.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--divider);
    background: color-mix(in oklab, var(--card2) 60%, transparent);
}
.modal-title {
    font-weight: 900;
}
.modal-body {
    padding: 14px;
    overflow: auto;
}
.modal-close {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: color-mix(in oklab, var(--card) 70%, transparent);
    color: var(--text);
    display: grid;
    place-items: center;
    cursor: pointer;
}
.modal-close svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    opacity: 0.92;
}
.modal-close:active {
    transform: scale(0.98);
}

.modal-footer {
    padding: 12px 14px;
    border-top: 1px solid var(--divider);
    background: color-mix(in oklab, var(--card2) 60%, transparent);
    display: flex;
    gap: 10px;
}
.modal-footer .btn {
    box-shadow: none;
}

/* Media modal */
.media-view {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.media-full {
    width: 100%;
    border-radius: 18px;
    border: 1px solid var(--border);
    overflow: hidden;
    background: #0b0b0d;
}
.media-full img,
.media-full video {
    width: 100%;
    height: auto;
    display: block;
}

/* Crop modal */
.crop-wrap {
    width: 100%;
    border-radius: 18px;
    overflow: hidden;
    border: 1px solid var(--border);
    background: #0b0b0d;
}
.crop-wrap img {
    width: 100%;
    height: auto;
    display: block;
}

/* Toasts */
.toast-root {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    top: 0;
    width: min(var(--container), 100%);
    padding: 10px 14px;
    padding-top: calc(10px + var(--safe-top));
    z-index: 60;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.toast {
    pointer-events: auto;
    padding: 12px 12px;
    border-radius: 18px;
    border: 1px solid var(--border);
    background: color-mix(in oklab, var(--card) 86%, transparent);
    box-shadow: var(--shadow2);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    animation: toastIn 0.14s ease;
}
@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
.toast .t-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.toast .t-title {
    font-weight: 900;
    font-size: 13px;
}
.toast .t-msg {
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.toast .t-x {
    border: 1px solid var(--border);
    background: transparent;
    color: var(--muted);
    width: 34px;
    height: 34px;
    border-radius: 12px;
    cursor: pointer;
}
.toast.success {
    border-color: color-mix(in oklab, var(--success) 55%, var(--border));
}
.toast.error {
    border-color: color-mix(in oklab, var(--danger) 55%, var(--border));
}

/* Skeleton */
.skeleton-card {
    height: 88px;
    border-radius: 22px;
    border: 1px solid var(--border);
    background: color-mix(in oklab, var(--card2) 70%, transparent);
    animation: pulse 1.05s ease-in-out infinite;
}
.skeleton-line {
    height: 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: color-mix(in oklab, var(--card2) 62%, transparent);
    animation: pulse 1.05s ease-in-out infinite;
}
.w60 {
    width: 60%;
}
.w70 {
    width: 70%;
}
.w85 {
    width: 85%;
}
@keyframes pulse {
    0%,
    100% {
        opacity: 0.6;
    }
    50% {
        opacity: 1;
    }
}

/* Tight screens */
@media (max-width: 360px) {
    .grid2 {
        grid-template-columns: 1fr;
    }
    .macro-top {
        align-items: flex-start;
    }
    .photo-actions {
        grid-template-columns: 1fr;
    }
}
