/* Gym Tracker — dark, phone-first */
:root {
  --bg: #0f1115;
  --card: #1a1d24;
  --card-2: #22262f;
  --text: #e8eaed;
  --muted: #8b93a1;
  --accent: #4ade80;
  --accent-dim: #1e3a2f;
  --orange: #fdba74;
  --orange-dim: #3a2e1e;
  --blue: #93c5fd;
  --blue-dim: #1e2f3a;
  --danger: #f87171;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 84px; /* room for footer */
  line-height: 1.45;
}

/* Header */
.app-header {
  position: sticky; top: 0; z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid #262a33;
  padding: 12px 16px 0;
}
.header-top { display: flex; align-items: center; justify-content: space-between; }
.app-header h1 { font-size: 1.25rem; font-weight: 700; }
.save-status { font-size: .78rem; color: var(--muted); }
.save-status.ok { color: var(--accent); }
.save-status.err { color: var(--danger); }

.tabs { display: flex; gap: 4px; margin-top: 8px; }
.tab {
  flex: 1; padding: 10px 0; border: none; background: none;
  color: var(--muted); font-size: 1rem; font-weight: 600;
  border-bottom: 2px solid transparent; cursor: pointer;
}
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Layout */
main { max-width: 560px; margin: 0 auto; padding: 14px 16px; }
.view { display: block; }
.hidden { display: none !important; }

.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px;
  margin-bottom: 14px;
}
.section-title { font-size: 1.02rem; font-weight: 700; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.count-badge {
  margin-left: auto; font-size: .78rem; font-weight: 700; color: var(--accent);
  background: var(--accent-dim); border-radius: 999px; padding: 2px 10px;
}

/* Date nav */
.date-nav { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.icon-btn {
  width: 42px; height: 42px; border: none; border-radius: 10px;
  background: var(--card); color: var(--text); font-size: 1.15rem; cursor: pointer;
  flex-shrink: 0;
}
.date-nav input[type="date"] {
  flex: 1; min-width: 0; background: var(--card); color: var(--text);
  border: 1px solid #2c313b; border-radius: 10px; padding: 10px 8px; font-size: 1rem;
  color-scheme: dark;
}
.ghost-btn {
  background: var(--card); color: var(--accent); border: 1px solid var(--accent-dim);
  border-radius: 10px; padding: 9px 12px; font-size: .9rem; font-weight: 600; cursor: pointer;
  flex-shrink: 0;
}
.day-title { font-size: .85rem; color: var(--muted); margin-bottom: 12px; text-align: center; }

/* Metrics */
.metric-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.metric { display: flex; flex-direction: column; gap: 4px; }
.metric span { font-size: .8rem; color: var(--muted); }
.metric input {
  background: var(--card-2); border: 1px solid #2c313b; border-radius: 10px;
  color: var(--text); padding: 11px 12px; font-size: 1.05rem; width: 100%;
  color-scheme: dark;
}

/* Checklist items */
.check-list { display: flex; flex-direction: column; gap: 8px; }
.check-item {
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--card-2); border: 1px solid #262a33;
  border-radius: 10px; padding: 12px; cursor: pointer; user-select: none;
}
.check-item:active { transform: scale(.99); }
.check-item .checkbox {
  width: 24px; height: 24px; border-radius: 7px; border: 2px solid #3a4150;
  background: var(--bg); flex-shrink: 0; margin-top: 1px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: transparent; transition: all .12s;
}
.check-item.checked .checkbox { background: var(--accent); border-color: var(--accent); color: #0f1115; }
.check-item .label { flex: 1; min-width: 0; }
.check-item .label .name { font-weight: 600; font-size: .98rem; }
.check-item .label .sub { font-size: .8rem; color: var(--muted); margin-top: 2px; }
.check-item .label .cue { font-size: .78rem; color: var(--blue); margin-top: 1px; }
.check-item.checked .label .name { text-decoration: line-through; color: var(--muted); }

/* Progress */
.streak-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.streak-card {
  background: var(--card); border-radius: var(--radius); padding: 14px 10px;
  text-align: center; box-shadow: var(--shadow);
}
.streak-card .num { font-size: 1.7rem; font-weight: 800; }
.streak-card .lbl { font-size: .78rem; color: var(--muted); }
.streak-card.diet .num { color: var(--accent); }
.streak-card.gym .num { color: var(--orange); }
.streak-card.posture .num { color: var(--blue); }

.chart-wrap { position: relative; height: 220px; }

/* Week grid */
.week-grid { display: grid; grid-template-columns: repeat(8, auto); gap: 6px; align-items: center; }
.week-grid .col-h { font-size: .72rem; color: var(--muted); text-align: center; }
.week-grid .day-cell { text-align: center; }
.week-grid .day-cell .d { font-size: .72rem; color: var(--muted); }
.week-grid .cell-row { display: flex; gap: 3px; justify-content: center; margin-top: 2px; }
.week-grid .dot { width: 14px; height: 14px; border-radius: 4px; background: #262a33; }
.week-grid .dot.done { background: var(--accent); }
.week-grid .dot.part { background: var(--accent-dim); }
.week-grid .dot.o { background: var(--orange); }
.week-grid .dot.op { background: var(--orange-dim); }
.week-grid .dot.b { background: var(--blue); }
.week-grid .dot.bp { background: var(--blue-dim); }

/* Heatmap */
.heatmap-block h3 { font-size: .9rem; color: var(--muted); margin: 10px 0 6px; }
.heatmap { display: grid; grid-auto-flow: column; grid-auto-columns: 14px; gap: 3px; overflow-x: auto; padding-bottom: 4px; }
.hm-col { display: grid; grid-template-rows: repeat(7, 14px); gap: 3px; }
.hm-cell { border-radius: 3px; background: #23262e; }
.hm-cell.l1 { background: #123f2a; }
.hm-cell.l2 { background: #1b6b3f; }
.hm-cell.l3 { background: #2ea653; }
.hm-cell.l4 { background: #4ade80; }
.hm-cell.g1 { background: #3a2b14; }
.hm-cell.g2 { background: #7a5517; }
.hm-cell.g3 { background: #c98a1b; }
.hm-cell.g4 { background: #fdba74; }
.hm-cell.b1 { background: #1e2f3a; }
.hm-cell.b2 { background: #2f4a63; }
.hm-cell.b3 { background: #4c7ea8; }
.hm-cell.b4 { background: #93c5fd; }
.hm-cell.today { outline: 1px solid var(--text); }

/* Backup / buttons */
.backup-row { display: flex; gap: 10px; }
.btn {
  display: inline-block; background: var(--card-2); color: var(--text);
  border: 1px solid #2c313b; border-radius: 10px; padding: 11px 16px;
  font-size: .95rem; font-weight: 600; cursor: pointer; text-align: center;
}
.btn-primary, .primary-btn { background: var(--accent); color: #0f1115; border: none; font-weight: 700; }
.btn-secondary { background: none; }

/* Footer */
.app-footer {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  background: var(--bg); border-top: 1px solid #262a33;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  max-width: 560px; margin: 0 auto;
}
.primary-btn { width: 100%; padding: 14px; font-size: 1.05rem; }

/* Toast */
.toast {
  position: fixed; bottom: 92px; left: 50%; transform: translateX(-50%);
  background: var(--card-2); color: var(--text); border: 1px solid #2c313b;
  border-radius: 999px; padding: 8px 18px; font-size: .85rem;
  z-index: 30; box-shadow: var(--shadow); transition: opacity .2s;
}
.toast.hidden { opacity: 0; pointer-events: none; }

@media (max-width: 360px) {
  .streak-grid { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: 1fr; }
}
