:root {
    /* Variables para las áreas seguras del iPhone (Notch y Barra inferior) */
    --safe-top: env(safe-area-inset-top, 20px);
    --safe-bottom: env(safe-area-inset-bottom, 20px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    /* Evita que se seleccione texto al pulsar rápido en móviles */
    -webkit-tap-highlight-color: transparent;
}

html, body {
    overflow-x: hidden;
    /* Evita el efecto elástico de rebote en iOS */
    overscroll-behavior-y: none;
}

body {
    font-family: Arial, sans-serif; 
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    transition: background-color 0.5s ease;
    background-color: #F8F4E3; 
    margin: 0;
    color: #5F4B3F;
}

body.setup {
    background-color: #F8F4E3;
}

body.completed {
    background-color: #5F4B3F; 
}

.container {
    text-align: center;
    padding: 0;
    width: 100%;
    max-width: 600px;
    /* Asegura que el contenido respete los laterales en pantallas curvas */
    padding-left: var(--safe-left);
    padding-right: var(--safe-right);
}

.setup-screen {
    /* Padding dinámico: usa 100px o el área segura + 60px, lo que sea mayor */
    padding-top: max(100px, calc(var(--safe-top) + 60px));
    padding-right: 30px;
    padding-bottom: 30px;
    padding-left: 30px;
    background-color: #F8F4E3;
    position: relative; 
}

.timer-screen {
    display: none;
    width: 100%;
    height: 100vh;
    /* Soporte para altura real en móviles con barras de navegación */
    height: 100dvh; 
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.setup-screen h1 {
    color: #5F4B3F; 
    margin-bottom: 30px;
    font-size: 2.5em;
    font-family: 'Arial Black', 'Arial Bold', sans-serif;
}


.input-group {
    margin: 0;
    padding: 25px 0;
    text-align: center;
    border-bottom: 2px solid rgba(95, 75, 63, 0.2); 
    transition: border-bottom-color 0.3s ease;
}

.input-group:focus-within {
     border-bottom-color: #27ae60; 
}

.input-group:last-of-type {
     border-bottom: none; 
}

.input-group label {
    display: block;
    margin-bottom: 15px;
    color: #5F4B3F; 
    font-weight: 700;
    font-size: 1.2em;
    letter-spacing: 0;
    text-transform: none; 
    cursor: pointer; 
}

.time-input-group {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0; 
    max-width: 400px;
    margin: 0 auto;
    border: none; 
    background: transparent; 
    overflow: hidden; 
}

.input-group input {
    width: 100%;
    max-width: 400px;
    padding: 10px 0; 
    border: none;
    background: transparent; 
    font-size: 3.5em; 
    font-weight: 400; 
    font-family: Arial, sans-serif;
    color: #5F4B3F; 
    text-align: center;
    -moz-appearance: textfield; 
    border-radius: 0; /* Fix iOS rounded inputs */
}

.input-group input::-webkit-outer-spin-button,
.input-group input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.time-input-group input {
    max-width: 100px; 
    padding: 10px 5px; 
    font-size: 3.0em; 
}

.time-input-group span {
    font-size: 3.0em; 
    font-weight: 400; 
    color: #5F4B3F; 
    padding: 0; 
    margin: 0 5px; 
    text-transform: none; 
}

.input-group input:focus {
    outline: none;
    background: rgba(95, 75, 63, 0.05);
    box-shadow: none;
}
.time-input-group:focus-within {
     box-shadow: none;
}


button {
    padding: 18px 40px; 
    font-size: 1.3em; 
    border-radius: 8px; 
    cursor: pointer;
    transition: all 0.2s; /* Transición más rápida */
    font-weight: 700; 
    margin: 30px auto;
    text-transform: none; 
    letter-spacing: 0; 
    display: block;
    border: none; 
    /* Previene selección de texto en botones */
    user-select: none;
    -webkit-user-select: none;
}

.btn-start {
    background: #F8F4E3;
    color: #227670;
    border: 3px solid #227670;
    margin-top: 15px; 
}

.setup-screen .btn-start:first-of-type {
     margin-top: 30px;
}

/* Solo aplicar hover en dispositivos que tienen ratón (PC) */
@media (hover: hover) {
    .btn-start:hover {
        background: #6EAF9F; 
        color: white; 
        border-color: #6EAF9F; 
        transform: scale(1.02); 
    }
}
/* Estado activo para móviles (feedback táctil) */
.btn-start:active {
    transform: scale(0.98);
    background: #6EAF9F; 
    color: white; 
}

.btn-new-workout {
    padding: 16px 35px;
    background: #D6EAF8;
    color: #146796;
    border: 2px solid #21618C;
    font-size: 1.1em;
    margin: 30px auto 0 auto;
}

.btn-history-completed {
    padding: 16px 35px; 
    font-size: 1.1em;
    background: #FAD7A0; 
    color: #784D0D;
    border: 2px solid #CC8400;
    margin-top: 15px; 
    display: block; 
    margin-left: auto;
    margin-right: auto;
}

@media (hover: hover) {
    .btn-history-completed:hover {
        background: #E67E22;
        color: white;
        border-color: #E67E22; 
        transform: scale(1.02);
    }
}


#errorMessage {
    color: #c0392b;
    background: #fbecec;
    border: 1px solid #c0392b;
    padding: 15px;
    margin: 10px auto 20px;
    border-radius: 5px;
    font-weight: bold;
    display: none; 
    max-width: 400px;
}

.timer-screen {
    display: none;
    width: 100%;
}

.phase-label {
    font-size: 2em;
    font-weight: bold;
    color: white; 
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    transition: opacity 0.3s, visibility 0.3s, font-size 0.3s; 
    position: absolute;
    top: max(80px, calc(var(--safe-top) + 60px)); 
    left: 0;
    right: 0;
    text-align: center;
    margin-bottom: 0;
    z-index: 100; 
    font-family: 'Arial Black', 'Arial Bold', sans-serif;
}

.phase-label.small-change {
    font-size: 1.6em; 
}

.current-exercise-name {
    font-size: 1.8em; 
    font-weight: bold;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    text-transform: uppercase;
    position: absolute;
    top: max(130px, calc(var(--safe-top) + 110px)); 
    left: 0;
    right: 0;
    text-align: center;
    z-index: 100;
    display: none; 
    padding: 0 15px;
}

.current-exercise-name.upcoming-exercise {
    color: #AED6F1; 
    text-transform: uppercase; 
    font-size: 1.6em; 
}


.hidden-label {
    visibility: hidden;
    opacity: 0;
}

.timer-display-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 0; 
    width: 100%;
}

.new-timer-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    line-height: 1; 
    margin-top: 50px; 
}

#timerMinutes, #timerSeconds {
    font-weight: bold;
    color: white;
    text-shadow: 5px 5px 10px rgba(0,0,0,0.5);
    font-family: 'Impact', 'Arial Black', sans-serif;
    display: block; 
}

#timerMinuteLabel {
    font-weight: bold;
    color: white;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    text-transform: uppercase;
    display: block; 
    font-family: 'Arial Black', 'Arial Bold', sans-serif;
}


.new-timer-display.dual-view #timerMinutes,
.new-timer-display.dual-view #timerSeconds {
    font-size: 45vw;
}
.new-timer-display.dual-view #timerMinuteLabel {
    font-size: 1.5em; 
    margin: -15px 0 15px 0;
}

.new-timer-display.single-view #timerMinutes,
.new-timer-display.single-view #timerMinuteLabel {
    display: none;
}
.new-timer-display.single-view #timerSeconds {
    font-size: 80vw;
}

@media (min-width: 768px) {
    
    .new-timer-display.dual-view #timerMinutes,
    .new-timer-display.dual-view #timerSeconds {
        font-size: 35vh; 
    }
    .new-timer-display.dual-view #timerMinuteLabel {
         font-size: 2.5vh; 
         margin: -5vh 0 2vh 0; 
    }

    .new-timer-display.single-view #timerSeconds {
        font-size: 70vh; 
    }
}


.progress-bar {
    width: 80%;
    max-width: 400px;
    height: 10px;
    background: rgba(255,255,255,0.3);
    border-radius: 5px;
    overflow: hidden;
    margin-top: 30px; 
    margin-bottom: 20px; 
}

.progress-fill {
    height: 100%;
    background: white;
    transition: width 1s linear, background-color 0.3s; 
}

.info-wrapper {
    position: static; 
    bottom: auto; 
    left: auto;
    right: auto;
    width: 100%;
    display: flex;
    justify-content: space-between; 
    align-items: center;
    padding: 0 20px; 
    flex-wrap: nowrap; 
    margin-top: 0; 
    margin-bottom: 20px; 
    align-items: flex-start; 
}

.info-block {
    display: flex;
    flex-direction: column;
    align-items: center; 
    width: 48%; 
}

.round-info, .exercise-info {
    font-size: 1.3em; 
    color: rgba(255, 255, 255, 0.9);
    margin: 0;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    font-weight: bold;
    display: block;
    width: 100%;
    text-align: center;
    margin-bottom: 10px; 
    background: rgba(255, 255, 255, 0.1);
    padding: 10px 20px; 
    border-radius: 10px;
    backdrop-filter: blur(10px);
    white-space: nowrap;
}

.dots-container {
    display: flex;
    flex-wrap: wrap; 
    justify-content: center; 
    max-width: 100px; 
    gap: 8px; 
}

.dot {
    width: 12px; 
    height: 12px; 
    background-color: rgba(255, 255, 255, 0.3); 
    border-radius: 50%;
}

.dot.active {
    background-color: white; 
}

.prepare { background-color: #f39c12; }
.work { background-color: #27ae60; } 
.rest { background-color: #e74c3c; } 
.round-rest { background-color: #9b59b6; }


.pause-hint {
    display: none; 
    position: absolute;
    top: max(130px, calc(var(--safe-top) + 110px)); 
    left: 0;
    right: 0;
    text-align: center;
    font-size: 1.2em;
    color: rgba(255, 255, 255, 0.8);
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
    z-index: 50;
    font-weight: bold;
    letter-spacing: 0.5px;
}

.current-exercise-name:not(:empty) + .pause-hint {
    top: max(160px, calc(var(--safe-top) + 140px)); 
}

.pause-overlay {
    display: none;
    position: fixed; 
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    cursor: pointer;
    backdrop-filter: blur(5px);
}

.pause-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px; 
}

.pause-time-remaining {
    position: absolute;
    top: 15%;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-weight: bold;
    text-align: center;
    font-family: 'Arial Black', 'Arial Bold', sans-serif;
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
}

.pause-time-remaining span {
    font-size: 1.8em;
    margin-bottom: 15px;
    opacity: 0.9;
    letter-spacing: 2px;
    white-space: nowrap;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.7);
}

.pause-time-remaining::before {
    content: attr(data-time);
    font-size: 6em;
    text-shadow: 3px 3px 6px rgba(0,0,0,0.7);
}

.pause-icon .bar {
    width: 30px;      
    height: 120px;    
    background: white;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    border-radius: 5px; 
}

@media (min-width: 768px) {
    .pause-icon .bar {
        width: 40px;      
        height: 150px;    
    }
    .pause-icon {
        gap: 25px;
    }
}

.pause-overlay.show {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}


.close-btn {
    position: fixed; 
    /* Ajuste Safe Area para el botón cerrar */
    top: max(20px, var(--safe-top));
    right: max(20px, var(--safe-right));
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 2em;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    border: 2px solid rgba(255, 255, 255, 0.5);
    z-index: 2000; 
    padding: 0;
    margin: 0;
}

@media (hover: hover) {
    .close-btn:hover {
        background: rgba(255, 255, 255, 0.5);
        transform: scale(1.1);
    }
}

.timer-screen .close-btn {
    background: transparent;
    border: none;
    border-radius: 0;
    width: auto;
    height: auto;
    font-size: 2.5em; 
    color: white;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5); 
}
@media (hover: hover) {
    .timer-screen .close-btn:hover {
        background: transparent;
        color: #ddd;
        transform: scale(1.1);
    }
}

.history-screen .close-btn, 
.workout-detail-screen .close-btn,
.workout-editor-screen .close-btn, 
.settings-screen .close-btn { 
    background: transparent; 
    border: none; 
    color: #5F4B3F; 
    font-size: 2.5em; 
    width: auto; 
    height: auto;
    top: max(20px, var(--safe-top)); 
    right: max(20px, var(--safe-right));
    z-index: 2000; 
    position: fixed; 
}

@media (hover: hover) {
    .history-screen .close-btn:hover,
    .workout-detail-screen .close-btn:hover,
    .workout-editor-screen .close-btn:hover, 
    .settings-screen .close-btn:hover { 
        background: transparent; 
        color: #000000; 
        transform: scale(1.1); 
    }
}

.btn-settings-setup {
    position: absolute;
    /* Ajuste Safe Area */
    top: max(20px, var(--safe-top));
    left: max(20px, var(--safe-left));
    width: 50px;
    height: 50px;
    background: transparent;
    border: none;
    color: #5F4B3F; 
    font-size: 2.5em;
    cursor: pointer;
    z-index: 10;
    padding: 0;
    margin: 0;
    line-height: 1;
}

@media (hover: hover) {
    .btn-settings-setup:hover {
        color: #000000;
        transform: rotate(30deg);
    }
}

.settings-screen,
.history-screen,
.workout-detail-screen,
.workout-editor-screen {
    background-color: #F8F4E3; 
}

.settings-screen {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh; /* Altura real en móvil */
    color: #5F4B3F;
    /* Padding dinámico con Safe Area Bottom */
    padding: 30px 30px max(120px, calc(var(--safe-bottom) + 40px)) 30px; 
    text-align: center;
    overflow-y: auto;
    z-index: 1500;
}

.settings-screen .settings-list-group {
     padding-top: max(80px, var(--safe-top)); 
     margin: 0 auto;
     padding-bottom: 0;
}


.completed-screen {
    display: none;
    padding: 50px;
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #E9DAC1;
}


.settings-list-group {
    width: 100%;
    max-width: 400px;
    margin: 0 auto; 
    padding: 0;
    text-align: left;
}

.menu-item-vertical {
    width: 100%;
    margin: 0 0 1px 0; 
    padding: 18px 0; 
    background-color: transparent; 
    color: #5F4B3F;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    box-shadow: none; 
    transition: background-color 0.2s;
    font-weight: 700; 
    font-size: 1.3em;
    letter-spacing: 0.5px;
    text-transform: none; 
    border-bottom: 1px solid rgba(95, 75, 63, 0.3);
}

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


.menu-item-vertical:hover {
    background-color: transparent;
}


.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px; 
    height: 28px; 
    flex-shrink: 0; 
    margin-right: 5px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #F8A8A8; 
    transition: .4s;
    border-radius: 34px; 
    border: 2px solid #5F4B3F; 
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px; 
    width: 20px; 
    left: 2px; 
    bottom: 2px; 
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #A9E4D7; 
}

input:checked + .slider:before {
    transform: translateX(20px); 
}


.history-screen {
    display: none;
    padding-top: max(80px, var(--safe-top));
    padding-bottom: max(30px, var(--safe-bottom));
    width: 100%;
    min-height: 100vh;
    color: #5F4B3F; 
    position: relative;
    display: flex; 
    flex-direction: column; 
    justify-content: space-between; 
}

#historyList {
    margin-bottom: 30px;
    padding-top: 0; 
    overflow-y: auto; 
    flex-grow: 1; 
    width: 100%; 
}

.history-entry {
    width: 100%; 
    text-align: left;
    border: none; 
    margin-bottom: 15px; 
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); 
    border-radius: 0; 
    overflow: hidden; 
    position: relative; 
    cursor: default; 
}

.history-header {
    height: 60px; 
    padding: 0 15px; 
    display: flex;
    justify-content: space-between;
    align-items: center; 
    gap: 10px; 
}

.history-title {
    font-size: 1.2em;
    font-weight: bold;
    flex-grow: 1; 
    text-align: left;
    line-height: 1.2;
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
    pointer-events: none; 
}

.history-date {
    font-size: 0.9em; 
    white-space: nowrap; 
    margin-left: auto;
    pointer-events: none; 
}

.history-status-label {
    font-size: 0.8em;
    font-weight: bold;
    padding: 3px 8px;
    border-radius: 4px;
    white-space: nowrap;
    margin-right: 10px;
}

.history-status-label.status-incomplete {
    background: #E74C3C; /* Rojo */
    color: white;
}

.history-status-label.status-template {
    background: #035661; /* Azul oscuro */
    color: white;
}

.btn-delete-all {
    padding: 18px 40px; 
    font-size: 1.3em; 
    background: #fa5555;
    color: White; 
    border: 2px solid #C0392B;
    margin: 0 auto; 
    display: block;
    width: fit-content; 
    flex-shrink: 0;
    margin-bottom: max(0px, var(--safe-bottom));
}

@media (hover: hover) {
    .btn-delete-all:hover {
        background: #C0392B;
        color: white; 
        border-color: #C0392B;
        transform: scale(1.02);
    }
}

.workout-detail-screen {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh; 
    color: #5F4B3F;
    padding: 30px;
    /* Padding inferior seguro */
    padding-bottom: max(30px, var(--safe-bottom));
    text-align: left;
    overflow-y: auto;
}

.detail-header {
    padding-top: max(50px, var(--safe-top)); 
    margin-bottom: 30px;
    border-bottom: 3px solid #5F4B3F;
}

.detail-header h2 {
    font-size: 1.8em;
    margin-bottom: 10px;
}

.detail-header p {
    font-size: 1.1em;
    margin-bottom: 15px;
    font-weight: bold;
}

.detail-section {
    margin-bottom: 25px; 
    padding: 15px 0 25px 0; 
    border: none;
    background: transparent; 
    border-bottom: 1px solid rgba(95, 75, 63, 0.3); 
}

#detailExercisePlan {
    display: none; 
}
#detailExercisePlan ul {
    list-style-type: none; 
    list-style-position: inside;
    margin-left: 0;
    padding-left: 0;
}
#detailExercisePlan li {
    font-size: 1.1em;
    margin: 5px 0 5px 10px; 
    position: relative;
}
#detailExercisePlan li::before {
    content: '›';
    position: absolute;
    left: -10px;
    font-weight: bold;
}
#detailExercisePlan p {
    font-size: 1.1em;
}


.detail-section h3 {
    font-size: 1.3em;
    margin-bottom: 10px;
    color: #5F4B3F;
    text-transform: uppercase;
}

.detail-section p {
    font-size: 1.1em;
    margin: 8px 0;
}

.detail-section p strong {
     font-weight: 900; 
}

.notes-group {
    margin-bottom: 15px;
    padding-top: 5px; 
}

.notes-group label {
    display: block;
    font-weight: 700; 
    margin-bottom: 5px;
    text-transform: none; 
    font-size: 1em;
    text-align: left;
}

.notes-group textarea, .notes-group input[type="text"] {
    width: 100%;
    padding: 10px;
    font-size: 1em;
    border: 2px solid #5F4B3F;
    background: #ffffff;
    color: #5F4B3F;
    font-family: Arial, sans-serif; 
    font-weight: normal;
    border-radius: 0;
}

.notes-group textarea {
    height: 100px;
    resize: vertical;
}

.btn-repeat-detail {
    background: #F8F4E3;
    color: #426300;
    border: 3px solid #426300;
    padding: 18px 40px;
    font-size: 1.3em;
    margin: 30px auto 15px auto; 
    display: block;
}

@media (hover: hover) {
    .btn-repeat-detail:hover {
        background: #6EAF9F;
        color: white;
        border-color: #6EAF9F;
    }
}

.btn-edit-detail {
    background: #F8F4E3;
    color: #035661;
    border: 3px solid #035661;
    padding: 18px 40px;
    font-size: 1.3em;
    margin: 15px auto; 
    display: block;
}

@media (hover: hover) {
    .btn-edit-detail:hover {
        background: #3CB371;
        color: white;
        border-color: #3CB371;
    }
}

.btn-delete-detail {
    background: #EB6C54;
    color: White;
    border: 3px solid #C0392B;
    padding: 18px 40px; 
    font-size: 1.3em;
    margin: 15px auto 40px auto;
    display: block;
}

@media (hover: hover) {
    .btn-delete-detail:hover {
        background: #fa5555;
        transform: scale(1.02);
    }
}


#historyAlert {
    color: #c0392b;
    background: #fbecec;
    border: 1px solid #c0392b;
    padding: 15px;
    margin: 10px auto 40px; 
    border-radius: 5px;
    font-weight: bold;
    display: none;
    max-width: 400px;
    text-align: center;
}

#swipeInfoMessage {
    color: #0056b3; 
    background: #e6f7ff; 
    border: 1px solid #b3d9ff; 
    padding: 15px;
    margin: 10px auto 40px; 
    border-radius: 5px;
    font-weight: bold;
    display: none; 
    max-width: 400px;
    text-align: center;
}

.history-entry-content {
    position: relative;
    z-index: 2; 
    background: #ffde54; 
    transition: transform 0.3s ease;
    cursor: pointer; 
}

@media (hover: hover) {
    .history-entry-content:hover {
        background: #ffde54; 
    }
}

.history-entry.history-entry-custom .history-entry-content {
     background: #56C1DB;
}

.history-entry.status-incomplete .history-entry-content {
     background: #d6d6d6;
}

.history-entry.status-incomplete:not(.history-entry-custom) .history-entry-content {
    border-left: 10px solid #ffde54; /* Normal (Amarillo) */
}
.history-entry.status-incomplete.history-entry-custom .history-entry-content {
    border-left: 10px solid #56C1DB; /* Custom (Azul) */
}


/* --- ESTILO PLANTILLA --- */
.history-entry.status-template .history-entry-content {
    background: #ffffff;
    color: #5F4B3F;
    cursor: pointer;
}


.history-entry-actions {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    z-index: 1; 
    display: flex;
    align-items: center;
}

.btn-delete-swipe {
    background-color: #e74c3c; 
    color: white;
    border: none;
    height: 100%;
    width: 100px; 
    padding: 0;   
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
    text-transform: uppercase; 
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0;
}

@media (hover: hover) {
    .btn-delete-swipe:hover {
        background-color: #c0392b; 
    }
}

.history-entry.swiped .history-entry-content {
    transform: translateX(-100px);
}


.workout-editor-screen {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    color: #5F4B3F;
    padding: 30px;
    padding-bottom: max(30px, var(--safe-bottom));
    z-index: 1500;
    overflow-y: auto;
}

#exerciseEditorList {
    padding-top: max(80px, var(--safe-top)); 
    padding-bottom: 30px; 
    max-width: 500px;
    margin: 0 auto;
    text-align: left;
}

#exerciseEditorList h3 {
    font-size: 1.3em;
    margin: 25px 0 15px 0;
    color: #5F4B3F;
    text-transform: uppercase;
    border-bottom: 2px solid rgba(95, 75, 63, 0.3);
    padding-bottom: 5px;
}

#exerciseEditorList h3:first-of-type {
    margin-top: 0;
}

.exercise-input-group {
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.exercise-input-group label {
    font-weight: 700; 
    font-size: 1.1em;
    color: #5F4B3F;
    min-width: 110px; 
}

.exercise-input-group input[type="text"] {
    width: 100%;
    padding: 10px;
    font-size: 1.1em;
    border: 2px solid #5F4B3F;
    background: #ffffff;
    color: #5F4B3F;
    font-family: Arial, sans-serif;
    font-weight: normal;
    border-radius: 0;
}

.btn-start-editor {
    background: #F8F4E3;
    color: #227670;
    border: 3px solid #227670;
    position: static; 
    margin: 30px auto 10px auto; 
    width: 90%; 
    max-width: 400px;
    display: block; 
    z-index: auto; 
}

.btn-save-template {
    background: #F8F4E3;
    color: #8A6D1D;
    border: 3px solid #8A6D1D;
    padding: 18px 40px;
    font-size: 1.3em;
    position: static;
    margin: 10px auto 30px auto;
    width: 90%;
    max-width: 400px;
    display: flex;          
    justify-content: center;
    align-items: center;    
    white-space: nowrap;
    text-align: center;
}

/* --- ESTILOS PARA EL NUEVO MODAL DE TIEMPOS --- */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 2000;
    backdrop-filter: blur(2px);
}

.modal-content {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #F8F4E3;
    color: #5F4B3F;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    z-index: 2001;
    width: 90%;
    max-width: 450px;
    text-align: center;
}

.modal-input-group {
    margin: 0;
    padding: 25px 0;
    text-align: center;
    border-bottom: 2px solid rgba(95, 75, 63, 0.2);
}
.modal-input-group:last-of-type {
    border-bottom: none;
}

.modal-input-group label {
    display: block;
    margin-bottom: 15px;
    font-weight: 700;
    font-size: 1.2em;
}

.modal-input-group .time-input-group input {
    font-size: 3.0em; 
    font-weight: 400;
    border: none;
    background: transparent;
    padding: 10px 5px; 
    max-width: 100px;
}
.modal-input-group .time-input-group span {
    font-size: 3.0em;
    font-weight: 400;
}
.modal-input-group .time-input-group input:focus {
     outline: none;
     background: rgba(95, 75, 63, 0.05);
}


#errorMessage, #modalErrorMessage, #globalModalErrorMessage {
    color: #c0392b;
    background: #fbecec;
    border: 1px solid #c0392b;
    padding: 15px;
    margin: 10px auto 20px;
    border-radius: 5px;
    font-weight: bold;
    display: none; 
}

/* Generic close button for modals */
.modal-content .modal-close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 2.0em;
    color: #5F4B3F;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    margin: 0;
    line-height: 1;
}
@media (hover: hover) {
    .modal-content .modal-close-btn:hover {
        color: #000;
    }
}

.modal-content button {
    margin: 10px auto;
    font-size: 1.1em;
    padding: 15px 30px;
}
/* Botón de Cancelar/Borrar del modal */
.modal-content .btn-modal-cancel {
    font-size: 1.1em;
    padding: 15px 30px;
    margin-top: 0;
    background: transparent;
    border: none;
    color: #c0392b;
}
@media (hover: hover) {
    .modal-content .btn-modal-cancel:hover {
        background: #fbecec;
        transform: none;
    }
}

#timeEditorModal .btn-start,
#globalTimeEditorModal .btn-start { 
    background: #F8F4E3; 
    color: #227670; 
    border: 3px solid #227670; 
}
@media (hover: hover) {
    #timeEditorModal .btn-start:hover,
    #globalTimeEditorModal .btn-start:hover { 
        background: #6EAF9F; 
        color: white;
        border-color: #6EAF9F;
    }
}


/* --- ESTILOS PARA EL NUEVO EDITOR DE EJERCICIOS --- */
.editor-title {
    text-align: center;
    font-size: clamp(1.5em, 5vw, 2em);
    font-weight: 700;
    color: #5F4B3F;
    margin-bottom: 10px;
    padding: 0 15px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}


/* Bloque de sumario de tiempos globales */
.global-times-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 5px;
    margin-bottom: 20px;
    border-bottom: 2px solid rgba(95, 75, 63, 0.3);
}
.global-times-summary .summary-labels {
    text-align: left;
    font-size: 1.1em; 
    line-height: 1.4; 
    text-transform: uppercase;
    color: #5F4B3F;
    font-weight: 700; 
}
.global-times-summary .summary-labels strong {
    font-weight: 900;
    color: #27ae60; 
    min-width: 50px;
    display: inline-block;
    text-align: right;
    margin-left: 5px;
}
.global-times-summary .summary-labels .rest-time-label {
     color: #9b59b6; 
}


#exerciseEditorList h3 {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.round-actions {
    display: flex;
    gap: 10px;
}

.editor-btn {
    background: transparent;
    border: none;
    padding: 5px;
    margin: 0;
    font-size: 1.8em;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    border-radius: 5px;
    transition: background 0.2s;
    min-width: 35px; 
    text-align: center;
}
@media (hover: hover) {
    .editor-btn:hover {
        background: rgba(95, 75, 63, 0.1);
    }
}

.btn-delete-round {
    color: #e74c3c; 
}
@media (hover: hover) {
    .btn-delete-round:hover {
        background: #fbecec;
    }
}

.btn-add-round {
    color: #3498db; 
}
@media (hover: hover) {
    .btn-add-round:hover {
        background: #e6f7ff;
    }
}

/* Grupo de ejercicio individual */
.exercise-editor-item {
    display: flex;
    align-items: center;
    gap: 8px; 
    margin-bottom: 10px;
    padding: 10px 5px;
    border-bottom: 1px solid rgba(95, 75, 63, 0.1);
}

.exercise-editor-item .exercise-number {
    font-weight: bold;
    font-size: 1.3em; 
    min-width: 25px; 
}

.exercise-editor-item input[type="text"] {
    flex-grow: 1; 
    flex-shrink: 1; 
    min-width: 50px; 
    padding: 10px;
    font-size: 1.1em;
    border: 2px solid #5F4B3F;
    background: #ffffff;
    color: #5F4B3F;
    border-radius: 0;
}

.exercise-time-display {
    display: flex;
    flex-direction: column;
    text-align: center;
    font-weight: bold;
    white-space: nowrap;
    min-width: 45px; 
    font-size: 1.1em; 
}

.time-display-work {
    color: #27ae60; 
}
.time-display-rest {
    color: #e74c3c; 
}

.btn-exercise-options {
    color: #5F4B3F; 
    font-size: 1.8em; 
    font-weight: bold;
    padding: 5px 10px;
    margin: 0;
    background: transparent;
    border: none;
    cursor: pointer;
    line-height: 1;
}
@media (hover: hover) {
    .btn-exercise-options:hover {
        background: rgba(95, 75, 63, 0.1);
        border-radius: 5px;
    }
}

#exerciseOptionsModal .modal-content {
    padding: 10px;
}

#exerciseOptionsModal button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 15px 20px;
    font-size: 1.2em;
    margin: 0;
    border: none;
    background: transparent;
    border-radius: 0;
    border-bottom: 1px solid rgba(95, 75, 63, 0.1);
}
 #exerciseOptionsModal button:last-child {
    border-bottom: none;
 }
 
@media (hover: hover) {
    #exerciseOptionsModal button:hover {
        background: rgba(95, 75, 63, 0.05);
        transform: none;
    }
}

#exerciseOptionsModal .btn-add-exercise {
    color: #4A6988; 
    font-weight: bold;
}
#exerciseOptionsModal .btn-edit-time {
    color: #5A8B73; 
    font-weight: bold;
}
#exerciseOptionsModal .btn-delete-exercise {
    color: #C06A6A; 
    font-weight: bold;
}

#exerciseOptionsModal .modal-close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    width: auto;
    display: inline-block;
    text-align: center;
    font-size: 2.0em;
    color: #5F4B3F;
    padding: 0;
    border: none;
    background: transparent;
    border-bottom: none; 
}
@media (hover: hover) {
    #exerciseOptionsModal .modal-close-btn:hover {
        color: #000;
        background: transparent;
    }
}

.settings-footer {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    padding: 15px 20px;
    /* Padding inferior dinámico */
    padding-bottom: max(20px, var(--safe-bottom));
    border-top: 1px solid rgba(95, 75, 63, 0.3);
    text-align: center;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: #F8F4E3; 
    z-index: 10;
}

.settings-footer-tip {
    color: #5F4B3F;
    font-size: 0.9em;
    opacity: 0.7;
    margin-bottom: 8px;
    line-height: 1.3;
    padding: 0 10px;
}

.setup-footer {
    width: 100%;
    max-width: 400px;
    margin: 30px auto 0 auto;
    padding: 15px 20px 10px 20px;
    /* Padding inferior dinámico */
    padding-bottom: max(10px, var(--safe-bottom));
    border-top: 1px solid rgba(95, 75, 63, 0.3);
    text-align: center;
}

.setup-footer-links {
    font-size: 0.75em;
    color: #5F4B3F;
    opacity: 0.6;
    line-height: 1.4;
    padding: 0 10px;
}

.setup-footer-links a {
    color: #5F4B3F !important; 
    text-decoration: none !important; 
    border-bottom: none;
    transition: opacity 0.2s;
    display: inline-block;
}

.setup-footer-links a:hover {
    opacity: 0.8;
}

.setup-footer-links a:visited {
    color: #5F4B3F; 
}

.setup-footer-version {
    margin-top: 5px;
    font-size: 0.7em;
    opacity: 0.5;
    color: #5F4B3F;
}
.total-duration-display {
    text-align: center;
    margin: 25px auto 20px auto;
    padding: 12px 20px;
    background: transparent;
    color: #5F4B3F;
    border-top: 2px solid rgba(95, 75, 63, 0.3);
    border-bottom: 2px solid rgba(95, 75, 63, 0.3);
    max-width: 400px;
    font-size: 1.3em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.total-duration-display strong {
    color: #1c92ad; 
    font-weight: 900;
}

/* --- Estilos para el Modal de Salida Simplificado --- */

.exit-modal-buttons {
    display: flex;
    gap: 15px;
    width: 100%;
    margin-top: 20px;
}

/* Botón SÍ (Verde) */
.btn-exit-yes {
    background: transparent;
    border: none;
    color: #27ae60; 
    font-weight: 900; 
    font-size: 1.4em; 
    flex: 1; 
    padding: 15px;
    margin: 0; 
    cursor: pointer;
    text-transform: uppercase;
    transition: transform 0.2s;
}

/* Botón NO (Azul) */
.btn-exit-no {
    background: transparent;
    border: none;
    color: #2980b9; 
    font-weight: 900;
    font-size: 1.4em;
    flex: 1; 
    padding: 15px;
    margin: 0; 
    cursor: pointer;
    text-transform: uppercase;
    transition: transform 0.2s;
}

@media (hover: hover) {
    .btn-exit-yes:hover, .btn-exit-no:hover {
        transform: scale(1.05);
        background-color: rgba(0,0,0,0.03);
        border-radius: 10px;
    }
}
.btn-exit-yes:active, .btn-exit-no:active {
    transform: scale(0.95);
}


/* Inputs desactivados */
.input-group input:disabled,
.time-input-group input:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    color: #5F4B3F;
    /* Asegurar que en iOS se vea desactivado */
    -webkit-text-fill-color: rgba(95, 75, 63, 0.3);
}

.input-group:has(input:disabled) {
    opacity: 0.6;
    pointer-events: none; 
}

/* Nuevo estilo para el botón SÍ destructivo (Rojo) */
.btn-exit-yes-danger {
    background: transparent;
    border: none;
    color: #c0392b; 
    font-weight: 900;
    font-size: 1.4em;
    flex: 1;
    padding: 15px;
    margin: 0;
    cursor: pointer;
    text-transform: uppercase;
    transition: transform 0.2s;
}

@media (hover: hover) {
    .btn-exit-yes-danger:hover {
        transform: scale(1.05);
        background-color: rgba(0,0,0,0.03);
        border-radius: 10px;
    }
}
/* --- AÑADIR AL FINAL DE STYLES.CSS --- */

/* Ocultar flechas de los inputs numéricos en Firefox */
input[type=number] {
  -moz-appearance: textfield;
}

/* Asegurar que los toques en iOS sean rápidos */
button, input, select, textarea {
    touch-action: manipulation;
}

.app-logo {
    width: 100px;
    max-width: 60%;
    display: block;
    margin: 0 auto 15px;
}

/* Animación de parpadeo solo para la bombilla */
@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.2; }
}

/* Crear la bombilla como pseudo-elemento para poder animarla sola */
.settings-footer-tip {
    position: relative;
    padding-left: 20px; /* Ajusta este valor para acercar/alejar la bombilla */
}

/* La bombilla como pseudo-elemento */
.settings-footer-tip::before {
    content: '💡';
    position: absolute;
    left: 0;
    top: 0;
}

/* Solo la bombilla parpadea */
.settings-footer-tip.blinking::before {
    animation: blink 0.6s ease-in-out 5;
}
