:root {
    --bg: #0D0D0D;
    --bg-secondary: #161616;
    --bg-card: #1C1C1C;
    --bg-input: #242424;
    --bg-hover: #2A2A2A;
    --text: #FFFFFF;
    --text-secondary: #999999;
    --text-muted: #5A5A5A;
    --accent: #FA8072;
    --accent-dim: rgba(250, 128, 114, 0.12);
    --accent-hover: #FF9589;
    --border: #2A2A2A;
    --danger: #E5534B;
    --danger-dim: rgba(229, 83, 75, 0.12);
    --success: #57AB5A;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --radius: 12px;
    --radius-sm: 8px;
    --nav-height: 64px;
}

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

html, body {
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    overflow: hidden;
}

#app {
    height: 100%;
    display: flex;
    flex-direction: column;
}

input, select, textarea, button {
    font-family: var(--font);
    font-size: 15px;
    outline: none;
    border: none;
    background: none;
    color: var(--text);
}

input[type="number"] { -moz-appearance: textfield; }
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button { -webkit-appearance: none; }

.view {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px calc(var(--nav-height) + 20px);
    display: none;
    -webkit-overflow-scrolling: touch;
}

.view.active { display: block; }
.view::-webkit-scrollbar { display: none; }

.header { margin-bottom: 24px; }
.header h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.5px; }
.header p { color: var(--text-secondary); font-size: 14px; margin-top: 4px; }

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
}

.card-clickable { cursor: pointer; transition: background 0.15s; }
.card-clickable:active { background: var(--bg-hover); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.15s;
    width: 100%;
}

.btn-primary { background: var(--accent); color: #0D0D0D; }
.btn-primary:active { background: var(--accent-hover); }
.btn-secondary { background: var(--accent-dim); color: var(--accent); }
.btn-secondary:active { background: rgba(250, 128, 114, 0.2); }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px dashed var(--border); }
.btn-ghost:active { background: var(--bg-hover); }
.btn-danger { background: var(--danger-dim); color: var(--danger); }
.btn-danger:active { background: rgba(229, 83, 75, 0.2); }
.btn-sm { padding: 8px 14px; font-size: 13px; }

.input-group { margin-bottom: 14px; }
.input-group label {
    display: block; font-size: 12px; font-weight: 600;
    color: var(--text-secondary); text-transform: uppercase;
    letter-spacing: 0.5px; margin-bottom: 6px;
}
.input-group input, .input-group select {
    width: 100%; padding: 10px 12px;
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text);
}
.input-group input::placeholder { color: var(--text-muted); }
.input-row { display: flex; gap: 10px; }
.input-row .input-group { flex: 1; }

.set-row {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 0; border-bottom: 1px solid var(--border);
}
.set-row:last-child { border-bottom: none; }

.set-number {
    width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    background: var(--accent-dim); color: var(--accent);
    border-radius: 50%; font-size: 12px; font-weight: 700; flex-shrink: 0;
}

.set-input {
    flex: 1; padding: 8px 10px;
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text);
    text-align: center; font-size: 15px; font-weight: 600;
}
.set-input::placeholder { color: var(--text-muted); font-weight: 400; }
.set-unit { font-size: 11px; color: var(--text-muted); flex-shrink: 0; width: 24px; }

.btn-icon {
    width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted); cursor: pointer; border-radius: 50%;
    flex-shrink: 0; transition: all 0.15s;
}
.btn-icon:active { background: var(--danger-dim); color: var(--danger); }
.btn-icon.accent:active { background: var(--accent-dim); color: var(--accent); }

.exercise-block {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); margin-bottom: 16px; overflow: hidden;
}
.exercise-block-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.exercise-block-header h3 { font-size: 16px; font-weight: 600; }
.exercise-block-body { padding: 4px 16px 12px; }
.exercise-block-footer { padding: 0 16px 12px; }

.cardio-row { display: flex; gap: 10px; flex-wrap: wrap; }
.cardio-field { flex: 1; min-width: 80px; }
.cardio-field label { display: block; font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.cardio-field input {
    width: 100%; padding: 8px 10px;
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text); font-size: 14px;
}

.workout-card { display: flex; align-items: center; gap: 12px; }
.workout-card-info { flex: 1; min-width: 0; }
.workout-card-date { font-size: 13px; color: var(--accent); font-weight: 600; }
.workout-card-title { font-size: 16px; font-weight: 600; margin: 2px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.workout-card-meta { font-size: 13px; color: var(--text-secondary); }

.stat-row { display: flex; gap: 12px; margin-bottom: 20px; }
.stat-card {
    flex: 1; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 14px; text-align: center;
}
.stat-value { font-size: 28px; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 2px; }

.chart-container { position: relative; height: 200px; margin: 16px 0; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty-state svg { width: 48px; height: 48px; margin-bottom: 12px; opacity: 0.3; }
.empty-state p { font-size: 14px; }

#bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0;
    height: var(--nav-height); background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-around;
    padding: 0 8px; z-index: 100;
}

.nav-btn {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 8px 12px; color: var(--text-muted); cursor: pointer;
    transition: color 0.15s; background: none; border: none;
}
.nav-btn svg { width: 22px; height: 22px; }
.nav-btn span { font-size: 10px; font-weight: 600; }
.nav-btn.active { color: var(--accent); }

.nav-btn-primary {
    width: 48px; height: 48px;
    background: var(--accent); color: #0D0D0D !important;
    border-radius: 50%; padding: 0; margin-top: -16px;
    box-shadow: 0 4px 16px rgba(250, 128, 114, 0.3);
}
.nav-btn-primary svg { width: 24px; height: 24px; }
.nav-btn-primary span { display: none; }
.nav-btn-primary:active { transform: scale(0.92); }

.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.6);
    z-index: 200; transition: opacity 0.2s;
}
.modal {
    position: fixed; bottom: 0; left: 0; right: 0; max-height: 80vh;
    background: var(--bg-secondary); border-top-left-radius: 20px;
    border-top-right-radius: 20px; z-index: 201;
    overflow-y: auto; padding: 20px;
    transform: translateY(100%); transition: transform 0.25s ease;
}
.modal.visible { transform: translateY(0); }
.modal.hidden { display: none; }
.modal-overlay.hidden { opacity: 0; pointer-events: none; }
.modal-handle { width: 36px; height: 4px; background: var(--text-muted); border-radius: 2px; margin: 0 auto 16px; }
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 12px; }
.modal-search {
    width: 100%; padding: 10px 12px;
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text); margin-bottom: 12px;
}
.modal-search::placeholder { color: var(--text-muted); }

.exercise-picker-item { padding: 12px; border-radius: var(--radius-sm); cursor: pointer; transition: background 0.1s; }
.exercise-picker-item:active { background: var(--accent-dim); }
.exercise-picker-item .name { font-weight: 500; }
.exercise-group-label { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; padding: 8px 12px 4px; }

.back-btn {
    display: flex; align-items: center; gap: 6px;
    color: var(--accent); font-weight: 600; font-size: 14px;
    cursor: pointer; padding: 4px 0; margin-bottom: 12px; background: none; border: none;
}
.back-btn svg { width: 18px; height: 18px; }

.section-title { font-size: 14px; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; margin: 20px 0 10px; }

.pr-list-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.pr-list-item:last-child { border-bottom: none; }

.session-entry { padding: 12px; border-radius: var(--radius-sm); background: var(--bg-secondary); margin-bottom: 8px; }
.session-entry .date { font-size: 13px; color: var(--accent); font-weight: 600; }
.session-entry .sets-summary { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }

.timer-bar {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 14px 16px; margin-bottom: 20px;
}
.timer-display { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: 1px; }
.timer-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.timer-dot { display: inline-block; width: 8px; height: 8px; background: var(--accent); border-radius: 50%; margin-right: 6px; animation: pulse 1.5s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

.workout-detail-exercise { margin-bottom: 20px; }
.workout-detail-exercise h3 { font-size: 16px; font-weight: 600; color: var(--accent); margin-bottom: 8px; }
.workout-detail-set { display: flex; justify-content: space-between; padding: 6px 0; font-size: 14px; color: var(--text-secondary); }
.workout-detail-set span:first-child { color: var(--text-muted); }

.cardio-detail { padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.cardio-detail:last-child { border-bottom: none; }

.active-banner {
    background: var(--accent-dim); border: 1px solid rgba(250, 128, 114, 0.2);
    border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px;
    display: flex; align-items: center; justify-content: space-between; cursor: pointer;
}
.active-banner:active { background: rgba(250, 128, 114, 0.18); }
.active-banner-text { font-weight: 600; font-size: 14px; color: var(--accent); }
.active-banner-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.top-exercise-item { display: flex; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.top-exercise-item:last-child { border-bottom: none; }
.top-exercise-rank { width: 24px; font-size: 14px; font-weight: 700; color: var(--accent); }
.top-exercise-name { flex: 1; font-weight: 500; }
.top-exercise-vol { font-size: 13px; color: var(--text-muted); }

.chart-toggle {
    flex: 1; padding: 8px 4px; font-size: 12px; font-weight: 600;
    background: var(--bg-input); color: var(--text-muted);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    cursor: pointer; transition: all 0.15s; width: auto;
}
.chart-toggle.active {
    background: var(--accent-dim); color: var(--accent);
    border-color: rgba(250, 128, 114, 0.3);
}
