:root {
    --bg-color: #0d0d0d;
    --card-bg: rgba(255, 255, 255, 0.05);
    --text-main: #ffffff;
    --text-muted: #a0a0a0;
    --primary: #00ff9d;
    --primary-dim: #00cc7d;
    --danger: #ff4d4d;
    --rest-color: #ffd700;
    /* Gold for Rest */
    --work-color: #00ff9d;
    /* Green for Work */
    --glass-border: 1px solid rgba(255, 255, 255, 0.1);
    --font-main: 'Inter', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: var(--font-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
}

.app-container {
    width: 100%;
    max-width: 900px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
}

h1 {
    font-weight: 800;
    font-size: 1.5rem;
    letter-spacing: -0.5px;
}

.highlight {
    color: var(--primary);
}

/* Views & Navigation */
.view {
    display: flex;
    flex-direction: column;
    gap: 16px;
    animation: fadeIn 0.3s ease;
}

.view.hidden {
    display: none;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

/* Lists & Cards */
.card-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.group-card {
    background: var(--card-bg);
    border: var(--glass-border);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    cursor: pointer;
    transition: transform 0.2s;
}

.group-card:hover {
    background: rgba(255, 255, 255, 0.08);
}

.card-top-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.card-title {
    font-weight: 600;
    font-size: 1.1rem;
    flex: 1;
}

.card-count {
    font-weight: 400;
    font-size: 0.9rem;
    color: var(--text-muted);
}


.card-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.card-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn-icon.small {
    font-size: 1rem;
    padding: 2px 6px;
    height: 36px;
    /* Align with header buttons */
    display: inline-flex;
    align-items: center;
}

.btn-icon .material-icons-outlined {
    font-size: 1.2rem;
}

/* Exercise Card with Thumbnail */
.exercise-card {
    background: var(--card-bg);
    border: var(--glass-border);
    border-radius: 16px;
    padding: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
    gap: 16px;
    /* Increased gap */
}

.exercise-card:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.exercise-card.dragging {
    opacity: 0.4;
    border: 2px dashed var(--primary);
}

.drag-drop-indicator {
    height: 3px;
    background: var(--primary);
    border-radius: 2px;
    margin: -7px 0;
    pointer-events: none;
}

.ex-thumb {
    width: 80px;
    height: 80px;
    border-radius: 10px;
    object-fit: cover;
    background: rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
}

/* Thumbnail wrapper for hover preview */
.thumb-wrapper {
    position: relative;
    flex-shrink: 0;
}

.thumb-wrapper .thumb-preview {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    width: 220px;
    height: auto;
    border-radius: 12px;
    object-fit: contain;
    border: 2px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    z-index: 100;
    pointer-events: none;
}

.thumb-wrapper:hover .thumb-preview {
    display: block;
}

.ex-info {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.exercise-card .card-title {
    font-size: 0.95rem;
    /* Smaller title */
    margin-bottom: 4px;
}

.drag-handle {
    color: var(--text-muted);
    cursor: grab;
    padding: 0 8px;
    user-select: none;
    display: flex;
    align-items: center;
}

.drag-handle .material-icons-outlined {
    font-size: 1.5rem;
}

.drag-handle:active {
    cursor: grabbing;
    color: var(--primary);
}

/* Forms */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.large-input {
    background: transparent;
    border: none;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
    font-size: 1.8rem;
    font-weight: 700;
    padding: 8px 0;
    color: var(--text-main);
    border-radius: 0;
}

.large-input:focus {
    border-color: var(--primary);
    outline: none;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-group.full {
    grid-column: span 2;
}

label {
    color: var(--text-muted);
    font-size: 0.85rem;
}

input,
select {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 8px;
    padding: 10px;
    color: var(--text-main);
    font-family: var(--font-main);
    width: 100%;
}

/* Only selects get the dropdown caret */
select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23a0a0a0%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 12px;
    cursor: pointer;
}

/* Adjust select background size for unit toggle specifically if needed */
.unit-toggle {
    width: 70px !important;
    flex-shrink: 0;
    border-left: none;
    border-radius: 0 8px 8px 0;
    background-position: right 8px center;
}

.input-group {
    display: flex;
    align-items: center;
}

.input-group input {
    border-radius: 8px 0 0 8px;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
}

input:focus,
select:focus {
    border-color: var(--primary);
    outline: none;
    z-index: 1;
    /* Bring to front on focus */
}

/* Active Workout Variables */
.workout-header {
    padding: 20px;
    text-align: center;
}

.workout-header-actions {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 10px;
}

.details-text {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 4px;
}

/* Guide link in wh-details */
.wh-details .guide-link {
    display: block;
    margin-top: 4px;
}

.guide-link {
    color: var(--primary);
    text-decoration: none;
    white-space: nowrap;
}

.guide-link:hover {
    text-decoration: underline;
}

/* Breadcrumb Navigation */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    padding: 4px 0;
}

.bc-link {
    color: var(--primary);
    cursor: pointer;
    transition: opacity 0.2s;
}

.bc-link:hover {
    opacity: 0.7;
    text-decoration: underline;
}

.bc-sep {
    color: var(--text-muted);
}

.bc-current {
    color: var(--text-muted);
}

/* Workout Thumbnail */
.workout-thumb {
    max-height: 180px;
    border-radius: 12px;
    margin-top: 12px;
    object-fit: contain;
}

/* Sets Section */
.sets-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.reps-badge {
    background: rgba(255, 255, 255, 0.1);
    border: var(--glass-border);
    border-radius: 20px;
    padding: 4px 14px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.set-card {
    flex: 0 0 88px;
    width: 88px;
    min-width: 88px;
    max-width: 88px;
    height: 88px;
    background: var(--card-bg);
    border: 2px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.set-card .set-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
    line-height: 1;
}

.set-card .set-number {
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1;
}

/* Pending (upcoming) — readable but subdued */
.set-card.pending {
    opacity: 0.6;
}

.set-card.pending .set-number {
    color: rgba(255, 255, 255, 0.5);
}

/* Active set */
.set-card.active {
    border-color: var(--primary);
    box-shadow: 0 0 12px rgba(0, 255, 157, 0.15);
    opacity: 1;
}

.set-card.active .set-number {
    color: var(--primary);
}

/* Completed set */
.set-card.completed {
    border-color: rgba(0, 255, 157, 0.3);
    background: rgba(0, 255, 157, 0.08);
    opacity: 1;
}

.set-card.completed .set-number {
    color: var(--primary);
}

/* Rest cards — readable but distinct via dashed border */
.set-card.rest-card {
    opacity: 0.6;
    border-style: dashed;
    border-color: rgba(255, 215, 0, 0.2);
}

.set-card.rest-card .set-label {
    color: var(--text-muted);
}

.set-card.rest-card .set-number {
    font-size: 1.3rem;
    font-weight: 700;
    color: rgba(255, 215, 0, 0.5);
}

/* Active rest */
.set-card.rest-card.rest-active {
    opacity: 1;
    border-color: var(--rest-color);
    border-style: solid;
    box-shadow: 0 0 12px rgba(255, 165, 0, 0.2);
}

.set-card.rest-card.rest-active .set-number {
    color: var(--rest-color);
}

/* Completed rest */
.set-card.rest-card.rest-done {
    opacity: 1;
    border-color: rgba(255, 165, 0, 0.3);
    border-style: solid;
    background: rgba(255, 165, 0, 0.08);
}

.set-card.rest-card.rest-done .set-number {
    color: var(--rest-color);
}

/* Back button */
.back-btn {
    flex: 0 0 64px !important;
    width: 64px;
    min-width: 64px;
    padding-left: 0;
    padding-right: 0;
}

/* Reset / icon button */
.btn-icon {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.08);
}

.sets-section-header {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-bottom: 6px;
}

/* Sets row layout with edge nav */
.sets-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.exercise-nav {
    flex: 0 0 auto;
    min-width: 88px;
}

.exercise-nav:empty {
    min-width: 88px;
    visibility: hidden;
}

.sets-grid {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    flex: 1;
}

/* Prev/Next exercise nav cards */
.nav-card {
    cursor: pointer;
    opacity: 0.5;
    border-style: dashed !important;
}

.nav-card:hover {
    opacity: 0.8;
    border-color: var(--primary) !important;
}

.nav-card .set-label {
    font-size: 0.65rem;
    text-align: center;
}

/* Exercise pills navigation */
.exercise-pills {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    padding: 0 0 4px;
}

/* Shared progress pills (used in both Home + Workout) */
.progress-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    padding: 5px 12px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    white-space: nowrap;
    transition: all 0.25s ease;
}

.progress-pill.active {
    background: rgba(0, 255, 157, 0.12);
    border-color: var(--primary);
    color: var(--primary);
    font-weight: 600;
}

.progress-pill:hover {
    border-color: rgba(255, 255, 255, 0.25);
}

.progress-dots {
    display: inline-flex;
    gap: 3px;
    margin-left: 2px;
}

.progress-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
}

.progress-dot.done {
    background: var(--primary);
}

/* Rest input row - left aligned, bigger */
.rest-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 600;
}

.rest-input-large {
    width: 80px;
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--card-bg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    font-size: 1.1rem;
    text-align: left;
}



/* Group card dragging */
.group-card.dragging {
    opacity: 0.5;
    border: 1px dashed var(--primary);
}

.group-card .drag-handle {
    flex-shrink: 0;
    margin-right: -4px;
}

/* Timer Section */
.timer-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    gap: 8px;
}

.timer-display-large {
    font-size: 3.5rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    color: var(--work-color);
    text-shadow: 0 0 20px rgba(0, 255, 157, 0.1);
}

.timer-display-large.rest-mode {
    color: var(--rest-color);
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.2);
}

/* Flashing pulse when idle and waiting for user to start a set */
.timer-display-large.idle-flash {
    animation: idlePulse 1.5s ease-in-out infinite;
}

@keyframes idlePulse {
    0%, 100% {
        opacity: 1;
        text-shadow: 0 0 20px rgba(0, 255, 157, 0.1);
    }
    50% {
        opacity: 0.35;
        text-shadow: 0 0 8px rgba(0, 255, 157, 0.05);
    }
}

.timer-label {
    font-size: 0.8rem;
    letter-spacing: 2px;
    color: var(--text-muted);
}

/* Resting badge */
.reps-badge.resting {
    background: rgba(255, 215, 0, 0.15);
    border-color: rgba(255, 215, 0, 0.3);
    color: var(--rest-color);
    font-weight: 600;
}

/* Audio controls */
.audio-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 4px 0;
}

.audio-controls .btn-icon {
    font-size: 1.2rem;
    padding: 4px 6px;
}

.volume-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100px;
    height: 4px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
    outline: none;
    border: none;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
}

.volume-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: none;
}

.controls-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.controls-row .large-btn {
    flex: 1;
}

.large-btn {
    padding: 18px;
    font-size: 1.2rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Header Layout Updates */
.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

#header-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    /* Consistent spacing */
}

/* Ensure all header buttons are same height */
#header-controls .btn {
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
    border-radius: 8px;
    /* Standardize */
}

/* Settings button specifically */
#settings-btn {
    height: 36px;
    width: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    /* Match other secondary buttons */
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    color: var(--text-muted);
}

#settings-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.settings-dropdown {
    display: flex;
    align-items: center;
}

/* Global Dropdown Styles */
#settings-menu {
    min-width: 180px;
    right: 0;
}

/* Card Dropdown updates */
.dropdown-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 6px 0;
}

.danger-text {
    color: var(--danger) !important;
}

.danger-text:hover {
    background: rgba(255, 77, 77, 0.15) !important;
}

/* Exercise Tags on Routine Cards */
.ex-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.ex-tag {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    padding: 3px 10px;
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    width: 90%;
    max-width: 400px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 10px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.close-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.1);
}

.close-btn .material-icons-outlined {
    font-size: 1.5rem;
}

.backup-actions {
    display: flex;
    gap: 12px;
}

.backup-actions .btn,
.backup-actions label {
    flex: 1;
    text-align: center;
    padding: 12px 16px;
    cursor: pointer;
}

/* Utilities */
.glass-panel {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: var(--glass-border);
    border-radius: 20px;
}

.btn {
    border: none;
    padding: 10px 20px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
}

.btn.primary {
    background: var(--primary);
    color: #000;
}

/* Flashing pulse for the action button when idle and waiting to start */
.btn.primary.idle-flash {
    animation: btnPulse 1.5s ease-in-out infinite;
}

@keyframes btnPulse {
    0%, 100% {
        opacity: 1;
        box-shadow: 0 0 0 rgba(0, 255, 157, 0);
    }
    50% {
        opacity: 0.4;
        box-shadow: 0 0 18px rgba(0, 255, 157, 0.35);
    }
}

.btn.secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    transition: all 0.2s ease;
}

.btn.secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.btn.secondary:disabled,
.btn.secondary.disabled {
    opacity: 0.3;
    cursor: default;
    pointer-events: none;
}

/* Compact inline row for small number inputs */
.form-row-compact {
    display: flex;
    gap: 12px;
    grid-column: span 2;
}

.form-row-compact .form-group {
    flex: 1;
    margin-bottom: 0;
}

.btn.danger-outline {
    border: 1px solid var(--danger);
    background: transparent;
    color: var(--danger);
}

.btn.small {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.btn.outline {
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: transparent;
    color: var(--text-muted);
}

.btn.icon-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    padding: 40px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 20px 0;
}

.divider-text {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 10px 0;
}

.link-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    text-decoration: underline;
    cursor: pointer;
}

/* History */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 400px;
    overflow-y: auto;
}

.history-entry {
    background: rgba(255, 255, 255, 0.04);
    border: var(--glass-border);
    border-radius: 12px;
    padding: 12px 14px;
}

.history-entry-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.link-btn.danger {
    color: var(--danger);
    margin-top: 12px;
}

.hidden {
    display: none !important;
}

/* Settings Dropdown */
.settings-dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: #1a1a1a;
    border: var(--glass-border);
    border-radius: 10px;
    padding: 4px 0;
    min-width: 160px;
    z-index: 100;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 16px;
    text-align: left;
    background: none;
    border: none;
    color: var(--text-main);
    font-family: var(--font-main);
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.15s;
}

.dropdown-item .material-icons-outlined {
    font-size: 16px;
}

.dropdown-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.dropdown-item.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Card Menu (vertical ...) */
.card-menu-wrapper {
    position: relative;
    flex-shrink: 0;
}

.card-menu-btn {
    font-size: 1.6rem;
    padding: 6px 12px;
    line-height: 1;
    min-width: 36px;
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-menu-btn .material-icons-outlined {
    font-size: 1.5rem;
}

.card-dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: #1a1a1a;
    border: var(--glass-border);
    border-radius: 10px;
    padding: 4px 0;
    min-width: 120px;
    z-index: 100;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.card-dropdown-menu .dropdown-item {
    padding: 8px 14px;
    font-size: 0.85rem;
}

.edit-ex-icon {
    font-size: 0.9rem;
    padding: 2px 4px;
    opacity: 0.6;
    transition: opacity 0.15s;
}

.edit-ex-icon:hover {
    opacity: 1;
}

.edit-ex-icon .material-icons-outlined {
    font-size: 1.2rem;
}

/* Completed check icon — inline on desktop, repositioned on mobile */
.card-completed-icon {
    display: inline-flex;
    align-items: center;
    margin-left: 8px;
    vertical-align: middle;
}

.card-completed-icon .material-icons-outlined {
    font-size: 1rem;
    color: var(--primary);
}

/* Completed date label inline */
.card-completed {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-muted);
    margin-left: 4px;
    vertical-align: middle;
}

/* Wider archive modal */
.modal-wide {
    max-width: 560px;
}

/* Archive entry layout */
.archive-entry-row {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.archive-checkbox {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

.archive-entry-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.archive-entry-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.archive-bulk-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 8px;
}

.archive-select-all-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-muted);
    cursor: pointer;
}

.archive-bulk-right {
    display: flex;
    gap: 8px;
}

/* Cloud Sync */
.sync-indicator {
    color: var(--primary);
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: opacity 0.3s ease;
}

.sync-indicator .material-icons-outlined {
    font-size: 1.3rem;
}

.sync-indicator.syncing .material-icons-outlined {
    animation: spin 1s linear infinite;
}

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

.sync-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sync-form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sync-form-group label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
}

.sync-form-group input {
    background: rgba(255, 255, 255, 0.08);
    border: var(--glass-border);
    border-radius: 10px;
    padding: 10px 14px;
    color: var(--text-main);
    font-family: var(--font-main);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}

.sync-form-group input:focus {
    border-color: var(--primary);
}

.sync-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
    font-size: 0.8rem;
    margin: 4px 0;
}

.sync-divider::before,
.sync-divider::after {
    content: '';
    flex: 1;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sync-status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: rgba(0, 255, 157, 0.08);
    border: 1px solid rgba(0, 255, 157, 0.2);
    border-radius: 12px;
    color: var(--primary);
    font-size: 0.95rem;
}

.sync-status-badge .material-icons-outlined {
    font-size: 1.3rem;
}

.sync-error {
    color: var(--danger);
    font-size: 0.85rem;
    text-align: center;
    padding: 8px;
}

/* ========== DESKTOP / MOBILE VISIBILITY ========== */

/* Mobile-only elements hidden on desktop */
.mobile-only {
    display: none !important;
}

/* Desktop-only: visible by default, hidden in mobile media query */
.desktop-only {
    /* shown by default */
}

/* Square icon add button (always styled, visibility toggled) */
.btn-icon-square {
    width: 36px;
    height: 36px;
    padding: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 0;
}

.btn-icon-square .material-icons-outlined {
    font-size: 1.3rem;
}

/* ---- Unified workout header hero (shared collapsed/expanded) ---- */
.wh-hero {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: relative;
}

.wh-thumb {
    display: none; /* hidden on desktop — full image shown in details */
}

.wh-text {
    text-align: center;
}

.wh-name-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.wh-name {
    font-weight: 700;
    font-size: 1.35rem;
}

.wh-meta {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.wh-chevron {
    display: none; /* hidden on desktop */
}

.wh-details {
    text-align: center;
}

/* ========== MOBILE RESPONSIVE ========== */
@media (max-width: 600px) {

    /* --- Visibility toggles --- */
    .mobile-only {
        display: flex !important;
    }

    .desktop-only {
        display: none !important;
    }

    /* Reset All in dropdown needs display:flex for icon alignment */
    button.mobile-only.dropdown-item {
        display: flex !important;
    }

    /* --- Header: single row, compact --- */
    header {
        gap: 8px;
    }

    .header-left {
        flex: 1 1 auto;
        min-width: 0;
    }

    #header-controls {
        flex-shrink: 0;
        gap: 6px;
    }

    /* --- Modals: fit screen, scrollable --- */
    .modal-content {
        width: 95%;
        max-width: none;
        max-height: 90vh;
        overflow-y: auto;
        padding: 18px;
    }

    .modal-wide {
        max-width: none;
    }

    /* Exercise modal form grid: single column on narrow screens */
    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-group.full {
        grid-column: span 1;
    }

    .form-row-compact {
        grid-column: span 1;
    }

    .modal-actions {
        flex-direction: row;
        flex-wrap: wrap;
    }

    /* --- Collapsible workout header (unified hero) --- */
    .workout-header {
        padding: 0;
        overflow: hidden;
    }

    /* Hero: collapsed = compact left-aligned row */
    .wh-hero {
        justify-content: flex-start;
        gap: 12px;
        padding: 12px 14px;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .wh-thumb {
        display: block;
        width: 44px;
        height: 44px;
        border-radius: 8px;
        object-fit: cover;
        background: rgba(0, 0, 0, 0.3);
        flex-shrink: 0;
        transition: opacity 0.2s ease,
                    width 0.25s cubic-bezier(.4,0,.2,1),
                    height 0.25s cubic-bezier(.4,0,.2,1),
                    margin 0.25s cubic-bezier(.4,0,.2,1);
    }

    .wh-thumb.no-thumb {
        display: none;
    }

    /* Fade out collapsed thumb when expanded (details image takes over) */
    .workout-header.expanded .wh-thumb {
        opacity: 0;
        width: 0;
        height: 0;
        margin: 0;
        overflow: hidden;
    }

    .wh-text {
        flex: 1;
        min-width: 0;
        text-align: left;
    }

    .wh-name-row {
        justify-content: flex-start;
    }

    .wh-name {
        font-size: 0.95rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .wh-meta {
        font-size: 0.8rem;
    }

    .wh-chevron {
        display: block;
        color: var(--text-muted);
        font-size: 1.4rem;
        transition: transform 0.3s cubic-bezier(.4,0,.2,1);
        flex-shrink: 0;
    }

    /* Edit button: hidden when collapsed, inline with name when expanded */
    .wh-edit-btn {
        display: none;
    }

    /* Details hidden in collapsed state */
    .wh-details {
        display: grid;
        grid-template-rows: 0fr;
        transition: grid-template-rows 0.4s cubic-bezier(.4,0,.2,1),
                    padding 0.4s cubic-bezier(.4,0,.2,1),
                    opacity 0.35s ease;
        opacity: 0;
        padding: 0 14px;
    }

    .wh-details-inner {
        overflow: hidden;
    }

    /* Image fades in/out with expand */
    .workout-thumb {
        transition: opacity 0.3s ease,
                    max-height 0.4s cubic-bezier(.4,0,.2,1),
                    margin 0.4s cubic-bezier(.4,0,.2,1);
        opacity: 0;
        max-height: 0;
        margin: 0;
    }

    /* ---- EXPANDED STATE ---- */
    .workout-header.expanded .wh-hero {
        padding: 14px 14px 8px;
    }

    .workout-header.expanded .wh-text {
        text-align: center;
    }

    .workout-header.expanded .wh-name-row {
        justify-content: center;
    }

    .workout-header.expanded .wh-name {
        font-size: 1.15rem;
        white-space: normal;
        overflow: visible;
    }

    .workout-header.expanded .wh-meta {
        font-size: 0.85rem;
    }

    .workout-header.expanded .wh-chevron {
        transform: rotate(180deg);
    }

    .workout-header.expanded .wh-edit-btn {
        display: inline-flex;
    }

    .workout-header.expanded .wh-details {
        grid-template-rows: 1fr;
        opacity: 1;
        padding: 0 14px 14px;
    }

    /* Image fades in when expanded */
    .workout-header.expanded .workout-thumb {
        opacity: 1;
        max-height: 160px;
        margin-top: 10px;
    }

    /* --- Workout view: hide prev/next nav, responsive sets grid --- */
    .exercise-nav {
        display: none !important;
    }

    .sets-row {
        justify-content: center;
    }

    .sets-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
        max-width: 100%;
        gap: 8px;
        justify-items: center;
    }

    .set-card {
        flex: none;
        width: 100%;
        max-width: 120px;
        min-width: 88px;
    }

    /* Slightly smaller timer on small screens */
    .timer-display-large {
        font-size: 2.8rem;
    }

    /* Slightly smaller large buttons */
    .large-btn {
        padding: 14px;
        font-size: 1.05rem;
    }

    /* App container tighter padding */
    .app-container {
        padding: 12px;
        gap: 14px;
    }

    /* Exercise cards tighter on mobile */
    .exercise-card {
        gap: 10px;
        padding: 10px;
    }

    .ex-thumb {
        width: 60px;
        height: 60px;
    }

    /* Hide thumbnail hover preview on touch devices */
    .thumb-wrapper .thumb-preview {
        display: none !important;
    }

    /* Backup / sync action buttons stack if needed */
    .backup-actions {
        flex-direction: column;
    }

    .backup-actions .btn,
    .backup-actions label {
        width: 100%;
    }

    /* Completed: icon moves left of name, date wraps below */
    .card-title.is-completed {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 0 6px;
    }

    .card-title.is-completed .card-completed-icon {
        order: -1;
        margin-left: 0;
    }

    .card-title.is-completed .card-name {
        order: 0;
        flex: 1;
        min-width: 0;
    }

    .card-title.is-completed .card-completed {
        order: 1;
        width: 100%;
        margin-left: 0;
        margin-top: 4px;
    }
}

/* Extra small (under 380px, very narrow phones) */
@media (max-width: 380px) {
    h1 {
        font-size: 1.2rem;
    }

    .set-card {
        height: 78px;
    }

    .set-card .set-number {
        font-size: 1.1rem;
    }

    .timer-display-large {
        font-size: 2.4rem;
    }

    .large-btn {
        padding: 12px;
        font-size: 0.95rem;
    }

    .modal-content {
        padding: 14px;
        gap: 12px;
    }
}