/* gym.the-value-matrix.com — Design System */

:root {
  --bg: #0e0f12;
  --bg-elev: #16181d;
  --bg-card: #1c1f26;
  --border: #2a2e38;
  --border-strong: #3a3f4d;
  --text: #ececec;
  --text-muted: #9ba3af;
  --text-dim: #6b7280;
  --accent: #d4a73a;      /* gold like identity-edge */
  --accent-soft: rgba(212,167,58,0.16);
  --green: #4ade80;
  --red: #f87171;
  --blue: #60a5fa;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: var(--font-sans); -webkit-font-smoothing: antialiased; }
body { line-height: 1.55; font-size: 16px; min-height: 100vh; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
input, button, textarea, select { font: inherit; color: inherit; }

/* ===== Layout ===== */
.app-shell { max-width: 760px; margin: 0 auto; padding: 0 16px 88px; }
.app-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(14,15,18,0.92); backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
}
.app-header__inner { max-width: 760px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; }
.app-brand { font-weight: 700; letter-spacing: 0.02em; font-size: 18px; color: var(--text); }
.app-brand a { color: inherit; text-decoration: none; }
.app-brand__dot { color: var(--accent); }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: rgba(14,15,18,0.96); backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px 0 max(6px, env(safe-area-inset-bottom));
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 4px; color: var(--text-muted); font-size: 11px;
  text-decoration: none;
}
.tabbar a.active { color: var(--accent); }
.tabbar a svg { width: 22px; height: 22px; }

/* ===== Components ===== */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin: 12px 0;
}
.card h2, .card h3 { margin-top: 0; }
.card__title { font-size: 14px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); margin: 0 0 8px; }

.stack { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; gap: 8px; align-items: center; }
.row--between { justify-content: space-between; }
.row--wrap { flex-wrap: wrap; }
.spacer { flex: 1; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 18px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--bg-elev); color: var(--text); cursor: pointer;
  font-weight: 600; text-decoration: none; min-height: 44px;
  transition: background 120ms, border-color 120ms, transform 80ms;
}
.btn:hover { background: var(--bg-card); }
.btn:active { transform: scale(0.98); }
.btn--primary { background: var(--accent); color: #1a1a1a; border-color: var(--accent); }
.btn--primary:hover { background: #e5b746; }
.btn--ghost { background: transparent; border-color: var(--border); }
.btn--danger { color: var(--red); border-color: rgba(248,113,113,0.4); }
.btn--small { padding: 8px 12px; min-height: 36px; font-size: 14px; }
.btn--block { width: 100%; }

.input, .select, .textarea {
  background: var(--bg-elev); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 12px 14px; width: 100%;
  font-size: 16px; min-height: 44px;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.textarea { min-height: 90px; resize: vertical; }
.label { font-size: 13px; color: var(--text-muted); margin-bottom: 4px; display: block; }
.field { margin-bottom: 12px; }

.tag {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase;
  background: var(--bg-elev); color: var(--text-muted); border: 1px solid var(--border);
}
.tag--active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.tag--mg-chest    { background: rgba(248,113,113,0.16); color: #fca5a5; border-color: rgba(248,113,113,0.35); }
.tag--mg-back     { background: rgba(96,165,250,0.16); color: #93c5fd; border-color: rgba(96,165,250,0.35); }
.tag--mg-legs     { background: rgba(74,222,128,0.16); color: #86efac; border-color: rgba(74,222,128,0.35); }
.tag--mg-shoulders{ background: rgba(251,191,36,0.16); color: #fcd34d; border-color: rgba(251,191,36,0.35); }
.tag--mg-arms     { background: rgba(192,132,252,0.16); color: #d8b4fe; border-color: rgba(192,132,252,0.35); }
.tag--mg-core     { background: rgba(244,114,182,0.16); color: #f9a8d4; border-color: rgba(244,114,182,0.35); }
.tag--mg-cardio   { background: rgba(45,212,191,0.16); color: #5eead4; border-color: rgba(45,212,191,0.35); }
.tag--mg-fullbody { background: rgba(212,167,58,0.16); color: var(--accent); border-color: rgba(212,167,58,0.35); }

.flash {
  margin: 12px 0; padding: 10px 14px; border-radius: var(--radius-sm);
  background: var(--bg-elev); border-left: 4px solid var(--accent);
}
.flash--error { border-left-color: var(--red); }
.flash--success { border-left-color: var(--green); }

.h1 { font-size: 22px; margin: 12px 0 4px; }
.h2 { font-size: 18px; margin: 8px 0 4px; }
.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.mono { font-family: var(--font-mono); }

hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ===== Login Page ===== */
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; }

/* ===== Workout Logger (the core UX) ===== */
.logger-exercise {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); margin: 12px 0; overflow: hidden;
}
.logger-exercise__header {
  padding: 14px 16px; border-bottom: 1px solid var(--border); background: var(--bg-elev);
}
.logger-exercise__title { font-size: 18px; font-weight: 700; margin: 0; }
.logger-exercise__target {
  font-size: 13px; color: var(--text-muted); margin-top: 4px;
  font-family: var(--font-mono);
}
.logger-set-row {
  display: grid; grid-template-columns: 32px 1fr 1fr auto;
  align-items: center; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--border);
}
.logger-set-row__num { font-weight: 700; color: var(--text-muted); text-align: center; font-size: 13px; }
.logger-set-row__weight, .logger-set-row__reps {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px; text-align: center;
}
.logger-set-row__weight-val, .logger-set-row__reps-val {
  font-size: 16px; font-weight: 600; font-family: var(--font-mono);
}
.logger-set-row__weight-lbl, .logger-set-row__reps-lbl {
  font-size: 10px; color: var(--text-dim); letter-spacing: 0.08em; text-transform: uppercase;
}
.logger-set-row--logged {
  background: rgba(74,222,128,0.08); border-left: 3px solid var(--green);
}
.logger-set-row--warmup .logger-set-row__num::before { content: "W"; }

.logger-input-bar {
  display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px;
  padding: 12px 16px; border-top: 1px solid var(--border); background: rgba(212,167,58,0.04);
}
.stepper {
  display: grid; grid-template-columns: 44px 1fr 44px; gap: 6px;
  background: var(--bg-elev); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  align-items: stretch;
}
.stepper button {
  background: transparent; border: none; color: var(--accent);
  font-size: 22px; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); min-height: 50px;
}
.stepper button:active { background: var(--bg-card); transform: scale(0.95); }
.stepper input {
  background: transparent; border: none; outline: none;
  text-align: center; font-size: 22px; font-weight: 700; font-family: var(--font-mono);
  width: 100%;
}
.stepper__label { grid-column: 1 / -1; text-align: center; font-size: 10px; color: var(--text-dim); letter-spacing: 0.1em; text-transform: uppercase; margin-bottom: -4px; padding-top: 4px; }

.btn-log-set {
  background: var(--accent); color: #1a1a1a; border: none;
  border-radius: var(--radius-sm); padding: 0 20px; min-width: 64px;
  font-size: 16px; font-weight: 700; cursor: pointer;
}
.btn-log-set:active { transform: scale(0.96); }

.rest-timer {
  position: fixed; bottom: 80px; left: 16px; right: 16px;
  background: var(--accent); color: #1a1a1a;
  border-radius: var(--radius); padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: var(--shadow); z-index: 40;
}
.rest-timer__count { font-size: 28px; font-weight: 800; font-family: var(--font-mono); }
.rest-timer__label { font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; opacity: 0.7; }

/* ===== Tables ===== */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 8px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
.table th { color: var(--text-muted); font-weight: 500; text-transform: uppercase; font-size: 11px; letter-spacing: 0.06em; }

/* ===== Chart container ===== */
.chart-box { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin: 12px 0; }
.chart-box canvas { width: 100% !important; max-height: 280px; }

/* ===== Read-only PT View ===== */
.share-banner {
  background: var(--accent-soft); border: 1px solid var(--accent);
  color: var(--accent); padding: 10px 14px; border-radius: var(--radius-sm);
  margin: 12px 0; font-size: 13px;
}

/* ===== Last-Time Hint (Progressive Overload) ===== */
.last-time-hint {
  display: flex; align-items: baseline; gap: 8px;
  margin-top: 6px; padding: 6px 8px;
  background: rgba(96,165,250,0.08); border-left: 3px solid var(--blue);
  border-radius: 4px; font-size: 12px;
}
.last-time-hint__label { color: var(--blue); letter-spacing: 0.06em; text-transform: uppercase; font-size: 10px; font-weight: 600; }
.last-time-hint__data { color: var(--text); }

/* ===== Plate Calculator ===== */
.plate-calc {
  padding: 6px 16px; font-size: 11px; color: var(--text-muted);
  background: rgba(212,167,58,0.05);
  border-top: 1px solid var(--border);
  letter-spacing: 0.02em;
}

/* ===== PR Toast ===== */
.pr-toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  background: linear-gradient(135deg, #d4a73a 0%, #e5b746 100%);
  color: #1a1a1a;
  padding: 14px 18px; border-radius: var(--radius);
  display: flex; align-items: center; gap: 12px;
  box-shadow: 0 8px 32px rgba(212,167,58,0.4), 0 0 0 2px rgba(255,255,255,0.15) inset;
  z-index: 60; max-width: 90%; min-width: 280px;
}
.pr-toast__icon { font-size: 28px; }
.pr-toast__title { font-weight: 800; font-size: 14px; letter-spacing: 0.04em; text-transform: uppercase; }
.pr-toast__detail { font-size: 13px; font-weight: 600; margin-top: 2px; }

/* ===== Streak / Quick Stats ===== */
.streak-bar {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  margin: 12px 0;
}
.streak-stat {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px;
  text-align: center;
}
.streak-stat__value { font-size: 22px; font-weight: 800; color: var(--accent); font-family: var(--font-mono); line-height: 1.1; }
.streak-stat__label { font-size: 10px; color: var(--text-muted); letter-spacing: 0.08em; text-transform: uppercase; margin-top: 4px; }
.streak-stat__delta { font-size: 11px; margin-top: 2px; font-weight: 600; }
.streak-stat__delta--up { color: var(--green); }
.streak-stat__delta--down { color: var(--red); }
.streak-stat__delta--flat { color: var(--text-dim); }

/* ===== Photo Comparison Slider ===== */
.compare-wrap {
  position: relative; max-width: 600px; margin: 0 auto;
  background: var(--bg-elev); border-radius: var(--radius); overflow: hidden;
  aspect-ratio: 3/4; user-select: none; touch-action: none;
}
.compare-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.compare-img--after { clip-path: inset(0 0 0 var(--split, 50%)); }
.compare-handle {
  position: absolute; top: 0; bottom: 0;
  left: var(--split, 50%); width: 3px; background: var(--accent);
  transform: translateX(-50%); cursor: ew-resize;
}
.compare-handle::after {
  content: ""; position: absolute; left: 50%; top: 50%;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--accent); transform: translate(-50%, -50%);
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
.compare-handle::before {
  content: "⇆"; position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%); z-index: 2; color: #1a1a1a; font-weight: 800;
}
.compare-label {
  position: absolute; top: 12px; padding: 4px 10px; border-radius: 4px;
  background: rgba(0,0,0,0.7); color: #fff; font-size: 11px;
  font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
}
.compare-label--before { left: 12px; }
.compare-label--after { right: 12px; }

/* ===== iOS-Specific tweaks ===== */
@supports (-webkit-touch-callout: none) {
  .stepper input { font-size: 22px; }
  input { font-size: 16px; /* prevents zoom on iOS */ }
}

/* ===== Empty state ===== */
.empty {
  text-align: center; padding: 32px 16px; color: var(--text-muted);
}
.empty__title { font-size: 18px; color: var(--text); margin-bottom: 6px; }

/* ===== Print: hide tabbar ===== */
@media print {
  .tabbar, .app-header { display: none; }
}
