/* ═══════════════════════════════════════════════════════════
   GymRPG — Dark iOS Premium UI
   ═══════════════════════════════════════════════════════════ */

/* ── RESET & ROOT ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:          #000000;
    --surface-1:   #1C1C1E;
    --surface-2:   #2C2C2E;
    --surface-3:   #3A3A3C;
    --accent:      #0A84FF;
    --accent-dim:  rgba(10,132,255,.15);
    --accent-glow: rgba(10,132,255,.35);
    --green:       #30D158;
    --yellow:      #FFD60A;
    --red:         #FF453A;
    --orange:      #FF9F0A;
    --text-1:      #FFFFFF;
    --text-2:      rgba(255,255,255,.6);
    --text-3:      rgba(255,255,255,.35);
    --border:      rgba(255,255,255,.08);
    --glass-bg:    rgba(28,28,30,.72);
    --glass-bdr:   rgba(255,255,255,.1);
    --nav-h:       62px;
    --top-bar-h:   44px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --radius-sm:   12px;
    --radius-md:   16px;
    --radius-lg:   22px;
    --radius-xl:   28px;
}

html { height: 100%; overflow: hidden; }

body {
    height: 100%;
    background: var(--bg);
    color: var(--text-1);
    font-family: 'Outfit', system-ui, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
    user-select: none;
}

/* ── TOP LOGO BAR ──────────────────────────────────────────── */
.top-bar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: calc(var(--top-bar-h) + env(safe-area-inset-top, 0px));
    padding-top: env(safe-area-inset-top, 0px);
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0d1a1a;
    border-bottom: none;
    z-index: 99;
}

.top-logo {
    height: 28px;
    width: auto;
    object-fit: contain;
}

/* ── APP SHELL ─────────────────────────────────────────────── */
#app {
    position: relative;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── VIEWS ─────────────────────────────────────────────────── */
.view {
    position: absolute;
    inset: 0;
    top: calc(var(--top-bar-h) + env(safe-area-inset-top, 0px));
    bottom: var(--nav-h);
    overflow-y: auto;
    overflow-x: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateY(18px);
    transition: opacity .28s cubic-bezier(.4,0,.2,1),
                transform .28s cubic-bezier(.4,0,.2,1);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.view::-webkit-scrollbar { display: none; }

.view.active {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0);
}

.view-inner {
    padding: 0 18px calc(32px + var(--safe-bottom));
    min-height: 100%;
    background: linear-gradient(to bottom, #0d1a1a 0px, #000000 80px);
}

/* ── BOTTOM NAV ────────────────────────────────────────────── */
.bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--nav-h);
    padding-bottom: var(--safe-bottom);
    display: flex;
    align-items: flex-start;
    justify-content: space-around;
    padding-top: 8px;
    background: var(--glass-bg);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border-top: 1px solid var(--glass-bdr);
    z-index: 100;
}

.nav-btn {
    background: none;
    border: none;
    color: var(--text-3);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    cursor: pointer;
    padding: 3px 20px;
    border-radius: var(--radius-md);
    transition: color .2s, transform .15s;
    -webkit-tap-highlight-color: transparent;
}
.nav-btn svg {
    width: 22px; height: 22px;
    transition: transform .2s cubic-bezier(.34,1.56,.64,1);
}
.nav-btn span {
    font-size: 9px;
    font-weight: 600;
    letter-spacing: .03em;
    text-transform: uppercase;
}
.nav-btn.active {
    color: var(--accent);
}
.nav-btn.active svg {
    transform: scale(1.12);
}
.nav-btn:active { transform: scale(.94); }

/* ── SECTION LABEL ─────────────────────────────────────────── */
.section-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .12em;
    color: var(--text-3);
    text-transform: uppercase;
    margin: 24px 0 12px;
}

/* ═══════════════════════════════════════════════════════════
   DASHBOARD
   ═══════════════════════════════════════════════════════════ */

.dash-header {
    padding-top: 20px;
    margin-bottom: 8px;
}

.dash-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 20px;
}

.dash-greeting {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-2);
    margin-bottom: 2px;
}

.dash-username {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 42px;
    line-height: 1;
    letter-spacing: .04em;
    background: linear-gradient(135deg, #fff 0%, rgba(255,255,255,.7) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.dash-avatar {
    width: 52px; height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #5E5CE6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 22px;
    letter-spacing: .05em;
    color: #fff;
    box-shadow: 0 0 0 2px var(--accent-glow);
    flex-shrink: 0;
}

/* XP Bar */
.xp-bar-wrap { margin-bottom: 4px; }
.xp-bar-track {
    height: 6px;
    background: var(--surface-2);
    border-radius: 99px;
    overflow: hidden;
    margin-bottom: 6px;
}
.xp-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #5E5CE6);
    border-radius: 99px;
    width: 0%;
    transition: width .8s cubic-bezier(.4,0,.2,1);
}
.xp-bar-labels {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-3);
}

/* Stats row */
.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin: 20px 0;
}

.stat-card {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    transition: transform .15s;
}
.stat-card.accent {
    background: var(--accent-dim);
    border-color: var(--accent-glow);
}
.stat-card:active { transform: scale(.96); }
.stat-icon { font-size: 22px; line-height: 1; }
.stat-value {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 30px;
    line-height: 1;
    letter-spacing: .04em;
    color: var(--text-1);
}
.stat-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--text-3);
}

/* Suggestion Card */
.suggestion-card {
    position: relative;
    background: var(--surface-1);
    border: 1px solid var(--glass-bdr);
    border-radius: var(--radius-xl);
    padding: 22px 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 8px;
    cursor: pointer;
    transition: transform .18s, box-shadow .18s;
}
.suggestion-card:active { transform: scale(.98); }
.suggestion-card::before {
    content: '';
    position: absolute;
    top: -40px; right: -40px;
    width: 180px; height: 180px;
    background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
    pointer-events: none;
}
.suggestion-bg-orb {
    position: absolute;
    bottom: -60px; left: -20px;
    width: 200px; height: 200px;
    background: radial-gradient(circle, rgba(94,92,230,.2) 0%, transparent 70%);
    pointer-events: none;
}
.suggestion-tag {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .15em;
    color: var(--accent);
    text-transform: uppercase;
}
.suggestion-name {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 28px;
    letter-spacing: .05em;
    line-height: 1.1;
    color: var(--text-1);
}
.suggestion-sub {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-2);
}
.suggestion-cta {
    align-self: flex-start;
    margin-top: 6px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 10px 22px;
    font-family: 'Outfit', sans-serif;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: background .15s, transform .15s;
    -webkit-tap-highlight-color: transparent;
}
.suggestion-cta:active { background: #0070e0; transform: scale(.97); }

/* Muscle Carousel */
.muscle-carousel {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
}
.muscle-carousel::-webkit-scrollbar { display: none; }

.muscle-chip {
    flex: 0 0 auto;
    scroll-snap-align: start;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    min-width: 110px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: transform .15s;
}
.muscle-chip:active { transform: scale(.96); }
.muscle-chip-name {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-2);
}
.muscle-chip-val {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 28px;
    letter-spacing: .04em;
    line-height: 1;
}
.muscle-chip-bar {
    height: 4px;
    background: var(--surface-3);
    border-radius: 99px;
    overflow: hidden;
}
.muscle-chip-bar-fill {
    height: 100%;
    border-radius: 99px;
    transition: width .6s cubic-bezier(.4,0,.2,1);
}
.color-green  { color: var(--green);  }
.color-yellow { color: var(--yellow); }
.color-red    { color: var(--red);    }
.fill-green   { background: var(--green);  }
.fill-yellow  { background: var(--yellow); }
.fill-red     { background: var(--red);    }

/* ═══════════════════════════════════════════════════════════
   LIBRARY
   ═══════════════════════════════════════════════════════════ */

.page-header {
    padding-top: 20px;
    margin-bottom: 20px;
}
.page-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 46px;
    letter-spacing: .04em;
    line-height: 1;
}
.page-sub {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-2);
    margin-top: 4px;
}

.session-list { display: flex; flex-direction: column; gap: 12px; }

.session-card {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    cursor: pointer;
    transition: transform .18s, background .18s;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    overflow: hidden;
}
.session-card:active { transform: scale(.98); background: var(--surface-2); }

.session-icon {
    width: 52px; height: 52px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    flex-shrink: 0;
}
.session-icon.s1 { background: rgba(10,132,255,.15); }
.session-icon.s2 { background: rgba(48,209,88,.15);  }
.session-icon.s3 { background: rgba(255,159,10,.15); }
.session-icon.s4 { background: rgba(191,90,242,.15); }
.session-icon.s5 { background: rgba(255,69,58,.15);  }

.session-info { flex: 1; min-width: 0; }
.session-name {
    font-weight: 700;
    font-size: 15px;
    color: var(--text-1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.session-meta {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-2);
    margin-top: 2px;
}

.session-counter {
    background: var(--surface-3);
    border-radius: 8px;
    padding: 4px 10px;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 18px;
    letter-spacing: .06em;
    color: var(--text-2);
    flex-shrink: 0;
}

.session-suggested-badge {
    position: absolute;
    top: 10px; right: 12px;
    background: var(--accent);
    color: #fff;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
    border-radius: 6px;
    padding: 3px 7px;
}

/* ═══════════════════════════════════════════════════════════
   RULES / RANK
   ═══════════════════════════════════════════════════════════ */

.rank-card {
    background: linear-gradient(135deg, #1C1C1E 0%, #2C2C2E 100%);
    border: 1px solid var(--glass-bdr);
    border-radius: var(--radius-xl);
    padding: 28px 24px;
    position: relative;
    overflow: hidden;
    margin-top: 8px;
}
.rank-card::before {
    content: '';
    position: absolute;
    top: -60px; right: -60px;
    width: 220px; height: 220px;
    background: radial-gradient(circle, var(--accent-glow) 0%, transparent 65%);
    pointer-events: none;
}
.rank-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 16px;
    letter-spacing: .15em;
    color: var(--accent);
    text-transform: uppercase;
    margin-bottom: 4px;
}
.rank-name {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 44px;
    letter-spacing: .06em;
    line-height: 1;
    margin-bottom: 16px;
}
.rank-xp-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}
.rank-xp-bar-track {
    flex: 1;
    height: 8px;
    background: var(--surface-3);
    border-radius: 99px;
    overflow: hidden;
}
.rank-xp-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #5E5CE6);
    border-radius: 99px;
    transition: width .8s;
}
.rank-xp-text {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-2);
    white-space: nowrap;
}

.achievements-list { display: flex; flex-direction: column; gap: 10px; }
.achievement-row {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 14px;
}
.achievement-row.locked { opacity: .4; }
.achievement-icon { font-size: 28px; }
.achievement-info { flex: 1; }
.achievement-name { font-weight: 700; font-size: 14px; }
.achievement-desc { font-size: 12px; font-weight: 500; color: var(--text-2); margin-top: 2px; }
.achievement-xp {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 18px;
    color: var(--yellow);
    letter-spacing: .06em;
}

/* ═══════════════════════════════════════════════════════════
   WORKOUT VIEW
   ═══════════════════════════════════════════════════════════ */

.workout-header {
    padding-top: 20px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 24px;
}
.back-btn {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-1);
    padding: 10px 14px;
    font-family: 'Outfit', sans-serif;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
    line-height: 1;
    transition: background .15s, transform .15s;
    -webkit-tap-highlight-color: transparent;
}
.back-btn:active { background: var(--surface-3); transform: scale(.95); }
.workout-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 26px;
    letter-spacing: .04em;
    line-height: 1.1;
}
.workout-sub { font-size: 13px; font-weight: 500; color: var(--text-2); margin-top: 3px; }

/* Slots */
.slots-list { display: flex; flex-direction: column; gap: 14px; }

.slot-card {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: border-color .2s;
}
.slot-card.done { border-color: rgba(48,209,88,.35); }

.slot-header {
    padding: 14px 16px 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.slot-pattern {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--text-3);
    flex: 1;
}
.slot-done-badge {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .06em;
    color: var(--green);
    opacity: 0;
    transition: opacity .2s;
}
.slot-card.done .slot-done-badge { opacity: 1; }

.slot-options {
    display: flex;
    gap: 8px;
    padding: 0 16px 14px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}
.slot-options::-webkit-scrollbar { display: none; }

.opt-btn {
    flex: 0 0 auto;
    background: var(--surface-2);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    cursor: pointer;
    font-family: 'Outfit', sans-serif;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-1);
    white-space: nowrap;
    transition: background .15s, border-color .15s, transform .12s;
    -webkit-tap-highlight-color: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}
.opt-btn:active { transform: scale(.95); }
.opt-btn.selected {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--text-1);
}
.opt-btn-rep {
    font-size: 10px;
    font-weight: 500;
    color: var(--text-3);
}
.opt-btn.selected .opt-btn-rep { color: var(--accent); }

/* Input panel */
.input-panel {
    margin: 0 16px 16px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px;
    animation: slideDown .22s cubic-bezier(.4,0,.2,1);
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.panel-record {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-3);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.record-val { color: var(--yellow); }

.progression-badge {
    background: rgba(255,214,10,.15);
    border: 1px solid rgba(255,214,10,.35);
    border-radius: 8px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 700;
    color: var(--yellow);
    margin-bottom: 10px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.series-grid {
    display: grid;
    grid-template-columns: auto 1fr 1fr;
    gap: 8px 10px;
    align-items: center;
    margin-bottom: 12px;
}
.series-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
    color: var(--text-3);
    text-transform: uppercase;
}
.series-hdr {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .08em;
    color: var(--text-3);
    text-transform: uppercase;
    text-align: center;
}
.series-input {
    background: var(--surface-1);
    border: 1.5px solid var(--border);
    border-radius: 10px;
    color: var(--text-1);
    font-family: 'Outfit', sans-serif;
    font-size: 15px;
    font-weight: 700;
    text-align: center;
    padding: 10px 6px;
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    transition: border-color .15s;
}
.series-input:focus {
    outline: none;
    border-color: var(--accent);
}
.series-input::placeholder { color: var(--text-3); }

.save-set-btn {
    width: 100%;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 13px;
    font-family: 'Outfit', sans-serif;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: background .15s, transform .15s;
    -webkit-tap-highlight-color: transparent;
}
.save-set-btn:active { background: #0070e0; transform: scale(.98); }

/* Finish button */
.finish-wrap {
    padding: 28px 0 10px;
}
.finish-btn {
    width: 100%;
    background: linear-gradient(135deg, var(--green), #27be4e);
    color: #000;
    border: none;
    border-radius: var(--radius-lg);
    padding: 18px;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 22px;
    letter-spacing: .1em;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: opacity .15s, transform .15s;
    box-shadow: 0 8px 32px rgba(48,209,88,.25);
    -webkit-tap-highlight-color: transparent;
}
.finish-btn:active { opacity: .85; transform: scale(.98); }

/* ═══════════════════════════════════════════════════════════
   TOAST
   ═══════════════════════════════════════════════════════════ */
.toast {
    position: fixed;
    bottom: calc(var(--nav-h) + 16px);
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(44,44,46,.96);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-bdr);
    border-radius: var(--radius-lg);
    padding: 14px 22px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-1);
    white-space: nowrap;
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s, transform .25s cubic-bezier(.34,1.56,.64,1);
    text-align: center;
    max-width: 90vw;
    white-space: normal;
}
.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ═══════════════════════════════════════════════════════════
   MISC UTILS
   ═══════════════════════════════════════════════════════════ */
@media (min-width: 500px) {
    .view-inner { max-width: 480px; margin: 0 auto; }
}

/* safe padding top for status bar */
.view-inner { padding-top: 0; }