:root {
    color-scheme: dark;
    --bg: #12151A;
    --surface: #1C2026;
    --surface-2: #262B32;
    --border: #383F47;
    --text: #F2EFEA;
    --text-muted: #98A1AA;
    --accent: #E2592F;
    --accent-2: #E5B23E;
    --success: #5FBE76;
    --danger: #E05A61;
    --focus-ring: rgba(229, 178, 62, .34);
    --topbar-h: 56px;
    --tabbar-h: 64px;
}

:root[data-theme="light"] {
    color-scheme: light;
    --bg: #F6F4EF;
    --surface: #FFFFFF;
    --surface-2: #F0EEE8;
    --border: #DDD6CA;
    --text: #1D252D;
    --text-muted: #65717D;
    --accent: #D34F2B;
    --accent-2: #A97812;
    --success: #27864E;
    --danger: #C63E49;
    --focus-ring: rgba(169, 120, 18, .25);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Vazirmatn', sans-serif;
    min-height: 100%;
}

a {
    color: inherit;
}

.app-backdrop {
    position: fixed;
    inset: 0;
    z-index: -1;
    background: linear-gradient( rgba(0,0,0,.25), rgba(0,0,0,.35) ), url('/images/gym-hero-mobile.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

:root[data-theme="light"] .app-backdrop {
    background: linear-gradient(180deg, rgba(246,244,239,.88) 0%, rgba(246,244,239,.96) 62%, rgba(246,244,239,1) 100%), url('/images/gym-hero-mobile.png');
    background-size: cover;
    background-position: center;
}

@media (min-width: 768px) {
    .app-backdrop {
        background-image: linear-gradient(180deg, rgba(12,15,18,.60) 0%, rgba(12,15,18,.88) 55%, rgba(12,15,18,.97) 100%), url('/images/gym-hero-desktop.png');
    }

    :root[data-theme="light"] .app-backdrop {
        background-image: linear-gradient(180deg, rgba(246,244,239,.78) 0%, rgba(246,244,239,.94) 58%, rgba(246,244,239,1) 100%), url('/images/gym-hero-desktop.png');
    }
}

.app-topbar {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    padding-top: env(safe-area-inset-top);
    background: rgba(18, 21, 26, .55);
    backdrop-filter: blur(28px) saturate(1.6);
    -webkit-backdrop-filter: blur(28px) saturate(1.6);
    border-bottom: 1px solid rgba(255, 255, 255, .07);
    z-index: 50;
}

:root[data-theme="light"] .app-topbar,
:root[data-theme="light"] .app-tabbar {
    background: rgba(255, 255, 255, .72);
    border-color: rgba(29, 37, 45, .10);
}

.theme-toggle {
    width: 38px;
    height: 38px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    flex-shrink: 0;
}

.theme-toggle:hover {
    border-color: var(--accent);
}
.topbar-logo {
    width: 42px;
    height: 42px;
    object-fit: contain;
    flex-shrink: 0;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    font-size: 15px;
    text-decoration: none;
}

    .topbar-brand .topbar-icon {
        width: 20px;
        height: 20px;
        color: var(--accent);
    }

.topbar-title {
    font-size: 12px;
    color: var(--text-muted);
}

.app-content {
    padding: calc(var(--topbar-h) + env(safe-area-inset-top) + 20px) 0 calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 24px);
    min-height: 100vh;
}

.app-tabbar {
    position: fixed;
    bottom: 0;
    right: 0;
    left: 0;
    height: var(--tabbar-h);
    display: flex;
    background: rgba(18, 21, 26, .55);
    backdrop-filter: blur(28px) saturate(1.6);
    -webkit-backdrop-filter: blur(28px) saturate(1.6);
    border-top: 1px solid rgba(255, 255, 255, .07);
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 50;
}

.tab-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 11px;
}

    .tab-item svg {
        width: 21px;
        height: 21px;
    }

    .tab-item.active {
        color: var(--text);
    }

.tab-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    border: 2px solid var(--text-muted);
    margin-top: 1px;
}

.tab-item.active .tab-dot {
    background: var(--accent);
    border-color: var(--accent);
}

.tab-item.disabled {
    opacity: .38;
    pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
    }
}

.dir-ltr {
    direction:ltr;
}

.responsive-date-desktop {
    display: none;
}

.review-saved-at {
    margin: 6px 0 0;
    color: var(--text-muted);
    font-size: 13px;
}

.generation-status-panel {
    width: min(560px, calc(100% - 28px));
    margin: 0 auto 16px;
    display: grid;
    gap: 10px;
}

.generation-status-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px;
    border-radius: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
}

.body-progress { margin: 18px 0; padding: 16px; }
.body-progress-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.body-progress-head h2 { margin: 3px 0 0; font-size: 18px; }
.body-progress-head label { color: var(--text-muted); font-size: 13px; }
.body-progress-head select { display: block; margin-top: 5px; min-width: 155px; }
.body-progress-canvas { display: block; max-width: 100%; }
@media (max-width: 520px) { .body-progress-head { align-items: stretch; flex-direction: column; } .body-progress-head select { width: 100%; } }

.generation-status-card p {
    margin: 4px 0 0;
    color: var(--text-muted);
    font-size: 13px;
}

.generation-status-card span,
.generation-status-card a {
    color: var(--accent-2);
    font-weight: 800;
    text-decoration: none;
    text-align: left;
}

.generation-status-card.failed span {
    color: var(--accent);
}

.generation-cancel-form { display: flex; align-items: center; justify-content: end; gap: 10px; }
.generation-cancel-button { border: 1px solid color-mix(in srgb, #e45353 65%, var(--border)); background: transparent; color: #e45353; border-radius: 6px; padding: 7px 9px; font: inherit; font-size: 12px; font-weight: 800; cursor: pointer; }
.generation-cancel-button:hover { background: color-mix(in srgb, #e45353 12%, transparent); }

.generation-status-card.queued,
.generation-status-card.running {
    border-color: color-mix(in srgb, var(--accent) 48%, var(--border));
    background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}

.generation-monitor {
    position: fixed;
    z-index: 50;
    left: max(16px, env(safe-area-inset-left));
    bottom: calc(82px + env(safe-area-inset-bottom));
    width: min(370px, calc(100vw - 32px));
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    color: var(--text);
    background: color-mix(in srgb, var(--surface) 94%, var(--accent));
    border: 1px solid color-mix(in srgb, var(--accent) 55%, var(--border));
    border-radius: 8px;
    box-shadow: 0 14px 34px rgba(0, 0, 0, .22);
    backdrop-filter: blur(14px);
}

.generation-orbit {
    position: relative;
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    border: 3px solid color-mix(in srgb, var(--accent) 22%, transparent);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: generation-spin 1s linear infinite;
}

.generation-orbit i { position: absolute; inset: 8px; border-radius: 50%; background: var(--accent-2); opacity: .85; }
.generation-monitor-copy { min-width: 0; display: grid; gap: 3px; flex: 1; }
.generation-monitor-copy strong, .generation-monitor-copy span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.generation-monitor-copy strong { font-size: 13px; }
.generation-monitor-copy span { color: var(--text-muted); font-size: 12px; }
.generation-monitor-copy b { color: var(--accent-2); font-variant-numeric: tabular-nums; }
.generation-monitor-link { color: var(--accent-2); font-size: 12px; font-weight: 800; text-decoration: none; }
@keyframes generation-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .generation-orbit { animation: none; } }

/* Shared UI polish */
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }
body { overflow-x: hidden; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

:where(a, button, input, select, textarea):focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 2px;
}

.public-shell .app-content {
    padding-bottom: calc(32px + env(safe-area-inset-bottom));
}

.public-topbar {
    background: color-mix(in srgb, var(--surface) 88%, transparent);
}

.brand-text { display: grid; line-height: 1.15; }
.brand-text small { color: var(--text-muted); font-size: 10px; font-weight: 500; }

.account-theme-toggle {
    position: fixed;
    top: max(16px, env(safe-area-inset-top));
    left: max(16px, env(safe-area-inset-left));
    z-index: 5;
}

.generation-monitor { z-index: 70; }

@media (min-width: 760px) {
    .app-topbar { padding-inline: max(24px, calc((100vw - 1120px) / 2)); }
    .responsive-date-mobile { display: none; }
    .responsive-date-desktop { display: inline; }
    .app-tabbar {
        right: 50%;
        left: auto;
        width: min(620px, calc(100vw - 32px));
        transform: translateX(50%);
        bottom: 12px;
        height: 58px;
        border: 1px solid var(--border);
        border-radius: 8px;
        overflow: hidden;
        box-shadow: 0 14px 35px rgba(0, 0, 0, .22);
    }
}

@media (max-width: 640px) {
    .topbar-user-info { display: none; }
    .topbar-profile { gap: 0; }
    .topbar-user { gap: 6px; }
    .generation-monitor { right: 12px; left: 12px; width: auto; }
}
