/* ======================
   THEMING & PALETTE
====================== */
:root {
    --bg-color: #F9FAFB;
    --panel-bg: #F3F4F6;
    --card-bg: #FFFFFF;
    --text-main: #1F2937;
    --text-muted: #4B5563;
    --primary: #1E3A8A;
    --secondary: #3B82F6;
    --accent: #FACC15;
    --border: #D1D5DB;
    
    --success: #166534;
    --warning: #9A3412;
    --error: #991B1B;
    
    --work-color: var(--success);
    --rest-color: var(--warning);
    --break-color: var(--primary);
    
    --radius: 12px;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

body.dark-mode {
    --bg-color: #121212;
    --panel-bg: #1e1e1e;
    --card-bg: #2d2d2d;
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --primary: #bb86fc;
    --secondary: #9965f4;
    --accent: #03dac6;
    --border: #333;
    
    --work-color: #03dac6;
    --rest-color: #cf6679;
    --break-color: #3700b3;
}

html {
    box-sizing: border-box;
}

*, *:before, *:after {
    box-sizing: inherit;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 18px;
    background: var(--bg-color);
    color: var(--text-main);
    margin: 0; padding: 0;
    line-height: 1.6;
    transition: background-color 0.3s ease;
    overscroll-behavior-y: contain; 
    padding-top: env(safe-area-inset-top, 0);
    padding-bottom: env(safe-area-inset-bottom, 0);
    padding-left: env(safe-area-inset-left, 0);
    padding-right: env(safe-area-inset-right, 0);
}

*:focus-visible {
    outline: 3px solid var(--secondary);
    outline-offset: 4px;
}

/* ======================
   COMPONENTS
====================== */
#progress-container {
    position: fixed; bottom: 0; left: 0; width: 100%; height: 12px;
    background: rgba(0,0,0,0.15); z-index: 100; pointer-events: none;
    overflow: hidden; display: none;
}

#fullscreen-bg {
    position: absolute; top: 0; left: 0; width: 0%; height: 100%;
    transition: width 1s linear, background-color 0.5s ease;
    background-image: linear-gradient(to right, rgba(255,255,255,0) 0%, rgba(255,255,255,0.2) 100%);
}

#fullscreen-bg::after {
    content: ''; position: absolute; top: 0; right: 0;
    width: 2px; height: 100%; background: #fff;
    box-shadow: 0 0 10px #fff, 0 0 20px #fff;
    opacity: 0.6;
}

.progress-marker {
    position: absolute; top: 0; width: 1px; height: 100%;
    background: rgba(255,255,255,0.4); z-index: 101;
}

.progress-marker.swap {
    width: 3px; background: var(--accent);
    box-shadow: 0 0 8px var(--accent);
}

/* Visual Flourishes */
@keyframes marker-flash {
    0% { background: rgba(255,255,255,0.4); }
    50% { background: #fff; transform: scaleX(5); box-shadow: 0 0 15px #fff; }
    100% { background: rgba(255,255,255,0.4); }
}
.flash-marker { animation: marker-flash 0.6s ease-out; }

@keyframes bar-pulse-warn {
    0% { transform: scaleY(1); filter: brightness(1); }
    50% { transform: scaleY(1.5); filter: brightness(1.5); }
    100% { transform: scaleY(1); filter: brightness(1); }
}
.pulse-warn { animation: bar-pulse-warn 0.4s ease-out; }

.container {
    max-width: 1000px;
    margin: 20px auto; padding: 20px;
    background: var(--panel-bg);
    border-radius: var(--radius);
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
    position: relative;
}

/* Tabs & Integrated Menu */
.tabs-row {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 25px;
    position: relative;
    z-index: 11;
}
.tabs {
    flex: 1;
    display: flex;
    background: #e5e7eb;
    border-radius: 35px;
    padding: 6px;
    overflow-x: auto;
    scrollbar-width: none;
}
body.dark-mode .tabs { background: #000; }
.tab-btn {
    flex: 1; padding: 14px 20px; background: transparent;
    border: none; border-radius: 30px; font-weight: 700;
    color: var(--text-muted); cursor: pointer; white-space: nowrap;
    transition: var(--transition);
    min-height: 48px;
    font-size: 1rem;
}
.tab-btn.active { background: var(--accent); color: #000; }

.menu-btn {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 50%;
    width: 52px;
    height: 52px;
    font-size: 1.5rem;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    position: relative;
    z-index: 11;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

.settings-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 24px;
}
@media (max-width: 650px) { .settings-grid { grid-template-columns: 1fr; } }
.group-label {
    font-size: 0.85rem; font-weight: 800; text-transform: uppercase;
    letter-spacing: 1.5px; color: var(--primary); margin: 25px 0 12px;
    text-align: center;
}

.profile-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-bottom: 25px;
}

/* Standardized Chips & Targets */
.profile-btn, .strat-chip, .preset-chip, .tab-btn {
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    box-sizing: border-box;
    transition: var(--transition);
}

.profile-btn { 
    background: var(--card-bg); border: 2px solid var(--border); border-radius: 10px; 
    padding: 10px 15px; cursor: pointer;
    font-weight: 700; font-size: 0.85rem; color: var(--text-muted);
    min-width: 100px;
}
.profile-btn:hover { border-color: var(--secondary); color: var(--secondary); }
.profile-btn.active { border-color: var(--primary); color: var(--primary); background: rgba(30, 58, 138, 0.05); }

/* Range Thumb Uniformity */
input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    border: 2px solid white;
    margin-top: -9px; /* (6px track / 2) - (24px thumb / 2) */
    position: relative;
    z-index: 5;
}
input[type=range]::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    border: 2px solid white;
    border: none;
}

#hiit-duration, .dual-slider-input {
    -webkit-appearance: none;
    background: transparent;
    width: 100%;
    height: 32px;
    margin: 0;
}

#hiit-duration::-webkit-slider-runnable-track,
.dual-slider-input::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px;
    background: rgba(255,255,255,0.3);
    border-radius: 3px;
}
.dual-slider-input::-webkit-slider-runnable-track {
    background: transparent; /* Track is handled by .dual-slider-track */
}

#hiit-duration::-moz-range-track,
.dual-slider-input::-moz-range-track {
    width: 100%;
    height: 6px;
    background: rgba(255,255,255,0.3);
    border-radius: 3px;
}
.dual-slider-input::-moz-range-track {
    background: transparent;
}

.preview-set-label {
    font-size: 0.85rem; font-weight: 800; text-transform: uppercase;
    letter-spacing: 1.5px; color: var(--primary); 
    margin: 35px 0 15px;
    position: sticky; top: 0; z-index: 12; 
    background: var(--card-bg); 
    padding: 12px 20px; 
    border-radius: var(--radius);
    border-left: 6px solid var(--primary);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    display: inline-block;
}

.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.check-card {
    background: var(--card-bg); padding: 14px; border-radius: 10px;
    border: 2px solid transparent; cursor: pointer; display: flex;
    align-items: center; gap: 12px; transition: var(--transition); font-size: 0.95rem;
    border-left-width: 8px;
    min-height: 52px;
}
.check-card input[type="checkbox"] {
    width: 20px; height: 20px; cursor: pointer;
}
.check-card.active { border-color: var(--secondary); background: rgba(59, 130, 246, 0.05); }

.stepper { background: var(--card-bg); padding: 12px; border-radius: 12px; margin-bottom: 8px; }
.stepper.disabled { opacity: 0.4; pointer-events: none; filter: grayscale(1); }
.stepper-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.slider-header { font-size: 0.95rem; font-weight: 700; color: var(--text-main); }
.slider-val { font-size: 1.1rem; font-weight: 800; color: var(--primary); }
.stepper-controls { display: flex; align-items: center; gap: 15px; justify-content: center; }
.step-btn {
    width: 48px; height: 48px; border-radius: 50%; border: none;
    background: var(--primary); color: white; font-weight: bold; cursor: pointer;
    font-size: 1.2rem; display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.step-btn:disabled {
    opacity: 0.3;
    pointer-events: none;
    filter: grayscale(1);
}
.stepper-val-display {
    font-size: 1.4rem; font-weight: 900; color: var(--primary); min-width: 50px; text-align: center;
}
.slider-wrap { flex: 1; position: relative; height: 32px; display: flex; align-items: center; }
input[type=range] { width: 100%; accent-color: var(--primary); cursor: pointer; height: 32px; }

/* Preset Chips */
.preset-container { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 15px; }
.preset-chip {
    flex: 1; padding: 12px; background: var(--card-bg);
    border: 2px solid var(--border); border-radius: 12px; cursor: pointer;
    text-align: center; font-size: 0.9rem; font-weight: bold; color: var(--text-muted);
    min-height: 48px; display: flex; align-items: center; justify-content: center;
    transition: var(--transition);
}
.preset-chip.active { border-color: var(--secondary); color: var(--secondary); background: rgba(59, 130, 246, 0.05); }

/* Duration Slider Specialized */
.duration-stepper {
    background: var(--primary); color: white; padding: 20px; border-radius: 15px; margin: 20px 0;
    box-shadow: 0 4px 15px rgba(30, 58, 138, 0.2);
}
.duration-stepper .slider-header { color: rgba(255,255,255,0.9); }
.duration-stepper .slider-val { color: var(--accent); font-size: 1.6rem; }
.duration-stepper input[type=range] { accent-color: var(--accent); }

/* 2-Way Slider */
.dual-slider-container {
    position: relative;
    height: 32px;
    width: 100%;
    margin-top: 5px;
}
.dual-slider-track {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 100%;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    z-index: 1;
}
.dual-slider-range {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    height: 6px;
    background: var(--primary);
    border-radius: 3px;
    z-index: 2;
}
.dual-slider-input {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 100%;
    height: 0;
    margin: 0;
    pointer-events: none;
    -webkit-appearance: none;
    background: none;
    z-index: 3;
}
.dual-slider-input::-webkit-slider-thumb {
    pointer-events: auto;
    -webkit-appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    border: 2px solid white;
}
.dual-slider-input::-moz-range-thumb {
    pointer-events: auto;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    border: 2px solid white;
}

/* Strategy Chips */
.strategy-container { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.strat-chip {
    flex: 1; min-width: 130px; padding: 14px; background: var(--card-bg);
    border: 2px solid transparent; border-radius: 12px; cursor: pointer;
    text-align: center; font-size: 0.85rem; font-weight: bold; color: var(--text-muted);
    min-height: 52px; display: flex; align-items: center; justify-content: center;
}
.strat-chip.active { border-color: var(--primary); color: var(--primary); background: rgba(30, 58, 138, 0.1); }
#strat-desc { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 20px; font-style: italic; }

/* Buttons */
.btn { padding: 14px 24px; border-radius: 10px; border: none; font-weight: 700; text-transform: uppercase; cursor: pointer; transition: var(--transition); min-height: 48px; font-size: 1rem; }
.btn-cta { background: var(--accent); color: #000; width: 100%; font-size: 1.1rem; margin-top: 24px; }
.btn-secondary { background: #374151; color: #fff; padding: 12px 16px; font-size: 0.9rem; }
.btn-small { padding: 8px 12px; font-size: 0.8rem; min-height: 36px; }

/* Preview */
#preview-view .btn { margin-top: 0; padding: 14px 24px; font-size: 1.1rem; }
.preview-set { margin: 20px 0; display: block; }
.set-complete { opacity: 0.5; filter: grayscale(0.5); }
.set-complete b::after { content: ' ✓'; color: var(--success); }

.preview-component {
    margin-bottom: 15px;
    background: rgba(255,255,255,0.03);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.05);
}
.component-header {
    background: rgba(255,255,255,0.05);
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}
.component-header:hover { background: rgba(255,255,255,0.08); }
.component-title {
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.85rem;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 8px;
}
.component-status {
    font-size: 0.75rem;
    color: var(--text-muted);
}
.component-content {
    padding: 10px;
    display: block;
}
.component-content.collapsed { display: none; }

.preview-grid { 
    display: flex; 
    gap: 15px; 
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding: 10px 0;
    width: 100%;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}
.preview-grid::-webkit-scrollbar { display: none; }

.carousel-container {
    position: relative;
    width: 100%;
    margin-bottom: 20px;
}

.carousel-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
    background: var(--primary);
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: transform 0.2s;
    pointer-events: auto;
}

.carousel-nav:active { transform: translateY(-50%) scale(0.9); }
.carousel-nav.left { left: -15px; }
.carousel-nav.right { right: -15px; }

@media (max-width: 600px) {
    .carousel-nav.left { left: 5px; }
    .carousel-nav.right { right: 5px; }
}

@media (hover: none) {
    .carousel-nav { display: none; }
}

.ex-card-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 0 0 260px;
    scroll-snap-align: start;
}

.ex-sequence-label {
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--text-muted);
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.8;
}

.ex-card {
    background: var(--card-bg); 
    padding: 16px; 
    border-radius: 12px;
    border-left: 6px solid var(--primary); 
    position: relative;
    z-index: 11;
    display: flex; 
    flex-direction: column;
    width: 100%;
    overflow: hidden;
    transition: transform 0.2s;
}

.thumbnail-wrap {
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 12px;
    position: relative;
    cursor: pointer;
}

.ex-thumbnail-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-overlay-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.4);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    pointer-events: none;
    opacity: 0.8;
}
.ex-card.edit-mode {
    cursor: grab;
}
.ex-card b { 
    display: block; 
    min-height: 2.6em; 
    margin-bottom: 6px; 
    color: var(--primary); 
    font-size: 1.05rem; 
    word-wrap: break-word;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.ex-card .card-actions { margin-top: auto; }
.ex-card.edit-mode:active { cursor: grabbing; opacity: 0.8; }
.card-actions { 
    display: flex; 
    justify-content: space-between;
    align-items: center;
    margin-top: 12px; 
    border-top: 1px solid var(--border); 
    padding-top: 12px; 
    flex-wrap: nowrap; 
}
.card-actions .step-btn, .card-actions .yt-link { 
    width: 42px; 
    height: 42px; 
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 1rem; 
    flex-shrink: 0;
    margin: 0;
}
.card-actions .yt-link { 
    background: var(--primary);
    color: white;
    font-size: 0.9rem;
}

.yt-link { text-decoration: none; font-size: 1.4rem; display: flex; align-items: center; background: rgba(0,0,0,0.05); border-radius: 10px; padding: 8px 18px; }

/* Timer UI Labels */
#video-container {
    --pill-edge: clamp(14px, 2.5vw, 28px);
    --pill-bottom: calc(clamp(18px, 4vh, 44px) + env(safe-area-inset-bottom));
    --pip-size: clamp(150px, 30vw, 420px);
}
.ex-label-overlay {
    position: absolute;
    bottom: var(--pill-bottom);
    background: rgba(0,0,0,0.7);
    color: white;
    padding: clamp(7px, 1.2vw, 10px) clamp(12px, 2vw, 20px);
    border-radius: 30px;
    font-size: clamp(0.88rem, 1.8vw, 1.2rem);
    font-weight: 800;
    z-index: 20;
    display: none;
    text-align: center;
    max-width: min(46%, calc(100vw - (var(--pill-edge) * 2)));
    backdrop-filter: blur(5px);
    border: 2px solid var(--accent);
    transition: all 0.5s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ex-label-tag {
    font-size: clamp(0.58rem, 1vw, 0.7rem);
    color: var(--accent);
    display: block;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 2px;
}
.ex-label-name {
    display: block;
}

/* Layout Specific Label Positioning */
#video-container.layout-standard #current-ex-overlay {
    display: block;
    left: var(--pill-edge);
    transform: none;
}
#video-container.layout-standard #next-up-overlay {
    left: 50%;
    transform: translateX(-50%);
}

#video-container.layout-side-by-side #current-ex-overlay {
    display: block;
    left: 25%;
    transform: translateX(-50%);
}
#video-container.layout-side-by-side #next-up-overlay {
    display: block;
    left: 75%;
    transform: translateX(-50%);
}

#video-container.layout-pip #current-ex-overlay {
    display: block;
    left: 35%; /* Shifted slightly to account for PiP space */
    transform: translateX(-50%);
}
#video-container.layout-pip #next-up-overlay {
    display: block;
    left: auto;
    right: var(--pill-edge);
    bottom: calc(var(--pill-bottom) + min(30vh, var(--pip-size)) + 10px); /* Positioned above PiP window */
    transform: none;
    max-width: min(34%, 360px);
    font-size: clamp(0.72rem, 1.25vw, 0.9rem);
    padding: 6px 12px;
}

#video-container.layout-split-shift #current-ex-overlay {
    display: block;
    left: 20%;
    transform: translateX(-50%);
}
#video-container.layout-split-shift #next-up-overlay {
    display: block;
    left: 70%;
    transform: translateX(-50%);
}

#video-container #next-up-overlay.is-now-playing {
    display: block;
    left: var(--pill-edge);
    right: auto;
    bottom: var(--pill-bottom);
    transform: none;
    max-width: min(70%, calc(100% - (var(--pill-edge) * 2)));
    border-color: var(--secondary);
    background: rgba(0,0,0,0.78);
}
#video-container #next-up-overlay.is-now-playing #next-up-tag {
    color: var(--secondary);
}

/* ----- Rest-break variant preview (HIIT only) ----- */

/* Alt-tag colouring when next-up-overlay is hosting an easier/harder alternative */
#next-up-overlay.alt-easier { border-color: var(--secondary); }
#next-up-overlay.alt-easier #next-up-tag { color: var(--secondary); }
#next-up-overlay.alt-harder { border-color: var(--warning); }
#next-up-overlay.alt-harder #next-up-tag { color: var(--warning); }

/* Variant ladder — vertical pill, right edge of video container */
.variant-ladder {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    background: rgba(0,0,0,0.55);
    padding: 8px 6px;
    border-radius: 999px;
    backdrop-filter: blur(6px);
    z-index: 25;
    pointer-events: none;
}
.variant-ladder .vl-cap {
    font-size: 0.55rem;
    font-weight: 800;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.7);
    line-height: 1;
    padding: 1px 0;
}
.variant-ladder .vl-rung {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.45);
    background: transparent;
    color: #fff;
    font-weight: 800;
    font-size: 0.78rem;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.4s ease;
}
.variant-ladder .vl-rung.active {
    background: var(--accent);
    color: #1a1a1a;
    border-color: var(--accent);
    transform: scale(1.18);
    box-shadow: 0 0 12px rgba(250,204,21,0.65);
}
.variant-ladder .vl-rung.empty {
    border-style: dashed;
    opacity: 0.4;
    font-size: 0.6rem;
}
.variant-ladder .vl-rung[data-hidden="true"] { display: none; }

/* Vertical slide for the secondary slot when cycling variants — applies to
   both #ex-video-next and #ex-video-alt so they can swap roles each cycle. */
.variant-slide-from-top    { transform: translateY(-105%); opacity: 0; }
.variant-slide-from-bottom { transform: translateY(105%);  opacity: 0; }
.variant-slide-to-top      { transform: translateY(-105%); opacity: 0; }
.variant-slide-to-bottom   { transform: translateY(105%);  opacity: 0; }

/* Disabled state for dependent .check-card rows (used by voice + variant deps) */
.check-card.disabled { opacity: 0.45; pointer-events: none; }
.timer-view { 
    display: none; 
    flex-direction: column; 
    align-items: center; 
    justify-content: center; 
    min-height: 100vh; 
    min-height: 100dvh; 
    text-align: center; 
    padding: 0; 
    box-sizing: border-box; 
    overflow: hidden; 
    gap: 0; 
    background: #000;
    position: relative;
    cursor: pointer;
}

#video-container { 
    display: none; 
    width: 100vw; 
    height: 100vh;
    height: 100dvh;
    margin: 0 auto !important; 
    overflow: hidden; 
    position: relative; 
    background: #000; 
    transition: all 0.3s ease;
    flex-shrink: 0;
    cursor: pointer;
}
#ex-video, #ex-video-next, #ex-video-alt { width: 100%; height: 100%; object-fit: contain; transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1); object-position: center; }
#ex-video-next, #ex-video-alt { z-index: 4; }

#video-container.next-up-flip-active,
#video-container.next-up-flip-active #ex-video,
#video-container.next-up-flip-active #ex-video-next,
#video-container.next-up-flip-active .ex-label-overlay {
    transition: none !important;
}

.slot-primary { z-index: 2; display: block; }
.slot-secondary { z-index: 4; }

/* Layouts */
#video-container.layout-standard .slot-primary { width: 100%; height: 100%; }
#video-container.layout-standard .slot-secondary { display: none; }

#video-container.next-up-flip-active .next-up-flip-incoming,
#video-container.next-up-flip-active .next-up-flip-outgoing {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    display: block !important;
}
#video-container.next-up-flip-active .next-up-flip-incoming {
    z-index: 18 !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
}
#video-container.next-up-flip-active .next-up-flip-outgoing {
    z-index: 2 !important;
}

#video-container.layout-side-by-side,
#video-container.layout-pip,
#video-container.layout-split-shift {
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-width: none !important;
    max-height: none !important;
    aspect-ratio: auto !important;
}

#video-container.layout-side-by-side {
    display: flex !important;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    background: #000;
}
#video-container.layout-side-by-side .slot-primary { width: 50%; height: 100%; }
#video-container.layout-side-by-side .slot-secondary { display: block; width: 50%; height: 100%; }

#video-container.layout-pip {
    position: relative;
}
#video-container.layout-pip .slot-primary { width: 100%; height: 100%; }
#video-container.layout-pip .slot-secondary { 
    display: block; 
    position: absolute; 
    bottom: var(--pill-bottom); 
    right: var(--pill-edge); 
    width: 30%; 
    height: auto; 
    aspect-ratio: auto;
    border: 2px solid var(--accent);
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    z-index: 15;
}

#video-container.layout-split-shift {
    display: flex !important;
    flex-direction: row;
    align-items: center;
    background: #000;
}
#video-container.layout-split-shift .slot-primary { width: 40%; height: 100%; }
#video-container.layout-split-shift .slot-secondary { display: block; width: 60%; height: 100%; }

.video-controls-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(10px);
    opacity: 0;
    transition: opacity 0.3s;
    display: flex;
    justify-content: space-around;
    padding: calc(15px + env(safe-area-inset-bottom)) 15px;
    z-index: 10;
    pointer-events: none;
}
.video-controls-overlay.active {
    opacity: 1;
    pointer-events: auto;
}
.video-controls-overlay .btn {
    min-width: 60px;
    padding: 8px 12px;
    font-size: 0.8rem;
}

/* Landscape Mobile Optimization */
@media (orientation: landscape) and (max-height: 500px) {
    .timer-view { padding: 0; }
    #video-container { display: block; width: 100vw; height: 100vh; height: 100dvh; }
}

/* Modals & Forms */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); display: none; justify-content: center; align-items: center; z-index: 1000; opacity: 0; transition: opacity 0.3s ease; }
.modal-overlay.active { display: flex; opacity: 1; }
.modal { background: var(--bg-color); padding: 30px; border-radius: var(--radius); width: 95%; max-width: 800px; max-height: 90vh; overflow-y: auto; position: relative; box-shadow: 0 10px 40px rgba(0,0,0,0.2); }

.modal-header {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px;
    position: sticky; top: -30px; background: var(--bg-color); z-index: 10; padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.modal-header h2 { margin: 0; font-size: 1.5rem; }
.close-x {
    background: none; border: none; font-size: 2rem; color: var(--text-muted);
    cursor: pointer; width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; border-radius: 50%; transition: var(--transition);
}
.close-x:hover { background: rgba(0,0,0,0.1); color: var(--error); }

.collapsible-header {
    cursor: pointer; display: flex; justify-content: space-between; align-items: center;
    padding: 14px 20px; background: var(--card-bg); border-radius: 10px;
    margin: 12px 0 6px; font-weight: 800; font-size: 0.9rem; color: var(--primary);
    text-transform: uppercase; border: 1px solid var(--border);
    min-height: 52px;
}
.collapsible-header::after { content: '▼'; font-size: 0.8rem; transition: transform 0.3s; }
.collapsible-header.active::after { transform: rotate(180deg); }
.collapsible-content { 
    max-height: 1200px; overflow: hidden; transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1); 
}
.collapsible-content.collapsed { max-height: 0; }

.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 800; margin-bottom: 8px; color: var(--primary); text-transform: uppercase; }
.form-control { width: 100%; padding: 12px; border-radius: 10px; border: 2px solid var(--border); background: var(--card-bg); color: var(--text-main); font-size: 1rem; }
.form-control:focus { border-color: var(--secondary); outline: none; }

/* Vault Table */
.vault-table { width: 100%; border-collapse: collapse; margin-top: 15px; }
.vault-table th { text-align: left; padding: 14px; border-bottom: 3px solid var(--border); cursor: pointer; position: relative; font-size: 0.95rem; }
.vault-table th:hover { background: rgba(0,0,0,0.05); }
.vault-table td { padding: 14px; border-bottom: 1px solid var(--border); font-size: 1rem; }

/* Vault New Sections */
.vault-info-box {
    background: var(--bg-color);
    padding: 20px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    border-left: 8px solid var(--primary);
    margin-bottom: 25px;
    font-size: 0.95rem;
}
.vault-info-box h3 { margin: 0 0 10px 0; font-size: 1rem; color: var(--primary); text-transform: uppercase; letter-spacing: 1.2px; }

.profile-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; margin-bottom: 25px; }

.profile-btn { 
    background: var(--card-bg); border: 2px solid var(--border); border-radius: 10px; 
    padding: 12px 20px; cursor: pointer; transition: var(--transition);
    font-weight: 700; font-size: 0.85rem; color: var(--text-muted);
    display: inline-block;
    margin-right: 10px;
    margin-bottom: 10px;
    min-height: 48px;
}
.profile-btn:hover { border-color: var(--secondary); color: var(--secondary); }
.profile-btn.active { border-color: var(--primary); color: var(--primary); background: rgba(30, 58, 138, 0.05); }
/* Routine Side Sheet (Drawer) */
.routine-sidebar {
    position: fixed;
    top: 0;
    right: -350px;
    width: 320px;
    height: 100%;
    background: var(--card-bg);
    z-index: 2000;
    box-shadow: -5px 0 25px rgba(0,0,0,0.1);
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    overflow-y: auto;
}

/* Toast Notifications */
#toast-container {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}
.toast {
    background: #1f2937;
    color: white;
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    pointer-events: auto;
    text-align: center;
    min-width: 200px;
}
.toast.show {
    opacity: 1;
    transform: translateY(0);
}
.toast-error { background: var(--error); }
.toast-success { background: var(--success); }
.toast-info { background: var(--primary); }
.toast:has(.toast-action) {
    display: flex; align-items: center; gap: 12px;
    text-align: left;
    padding: 10px 10px 10px 18px;
}
.toast-action {
    background: rgba(255,255,255,0.2);
    color: white;
    border: 1px solid rgba(255,255,255,0.4);
    padding: 6px 14px;
    border-radius: 18px;
    font-weight: 700;
    font-size: 0.82rem;
    cursor: pointer;
    flex-shrink: 0;
}
.toast-action:hover { background: rgba(255,255,255,0.3); }

.routine-sidebar.open {
    right: 0;
}
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s;
}
.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

.routine-toggle-btn {
    position: relative;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 10px 15px;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.routine-badge {
    background: var(--accent);
    color: #000;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
    position: absolute;
    top: -5px;
    right: -5px;
}

.nav-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    position: relative;
    z-index: 11;
}
.back-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    color: var(--text-muted);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
    position: relative;
    z-index: 11;
}
.back-btn:hover { background: var(--panel-bg); color: var(--primary); }

.main-flow {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding-bottom: 120px; /* Space for pinned floating buttons */
}

/* Pinned Action Buttons on Mobile */
.step-actions {
    display: flex;
    gap: 15px;
    margin-top: 25px;
    position: relative;
    z-index: 11;
}

@media (max-width: 1000px) {
    .step-actions {
        position: fixed;
        bottom: calc(20px + env(safe-area-inset-bottom));
        left: 20px;
        right: 20px;
        background: var(--card-bg);
        padding: 15px 20px;
        border-radius: 16px;
        box-shadow: 0 4px 20px rgba(0,0,0,0.15);
        z-index: 1000;
        margin-top: 0;
        border: 1px solid var(--border);
    }
}

.finalize-stats {
    background: var(--primary);
    color: white;
    padding: 20px;
    border-radius: var(--radius);
    text-align: center;
    margin-bottom: 25px;
    box-shadow: 0 4px 15px rgba(30, 58, 138, 0.2);
}
.stats-time { font-size: 2rem; font-weight: 900; color: var(--accent); }
.stats-finish { font-size: 1rem; opacity: 0.9; margin-top: 5px; }

/* Order Cards in Sidebar & Summary */
.order-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 15px;
    margin-bottom: 12px;
    transition: var(--transition);
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.order-card.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(30, 58, 138, 0.1);
    background: rgba(30, 58, 138, 0.02);
}
.order-card.added {
    border-left: 6px solid var(--success);
}
.order-card.skipped {
    border-left: 6px solid var(--border);
    opacity: 0.6;
}
.order-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.order-type {
    font-weight: 800;
    font-size: 0.9rem;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.order-status {
    font-size: 0.65rem;
    font-weight: 900;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
}
.status-added { background: var(--success); color: white; }
.status-skipped { background: var(--border); color: var(--text-muted); }
.status-pending { background: var(--panel-bg); color: var(--text-muted); }

.order-summary {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}
.order-actions {
    display: flex;
    gap: 10px;
    margin-top: 4px;
    border-top: 1px solid rgba(0,0,0,0.05);
    padding-top: 10px;
}

@media (max-width: 850px) {
    .routine-sidebar { width: 280px; }
}

/* ===== Utility classes (extracted from inline styles in index.html) ===== */

/* nav-header side spacers (left back-btn slot / right menu-btn slot) */
.nav-header-side { flex: 1; display: flex; align-items: center; gap: 8px; }
.nav-header-side.start { justify-content: flex-start; }
.nav-header-side.end { justify-content: flex-end; }
.nav-header-title { margin: 0; }

/* icon-sized header buttons */
.menu-btn--lg { width: 42px; height: 42px; font-size: 1.2rem; }
.close-x--sm { width: 32px; height: 32px; font-size: 1.2rem; }

/* Available-exercises hint text (used by warmup/hiit/cooldown summaries) */
.available-exercises {
    text-align: center;
    font-size: 0.9rem;
    font-weight: 800;
    color: var(--secondary);
    margin: 10px 0 20px;
}

/* generic muted helper text */
.field-hint { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 20px; }
.hint-sm { font-size: 0.75rem; text-align: center; opacity: 0.8; margin-top: 10px; }

/* step-actions button proportions */
.btn--flex-1 { flex: 1; }
.btn--flex-2 { flex: 2; margin-top: 0; }
.btn--icon { flex: 0; padding: 10px 15px; }
.btn--install { background: var(--accent); color: #000; }

/* sidebar title row */
.sidebar-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--border);
    padding-bottom: 8px;
    margin-bottom: 10px;
}
.sidebar-title-row .sidebar-title {
    margin: 0;
    border: none;
    font-weight: 900;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Spacing helpers */
.mt-10 { margin-top: 10px; }
.mt-20 { margin-top: 20px; }
.mt-30 { margin-top: 30px; }
.mb-10 { margin-bottom: 10px; }
.mb-25 { margin-bottom: 25px; }

/* Wizard step progress bar (variant C — bar with labels) */
.wiz-bar { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.wiz-bar-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.wiz-bar-labels .step.active { color: var(--primary); }
.wiz-bar-labels .step.done { color: var(--success); }
.wiz-bar-track {
    position: relative;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}
.wiz-bar-fill {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.3s ease;
}

/* Difficulty range stepper-pair (variant B — replaces dual slider) */
.range-stepper-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}
.range-stepper-row .mini-step {
    width: 36px;
    height: 36px;
    min-height: 36px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-color);
    cursor: pointer;
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-color);
    display: flex;
    align-items: center;
    justify-content: center;
}
.range-stepper-row .mini-step:hover {
    background: var(--panel-bg);
    border-color: var(--primary);
    color: var(--primary);
}
.range-stepper-row .mini-step:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}
.range-stepper-row .num-pill {
    min-width: 36px;
    padding: 6px 12px;
    text-align: center;
    background: var(--primary);
    color: white;
    border-radius: 8px;
    font-weight: 800;
    font-size: 1rem;
}
.range-stepper-row .range-dash {
    color: var(--text-muted);
    font-weight: 700;
    margin: 0 4px;
    text-transform: uppercase;
    font-size: 0.8rem;
}

/* Ticked target-duration slider */
.ticked-slider-wrap { position: relative; padding-top: 4px; padding-bottom: 24px; }
.ticked-slider-wrap .slider-wrap { position: relative; z-index: 2; }
.slider-ticks {
    position: absolute;
    left: 0; right: 0;
    bottom: 0;
    height: 14px;
    pointer-events: none;
}
.tick {
    position: absolute;
    bottom: 0;
    width: 1px;
    height: 6px;
    background: var(--text-muted);
    opacity: 0.55;
    transform: translateX(-50%);
}
.tick.major {
    width: 2px;
    height: 10px;
    background: var(--primary);
    opacity: 1;
}
.tick-label {
    position: absolute;
    bottom: -16px;
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--text-color);
    transform: translateX(-50%);
    font-variant-numeric: tabular-nums;
}

/* Component summary sentence (replaces "ESTIMATED COMPONENT TIME" line) */
.component-summary {
    margin-top: 14px;
    margin-bottom: 18px;
    padding: 12px 14px;
    background: var(--panel-bg);
    border-radius: 10px;
    border-left: 4px solid var(--primary);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-color);
    line-height: 1.55;
}
.component-summary b {
    color: var(--primary);
    font-weight: 900;
    font-variant-numeric: tabular-nums;
    font-size: 1.1em;
}
.component-summary:empty { display: none; }

/* Visually hidden but available to screen readers */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Favorites section is hidden by default; JS toggles .has-items when populated */
#favorites-section { display: none; margin-bottom: 25px; }
#favorites-section.has-items { display: block; }
#favorites-list { display: flex; flex-direction: column; gap: 8px; }
.fav-btn {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 5px;
    padding: 8px 12px;
    text-align: left;
}
.fav-btn-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fav-btn-delete { padding: 4px 8px; min-height: auto; }

/* Collapsible inner grid padding */
.settings-grid--pt-10 { padding-top: 10px; }

/* check-card variants */
.check-card--bordered { border: 1px solid var(--border); margin-bottom: 10px; }
.check-card--flush { border: none; background: transparent; padding: 0; min-height: auto; }
.check-card--flush + .check-card--flush { margin-top: 10px; }

/* Transition+overlap card wrapper inside HIIT manual controls */
.transition-card {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px;
    margin-top: 10px;
}

/* Finalize transition-break stepper override */
.stepper--accent {
    margin-top: 20px;
    background: var(--primary);
    color: white;
}
.stepper--accent .slider-header,
.stepper--accent .stepper-val-display { color: white; }
.stepper--accent .slider-val { color: var(--accent); }
.stepper--accent .step-btn { background: rgba(255,255,255,0.2); }

/* Modal sizing variants */
.modal--narrow { max-width: 500px; }
.modal--confirm { max-width: 400px; text-align: center; }
.modal--video-preview { max-width: 95vw; width: fit-content; padding: 15px; }
.modal--video-preview .modal-header { margin-bottom: 10px; }
.modal--video-preview .modal-header h2 { font-size: 1.2rem; }

/* Settings menu action stack */
.settings-actions { margin-top: 25px; }
.settings-actions .btn { width: 100%; margin-bottom: 12px; }
.settings-actions .btn:last-child { margin-bottom: 0; }

/* checkbox grid column variants (overrides base auto-fill) */
.checkbox-grid--2col { grid-template-columns: 1fr 1fr; padding: 10px; }
.checkbox-grid--1col { grid-template-columns: 1fr; padding: 10px; }

/* Resume / manual proceed wrappers */
.resume-ready-wrap {
    display: none;
    align-items: center;
    justify-content: center;
    background: var(--card-bg);
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 0 15px;
    flex: 1;
}
.resume-ready-wrap.visible { display: flex; }
.resume-ready-label {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-weight: bold;
    color: var(--primary);
    font-size: 0.9rem;
}
.resume-ready-chk { width: 20px; height: 20px; }

.manual-proceed-wrap { text-align: center; margin-top: 20px; display: none; }
.manual-proceed-label {
    font-weight: bold;
    cursor: pointer;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}
.manual-proceed-chk { width: 24px; height: 24px; margin-right: 10px; }

/* Vault layout */
.vault-actions { display: flex; gap: 10px; align-items: center; }
.vault-action-bar { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
.vault-search-row { display: flex; gap: 12px; }
.vault-search-input { flex: 1; padding: 12px; border-radius: 10px; border: 2px solid var(--border); }
.vault-filter-btn { padding: 12px; min-height: auto; }
.vault-filter-section { display: none; margin-top: 10px; }
.vault-filter-card {
    background: var(--panel-bg);
    border-radius: 10px;
    padding: 15px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 15px;
}
.vault-filter-groups { display: flex; flex-direction: column; gap: 12px; }
.vault-filter-difficulty { border-top: 1px solid var(--border); padding-top: 15px; }
.vault-filter-difficulty h4 {
    margin: 0 0 10px 0;
    font-size: 0.85rem;
    text-transform: uppercase;
    color: var(--primary);
}
.vault-diff-inputs { display: flex; gap: 10px; align-items: center; }
.vault-diff-input { width: 70px; }
.vault-scroll { overflow-x: auto; }
.vault-export-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 25px; }
.vault-info-box p { margin: 0; }
.btn--vault-random { background: var(--accent); color: #000; }

/* Video preview frame */
.video-preview-frame {
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    margin: 0 auto;
}
.video-preview-player { width: 100%; height: 100%; object-fit: contain; }

/* Confirm modal */
.modal--confirm h3 {
    margin-top: 0;
    margin-bottom: 25px;
    font-size: 1.2rem;
    color: var(--primary);
}
.modal-confirm-actions { display: flex; gap: 15px; }
.modal-confirm-actions .btn { flex: 1; }

/* === Methodology panel (Preview Routine: "How this was built") === */
.methodology-block { margin-bottom: 14px; }
.methodology-summary {
    padding: 10px 14px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.05);
    border-left: 3px solid var(--primary);
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 0.8rem;
    line-height: 1.5;
    color: var(--text-color);
}
.methodology-summary b { color: var(--primary); font-weight: 800; }
.methodology-summary .ms-line { display: block; margin: 2px 0; }
.methodology-summary .ms-comp {
    font-size: 0.65rem; font-weight: 800; letter-spacing: 0.5px;
    text-transform: uppercase; color: var(--primary);
    margin-right: 6px;
}
.methodology {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 10px;
    overflow: hidden;
}
.methodology-header {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px;
    cursor: pointer; user-select: none;
    transition: background 0.2s;
}
.methodology-header:hover { background: rgba(255,255,255,0.05); }
.methodology-header .m-icon { font-size: 1rem; }
.methodology-header .m-title {
    font-weight: 800; font-size: 0.75rem; letter-spacing: 0.5px;
    text-transform: uppercase; color: var(--primary); flex: 1;
}
.methodology-header .m-chevron {
    transition: transform 0.2s; color: var(--text-muted);
    font-size: 0.7rem;
}
.methodology.open .m-chevron { transform: rotate(90deg); }
.methodology-body {
    display: none;
    padding: 4px 14px 14px;
    border-top: 1px solid rgba(255,255,255,0.06);
}
.methodology.open .methodology-body { display: block; }
.method-comp-block { margin-top: 12px; }
.method-comp-block:first-child { margin-top: 0; }
.method-comp-label {
    display: flex; align-items: center; gap: 8px;
    font-size: 0.7rem; font-weight: 800; text-transform: uppercase;
    letter-spacing: 0.5px; color: var(--text-muted);
    margin: 10px 0 6px;
}
.method-comp-label .strategy-pill {
    font-size: 0.6rem; font-weight: 700; padding: 2px 7px;
    background: var(--primary); color: #fff; border-radius: 99px;
    text-transform: uppercase; letter-spacing: 0.4px;
}
.method-stats {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
    margin: 4px 0 8px;
}
.method-stats .stat {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 6px;
    padding: 6px 8px;
    text-align: center;
}
.method-stats .stat-val {
    font-size: 1rem; font-weight: 900;
    font-variant-numeric: tabular-nums; color: var(--text-color);
}
.method-stats .stat-label {
    font-size: 0.55rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.4px;
    color: var(--text-muted); margin-top: 2px;
}
.progressive-bar { display: flex; gap: 4px; margin: 4px 0 8px; }
.prog-set {
    flex: 1; padding: 5px 4px; border-radius: 6px; text-align: center;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.05);
}
.prog-set .prog-set-label {
    font-size: 0.5rem; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.4px;
}
.prog-set .prog-set-lvl {
    font-size: 0.95rem; font-weight: 800;
    font-variant-numeric: tabular-nums; color: var(--primary);
}
.slot-list { display: flex; flex-direction: column; gap: 3px; }
.slot-row {
    display: grid; grid-template-columns: 22px 1fr auto; gap: 8px;
    align-items: center; padding: 5px 8px;
    background: rgba(255,255,255,0.03); border-radius: 6px;
    font-size: 0.72rem;
}
.slot-num {
    width: 20px; height: 20px; border-radius: 50%;
    background: var(--primary); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 0.6rem;
}
.slot-name { font-weight: 600; color: var(--text-color); font-size: 0.75rem; }
.slot-reason { font-size: 0.62rem; color: var(--text-muted); margin-top: 1px; }
.slot-tag {
    font-size: 0.55rem; font-weight: 700;
    padding: 2px 6px; border-radius: 99px;
    background: rgba(255,255,255,0.05); color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.4px;
}
.slot-tag.push     { background: #fee2e2; color: #b91c1c; }
.slot-tag.pull     { background: #dbeafe; color: #1e40af; }
.slot-tag.upper    { background: #fef3c7; color: #92400e; }
.slot-tag.lower    { background: #dcfce7; color: #166534; }
.slot-tag.core     { background: #ede9fe; color: #6d28d9; }
.slot-tag.cardio   { background: #fee2e2; color: #b91c1c; }
.slot-tag.standing { background: #e0f2fe; color: #075985; }
.slot-tag.kneeling { background: #fef3c7; color: #92400e; }
.slot-tag.floor    { background: #f3e8ff; color: #6b21a8; }
.method-warning {
    display: flex; gap: 6px; align-items: flex-start;
    padding: 6px 10px; margin-top: 6px;
    background: rgba(217, 119, 6, 0.15);
    border-left: 3px solid #d97706;
    border-radius: 6px;
    font-size: 0.7rem; color: var(--text-color);
}
.method-section-title {
    font-size: 0.6rem; font-weight: 800; text-transform: uppercase;
    letter-spacing: 0.5px; color: var(--text-muted);
    margin: 8px 0 4px;
}

/* ===========================================================================
 * Saved-workouts UI — share modal + list screens
 * ========================================================================= */

.sw-modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex; align-items: center; justify-content: center;
    z-index: 9000;
    padding: 16px;
}
.sw-modal {
    background: var(--bg-color, #1f2937);
    color: var(--text-color, #f3f4f6);
    border-radius: 12px;
    padding: 20px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}
.sw-modal h3 {
    margin: 0 0 8px;
    font-size: 1.05rem;
}
.sw-modal p {
    margin: 8px 0 12px;
    font-size: 0.85rem;
    color: var(--text-muted, #9ca3af);
}
.sw-share-url {
    display: flex; gap: 8px; align-items: center;
    margin-bottom: 12px;
}
.sw-share-url input {
    flex: 1; padding: 8px 10px;
    border: 1px solid var(--border-color, #374151);
    background: rgba(0,0,0,0.25);
    color: var(--text-color, #f3f4f6);
    border-radius: 6px;
    font-size: 0.78rem;
}
.sw-modal .btn { margin-top: 4px; }
.sw-modal .btn-disabled { opacity: 0.55; cursor: not-allowed; }

.sw-list { padding: 8px 12px; }
.sw-routine-row, .sw-history-row, .sw-catalog-row {
    display: flex; justify-content: space-between; align-items: center;
    gap: 8px;
    padding: 12px 14px;
    margin-bottom: 8px;
    border-radius: 8px;
    background: rgba(255,255,255,0.04);
    border-left: 3px solid var(--primary, #3b82f6);
    cursor: pointer;
}
.sw-row-main {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}
.sw-row-pending { border-left-color: #d97706; opacity: 0.85; cursor: default; }
.sw-routine-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sw-routine-meta { font-size: 0.72rem; color: var(--text-muted, #9ca3af); }
.sw-row-delete { padding: 4px 8px; min-height: auto; flex-shrink: 0; }
.sw-loading, .sw-empty {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-muted, #9ca3af);
    font-size: 0.85rem;
}

/* ----- Phase 2 account UI (§8.2) ----- */
.sw-sync-status {
    margin: 8px 12px 0;
    padding: 6px 10px;
    font-size: 0.78rem;
    color: var(--text-muted, #9ca3af);
    border-left: 3px solid var(--accent, #60a5fa);
    background: rgba(96, 165, 250, 0.08);
    border-radius: 4px;
}
.sw-sync-status code { font-size: 0.78rem; }

.sw-account { padding: 16px; line-height: 1.5; }
.sw-account p { margin: 0.5em 0; }
.sw-account hr { margin: 1.5em 0; border: 0; border-top: 1px solid rgba(128,128,128,0.25); }
.sw-account-help { font-size: 0.82rem; color: var(--text-muted, #9ca3af); }
.sw-account-row { padding: 8px 0; }
.sw-account-row code { font-size: 0.82rem; word-break: break-all; }

.sw-account-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}
.sw-account-actions .btn { width: 100%; }

.sw-account-claim {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}
.sw-account-claim input {
    flex: 1;
    padding: 8px 10px;
    border-radius: 4px;
    border: 1px solid rgba(128,128,128,0.4);
    background: var(--bg-input, #1f2937);
    color: var(--text, inherit);
    font: inherit;
}

.sw-account-code {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 12px 0;
    padding: 12px;
    background: rgba(96, 165, 250, 0.08);
    border-radius: 6px;
    border: 1px dashed rgba(96, 165, 250, 0.4);
}
.sw-account-code code {
    flex: 1;
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    word-break: break-all;
}

/* ============================================================
   SWAP PICKER — inline replacement for the full-vault flow on
   preview-routine cards. Renders as a sibling of .carousel-container
   inside .preview-set.
   ============================================================ */
.swap-picker {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin: 4px 12px 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.14);
    overflow: hidden;
    animation: swap-picker-slide 0.22s ease-out;
}
@keyframes swap-picker-slide {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* sticky "REPLACING X" pin */
.swap-picker__pin {
    position: sticky; top: 0; z-index: 5;
    background: var(--panel-bg);
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 10px;
}
.swap-picker__pin-thumb {
    width: 42px; height: 32px;
    background: linear-gradient(135deg, #4b5563, #1f2937);
    border-radius: 4px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 0.55rem; opacity: 0.85;
}
.swap-picker__pin-body { flex: 1; min-width: 0; }
.swap-picker__pin-label {
    font-size: 0.55rem; font-weight: 800; letter-spacing: 0.6px;
    color: var(--text-muted);
}
.swap-picker__pin-name {
    font-size: 0.85rem; font-weight: 800; color: var(--primary);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.swap-picker__pin-meta {
    font-size: 0.62rem; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.3px;
}
.swap-picker__pin-close {
    background: transparent; border: none;
    font-size: 1.05rem; cursor: pointer; color: var(--text-muted);
    padding: 4px 6px;
}
.swap-picker__pin-close:hover { color: var(--text-color); }

/* search + random row */
.swap-picker__search-row {
    display: flex; gap: 6px;
    padding: 10px 10px 8px;
    background: var(--card-bg);
    align-items: center;
}
.swap-picker__search-wrap {
    flex: 1;
    position: relative;
    display: flex; align-items: center;
}
.swap-picker__search-wrap::before {
    content: '🔍';
    position: absolute; left: 8px;
    font-size: 0.75rem; opacity: 0.5;
    pointer-events: none;
}
.swap-picker__search-input {
    width: 100%;
    padding: 8px 28px 8px 28px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--panel-bg);
    color: var(--text-color);
    font-size: 0.85rem;
    font-family: inherit;
}
.swap-picker__search-input:focus { outline: none; border-color: var(--primary); }
.swap-picker__search-clear {
    position: absolute; right: 6px;
    background: transparent; border: none;
    color: var(--text-muted); cursor: pointer;
    font-size: 0.9rem; padding: 3px 6px;
    display: none;
}
.swap-picker__search-wrap.has-text .swap-picker__search-clear { display: block; }
.swap-picker__random-btn {
    background: var(--accent); color: #1f2937;
    border: 1px solid var(--accent);
    padding: 8px 14px; border-radius: 6px;
    font-size: 0.8rem; font-weight: 800;
    cursor: pointer; white-space: nowrap;
    display: flex; align-items: center; gap: 4px;
    transition: transform 0.08s;
}
.swap-picker__random-btn:hover { transform: scale(1.04); }
.swap-picker__random-icon { display: inline-block; }
.swap-picker__random-btn.spinning .swap-picker__random-icon { animation: swap-picker-spin 0.6s linear; }
@keyframes swap-picker-spin {
    from { transform: rotate(0); }
    to   { transform: rotate(720deg); }
}

/* chips */
.swap-picker__chips {
    display: flex; gap: 5px;
    padding: 0 10px 10px;
    flex-wrap: wrap;
}
.swap-picker__chip {
    font-size: 0.7rem; font-weight: 700;
    padding: 5px 11px; border-radius: 999px;
    background: var(--panel-bg); color: var(--text-color);
    border: 1px solid var(--border); cursor: pointer;
    white-space: nowrap;
    user-select: none;
}
.swap-picker__chip.is-active {
    background: var(--primary); color: var(--card-bg);
    border-color: var(--primary);
}
.swap-picker__chip-count { opacity: 0.6; margin-left: 3px; font-weight: 500; }
.swap-picker__widened {
    color: var(--accent); font-weight: 700; margin-left: 4px;
    font-size: 0.65rem;
}

/* random reveal banner */
.swap-picker__reveal {
    margin: 0 10px 10px;
    padding: 10px 12px;
    background: linear-gradient(135deg, rgba(250,204,21,0.18), rgba(250,204,21,0.05));
    border: 2px solid var(--accent);
    border-radius: 8px;
    display: flex; align-items: center; gap: 10px;
    animation: swap-picker-pulse 1.4s ease-in-out;
}
@keyframes swap-picker-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(250,204,21,0.45); }
    60%  { box-shadow: 0 0 0 10px rgba(250,204,21,0); }
    100% { box-shadow: 0 0 0 0 rgba(250,204,21,0); }
}
.swap-picker__reveal-thumb {
    width: 50px; height: 38px;
    background: linear-gradient(135deg, #4b5563, #1f2937);
    border-radius: 4px; flex-shrink: 0;
}
.swap-picker__reveal-body { flex: 1; min-width: 0; }
.swap-picker__reveal-label {
    font-size: 0.55rem; font-weight: 800; letter-spacing: 0.5px;
    color: #b45309;
}
.swap-picker__reveal-name {
    font-size: 0.9rem; font-weight: 800; color: var(--primary);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.swap-picker__reveal-meta { font-size: 0.65rem; color: var(--text-muted); }
.swap-picker__reveal-actions { display: flex; gap: 5px; flex-shrink: 0; }
.swap-picker__reveal-actions button {
    border: none; border-radius: 5px;
    padding: 7px 12px; font-size: 0.78rem; font-weight: 800;
    cursor: pointer;
}
.swap-picker__reveal-use { background: var(--primary); color: var(--card-bg); }
.swap-picker__reveal-reroll {
    background: rgba(255,255,255,0.7);
    color: var(--text-color);
    border: 1px solid var(--border) !important;
}

/* candidate list */
.swap-picker__list {
    display: grid; gap: 5px;
    padding: 0 10px 10px;
}
.swap-picker__row {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px;
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-left: 3px solid var(--primary);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: transform 0.08s, background 0.08s;
}
.swap-picker__row:hover { transform: translateX(2px); background: var(--card-bg); }
.swap-picker__row-thumb {
    width: 40px; height: 28px; flex-shrink: 0;
    background: linear-gradient(135deg, #4b5563, #1f2937);
    border-radius: 3px;
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 0.55rem; opacity: 0.85;
}
.swap-picker__row-body { flex: 1; min-width: 0; }
.swap-picker__row-name {
    font-weight: 800; color: var(--primary);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.swap-picker__row-sub {
    font-size: 0.65rem; color: var(--text-muted);
    margin-top: 1px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    text-transform: uppercase; letter-spacing: 0.3px;
}
.swap-picker__row-sub i { font-style: italic; text-transform: none; letter-spacing: 0; }
.swap-picker__row-name mark,
.swap-picker__row-sub mark {
    background: rgba(250,204,21,0.45);
    color: inherit;
    padding: 0 1px; border-radius: 2px;
}
.swap-picker__row-lvl {
    font-size: 0.65rem; font-weight: 800; color: var(--primary);
    background: rgba(30,58,138,0.1); padding: 2px 7px; border-radius: 999px;
    flex-shrink: 0;
}

/* empty state */
.swap-picker__empty {
    margin: 0 10px 10px;
    padding: 18px 12px;
    text-align: center;
    background: var(--panel-bg);
    border: 1px dashed var(--border);
    border-radius: 8px;
}
.swap-picker__empty-icon { font-size: 1.6rem; opacity: 0.5; }
.swap-picker__empty-msg {
    font-size: 0.82rem; color: var(--text-muted);
    margin: 6px 0; line-height: 1.4;
}
.swap-picker__empty-cta {
    margin-top: 8px; display: inline-block;
    background: var(--primary); color: var(--card-bg);
    padding: 7px 16px; border-radius: 6px; font-weight: 700;
    font-size: 0.78rem; cursor: pointer; border: none;
}

/* full-vault escape hatch */
.swap-picker__full-vault {
    width: calc(100% - 20px);
    margin: 0 10px 10px;
    padding: 9px;
    background: transparent;
    color: var(--text-muted);
    border: 1px dashed var(--border);
    border-radius: 6px;
    font-size: 0.75rem; font-weight: 700;
    cursor: pointer;
}
.swap-picker__full-vault:hover {
    color: var(--primary);
    border-color: var(--primary);
}
