:root {
            --bg:            #0b1121;
            --nav-bg:        rgba(11,17,33,0.96);
            --overlay-bg:    rgba(11,17,33,0.82);
            --dialog-bg:     rgba(11,17,33,0.88);
            --timer-bg:      rgba(26,34,54,0.97);
            --border:        rgba(255,255,255,0.06);
            --border-mid:    rgba(255,255,255,0.07);
            --set-row-bg:    rgba(0,0,0,0.2);
            --hist-ex-bg:    rgba(255,255,255,0.04);
            --surface:       #1a2236;
            --surface-2:     #243047;
            --surface-3:     #2e3c54;
            --blue:          #3b82f6;
            --blue-light:    #60a5fa;
            --blue-glow:     rgba(59,130,246,0.25);
            --green:         #10b981;
            --green-glow:    rgba(16,185,129,0.25);
            --red:           #ef4444;
            --amber:         #f59e0b;
            --orange:        #f97316;
            --text:          #f1f5f9;
            --text-2:        #94a3b8;
            --text-3:        #64748b;
            --radius:        18px;
            --radius-sm:     12px;
            --radius-xs:     8px;
            --nav-h:         70px;
            --font:          -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
        }

        *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
        html { height: 100%; }
        html.light {
            --bg:        #f1f5f9;
            --surface:   #ffffff;
            --surface-2: #e2e8f0;
            --surface-3: #cbd5e1;
            --text:      #0f172a;
            --text-2:    #475569;
            --text-3:    #94a3b8;
            --blue:      #2563eb;
            --blue-light:#3b82f6;
            --green:     #059669;
            --red:       #dc2626;
            --amber:     #d97706;
            --orange:    #ea580c;
            --nav-bg:        rgba(255,255,255,0.95);
            --overlay-bg:    rgba(100,116,139,0.5);
            --dialog-bg:     rgba(100,116,139,0.6);
            --timer-bg:      rgba(255,255,255,0.97);
            --border:        rgba(0,0,0,0.08);
            --border-mid:    rgba(0,0,0,0.08);
            --set-row-bg:    rgba(0,0,0,0.04);
            --hist-ex-bg:    rgba(0,0,0,0.04);
        }
        body { background: var(--bg); color: var(--text); height: 100%; display: flex; font-family: var(--font); font-size: 16px; font-weight: 400; overflow: hidden; }

        #app { max-width: 600px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; height: 100%; position: relative; background: var(--bg); }

        /* ─── SCROLLABLE MAIN ─────────────────────── */
        main { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 0 16px calc(var(--nav-h) + 100px); -webkit-overflow-scrolling: touch; scroll-behavior: smooth; }

        /* ─── TYPOGRAPHY ──────────────────────────── */
        .title-lg  { font-size: 1.5rem;  font-weight: 700; letter-spacing: -0.3px; }
        .title-md  { font-size: 1.2rem;  font-weight: 700; }
        .title-sm  { font-size: 1rem;    font-weight: 600; }
        .label     { font-size: 0.8rem;  font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-2); }
        .muted     { color: var(--text-2); }
        .mono      { font-family: "SF Mono", "Fira Code", monospace; }
        strong     { font-weight: 700; }

        /* ─── VIEWS ───────────────────────────────── */
        .view { display: none; padding-top: 8px; animation: fadeUp 0.2s ease; }
        .view.active { display: block; }
        @keyframes fadeUp { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:translateY(0); } }

        /* ─── HEADER ──────────────────────────────── */
        header { padding: 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-shrink: 0; }
        header h1 { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.2px; }
        #user-pill { font-size: 0.8rem; color: var(--text-2); font-weight: 600; background: var(--surface); padding: 6px 12px; border-radius: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 140px; }
        #help-btn { display: none; width: 36px; height: 36px; padding: 0; border: none; border-radius: 50%; background: var(--surface-2); color: var(--text-2); font-size: 1rem; cursor: pointer; transition: all 0.15s; box-shadow: none; justify-content: center; align-items: center; flex-shrink: 0; }
        #help-btn:hover { color: var(--blue-light); background: var(--surface-3); }

        /* ─── NAV ─────────────────────────────────── */
        nav { position: absolute; bottom: 0; width: 100%; height: var(--nav-h); background: var(--nav-bg); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); display: flex; justify-content: space-around; align-items: center; z-index: 10; border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); padding: 0 8px env(safe-area-inset-bottom); }
        .nav-item { color: var(--text-3); display: flex; flex-direction: column; align-items: center; justify-content: center; flex: 1; height: 100%; text-decoration: none; font-size: 0.7rem; font-weight: 600; gap: 5px; cursor: pointer; transition: color 0.2s; letter-spacing: 0.02em; }
        .nav-item i { font-size: 1.25rem; transition: transform 0.2s; }
        .nav-item.active { color: var(--blue); }
        .nav-item.active i { transform: translateY(-2px); }

        /* ─── CARDS ───────────────────────────────── */
        .card { background: var(--surface); border-radius: var(--radius); padding: 20px; margin-bottom: 14px; border: 1px solid var(--border); }
        .card-accent-blue { border-left: 3px solid var(--blue); }
        .card-accent-green { border-left: 3px solid var(--green); }
        .card-accent-amber { border-left: 3px solid var(--amber); }

        /* ─── BUTTONS ─────────────────────────────── */
        button { font-family: var(--font); border: none; cursor: pointer; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: transform 0.12s, opacity 0.15s, box-shadow 0.15s; width: 100%; padding: 15px 20px; border-radius: var(--radius-sm); font-size: 1rem; }
        button:active { transform: scale(0.95) !important; opacity: 0.88; }
        button:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; }

        .btn-primary { background: var(--blue); color: #fff; box-shadow: 0 4px 16px var(--blue-glow); }
        .btn-primary:active { box-shadow: none; }
        .btn-success { background: var(--green); color: #fff; box-shadow: 0 4px 16px var(--green-glow); }
        .btn-success:active { box-shadow: none; }
        .btn-secondary { background: var(--surface-2); color: var(--text); box-shadow: none; }
        .btn-ghost { background: transparent; color: var(--text-2); box-shadow: none; border: 1.5px solid var(--surface-3); }
        .btn-danger { background: rgba(239,68,68,0.12); color: var(--red); box-shadow: none; border: 1.5px solid rgba(239,68,68,0.25); }

        /* icon buttons */
        .ibtn { width: 40px; height: 40px; padding: 0; border-radius: var(--radius-xs); font-size: 1rem; background: var(--surface-2); color: var(--text); box-shadow: none; flex-shrink: 0; }
        .ibtn.danger { background: rgba(239,68,68,0.12); color: var(--red); }
        .ibtn.success { background: rgba(16,185,129,0.12); color: var(--green); }
        .ibtn.primary { background: rgba(59,130,246,0.15); color: var(--blue-light); }
        .ibtn:active { transform: scale(0.82) !important; }

        /* ─── FORMS ───────────────────────────────── */
        input, select, textarea {
            width: 100%; padding: 14px 16px; border-radius: var(--radius-sm);
            border: 1.5px solid rgba(255,255,255,0.07); background: var(--surface-2);
            color: var(--text); font-size: 16px; font-family: var(--font);
            transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
            margin-bottom: 14px; appearance: none; -webkit-appearance: none;
        }
        input[type="checkbox"] { appearance: auto; -webkit-appearance: auto; width: 18px; height: 18px; margin: 0 10px 0 0; flex-shrink: 0; accent-color: var(--blue); cursor: pointer; border-radius: 4px; }
        input:focus, select:focus, textarea:focus {
            outline: none; border-color: var(--blue); background: var(--surface-3);
            box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
        }
        input[type="checkbox"] { width: 20px; height: 20px; margin: 0 10px 0 0; flex-shrink: 0; accent-color: var(--blue); cursor: pointer; border-radius: 5px; }
        input::placeholder, textarea::placeholder { color: var(--text-3); }
        textarea { resize: none; }

        .field-row { position: relative; display: flex; align-items: center; margin-bottom: 14px; }
        .field-row input, .field-row select { margin-bottom: 0; }
        .field-clear { position: absolute; right: 12px; color: var(--text-3); cursor: pointer; font-size: 1.1rem; padding: 6px; opacity: 0; pointer-events: none; transition: opacity 0.15s; z-index: 5; line-height: 1; }
        .field-row input:not(:placeholder-shown) + .field-clear { opacity: 1; pointer-events: auto; }
        .field-row input { padding-right: 42px; }

        /* ─── BADGE / CHIP ────────────────────────── */
        .chip { display: inline-flex; align-items: center; gap: 6px; background: var(--surface-2); border-radius: 20px; padding: 7px 13px; font-size: 0.82rem; font-weight: 600; cursor: pointer; transition: all 0.15s; border: 1.5px solid transparent; white-space: nowrap; flex-shrink: 0; }
        .chip:active { transform: scale(0.9); }
        .chip.active { background: rgba(59,130,246,0.15); color: var(--blue-light); border-color: rgba(59,130,246,0.3); }

        /* ─── MODALS ──────────────────────────────── */
        .overlay { position: absolute; inset: 0; background: var(--overlay-bg); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); display: none; flex-direction: column; justify-content: flex-end; z-index: 200; }
        .overlay.open { display: flex; animation: overlayIn 0.2s ease; }
        @keyframes overlayIn { from { opacity:0; } to { opacity:1; } }
        .sheet { background: var(--bg); border-top-left-radius: 28px; border-top-right-radius: 28px; padding: 24px 20px; max-height: 92%; overflow-y: auto; box-shadow: 0 -16px 48px rgba(0,0,0,0.5); display: flex; flex-direction: column; gap: 14px; animation: sheetUp 0.28s cubic-bezier(0.34,1.1,0.64,1); }
        @keyframes sheetUp { from { transform:translateY(60px); opacity:0; } to { transform:translateY(0); opacity:1; } }
        .sheet-handle { width: 36px; height: 4px; background: var(--surface-3); border-radius: 2px; margin: -8px auto 8px; flex-shrink: 0; }
        .sheet-header { display: flex; justify-content: space-between; align-items: center; }
        .sheet-header h2 { font-size: 1.3rem; font-weight: 700; }

        /* ─── DIALOG ──────────────────────────────── */
        #dialog-overlay { position: absolute; inset: 0; background: var(--dialog-bg); backdrop-filter: blur(10px); display: none; flex-direction: column; justify-content: center; align-items: center; z-index: 500; padding: 24px; }
        #dialog-overlay.open { display: flex; animation: dialogPop 0.22s cubic-bezier(0.34,1.2,0.64,1); }
        @keyframes dialogPop { from { opacity:0; transform:scale(0.92); } to { opacity:1; transform:scale(1); } }
        .dialog-box { background: var(--surface); border-radius: 24px; padding: 28px 22px; width: 100%; max-width: 340px; border: 1px solid rgba(255,255,255,0.08); text-align: center; display: flex; flex-direction: column; gap: 18px; }
        .dialog-box h3 { font-size: 1.1rem; font-weight: 700; line-height: 1.4; }

        /* ─── AUTH SCREEN ─────────────────────────── */
        #auth-screen { position: absolute; inset: 0; background: var(--bg); z-index: 300; display: flex; flex-direction: column; justify-content: center; padding: 32px 24px; }
        #auth-screen.gone { display: none; }
        .auth-logo { text-align: center; margin-bottom: 36px; }
        .auth-logo i { font-size: 2.5rem; color: var(--blue); margin-bottom: 12px; display: block; }
        .auth-logo h1 { font-size: 2rem; font-weight: 800; letter-spacing: -0.5px; }
        .auth-logo p { color: var(--text-2); margin-top: 6px; font-size: 0.95rem; }

        /* ─── BANNER ──────────────────────────────── */
        #banner { position: absolute; bottom: calc(var(--nav-h) + 10px); left: 12px; right: 12px; background: linear-gradient(135deg, #1d4ed8, #3b82f6); border-radius: 16px; padding: 12px 14px; z-index: 9; display: none; justify-content: space-between; align-items: center; box-shadow: 0 8px 24px rgba(59,130,246,0.35); gap: 12px; }

        /* ─── STREAK STRIP ────────────────────────── */
        #streak-strip { display: flex; gap: 8px; margin-bottom: 16px; overflow-x: auto; padding-bottom: 2px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
        #streak-strip::-webkit-scrollbar { display: none; }

        /* ─── ROUTINE CARD ────────────────────────── */
        .routine-card { background: var(--surface); border-radius: var(--radius); padding: 18px; margin-bottom: 12px; border: 1px solid var(--border); border-left: 3px solid var(--blue); transition: border-color 0.2s; }
        .routine-card-top { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
        .routine-card-info { flex: 1; min-width: 0; cursor: pointer; }
        .routine-card-info h3 { font-size: 1.1rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
        .routine-card-info p { font-size: 0.85rem; color: var(--text-2); margin-top: 4px; }
        .routine-card-bottom { display: flex; justify-content: space-between; align-items: center; padding-top: 12px; border-top: 1px solid var(--border); }

        /* ─── HISTORY CARD ────────────────────────── */
        .hist-card { background: var(--surface); border-radius: var(--radius); padding: 18px; margin-bottom: 12px; border: 1px solid var(--border); }
        .hist-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; cursor: pointer; }
        .hist-card-info h3 { font-size: 1.05rem; font-weight: 700; color: var(--blue-light); line-height: 1.3; }
        .hist-card-info .meta { font-size: 0.82rem; color: var(--text-2); margin-top: 5px; display: flex; flex-wrap: wrap; gap: 10px; }
        .hist-card-info .meta span { display: flex; align-items: center; gap: 4px; }
        .hist-actions { display: flex; gap: 8px; flex-shrink: 0; }
        .hist-menu { position:absolute; right:0; top:42px; background:var(--surface); border:1px solid var(--border-mid); border-radius:14px; z-index:50; min-width:170px; overflow:hidden; box-shadow:0 12px 32px rgba(0,0,0,0.5); }
        .hist-menu-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 13px 16px; background: none; border: none; border-bottom:1px solid var(--border); color: var(--text-1); font-size: 0.88rem; font-weight:500; cursor: pointer; text-align: left; }
        .hist-menu-item:last-child { border-bottom:none; }
        .hist-menu-item:active { background: var(--surface-2); }
        .hist-menu-item.danger { color: var(--red); }
        .hist-menu-item i { width: 15px; text-align: center; font-size:0.85rem; opacity: 0.8; }
        .hist-details { display: none; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
        .hist-details.open { display: block; animation: fadeUp 0.2s ease; }
        .hist-ex-row { background: var(--hist-ex-bg); padding: 10px 12px; border-radius: var(--radius-xs); margin-bottom: 8px; }
        .hist-ex-row:last-child { margin-bottom: 0; }
        /* Data tab */
        .data-section-label { font-size:0.72rem; font-weight:700; letter-spacing:1px; text-transform:uppercase; color:var(--text-2); padding:0 2px; margin:20px 0 10px; }
        .stat-tile { background:var(--surface); border-radius:14px; padding:16px 12px; text-align:center; border:1px solid var(--border); }
        .stat-tile-val { font-size:1.3rem; font-weight:800; font-family:monospace; color:var(--text); }
        .stat-tile-icon { font-size:1rem; display:block; margin-bottom:6px; }
        .stat-tile-label { font-size:0.68rem; color:var(--text-2); margin-top:4px; font-weight:600; text-transform:uppercase; letter-spacing:0.05em; }
        /* Data tab bar */
        .data-tabs { display:flex; gap:0; background:var(--surface); border-bottom:1px solid var(--border-mid); position:sticky; top:0; z-index:10; overflow:hidden; }
        .data-tab { flex:1; padding:13px 4px; font-size:0.82rem; font-weight:600; background:none; border:none; color:var(--text-2); cursor:pointer; border-bottom:2px solid transparent; margin-bottom:-1px; transition:color 0.15s, border-color 0.15s; }
        .data-tab.active { color:var(--blue-light); border-bottom-color:var(--blue-light); }
        .data-tab-panel { display:block; }

        /* ─── PRE-WORKOUT SETUP ───────────────────── */
        .rating-row { display: flex; gap: 8px; }
        .rating-btn { flex: 1; height: 52px; border-radius: 14px; background: var(--surface-2); color: var(--text-2); font-size: 1.1rem; font-weight: 700; cursor: pointer; transition: all 0.2s; border: 2px solid transparent; box-shadow: none; }
        .rating-btn.on { background: var(--blue); color: #fff; border-color: transparent; transform: scale(1.06); box-shadow: 0 4px 14px var(--blue-glow); }

        /* ─── TIMER BAR ───────────────────────────── */
        #timer-bar { position: sticky; top: 0; z-index: 5; background: var(--timer-bg); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-radius: 18px; border: 1px solid var(--border-mid); padding: 12px 14px; margin: 8px 0 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
        #timer-bar .time-col { min-width: 80px; }
        #workout-time { font-family: "SF Mono","Fira Code",monospace; font-size: 1.4rem; font-weight: 700; letter-spacing: 0.05em; }
        #rest-display { font-size: 0.85rem; font-weight: 600; color: var(--blue-light); font-family: "SF Mono","Fira Code",monospace; margin-top: 3px; min-height: 18px; }

        .rest-presets { display: flex; gap: 5px; margin-bottom: 6px; }
        .rp-btn { width: auto; padding: 0 10px; height: 32px; font-size: 0.8rem; font-weight: 700; border-radius: 8px; background: var(--surface-3); color: var(--text-2); box-shadow: none; flex-shrink: 0; transition: all 0.15s; border: 1.5px solid transparent; }
        .rp-btn.lit { background: rgba(59,130,246,0.2); color: var(--blue-light); border-color: rgba(59,130,246,0.35); }

        .custom-rest-row { display: flex; gap: 6px; align-items: center; }
        .custom-rest-row input { width: 60px; height: 32px; padding: 0 6px; margin-bottom: 0; text-align: center; border-radius: 8px; font-size: 0.85rem; }

        /* ─── SET ROW ─────────────────────────────── */
        .set-block { margin-bottom: 12px; }
        .set-row { display: grid; grid-template-columns: 38px 1fr 1fr 32px 32px; gap: 5px; align-items: center; background: var(--set-row-bg); padding: 7px 8px; border-radius: 14px; border: 1.5px solid transparent; transition: all 0.25s; }
        .set-row.done { background: rgba(16,185,129,0.07); border-color: rgba(16,185,129,0.15); }
        .set-row input { margin-bottom: 0; text-align: center; padding: 10px 4px; border-radius: 9px; font-weight: 600; font-size: 0.95rem; }
        .set-row.done input { color: var(--green); }

        .type-btn { height: 36px; border-radius: 9px; background: var(--surface-3); color: var(--text-2); font-weight: 700; font-size: 0.78rem; cursor: pointer; user-select: none; transition: all 0.15s; display: flex; align-items: center; justify-content: center; box-shadow: none; }
        .type-btn:active { transform: scale(0.88) !important; }
        .type-btn.warmup  { background: rgba(245,158,11,0.2);  color: var(--amber); }
        .type-btn.drop    { background: rgba(249,115,22,0.2);  color: var(--orange); }
        .type-btn.failure { background: rgba(239,68,68,0.2);   color: var(--red); }

        .sib { width: 32px; height: 32px; padding: 0; border-radius: 8px; font-size: 0.78rem; box-shadow: none; flex-shrink: 0; }
        .sib.copy { background: rgba(59,130,246,0.12); color: var(--blue-light); }
        .sib.del  { background: rgba(239,68,68,0.12);  color: var(--red); }

        .rm-line { font-size: 0.72rem; color: var(--text-3); text-align: center; min-height: 13px; margin: 2px 0 8px; font-weight: 500; }


        /* ─── EXERCISE BLOCK ──────────────────────── */
        .ex-block { background: var(--surface); border-radius: var(--radius); padding: 16px; border: 1px solid var(--border); }
        .ex-block-header { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
        .ex-title { flex: 1; font-weight: 700; font-size: 1rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
        .ex-title { font-size: 1.05rem; font-weight: 700; color: var(--blue-light); flex: 1; line-height: 1.3; transition: all 0.3s; }
        .ex-title.pr { color: var(--green); text-shadow: 0 0 12px rgba(16,185,129,0.4); }
        .ex-actions { display: flex; gap: 8px; flex-shrink: 0; }

        .add-set-btn { width: 100%; padding: 10px; margin-top: 8px; background: transparent; color: var(--text-3); border: 1.5px dashed var(--surface-3); border-radius: 10px; font-size: 0.9rem; font-weight: 600; box-shadow: none; transition: all 0.2s; }
        .add-set-btn:hover { color: var(--text-2); border-color: var(--surface-2); }

        /* ─── TOTAL VOLUME CARD ───────────────────── */
        #vol-card { background: var(--surface); border-radius: var(--radius); padding: 20px; border: 1px solid var(--border); margin-top: 4px; }
        .vol-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 16px; }
        .vol-label { font-size: 0.9rem; color: var(--text-2); font-weight: 500; }
        #live-volume { font-family: "SF Mono","Fira Code",monospace; font-size: 1.6rem; font-weight: 800; color: var(--blue-light); }

        /* ─── ANALYTICS ───────────────────────────── */
        .pr-item { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); }
        .pr-item:last-child { border-bottom: none; }
        .pr-weight { font-family: "SF Mono","Fira Code",monospace; font-weight: 700; font-size: 1rem; color: var(--green); }

        #bw-chart-wrap { height: 150px; margin-top: 10px; position: relative; }

        /* ─── DATA TAB OVERHAUL ───────────────────── */
        /* Hero number card */
        .data-hero-card { background: linear-gradient(135deg, rgba(59,130,246,0.15) 0%, rgba(59,130,246,0.04) 100%); border-radius: var(--radius); padding: 22px 20px; margin-bottom: 10px; border: 1px solid rgba(59,130,246,0.2); position: relative; overflow: hidden; }
        .data-hero-card::before { content:''; position:absolute; top:-30px; right:-30px; width:120px; height:120px; background: radial-gradient(circle, rgba(59,130,246,0.2) 0%, transparent 70%); pointer-events:none; }
        .data-hero-label { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--blue-light); margin-bottom: 6px; }
        .data-hero-val { font-size: 2.6rem; font-weight: 800; font-family: "SF Mono","Fira Code",monospace; color: var(--text); line-height: 1; letter-spacing: -1px; }
        .data-hero-sub { font-size: 0.8rem; color: var(--text-2); margin-top: 6px; }

        /* Stat tile rows */
        .stat-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
        .stat-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 8px; }
        .stat-tile-v2 { background: var(--surface); border-radius: 14px; padding: 14px 12px 12px; border: 1px solid var(--border); position: relative; overflow: hidden; }
        .stat-tile-v2::after { content:''; position:absolute; bottom:0; left:0; right:0; height:2px; }
        .stat-tile-v2.blue::after { background: var(--blue); }
        .stat-tile-v2.green::after { background: var(--green); }
        .stat-tile-v2.amber::after { background: var(--amber); }
        .stat-tile-v2.purple::after { background: #a855f7; }
        .stat-tile-v2.orange::after { background: var(--orange); }
        .stv2-icon { font-size: 0.82rem; margin-bottom: 8px; }
        .stv2-val { font-size: 1.25rem; font-weight: 800; font-family: "SF Mono","Fira Code",monospace; color: var(--text); line-height: 1; }
        .stv2-label { font-size: 0.65rem; color: var(--text-2); margin-top: 4px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }

        /* Section label accent */
        .data-section-label { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-2); margin: 18px 0 10px; padding-left: 10px; border-left: 2px solid var(--blue); }
        .data-section-label.green { border-left-color: var(--green); }
        .data-section-label.purple { border-left-color: #a855f7; }
        .data-section-label.amber { border-left-color: var(--amber); }

        /* Activity heatmap */
        .heatmap-grid { display: grid; grid-template-columns: repeat(13, 1fr); gap: 3px; margin-top: 4px; }
        .heatmap-cell { aspect-ratio: 1; border-radius: 3px; background: var(--surface-2); transition: transform 0.1s; }
        .heatmap-cell.l1 { background: rgba(59,130,246,0.25); }
        .heatmap-cell.l2 { background: rgba(59,130,246,0.5); }
        .heatmap-cell.l3 { background: rgba(59,130,246,0.75); }
        .heatmap-cell.l4 { background: var(--blue); }
        .heatmap-cell.today { box-shadow: 0 0 0 1.5px var(--blue-light); }
        .heatmap-months { display: flex; justify-content: space-between; margin-bottom: 4px; }
        .heatmap-month-label { font-size: 0.62rem; color: var(--text-3); font-weight: 600; }

        /* PR cards */
        .pr-card { background: var(--surface); border-radius: 14px; padding: 14px; border: 1px solid var(--border); margin-bottom: 8px; display: flex; align-items: center; gap: 12px; }
        .pr-card-rank { width: 32px; height: 32px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 0.85rem; font-weight: 800; flex-shrink: 0; }
        .pr-card-rank.gold { background: rgba(245,158,11,0.15); color: var(--amber); }
        .pr-card-rank.silver { background: rgba(148,163,184,0.15); color: #94a3b8; }
        .pr-card-rank.bronze { background: rgba(249,115,22,0.12); color: var(--orange); }
        .pr-card-rank.default { background: var(--surface-2); color: var(--text-3); }
        .pr-card-body { flex: 1; min-width: 0; }
        .pr-card-name { font-weight: 700; font-size: 0.92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
        .pr-card-chips { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 5px; }
        .pr-chip { border-radius: 6px; padding: 2px 7px; font-size: 0.72rem; font-weight: 700; white-space: nowrap; border: 1px solid var(--border); }
        .pr-chip.weight { background: rgba(245,158,11,0.1); color: var(--amber); border-color: rgba(245,158,11,0.2); }
        .pr-chip.orm { background: rgba(59,130,246,0.1); color: var(--blue-light); border-color: rgba(59,130,246,0.2); }
        .pr-chip.vol { background: rgba(16,185,129,0.1); color: var(--green); border-color: rgba(16,185,129,0.2); }

        /* Exercise deep-dive summary */
        .ex-summary-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; margin-bottom: 14px; }
        .ex-summary-cell { background: var(--surface-2); border-radius: 10px; padding: 10px 8px; text-align: center; }
        .ex-summary-val { font-size: 0.95rem; font-weight: 800; font-family: monospace; color: var(--text); }
        .ex-summary-lbl { font-size: 0.62rem; color: var(--text-2); margin-top: 3px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }

        /* Volume by exercise bars */
        .vol-bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
        .vol-bar-label { font-size: 0.78rem; font-weight: 600; color: var(--text); width: 110px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-shrink: 0; }
        .vol-bar-track { flex: 1; height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
        .vol-bar-fill { height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--blue), var(--blue-light)); transition: width 0.6s cubic-bezier(0.34,1.2,0.64,1); }
        .vol-bar-num { font-size: 0.72rem; font-weight: 700; color: var(--text-2); font-family: monospace; width: 52px; text-align: right; flex-shrink: 0; }

        /* Strength-to-weight card */
        .stw-card { background: var(--surface); border-radius: 14px; padding: 18px; border: 1px solid var(--border); margin-bottom: 8px; }
        .stw-ratio { font-size: 2.2rem; font-weight: 800; font-family: monospace; color: var(--amber); }
        .stw-label { font-size: 0.75rem; color: var(--text-2); margin-top: 4px; }

        /* Ratio leaderboard */
        .ratio-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); }
        .ratio-row:last-child { border-bottom: none; }
        .ratio-ex-name { font-size: 0.88rem; font-weight: 600; color: var(--text); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
        .ratio-val { font-size: 0.9rem; font-weight: 800; font-family: monospace; color: var(--amber); margin-left: 10px; flex-shrink: 0; }

        /* BW current display */
        .bw-current { font-size: 2rem; font-weight: 800; font-family: monospace; color: var(--green); }
        .bw-meta { font-size: 0.78rem; color: var(--text-2); margin-top: 2px; }
        .bw-delta { font-size: 0.82rem; font-weight: 700; margin-top: 8px; }
        .bw-delta.up { color: var(--red); }
        .bw-delta.down { color: var(--green); }
        .bw-delta.flat { color: var(--text-2); }

        /* ─── SETTINGS ────────────────────────────── */
        .settings-section { background: var(--surface); border-radius: var(--radius); padding: 20px; margin-bottom: 14px; border: 1px solid rgba(255,255,255,0.05); }
        .settings-section h3 { font-size: 0.95rem; font-weight: 700; color: var(--text); margin-bottom: 4px; }
        .settings-section p { font-size: 0.83rem; color: var(--text-2); margin-bottom: 14px; line-height: 1.5; }
        .setting-row { display: flex; align-items: center; gap: 10px; }
        .setting-row input { margin-bottom: 0; flex: 1; }

        /* ─── SORTABLE ────────────────────────────── */
        .drag-handle { color: var(--text-3); font-size: 1.1rem; padding: 6px; cursor: grab; transition: color 0.15s; }
        .drag-handle:active { cursor: grabbing; color: var(--blue-light); }
        .sortable-ghost { opacity: 0.35; border-color: var(--blue) !important; }

        /* ─── EMPTY STATES ────────────────────────── */
        .empty-state { text-align: center; padding: 48px 24px; color: var(--text-2); }
        .empty-state i { font-size: 2.8rem; color: var(--surface-3); display: block; margin-bottom: 14px; }
        .empty-state p { font-size: 1rem; line-height: 1.6; }

        /* ─── TUTORIAL ────────────────────────────── */
        #tutorial-overlay { position: absolute; inset: 0; background: var(--bg); z-index: 400; display: flex; flex-direction: column; overflow-y: auto; -webkit-overflow-scrolling: touch; }
        #tutorial-overlay.hidden { display: none; }
        .tut-inner { padding: 36px 24px 60px; }
        .tut-hero { text-align: center; margin-bottom: 32px; }
        .tut-hero .emoji { font-size: 3rem; display: block; margin-bottom: 14px; }
        .tut-hero h2 { font-size: 1.5rem; font-weight: 800; margin-bottom: 8px; letter-spacing: -0.3px; }
        .tut-hero p { font-size: 0.9rem; color: var(--text-2); line-height: 1.6; }
        .tut-tabs { display: flex; border-radius: 14px; overflow: hidden; background: var(--surface); margin-bottom: 28px; padding: 4px; gap: 4px; }
        .tut-tab { flex: 1; padding: 11px 8px; font-weight: 700; font-size: 0.9rem; cursor: pointer; text-align: center; background: transparent; color: var(--text-2); border: none; border-radius: 10px; box-shadow: none; transition: all 0.2s; gap: 6px; }
        .tut-tab.on { background: var(--blue); color: #fff; }
        .tut-tab:active { transform: none !important; opacity: 0.9; }
        .tut-platform { display: none; flex-direction: column; gap: 18px; }
        .tut-platform.on { display: flex; animation: fadeUp 0.2s ease; }
        .tut-step { display: flex; gap: 14px; }
        .tut-num { width: 34px; height: 34px; border-radius: 50%; background: var(--blue); color: #fff; font-weight: 800; font-size: 0.9rem; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 1px; }
        .tut-body h4 { font-size: 0.95rem; font-weight: 700; margin-bottom: 4px; }
        .tut-body p { font-size: 0.85rem; color: var(--text-2); line-height: 1.55; }
        .tut-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--surface-2); border-radius: 9px; padding: 6px 11px; margin-top: 8px; font-size: 0.82rem; font-weight: 600; color: var(--text); }
        .tut-chip i { color: var(--blue-light); }
        .tut-actions { margin-top: 36px; display: flex; flex-direction: column; gap: 10px; }

        /* ─── UTILITIES ───────────────────────────── */
        .hidden { display: none !important; }
        .flex { display: flex; }
        .flex-col { display: flex; flex-direction: column; }
        .gap-1 { gap: 8px; }
        .gap-2 { gap: 14px; }
        .items-center { align-items: center; }
        .justify-between { justify-content: space-between; }
        .mt-1 { margin-top: 8px; }
        .mt-2 { margin-top: 14px; }
        .mb-1 { margin-bottom: 8px; }
        .mb-2 { margin-bottom: 14px; }
        .text-center { text-align: center; }
        .w-full { width: 100%; }
        .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
        .scroll-x { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
        .scroll-x::-webkit-scrollbar { display: none; }

        /* Settings groups */
        /* ─── SETTINGS REDESIGN ───────────────────── */
        .settings-group-label { font-size:0.72rem; font-weight:700; letter-spacing:1px; text-transform:uppercase; color:var(--text-2); padding:0 4px; margin:20px 0 8px; }
        .settings-group { background:var(--surface); border-radius:16px; overflow:hidden; margin-bottom:4px; }
        .settings-row { display:flex; align-items:center; justify-content:space-between; padding:14px 16px; gap:12px; border-bottom:1px solid var(--border-mid); }
        .settings-row:last-child { border-bottom:none; }
        .settings-row-left { display:flex; align-items:center; gap:10px; font-size:0.9rem; font-weight:500; flex:1; min-width:0; }
        .settings-row-left i { width:16px; text-align:center; color:var(--text-2); font-size:0.85rem; }

        /* New icon-badge row system */
        .s-section { margin-bottom:6px; }
        .s-section-label { font-size:0.68rem; font-weight:700; letter-spacing:0.09em; text-transform:uppercase; color:var(--text-3); padding:0 6px; margin:22px 0 8px; }
        .s-group { background:var(--surface); border-radius:18px; overflow:hidden; border:1px solid var(--border); }
        .s-row { display:flex; align-items:center; gap:14px; padding:13px 16px; border-bottom:1px solid var(--border-mid); transition:background 0.15s; cursor:default; }
        .s-row:last-child { border-bottom:none; }
        .s-row.tappable { cursor:pointer; }
        .s-row.tappable:active { background:var(--surface-2); }
        .s-row.expandable { cursor:pointer; }
        .s-row.expandable:active { background:var(--surface-2); }
        .s-icon { width:36px; height:36px; border-radius:10px; display:flex; align-items:center; justify-content:center; font-size:0.95rem; flex-shrink:0; }
        .s-icon.blue   { background:rgba(59,130,246,0.15);  color:var(--blue-light); }
        .s-icon.green  { background:rgba(16,185,129,0.15);  color:var(--green); }
        .s-icon.purple { background:rgba(168,85,247,0.15);  color:#a855f7; }
        .s-icon.amber  { background:rgba(245,158,11,0.15);  color:var(--amber); }
        .s-icon.orange { background:rgba(249,115,22,0.15);  color:var(--orange); }
        .s-icon.red    { background:rgba(239,68,68,0.12);   color:var(--red); }
        .s-icon.slate  { background:var(--surface-2);       color:var(--text-2); }
        .s-text { flex:1; min-width:0; }
        .s-text-title { font-size:0.92rem; font-weight:600; color:var(--text); }
        .s-text-sub { font-size:0.75rem; color:var(--text-2); margin-top:2px; line-height:1.4; }
        .s-control { flex-shrink:0; }
        .s-chevron { color:var(--text-3); font-size:0.78rem; flex-shrink:0; }
        .s-expand-body { display:none; padding:0 16px 16px; border-top:1px solid var(--border); background:var(--surface); }
        .s-expand-body.open { display:block; animation:fadeUp 0.18s ease; }

        /* Pill toggle group */
        .pill-group { display:flex; background:var(--surface-2); border-radius:10px; padding:3px; gap:3px; }
        .pill-btn { flex:1; padding:7px 10px; border-radius:8px; font-size:0.82rem; font-weight:700; background:transparent; color:var(--text-2); box-shadow:none; transition:all 0.15s; }
        .pill-btn.on { background:var(--surface-3); color:var(--text); box-shadow:0 1px 4px rgba(0,0,0,0.2); }
        .pill-btn:active { transform:none !important; }

        /* Accent color swatches */
        .accent-swatches { display:flex; gap:10px; padding:14px 0 4px; }
        .accent-swatch { width:34px; height:34px; border-radius:50%; cursor:pointer; transition:transform 0.15s; border:2px solid transparent; flex-shrink:0; }
        .accent-swatch.on { transform:scale(1.18); border-color:var(--text); }
        .accent-swatch:active { transform:scale(0.9); }

        /* Custom exercise list in settings */
        .custom-ex-item { display:flex; align-items:center; gap:10px; padding:10px 0; border-bottom:1px solid var(--border); }
        .custom-ex-item:last-child { border-bottom:none; }
        .custom-ex-name { flex:1; font-size:0.88rem; font-weight:600; color:var(--text); }
        .custom-ex-group-badge { font-size:0.7rem; font-weight:700; color:var(--text-3); background:var(--surface-2); border-radius:5px; padding:2px 7px; white-space:nowrap; }

        /* Danger zone */
        .s-danger-title { color:var(--red) !important; }

        /* acc- classes kept for any legacy references */
        .acc-section { background:var(--surface); border-radius:var(--radius); margin-bottom:10px; border:1px solid var(--border); overflow:hidden; }
        .acc-header { display:flex; align-items:center; gap:12px; padding:16px 18px; cursor:pointer; user-select:none; -webkit-user-select:none; }
        .acc-header-icon { width:34px; height:34px; border-radius:10px; display:flex; align-items:center; justify-content:center; font-size:0.95rem; flex-shrink:0; }
        .acc-header-text { flex:1; }
        .acc-header-text h3 { font-size:0.95rem; font-weight:700; color:var(--text); }
        .acc-header-text p { font-size:0.78rem; color:var(--text-2); margin-top:2px; }
        .acc-chevron { color:var(--text-3); font-size:0.8rem; transition:transform 0.2s; flex-shrink:0; }
        .acc-section.open .acc-chevron { transform:rotate(180deg); }
        .acc-body { display:none; padding:0 18px 18px; border-top:1px solid var(--border); }
        .acc-section.open .acc-body { display:block; animation:fadeUp 0.18s ease; }

        /* Accent color themes on html element */
        html.accent-green  { --blue:#10b981; --blue-light:#34d399; --blue-glow:rgba(16,185,129,0.25); }
        html.accent-purple { --blue:#a855f7; --blue-light:#c084fc; --blue-glow:rgba(168,85,247,0.25); }
        html.accent-orange { --blue:#f97316; --blue-light:#fb923c; --blue-glow:rgba(249,115,22,0.25); }
        html.accent-red    { --blue:#ef4444; --blue-light:#f87171; --blue-glow:rgba(239,68,68,0.25); }

        /* Bodyweight set block — matches regular .set-row layout */
        .bw-row { display:grid; grid-template-columns:38px auto 1fr 1fr 32px 32px; gap:5px; align-items:center; background:var(--set-row-bg); padding:7px 8px; border-radius:14px; border:1.5px solid transparent; transition:all 0.25s; }
        .bw-row.done { background:rgba(16,185,129,0.07); border-color:rgba(16,185,129,0.15); }
        .bw-row input { margin-bottom:0; text-align:center; padding:10px 4px; border-radius:9px; font-weight:600; font-size:0.95rem; }
        .bw-row.done input { color:var(--green); }
        .bw-badge { background:rgba(16,185,129,0.18); color:var(--green); border-radius:9px; padding:10px 8px; font-size:0.78rem; font-weight:700; white-space:nowrap; border:1px solid rgba(16,185,129,0.25); line-height:1; text-align:center; }
        .bw-badge.no-bw { background:rgba(249,115,22,0.15); color:var(--orange); border-color:rgba(249,115,22,0.25); cursor:pointer; font-size:0.72rem; }

        /* Last-session panel */
        .last-session-panel { background:var(--surface-2); border-radius:10px; padding:10px 12px; margin:-4px 0 10px; border-left:2px solid var(--blue); }
        .last-session-panel .ls-title { font-size:0.72rem; color:var(--text-3); text-transform:uppercase; letter-spacing:0.06em; font-weight:700; margin-bottom:7px; }
        .ls-set-row { display:flex; gap:6px; flex-wrap:wrap; margin-bottom:0; }
        .ls-chip { background:var(--surface); border-radius:7px; padding:4px 9px; font-size:0.78rem; font-weight:600; color:var(--text-2); border:1px solid var(--border-mid); white-space:nowrap; }
        .ls-chip.best { color:var(--amber); border-color:rgba(245,158,11,0.25); }

        /* Routine day-chips */
        .day-chips { display:flex; gap:4px; flex-wrap:wrap; margin-top:8px; }
        .day-chip { background:var(--surface-2); border:1px solid var(--border); border-radius:7px; padding:3px 8px; font-size:0.72rem; font-weight:700; color:var(--text-3); cursor:pointer; transition:all 0.15s; user-select:none; -webkit-user-select:none; }
        .day-chip.on { background:rgba(59,130,246,0.2); border-color:rgba(59,130,246,0.4); color:var(--blue-light); }

        /* PR items expanded */
        .pr-item { display:flex; align-items:flex-start; justify-content:space-between; padding:10px 0; border-bottom:1px solid var(--border); gap:10px; }
        .pr-item:last-child { border-bottom:none; }
        .pr-stats { display:flex; gap:6px; flex-wrap:wrap; margin-top:4px; }
        .pr-stat-chip { background:var(--surface-2); border-radius:6px; padding:3px 8px; font-size:0.75rem; font-weight:700; color:var(--text-2); white-space:nowrap; border:1px solid var(--border); }
        .pr-stat-chip.highlight { color:var(--amber); background:rgba(245,158,11,0.1); }

        /* Drag handle for exercise blocks in workout */
        .ex-drag { cursor:grab; color:var(--text-3); padding:6px 8px 6px 4px; font-size:1rem; touch-action:none; flex-shrink:0; transition:color 0.15s; }
        .ex-drag:active { cursor:grabbing; color:var(--blue-light); }
        .sortable-ghost-ex { opacity:0.3; border:2px dashed var(--blue) !important; }

        /* Drag handle for routine builder */
        .builder-drag { cursor:grab; color:var(--text-3); padding:6px; font-size:0.95rem; touch-action:none; flex-shrink:0; }
        .builder-drag:active { cursor:grabbing; color:var(--blue-light); }

        /* Motivational quote under set */
        .set-quote { font-size: 0.75rem; color: var(--orange); font-style: italic; font-weight: 500; text-align: center; padding: 4px 8px 6px; opacity: 0; animation: quoteIn 0.4s ease 0.1s forwards; line-height: 1.4; }
        @keyframes quoteIn { from { opacity:0; transform:translateY(-4px); } to { opacity:1; transform:translateY(0); } }

        /* Quote list in settings */
        .quote-item { display:flex; align-items:flex-start; gap:10px; padding:10px 0; border-bottom:1px solid var(--border); }
        .quote-item:last-child { border-bottom:none; }
        .quote-text { flex:1; font-size:0.88rem; color:var(--text); line-height:1.4; font-style:italic; }