/* Voice Fitness Coach - Monochrome + Electric Orange */

/* ============================================
   CSS Variables - Stark Monochrome
   ============================================ */
:root {
    /* Backgrounds - Pure darkness */
    --bg-void: #000000;
    --bg-primary: #0a0a0a;
    --bg-card: #111111;
    --bg-elevated: #1a1a1a;
    --bg-input: #141414;

    /* Text - White hierarchy */
    --text-primary: #ffffff;
    --text-secondary: #888888;
    --text-muted: #555555;
    --text-ghost: #333333;

    /* The ONE accent - Electric Orange */
    --accent: #ff6a00;
    --accent-glow: rgba(255, 106, 0, 0.4);
    --accent-dim: #cc5500;

    /* Functional colors (used sparingly) */
    --color-success: #00ff88;
    --color-rest: #ffaa00;

    /* Borders */
    --border-subtle: #1f1f1f;
    --border-card: #222222;
    --border: var(--border-subtle);

    /* Error/Alert colors */
    --color-error: #ff4444;
    --color-error-light: #ff6666;

    /* Medal colors */
    --medal-gold: #FFD700;
    --medal-silver: #C0C0C0;
    --medal-bronze: #CD7F32;

    /* Accent opacity ladder */
    --accent-strong: rgba(255, 106, 0, 0.5);
    --accent-medium: rgba(255, 106, 0, 0.3);
    --accent-light: rgba(255, 106, 0, 0.2);
    --accent-subtle: rgba(255, 106, 0, 0.1);
    --accent-faint: rgba(255, 106, 0, 0.05);

    /* Typography scale */
    --text-xs: 0.75rem;
    --text-sm: 0.85rem;
    --text-base: 1rem;
    --text-lg: 1.25rem;
    --text-xl: 1.5rem;
    --text-2xl: 2rem;

    /* Spacing scale */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;
    --space-8: 2.5rem;

    /* Letter spacing */
    --tracking-tight: -0.02em;
    --tracking-normal: 0.02em;
    --tracking-wide: 0.1em;
    --tracking-wider: 0.2em;

    /* Sizing */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 300ms ease;

    /* Icon size */
    --icon-sm: 20px;
    --icon-md: 28px;
    --icon-lg: 36px;
}

/* ============================================
   Reset & Base
   ============================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-void);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}

/* ============================================
   Accessibility - Reduced Motion
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ============================================
   Utility Classes
   ============================================ */
.hidden {
    display: none !important;
}

.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;
}

/* Visibility states via data attributes */
[data-state="hidden"] {
    display: none;
}

[data-state="loading"] {
    opacity: 0.6;
    pointer-events: none;
}

/* Progress via CSS custom property */
[data-progress] {
    --progress-value: 0;
}

/* Base overlay pattern */
.overlay-base {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal);
    z-index: 10000;
}

.overlay-base.active,
.overlay-base:not(.hidden) {
    opacity: 1;
    pointer-events: auto;
}

/* Base card pattern */
.card-base {
    padding: var(--space-4);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    background: var(--bg-card);
}

/* Glow utilities */
.glow-sm { box-shadow: 0 0 10px var(--accent-glow); }
.glow-md { box-shadow: 0 0 20px var(--accent-glow); }
.glow-lg { box-shadow: 0 0 40px var(--accent-glow); }

/* Filter for accent-colored icons */
.filter-accent {
    filter: invert(48%) sepia(99%) saturate(1500%) hue-rotate(360deg) brightness(103%) contrast(106%);
}

/* ============================================
   Typography
   ============================================ */
h1, h2, h3, h4 {
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.mono {
    font-family: 'JetBrains Mono', monospace;
    font-variant-numeric: tabular-nums;
}

/* ============================================
   Icons - Inverted to white, accent when active
   ============================================ */
.icon {
    display: inline-block;
    width: var(--icon-md);
    height: var(--icon-md);
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    filter: invert(1);
    opacity: 0.7;
    transition: all var(--transition-normal);
}

.icon--sm { width: var(--icon-sm); height: var(--icon-sm); }
.icon--lg { width: var(--icon-lg); height: var(--icon-lg); }

.icon--fire { background-image: url('/plates/assets/icons/fire.png'); }
.icon--calendar { background-image: url('/plates/assets/icons/calendar.png'); }
.icon--trophy { background-image: url('/plates/assets/icons/trophy.png'); }
.icon--dumbell { background-image: url('/plates/assets/icons/dumbell.png'); }
.icon--legs { background-image: url('/plates/assets/icons/legs.png'); }
.icon--heart { background-image: url('/plates/assets/icons/heart.png'); }
.icon--skull { background-image: url('/plates/assets/icons/skull.png'); }
.icon--plate { background-image: url('/plates/assets/icons/plate.png'); }
.icon--strain { background-image: url('/plates/assets/icons/strained-face.png'); }

/* Active/Accent state - orange glow */
.icon--active {
    filter: invert(48%) sepia(99%) saturate(1500%) hue-rotate(360deg) brightness(103%) contrast(106%);
    opacity: 1;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.btn-primary {
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border: 1px solid var(--border-card);
}

.btn-primary:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.btn:focus-visible,
.btn-primary:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Active CTA - THE spotlight */
.btn-primary.btn--active {
    background: var(--accent);
    color: var(--bg-void);
    border-color: var(--accent);
    box-shadow: 0 0 30px var(--accent-glow);
    animation: pulse-glow 2s ease-in-out infinite;
}

.btn-primary.btn--active:hover {
    background: var(--accent-dim);
    transform: scale(1.02);
}

@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 0 20px var(--accent-glow);
    }
    50% {
        box-shadow: 0 0 40px var(--accent-glow), 0 0 60px rgba(255, 106, 0, 0.2);
    }
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: none;
    padding: 0.5rem 1rem;
    text-transform: none;
    font-weight: 500;
}

.btn-ghost:hover,
.btn-ghost:focus-visible {
    color: var(--text-primary);
}

.btn-ghost:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.btn-danger {
    color: var(--color-error);
}

.btn-danger:focus-visible {
    outline: 2px solid var(--color-error);
    outline-offset: 2px;
}

.btn-danger:hover {
    color: var(--color-error-light);
    background: rgba(255, 68, 68, 0.1);
}

.btn-large {
    padding: 1rem 2rem;
    font-size: 1rem;
    width: 100%;
}

/* ============================================
   Forms
   ============================================ */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-group input {
    width: 100%;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    transition: border-color var(--transition-fast);
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-subtle);
}

.form-group input:focus-visible {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-subtle);
}

.form-group input::placeholder {
    color: var(--text-ghost);
}

.form-error {
    color: var(--accent);
    font-size: 0.85rem;
    min-height: 1.5rem;
    margin-bottom: 0.5rem;
}

.form-success {
    color: var(--color-success);
    font-size: 0.85rem;
    min-height: 1.5rem;
    margin-bottom: 0.5rem;
}

.forgot-password-link {
    display: block;
    text-align: center;
    margin-top: 1rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-decoration: none;
    transition: color 0.2s ease;
}

.forgot-password-link:hover,
.forgot-password-link:focus-visible {
    color: var(--accent);
}

.forgot-password-link:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 1rem;
}

.modal-overlay.active {
    display: flex;
}

.modal-overlay .modal {
    position: relative;
    background: var(--bg-primary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    width: 100%;
    max-width: 400px;
}

.modal-overlay .modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color var(--transition-fast);
}

.modal-overlay .modal-close:hover,
.modal-overlay .modal-close:focus-visible {
    color: var(--text-primary);
}

.modal-overlay .modal-close:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.forgot-modal {
    max-width: 360px;
}

.forgot-modal .modal-desc {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

/* ============================================
   Landing Page
   ============================================ */
.landing-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1.5rem;
}

.landing-container {
    width: 100%;
    max-width: 360px;
}

.landing-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.landing-logo {
    width: 60px;
    height: 60px;
    margin: 0 auto 1rem;
}

.landing-logo-icon {
    width: 100%;
    height: 100%;
}

.landing-title {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
}

.landing-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Auth Tabs */
.auth-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 1.5rem;
}

.auth-tab {
    flex: 1;
    padding: 0.75rem;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.auth-tab.active {
    color: var(--text-primary);
    border-bottom-color: var(--text-primary);
}

/* Auth Forms */
.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

/* Features */
.landing-features {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-top: 2.5rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-subtle);
}

.feature {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.feature-icon {
    width: var(--icon-md);
    height: var(--icon-md);
    opacity: 0.4;
}

.feature-text {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ============================================
   App Header
   ============================================ */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-subtle);
    position: relative;
    z-index: 101; /* Above modal (100) so timer remains accessible */
}

.app-header .logo {
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    color: var(--text-primary);
    text-decoration: none;
}

/* Header Actions (timer + hamburger) */
.header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

/* Hamburger Button */
.hamburger {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
}

.hamburger:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.hamburger svg {
    width: 24px;
    height: 24px;
}

.hamburger svg line {
    stroke: #ffffff;
    stroke-width: 2;
    stroke-linecap: round;
    transition: transform 0.2s ease, opacity 0.2s ease;
    transform-origin: center;
}

.hamburger.active svg line:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}

.hamburger.active svg line:nth-child(2) {
    opacity: 0;
}

.hamburger.active svg line:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

/* Navigation Menu */
.nav-menu {
    position: fixed;
    inset: 0;
    z-index: 200;
    visibility: hidden;
    pointer-events: none;
}

.nav-menu.open {
    visibility: visible;
    pointer-events: auto;
}

.nav-menu__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    opacity: 0;
    transition: opacity 0.25s ease;
}

.nav-menu.open .nav-menu__overlay {
    opacity: 1;
}

.nav-menu__panel {
    position: absolute;
    top: 0;
    right: 0;
    width: 280px;
    max-width: 85vw;
    height: 100%;
    background: var(--bg-primary);
    border-left: 1px solid var(--border-subtle);
    transform: translateX(100%);
    transition: transform 0.25s ease;
    display: flex;
    flex-direction: column;
}

.nav-menu.open .nav-menu__panel {
    transform: translateX(0);
}

.nav-menu__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-subtle);
}

.nav-menu__user {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.nav-menu__close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    line-height: 1;
    border-radius: var(--radius-sm);
}

.nav-menu__close:hover,
.nav-menu__close:focus-visible {
    color: var(--text-primary);
}

.nav-menu__close:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.nav-menu__links {
    flex: 1;
    padding: 1rem 0;
}

.nav-menu__links a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 1rem;
    font-weight: 500;
    transition: background 0.15s ease, color 0.15s ease;
}

.nav-menu__links a:hover,
.nav-menu__links a:focus-visible {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.nav-menu__links a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

.nav-menu__links a svg {
    width: 20px;
    height: 20px;
    opacity: 0.7;
}

.nav-menu__footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-subtle);
}

.nav-menu__footer .btn-logout {
    width: 100%;
    padding: 0.75rem 1rem;
    background: transparent;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease;
}

.nav-menu__footer .btn-logout:hover,
.nav-menu__footer .btn-logout:focus-visible {
    border-color: var(--accent);
    color: var(--accent);
}

.nav-menu__footer .btn-logout:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ============================================
   Dashboard Layout
   ============================================ */
.dashboard-page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.dashboard-main {
    flex: 1;
    padding: 1.25rem;
    max-width: 500px;
    margin: 0 auto;
    width: 100%;
}

/* ============================================
   XP Section
   ============================================ */
.xp-section {
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
}

.level-badge {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    border: 1px solid var(--text-muted);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
}

/* Active level badge - when just leveled up */
.level-badge--active {
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 0 15px var(--accent-glow);
    animation: pulse-glow 2s ease-in-out infinite;
}

.xp-bar {
    height: 6px;
    background: var(--bg-elevated);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.xp-bar-fill {
    height: 100%;
    background: var(--text-muted);
    border-radius: var(--radius-full);
    transition: width var(--transition-normal);
}

/* Active XP bar - when XP was just earned */
.xp-bar-fill--active {
    background: var(--accent);
    box-shadow: 0 0 10px var(--accent-glow);
}

.xp-text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.xp-current {
    color: var(--text-secondary);
}

/* ============================================
   Stats Grid
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.stat-card {
    position: relative;
    padding: 1.25rem 1rem;
    text-align: center;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    transition: all var(--transition-normal);
    overflow: hidden;
}

/* Background watermark icon */
.stat-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.stat-icon .icon {
    width: 70px;
    height: 70px;
    opacity: 0.08;
}

.stat-value {
    position: relative;
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
    z-index: 1;
}

.stat-label {
    position: relative;
    font-size: 0.6rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    z-index: 1;
}

/* Active stat - with accent color */
.stat-card--active {
    border-color: var(--accent);
    box-shadow: 0 0 20px var(--accent-glow);
}

.stat-card--active .stat-icon .icon {
    opacity: 0.15;
}

.stat-card--active .stat-value {
    color: var(--accent);
}

/* ============================================
   Action Section
   ============================================ */
.action-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.btn-rest {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    padding: 0.65rem 1.25rem;
    text-transform: none;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-ghost);
    border-radius: 6px;
    cursor: not-allowed;
    transition: all 0.2s ease;
}

.btn-rest .rest-icon {
    font-size: 1rem;
}

.btn-rest .rest-count {
    font-size: 0.7rem;
    opacity: 0.7;
}

.btn-rest:disabled {
    opacity: 0.5;
}

.btn-rest--available {
    cursor: pointer;
    color: var(--text-secondary);
    border-color: var(--text-muted);
    background: rgba(255, 255, 255, 0.03);
}

.btn-rest--available:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(255, 106, 0, 0.05);
}

.btn-rest--available .rest-icon {
    animation: pulse-subtle 2s ease-in-out infinite;
}

@keyframes pulse-subtle {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ============================================
   Bottom Grid (Weekly Coverage + Activity)
   ============================================ */
.bottom-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.card {
    padding: 1rem;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
}

.card-title {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 1rem;
}

/* Coverage Dot Matrix */
.coverage-card {
    padding: 0.875rem;
}

.coverage-grid {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.coverage-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.coverage-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    transition: all var(--transition-fast);
}

.coverage-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    width: 48px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    transition: color var(--transition-fast);
}

.coverage-dots {
    display: flex;
    gap: 5px;
    margin-left: auto;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--bg-elevated);
    border: 1px solid var(--border-card);
    transition: all var(--transition-fast);
}

/* Tier 1: 1-2 hits - dim gray */
.coverage-row[data-tier="1"] .dot--filled {
    background: var(--text-ghost);
    border-color: var(--text-ghost);
}
.coverage-row[data-tier="1"] .coverage-icon {
    filter: invert(1);
    opacity: 0.4;
}
.coverage-row[data-tier="1"] .coverage-label {
    color: var(--text-ghost);
}

/* Tier 2: 3-4 hits - brighter gray */
.coverage-row[data-tier="2"] .dot--filled {
    background: var(--text-muted);
    border-color: var(--text-muted);
}
.coverage-row[data-tier="2"] .coverage-icon {
    filter: invert(1);
    opacity: 0.6;
}
.coverage-row[data-tier="2"] .coverage-label {
    color: var(--text-muted);
}

/* Tier 3: 5-6 hits - orange, no glow */
.coverage-row[data-tier="3"] .dot--filled {
    background: var(--accent);
    border-color: var(--accent);
}
.coverage-row[data-tier="3"] .coverage-icon {
    filter: invert(48%) sepia(99%) saturate(1500%) hue-rotate(360deg) brightness(103%) contrast(106%);
    opacity: 0.8;
}
.coverage-row[data-tier="3"] .coverage-label {
    color: var(--accent);
    opacity: 0.8;
}

/* Tier 4: 7 hits - full orange with glow */
.coverage-row[data-tier="4"] .dot--filled {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 6px var(--accent-glow);
}
.coverage-row[data-tier="4"] .coverage-icon {
    filter: invert(48%) sepia(99%) saturate(1500%) hue-rotate(360deg) brightness(103%) contrast(106%);
    opacity: 1;
}
.coverage-row[data-tier="4"] .coverage-label {
    color: var(--accent);
}

/* Activity List */
.activity-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.activity-empty {
    color: var(--text-ghost);
    font-size: 0.85rem;
    font-style: italic;
}

.activity-item {
    display: flex;
    gap: 1rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border-subtle);
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-date {
    color: var(--text-muted);
    font-size: 0.75rem;
    min-width: 70px;
    text-transform: uppercase;
}

.activity-summary {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* ============================================
   Modal
   ============================================ */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: env(safe-area-inset-top, 0) 0 env(safe-area-inset-bottom, 0) 0;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-primary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

/* Chat modal - bottom-sheet style for keyboard input */
.modal--chat {
    align-items: stretch; /* Full width */
    justify-content: flex-end; /* Anchor to bottom */
    padding: 0;
    top: 60px; /* Leave header visible for timer access */
}

/* Adjust for iOS standalone safe area */
@supports (padding-top: env(safe-area-inset-top)) {
    @media (display-mode: standalone) {
        .modal--chat {
            top: calc(60px + env(safe-area-inset-top));
        }
    }
}

.modal--chat .modal-content {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-width: 100%;
    width: 100%;
    margin-bottom: 0;
    /* Let content determine height, with max for when keyboard is hidden */
    height: auto;
    max-height: calc(100vh - 60px);
    max-height: calc(100dvh - 60px); /* Dynamic viewport for keyboard */
}

/* Messages area - fit content, scroll only when needed */
.modal--chat .chat-messages {
    /* Don't flex-grow into empty space - only take space needed for content */
    flex: 0 1 auto;
    min-height: 60px;
    /* Cap height so it scrolls when conversation grows */
    max-height: calc(100vh - 200px);
    max-height: calc(100dvh - 200px); /* Dynamic viewport for keyboard */
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border-subtle);
}

@media (min-width: 480px) {
    .modal-header {
        padding: 1rem 1.25rem;
    }
}

.modal-header h2 {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
    transition: color var(--transition-fast);
    border-radius: var(--radius-sm);
}

.modal-close:hover,
.modal-close:focus-visible {
    color: var(--text-primary);
}

.modal-close:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.modal-body {
    padding: 1.25rem;
    max-height: 60vh;
    overflow-y: auto;
}

.modal-content--wide {
    max-width: 600px;
}

/* Trends modal needs full-screen on mobile */
#trends-modal {
    align-items: stretch;
    justify-content: stretch;
    padding: 0;
}

#trends-modal > .modal-content--trends {
    /* Use flex: 1 to fill parent instead of height: 100% */
    flex: 1;
    max-height: 100dvh;
    max-width: none;
    border-radius: 0;
    border: none;
}

@media (min-width: 600px) {
    #trends-modal {
        align-items: center;
        justify-content: center;
        padding: 1rem;
    }

    #trends-modal > .modal-content--trends {
        flex: 0 1 auto;
        height: auto;
        max-height: 85vh;
        max-width: 800px;
        border-radius: var(--radius-lg);
        border: 1px solid var(--border-subtle);
    }
}

.modal-content--trends {
    display: flex;
    flex-direction: column;
    width: 100%;
}

/* Consolidated responsive modal styles */
@media (min-width: 480px) {
    .modal {
        padding: 1rem;
    }
    .modal-content {
        max-height: 85vh;
    }
    /* On larger screens, chat modal can be centered */
    .modal--chat {
        align-items: center;
        justify-content: center;
        padding: 1rem;
        top: 60px; /* Keep header visible */
    }
    .modal--chat .modal-content {
        border-radius: var(--radius-lg);
        max-height: 70vh;
        max-width: 500px;
    }
    .modal--chat .chat-input-form {
        padding-bottom: 0.75rem; /* Remove safe-area on desktop */
    }
}

.modal-content--trends .modal-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
    /* Override base modal-body max-height constraint */
    max-height: none;
    /* Tighter padding on mobile to maximize space */
    padding: 0.75rem;
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
}

@media (min-width: 600px) {
    .modal-content--trends .modal-body {
        padding: 1.25rem;
        padding-bottom: 1.25rem;
    }
}

/* ============================================
   Exercise Trends Chart
   ============================================ */
.trends-content {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.trends-chart-container {
    position: relative;
    /* On mobile, chart is smaller to give more room to exercise list */
    flex: 0 0 180px;
    min-height: 180px;
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
    padding: 0.75rem;
}

@media (min-width: 600px) {
    .trends-chart-container {
        flex: 1 1 auto;
        min-height: 280px;
        padding: 1rem;
    }
}

/* Search input for exercises */
.trends-search {
    flex-shrink: 0;
}

.trends-search input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
    transition: border-color var(--transition-fast);
}

.trends-search input::placeholder {
    color: var(--text-ghost);
}

.trends-search input:focus {
    border-color: var(--accent);
}

.trends-legend {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0.5rem;
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
}

@media (min-width: 600px) {
    .trends-legend {
        flex-direction: row;
        flex-wrap: wrap;
        flex: 0 0 auto;
        max-height: 180px;
        min-height: auto;
    }
}

.trends-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    background: var(--bg-card);
    border: 2px solid var(--border-subtle);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    flex: 0 0 auto;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

@media (min-width: 600px) {
    .trends-toggle {
        padding: 0.5rem 0.75rem;
        gap: 0.5rem;
        border-width: 1px;
        border-radius: var(--radius-sm);
    }
}

.trends-toggle:hover {
    border-color: var(--text-ghost);
}

.trends-toggle:active {
    transform: scale(0.98);
    background: var(--bg-elevated);
}

.trends-toggle:has(input:checked) {
    border-color: var(--toggle-color, var(--accent));
    background: rgba(255, 255, 255, 0.05);
}

.trends-toggle input {
    display: none;
}

.trends-toggle__color {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--toggle-color, var(--accent));
    opacity: 0.3;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

@media (min-width: 600px) {
    .trends-toggle__color {
        width: 12px;
        height: 12px;
    }
}

.trends-toggle:has(input:checked) .trends-toggle__color {
    opacity: 1;
    box-shadow: 0 0 8px var(--toggle-color, var(--accent));
}

.trends-toggle__name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    flex: 1;
}

@media (min-width: 600px) {
    .trends-toggle__name {
        font-size: 0.8rem;
        flex: 0 0 auto;
    }
}

.trends-toggle__meta {
    font-size: 0.7rem;
    color: var(--text-ghost);
    margin-left: auto;
}

@media (min-width: 600px) {
    .trends-toggle__meta {
        font-size: 0.65rem;
        margin-left: 0;
    }
}

/* Chart empty state when no exercises selected */
.chart-empty-state {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    text-align: center;
    padding: 1rem;
}

.chart-empty-state.hidden {
    display: none;
}

.chart-empty-state p {
    margin: 0;
    opacity: 0.7;
}

/* Backfill notice */
.trends-backfill {
    padding: 1rem;
    background: rgba(255, 106, 0, 0.1);
    border: 1px solid rgba(255, 106, 0, 0.3);
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
}

.trends-backfill p {
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.trends-backfill .btn {
    width: 100%;
}

.trends-loading,
.trends-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-height: 200px;
    color: var(--text-muted);
    font-size: 0.9rem;
    text-align: center;
    padding: 2rem;
}

.trends-empty p {
    margin: 0;
}

/* ============================================
   Chat
   ============================================ */
.chat-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden; /* Prevent container from growing beyond modal */
}

.chat-messages {
    flex: 1 1 auto; /* Grow and shrink as needed */
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: 100px; /* Minimum visible area, but can shrink */
}

.message {
    max-width: 85%;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-lg);
    font-size: 0.9rem;
    line-height: 1.5;
}

.message--assistant {
    background: var(--bg-elevated);
    color: var(--text-secondary);
    align-self: flex-start;
    border-bottom-left-radius: var(--radius-sm);
}

.message--user {
    background: var(--text-ghost);
    color: var(--text-primary);
    align-self: flex-end;
    border-bottom-right-radius: var(--radius-sm);
}

.message--loading {
    opacity: 0.5;
}

/* Chat Continue Button - workout completion flow */
.chat-continue {
    display: flex;
    justify-content: center;
    padding: 0.5rem 0;
    animation: fadeSlideUp 0.3s ease-out;
}

.chat-continue__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-width: 160px;
    min-height: 48px; /* Mobile-friendly tap target */
    padding: 0.75rem 1.5rem;
    background: var(--accent);
    color: var(--bg-void);
    border: none;
    border-radius: var(--radius-lg);
    font-size: var(--text-base);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: 0 0 20px var(--accent-glow);
}

.chat-continue__btn:hover,
.chat-continue__btn:focus-visible {
    background: var(--accent-dim);
    transform: scale(1.02);
    box-shadow: 0 0 30px var(--accent-glow);
}

.chat-continue__btn:active {
    transform: scale(0.98);
}

.chat-continue__btn svg {
    width: 18px;
    height: 18px;
    stroke-width: 2.5;
}

@keyframes fadeSlideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Chat Input Form - Modern Layout */
.chat-input-form {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0));
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-card);
    flex-shrink: 0; /* Don't shrink - messages area shrinks instead */
    align-items: flex-end; /* Buttons at bottom when textarea grows */
}

.chat-input-actions {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0;
}

.chat-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.chat-action-btn svg {
    width: 20px;
    height: 20px;
    stroke: var(--text-secondary);
    transition: all var(--transition-fast);
}

.chat-action-btn:hover svg,
.chat-action-btn:active svg {
    stroke: var(--accent);
}

.chat-action-btn:active {
    transform: scale(0.95);
}

/* Active states for action buttons */
.chat-action-btn--active {
    background: rgba(255, 106, 0, 0.15);
}

.chat-action-btn--active svg {
    stroke: var(--accent);
}

/* Voice listening state */
.chat-action-btn--listening {
    background: rgba(255, 106, 0, 0.15);
    animation: voice-pulse 1.5s ease-in-out infinite;
}

.chat-action-btn--listening svg {
    stroke: var(--accent);
}

@keyframes voice-pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(255, 106, 0, 0.4);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(255, 106, 0, 0);
    }
}

/* Text Input - Auto-expanding Textarea */
.chat-input-form textarea {
    flex: 1;
    min-width: 0;
    height: 36px;
    min-height: 36px;
    max-height: 120px; /* ~5 lines before scrolling */
    padding: 0.45rem 0.875rem;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: 18px;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    line-height: 1.5;
    resize: none;
    overflow-y: hidden;
    transition: border-color var(--transition-fast);
}

.chat-input-form textarea:focus {
    outline: none;
    border-color: var(--text-muted);
}

.chat-input-form textarea::placeholder {
    color: var(--text-muted);
}

/* When textarea has multiple lines or exceeds max-height */
.chat-input-form textarea.is-multiline {
    border-radius: 12px;
}

.chat-input-form textarea.has-scroll {
    overflow-y: auto;
}

/* Send Button */
.chat-send-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    background: var(--accent);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.chat-send-btn svg {
    width: 18px;
    height: 18px;
    stroke: white;
    fill: none;
    transform: translateX(1px);
}

.chat-send-btn:hover {
    background: var(--accent-dim);
    transform: scale(1.05);
}

.chat-send-btn:active {
    transform: scale(0.95);
}

/* Image Preview - Above Input */
/* Multi-image preview grid */
.chat-images-preview {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.chat-images-grid {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    flex: 1;
    min-width: 0;
}

.chat-image-thumb {
    position: relative;
    width: 48px;
    height: 48px;
    flex-shrink: 0;
}

.chat-image-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
}

.chat-image-thumb__actions {
    position: absolute;
    top: -6px;
    right: -6px;
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.chat-image-thumb:hover .chat-image-thumb__actions {
    opacity: 1;
}

.chat-image-thumb__remove,
.chat-image-thumb__dupe {
    width: 18px;
    height: 18px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 50%;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: bold;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.chat-image-thumb__remove:hover {
    background: var(--color-error);
    border-color: var(--color-error);
    color: white;
}

.chat-image-thumb__dupe:hover {
    background: var(--color-success);
    border-color: var(--color-success);
    color: black;
}

.chat-image-thumb__btn--disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.chat-image-thumb__btn--disabled:hover {
    background: var(--bg-card);
    border-color: var(--border-subtle);
    color: var(--text-secondary);
}

.chat-image-thumb__number {
    position: absolute;
    bottom: 2px;
    left: 2px;
    background: rgba(0, 0, 0, 0.75);
    color: white;
    font-size: 10px;
    font-weight: bold;
    padding: 1px 4px;
    border-radius: 2px;
}

.chat-images-clear {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: var(--text-xs);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    flex-shrink: 0;
}

.chat-images-clear:hover {
    color: var(--color-error);
}

/* Image button states */
.chat-action-btn--maxed {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Image badge in chat messages */
.message-image-badge {
    margin-right: 0.25rem;
}

/* ============================================
   History Page - Workout Cards
   ============================================ */
.page-main {
    padding: 1.25rem;
    max-width: 600px;
    margin: 0 auto;
}

.page-header {
    margin-bottom: 1.5rem;
}

.page-header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.workout-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.workout-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.workout-card:hover {
    border-color: var(--text-ghost);
}

.workout-card__date {
    font-size: 0.75rem;
    color: var(--text-muted);
    min-width: 65px;
    text-transform: uppercase;
}

.workout-card__content {
    flex: 1;
}

.workout-card__summary {
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.2rem;
}

.workout-card__meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.workout-card__xp {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.badge {
    display: inline-flex;
    padding: 0.15rem 0.4rem;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    border-radius: var(--radius-sm);
}

.badge--pr {
    background: var(--accent);
    color: var(--bg-void);
}

.load-more-container {
    display: flex;
    justify-content: center;
    padding: 1.5rem;
}

.empty-state,
.error-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

.loading {
    text-align: center;
    padding: 2rem;
    color: var(--text-ghost);
}

/* Workout Detail */
.workout-detail__summary {
    margin-bottom: 1.5rem;
}

.workout-detail__summary p {
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.workout-detail__stats {
    display: flex;
    gap: 1.5rem;
}

.workout-detail__stats .stat {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.workout-detail__stats .stat strong {
    color: var(--text-primary);
}

.workout-detail h3 {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 1rem;
    color: var(--text-muted);
}

.exercise-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.exercise-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.25rem 1rem;
    padding: 0.75rem;
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
}

.exercise-name {
    font-weight: 500;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-transform: capitalize;
}

.exercise-details {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.exercise-muscles {
    font-size: 0.7rem;
    color: var(--text-ghost);
    text-transform: uppercase;
}

.exercise-xp {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    color: var(--text-muted);
    justify-self: end;
}

.workout-detail__actions {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    justify-content: flex-end;
}

/* ============================================
   Progress Page
   ============================================ */
.stats-summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.stats-summary .stat-box {
    padding: 1rem 0.5rem;
    text-align: center;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
}

.stats-summary .stat-box__value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.stats-summary .stat-box__label {
    font-size: 0.6rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.25rem;
}

.progress-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chart-card {
    padding: 1rem;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
}

.chart-card h3 {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

/* Bar Chart */
.chart-container {
    height: 150px;
    position: relative;
}

.bar-chart {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    height: 100%;
    gap: 0.35rem;
    padding-bottom: 1.5rem;
}

.bar-chart__bar {
    flex: 1;
    background: var(--text-ghost);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    min-height: 2px;
    position: relative;
    transition: all var(--transition-normal);
}

.bar-chart__bar:hover {
    background: var(--text-muted);
}

.bar-chart__label {
    position: absolute;
    bottom: -1.25rem;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.6rem;
    color: var(--text-ghost);
    white-space: nowrap;
}

.bar-chart__value {
    position: absolute;
    top: -1rem;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.6rem;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.bar-chart__bar:hover .bar-chart__value {
    opacity: 1;
}

/* Calendar */
.calendar-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
    margin-bottom: 0.5rem;
}

.calendar-header span {
    text-align: center;
    font-size: 0.6rem;
    color: var(--text-ghost);
    font-weight: 600;
    text-transform: uppercase;
}

.streak-calendar {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
}

.calendar-day {
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: var(--text-ghost);
    font-family: 'JetBrains Mono', monospace;
}

.calendar-day--empty {
    background: transparent;
}

.calendar-day--workout {
    background: var(--text-muted);
    color: var(--bg-void);
}

.calendar-day--rest {
    background: var(--text-ghost);
    color: var(--bg-void);
}

.calendar-day--today {
    box-shadow: inset 0 0 0 2px var(--accent);
}

.calendar-day--future {
    opacity: 0.3;
}

.calendar-legend {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-subtle);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: var(--radius-sm);
}

.legend-dot--workout {
    background: var(--text-muted);
}

.legend-dot--rest {
    background: var(--text-ghost);
}

/* PR List */
.pr-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.pr-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border-subtle);
}

.pr-item:last-child {
    border-bottom: none;
}

.pr-exercise {
    flex: 1;
    font-weight: 500;
    font-size: 0.85rem;
    text-transform: capitalize;
}

.pr-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    color: var(--accent);
}

.pr-date {
    font-size: 0.75rem;
    color: var(--text-ghost);
}

/* All-Time Stats */
.all-time-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.all-time-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
}

.all-time-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.all-time-label {
    font-size: 0.6rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.25rem;
}

/* ============================================
   Compete Page - Challenges
   ============================================ */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.page-header .btn {
    padding: 0.6rem 1rem;
    font-size: 0.75rem;
}

.challenge-lobby {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.challenge-card {
    padding: 1rem;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.challenge-card:hover {
    border-color: var(--text-ghost);
}

.challenge-card--joined {
    border-color: var(--accent);
    box-shadow: 0 0 15px var(--accent-glow);
}

.challenge-card__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.challenge-card__name {
    font-size: 1rem;
    font-weight: 600;
}

.challenge-card__days {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--accent);
    font-weight: 600;
}

.challenge-card__meta {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.75rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.challenge-card__footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.challenge-card__creator {
    font-size: 0.7rem;
    color: var(--text-ghost);
}

.btn-sm {
    padding: 0.4rem 0.75rem;
    font-size: 0.7rem;
}

/* Leaderboard */
.leaderboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-subtle);
}

.leaderboard-dates {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.badge--active {
    background: var(--accent);
    color: var(--bg-void);
}

.badge--completed {
    background: var(--text-ghost);
    color: var(--text-primary);
}

.badge--you {
    background: var(--text-ghost);
    color: var(--text-primary);
    font-size: 0.55rem;
    padding: 0.1rem 0.3rem;
    margin-left: 0.5rem;
}

/* Challenge Countdown Timer */
.countdown-timer {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.5rem;
    background: var(--accent);
    border-radius: var(--radius-sm);
    font-family: 'JetBrains Mono', monospace;
}

.countdown-segment {
    display: inline-flex;
    align-items: baseline;
    color: var(--bg-void);
}

.countdown-value {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.countdown-label {
    font-size: 0.55rem;
    font-weight: 600;
    opacity: 0.8;
    margin-left: 0.05rem;
}

.challenge-goal-progress {
    margin-bottom: 1rem;
}

.goal-bar {
    height: 8px;
    background: var(--bg-elevated);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.goal-bar__fill {
    height: 100%;
    background: var(--accent);
    border-radius: var(--radius-full);
    transition: width var(--transition-normal);
}

.goal-text {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.leaderboard-row {
    display: grid;
    grid-template-columns: 2rem 1fr auto auto;
    gap: 0.75rem;
    align-items: center;
    padding: 0.75rem;
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
}

.leaderboard-row--you {
    border: 1px solid var(--accent);
    box-shadow: 0 0 10px var(--accent-glow);
}

.leaderboard-rank {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-muted);
}

.rank--first .leaderboard-rank {
    color: var(--accent);
    font-size: 1rem;
}

.rank--second .leaderboard-rank,
.rank--third .leaderboard-rank {
    color: var(--text-secondary);
}

.leaderboard-name {
    font-weight: 500;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
}

.leaderboard-stats {
    font-size: 0.75rem;
    color: var(--text-ghost);
}

.leaderboard-xp {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.rank--first .leaderboard-xp {
    color: var(--accent);
}

/* Form select styling */
.form-group select {
    width: 100%;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    cursor: pointer;
}

.form-group select:focus {
    outline: none;
    border-color: var(--text-muted);
}

.form-hint {
    display: block;
    margin-top: 0.4rem;
    font-size: 0.7rem;
    color: var(--text-ghost);
}

.empty-hint {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-ghost);
}

/* Dashboard challenge widget */
.challenge-widget {
    margin-bottom: 1.25rem;
    color: var(--text-primary);
}

.challenge-widget__item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    color: var(--text-primary);
    text-decoration: none;
    text-transform: none;
}

.challenge-widget__item:hover {
    border-color: var(--text-ghost);
}

.challenge-widget__item:last-child {
    margin-bottom: 0;
}

.challenge-widget__name {
    font-size: 0.85rem;
    font-weight: 500;
}

.challenge-widget__rank {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    color: var(--accent);
}

/* ============================================
   Achievement Burst Animation
   ============================================ */
@keyframes achievement-burst {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 var(--accent-glow);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 40px var(--accent-glow);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 20px var(--accent-glow);
    }
}

.achievement-burst {
    animation: achievement-burst 0.6s ease-out;
}

/* ============================================
   Workout Share Card
   ============================================ */
.share-card-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
    z-index: 9000;
    padding: 1rem;
    overflow-y: auto;
}

.share-card-overlay.hidden {
    display: none;
}

.share-card__close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    z-index: 10;
}

.share-card__close:hover {
    background: rgba(255, 255, 255, 0.2);
    color: var(--text-primary);
}

.share-card {
    background: linear-gradient(165deg, #1a1a1a 0%, #0a0a0a 100%);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.25rem;
    width: 100%;
    max-width: 340px;
    box-shadow:
        0 0 0 1px rgba(255, 106, 0, 0.15),
        0 25px 50px rgba(0, 0, 0, 0.6);
}

.share-card__header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.share-card__logo {
    width: 20px;
    height: 20px;
}

.share-card__brand {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    color: var(--text-muted);
}

.share-card__hero {
    text-align: center;
    margin-bottom: 1rem;
}

.share-card__level {
    margin-bottom: 0.25rem;
}

.share-card__level-label {
    display: block;
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.2em;
    color: var(--text-ghost);
    text-transform: uppercase;
}

.share-card__level-num {
    font-family: 'JetBrains Mono', monospace;
    font-size: 3rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.share-card__xp-earned {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent);
    text-shadow: 0 0 20px var(--accent-glow);
}

.share-card__divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border), transparent);
    margin: 1rem -0.5rem;
}

/* Exercise List */
.share-card__exercises {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.share-card__exercise {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 6px;
    border-left: 2px solid var(--border);
}

.share-card__exercise--pr {
    border-left-color: var(--accent);
    background: rgba(255, 106, 0, 0.05);
}

.share-card__exercise-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
}

.share-card__exercise-name .pr-badge {
    display: inline-block;
    padding: 0.1rem 0.35rem;
    background: var(--accent);
    color: #000;
    font-size: 0.55rem;
    font-weight: 700;
    border-radius: 3px;
    margin-left: 0.35rem;
    vertical-align: middle;
}

.share-card__exercise-detail {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--text-muted);
    flex: 1;
    text-align: center;
}

.share-card__exercise-xp {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent);
    min-width: 50px;
    text-align: right;
}

/* Muscle Tags */
.share-card__muscles {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.4rem;
    margin-top: 1rem;
}

.share-card__muscle-tag {
    padding: 0.2rem 0.5rem;
    background: rgba(255, 106, 0, 0.1);
    border: 1px solid rgba(255, 106, 0, 0.25);
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Footer */
.share-card__footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-subtle);
}

.share-card__date {
    font-size: 0.7rem;
    color: var(--text-ghost);
}

.share-card__username {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Actions */
.share-card__actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
    max-width: 340px;
}

.share-card__actions .btn {
    width: 100%;
    justify-content: center;
}

.btn-icon {
    width: 16px;
    height: 16px;
    margin-right: 0.5rem;
    flex-shrink: 0;
}

/* SVG icons in buttons */
svg.btn-icon {
    stroke: currentColor;
}

/* ============================================
   Trophy Display (next to level badge)
   ============================================ */
.level-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.level-row__right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.trophy-display {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.6rem;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.02);
}

.trophy-display .trophy-icon {
    width: 18px;
    height: 18px;
    filter: invert(48%) sepia(99%) saturate(1500%) hue-rotate(360deg) brightness(103%) contrast(106%);
    opacity: 0.8;
}

.trophy-count {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Badge Display (inline with trophy) */
.badge-display {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.6rem;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.02);
    text-decoration: none;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.badge-display:hover {
    border-color: var(--accent);
    background: rgba(255, 106, 0, 0.05);
}

.badge-display .badge-icon {
    width: 18px;
    height: 18px;
}

.badge-count {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Trophy display pulse when new trophy earned */
.trophy-display--new {
    border-color: var(--accent);
    box-shadow: 0 0 15px var(--accent-glow);
    animation: trophy-pulse 2s ease-in-out infinite;
}

@keyframes trophy-pulse {
    0%, 100% {
        box-shadow: 0 0 10px var(--accent-glow);
    }
    50% {
        box-shadow: 0 0 25px var(--accent-glow);
    }
}

/* ============================================
   Trophy Win Animation Overlay
   ============================================ */
.trophy-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.trophy-overlay.hidden {
    display: none;
}

.trophy-overlay.animate {
    opacity: 1;
    pointer-events: auto;
}

.trophy-content {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Burst effect behind trophy */
.trophy-burst {
    position: absolute;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    opacity: 0;
    transform: scale(0);
}

.trophy-overlay--gold .trophy-burst {
    background: radial-gradient(circle, #ffd700 0%, transparent 70%);
}

.trophy-overlay--silver .trophy-burst {
    background: radial-gradient(circle, #c0c0c0 0%, transparent 70%);
}

.trophy-overlay--bronze .trophy-burst {
    background: radial-gradient(circle, #cd7f32 0%, transparent 70%);
}

.trophy-overlay.animate .trophy-burst {
    animation: trophy-burst-expand 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes trophy-burst-expand {
    0% {
        opacity: 0.8;
        transform: scale(0);
    }
    50% {
        opacity: 0.6;
    }
    100% {
        opacity: 0;
        transform: scale(3);
    }
}

/* Trophy icon */
.trophy-icon-large {
    position: relative;
    width: 120px;
    height: 120px;
    z-index: 1;
    opacity: 0;
    transform: scale(0.3) rotate(-20deg);
}

/* Trophy color variants */
.trophy-icon--gold {
    filter: invert(79%) sepia(68%) saturate(500%) hue-rotate(360deg) brightness(105%);
}

.trophy-icon--silver {
    filter: invert(85%) sepia(5%) saturate(100%) brightness(115%);
}

.trophy-icon--bronze {
    filter: invert(55%) sepia(50%) saturate(500%) hue-rotate(350deg) brightness(95%);
}

.trophy-overlay.animate .trophy-icon-large {
    animation: trophy-appear 0.7s 0.2s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes trophy-appear {
    0% {
        opacity: 0;
        transform: scale(0.3) rotate(-20deg);
    }
    60% {
        opacity: 1;
        transform: scale(1.3) rotate(5deg);
    }
    80% {
        transform: scale(0.95) rotate(-2deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotate(0);
    }
}

/* Trophy text */
.trophy-text {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    margin-top: 1.5rem;
    z-index: 1;
}

.trophy-label {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    opacity: 0;
    transform: translateY(20px);
}

.trophy-overlay--gold .trophy-label {
    color: #ffd700;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
}

.trophy-overlay--silver .trophy-label {
    color: #c0c0c0;
    text-shadow: 0 0 20px rgba(192, 192, 192, 0.5);
}

.trophy-overlay--bronze .trophy-label {
    color: #cd7f32;
    text-shadow: 0 0 20px rgba(205, 127, 50, 0.5);
}

.trophy-overlay.animate .trophy-label {
    animation: trophy-text-appear 0.5s 0.6s ease-out forwards;
}

.trophy-challenge {
    font-size: 0.9rem;
    color: var(--text-muted);
    opacity: 0;
    transform: translateY(15px);
}

.trophy-overlay.animate .trophy-challenge {
    animation: trophy-text-appear 0.5s 0.75s ease-out forwards;
}

@keyframes trophy-text-appear {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Shimmer effect on gold trophy */
.trophy-overlay--gold.animate .trophy-icon-large {
    animation: trophy-appear 0.7s 0.2s cubic-bezier(0.34, 1.56, 0.64, 1) forwards,
               trophy-shimmer-gold 2s 1.2s ease-in-out infinite;
}

@keyframes trophy-shimmer-gold {
    0%, 100% {
        filter: invert(79%) sepia(68%) saturate(500%) hue-rotate(360deg) brightness(105%);
    }
    50% {
        filter: invert(79%) sepia(68%) saturate(500%) hue-rotate(360deg) brightness(140%);
    }
}

/* ============================================
   Level Up Animation
   ============================================ */
.levelup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.levelup-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.levelup-content {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.levelup-burst {
    position: absolute;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, var(--accent) 0%, transparent 70%);
    border-radius: 50%;
    opacity: 0;
    transform: scale(0);
}

.levelup-overlay.animate .levelup-burst {
    animation: burst-expand 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes burst-expand {
    0% {
        opacity: 0.8;
        transform: scale(0);
    }
    50% {
        opacity: 0.6;
    }
    100% {
        opacity: 0;
        transform: scale(3);
    }
}

.levelup-particles {
    position: absolute;
    width: 1px;
    height: 1px;
}

.levelup-particles .particle {
    position: absolute;
    width: var(--size);
    height: var(--size);
    background: var(--accent);
    border-radius: 50%;
    opacity: 0;
}

.levelup-overlay.animate .particle {
    animation: particle-explode var(--duration) var(--delay) cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes particle-explode {
    0% {
        opacity: 1;
        transform: translate(0, 0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(var(--tx), var(--ty)) scale(0);
    }
}

.levelup-text {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    z-index: 1;
}

.levelup-label {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.3em;
    color: var(--text-muted);
    text-transform: uppercase;
    opacity: 0;
    transform: translateY(20px);
}

.levelup-overlay.animate .levelup-label {
    animation: label-appear 0.5s 0.1s ease-out forwards;
}

@keyframes label-appear {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.levelup-number {
    font-family: 'JetBrains Mono', monospace;
    font-size: 8rem;
    font-weight: 700;
    color: var(--accent);
    text-shadow:
        0 0 20px var(--accent-glow),
        0 0 40px var(--accent-glow),
        0 0 80px rgba(255, 106, 0, 0.3);
    opacity: 0;
    transform: scale(0.5);
}

.levelup-overlay.animate .levelup-number {
    animation: number-appear 0.6s 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes number-appear {
    0% {
        opacity: 0;
        transform: scale(0.5);
    }
    60% {
        opacity: 1;
        transform: scale(1.2);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Pulse effect after main animation */
.levelup-overlay.animate .levelup-number {
    animation:
        number-appear 0.6s 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards,
        number-glow 1s 0.9s ease-in-out 2;
}

@keyframes number-glow {
    0%, 100% {
        text-shadow:
            0 0 20px var(--accent-glow),
            0 0 40px var(--accent-glow),
            0 0 80px rgba(255, 106, 0, 0.3);
    }
    50% {
        text-shadow:
            0 0 30px var(--accent-glow),
            0 0 60px var(--accent-glow),
            0 0 120px rgba(255, 106, 0, 0.5);
    }
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 400px) {
    .stats-summary {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================================
   PWA Install UI
   ============================================ */

/* Install Banner (top popup) */
.pwa-install-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #1a1a1a 0%, #0d0d0d 100%);
    border-bottom: 1px solid var(--accent);
    padding: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    box-shadow: 0 4px 20px rgba(255, 106, 0, 0.2);
    animation: slideDown 0.3s ease-out;
}

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

.pwa-install-banner.hidden {
    display: none;
}

.pwa-install-banner__content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.pwa-install-banner__icon {
    width: 40px;
    height: 40px;
    filter: invert(48%) sepia(99%) saturate(1500%) hue-rotate(360deg) brightness(103%) contrast(106%);
}

.pwa-install-banner__text {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.pwa-install-banner__text strong {
    font-size: 0.95rem;
    color: var(--text-primary);
}

.pwa-install-banner__text span {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.pwa-install-banner__actions {
    display: flex;
    gap: 0.5rem;
}

.pwa-install-banner__actions .btn {
    flex: 1;
    padding: 0.6rem 1rem;
}

/* Footer Install Button */
.pwa-install-footer {
    display: flex;
    justify-content: center;
    padding: 1.5rem 0 0.5rem;
    margin-top: 1rem;
    border-top: 1px solid var(--border-subtle);
}

.pwa-install-footer .btn {
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: none;
}

.pwa-install-footer .btn:hover {
    color: var(--accent);
}

.pwa-install-footer .btn-icon {
    width: 16px;
    height: 16px;
    margin-right: 0.5rem;
}

/* iOS-specific: Add safe area padding when in standalone mode */
@media (display-mode: standalone) {
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }

    .app-header {
        padding-top: calc(1rem + env(safe-area-inset-top));
    }

    /* Hide install UI when running as installed app */
    .pwa-install-banner,
    .pwa-install-footer {
        display: none !important;
    }
}

/* Share App Footer Button */
.share-app-footer {
    display: flex;
    justify-content: center;
    padding: 1rem 0 1.5rem;
}

.share-app-footer .btn {
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: none;
}

.share-app-footer .btn:hover {
    color: var(--accent);
}

.share-app-footer .btn-icon {
    width: 16px;
    height: 16px;
    margin-right: 0.5rem;
}

/* ============================================
   Badges Page
   ============================================ */
.page-badges .page-main {
    padding: 1rem;
    padding-bottom: 2rem;
}

/* Badge Summary Ring */
.badge-summary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    padding: 1.5rem;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    margin-bottom: 1.5rem;
}

.badge-summary__ring {
    position: relative;
    width: 100px;
    height: 100px;
}

.badge-summary__ring svg {
    transform: rotate(-90deg);
    width: 100%;
    height: 100%;
}

.badge-summary__ring-bg {
    fill: none;
    stroke: var(--bg-elevated);
    stroke-width: 8;
}

.badge-summary__ring-progress {
    fill: none;
    stroke: var(--accent);
    stroke-width: 8;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.5s ease;
}

.badge-summary__count {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.badge-summary__total {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.badge-summary__text {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.badge-summary__percent {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
    font-family: 'JetBrains Mono', monospace;
}

.badge-summary__label {
    font-size: 0.9rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Badge Categories */
.badge-categories {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.badge-category {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 1rem;
}

.badge-category__title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-subtle);
}

/* Badge Grid */
.badge-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 1rem;
}

.badge-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: transform var(--transition-fast);
}

.badge-item:active {
    transform: scale(0.95);
}

.badge-item__icon {
    position: relative;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.badge-item__icon img {
    width: 50px;
    height: 50px;
    object-fit: contain;
}

.badge-item--locked .badge-item__icon img {
    filter: grayscale(1) brightness(0.4);
    opacity: 0.5;
}

.badge-item--earned .badge-item__icon img {
    filter: none;
}

.badge-item__name {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.2;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.badge-item--earned .badge-item__name {
    color: var(--text-primary);
}

/* Badge Progress Ring (for locked badges with progress) */
.badge-item__progress-ring {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.badge-item__progress-ring svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.badge-item__ring-bg {
    fill: none;
    stroke: var(--bg-elevated);
    stroke-width: 2;
}

.badge-item__ring-fill {
    fill: none;
    stroke: var(--accent);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-dasharray: 0, 100;
}

/* Badge Detail Modal */
.modal-content--badge {
    max-width: 340px;
    text-align: center;
    padding: 2.5rem 1.5rem 2rem;
    background: radial-gradient(ellipse at top, var(--bg-elevated) 0%, var(--bg-card) 100%);
    border: 1px solid var(--border-card);
    overflow: visible;
}

.badge-detail {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
}

.badge-detail__icon {
    position: relative;
    width: 160px;
    height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.badge-detail__icon::before {
    content: '';
    position: absolute;
    inset: -10px;
    background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.badge-detail--earned .badge-detail__icon::before {
    opacity: 1;
    animation: badge-glow-pulse 2s ease-in-out infinite;
}

@keyframes badge-glow-pulse {
    0%, 100% { opacity: 0.4; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.05); }
}

.badge-detail__icon img {
    position: relative;
    width: 240px;
    height: 240px;
    object-fit: contain;
    filter: drop-shadow(0 4px 20px rgba(0, 0, 0, 0.5));
}

.badge-detail--earned .badge-detail__icon img {
    filter: drop-shadow(0 0 20px var(--accent-glow)) drop-shadow(0 4px 20px rgba(0, 0, 0, 0.5));
}

.badge-detail__name {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.badge-detail--earned .badge-detail__name {
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.badge-detail__desc {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.5;
    max-width: 280px;
}

.badge-detail__progress {
    width: 100%;
    margin-top: 0.5rem;
}

.badge-detail__progress-bar {
    width: 100%;
    height: 10px;
    background: var(--bg-void);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: 0.75rem;
    border: 1px solid var(--border-subtle);
}

.badge-detail__progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-dim) 0%, var(--accent) 100%);
    border-radius: var(--radius-full);
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 10px var(--accent-glow);
}

.badge-detail__progress-text {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

.badge-detail__earned {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding: 1.25rem 1.5rem;
    background: linear-gradient(135deg, rgba(255, 106, 0, 0.1) 0%, rgba(255, 106, 0, 0.05) 100%);
    border: 1px solid rgba(255, 106, 0, 0.2);
    border-radius: var(--radius-lg);
    width: 100%;
}

.badge-detail__earned-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 600;
}

.badge-detail__earned-date {
    font-size: 1.1rem;
    color: var(--accent);
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
}

/* ============================================
   Badge Unlock Animation Overlay
   ============================================ */
.badge-unlock-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.badge-unlock-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.badge-unlock-content {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
}

/* Burst effect behind badge */
.badge-unlock-burst {
    position: absolute;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, var(--accent) 0%, transparent 70%);
    border-radius: 50%;
    opacity: 0;
    transform: scale(0);
}

.badge-unlock-overlay.animate .badge-unlock-burst {
    animation: badge-burst 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes badge-burst {
    0% { opacity: 0.9; transform: scale(0); }
    50% { opacity: 0.5; }
    100% { opacity: 0; transform: scale(2.5); }
}

/* Shatter particles from locked badge */
.badge-unlock-shatter {
    position: absolute;
    width: 1px;
    height: 1px;
}

.badge-unlock-shatter .shard {
    position: absolute;
    background: linear-gradient(135deg, #333 0%, #555 100%);
    opacity: 0;
}

.badge-unlock-overlay.animate .shard {
    animation: shard-explode var(--duration) var(--delay) cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes shard-explode {
    0% {
        opacity: 1;
        transform: translate(0, 0) rotate(0deg) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(var(--tx), var(--ty)) rotate(var(--rot)) scale(0);
    }
}

/* Orange particles */
.badge-unlock-particles {
    position: absolute;
    width: 1px;
    height: 1px;
}

.badge-unlock-particles .particle {
    position: absolute;
    width: var(--size);
    height: var(--size);
    background: var(--accent);
    border-radius: 50%;
    opacity: 0;
    box-shadow: 0 0 6px var(--accent);
}

.badge-unlock-overlay.animate .particle {
    animation: badge-particle var(--duration) var(--delay) cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes badge-particle {
    0% {
        opacity: 1;
        transform: translate(0, 0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(var(--tx), var(--ty)) scale(0);
    }
}

/* Badge icon container */
.badge-unlock-icon {
    position: relative;
    width: 160px;
    height: 160px;
    z-index: 2;
}

.badge-unlock-icon__locked,
.badge-unlock-icon__unlocked {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.badge-unlock-icon__locked img,
.badge-unlock-icon__unlocked img {
    width: 140px;
    height: 140px;
    object-fit: contain;
}

.badge-unlock-icon__locked {
    opacity: 1;
}

.badge-unlock-icon__unlocked {
    opacity: 0;
    transform: scale(0.5);
}

.badge-unlock-overlay.animate .badge-unlock-icon__locked {
    animation: locked-shatter 0.3s 0.1s ease-out forwards;
}

@keyframes locked-shatter {
    0% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.1); }
    100% { opacity: 0; transform: scale(0); }
}

.badge-unlock-overlay.animate .badge-unlock-icon__unlocked {
    animation: unlocked-reveal 0.6s 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes unlocked-reveal {
    0% { opacity: 0; transform: scale(0.5); }
    60% { opacity: 1; transform: scale(1.15); }
    100% { opacity: 1; transform: scale(1); }
}

/* Glow ring around unlocked badge */
.badge-unlock-icon__unlocked::before {
    content: '';
    position: absolute;
    inset: -20px;
    border: 2px solid var(--accent);
    border-radius: 50%;
    opacity: 0;
}

.badge-unlock-overlay.animate .badge-unlock-icon__unlocked::before {
    animation: glow-ring 0.8s 0.4s ease-out forwards;
}

@keyframes glow-ring {
    0% { opacity: 0; transform: scale(0.8); }
    50% { opacity: 0.8; }
    100% { opacity: 0; transform: scale(1.5); }
}

/* Text content */
.badge-unlock-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    z-index: 2;
}

.badge-unlock-label {
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.25em;
    color: var(--accent);
    text-transform: uppercase;
    opacity: 0;
    transform: translateY(10px);
}

.badge-unlock-overlay.animate .badge-unlock-label {
    animation: text-appear 0.4s 0.5s ease-out forwards;
}

.badge-unlock-name {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
    opacity: 0;
    transform: translateY(10px);
}

.badge-unlock-overlay.animate .badge-unlock-name {
    animation: text-appear 0.4s 0.6s ease-out forwards;
}

@keyframes text-appear {
    0% { opacity: 0; transform: translateY(10px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* Pulsing glow on revealed badge */
.badge-unlock-overlay.animate .badge-unlock-icon__unlocked img {
    animation: badge-glow 1s 0.9s ease-in-out 2;
}

@keyframes badge-glow {
    0%, 100% {
        filter: drop-shadow(0 0 20px var(--accent-glow));
    }
    50% {
        filter: drop-shadow(0 0 40px var(--accent)) drop-shadow(0 0 60px var(--accent-glow));
    }
}

/* ============================================
   Tab Navigation
   ============================================ */
.tab-nav {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 0.5rem;
}

.tab-btn {
    background: none;
    border: none;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.tab-btn:hover {
    color: var(--text-primary);
    background: var(--bg-elevated);
}

.tab-btn--active {
    color: var(--accent);
    background: var(--bg-card);
}

.tab-content.hidden {
    display: none;
}

/* ============================================
   Past Challenge Cards
   ============================================ */
.challenge-card--completed {
    opacity: 0.85;
}

.challenge-card--completed:hover {
    opacity: 1;
}

.challenge-card--participated {
    border-left: 3px solid var(--accent);
}

.challenge-card__date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.challenge-card__winner {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.challenge-card__your-stats {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-subtle);
    font-size: 0.85rem;
    color: var(--accent);
    font-weight: 500;
}

.placement-badge {
    display: inline-block;
    padding: 0.15rem 0.4rem;
    font-size: 0.7rem;
    font-weight: 700;
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    margin-left: 0.5rem;
}

.placement-badge.placement--1 {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: #000;
}

.placement-badge.placement--2 {
    background: linear-gradient(135deg, #C0C0C0, #A0A0A0);
    color: #000;
}

.placement-badge.placement--3 {
    background: linear-gradient(135deg, #CD7F32, #A0522D);
    color: #fff;
}

/* ============================================
   Challenge Completion Overlay
   ============================================ */
.challenge-complete-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.challenge-complete-overlay:not(.hidden) {
    opacity: 1;
    pointer-events: auto;
}

.challenge-complete-overlay.animate {
    opacity: 1;
}

.challenge-complete-content {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 1.5rem;
    max-width: 340px;
    max-height: 90vh;
    overflow-y: auto;
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
}

.challenge-complete-burst {
    position: absolute;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, var(--accent) 0%, transparent 70%);
    border-radius: 50%;
    opacity: 0;
    transform: scale(0);
}

.challenge-complete-overlay.animate .challenge-complete-burst {
    animation: burst-expand 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

/* Gold variant */
.challenge-complete--gold .challenge-complete-burst {
    background: radial-gradient(circle, #FFD700 0%, transparent 70%);
}

/* Silver variant */
.challenge-complete--silver .challenge-complete-burst {
    background: radial-gradient(circle, #C0C0C0 0%, transparent 70%);
}

/* Bronze variant */
.challenge-complete--bronze .challenge-complete-burst {
    background: radial-gradient(circle, #CD7F32 0%, transparent 70%);
}

.challenge-complete-header {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    opacity: 0;
    transform: translateY(-20px);
}

.challenge-complete-overlay.animate .challenge-complete-header {
    animation: slide-in 0.5s 0.2s ease-out forwards;
}

.challenge-complete-label {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    color: var(--accent);
    text-transform: uppercase;
}

.challenge-complete--gold .challenge-complete-label {
    color: #FFD700;
}

.challenge-complete--silver .challenge-complete-label {
    color: #C0C0C0;
}

.challenge-complete--bronze .challenge-complete-label {
    color: #CD7F32;
}

.challenge-complete-name {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.challenge-complete-placement {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 1.5rem;
    opacity: 0;
    transform: scale(0.5);
}

.challenge-complete-overlay.animate .challenge-complete-placement {
    animation: pop-in 0.4s 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.challenge-complete-rank {
    font-size: 4rem;
    font-weight: 800;
    line-height: 1;
    color: var(--accent);
    font-family: 'JetBrains Mono', monospace;
}

.challenge-complete--gold .challenge-complete-rank {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.challenge-complete--silver .challenge-complete-rank {
    background: linear-gradient(135deg, #E8E8E8, #A0A0A0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.challenge-complete--bronze .challenge-complete-rank {
    background: linear-gradient(135deg, #CD7F32, #8B4513);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.challenge-complete-of {
    font-size: 1rem;
    color: var(--text-secondary);
}

.challenge-complete-stats {
    display: flex;
    gap: 2rem;
    margin-bottom: 1.5rem;
    opacity: 0;
}

.challenge-complete-overlay.animate .challenge-complete-stats {
    animation: fade-in 0.4s 0.6s ease-out forwards;
}

.challenge-complete-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.challenge-complete-stat .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
}

.challenge-complete-stat .stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.challenge-complete-winner {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    opacity: 0;
}

.challenge-complete-overlay.animate .challenge-complete-winner {
    animation: fade-in 0.4s 0.7s ease-out forwards;
}

.challenge-complete-winner--you {
    color: #FFD700;
    font-weight: 600;
    font-size: 1rem;
}

/* Your Stats Section */
.challenge-complete-your-stats {
    width: 100%;
    margin-bottom: 1rem;
    opacity: 0;
}

.challenge-complete-overlay.animate .challenge-complete-your-stats {
    animation: fade-in 0.4s 0.65s ease-out forwards;
}

.your-stats-title {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.5rem;
    text-align: left;
}

.your-stats-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}

.your-stat {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.6rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.your-stat .stat-icon {
    width: 14px;
    height: 14px;
    filter: invert(1);
    opacity: 0.7;
}

/* Awards Section */
.challenge-complete-awards {
    width: 100%;
    margin-bottom: 1rem;
    opacity: 0;
}

.challenge-complete-overlay.animate .challenge-complete-awards {
    animation: fade-in 0.4s 0.7s ease-out forwards;
}

.awards-title {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.5rem;
    text-align: left;
}

.awards-title-icon {
    width: 14px;
    height: 14px;
    filter: invert(1);
    opacity: 0.7;
}

.awards-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.award-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.6rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    font-size: 0.8rem;
}

.award-item.award--you {
    background: rgba(255, 106, 0, 0.1);
    border-color: rgba(255, 106, 0, 0.3);
}

.award-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    filter: invert(1);
    opacity: 0.8;
}

.award-item.award--you .award-icon {
    filter: invert(48%) sepia(99%) saturate(1500%) hue-rotate(360deg) brightness(103%) contrast(106%);
    opacity: 1;
}

.award-details {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.award-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.75rem;
}

.award-winner {
    color: var(--text-muted);
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.award-you-badge {
    background: var(--accent);
    color: #000;
    font-size: 0.55rem;
    font-weight: 700;
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.award-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.award-item.award--you .award-value {
    color: var(--accent);
}

.challenge-complete-dismiss {
    opacity: 0;
    transform: translateY(10px);
}

.challenge-complete-overlay.animate .challenge-complete-dismiss {
    animation: slide-in 0.4s 0.8s ease-out forwards;
}

@keyframes slide-in {
    0% {
        opacity: 0;
        transform: translateY(-20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pop-in {
    0% {
        opacity: 0;
        transform: scale(0.5);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes fade-in {
    0% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}

/* ============================================
   Workout Generator
   ============================================ */

.generator-page {
    background: var(--bg-void);
}

.generator-main {
    max-width: 600px;
    margin: 0 auto;
    padding: var(--space-4);
    padding-bottom: var(--space-8);
}

.generator-section {
    margin-bottom: var(--space-6);
}

.section-title {
    font-size: var(--text-xl);
    font-weight: 700;
    margin-bottom: var(--space-2);
}

.section-subtitle {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-bottom: var(--space-5);
}

/* Theme Grid */
.theme-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3);
    margin-bottom: var(--space-5);
}

@media (min-width: 480px) {
    .theme-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.theme-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-4);
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: center;
}

.theme-btn:hover {
    background: var(--bg-elevated);
    border-color: var(--accent);
    transform: translateY(-2px);
}

.theme-btn--selected {
    background: var(--accent-subtle);
    border-color: var(--accent);
    box-shadow: 0 0 20px var(--accent-glow);
}

.theme-btn--selected .theme-label {
    color: var(--accent);
}

/* Theme Icons - using pre-colored PNG files (white/orange) */
.theme-icon {
    display: block;
    width: var(--icon-lg);
    height: var(--icon-lg);
    object-fit: contain;
    opacity: 0.85;
    transition: opacity var(--transition-fast);
}

.theme-btn:hover .theme-icon,
.theme-btn:active .theme-icon {
    opacity: 1;
}

.theme-btn--selected .theme-icon {
    opacity: 1;
    /* Icon src is swapped to orange via JS */
}

.theme-label {
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--text-primary);
}

.theme-desc {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

/* Generate Button */
.generate-actions {
    text-align: center;
}

/* Loading State */
.generator-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-8);
    min-height: 200px;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border-subtle);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    margin-top: var(--space-4);
    color: var(--text-secondary);
    font-size: var(--text-sm);
}

/* Workout Section */
.workout-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-4);
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
}

.workout-header__left {
    flex: 1;
}

.workout-name {
    font-size: var(--text-lg);
    font-weight: 600;
    margin-bottom: var(--space-2);
}

.workout-theme-tag {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: var(--accent-subtle);
    color: var(--accent);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
}

.workout-header__right {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    text-align: right;
}

.workout-stat {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-2);
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.icon-sm {
    width: var(--icon-sm);
    height: var(--icon-sm);
    opacity: 0.7;
}

/* Tips */
.workout-tips {
    margin-bottom: var(--space-4);
}

.tip-item {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    padding: var(--space-3);
    background: var(--bg-card);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-2);
}

.tip-item:empty {
    display: none;
}

.tip-item--coach {
    border-left: 3px solid var(--accent);
    font-style: italic;
}

/* Exercise List */
.exercise-list {
    margin-bottom: var(--space-4);
}

.exercise-row {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-3);
    overflow: hidden;
    transition: all var(--transition-fast);
}

.exercise-row:hover {
    border-color: var(--border-subtle);
}

.exercise-row__main {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding-right: var(--space-3);
}

.exercise-row--completed {
    opacity: 0.6;
    background: rgba(0, 255, 136, 0.05);
    border-color: var(--color-success);
}

.exercise-row--completed .exercise-name {
    text-decoration: line-through;
    color: var(--text-secondary);
}

.exercise-main {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4);
    cursor: pointer;
    flex: 1;
    min-width: 0;
}

.exercise-checkbox {
    appearance: none;
    width: 24px;
    height: 24px;
    min-width: 24px;
    border: 2px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    background: transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
}

.exercise-checkbox:hover {
    border-color: var(--accent);
}

.exercise-checkbox:checked {
    background: var(--color-success);
    border-color: var(--color-success);
}

.exercise-checkbox:checked::after {
    content: '';
    position: absolute;
    left: 6px;
    top: 2px;
    width: 6px;
    height: 12px;
    border: solid #000;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.exercise-info {
    flex: 1;
    min-width: 0;
}

.exercise-name {
    font-weight: 500;
    font-size: var(--text-base);
    margin-bottom: var(--space-1);
}

.exercise-detail {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    font-family: 'JetBrains Mono', monospace;
}

.exercise-muscles {
    display: flex;
    gap: var(--space-2);
    margin-top: var(--space-2);
    flex-wrap: wrap;
}

.exercise-muscle {
    font-size: var(--text-xs);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
}

.exercise-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: var(--space-1);
}

.exercise-xp {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--accent);
    font-family: 'JetBrains Mono', monospace;
}

.exercise-pr-tag {
    font-size: var(--text-xs);
    padding: 0.125rem 0.5rem;
    background: var(--medal-gold);
    color: #000;
    border-radius: var(--radius-sm);
    font-weight: 700;
}

.exercise-edit-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    padding: var(--space-2);
    min-width: 44px;
    min-height: 44px;
    margin-left: var(--space-2);
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.exercise-edit-btn:hover,
.exercise-edit-btn:active {
    background: var(--accent-subtle);
    border-color: var(--accent);
    color: var(--accent);
}

.exercise-row--editing .exercise-edit-btn {
    background: var(--accent);
    border-color: var(--accent);
    color: #000;
}

.exercise-row {
    position: relative;
}

.exercise-edit-btn svg {
    width: 18px;
    height: 18px;
}

/* Edit Panel */
.exercise-edit-panel {
    display: none;
    padding: var(--space-4);
    padding-top: 0;
    border-top: 1px dashed var(--border-subtle);
}

.exercise-row--editing .exercise-edit-panel {
    display: block;
}

.edit-row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
}

.edit-row label {
    width: 80px;
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.edit-input {
    flex: 1;
    padding: var(--space-2) var(--space-3);
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: var(--text-sm);
    font-family: 'JetBrains Mono', monospace;
    max-width: 100px;
}

.edit-input:focus {
    outline: none;
    border-color: var(--accent);
}

.edit-select {
    padding: var(--space-2);
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: var(--text-sm);
}

.edit-suffix {
    font-size: var(--text-sm);
    color: var(--text-muted);
}

.edit-notes {
    font-size: var(--text-sm);
    color: var(--text-muted);
    font-style: italic;
    margin-top: var(--space-2);
}

/* Progress Bar */
.workout-progress {
    margin-bottom: var(--space-5);
}

.progress-bar {
    height: 8px;
    background: var(--bg-elevated);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: var(--space-2);
}

.progress-fill {
    height: 100%;
    background: var(--color-success);
    border-radius: var(--radius-full);
    transition: width var(--transition-normal);
}

.progress-text {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    text-align: center;
    display: block;
}

/* Workout Actions */
.workout-actions {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.actions-secondary {
    display: flex;
    gap: var(--space-3);
}

.actions-secondary .btn {
    flex: 1;
}

/* Success Overlay */
.success-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    animation: fade-in 0.3s ease-out forwards;
}

.success-overlay.hidden {
    display: none;
}

.success-content {
    text-align: center;
    padding: var(--space-6);
    animation: pop-in 0.4s 0.2s ease-out both;
}

.success-burst {
    position: absolute;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, var(--color-success) 0%, transparent 70%);
    border-radius: 50%;
    opacity: 0.3;
    animation: pulse 2s ease-in-out infinite;
}

.success-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto var(--space-4);
    background: var(--color-success);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.success-icon svg {
    width: 40px;
    height: 40px;
    stroke: #000;
}

.success-title {
    font-size: var(--text-xl);
    font-weight: 700;
    margin-bottom: var(--space-4);
}

.success-stats {
    display: flex;
    justify-content: center;
    gap: var(--space-6);
    margin-bottom: var(--space-4);
}

.success-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.success-value {
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--color-success);
    font-family: 'JetBrains Mono', monospace;
}

.success-label {
    font-size: var(--text-xs);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
}

.success-muscles {
    display: flex;
    justify-content: center;
    gap: var(--space-2);
    flex-wrap: wrap;
    margin-bottom: var(--space-5);
}

.success-muscle {
    padding: 0.25rem 0.75rem;
    background: var(--accent-subtle);
    color: var(--accent);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.3; }
    50% { transform: scale(1.2); opacity: 0.5; }
}

/* Custom Theme SVG Icon */
.theme-icon--svg {
    stroke: rgba(255, 255, 255, 0.85);
    transition: stroke var(--transition-fast);
}

.theme-btn:hover .theme-icon--svg,
.theme-btn:active .theme-icon--svg {
    stroke: #ffffff;
}

.theme-btn--selected .theme-icon--svg {
    stroke: var(--accent);
}

/* Custom Prompt Input */
.custom-prompt-container {
    margin-top: var(--space-4);
    animation: slide-down 0.2s ease-out;
}

@keyframes slide-down {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.custom-prompt-label {
    display: block;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

.custom-prompt-input {
    width: 100%;
    padding: var(--space-3);
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: var(--text-sm);
    font-family: inherit;
    resize: vertical;
    min-height: 80px;
    transition: border-color var(--transition-fast);
}

.custom-prompt-input:focus {
    outline: none;
    border-color: var(--accent);
}

.custom-prompt-input::placeholder {
    color: var(--text-muted);
}

/* Add Exercise */
.add-exercise-container {
    margin-top: var(--space-3);
    margin-bottom: var(--space-4);
}

.add-exercise-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    width: 100%;
    padding: var(--space-3);
    background: transparent;
    border: 2px dashed var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: var(--text-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.add-exercise-btn:hover,
.add-exercise-btn:active {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-subtle);
}

.add-exercise-btn svg {
    width: 18px;
    height: 18px;
}

.add-exercise-form {
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    animation: slide-down 0.2s ease-out;
}

.add-exercise-row {
    margin-bottom: var(--space-3);
}

.add-exercise-row:last-child {
    margin-bottom: 0;
}

.add-exercise-row--inline {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.add-exercise-input {
    width: 100%;
    padding: var(--space-2) var(--space-3);
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: var(--text-sm);
}

.add-exercise-input:focus {
    outline: none;
    border-color: var(--accent);
}

.add-exercise-input--sm {
    width: auto;
    flex: 1;
    max-width: 100px;
}

.add-exercise-select {
    padding: var(--space-2) var(--space-3);
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: var(--text-sm);
}

.add-exercise-select--sm {
    width: auto;
    padding: var(--space-2);
}

.add-exercise-separator {
    color: var(--text-muted);
    font-weight: 500;
}

.add-exercise-suffix {
    color: var(--text-muted);
    font-size: var(--text-sm);
}

.add-exercise-actions {
    display: flex;
    gap: var(--space-2);
    justify-content: flex-end;
    margin-top: var(--space-4);
    padding-top: var(--space-3);
    border-top: 1px solid var(--border-subtle);
}

.btn-sm {
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-sm);
}

/* ============================================
   Rest Timer
   ============================================ */

.rest-timer {
    position: relative;
    display: flex;
    align-items: center;
    margin-right: var(--space-2);
}

.rest-timer__toggle {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background-color var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
}

.rest-timer__toggle:hover,
.rest-timer__toggle:active {
    background: var(--bg-elevated);
}

.rest-timer__icon {
    width: 22px;
    height: 22px;
    stroke: var(--text-secondary);
    transition: stroke var(--transition-fast);
}

.rest-timer--active .rest-timer__icon {
    stroke: var(--accent);
}

.rest-timer--done .rest-timer__icon {
    stroke: var(--color-success);
    animation: timer-pulse 0.5s ease-in-out infinite alternate;
}

@keyframes timer-pulse {
    from { transform: scale(1); }
    to { transform: scale(1.1); }
}

/* Badge showing countdown */
.rest-timer__badge {
    position: absolute;
    top: 4px;
    right: 2px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    background: var(--accent);
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    animation: badge-pop 0.2s ease-out;
}

@keyframes badge-pop {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* Dropdown panel - use fixed positioning to escape header stacking context */
.rest-timer__panel {
    position: fixed;
    top: 60px; /* Below header */
    right: var(--space-3);
    min-width: 180px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-3);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    z-index: 10001; /* Above modals */
    animation: panel-slide 0.15s ease-out;
}

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

/* State containers */
.rest-timer__state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
}

/* Idle state */
.rest-timer__label {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    margin-bottom: var(--space-1);
}

.rest-timer__presets {
    display: flex;
    gap: var(--space-2);
    width: 100%;
}

.rest-timer__preset {
    flex: 1;
    padding: var(--space-3) var(--space-2);
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: var(--text-base);
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    cursor: pointer;
    transition: all var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
}

.rest-timer__preset:hover,
.rest-timer__preset:active {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-subtle);
}

/* Running state */
.rest-timer__countdown {
    font-size: var(--text-3xl);
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    color: var(--accent);
    line-height: 1;
    padding: var(--space-2) 0;
}

.rest-timer__cancel {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-2) var(--space-3);
    background: transparent;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: var(--text-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.rest-timer__cancel:hover,
.rest-timer__cancel:active {
    border-color: var(--color-error);
    color: var(--color-error);
}

.rest-timer__cancel svg {
    width: 14px;
    height: 14px;
}

/* Done state */
.rest-timer__done-text {
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--color-success);
    padding: var(--space-3) 0;
    animation: done-bounce 0.4s ease-out;
}

@keyframes done-bounce {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

/* =============================================
   LOGBOOK MODE - Structured Workout Entry
   ============================================= */

/* Mode Toggle */
.input-mode-toggle {
    display: flex;
    gap: 2px;
    background: var(--bg-secondary);
    padding: 3px;
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-3);
}

.mode-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-1);
    padding: var(--space-2) var(--space-3);
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: var(--text-sm);
    font-weight: 500;
    cursor: pointer;
    border-radius: calc(var(--radius-sm) - 2px);
    transition: all var(--transition-fast);
}

.mode-btn:hover {
    color: var(--text-primary);
}

.mode-btn.active {
    background: var(--accent);
    color: var(--bg-primary);
}

.mode-btn .mode-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.mode-btn.active .mode-icon {
    stroke: var(--bg-primary);
}

/* Logbook Container - Expandable, not limited like chat */
.logbook-container {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    overflow-y: auto;
    padding-right: var(--space-2);
    padding-bottom: var(--space-4);
}

.logbook-container.hidden {
    display: none;
}

/* Override modal--chat constraints for logbook mode */
.modal--chat:has(.logbook-container:not(.hidden)) .modal-content {
    max-height: 90vh;
    max-height: 90dvh;
}

.modal--chat:has(.logbook-container:not(.hidden)) {
    align-items: flex-start;
    padding-top: var(--space-4);
    padding-bottom: var(--space-4);
}

/* Exercise Search */
.exercise-search {
    position: relative;
}

.exercise-search-input {
    width: 100%;
    padding: var(--space-3);
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: var(--text-base);
    transition: border-color var(--transition-fast);
}

.exercise-search-input:focus {
    outline: none;
    border-color: var(--accent);
}

.exercise-search-input::placeholder {
    color: var(--text-muted);
}

/* Suggestions Dropdown */
.exercise-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    max-height: 240px;
    overflow-y: auto;
    z-index: 100;
    margin-top: 4px;
    box-shadow: var(--shadow-lg);
}

.exercise-suggestions.hidden {
    display: none;
}

.exercise-suggestion {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3);
    cursor: pointer;
    border-bottom: 1px solid var(--border-subtle);
    transition: background var(--transition-fast);
}

.exercise-suggestion:last-child {
    border-bottom: none;
}

.exercise-suggestion:hover,
.exercise-suggestion.highlighted {
    background: var(--bg-secondary);
}

.exercise-suggestion-name {
    font-weight: 500;
    color: var(--text-primary);
}

.exercise-suggestion-meta {
    font-size: var(--text-xs);
    color: var(--text-muted);
    text-transform: capitalize;
}

/* Exercise Cards */
.logbook-exercises {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.logbook-exercise {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.exercise-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-subtle);
}

.exercise-card-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: var(--text-base);
}

.exercise-card-remove {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.exercise-card-remove:hover {
    background: var(--color-error);
    color: white;
}

.exercise-card-previous {
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-xs);
    color: var(--text-muted);
    background: var(--bg-tertiary);
}

.exercise-card-body {
    padding: var(--space-3);
}

/* Set Table */
.set-table {
    width: 100%;
}

.set-table-header {
    display: grid;
    gap: var(--space-2);
    padding-bottom: var(--space-2);
    border-bottom: 1px solid var(--border-subtle);
    font-size: var(--text-xs);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Different grid layouts based on metric type */
.set-table.metric-volume .set-table-header,
.set-table.metric-volume .set-row {
    grid-template-columns: 40px 1fr 1fr 1fr;
}

.set-table.metric-reps .set-table-header,
.set-table.metric-reps .set-row {
    grid-template-columns: 40px 1fr 1fr;
}

.set-table.metric-duration .set-table-header,
.set-table.metric-duration .set-row {
    grid-template-columns: 40px 1fr 1fr;
}

.set-table.metric-distance .set-table-header,
.set-table.metric-distance .set-row {
    grid-template-columns: 40px 1fr 1fr 1fr;
}

.set-rows {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    padding-top: var(--space-2);
}

.set-row {
    display: grid;
    gap: var(--space-2);
    align-items: center;
    position: relative;
}

.set-row-num {
    font-weight: 600;
    color: var(--text-secondary);
    text-align: center;
    position: relative;
}

/* Set action buttons - appear on hover/focus */
.set-row-remove,
.set-row-dupe {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: none;
    color: white;
    font-size: 14px;
    font-weight: bold;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    transition: opacity var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.set-row-remove {
    left: -14px;
    background: var(--color-error);
}

.set-row-dupe {
    right: -14px;
    background: var(--color-success);
    color: black;
}

.set-row:hover .set-row-remove,
.set-row:hover .set-row-dupe,
.set-row-remove:focus,
.set-row-dupe:focus {
    opacity: 1;
}

/* Always show on touch devices */
@media (hover: none) {
    .set-row-remove,
    .set-row-dupe {
        opacity: 0.7;
    }
}

.set-row-prev {
    font-size: var(--text-sm);
    color: var(--text-muted);
    cursor: pointer;
    padding: var(--space-2);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    text-align: center;
}

.set-row-prev:hover {
    background: var(--accent-subtle);
    color: var(--accent);
}

.set-row-prev:empty::before {
    content: '—';
}

.set-row input {
    width: 100%;
    padding: var(--space-2) var(--space-2);
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: var(--text-base);
    text-align: center;
    transition: border-color var(--transition-fast);
    -moz-appearance: textfield;
}

.set-row input::-webkit-outer-spin-button,
.set-row input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.set-row input:focus {
    outline: none;
    border-color: var(--accent);
}

.set-row input::placeholder {
    color: var(--text-muted);
    font-family: inherit;
}

/* Add Set Button */
.add-set-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-1);
    width: 100%;
    padding: var(--space-2);
    margin-top: var(--space-2);
    background: transparent;
    border: 1px dashed var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-family: inherit;
    font-size: var(--text-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.add-set-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-subtle);
}

/* Add Exercise & Submit Buttons */
.logbook-actions {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    padding-top: var(--space-3);
    border-top: 1px solid var(--border-subtle);
    margin-top: auto;
}

.add-exercise-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3);
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: var(--text-base);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.add-exercise-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.logbook-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    background: var(--accent);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--bg-primary);
    font-family: inherit;
    font-size: var(--text-base);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.logbook-submit:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.logbook-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Empty State */
.logbook-empty {
    text-align: center;
    padding: var(--space-6);
    color: var(--text-muted);
}

.logbook-empty-icon {
    font-size: 2.5rem;
    margin-bottom: var(--space-2);
    opacity: 0.5;
}

.logbook-empty-text {
    font-size: var(--text-sm);
}

/* Unit Toggle */
.unit-toggle {
    display: flex;
    background: var(--bg-tertiary);
    border-radius: var(--radius-xs);
    overflow: hidden;
    font-size: var(--text-xs);
}

.unit-toggle button {
    padding: var(--space-1) var(--space-2);
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.unit-toggle button.active {
    background: var(--accent);
    color: var(--bg-primary);
}

/* Loading State */
.logbook-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    color: var(--text-muted);
}

.logbook-loading::after {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-subtle);
    border-top-color: var(--accent);
    border-radius: 50%;
    margin-left: var(--space-2);
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 480px) {
    .logbook-container {
        max-height: 50vh;
    }
    
    .set-table.metric-volume .set-table-header,
    .set-table.metric-volume .set-row {
        grid-template-columns: 32px 1fr 1fr 1fr;
    }
    
    .set-row input {
        padding: var(--space-2);
        font-size: var(--text-sm);
    }
    
    .set-row-prev {
        font-size: var(--text-xs);
        padding: var(--space-1);
    }
}
