:root{
    --bg:#0f1115;
    --surface:#171a21;
    --surface-soft:#20242d;
    --surface-hover:#2b303b;
    --border:rgba(255,255,255,0.08);

    --text:#f9fafb;
    --muted:#9ca3af;

    --accent:#20c7b5;
    --accent-hover:#17a99a;
    --accent-soft:rgba(32,199,181,0.16);

    --danger:#ef4444;
    --danger-soft:rgba(239,68,68,0.16);
}

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

html,
body{
    min-height:100%;
}

body{
    background:#2f2f2f;
    color:var(--text);
    font-family:Inter, Arial, sans-serif;
}

a{
    color:inherit;
}

/* Layout */
.content{
    width:100%;
    min-height:100vh;
    max-width:430px;
    margin:0 auto;
    background:var(--bg);
    padding:22px 18px 105px;
}

@media(min-width:768px){
    .content{
        max-width:720px;
        min-height:calc(100vh - 64px);
        margin:32px auto;
        border-radius:32px;
        padding:32px 40px 120px;
    }
}

@media(min-width:1100px){
    .content{
        max-width:920px;
    }
}

@media(max-width:480px){
    body{
        background:var(--bg);
    }

    .content{
        max-width:none;
        margin:0;
        border-radius:0;
    }
}

/* Header */
.page-header{
    display:flex;
    justify-content:space-between;
    align-items:center;
    gap:16px;
    margin-bottom:24px;
}

.eyebrow{
    color:var(--muted);
    font-size:13px;
    margin-bottom:8px;
}

h1{
    font-size:30px;
    line-height:1.1;
}

h2{
    font-size:20px;
}

.back-button{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    gap:8px;

    width:auto;
    min-width:42px;
    height:42px;
    padding:0 14px;

    border:none;
    border-radius:999px;
    background:var(--surface-soft);
    color:var(--text);

    font-size:14px;
    font-weight:700;
    text-decoration:none;

    margin-bottom:18px;
    cursor:pointer;
}

.back-button:hover{
    background:var(--surface-hover);
}

@media(max-width:520px){
    .back-button{
        height:40px;
        padding:0 12px;
        font-size:13px;
    }
}

/* Cards */
.card{
    background:var(--surface);
    border:1px solid var(--border);
    color:var(--text);
    border-radius:24px;
    padding:18px;
    margin-top:16px;
}

.card p,
.muted{
    color:var(--muted);
}

.btn-primary{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    min-width:44px;
    min-height:44px;
    padding:12px 18px;
    border:none;
    border-radius:16px;
    background:var(--accent);
    color:white;
    text-decoration:none;
    font-weight:800;
    cursor:pointer;
}

.btn-primary:hover{
    background:var(--accent-hover);
}

.btn-primary.large{
    min-height:52px;
}

.full-width{
    width:100%;
}

.btn-small{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    padding:9px 12px;
    border-radius:999px;
    background:var(--surface-soft);
    color:white;
    border:1px solid var(--border);
    text-decoration:none;
    font-size:13px;
    font-weight:700;
    white-space:nowrap;
}

.btn-danger{
    background:rgba(239,68,68,0.14);
    color:#fca5a5;
    border:1px solid rgba(239,68,68,0.35);
}

.btn-danger:hover{
    background:rgba(239,68,68,0.22);
}

.btn-secondary{
    background:#374151;
}

/* Programs */
.program-list{
    display:grid;
    grid-template-columns:1fr;
    gap:14px;
}

@media(min-width:768px){
    .program-list{
        grid-template-columns:repeat(2, 1fr);
    }
}

.program-card{
    display:flex;
    align-items:center;
    gap:14px;
    width:100%;
    min-height:96px;
    padding:16px;
    border-radius:24px;
    background:var(--surface);
    border:1px solid var(--border);
    color:var(--text);
    text-decoration:none;
}

.program-card:hover{
    background:var(--surface-hover);
}

.program-icon{
    width:48px;
    height:48px;
    border-radius:18px;
    background:var(--accent);
    flex-shrink:0;
}

.program-info{
    flex:1;
    min-width:0;
}

.program-info h2{
    font-size:18px;
    margin-bottom:4px;
    color:var(--text);
}

.program-info p{
    color:var(--muted);
    font-size:14px;
    margin-bottom:8px;
}

.program-status{
    display:inline-flex;
    padding:5px 10px;
    border-radius:999px;
    background:var(--surface-soft);
    color:var(--muted);
    font-size:12px;
}

.program-status.active{
    background:var(--accent-soft);
    color:#93c5fd;
}

/* Workouts / exercises */
.workout-header{
    display:flex;
    justify-content:space-between;
    align-items:flex-start;
    gap:12px;
}

.exercise-list{
    margin-top:14px;
    display:flex;
    flex-direction:column;
    gap:12px;
}

.exercise-block{
    background:var(--surface-soft);
    border:1px solid var(--border);
    border-radius:20px;
    padding:12px;
}

.exercise-row{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:16px;
}

.exercise-title{
    display:flex;
    align-items:center;
    gap:12px;
    flex:1;
}

.exercise-title strong{
    display:block;
    text-align:left;
}

.exercise-title small{
    display:block;
    text-align:left;
}

.exercise-row small{
    display:block;
    color:var(--muted);
    margin-top:4px;
}

/* Sets */
.set-list{
    margin-top:10px;
    display:flex;
    flex-direction:column;
    gap:8px;
}

.set-row{
    display:flex;
    justify-content:space-between;
    align-items:center;
    gap:10px;
    background:var(--bg);
    border:1px solid var(--border);
    border-radius:16px;
    padding:12px;
}

.set-row p{
    margin-top:4px;
    font-size:13px;
    color:var(--muted);
}

.set-actions{
    display:flex;
    align-items:center;
    gap:6px;
    flex-shrink:0;
}

.icon-btn{
    border:none;
    background:var(--surface-soft);
    color:var(--text);
    min-width:32px;
    min-height:32px;
    border-radius:50%;
    text-decoration:none;
    display:flex;
    align-items:center;
    justify-content:center;
    cursor:pointer;
}

.icon-btn.danger{
    background:var(--danger-soft);
    color:#fca5a5;
}

/* Forms */
.form-group{
    margin-bottom:18px;
}

.form-group label{
    display:block;
    margin-bottom:8px;
    color:var(--muted);
    font-size:14px;
}

.form-control{
    width:100%;
    min-height:50px;
    border-radius:16px;
    border:1px solid var(--border);
    background:var(--surface-soft);
    color:var(--text);
    padding:14px;
    font-size:16px;
}

.form-control:focus{
    outline:2px solid var(--accent);
}

.form-control option{
    background:#fff;
    color:#111;
}

.textarea{
    min-height:110px;
    resize:vertical;
}

/* Flash */
.flash-error{
    background:var(--danger-soft);
    color:#fca5a5;
    padding:12px;
    border-radius:14px;
    margin-bottom:16px;
}

/* Bottom nav */
.bottom-nav{
    position:fixed;
    bottom:14px;
    left:50%;
    transform:translateX(-50%);
    width:calc(100% - 28px);
    max-width:400px;
    height:64px;
    background:var(--surface);
    border:1px solid var(--border);
    border-radius:24px;
    display:flex;
    justify-content:space-around;
    align-items:center;
    box-shadow:0 16px 40px rgba(0,0,0,0.35);
    z-index:100;
}

.bottom-nav a{
    color:var(--text);
    text-decoration:none;
    font-size:13px;
    font-weight:700;
}

@media(min-width:768px){
    .bottom-nav{
        max-width:420px;
    }
}

.icon-btn svg{
    width:16px;
    height:16px;
    stroke:currentColor;
    stroke-width:2;
    fill:none;
    stroke-linecap:round;
    stroke-linejoin:round;
}

.icon-btn.edit{
    color:#93c5fd;
}

.icon-btn.delete{
    color:#fca5a5;
}

.icon-btn.move{
    color:#c4b5fd;
}

.exercise-block{
    background:var(--surface-soft);
    border:1px solid var(--border);
    border-radius:20px;
    padding:8px;
}

.exercise-block summary{
    list-style:none;
    cursor:pointer;
}

.exercise-block summary::-webkit-details-marker{
    display:none;
}

.exercise-row::before{
    content:"▾";
    color:var(--muted);
    margin-right:8px;
}

.exercise-block:not([open]) .exercise-row::before{
    content:"▸";
}

.exercise-block:not([open]) .set-list,
.exercise-block:not([open]) .muted{
    display:none;
}

.workout-list{
    display:flex;
    flex-direction:column;
    gap:16px;
}

.workout-card{
    width:100%;
}

.exercise-row{
    list-style:none;
}

.exercise-row::-webkit-details-marker{
    display:none;
}



@media(max-width:520px){
    .workout-header,
    .exercise-row,
    .set-row{
        align-items:flex-start;
    }

    .set-actions{
        flex-wrap:wrap;
        justify-content:flex-end;
    }
}

.set-actions{
    display:flex;
    gap:4px;
}

.icon-btn{
    width:32px;
    height:32px;
}

.btn-small{
    padding:8px 10px;
    font-size:12px;
}

.program-actions{
    margin-top:16px;
}

.week-grid{
    margin-top:16px;
    display:grid;
    grid-template-columns:1fr;
    gap:12px;
}

.day-card{
    background:var(--surface);
    border:1px solid var(--border);
    border-radius:20px;
    padding:16px;
}

.day-card span{
    display:block;
    color:var(--muted);
    font-size:13px;
    margin-bottom:8px;
}

.day-card p{
    color:var(--muted);
}

.day-card strong{
    display:block;
    color:var(--text);
}

@media(min-width:768px){
    .week-grid{
        grid-template-columns:repeat(7, 1fr);
    }

    .day-card{
        min-height:110px;
    }
}

.calendar-header{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:16px;
    margin-bottom:20px;
}

.calendar-grid{
    display:grid;
    grid-template-columns:repeat(7, 1fr);
    gap:8px;
    margin-top:12px;
}

.calendar-week-labels{
    color:var(--muted);
    font-size:12px;
    text-align:center;
}

.calendar-day{
    min-height:96px;
    background:var(--surface);
    border:1px solid var(--border);
    border-radius:16px;
    padding:8px;
}

.calendar-day.outside-month{
    opacity:0.35;
}

.calendar-day-number{
    color:var(--muted);
    font-size:13px;
    margin-bottom:8px;
}

.calendar-workout{
    background:var(--accent-soft);
    color:#99f6e4;
    border-radius:10px;
    padding:6px;
    font-size:12px;
    font-weight:700;
    margin-top:6px;
}

@media(max-width:520px){
    .calendar-grid{
        gap:5px;
    }

    .calendar-day{
        min-height:78px;
        border-radius:12px;
        padding:6px;
    }

    .calendar-workout{
        font-size:10px;
        padding:5px;
    }
}

.calendar-workout{
    display:block;
    text-decoration:none;
}

.checkbox-line{
    display:flex;
    align-items:center;
    gap:10px;
}

.checkbox-line{
    display:flex;
    align-items:center;
    gap:10px;
}

.checkbox-line label{
    margin:0;
}

.checkbox-line input{
    width:18px;
    height:18px;
    accent-color:var(--accent);
}

.set-row.completed{
    border-color:rgba(20,184,166,0.45);
    background:rgba(20,184,166,0.08);
}

.set-row p + p{
    margin-top:2px;
}

.calendar-workout{
    display:block;
    text-decoration:none;
    background:var(--surface-soft);
    color:var(--text);
    border-radius:10px;
    padding:6px;
    font-size:12px;
    font-weight:700;
    margin-top:6px;
    border:1px solid var(--border);
}

.calendar-workout span,
.calendar-workout small{
    display:block;
}

.calendar-workout small{
    margin-top:3px;
    color:var(--muted);
    font-size:10px;
}

.calendar-workout.planned{
    border-color:rgba(255,255,255,0.08);
}

.calendar-workout.started{
    border-color:rgba(251,191,36,0.45);
    background:rgba(251,191,36,0.08);
}

.calendar-workout.completed{
    border-color:rgba(20,184,166,0.45);
    background:rgba(20,184,166,0.08);
}

.set-footer-actions{
    display:flex;
    gap:8px;
    flex-wrap:wrap;
    margin-top:10px;
}

.card-link{
    display:block;
    text-decoration:none;
}

.card-link:hover{
    background:var(--surface-hover);
}

.month-nav-btn{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    min-height:40px;
    padding:0 14px;
    border-radius:999px;
    background:var(--surface-soft);
    border:1px solid var(--border);
    color:var(--text);
    text-decoration:none;
    font-size:13px;
    font-weight:700;
}

.month-nav-btn:hover{
    background:var(--surface-hover);
}

@media(max-width:520px){
    .month-nav-btn{
        width:40px;
        height:40px;
        padding:0;
        font-size:0;
    }

    .month-nav-btn:first-child::before{
        content:"←";
        font-size:18px;
    }

    .month-nav-btn:last-child::before{
        content:"→";
        font-size:18px;
    }
}

.session-actions{
    display:flex;
    gap:8px;
    flex-wrap:wrap;
    margin-top:16px;
}
