*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
    --bg:        #0F0F0F;
    --bg-card:   #1A1A1A;
    --bg-input:  #242424;
    --bg-hover:  #2A2A2A;
    --border:    #2E2E2E;
    --border-hi: #3E3E3E;
    --txt:       #F0F0F0;
    --txt2:      #999;
    --txt3:      #555;
    --blue:      #4A9EFF;
    --green:     #34D399;
    --green-dk:  #059669;
    --yellow:    #FBBF24;
    --red:       #F87171;
    --radius:    12px;
    --radius-sm: 8px;
}

body {
    background: var(--bg);
    color: var(--txt);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
    font-size: 17px;
    line-height: 1.5;
    min-height: 100vh;
    padding-bottom: 80px;
}

/* ── Top bar ─────────────────────────────────────────────────────────────── */
.topbar {
    background: #141414;
    border-bottom: 1px solid var(--border);
    padding: 18px 16px 16px;
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar-title {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.4px;
    margin-bottom: 14px;
    color: var(--txt);
    text-align: center;
}
.topbar-controls { display: flex; flex-direction: column; gap: 10px; }

input[type="date"], select {
    width: 100%;
    height: 50px;
    padding: 0 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--txt);
    font-size: 17px;
    font-family: inherit;
    appearance: none;
    -webkit-appearance: none;
}
input[type="date"]:focus, select:focus { outline: none; border-color: var(--blue); }

#load-btn {
    width: 100%;
    height: 50px;
    border-radius: var(--radius-sm);
    border: none;
    background: var(--blue);
    color: #fff;
    font-size: 17px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: opacity .15s;
}
#load-btn:disabled { opacity: 0.5; cursor: not-allowed; }
#load-btn:active { opacity: 0.8; }

/* ── Status banner ───────────────────────────────────────────────────────── */
.status-banner {
    margin: 12px 16px 0;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 500;
}
.status-banner.info    { background: #1A2A3A; color: var(--blue);  border: 1px solid #2A4A6A; }
.status-banner.success { background: #0D2A1E; color: var(--green); border: 1px solid #1A4A32; }
.status-banner.error   { background: #2A1A1A; color: var(--red);   border: 1px solid #4A2A2A; }
.status-banner.hidden  { display: none; }

/* ── Workout container ───────────────────────────────────────────────────── */
#workout-container { padding: 14px 16px 0; }
.hidden { display: none !important; }

/* ── Section label ───────────────────────────────────────────────────────── */
.section-label {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--txt3);
    margin: 22px 0 10px 2px;
}
.section-label:first-child { margin-top: 4px; }

/* ── Exercise card ───────────────────────────────────────────────────────── */
.ex-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 12px;
    overflow: hidden;
}
.ex-card-header {
    padding: 14px 16px 12px;
    border-bottom: 1px solid var(--border);
}
.ex-name-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}
.ex-name {
    font-size: 17px;
    font-weight: 700;
    color: var(--txt);
    flex: 1;
    line-height: 1.3;
}
.ex-badge {
    font-size: 12px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    flex-shrink: 0;
    white-space: nowrap;
}
.badge-push     { background: #1A2A4A; color: #7EB8FF; }
.badge-pull     { background: #0D2A20; color: #6EE7B7; }
.badge-legs     { background: #2A2010; color: #FCD34D; }
.badge-finisher { background: #2A1F0A; color: var(--yellow); }
.badge-arms     { background: #2A1A2A; color: #D8B4FE; }
.ex-notes {
    font-size: 14px;
    color: var(--txt2);
    line-height: 1.6;
}

/* ── Set rows ────────────────────────────────────────────────────────────── */
.sets-body { padding: 8px 16px 14px; }
.set-row {
    display: grid;
    grid-template-columns: 40px 1fr 1fr 1fr auto;
    align-items: center;
    gap: 8px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.set-row:last-of-type { border-bottom: none; }
.set-num {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--bg-input);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: var(--txt2);
}
.input-wrap { display: flex; flex-direction: column; gap: 3px; }
.input-wrap label {
    font-size: 11px;
    font-weight: 600;
    color: var(--txt3);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding-left: 2px;
}
.input-wrap input {
    width: 100%;
    height: 44px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--txt);
    font-size: 18px;
    font-weight: 600;
    text-align: center;
    font-family: inherit;
    padding: 0 4px;
}
.input-wrap input:focus { border-color: var(--blue); outline: none; }
.input-wrap input::placeholder { color: var(--txt3); font-size: 14px; font-weight: 400; }
.rest-btn {
    height: 44px;
    padding: 0 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--txt2);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 4px;
}
.rest-btn:active { background: var(--bg-hover); }

/* ── Finisher card ───────────────────────────────────────────────────────── */
.fin-card {
    background: var(--bg-card);
    border: 1.5px dashed #3A2E10;
    border-radius: var(--radius);
    margin-bottom: 12px;
    overflow: hidden;
}
.fin-card-header {
    padding: 14px 16px 12px;
    border-bottom: 1px solid #2A2010;
}
.fin-blocks { padding: 10px 16px 4px; display: flex; flex-direction: column; gap: 8px; }
.fin-block {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    transition: background .12s, border-color .12s;
    user-select: none;
}
.fin-block.active {
    border-color: var(--yellow);
    background: #2A2010;
}
.fin-block.done {
    background: #0A2018;
    border-color: #1A4030;
}
.fin-check {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 2px solid var(--border-hi);
    background: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: transparent;
    flex-shrink: 0;
    transition: all .15s;
}
.fin-block.done .fin-check { background: var(--green); border-color: var(--green); color: #0A2018; }
.fin-info { flex: 1; min-width: 0; }
.fin-block-num  { font-size: 12px; font-weight: 700; color: var(--txt3); display: block; }
.fin-block-text { font-size: 15px; color: var(--txt); display: block; line-height: 1.4; }
.fin-dur {
    font-size: 15px;
    font-weight: 700;
    color: var(--txt2);
    flex-shrink: 0;
    min-width: 40px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.fin-block.active .fin-dur { color: var(--yellow); font-size: 18px; }
.fin-block.done  .fin-dur  { color: var(--green); }

/* ── Finisher block inputs ───────────────────────────────────────────────── */
.fin-block-inputs {
    display: flex;
    gap: 6px;
    margin-left: auto;
    margin-right: 10px;
}
.fin-input-wrap {
    display: flex;
    flex-direction: column;
    gap: 2px;
    align-items: center;
}
.fin-input-wrap label {
    font-size: 10px;
    font-weight: 600;
    color: var(--txt3);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.fin-input-wrap input {
    width: 54px;
    height: 36px;
    border-radius: 7px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--txt);
    font-size: 15px;
    font-weight: 600;
    text-align: center;
    font-family: inherit;
    padding: 0;
}
.fin-input-wrap input:focus { border-color: var(--blue); outline: none; }
.fin-block.active .fin-input-wrap input { border-color: var(--yellow); }
.fin-block.done  .fin-input-wrap input { border-color: var(--green-dk); }

/* ── Finisher footer ─────────────────────────────────────────────────────── */
.fin-footer {
    display: flex;
    gap: 8px;
    padding: 10px 16px 14px;
}
.fin-footer button {
    height: 46px;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: opacity .15s;
    border: none;
}
.fin-footer button:active { opacity: 0.8; }
.fin-start-btn  { flex: 1; background: var(--yellow); color: #111; }
.fin-pause-btn  { flex: 1; background: var(--bg-input); color: var(--yellow); border: 1px solid var(--yellow) !important; }
.fin-resume-btn { flex: 1; background: var(--yellow); color: #111; }
.fin-restart-btn{ padding: 0 16px; background: var(--bg-input); color: var(--txt2); border: 1px solid var(--border-hi) !important; }

/* ── Save button ─────────────────────────────────────────────────────────── */
.save-btn {
    width: 100%;
    height: 56px;
    margin-top: 18px;
    border-radius: var(--radius);
    border: none;
    background: var(--green-dk);
    color: #fff;
    font-size: 18px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: background .2s, opacity .15s;
}
.save-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.save-btn.saved { background: #065F46; }

/* ── Rest timer (floating bottom) ────────────────────────────────────────── */
.rest-timer {
    position: fixed;
    bottom: 20px;
    left: 16px;
    right: 16px;
    background: #141E2E;
    border: 1px solid #2A4A6A;
    border-radius: var(--radius);
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    z-index: 100;
    box-shadow: 0 8px 32px rgba(0,0,0,0.7);
}
.rt-left { display: flex; align-items: baseline; gap: 10px; flex-shrink: 0; }
.rt-label { font-size: 14px; color: var(--txt2); font-weight: 600; }
#rt-display {
    font-size: 30px;
    font-weight: 700;
    color: var(--blue);
    font-variant-numeric: tabular-nums;
    min-width: 72px;
}
#rt-display.done { color: var(--green); }
.rt-bar-wrap { flex: 1; height: 5px; background: var(--border); border-radius: 3px; }
.rt-bar { height: 5px; background: var(--blue); border-radius: 3px; width: 100%; transition: width 1s linear, background .3s; }
.rt-bar.done { background: var(--green); }
.rt-dismiss {
    background: none;
    border: 1px solid var(--border-hi);
    border-radius: 7px;
    color: var(--txt2);
    font-size: 16px;
    width: 36px;
    height: 36px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-family: inherit;
}
