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

:root {
    --bg: #0d0f14;
    --bg2: #12151c;
    --surface: rgba(255, 255, 255, 0.05);
    --surface-hover: rgba(255, 255, 255, 0.08);
    --border: rgba(255, 255, 255, 0.08);
    --border-active: rgba(255, 255, 255, 0.18);
    --text: #e8eaf0;
    --text-muted: #8b8fa8;
    --text-dim: #555972;
    --accent: #6c63ff;
    --accent-soft: rgba(108, 99, 255, 0.18);
    --accent-glow: rgba(108, 99, 255, 0.35);
    --green: #22d986;
    --green-soft: rgba(34, 217, 134, 0.15);
    --yellow: #f9b529;
    --yellow-soft: rgba(249, 181, 41, 0.15);
    --red: #ff5b5b;
    --red-soft: rgba(255, 91, 91, 0.15);
    --radius: 16px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ─── HEADER ─────────────────────────────────────── */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(13, 15, 20, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    max-width: 680px;
    margin: 0 auto;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-icon {
    font-size: 26px;
    line-height: 1;
    filter: drop-shadow(0 0 10px #ffca28);
}

.header-title {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: var(--text);
}

.header-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 400;
}

/* ─── BUTTONS ────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    user-select: none;
}

.btn-ghost {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text-muted);
}

.btn-ghost:hover {
    background: var(--surface-hover);
    border-color: var(--border-active);
    color: var(--text);
}

.btn-cancel {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text-muted);
    flex: 1;
}

.btn-cancel:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.btn-danger {
    background: var(--red-soft);
    border-color: rgba(255, 91, 91, 0.35);
    color: var(--red);
    flex: 1;
}

.btn-danger:hover {
    background: rgba(255, 91, 91, 0.25);
}

.btn-label {
    display: inline;
}

@media (max-width: 380px) {
    .btn-label {
        display: none;
    }
}

/* ─── STATS BAR ──────────────────────────────────── */
.stats-bar {
    display: flex;
    gap: 8px;
    padding: 12px 16px 0;
    max-width: 680px;
    margin: 0 auto;
}

.stat-chip {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 6px;
}

.stat-label {
    font-size: 10px;
    color: var(--text-dim);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: center;
}

.stat-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.5px;
}

/* ─── OVERALL PROGRESS BAR ───────────────────────── */
.overall-progress-wrapper {
    padding: 12px 16px 0;
    max-width: 680px;
    margin: 0 auto;
}

.overall-progress-bar {
    height: 5px;
    background: var(--surface);
    border-radius: 99px;
    overflow: hidden;
}

.overall-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--green));
    border-radius: 99px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    width: 0%;
}

/* ─── EXERCISE CARDS ─────────────────────────────── */
.exercises {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px 16px 32px;
    max-width: 680px;
    margin: 0 auto;
}

.card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.card.completed {
    border-color: rgba(34, 217, 134, 0.3);
    box-shadow: 0 0 20px rgba(34, 217, 134, 0.08);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    cursor: pointer;
    user-select: none;
}

.card-header:hover .card-title {
    color: var(--accent);
}

.card-emoji {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.card-meta {
    flex: 1 0 auto;
    min-width: 0;
}

.card-title {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.2px;
    transition: color var(--transition);
}

.card-rec {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.card-chevron {
    color: var(--text-dim);
    transition: transform var(--transition);
    flex-shrink: 0;
}

@media (max-width: 500px) {
    .card-header {
        flex-wrap: wrap;
    }

    .ring-wrap, .set-counter {
        margin-left: auto;
    }
}

.card.open .card-chevron {
    transform: rotate(180deg);
}

/* ─── SET COUNTER ────────────────────────────────── */
.set-counter {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.counter-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition);
    flex-shrink: 0;
    user-select: none;
}

.counter-btn:hover {
    background: var(--surface-hover);
    border-color: var(--border-active);
}

.counter-btn:active {
    transform: scale(0.92);
}

.counter-btn.plus:hover {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
}

.counter-display {
    min-width: 28px;
    text-align: center;
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.5px;
}

/* ─── PROGRESS RING ──────────────────────────────── */
.ring-wrap {
    position: relative;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

.ring-wrap svg {
    transform: rotate(-90deg);
}

.ring-bg {
    fill: none;
    stroke: var(--surface);
    stroke-width: 3;
}

.ring-fill {
    fill: none;
    stroke: var(--green);
    stroke-width: 3;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

.ring-label {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 700;
    color: var(--text-muted);
}

/* ─── CARD BODY (collapsible) ────────────────────── */
.card-body {
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.card.open .card-body {
    max-height: 800px;
}

.card-body-inner {
    border-top: 1px solid var(--border);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* ─── VARIATIONS ─────────────────────────────────── */

.variations-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-dim);
    margin-bottom: 8px;
}

.variations-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.variation-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.variation-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 2px;
}

.variation-desc {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.45;
}

.variation-badge {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 1px;
}

/* ─── SETS LOG ───────────────────────────────────── */

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

.sets-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-dim);
}

.sets-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sets-count-large {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -1px;
    color: var(--text);
}

.sets-rec-text {
    font-size: 12px;
    color: var(--text-muted);
}

.sets-dots {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.set-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--surface-hover);
    border: 1px solid var(--border);
    transition: all var(--transition);
}

.set-dot.filled {
    background: var(--green);
    border-color: var(--green);
    box-shadow: 0 0 6px rgba(34, 217, 134, 0.5);
}

/* ─── CARD COLORS ────────────────────────────────── */
.color-purple .card-emoji {
    background: rgba(108, 99, 255, 0.15);
}

.color-blue .card-emoji {
    background: rgba(56, 189, 248, 0.12);
}

.color-green .card-emoji {
    background: rgba(34, 217, 134, 0.12);
}

.color-orange .card-emoji {
    background: rgba(249, 115, 22, 0.13);
}

.color-pink .card-emoji {
    background: rgba(236, 72, 153, 0.12);
}

/* ─── MODAL ──────────────────────────────────────── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
}

.modal-backdrop.open {
    opacity: 1;
    pointer-events: all;
}

.modal {
    background: var(--bg2);
    border: 1px solid var(--border-active);
    border-radius: var(--radius);
    padding: 28px 24px;
    max-width: 340px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow);
    transform: scale(0.94);
    transition: transform var(--transition);
}

.modal-backdrop.open .modal {
    transform: scale(1);
}

.modal-icon {
    font-size: 36px;
    margin-bottom: 12px;
}

.modal-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 8px;
}

.modal-body {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.55;
    margin-bottom: 20px;
}

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

/* ─── ANIMATIONS ─────────────────────────────────── */
@keyframes pop {
    0% {
        transform: scale(1);
    }

    40% {
        transform: scale(1.35);
    }

    100% {
        transform: scale(1);
    }
}

.set-dot.pop {
    animation: pop 0.28s ease;
}

@keyframes fadeSlideUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

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

.card {
    animation: fadeSlideUp 0.4s ease both;
}

.card:nth-child(1) {
    animation-delay: 0.05s;
}

.card:nth-child(2) {
    animation-delay: 0.10s;
}

.card:nth-child(3) {
    animation-delay: 0.15s;
}

.card:nth-child(4) {
    animation-delay: 0.20s;
}

.card:nth-child(5) {
    animation-delay: 0.25s;
}

/* ─── COMPLETED BADGE ────────────────────────────── */
.completed-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--green);
    background: var(--green-soft);
    border-radius: 99px;
    padding: 2px 8px;
    margin-top: 4px;
}

/* ─── SCROLLBAR ──────────────────────────────────── */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 99px;
}