* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #000;
    color: #ffffff;
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

/* Animated background gradients */
body::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 20% 50%, rgba(0, 255, 255, 0.3), transparent 50%),
                radial-gradient(circle at 80% 80%, rgba(255, 0, 102, 0.2), transparent 50%),
                radial-gradient(circle at 40% 20%, rgba(255, 204, 0, 0.2), transparent 50%);
    z-index: -1;
    animation: rotate 20s linear infinite;
}

@keyframes rotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.header {
    text-align: center;
    padding: 60px 20px 40px;
    position: relative;
}

.header h1 {
    font-size: 3rem;
    font-weight: 300;
    letter-spacing: 0.1em;
    text-shadow: 0 0 30px rgba(0, 255, 255, 0.5);
    margin-bottom: 20px;
}

.header-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
}

.header-btn {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 8px 16px;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    text-decoration: none;
}

.header-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(0, 255, 255, 0.5);
    color: #00ffff;
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.3);
}

.main-content {
    flex: 1;
    padding: 0 20px 40px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.quick-add-section {
    margin-bottom: 30px;
}

.quick-add-button {
    width: 100%;
    background: rgba(52, 199, 89, 0.2);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(52, 199, 89, 0.5);
    border-radius: 24px;
    padding: 20px;
    color: #34c759;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    position: relative;
    overflow: hidden;
}

.quick-add-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, #34c759, transparent);
    animation: slide 3s infinite;
}

@keyframes slide {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.quick-add-button:hover {
    background: rgba(52, 199, 89, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(52, 199, 89, 0.4);
}

.quick-add-button.hidden {
    display: none;
}

.category-filters {
    display: flex;
    overflow-x: auto;
    gap: 12px;
    margin-bottom: 30px;
    padding-bottom: 10px;
    -webkit-overflow-scrolling: touch;
    position: relative;
    mask-image: linear-gradient(to right, transparent, black 20px, black calc(100% - 20px), transparent);
    -webkit-mask-image: linear-gradient(to right, transparent, black 20px, black calc(100% - 20px), transparent);
}

.category-filters::before,
.category-filters::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 10px;
    width: 40px;
    pointer-events: none;
    z-index: 1;
}

.category-filters::before {
    left: 0;
    background: linear-gradient(to right, rgba(0, 0, 0, 0.8), transparent);
}

.category-filters::after {
    right: 0;
    background: linear-gradient(to left, rgba(0, 0, 0, 0.8), transparent);
}

.category-filter {
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 10px 20px;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
}

.category-filter.active {
    background: rgba(0, 255, 255, 0.2);
    border-color: rgba(0, 255, 255, 0.5);
    color: #00ffff;
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.3);
}

.category-filter:hover:not(.active) {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
    color: rgba(255, 255, 255, 0.9);
}

.exercises-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 40px;
}

.exercise-tile {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 14px;
    padding: 25px 15px;
    position: relative;
    height: auto;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    overflow: hidden;
    text-align: center;
}

.exercise-tile::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, #00ffff, transparent);
    animation: slide 3s infinite;
}

.exercise-tile:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-4px);
    border-color: #00ffff;
    box-shadow: 0 20px 40px rgba(0, 255, 255, 0.3);
}

.exercise-tile.add-new {
    background: rgba(0, 255, 255, 0.1);
    border-color: rgba(0, 255, 255, 0.3);
}

.exercise-tile.add-new::before {
    background: linear-gradient(90deg, transparent, #00ffff, transparent);
}

.exercise-tile.add-new:hover {
    background: rgba(0, 255, 255, 0.2);
    border-color: #00ffff;
}

.exercise-name {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.2;
}

.exercise-last {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 6px;
    font-weight: 400;
}

.exercise-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 255, 255, 0.3);
    color: #00ffff;
    font-size: 0.6rem;
    padding: 2px 6px;
    border-radius: 8px;
    font-weight: 600;
    text-transform: uppercase;
}

.exercise-badge.reps-only {
    background: rgba(52, 199, 89, 0.3);
    color: #34c759;
}

.exercise-badge.timed {
    background: rgba(255, 149, 0, 0.3);
    color: #ff9500;
}

.exercise-badge.run {
    background: rgba(88, 86, 214, 0.3);
    color: #5856d6;
}

.add-icon {
    font-size: 1.5rem;
    color: #00ffff;
    text-shadow: 0 0 20px rgba(0, 255, 255, 0.5);
    margin-bottom: 4px;
}

.history-section {
    margin-top: 40px;
}

.section-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 20px;
    color: rgba(255, 255, 255, 0.9);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.history-container {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    overflow: hidden;
}

.workout-group {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.workout-group:last-child {
    border-bottom: none;
}

.workout-group-header {
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.05);
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    transition: all 0.3s ease;
}

.workout-group-header:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #00ffff;
}

.workout-item {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.workout-info {
    flex: 1;
}

.workout-exercise {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.pr-badge {
    background: linear-gradient(135deg, #ffd700, #ffed4e);
    color: #000;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 700;
    animation: prPulse 2s ease-in-out;
}

.pr-badge.twm {
    background: linear-gradient(135deg, #ff9500, #ffcc00);
}

.pr-badge.run-pr {
    background: linear-gradient(135deg, #5856d6, #6e6ee8);
    color: #fff;
}

@keyframes prPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.workout-details {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 4px;
}

.workout-datetime {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
}

.workout-actions {
    display: flex;
    gap: 8px;
}

.action-btn {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 6px 12px;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.8rem;
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #00ffff;
    border-color: #00ffff;
}

.action-btn.delete {
    border-color: rgba(255, 0, 102, 0.5);
    color: #ff0066;
}

.action-btn.delete:hover {
    background: rgba(255, 0, 102, 0.2);
    border-color: #ff0066;
}

.empty-state {
    text-align: center;
    padding: 40px;
    color: rgba(255, 255, 255, 0.6);
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    z-index: 1000;
}

.modal.active {
    display: block;
}

.modal-content {
    background: rgba(20, 20, 20, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 24px;
    margin: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    position: relative;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
}

.modal-btn {
    background: none;
    border: none;
    color: #00ffff;
    font-size: 1rem;
    cursor: pointer;
    padding: 8px;
    transition: all 0.2s ease;
}

.modal-btn:hover {
    color: rgba(0, 255, 255, 0.7);
}

.modal-btn.cancel {
    color: #ff0066;
}

.modal-btn.cancel:hover {
    color: rgba(255, 0, 102, 0.7);
}

.modal-body {
    padding: 20px;
}

.input-group {
    margin-bottom: 20px;
}

.input-label {
    display: block;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
    margin-bottom: 8px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.input-field {
    width: 100%;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 12px 16px;
    color: white;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.input-field:focus {
    outline: none;
    border-color: #00ffff;
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.15);
}

.toggle-group {
    display: flex;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 12px;
}

.toggle-option {
    flex: 1;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    padding: 8px 12px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.toggle-option.active {
    background: rgba(0, 255, 255, 0.3);
    color: #00ffff;
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.3);
}

.sets-counter {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 12px 16px;
}

.sets-counter button {
    background: rgba(0, 255, 255, 0.3);
    border: none;
    border-radius: 8px;
    color: #00ffff;
    width: 36px;
    height: 36px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sets-counter button:hover {
    background: rgba(0, 255, 255, 0.5);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.3);
}

.sets-counter span {
    font-size: 1.1rem;
    font-weight: 600;
}

.plate-calculator {
    display: none;
}

.plate-calculator.active {
    display: block;
}

.bar-toggle {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 12px 16px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.toggle-switch {
    position: relative;
    width: 51px;
    height: 31px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 31px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.toggle-switch.active {
    background: rgba(52, 199, 89, 0.5);
}

.toggle-switch-handle {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 27px;
    height: 27px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s ease;
}

.toggle-switch.active .toggle-switch-handle {
    transform: translateX(20px);
}

.plate-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    margin-bottom: 12px;
}

.plate-button {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    padding: 12px 8px;
    color: white;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
}

.plate-button:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: #00ffff;
}

.plate-count {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #00ffff;
    color: #000;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
}

.total-weight {
    background: rgba(0, 255, 255, 0.2);
    border: 1px solid rgba(0, 255, 255, 0.5);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    margin-bottom: 12px;
}

.total-weight-label {
    font-size: 0.8rem;
    opacity: 0.8;
    margin-bottom: 4px;
}

.total-weight-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: #00ffff;
}

.clear-plates-button {
    width: 100%;
    background: rgba(255, 0, 102, 0.2);
    border: 1px solid rgba(255, 0, 102, 0.5);
    border-radius: 10px;
    color: #ff0066;
    padding: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.clear-plates-button:hover {
    background: rgba(255, 0, 102, 0.3);
    box-shadow: 0 0 15px rgba(255, 0, 102, 0.3);
}

.save-button {
    width: 100%;
    background: rgba(0, 255, 255, 0.2);
    border: 1px solid rgba(0, 255, 255, 0.5);
    border-radius: 12px;
    color: #00ffff;
    padding: 14px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 20px;
    transition: all 0.3s ease;
}

.save-button:hover {
    background: rgba(0, 255, 255, 0.3);
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.4);
    transform: translateY(-2px);
}

.warmup-suggestion {
    font-size: 0.9rem;
    color: rgba(255, 204, 0, 0.8);
    margin-top: 10px;
    text-align: center;
    padding: 8px;
    background: rgba(255, 204, 0, 0.1);
    border-radius: 8px;
}

.chart-container {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 20px;
    margin: 20px 0;
}

.chart {
    width: 100%;
    height: 200px;
    border-radius: 8px;
}

.stats-grid {
    display: grid;
    gap: 16px;
}

.stat-card {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 16px;
}

.stat-exercise {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 12px;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.9);
}

.stat-exercise:hover {
    color: #00ffff;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-row:last-child {
    border-bottom: none;
}

.stat-label {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
}

.stat-value {
    font-size: 1rem;
    font-weight: 600;
    color: #ffd700;
}

.stat-value.twm {
    color: #ff9500;
}

.stat-value.run-stat {
    color: #5856d6;
}

.template-exercise-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
}

.template-exercise-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
    padding: 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.template-exercise-name {
    flex: 1;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
}

.template-remove-btn {
    background: rgba(255, 0, 102, 0.2);
    border: 1px solid rgba(255, 0, 102, 0.5);
    color: #ff0066;
    padding: 4px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.template-remove-btn:hover {
    background: rgba(255, 0, 102, 0.3);
}

.template-card {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.template-card:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(0, 255, 255, 0.5);
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.2);
}

.template-name {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: rgba(255, 255, 255, 0.9);
}

.template-exercises {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 12px;
}

.template-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.template-action-btn {
    flex: 1;
    background: rgba(0, 255, 255, 0.2);
    border: 1px solid rgba(0, 255, 255, 0.5);
    color: #00ffff;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.template-action-btn:hover {
    background: rgba(0, 255, 255, 0.3);
}

.template-action-btn.delete {
    background: rgba(255, 0, 102, 0.2);
    border-color: rgba(255, 0, 102, 0.5);
    color: #ff0066;
}

.template-action-btn.delete:hover {
    background: rgba(255, 0, 102, 0.3);
}

/* Responsive */
@media (max-width: 768px) {
    .header h1 {
        font-size: 2.5rem;
    }
    
    .exercises-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }
    
    .exercise-tile {
        padding: 20px 12px;
        min-height: 70px;
    }
    
    .exercise-name {
        font-size: 0.9rem;
    }
    
    .modal-content {
        margin: 10px;
        max-height: calc(100vh - 20px);
    }
}

@media (max-width: 480px) {
    .exercise-tile {
        padding: 16px 10px;
        min-height: 65px;
    }
    
    .exercise-name {
        font-size: 0.85rem;
    }
    
    .add-icon {
        font-size: 1.2rem;
    }
}

@keyframes celebrate {
    0%, 100% { 
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }
    50% { 
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.2);
    }
    100% { 
        opacity: 0;
        transform: translate(-50%, -50%) scale(1.5);
    }
}
