/* ============================================================
   The Factory — Gym Tracker
   Light theme, red accent
   ============================================================ */

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

:root {
  --bg-base:      #f8f9fa;
  --bg-surface:   #ffffff;
  --bg-raised:    #f1f3f5;
  --bg-hover:     #e9ecef;
  --border:       #dee2e6;
  --border-light: #ced4da;

  --text-primary:   #1a1a2e;
  --text-secondary: #495057;
  --text-muted:     #868e96;

  --accent:               #ef4444;
  --accent-hover:         #dc2626;
  --accent-dim:           rgba(239, 68, 68, 0.10);
  --accent-success:       #22c55e;
  --accent-success-hover: #16a34a;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.10), 0 2px 4px rgba(0,0,0,0.06);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --header-h:  60px;
  --nav-h:     50px;
  --mob-nav-h: 60px;
}

html, body {
  height: 100%;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   APP SHELL
============================================================ */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ============================================================
   HEADER
============================================================ */
.site-header {
  height: var(--header-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon svg {
  display: block;
}

.brand-text h1 {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  line-height: 1.2;
}

.brand-text p {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.greeting {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.header-action-btn {
  color: var(--text-muted);
  flex-shrink: 0;
}

.header-action-btn:hover {
  color: var(--accent);
  background: var(--accent-dim);
}

/* ============================================================
   MODAL
============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 420px;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close {
  color: var(--text-muted);
}

.modal-close:hover {
  color: var(--accent);
  background: var(--accent-dim);
}

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-raised);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.form-error {
  font-size: 0.85rem;
  color: var(--accent);
  font-weight: 500;
  padding: 10px 14px;
  background: var(--accent-dim);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

/* ============================================================
   TAB NAV — desktop (top bar)
============================================================ */
.tab-nav {
  display: flex;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 0 12px;
  height: var(--nav-h);
  gap: 4px;
  align-items: flex-end;
  position: sticky;
  top: var(--header-h);
  z-index: 90;
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 500;
  font-family: var(--font);
  padding: 0 16px 12px;
  transition: color 0.15s, border-color 0.15s;
  min-height: 44px;
  display: inline-flex;
  align-items: flex-end;
  padding-bottom: 12px;
}

.tab-btn:hover {
  color: var(--text-secondary);
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* ============================================================
   TAB CONTENT
============================================================ */
.tab-content {
  flex: 1;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.panel-inner {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

/* ============================================================
   TYPOGRAPHY
============================================================ */
.section-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.section-sub {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: block;
  margin-bottom: 6px;
}

/* ============================================================
   BUTTONS
============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.875rem;
  padding: 10px 18px;
  min-height: 44px;
  transition: background 0.15s, opacity 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 3px rgba(239,68,68,0.25);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: 0 2px 6px rgba(239,68,68,0.35);
}

.btn-success {
  background: var(--accent-success);
  color: #fff;
  box-shadow: 0 1px 3px rgba(34,197,94,0.25);
}

.btn-success:hover:not(:disabled) {
  background: var(--accent-success-hover);
}

.btn-outline {
  background: transparent;
  color: var(--accent);
  border: 1.5px solid var(--accent);
}

.btn-outline:hover:not(:disabled) {
  background: var(--accent-dim);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-raised);
  border-color: var(--border-light);
  color: var(--text-primary);
}

.btn-danger-ghost {
  background: transparent;
  color: var(--accent);
  border: none;
  padding: 6px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
}

.btn-danger-ghost:hover:not(:disabled) {
  background: var(--accent-dim);
  color: var(--accent-hover);
}

.btn-sm {
  font-size: 0.8rem;
  padding: 8px 14px;
  min-height: 36px;
}

.btn-lg {
  font-size: 1rem;
  padding: 14px 28px;
  min-height: 52px;
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
  line-height: 1;
  transition: color 0.15s, background 0.15s;
  min-width: 36px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover {
  color: var(--accent);
  background: var(--accent-dim);
}

/* ============================================================
   FORM CONTROLS
============================================================ */
.form-input,
.form-select,
.form-textarea {
  background: var(--bg-surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 1rem;
  padding: 10px 14px;
  width: 100%;
  min-height: 44px;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(239,68,68,0.12);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-muted);
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23868e96' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

.form-select option {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.form-textarea {
  resize: vertical;
  min-height: 70px;
  font-size: 0.9rem;
}

/* ============================================================
   WORKOUT TAB
============================================================ */
.workout-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.workout-header-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.day-picker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.day-chip {
  background: var(--bg-surface);
  border: 1.5px solid var(--border);
  border-radius: 22px;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 8px 18px;
  min-height: 40px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.day-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

.day-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Session form */
.session-form {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

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

.form-section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* Exercise block */
.exercise-block {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 12px;
}

.exercise-block-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.exercise-name-input {
  flex: 1;
  background: var(--bg-surface);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 9px 12px;
  min-height: 44px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.exercise-name-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(239,68,68,0.10);
}

.exercise-name-input::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

/* Sets table — desktop layout */
.sets-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 10px;
}

.sets-table th {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: left;
  padding: 0 8px 8px 0;
}

.sets-table th:last-child {
  width: 36px;
}

.sets-table td {
  padding: 4px 8px 4px 0;
  vertical-align: middle;
}

.sets-table td:last-child {
  width: 40px;
  text-align: right;
}

.set-input {
  background: var(--bg-surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 1rem;
  padding: 8px 10px;
  width: 80px;
  min-height: 44px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  text-align: center;
}

.set-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(239,68,68,0.10);
}

.add-set-btn {
  background: var(--bg-surface);
  border: 1.5px dashed var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 10px 12px;
  min-height: 44px;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  width: 100%;
}

.add-set-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

.session-notes-row {
  margin-top: 16px;
  margin-bottom: 20px;
}

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

/* Idle state */
.idle-state {
  text-align: center;
  padding: 60px 20px;
}

.idle-icon {
  margin-bottom: 16px;
  opacity: 0.7;
}

.idle-text {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.idle-sub {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* ============================================================
   PLAN TAB
============================================================ */
.plan-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

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

.plan-day-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.plan-day-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.plan-day-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
  min-width: 90px;
}

.plan-day-badge {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-dim);
  border-radius: 10px;
  padding: 3px 9px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.plan-exercises-input {
  background: var(--bg-raised);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.9rem;
  padding: 10px 14px;
  min-height: 44px;
  width: 100%;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.plan-exercises-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(239,68,68,0.10);
}

.plan-exercises-input::placeholder {
  color: var(--text-muted);
}

/* ============================================================
   HISTORY TAB
============================================================ */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 12px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.stat-value {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--accent);
  line-height: 1;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.filter-row {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.filter-row .form-select {
  flex: 0 0 150px;
}

.filter-row .form-input {
  flex: 1;
}

/* History entries */
.history-entry {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.history-entry-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  cursor: pointer;
  user-select: none;
}

.history-entry-header:hover {
  background: var(--bg-raised);
}

.history-entry-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.history-day-badge {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-dim);
  border-radius: 8px;
  padding: 3px 9px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.history-date {
  font-size: 0.875rem;
  color: var(--text-primary);
  font-weight: 600;
}

.history-exercises-count {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.history-entry-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.history-chevron {
  color: var(--text-muted);
  transition: transform 0.2s;
  font-size: 0.75rem;
  margin-left: 4px;
}

.history-entry.expanded .history-chevron {
  transform: rotate(180deg);
}

.history-entry-body {
  display: none;
  padding: 0 16px 16px;
  border-top: 1px solid var(--border);
}

.history-entry.expanded .history-entry-body {
  display: block;
}

.history-exercise {
  margin-top: 12px;
}

.history-exercise-name {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.history-sets {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.history-set-pill {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  padding: 4px 12px;
}

.history-notes {
  margin-top: 12px;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.history-empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* ============================================================
   MEALS TAB
============================================================ */
.meal-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 20px;
}

.meal-day-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.meal-day-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.meal-slots {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.meal-slot {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.meal-slot-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.meal-slot-input {
  background: var(--bg-raised);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.9rem;
  padding: 9px 12px;
  min-height: 44px;
  width: 100%;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.meal-slot-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(239,68,68,0.10);
}

.meal-slot-input::placeholder {
  color: var(--text-muted);
}

/* ============================================================
   TOASTS
============================================================ */
.toast-container {
  position: fixed;
  bottom: 80px;   /* clear the mobile nav bar */
  right: 16px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  color: var(--text-primary);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 12px 18px;
  pointer-events: auto;
  transform: translateX(110%);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 280px;
  border-left: 3px solid var(--accent);
}

.toast.success {
  border-left-color: var(--accent-success);
}

.toast.show {
  transform: translateX(0);
}

/* ============================================================
   UTILITIES
============================================================ */
.hidden {
  display: none !important;
}

/* ============================================================
   EXERCISE TYPE BADGE (toggle between Cardio / Weights)
============================================================ */
.exercise-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 20px;
  border: 1.5px solid;
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 5px 10px;
  min-height: 32px;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  text-transform: uppercase;
}

.exercise-type-badge.run {
  color: #0ea5e9;
  border-color: #bae6fd;
  background: #f0f9ff;
}

.exercise-type-badge.run:hover {
  background: #e0f2fe;
  border-color: #7dd3fc;
}

.exercise-type-badge.lift {
  color: var(--text-muted);
  border-color: var(--border);
  background: var(--bg-raised);
}

.exercise-type-badge.lift:hover {
  background: var(--bg-hover);
  border-color: var(--border-light);
  color: var(--text-secondary);
}

/* ============================================================
   RUN EXERCISE BLOCK — distinct background tint
============================================================ */
.exercise-block-run {
  background: #f0f9ff;
  border-color: #bae6fd;
}

/* ============================================================
   RUN ENTRY FORM
   (replaces sets table for cardio exercises)
============================================================ */
.run-form {
  margin-top: 4px;
}

.run-fields-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.run-field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.run-pace-group {
  flex: 1.2;
}

.run-field-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.run-input-wrap {
  display: flex;
  align-items: center;
  background: var(--bg-surface);
  border: 1.5px solid #bae6fd;
  border-radius: var(--radius-sm);
  overflow: hidden;
  min-height: 44px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.run-input-wrap:focus-within {
  border-color: #0ea5e9;
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.12);
}

.run-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 1.05rem;
  font-weight: 600;
  padding: 10px 12px;
  outline: none;
  text-align: center;
  min-width: 0;
}

.run-input::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

.run-unit {
  font-size: 0.78rem;
  font-weight: 700;
  color: #0ea5e9;
  padding: 0 10px 0 4px;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Pace display — live calculated, read-only */
.run-pace-display {
  background: var(--bg-surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 1.05rem;
  font-weight: 600;
  padding: 10px 12px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: -0.01em;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.run-pace-display.pace-active {
  color: #0ea5e9;
  border-color: #bae6fd;
  background: #f0f9ff;
  font-size: 0.95rem;
}

/* ============================================================
   HISTORY — run session styling
============================================================ */
.history-entry-run .history-day-badge {
  color: #0ea5e9;
  background: #e0f2fe;
}

.history-exercise-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.history-run-tag {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #0ea5e9;
  background: #e0f2fe;
  border-radius: 8px;
  padding: 2px 8px;
  flex-shrink: 0;
}

/* Run stat pills — larger, more visually prominent than set pills */
.history-run-stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.history-run-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 6px 14px;
  border: 1.5px solid;
}

.dist-pill {
  color: #0ea5e9;
  background: #f0f9ff;
  border-color: #bae6fd;
}

.time-pill {
  color: #7c3aed;
  background: #faf5ff;
  border-color: #e9d5ff;
}

.pace-pill {
  color: #16a34a;
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.run-pill-value {
  font-size: 1rem;
  letter-spacing: -0.02em;
}

.run-pill-unit {
  font-size: 0.72rem;
  font-weight: 600;
  opacity: 0.75;
  text-transform: lowercase;
}

.run-pill-icon {
  display: inline-flex;
  align-items: center;
  opacity: 0.7;
}

/* ============================================================
   MOBILE — bottom tab bar + responsive layout
   Breakpoint: <= 600px
============================================================ */
@media (max-width: 600px) {

  /* Push content up above the fixed bottom nav */
  .app-shell {
    padding-bottom: var(--mob-nav-h);
  }

  /* Header — compact */
  .site-header {
    height: 52px;
    padding: 0 14px;
  }

  .brand-text p {
    display: none; /* hide tagline on mobile — too tight */
  }

  /* Hide the top tab bar, show nothing (bottom nav replaces it) */
  .tab-nav {
    display: none;
  }

  /* Bottom navigation bar */
  .tab-nav-mobile {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--mob-nav-h);
    background: var(--bg-surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 12px rgba(0,0,0,0.08);
    z-index: 200;
    align-items: stretch;
  }

  .tab-nav-mobile .tab-btn {
    flex: 1;
    flex-direction: column;
    gap: 3px;
    border-bottom: none;
    border-top: 3px solid transparent;
    padding: 8px 4px 6px;
    font-size: 0.72rem;
    font-weight: 500;
    min-height: unset;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
  }

  .tab-nav-mobile .tab-btn.active {
    color: var(--accent);
    border-top-color: var(--accent);
    border-bottom: none;
    font-weight: 600;
  }

  .tab-nav-mobile .tab-btn-icon {
    font-size: 1.3rem;
    line-height: 1;
    display: block;
  }

  .panel-inner {
    padding: 16px 14px 24px;
  }

  /* Workout header — stack on mobile */
  .workout-header-row {
    flex-direction: column;
    gap: 12px;
  }

  .workout-header-actions {
    width: 100%;
    justify-content: stretch;
    gap: 8px;
  }

  .workout-header-actions .btn {
    flex: 1;
  }

  /* Day chips — full width wrapping, bigger tap targets */
  .day-chip {
    flex: 1;
    min-width: 0;
    text-align: center;
    padding: 10px 6px;
    font-size: 0.82rem;
  }

  /* Session form — tighter */
  .session-form {
    padding: 16px 14px;
  }

  .exercise-block {
    padding: 12px;
  }

  /* -------------------------------------------------------
     Sets — switch from table to stacked card layout on mobile.
     We override display properties to turn the table into
     a flex-column stack. Each row becomes a mini-card with
     labelled fields side by side.
  ------------------------------------------------------- */
  .sets-table,
  .sets-table tbody,
  .sets-table tr {
    display: block;
    width: 100%;
  }

  /* Hide the table header row — we use pseudo-content labels instead */
  .sets-table thead {
    display: none;
  }

  .sets-table tr {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
  }

  .sets-table tr:last-child {
    border-bottom: none;
  }

  /* Set number cell — compact badge */
  .sets-table td:first-child {
    width: 28px !important;
    flex-shrink: 0;
    text-align: center;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-muted);
  }

  /* Reps and weight cells — grow equally */
  .sets-table td:nth-child(2),
  .sets-table td:nth-child(3) {
    flex: 1;
    padding: 0;
  }

  /* Remove button cell — compact */
  .sets-table td:last-child {
    width: 40px !important;
    flex-shrink: 0;
    text-align: right;
    padding: 0;
  }

  /* Inputs fill their cells */
  .set-input {
    width: 100%;
    font-size: 1rem;
    padding: 10px 8px;
    text-align: center;
  }

  /* Stats row — keep 3 columns but tighter */
  .stats-row {
    gap: 8px;
  }

  .stat-value {
    font-size: 1.8rem;
  }

  .stat-label {
    font-size: 0.68rem;
  }

  /* Filter row — stack on mobile */
  .filter-row {
    flex-direction: column;
    gap: 8px;
  }

  .filter-row .form-select {
    flex: none;
    width: 100%;
  }

  /* Meal slots — single column on mobile */
  .meal-slots {
    grid-template-columns: 1fr;
  }

  /* Session actions — full-width stack */
  .session-actions {
    flex-direction: column-reverse;
    gap: 8px;
  }

  .session-actions .btn {
    width: 100%;
    justify-content: center;
  }

  /* Toast clears bottom nav */
  .toast-container {
    bottom: 72px;
  }

  /* Run form — stack fields vertically on mobile */
  .run-fields-row {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 10px;
  }

  .run-field-group {
    flex: 1;
    min-width: 80px;
  }

  .run-pace-group {
    flex: 0 0 100%;
  }

  .run-pace-display {
    font-size: 1.1rem;
  }

  /* Run history pills — wrap naturally */
  .history-run-stats {
    gap: 6px;
  }

  .history-run-pill {
    font-size: 0.82rem;
    padding: 5px 12px;
  }

  .run-pill-value {
    font-size: 0.95rem;
  }
}

/* Desktop — hide the mobile nav */
@media (min-width: 601px) {
  .tab-nav-mobile {
    display: none;
  }
}

/* ============================================================
   LOGIN OVERLAY
   Full-screen cover shown when no valid session cookie exists.
   Works identically in Safari, standalone PWA mode, and any
   browser — no dependency on BasicAuth prompts.
============================================================ */
.login-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-base);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 20px env(safe-area-inset-bottom, 20px);
}

.login-overlay.hidden {
  display: none;
}

.login-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 360px;
  padding: 32px 28px 28px;
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 28px;
  text-align: center;
}

.login-brand h1 {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.login-brand p {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.btn-block {
  width: 100%;
  justify-content: center;
  padding: 13px;
  font-size: 1rem;
}
