:root {
  --bg: #0d0d14;
  --surface: #15151f;
  --card: #1e1e2d;
  --border: #2c2c42;
  --primary: #8b5cf6;
  --primary-light: #a78bfa;
  --primary-dim: rgba(139, 92, 246, 0.15);
  --green: #10b981;
  --amber: #f59e0b;
  --red: #ef4444;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --dim: #64748b;
  --nav-height: 60px;
}

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

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

/* ── Navigation ── */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 32px;
}

.nav-brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--primary-light);
  text-decoration: none;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}

.nav-brand span { color: var(--muted); font-weight: 400; }

.nav-links {
  display: flex;
  gap: 4px;
  list-style: none;
}

.nav-links a {
  color: var(--muted);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.15s, background 0.15s;
}

.nav-links a:hover { color: var(--text); background: var(--primary-dim); }
.nav-links a.active { color: var(--primary-light); background: var(--primary-dim); }

/* ── Layout ── */
.main {
  padding-top: calc(var(--nav-height) + 32px);
  padding-bottom: 64px;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ── Cards ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
}

.card-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 16px;
}

/* ── Stats grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.stat-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 8px;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
}

.stat-value.accent { color: var(--primary-light); }
.stat-value.green  { color: var(--green); }
.stat-sub { font-size: 0.78rem; color: var(--muted); margin-top: 4px; }

/* ── Tables ── */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

th {
  text-align: left;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(44, 44, 66, 0.5);
}

tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(139, 92, 246, 0.05); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  text-decoration: none;
  font-family: inherit;
}

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

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--primary-light); }

.btn-secondary { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { color: var(--text); border-color: var(--primary); }

.btn-danger { background: transparent; color: var(--red); border: 1px solid var(--border); }
.btn-danger:hover:not(:disabled) { background: rgba(239, 68, 68, 0.1); border-color: var(--red); }

/* ── Forms ── */
textarea, input[type="text"], input[type="search"], input[type="password"] {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  padding: 10px 14px;
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
}

textarea:focus, input:focus { border-color: var(--primary); }

textarea {
  resize: vertical;
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Mono', monospace;
  font-size: 0.82rem;
  line-height: 1.6;
}

label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 8px;
}

.form-group { margin-bottom: 20px; }

/* ── Alerts ── */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 0.88rem;
  margin-bottom: 16px;
}

.alert-error   { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); color: #fca5a5; }
.alert-success { background: rgba(16,185,129,0.1); border: 1px solid rgba(16,185,129,0.3); color: #6ee7b7; }

/* ── Page header ── */
.page-header { margin-bottom: 32px; }
.page-title { font-size: 1.75rem; font-weight: 700; margin-bottom: 4px; }
.page-subtitle { color: var(--muted); font-size: 0.9rem; }

/* ── Grid layouts ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }

/* ── Charts ── */
.chart-container { position: relative; height: 280px; }

/* ── Workout list items ── */
.workout-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
}

.workout-item:last-child { border-bottom: none; }
.workout-item:hover .workout-name { color: var(--primary-light); }
.workout-name { font-weight: 600; margin-bottom: 2px; transition: color 0.15s; }
.workout-meta { font-size: 0.78rem; color: var(--muted); }
.workout-volume { font-size: 0.82rem; color: var(--muted); text-align: right; }

/* ── Exercise cards (workout detail) ── */
.exercise-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}

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

.exercise-card-name { font-weight: 700; font-size: 1rem; }
.exercise-card-link { color: var(--primary-light); text-decoration: none; font-size: 0.8rem; }

/* ── Set badges ── */
.set-badge {
  display: inline-block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 9px;
  font-size: 0.78rem;
  color: var(--muted);
}

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 500;
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
  font-family: inherit;
}

.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary-light); border-bottom-color: var(--primary); }

/* ── Frequency heatmap ── */
.heatmap { overflow-x: auto; padding-bottom: 8px; }

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

.heatmap-day-labels {
  display: grid;
  grid-template-rows: repeat(7, 14px);
  gap: 2px;
  padding-top: 20px;
  flex-shrink: 0;
}

.heatmap-day-labels span {
  font-size: 10px;
  color: var(--dim);
  line-height: 14px;
  text-align: right;
}

.heatmap-right { display: flex; flex-direction: column; }

.heatmap-month-labels {
  display: flex;
  gap: 2px;
  margin-bottom: 4px;
  height: 16px;
  overflow: hidden;
}

.heatmap-month-labels span {
  font-size: 10px;
  color: var(--dim);
  width: 14px;
  flex-shrink: 0;
  overflow: visible;
  white-space: nowrap;
}

.heatmap-grid {
  display: grid;
  grid-template-rows: repeat(7, 14px);
  grid-auto-flow: column;
  grid-auto-columns: 14px;
  gap: 2px;
}

.heatmap-cell {
  width: 14px;
  height: 14px;
  border-radius: 2px;
  background: var(--surface);
  cursor: default;
}

.heatmap-cell[data-level="1"] { background: rgba(139, 92, 246, 0.3); }
.heatmap-cell[data-level="2"] { background: rgba(139, 92, 246, 0.5); }
.heatmap-cell[data-level="3"] { background: rgba(139, 92, 246, 0.75); }
.heatmap-cell[data-level="4"] { background: var(--primary); }

/* ── Utilities ── */
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.text-muted  { color: var(--muted); }
.text-accent { color: var(--primary-light); }
.text-right  { text-align: right; }

.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }

.flex         { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8        { gap: 8px; }
.gap-12       { gap: 12px; }
.gap-16       { gap: 16px; }
.flex-wrap    { flex-wrap: wrap; }

.empty-state { text-align: center; padding: 48px 24px; color: var(--muted); }
.empty-state h3 { font-size: 1.1rem; margin-bottom: 8px; color: var(--text); }

/* ── Cat mascot header ── */
.mascot-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
}

.mascot-cat svg {
  width: 140px;
  height: auto;
  filter: drop-shadow(0 0 24px rgba(139, 92, 246, 0.4));
}

/* ── Nav cat icon ── */
.nav-cat {
  display: inline-block;
  vertical-align: -4px;
  margin-right: 5px;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .grid-2 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .container { padding: 0 16px; }
  .nav { padding: 0 16px; gap: 16px; }
  .page-title { font-size: 1.4rem; }
}

@media (max-width: 500px) {
  .mascot-cat { display: none; }
}
