/* =========================================
   RESET & VARIABLES
   ========================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d0d0d;
  --bg2: #161616;
  --bg3: #1e1e1e;
  --bg4: #252525;
  --border: #2a2a2a;
  --border2: #333;
  --accent: #e8a020;
  --accent-dim: rgba(232,160,32,0.15);
  --accent-dim2: rgba(232,160,32,0.08);
  --text: #f0f0f0;
  --text2: #a0a0a0;
  --text3: #666;
  --success: #4caf50;
  --success-dim: rgba(76,175,80,0.15);
  --danger: #e53935;
  --danger-dim: rgba(229,57,53,0.15);
  --radius: 12px;
  --radius-sm: 8px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --header-h: 56px;
  --nav-h: 60px;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* =========================================
   LOADING SCREEN
   ========================================= */
.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  height: 100dvh;
  gap: 24px;
}

.loading-logo {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--accent);
  text-transform: uppercase;
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* =========================================
   APP LAYOUT
   ========================================= */
#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

.view {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* =========================================
   HEADER
   ========================================= */
.header {
  display: flex;
  align-items: center;
  padding: 0 16px;
  padding-top: var(--safe-top);
  height: calc(var(--header-h) + var(--safe-top));
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-back {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 24px;
  cursor: pointer;
  padding: 8px;
  margin: -8px -4px -8px -8px;
  border-radius: 8px;
  min-width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.header-back:active { background: var(--bg4); }

.header-title {
  flex: 1;
  font-size: 18px;
  font-weight: 700;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.header-logo {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.header-action {
  background: none;
  border: none;
  color: var(--text2);
  font-size: 22px;
  cursor: pointer;
  padding: 8px;
  margin: -8px -8px -8px 0;
  border-radius: 8px;
  min-width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

.header-action:active { background: var(--bg4); }

/* =========================================
   BOTTOM NAV
   ========================================= */
.bottom-nav {
  display: flex;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
  flex-shrink: 0;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 0;
  min-height: var(--nav-h);
  background: none;
  border: none;
  color: var(--text3);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  gap: 4px;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s;
}

.nav-item.active { color: var(--accent); }
.nav-item:active { color: var(--accent); }

.nav-icon { font-size: 22px; line-height: 1; }

/* =========================================
   SCROLLABLE CONTENT AREA
   ========================================= */
.scroll-area {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.content-pad {
  padding: 16px;
  padding-bottom: 32px;
}

/* =========================================
   PROGRAM LIST
   ========================================= */
.program-list { display: flex; flex-direction: column; gap: 12px; }

.program-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.15s, background 0.15s;
}

.program-card:active { background: var(--bg3); border-color: var(--border2); }

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

.program-card-name {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}

.program-card-meta {
  font-size: 13px;
  color: var(--text2);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.program-card-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--accent-dim);
  color: var(--accent);
  flex-shrink: 0;
}

.program-card-arrow { color: var(--text3); font-size: 20px; flex-shrink: 0; }

.program-progress {
  font-size: 12px;
  color: var(--text3);
  margin-top: 6px;
}

.progress-bar-wrap {
  height: 3px;
  background: var(--bg4);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s;
}

/* =========================================
   WEEK LIST
   ========================================= */
.week-list { display: flex; flex-direction: column; gap: 8px; }

.week-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  -webkit-tap-highlight-color: transparent;
}

.week-card:active { background: var(--bg3); }

.week-card.complete { border-color: var(--success); }

.week-label {
  font-size: 16px;
  font-weight: 600;
}

.week-meta { font-size: 13px; color: var(--text2); margin-top: 3px; }

.week-complete-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--success);
  background: var(--success-dim);
  padding: 3px 10px;
  border-radius: 20px;
}

/* =========================================
   DAY LIST
   ========================================= */
.day-list { display: flex; flex-direction: column; gap: 8px; }

.day-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  -webkit-tap-highlight-color: transparent;
}

.day-card:active { background: var(--bg3); }
.day-card.complete { border-color: var(--success); }

.day-name { font-size: 16px; font-weight: 600; }
.day-meta { font-size: 13px; color: var(--text2); margin-top: 3px; }

/* =========================================
   SESSION VIEW
   ========================================= */
.session-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  background: var(--bg2);
}

.session-header-info { flex: 1; min-width: 0; }
.session-title { font-size: 18px; font-weight: 700; }
.session-subtitle { font-size: 13px; color: var(--text2); margin-top: 2px; }

.session-progress {
  font-size: 13px;
  color: var(--accent);
  font-weight: 600;
  flex-shrink: 0;
}

.btn-reset {
  background: none;
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: 13px;
  padding: 8px 14px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}

.btn-reset:active { background: var(--bg4); }

.exercises-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 8px 16px 32px;
}

/* =========================================
   EXERCISE CARD
   ========================================= */
.exercise-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
  transition: border-color 0.2s;
}

.exercise-card.done { border-color: var(--success); opacity: 0.75; }
.exercise-card.weak-point-card { border-style: dashed; border-color: var(--accent); }
.exercise-card.weak-point-card.resolved { border-style: solid; border-left: 3px solid var(--accent); }

.exercise-card-header {
  display: flex;
  align-items: flex-start;
  padding: 14px 14px 0;
  gap: 10px;
}

.exercise-checkbox {
  width: 26px;
  height: 26px;
  border: 2px solid var(--border2);
  border-radius: 6px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin-top: 2px;
  background: var(--bg3);
  -webkit-tap-highlight-color: transparent;
  transition: all 0.15s;
}

.exercise-checkbox.checked {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
  font-size: 14px;
}

.exercise-checkbox.greyed {
  opacity: 0.35;
  pointer-events: none;
}

.exercise-name-block { flex: 1; min-width: 0; }

.exercise-name {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.3;
  word-break: break-word;
}

.exercise-name.has-video {
  color: var(--accent);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

.exercise-name.has-video:active { opacity: 0.7; }

.play-icon {
  font-size: 13px;
  flex-shrink: 0;
  margin-top: 3px;
  opacity: 0.8;
}

.exercise-technique {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-dim2);
  padding: 2px 8px;
  border-radius: 20px;
  margin-top: 6px;
  display: inline-block;
}

.exercise-meta {
  padding: 10px 14px 10px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px 12px;
  border-top: 1px solid var(--border);
  margin-top: 10px;
}

.meta-item { display: flex; flex-direction: column; gap: 1px; }
.meta-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text3); }
.meta-value { font-size: 14px; font-weight: 600; color: var(--text); }

.exercise-intensity {
  padding: 8px 14px;
  background: var(--bg3);
  font-size: 13px;
  color: var(--text2);
  border-top: 1px solid var(--border);
}

.exercise-notes {
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text2);
  line-height: 1.5;
  border-top: 1px solid var(--border);
}

.exercise-subs {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.subs-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text3); margin-bottom: 2px; }

.sub-item {
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 5px;
}

.sub-item.tappable { color: var(--accent); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.sub-item.tappable:active { opacity: 0.7; }
.sub-item.plain { color: var(--text2); }

/* Previous log hint */
.exercise-prev {
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text2);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.exercise-prev:active { background: var(--bg3); }

.prev-text { flex: 1; }
.prev-text strong { color: var(--text); }
.history-icon { color: var(--text3); font-size: 16px; }

/* Log input row */
.exercise-log {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.log-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.log-input-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
}

.log-input-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text3); }

.log-input {
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 18px;
  font-weight: 600;
  padding: 8px 10px;
  width: 100%;
  text-align: center;
  -webkit-appearance: none;
}

.log-input:focus {
  outline: none;
  border-color: var(--accent);
}

.log-x { color: var(--text3); font-size: 16px; font-weight: 700; flex-shrink: 0; }

.btn-save {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  padding: 12px 18px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
  white-space: nowrap;
}

.btn-save:active { opacity: 0.8; }
.btn-save:disabled { opacity: 0.4; pointer-events: none; }

/* Weak point CTA */
.wp-cta {
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.wp-cta-title { font-size: 16px; font-weight: 700; color: var(--accent); }
.wp-cta-sub { font-size: 13px; color: var(--text2); }

.btn-wp-pick {
  margin-top: 8px;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
  padding: 12px;
  cursor: pointer;
  width: 100%;
  -webkit-tap-highlight-color: transparent;
}

.btn-wp-pick:active { background: var(--accent); color: #000; }

.wp-resolved-caption {
  padding: 0 14px 10px;
  font-size: 12px;
  color: var(--text3);
  display: flex;
  align-items: center;
  gap: 4px;
}

.wp-change-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

/* =========================================
   SETTINGS VIEW
   ========================================= */
.settings-section { margin-bottom: 24px; }

.settings-section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text3);
  padding: 0 4px;
  margin-bottom: 8px;
}

.settings-row {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  margin-bottom: 8px;
  gap: 12px;
}

.settings-row-label { font-size: 16px; font-weight: 500; }
.settings-row-sub { font-size: 13px; color: var(--text2); margin-top: 2px; }

.settings-btn {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 16px;
  font-weight: 500;
  padding: 16px;
  text-align: left;
  cursor: pointer;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  -webkit-tap-highlight-color: transparent;
}

.settings-btn:active { background: var(--bg3); }
.settings-btn.danger { color: var(--danger); border-color: var(--danger); }

/* Toggle */
.toggle {
  position: relative;
  width: 56px;
  height: 30px;
  flex-shrink: 0;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--bg4);
  border-radius: 15px;
  cursor: pointer;
  transition: background 0.2s;
  border: 1px solid var(--border2);
}

.toggle input:checked + .toggle-track { background: var(--accent); border-color: var(--accent); }

.toggle-track::after {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  background: #fff;
  border-radius: 50%;
  top: 3px;
  left: 3px;
  transition: transform 0.2s;
}

.toggle input:checked + .toggle-track::after { transform: translateX(26px); }

/* Unit toggle */
.unit-toggle {
  display: flex;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.unit-btn {
  padding: 8px 20px;
  background: none;
  border: none;
  color: var(--text2);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.unit-btn.active {
  background: var(--accent);
  color: #000;
}

/* =========================================
   HISTORY VIEW
   ========================================= */
.history-list { display: flex; flex-direction: column; gap: 0; }

.history-entry {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.history-entry:last-child { border-bottom: none; }

.history-entry-info { flex: 1; min-width: 0; }
.history-weight { font-size: 17px; font-weight: 700; }
.history-date { font-size: 12px; color: var(--text2); margin-top: 2px; }
.history-week { font-size: 12px; color: var(--text3); }

.history-entry-actions { display: flex; gap: 8px; }

.entry-btn {
  background: none;
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: 13px;
  padding: 6px 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.entry-btn.delete { color: var(--danger); border-color: var(--danger-dim); }
.entry-btn:active { background: var(--bg3); }

.history-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text3);
  font-size: 15px;
}

/* Sparkline */
.sparkline-wrap {
  padding: 8px 16px 4px;
  border-bottom: 1px solid var(--border);
}

.sparkline-title { font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; }

/* =========================================
   BUTTONS
   ========================================= */
.btn {
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  padding: 12px 20px;
  cursor: pointer;
  border: none;
  -webkit-tap-highlight-color: transparent;
}

.btn-primary { background: var(--accent); color: #000; }
.btn-primary:active { opacity: 0.8; }
.btn-ghost { background: var(--bg3); color: var(--text2); border: 1px solid var(--border2); }
.btn-ghost:active { background: var(--bg4); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:active { opacity: 0.8; }

/* =========================================
   MODALS
   ========================================= */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal.hidden { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.85);
}

.modal-content {
  position: relative;
  z-index: 1;
  background: var(--bg2);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: 640px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: var(--safe-bottom);
  animation: slideUp 0.2s ease-out;
}

@keyframes slideUp {
  from { transform: translateY(40px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.video-modal-content { max-height: 95vh; }

.modal-header {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  gap: 10px;
  flex-shrink: 0;
}

.modal-title {
  flex: 1;
  font-size: 16px;
  font-weight: 700;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.modal-close {
  background: var(--bg3);
  border: none;
  color: var(--text2);
  font-size: 16px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.modal-close:active { background: var(--bg4); }

.modal-back {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 15px;
  padding: 4px 8px;
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

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

.yt-link {
  font-size: 13px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
}

/* Video */
.video-container {
  flex: 1;
  overflow: hidden;
  position: relative;
  background: #000;
}

.video-iframe-wrap {
  width: 100%;
  aspect-ratio: 16 / 9;
}

.video-iframe-wrap iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.video-offline {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 40px 20px;
  text-align: center;
  color: var(--text2);
}

/* Confirm modal */
.confirm-modal-content {
  max-height: auto;
  padding: 24px 20px;
  padding-bottom: calc(24px + var(--safe-bottom));
  gap: 16px;
  display: flex;
  flex-direction: column;
}

#confirm-message { font-size: 16px; line-height: 1.5; }

.confirm-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* Weak point modal */
.wp-modal-content {
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.wp-modal-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.wp-category-list { display: flex; flex-direction: column; gap: 0; }

.wp-category-item {
  padding: 18px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  -webkit-tap-highlight-color: transparent;
}

.wp-category-item:active { background: var(--bg3); }
.wp-category-item:last-child { border-bottom: none; }

.wp-category-name { font-size: 16px; font-weight: 600; }
.wp-category-meta { font-size: 13px; color: var(--text2); margin-top: 2px; }
.wp-category-tag { font-size: 12px; color: var(--text3); font-style: italic; }

.wp-exercise-list { display: flex; flex-direction: column; gap: 0; }

.wp-exercise-item {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.wp-exercise-item:active { background: var(--bg3); }
.wp-exercise-item:last-child { border-bottom: none; }

.wp-exercise-name { flex: 1; font-size: 15px; font-weight: 600; }

.wp-play-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-dim);
  border: none;
  color: var(--accent);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.wp-play-btn:active { background: var(--accent); color: #000; }

.wp-confirm-bar {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg2);
  flex-shrink: 0;
}

.wp-advice-body {
  padding: 20px 16px;
  font-size: 15px;
  color: var(--text2);
  line-height: 1.6;
}

/* History modal */
.history-modal-content {
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.history-modal-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Edit inline */
.entry-edit-row {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg3);
}

.entry-edit-input {
  background: var(--bg2);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 16px;
  padding: 8px 10px;
  width: 70px;
  text-align: center;
}

.entry-edit-label { font-size: 13px; color: var(--text2); }

/* =========================================
   TOAST
   ========================================= */
#toast {
  position: fixed;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg4);
  color: var(--text);
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 200;
  border: 1px solid var(--border2);
  max-width: calc(100vw - 40px);
  white-space: normal;
  text-align: center;
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* =========================================
   EMPTY / ERROR STATES
   ========================================= */
.empty-state {
  padding: 60px 20px;
  text-align: center;
  color: var(--text3);
}

.empty-state-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state-title { font-size: 18px; font-weight: 700; color: var(--text2); margin-bottom: 8px; }
.empty-state-sub { font-size: 14px; line-height: 1.5; }

.error-banner {
  background: var(--danger-dim);
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin: 16px;
  font-size: 14px;
  color: var(--danger);
}

/* =========================================
   MISC UTILS
   ========================================= */
.hidden { display: none !important; }
.text-accent { color: var(--accent); }
.text-dim { color: var(--text2); }
.text-muted { color: var(--text3); }
.fw-bold { font-weight: 700; }
.mt-8 { margin-top: 8px; }

/* Divider */
.divider {
  height: 1px;
  background: var(--border);
  margin: 8px 0;
}

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-accent { background: var(--accent-dim); color: var(--accent); }
.badge-success { background: var(--success-dim); color: var(--success); }

/* No-scroll for modal open */
body.modal-open { overflow: hidden; }

/* =========================================
   STATS VIEW
   ========================================= */

/* Search */
.stats-search-wrap { margin-bottom: 16px; }

.stats-search {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 16px;
  padding: 12px 16px;
  -webkit-appearance: none;
}

.stats-search:focus { outline: none; border-color: var(--accent); }
.stats-search::placeholder { color: var(--text3); }

/* Summary strip */
.stats-strip {
  display: flex;
  align-items: center;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 0;
  margin-bottom: 16px;
}

.stats-strip-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.stats-strip-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--accent);
}

.stats-strip-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text3);
}

.stats-strip-divider {
  width: 1px;
  height: 36px;
  background: var(--border);
}

/* Exercise list rows */
.stats-exercise-list { display: flex; flex-direction: column; gap: 8px; }

.stats-exercise-row {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 12px 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.stats-exercise-row:active { background: var(--bg3); }

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

.stats-exercise-name {
  font-size: 15px;
  font-weight: 600;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}

.stats-exercise-meta { font-size: 12px; color: var(--text2); }

/* Mini sparkline */
.mini-spark { flex-shrink: 0; opacity: 0.85; }
.mini-spark-empty { width: 56px; height: 28px; flex-shrink: 0; }

/* Exercise stats detail */
.ex-stats-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 0;
}

.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-card-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text3);
}

.stat-card-value {
  font-size: 17px;
  font-weight: 800;
  color: var(--accent);
  line-height: 1.2;
}

.stat-card-sub {
  font-size: 11px;
  color: var(--text2);
  line-height: 1.3;
}

/* Chart card */
.chart-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  overflow: hidden;
}

.chart-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}

.chart-svg-wrap { width: 100%; overflow: visible; }

.chart-single {
  padding: 24px 0;
  text-align: center;
}

.chart-single-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--accent);
}

.chart-single-sub {
  font-size: 13px;
  color: var(--text3);
  margin-top: 6px;
}

/* Log table */
.ex-stats-table {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.ex-stats-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.ex-stats-row:last-child { border-bottom: none; }
.ex-stats-row.is-pr { background: var(--accent-dim2); }

.ex-stats-date { font-size: 13px; color: var(--text2); flex: 1; }

.ex-stats-weight {
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.pr-badge {
  font-size: 10px;
  font-weight: 800;
  background: var(--accent);
  color: #000;
  padding: 2px 6px;
  border-radius: 20px;
  letter-spacing: 0.05em;
}
