:root {
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #1c2129;
  --border: #30363d;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  --accent: #58a6ff;

  --color-bjj: #3b82f6;
  --color-cw: #f97316;
  --color-run: #22c55e;
  --color-wl: #a855f7;
  --color-other: #6b7280;

  --radius: 6px;
  --radius-lg: 10px;
}

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

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

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

/* ------------------------------------------------------------------ */
/* Header & tabs                                                       */
/* ------------------------------------------------------------------ */

header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem 0;
}

header h1 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--text-primary);
}

.tabs {
  display: flex;
  gap: 0;
}

.tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: color 0.15s, border-color 0.15s;
}

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

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ------------------------------------------------------------------ */
/* Tab panels                                                          */
/* ------------------------------------------------------------------ */

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
}

.tab-panel {
  display: none;
}

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

/* ------------------------------------------------------------------ */
/* Calendar                                                            */
/* ------------------------------------------------------------------ */

.calendar-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.calendar-controls button {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 1rem;
}

.calendar-controls button:hover {
  background: var(--border);
}

#calendar-year {
  font-size: 1.25rem;
  font-weight: 600;
}

.legend {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.month-block {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0.75rem;
}

.month-title {
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.day-header {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-align: center;
  padding: 0.15rem 0;
}

.day-cell {
  min-height: 32px;
  border-radius: 4px;
  padding: 2px;
  font-size: 0.6rem;
  position: relative;
}

.day-cell.has-entries {
  background: var(--bg-tertiary);
}

.day-number {
  font-size: 0.6rem;
  color: var(--text-muted);
  display: block;
  text-align: right;
  line-height: 1;
  margin-bottom: 1px;
}

.day-cell.today .day-number {
  color: var(--accent);
  font-weight: 700;
}

.entry-pill {
  display: block;
  padding: 1px 3px;
  border-radius: 3px;
  font-size: 0.55rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
  cursor: default;
  line-height: 1.3;
}

.entry-pill.clickable {
  cursor: pointer;
  opacity: 0.9;
}

.entry-pill.clickable:hover {
  opacity: 1;
  filter: brightness(1.15);
}

.entry-pill.type-bjj  { background: var(--color-bjj); }
.entry-pill.type-cw   { background: var(--color-cw); }
.entry-pill.type-run  { background: var(--color-run); }
.entry-pill.type-wl   { background: var(--color-wl); }
.entry-pill.type-other { background: var(--color-other); }

/* ------------------------------------------------------------------ */
/* BJJ graph                                                           */
/* ------------------------------------------------------------------ */

.graph-controls {
  margin-bottom: 1rem;
}

.graph-controls label {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.graph-controls select {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.25rem 0.5rem;
  font-size: 0.85rem;
  margin-left: 0.35rem;
}

#bjj-graph {
  width: 100%;
  height: 600px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.tooltip {
  position: fixed;
  z-index: 200;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  max-width: 360px;
  font-size: 0.8rem;
  color: var(--text-primary);
  pointer-events: none;
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
}

.tooltip.hidden {
  display: none;
}

.tooltip h3 {
  font-size: 0.9rem;
  margin-bottom: 0.35rem;
  color: var(--accent);
}

.tooltip .meta {
  color: var(--text-secondary);
  font-size: 0.75rem;
  margin-bottom: 0.25rem;
}

.tooltip .tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin: 0.35rem 0;
}

.tooltip .tag {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 0.65rem;
  color: var(--text-secondary);
}

.tooltip .description {
  margin-top: 0.35rem;
  line-height: 1.4;
}

.tooltip .original {
  margin-top: 0.35rem;
  font-style: italic;
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* ------------------------------------------------------------------ */
/* Weightlifting tracker                                               */
/* ------------------------------------------------------------------ */

#lifts-container {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.lift-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  transition: border-color 0.3s;
}

.lift-card.highlight {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.lift-card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.75rem;
}

.lift-card-header h2 {
  font-size: 1rem;
  font-weight: 600;
}

.lift-card-header .code {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: monospace;
}

.lift-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
  font-size: 0.8rem;
}

.lift-table th {
  text-align: left;
  color: var(--text-muted);
  font-weight: 500;
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--border);
}

.lift-table td {
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid rgba(48, 54, 61, 0.5);
}

.lift-table tr.highlight-row td {
  background: rgba(88, 166, 255, 0.08);
}

.lift-chart-container {
  height: 180px;
  position: relative;
}

/* ------------------------------------------------------------------ */
/* Responsive                                                          */
/* ------------------------------------------------------------------ */

@media (max-width: 600px) {
  header {
    padding: 0.5rem 1rem 0;
  }

  main {
    padding: 1rem;
  }

  .calendar-grid {
    grid-template-columns: 1fr;
  }

  #bjj-graph {
    height: 400px;
  }

  .lift-chart-container {
    height: 140px;
  }
}
