*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

:root {
    --bg:        #0F1115;
    --panel:     #1A1D23;
    --panel-2:   #232730;
    --border:    #2C3038;
    --text:      #FFFFFF;
    --muted:     #8E8E93;
    --muted-2:   #5E6470;
    --accent:    #FF6B35;
    --tabbar-h:  68px;
    --radius:    16px;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    overscroll-behavior: none;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; }

.app {
    position: relative;
    height: 100%;
    max-width: 540px;
    margin: 0 auto;
    background: var(--bg);
    overflow: hidden;
}

.view {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
}

/* ===== TOPBAR ===== */
.topbar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: calc(12px + env(safe-area-inset-top)) 18px 12px;
    background: rgba(15,17,21,.92);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--border);
}
.brand {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 18px;
    font-weight: 750;
    letter-spacing: -.3px;
}
.brand-mark { font-size: 20px; line-height: 1; }
.conn-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: #cbd2de; flex-shrink: 0;
    transition: background .3s, box-shadow .3s;
}
.conn-dot.online  { background: #10b981; box-shadow: 0 0 0 3px rgba(16,185,129,.18); }
.conn-dot.offline { background: #f59e0b; box-shadow: 0 0 0 3px rgba(245,158,11,.18); }

.icon-btn {
    width: 38px; height: 38px;
    border: none; background: transparent; border-radius: 12px;
    color: var(--text); font-size: 18px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: background .12s;
}
.icon-btn:active { background: var(--panel-2); }

/* ===== SCROLL ===== */
.scroll {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px 16px calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom));
    min-height: 0;
}

/* ===== HERO ===== */
.hero {
    background: linear-gradient(155deg, #1F232B 0%, #191C22 100%);
    border-radius: var(--radius);
    padding: 20px 20px 18px;
    margin-bottom: 22px;
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
}
.hero::before {
    content: '';
    position: absolute;
    top: -40px; right: -40px;
    width: 160px; height: 160px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255,107,53,.35), transparent 70%);
    pointer-events: none;
}
.hero-label {
    font-size: 11px; font-weight: 700;
    letter-spacing: 1.4px; text-transform: uppercase;
    color: var(--muted); margin-bottom: 8px;
}
.hero-streak {
    font-size: 14px; color: var(--text); margin-bottom: 18px;
}
.hero-streak b { font-weight: 750; }
.hero-title {
    font-size: 26px; font-weight: 800;
    letter-spacing: -.5px; margin-bottom: 12px;
}
.hero-ladder {
    display: flex; flex-wrap: wrap; align-items: center;
    gap: 6px; font-size: 15px; color: var(--muted);
    margin-bottom: 16px;
}
.hero-ladder .set-num { font-weight: 700; color: var(--text); }
.hero-ladder .dot { color: var(--muted-2); }

.hero-progress {
    height: 6px; background: var(--panel-2);
    border-radius: 3px; overflow: hidden;
    margin-bottom: 18px;
}
.hero-progress-fill {
    height: 100%; background: var(--accent);
    border-radius: 3px;
    transition: width .35s cubic-bezier(.32,.72,0,1);
}

.btn-primary {
    width: 100%; height: 54px;
    border: none; border-radius: 14px;
    background: linear-gradient(145deg, #FF8A4C, #FF6B35);
    color: #fff;
    font-size: 15px; font-weight: 750;
    letter-spacing: .3px;
    cursor: pointer;
    box-shadow: 0 8px 22px rgba(255,107,53,.32);
    transition: transform .12s, box-shadow .12s;
}
.btn-primary:active {
    transform: scale(.97);
    box-shadow: 0 4px 12px rgba(255,107,53,.28);
}

/* ===== SECTION HEAD ===== */
.section-head {
    display: flex; align-items: center; justify-content: space-between;
    font-size: 13px; font-weight: 700;
    letter-spacing: .8px; text-transform: uppercase;
    color: var(--muted);
    padding: 0 4px; margin: 22px 0 12px;
}
.section-link {
    color: var(--accent);
    text-transform: none; letter-spacing: 0;
    font-weight: 650; font-size: 13px;
}

/* ===== ZONES ===== */
.zones {
    display: flex; gap: 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0 4px 4px;
    margin: 0 -4px;
    scrollbar-width: none;
}
.zones::-webkit-scrollbar { display: none; }

.zone {
    flex-shrink: 0;
    width: 100px;
    padding: 14px 10px 12px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    color: var(--text);
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    cursor: pointer;
    transition: transform .12s, border-color .15s;
    position: relative; overflow: hidden;
}
.zone::before {
    content: '';
    position: absolute; inset: 0;
    background: var(--zone-color, var(--accent));
    opacity: .10;
    pointer-events: none;
}
.zone:active { transform: scale(.96); }
.zone-emoji { font-size: 22px; line-height: 1; }
.zone-name {
    font-size: 11.5px; font-weight: 650;
    text-align: center; line-height: 1.2;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 100%;
}
.zone-pct {
    font-size: 11px; color: var(--muted);
    font-variant-numeric: tabular-nums;
}

/* ===== PROGRAMS ===== */
.program-card {
    display: flex; gap: 14px; align-items: center;
    padding: 14px 16px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: transform .12s;
    position: relative; overflow: hidden;
}
.program-card::before {
    content: '';
    position: absolute; left: 0; top: 0; bottom: 0;
    width: 4px;
    background: var(--program-color, var(--accent));
}
.program-card:active { transform: scale(.98); }
.program-emoji {
    width: 48px; height: 48px;
    border-radius: 14px;
    background: var(--panel-2);
    display: flex; align-items: center; justify-content: center;
    font-size: 24px; flex-shrink: 0;
}
.program-body { flex: 1; min-width: 0; }
.program-title {
    font-size: 15px; font-weight: 700;
    letter-spacing: -.2px; margin-bottom: 3px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.program-sub {
    font-size: 12.5px; color: var(--muted); margin-bottom: 8px;
}
.program-progress {
    height: 5px; background: var(--panel-2);
    border-radius: 3px; overflow: hidden;
}
.program-progress-fill {
    height: 100%;
    background: var(--program-color, var(--accent));
    border-radius: 3px;
    transition: width .35s cubic-bezier(.32,.72,0,1);
}

/* ===== TABBAR ===== */
.tabbar {
    flex-shrink: 0;
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding: 0 6px env(safe-area-inset-bottom);
    background: rgba(15,17,21,.96);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-top: 1px solid var(--border);
    display: flex; align-items: center;
    z-index: 20;
}
.tab {
    flex: 1; height: 100%;
    border: none; background: transparent;
    color: var(--muted);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; cursor: pointer;
    transition: color .15s;
    font-family: inherit;
}
.tab:active { transform: scale(.94); }
.tab.active { color: var(--accent); }
.tab-icon { font-size: 20px; line-height: 1; }
.tab-label { font-size: 10.5px; font-weight: 650; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: #3A3F48; border-radius: 3px; }
::-webkit-scrollbar-track { background: transparent; }