/* === Home screen === */

.btn-new-workout {
    display: block;
    text-align: center;
    padding: 0.65rem;
    border-radius: var(--radius);
    background: var(--color-bg-secondary);
    color: var(--color-accent);
    font-weight: 500;
    text-decoration: none;
    border: 1px dashed var(--color-border);
}

.btn-new-workout:hover {
    background: var(--color-accent);
    color: var(--color-accent-text);
    border-style: solid;
    text-decoration: none;
}

.workout-card { padding: var(--space-md); }

.workout-card-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: var(--space-sm);
}

.workout-card-name {
    font-weight: 600;
    font-size: 1.05rem;
}

.workout-card-summary {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-bottom: var(--space-md);
    line-height: 1.5;
}

.btn-start {
    display: block;
    text-align: center;
    padding: 0.6rem;
    border-radius: var(--radius);
    background: var(--color-text);
    color: var(--color-bg);
    font-weight: 500;
    text-decoration: none;
    font-size: 0.95rem;
}

.btn-start:hover {
    opacity: 0.9;
    text-decoration: none;
}

.btn-icon {
    font-size: 1.1rem;
    text-decoration: none;
    color: var(--color-text-muted);
    padding: 4px;
}

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

/* === Editor === */

.editor-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn-back {
    color: var(--color-text-muted);
    text-decoration: none;
    font-size: 0.9rem;
}

.btn-save { padding: 0.4rem 1.2rem; }

.editor-name-input {
    font-size: 1.3rem !important;
    font-weight: 600;
    border: none !important;
    border-bottom: 1px solid var(--color-border) !important;
    border-radius: 0 !important;
    padding: 0.25rem 0 !important;
    background: transparent !important;
}

.editor-name-input:focus {
    box-shadow: none !important;
    border-bottom-color: var(--color-accent) !important;
}

.editor-block {
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    padding: var(--space-sm) var(--space-md);
    border-left: 4px solid var(--color-border);
}

.editor-block.kind-warmup   { border-left-color: #EF9F27; background: #fef9f0; }
.editor-block.kind-work      { border-left-color: #E24B4A; background: #fef5f5; }
.editor-block.kind-rest      { border-left-color: #5DCAA5; background: #f0fdf8; }
.editor-block.kind-cooldown  { border-left-color: #85B7EB; background: #f0f7fe; }
.editor-block.kind-repeat    { border-left-color: var(--color-accent); }

@media (prefers-color-scheme: dark) {
    .editor-block.kind-warmup   { background: #2a2210; }
    .editor-block.kind-work      { background: #2a1515; }
    .editor-block.kind-rest      { background: #0f2a22; }
    .editor-block.kind-cooldown  { background: #0f1a2a; }
}

.block-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
    flex-wrap: wrap;
}

.block-icon { font-size: 1rem; }

.block-actions {
    margin-left: auto;
    display: flex;
    gap: 2px;
}

.btn-icon-sm {
    background: none;
    border: none;
    padding: 2px 6px;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    cursor: pointer;
    border-radius: 3px;
}

.btn-icon-sm:hover {
    background: var(--color-bg-secondary);
    color: var(--color-text);
}

.block-edit-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.edit-row {
    display: flex;
    gap: var(--space-xs);
    align-items: center;
    flex-wrap: wrap;
}

.edit-row select {
    width: auto;
    min-width: 5rem;
    flex: 0 0 auto;
}

.edit-label {
    flex: 1;
    min-width: 5rem;
}

.edit-num {
    width: 3.5rem !important;
    flex: 0 0 auto !important;
    text-align: center;
}

.edit-inline-label {
    font-size: 0.8rem;
    margin: 0;
    color: var(--color-text-muted);
    flex: 0 0 auto;
}

.edit-intensity {
    flex: 1;
    min-width: 5rem;
}

.repeat-segment-edit {
    position: relative;
    padding: var(--space-sm);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    margin-top: var(--space-xs);
}

.btn-delete-seg {
    position: absolute;
    top: 4px;
    right: 4px;
}

.btn-add-seg {
    font-size: 0.8rem;
    padding: 0.3rem 0.6rem;
    margin-top: var(--space-xs);
    align-self: flex-start;
}

.repeat-pills {
    display: flex;
    gap: var(--space-xs);
    flex-wrap: wrap;
    margin-top: var(--space-sm);
}

.repeat-pill {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 99px;
}

.repeat-pill.kind-work     { background: #fee2e2; color: #991b1b; }
.repeat-pill.kind-rest     { background: #dcfce7; color: #15803d; }
.repeat-pill.kind-warmup   { background: #fef3c7; color: #92400e; }
.repeat-pill.kind-cooldown { background: #dbeafe; color: #1e40af; }

@media (prefers-color-scheme: dark) {
    .repeat-pill.kind-work     { background: #7f1d1d; color: #fca5a5; }
    .repeat-pill.kind-rest     { background: #14532d; color: #86efac; }
    .repeat-pill.kind-warmup   { background: #78350f; color: #fde68a; }
    .repeat-pill.kind-cooldown { background: #1e3a5f; color: #93c5fd; }
}

.editor-add-buttons {
    display: flex;
    gap: var(--space-sm);
}

.btn-add {
    flex: 1;
    padding: 0.5rem;
    font-size: 0.85rem;
    text-align: center;
}

.btn-delete-workout {
    background: none;
    border: none;
    color: var(--color-danger);
    font-size: 0.85rem;
    padding: var(--space-sm) 0;
    cursor: pointer;
    text-align: center;
}

.btn-delete-workout:hover {
    text-decoration: underline;
    background: none;
}

/* === Timer === */

.timer-screen {
    position: fixed;
    inset: 0;
    background: var(--timer-bg, #1a1a2e);
    color: var(--timer-text, #e8e8ed);
    z-index: 100;
    overflow: hidden;
    transition: background-color 0.15s;
}

.timer-layout {
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: env(safe-area-inset-top, 12px) 16px env(safe-area-inset-bottom, 12px);
}

.timer-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
}

.timer-exit {
    position: absolute;
    top: 0;
    left: 0;
    background: none;
    border: none;
    color: var(--timer-muted);
    font-size: 0.85rem;
    cursor: pointer;
    padding: 8px 4px;
}

.timer-exit:hover { color: var(--timer-text); background: none; }

.timer-center {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.timer-kind {
    color: var(--timer-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.timer-round {
    color: var(--timer-text);
    font-size: 1.15rem;
    font-weight: 500;
    margin-top: 4px;
}

.timer-countdown {
    font-family: var(--font-mono);
    font-size: clamp(4rem, 18vw, 7rem);
    font-weight: 500;
    color: var(--timer-text);
    line-height: 1;
    margin: 0.5rem 0;
    font-variant-numeric: tabular-nums;
}

.timer-intensity {
    font-size: 0.9rem;
    color: var(--timer-muted);
    background: var(--timer-track);
    padding: 4px 12px;
    border-radius: var(--radius);
    min-height: 1.6rem;
}

.timer-intensity:empty { background: none; }

.timer-progress-track {
    width: 85%;
    max-width: 20rem;
    height: 6px;
    background: var(--timer-track);
    border-radius: 3px;
    margin: 1.25rem 0 0.75rem;
    overflow: hidden;
}

.timer-progress-fill {
    height: 100%;
    background: var(--timer-accent);
    border-radius: 3px;
    transition: width 0.1s linear;
}

.timer-next {
    color: var(--timer-muted);
    font-size: 0.85rem;
}

.timer-meta {
    text-align: center;
    color: var(--timer-muted);
    font-size: 0.75rem;
    padding-bottom: var(--space-sm);
}

.timer-controls {
    display: flex;
    gap: 12px;
    justify-content: center;
    align-items: center;
    padding: var(--space-sm) 0;
}

.timer-btn-primary {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--timer-accent);
    color: var(--timer-bg);
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s;
}

.timer-btn-primary:hover { transform: scale(1.05); background: var(--timer-accent); }
.timer-btn-primary:active { transform: scale(0.95); }

.timer-btn-secondary {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--timer-track);
    color: var(--timer-muted);
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.timer-btn-secondary:hover { color: var(--timer-text); background: var(--timer-track); }

/* Timer landscape layout */
@media (orientation: landscape) and (max-height: 500px) {
    .timer-layout {
        flex-direction: row;
        padding: 8px 16px;
    }

    .timer-info {
        flex: 1;
    }

    .timer-countdown {
        font-size: clamp(3rem, 12vw, 5rem);
    }

    .timer-controls {
        flex-direction: column;
        justify-content: center;
        padding: 0 0 0 16px;
        border-left: 1px solid var(--timer-track);
        margin-left: 16px;
    }

    .timer-meta {
        position: absolute;
        bottom: 0;
        right: 0;
        text-align: right;
        font-size: 0.7rem;
    }
}

/* Timer complete */
.timer-complete {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: var(--space-sm);
}

.timer-complete-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--timer-accent);
    color: var(--timer-bg);
    font-size: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-md);
}

.timer-complete h2 { color: var(--timer-text); }
.timer-complete .muted { color: var(--timer-muted); }

/* === Admin === */

.admin-form-row {
    display: flex;
    gap: var(--space-sm);
}

.admin-form-row > * { flex: 1; }

.admin-user-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) var(--space-md);
}

.admin-user-row .badge {
    margin-left: var(--space-sm);
    font-size: 0.7rem;
}

.badge-admin {
    background: var(--color-accent);
    color: var(--color-accent-text);
}