/* Training App v2 — Dark Theme */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #1C1C1E;
  --bg2: #2C2C2E;
  --bg3: #3A3A3C;
  --blue: #4A9EFF;
  --green: #30D158;
  --orange: #FF9F0A;
  --red: #FF453A;
  --text: #FFFFFF;
  --text2: #EBEBF5CC;
  --text3: #EBEBF560;
  --border: #38383A;
}

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif; }

/* Login */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-container { width: 100%; max-width: 360px; padding: 40px 24px; text-align: center; }
.app-logo { display: flex; justify-content: center; margin-bottom: 24px; }
.login-title { font-size: 28px; font-weight: 700; margin-bottom: 8px; }
.login-subtitle { color: var(--text3); font-size: 15px; margin-bottom: 32px; }
.error-msg { background: rgba(255,69,58,0.15); border: 1px solid var(--red); color: var(--red); padding: 12px 16px; border-radius: 10px; font-size: 14px; margin-bottom: 20px; }

.pin-display { display: flex; gap: 20px; justify-content: center; margin-bottom: 32px; }
.pin-dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--bg3); transition: all 0.15s; }
.pin-dot.filled { background: var(--blue); border-color: var(--blue); }

.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 280px; margin: 0 auto; }
.pin-btn { height: 72px; background: var(--bg2); border: none; border-radius: 50%; color: var(--text); font-size: 24px; font-weight: 400; cursor: pointer; transition: background 0.1s; }
.pin-btn:active { background: var(--bg3); }
.pin-btn--empty { background: transparent; cursor: default; }
.pin-btn--delete { font-size: 20px; }

/* App shell */
.screen { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

.app-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.header-title { font-size: 20px; font-weight: 700; }
.header-action { color: var(--blue); font-size: 14px; text-decoration: none; }

.workout-header { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--bg2); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.header-back { color: var(--text3); font-size: 18px; text-decoration: none; padding: 4px; }
.header-center { flex: 1; text-align: center; }
.workout-title { font-size: 16px; font-weight: 700; }
.workout-timer { color: var(--blue); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 2px; }

.main-content { flex: 1; overflow-y: auto; padding: 16px; padding-bottom: 80px; }
.workout-content { flex: 1; overflow-y: auto; padding: 12px 16px; }

/* Bottom nav */
.bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--bg2); border-top: 1px solid var(--border); z-index: 100; }
.nav-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 8px; text-decoration: none; color: var(--text3); font-size: 11px; transition: color 0.15s; }
.nav-item--active { color: var(--blue); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; padding: 12px 20px; border-radius: 10px; font-size: 15px; font-weight: 600; border: none; cursor: pointer; transition: opacity 0.15s; }
.btn:active { opacity: 0.7; }
.btn--primary { background: var(--blue); color: #fff; }
.btn--finish { background: var(--green); color: #fff; padding: 8px 16px; font-size: 14px; border-radius: 8px; }
.btn--ghost { background: transparent; color: var(--blue); border: 1px solid var(--blue); }
.btn--sm { font-size: 13px; padding: 8px 14px; }
.btn--full { width: 100%; margin-top: 16px; }

/* Template cards */
.template-card { background: var(--bg2); border-radius: 14px; padding: 16px; margin-bottom: 12px; }
.template-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 6px; }
.template-name { font-size: 17px; font-weight: 700; }
.last-performed { font-size: 12px; color: var(--text3); white-space: nowrap; }
.last-performed.never { color: var(--text3); }
.template-notes { font-size: 13px; color: var(--text2); margin-bottom: 12px; }

.exercise-preview { margin-bottom: 4px; }
.exercise-preview-item { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid var(--border); }
.exercise-preview-item:last-child { border-bottom: none; }
.exercise-preview-item.more { color: var(--text3); font-size: 13px; justify-content: flex-start; }
.ex-preview-name { font-size: 14px; color: var(--blue); }
.ex-preview-sets { font-size: 13px; color: var(--text3); }

/* Workout / Exercise sections */
.exercise-section { background: var(--bg2); border-radius: 14px; padding: 14px; margin-bottom: 14px; }
.exercise-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.exercise-name { font-size: 16px; font-weight: 700; color: var(--blue); }
.prev-best { font-size: 11px; color: var(--text3); }

/* Sets table */
.sets-table { width: 100%; border-collapse: collapse; margin-bottom: 8px; }
.sets-table th { font-size: 10px; font-weight: 600; color: var(--text3); text-align: center; padding: 4px 2px; letter-spacing: 0.05em; }
.sets-table th:first-child { text-align: left; }
.set-row td { padding: 6px 2px; border-bottom: 1px solid var(--border); }
.set-row:last-child td { border-bottom: none; }
.set-row--done { opacity: 0.6; }
.set-row--done .input-weight, .set-row--done .input-reps { color: var(--text3); }

.set-num { font-size: 13px; font-weight: 600; color: var(--text3); width: 28px; }
.set-num.warmup { color: var(--orange); }
.set-prev { font-size: 12px; color: var(--text3); text-align: center; white-space: nowrap; }
.set-input { text-align: center; }
.input-weight, .input-reps { width: 52px; background: var(--bg3); border: 1px solid var(--border); border-radius: 6px; color: var(--text); text-align: center; padding: 6px 4px; font-size: 15px; font-weight: 600; -moz-appearance: textfield; }
.input-weight::-webkit-outer-spin-button, .input-weight::-webkit-inner-spin-button,
.input-reps::-webkit-outer-spin-button, .input-reps::-webkit-inner-spin-button { -webkit-appearance: none; }
.input-error { border-color: var(--red) !important; }
.set-check { text-align: center; }
.check-btn { background: var(--bg3); border: 1px solid var(--border); border-radius: 6px; color: var(--text3); padding: 6px 10px; font-size: 15px; cursor: pointer; transition: all 0.15s; }
.check-btn--done { background: var(--green); border-color: var(--green); color: #fff; }

.add-set-form { text-align: right; }

/* History */
.month-section { margin-bottom: 24px; }
.month-label { font-size: 13px; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 10px; padding: 0 2px; }
.history-card { background: var(--bg2); border-radius: 14px; padding: 14px; margin-bottom: 10px; cursor: pointer; }
.history-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.history-name { display: block; font-size: 16px; font-weight: 700; }
.history-date { display: block; font-size: 12px; color: var(--text3); margin-top: 2px; }
.pr-badge { background: rgba(255,159,10,0.15); color: var(--orange); border: 1px solid var(--orange); padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.history-stats { display: flex; gap: 16px; }
.stat { display: flex; align-items: center; gap: 4px; font-size: 13px; color: var(--text3); }
.history-detail { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.history-ex-row { display: flex; justify-content: space-between; padding: 4px 0; }
.history-ex-name { font-size: 13px; color: var(--blue); }
.history-ex-best { font-size: 13px; color: var(--text3); }

/* Empty state */
.empty-state { text-align: center; padding: 60px 20px; }
.empty-title { font-size: 18px; font-weight: 600; margin-top: 16px; margin-bottom: 8px; }
.empty-sub { font-size: 14px; color: var(--text3); }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.7); display: flex; align-items: center; justify-content: center; z-index: 200; padding: 24px; }
.modal { background: var(--bg2); border-radius: 16px; padding: 24px; width: 100%; max-width: 320px; }
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 10px; }
.modal-body { font-size: 14px; color: var(--text2); margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; }
