/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:         #0f172a;
  --card:       #111827;
  --card2:      #141e2e;
  --border:     #1e293b;
  --accent:     #38bdf8;
  --accent-dim: #0ea5e9;
  --text:       #e5e7eb;
  --muted:      #9ca3af;
  --danger:     #f87171;

  --check-size: 40px;
  --col-width:  88px;
  --label-w:    160px;
  --radius:     8px;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--bg), #020617);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ── Header (mirrors brokehsite) ── */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 2rem;
}

.logo {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--accent);
  text-decoration: none;
}

/* ── Hamburger ── */
.hamburger {
  width: 28px;
  height: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  z-index: 110;
}
.hamburger span {
  height: 3px;
  background: var(--text);
  border-radius: 2px;
  transition: 0.3s;
}

/* ── Slide-out menu ── */
.menu {
  position: fixed;
  top: 0;
  right: -260px;
  width: 260px;
  height: 100vh;
  background: var(--card);
  padding: 2rem;
  transition: right 0.3s ease;
  box-shadow: -10px 0 30px rgba(0,0,0,0.4);
  z-index: 100;
}
.menu.open { right: 0; }
.menu ul { list-style: none; margin-top: 3rem; }
.menu li { margin-bottom: 1.25rem; }
.menu a {
  text-decoration: none;
  color: var(--text);
  font-size: 1rem;
  transition: color 0.2s;
}
.menu a:hover, .menu a.active { color: var(--accent); }

/* ── Main ── */
main {
  padding: 0 1.5rem 3rem;
  max-width: 1200px;
  margin: 0 auto;
}

/* ── Page header ── */
.page-header { margin-bottom: 1.75rem; }

.badge {
  display: inline-block;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent);
  font-weight: 600;
  font-size: 0.8rem;
  margin-bottom: 0.75rem;
}

.page-title {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.page-subtitle {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.controls-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.progress-wrap {
  flex: 1;
  min-width: 120px;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s ease;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.4);
}

.progress-label {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
}

.btn-reset {
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--bg);
  background: var(--accent);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(56, 189, 248, 0.3);
  transition: all 0.2s ease;
  touch-action: manipulation;
  white-space: nowrap;
}
.btn-reset:hover { background: var(--accent-dim); transform: translateY(-1px); }
.btn-reset:active { transform: translateY(0); }

/* ── Grid scroll wrapper ── */
.grid-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--card);
  border-radius: 1rem;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}

/* ── Table ── */
.tracker {
  border-collapse: separate;
  border-spacing: 0;
  min-width: max-content;
  width: 100%;
}

.week-head {
  background: var(--card);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--accent);
  text-align: center;
  padding: 10px 4px 6px;
  border-bottom: 1px solid var(--border);
}
.week-head.wk-2, .week-head.wk-4, .week-head.wk-6 { background: var(--card2); }

.day-head {
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--muted);
  text-align: center;
  padding: 4px 4px 8px;
  min-width: var(--col-width);
  width: var(--col-width);
  border-bottom: 1px solid var(--border);
  vertical-align: bottom;
}
.day-head.wk-2, .day-head.wk-4, .day-head.wk-6 { background: var(--card2); }

/* ── Themed fields (match check-btn look) ── */
.day-date,
.day-note {
  display: block;
  width: 100%;
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  color-scheme: dark;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.day-date {
  font-size: 0.6rem;
  font-weight: 500;
  padding: 6px 4px;
  min-height: var(--check-size);
  cursor: pointer;
  text-align: center;
}

.day-date:hover,
.day-note:hover {
  border-color: #2a3a55;
}

.day-date:focus,
.day-note:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.25);
  background: rgba(56, 189, 248, 0.05);
}

.day-date.has-value {
  color: var(--accent);
  border-color: rgba(56, 189, 248, 0.45);
  background: rgba(56, 189, 248, 0.08);
}

.day-date::-webkit-datetime-edit {
  padding: 0;
  line-height: 1.2;
}

.day-date::-webkit-datetime-edit-fields-wrapper {
  padding: 0;
}

.day-date::-webkit-datetime-edit-text,
.day-date::-webkit-datetime-edit-month-field,
.day-date::-webkit-datetime-edit-day-field,
.day-date::-webkit-datetime-edit-year-field {
  color: var(--muted);
  font-size: 0.58rem;
  padding: 0 1px;
}

.day-date.has-value::-webkit-datetime-edit-text,
.day-date.has-value::-webkit-datetime-edit-month-field,
.day-date.has-value::-webkit-datetime-edit-day-field,
.day-date.has-value::-webkit-datetime-edit-year-field {
  color: var(--accent);
  font-weight: 600;
}

.day-date::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.75;
  filter: invert(72%) sepia(52%) saturate(1200%) hue-rotate(175deg) brightness(103%);
  width: 12px;
  height: 12px;
  padding: 0;
  margin: 0;
}

.day-date::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}

/* ── Sticky left column ── */
.sticky-col {
  position: sticky;
  left: 0;
  z-index: 10;
  background: var(--card);
  min-width: var(--label-w);
  max-width: var(--label-w);
  width: var(--label-w);
}
.sticky-col::after {
  content: '';
  position: absolute;
  top: 0; right: -8px;
  width: 8px; height: 100%;
  background: linear-gradient(to right, rgba(0,0,0,0.25), transparent);
  pointer-events: none;
}
.head-ex {
  font-size: 0.7rem;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 10px 14px 6px;
  vertical-align: bottom;
  border-bottom: 1px solid var(--border);
}

/* ── Exercise cell ── */
.ex-cell {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.ex-name {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}
.ex-info {
  display: block;
  font-size: 0.68rem;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.3;
}

/* ── Checkbox cells ── */
.check-cell {
  text-align: center;
  vertical-align: middle;
  padding: 6px 4px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}
.check-cell.wk-2, .check-cell.wk-4, .check-cell.wk-6 { background: var(--card2); }

.check-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--check-size);
  height: var(--check-size);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s, border-color 0.15s, transform 0.1s, box-shadow 0.15s;
}
.check-btn:active { transform: scale(0.85); }
.check-btn .icon-check {
  width: 17px;
  height: 17px;
  stroke: transparent;
  transition: stroke 0.12s;
}
.check-btn[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.35);
}
.check-btn[aria-pressed="true"] .icon-check {
  stroke: #0f172a;
}

/* Alternating rows — sticky col picks up the alternation */
tbody tr:nth-child(even) .sticky-col { background: var(--card2); }
tbody tr:nth-child(even) .check-cell.wk-1,
tbody tr:nth-child(even) .check-cell.wk-3,
tbody tr:nth-child(even) .check-cell.wk-5 { background: var(--card2); }
tbody tr:nth-child(even) .check-cell.wk-2,
tbody tr:nth-child(even) .check-cell.wk-4,
tbody tr:nth-child(even) .check-cell.wk-6 { background: #0f1827; }

/* ── Notes row ── */
.notes-row .sticky-col {
  background: var(--card);
  vertical-align: top;
  padding: 12px 14px 10px;
  border-bottom: none;
  border-top: 1px solid var(--border);
}
.notes-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}
.notes-cell {
  vertical-align: top;
  padding: 8px 4px 10px;
  background: var(--card);
  border-bottom: none;
  border-top: 1px solid var(--border);
}
.notes-cell.wk-2, .notes-cell.wk-4, .notes-cell.wk-6 { background: var(--card2); }

.day-note {
  min-height: 56px;
  font-size: 0.65rem;
  line-height: 1.4;
  padding: 7px 8px;
  resize: vertical;
}
.day-note::placeholder {
  color: var(--muted);
  opacity: 0.65;
  font-style: italic;
}
.day-note:not(:placeholder-shown) {
  border-color: rgba(56, 189, 248, 0.35);
  background: rgba(56, 189, 248, 0.04);
}

/* ── Scroll hint ── */
.scroll-hint {
  text-align: center;
  margin-top: 0.75rem;
  font-size: 0.72rem;
  color: var(--muted);
  transition: opacity 0.4s;
}
.scroll-hint.hidden { opacity: 0; pointer-events: none; }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.modal-overlay[hidden] { display: none; }

.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 2rem 1.75rem 1.5rem;
  max-width: 280px;
  width: calc(100% - 3rem);
  text-align: center;
  box-shadow: 0 20px 40px rgba(0,0,0,0.5);
}
.modal p { font-size: 0.95rem; line-height: 1.6; margin-bottom: 1.5rem; color: var(--text); }
.modal small { color: var(--muted); }
.modal-btns { display: flex; gap: 0.625rem; }
.modal-btns button {
  flex: 1;
  padding: 0.7rem;
  border-radius: 999px;
  border: none;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  transition: all 0.2s;
}
.btn-danger {
  background: var(--danger);
  color: #0f172a;
  box-shadow: 0 4px 12px rgba(248, 113, 113, 0.3);
}
.btn-danger:hover { background: #ef4444; transform: translateY(-1px); }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #2a3a55; }

/* ── Responsive ── */
@media (min-width: 768px) {
  :root { --label-w: 200px; --col-width: 96px; --check-size: 42px; }
  .page-title { font-size: 2rem; }
  main { padding: 0 2rem 4rem; }
}
