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

/* ============ THEME ============ */
/* Light by default; dark via data-theme on <html> (set in index.html, toggled in app.js) */
:root {
  color-scheme: light;
  --bg: #EEF0EC;
  --bg-card: #FFFFFF;
  --bg-card-hover: #F6F8F3;
  --bg-input: #F2F4EF;
  --border: #E1E5DE;
  --border-light: #C9CFC4;
  --text: #121411;
  --text-secondary: #4A5146;
  --text-muted: #737A70;

  --lime: #D4F542;
  --on-lime: #121411;
  --accent-ink: #4E7A0E;
  --accent-glow: rgba(212, 245, 66, 0.35);

  --tab-active-bg: #121411;
  --tab-active-fg: #D4F542;
  --hero-bg: #121411;
  --hero-fg: #F4F7EE;
  --hero-track: rgba(212, 245, 66, 0.18);
  --hero-accent: #D4F542;

  --done-bg: #F6FADF;
  --done-border: #DDEB9A;
  --check-bg: #121411;
  --check-fg: #D4F542;

  --danger: #C8372A;
  --danger-soft: rgba(200, 55, 42, 0.1);
  --good: #1E8A3C;
  --good-soft: rgba(30, 138, 60, 0.12);

  --chart-line: #121411;
  --chart-fill: rgba(140, 180, 20, 0.28);
  --chart-grid: #E6E9E2;
  --chart-tick: #737A70;

  /* Calendar & summary: one color per kind of workout. Light steps are darker
     so rings and bars read on white; validated for colorblind separation */
  --act-gym: #9EC21A;
  --act-bike: #D04E1E;
  --act-hyrox: #0FA08A;
  --act-other: #9284F2;

  --nav-bg: rgba(255, 255, 255, 0.92);

  --overlay: rgba(18, 20, 17, 0.45);
  --shadow: 0 1px 2px rgba(18, 20, 17, 0.04);
  --shadow-lg: 0 12px 32px -8px rgba(18, 20, 17, 0.25);

  --radius: 14px;
  --radius-lg: 20px;
  --font: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0F110E;
  --bg-card: #1A1D18;
  --bg-card-hover: #21251F;
  --bg-input: #141712;
  --border: #262A23;
  --border-light: #3A4036;
  --text: #EEF2E8;
  --text-secondary: #B5BCAE;
  --text-muted: #8C9486;

  --accent-ink: #D4F542;
  --accent-glow: rgba(212, 245, 66, 0.2);

  --tab-active-bg: #D4F542;
  --tab-active-fg: #121411;
  --hero-bg: #D4F542;
  --hero-fg: #121411;
  --hero-track: rgba(18, 20, 17, 0.16);
  --hero-accent: #121411;

  --done-bg: #171C10;
  --done-border: #3A4A17;
  --check-bg: #D4F542;
  --check-fg: #121411;

  --danger: #FF6B5E;
  --danger-soft: rgba(255, 107, 94, 0.14);
  --good: #4ADE80;
  --good-soft: rgba(74, 222, 128, 0.14);

  --chart-line: #D4F542;
  --chart-fill: rgba(212, 245, 66, 0.22);
  --chart-grid: #23271F;
  --chart-tick: #8C9486;

  --act-gym: #D4F542;
  --act-bike: #FF8A3D;
  --act-hyrox: #2CC9A8;
  --act-other: #A99BFF;

  --nav-bg: rgba(20, 23, 18, 0.92);

  --overlay: rgba(0, 0, 0, 0.6);
  --shadow: none;
  --shadow-lg: 0 12px 32px -8px rgba(0, 0, 0, 0.6);
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  padding-bottom: calc(100px + env(safe-area-inset-bottom, 0px));
  overflow-x: hidden;
}

[hidden] { display: none !important; }

button, input, select { font-family: inherit; }

button:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent-ink);
  outline-offset: 2px;
}

.icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* ============ NAVBAR ============ */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 12px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.nav-logo {
  width: 34px;
  height: 34px;
  display: block;
}

.nav-title {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: var(--text);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ============ ROUTINE TABS ============ */
.routine-tabs {
  display: flex;
  gap: 8px;
  padding: 4px 16px 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.routine-tabs::-webkit-scrollbar { display: none; }

.nav-tab {
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.nav-tab.active {
  background: var(--tab-active-bg);
  color: var(--tab-active-fg);
  border-color: var(--tab-active-bg);
}

.nav-tab-add {
  color: var(--text-muted);
  border: 1px dashed var(--border-light);
  background: transparent;
  display: flex;
  align-items: center;
  padding: 8px 12px;
}

/* ============ PROGRESS ============ */
.progress-card {
  margin: 8px 16px 4px;
  padding: 16px;
  border-radius: var(--radius-lg);
  background: var(--hero-bg);
  color: var(--hero-fg);
  display: flex;
  align-items: center;
  gap: 16px;
}

.progress-ring {
  width: 64px;
  height: 64px;
  flex-shrink: 0;
}

.progress-ring circle {
  fill: none;
  stroke-width: 7;
}

.progress-ring .ring-track { stroke: var(--hero-track); }

.progress-ring .ring-bar {
  stroke: var(--hero-accent);
  stroke-linecap: round;
  transition: stroke-dashoffset 0.4s ease;
}

.progress-ring text {
  fill: var(--hero-fg);
  font-size: 15px;
  font-weight: 800;
  font-family: var(--font);
}

.progress-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.progress-title {
  font-size: 16px;
  font-weight: 800;
}

.progress-sub {
  font-size: 12.5px;
  opacity: 0.75;
}

/* ============ ROUTINE HEADER ============ */
.routine-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 16px 10px;
  gap: 12px;
}

.routine-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.4px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.routine-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-icon .icon { width: 17px; height: 17px; }
.btn-icon:active { background: var(--bg-card-hover); }
.btn-icon.danger { color: var(--danger); }

/* ============ EXERCISES ============ */
.exercises {
  padding: 0 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.exercise-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: background 0.25s, border-color 0.25s;
  position: relative;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.exercise-card.dragging {
  transition: box-shadow 0.2s, border-color 0.2s, scale 0.2s;
  scale: 1.02;
  z-index: 10;
  border-color: var(--accent-ink);
  box-shadow: var(--shadow-lg), 0 0 0 3px var(--accent-glow);
  cursor: grabbing;
}

.exercise-card.done {
  background: var(--done-bg);
  border-color: var(--done-border);
}

.exercise-top {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.exercise-check {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  border: 2px solid var(--border-light);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
  color: transparent;
}

.exercise-check .icon { width: 15px; height: 15px; }

.exercise-card.done .exercise-check {
  background: var(--check-bg);
  border-color: var(--check-bg);
  color: var(--check-fg);
}

.exercise-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.exercise-name {
  font-size: 15.5px;
  font-weight: 800;
  letter-spacing: -0.2px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  overflow-wrap: anywhere;
}

.exercise-card.done .exercise-name { color: var(--text-muted); }

.pr-badge {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 3px 7px;
  border-radius: 6px;
  background: var(--lime);
  color: var(--on-lime);
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.pr-badge .icon { width: 11px; height: 11px; }

.exercise-meta {
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 600;
}

.exercise-weight {
  text-align: right;
  flex-shrink: 0;
  max-width: 40%;
}

.exercise-weight b {
  display: block;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.exercise-weight small {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 700;
}

/* Last log */
.last-log {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  border-radius: 12px;
  background: var(--bg-input);
  font-size: 12.5px;
}

.last-log-date {
  color: var(--text-muted);
  font-weight: 600;
  flex-shrink: 0;
}

.last-log-reps {
  color: var(--text);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* Actions */
.exercise-actions {
  display: flex;
  gap: 8px;
}

.btn-log {
  flex: 1;
  padding: 11px;
  border-radius: 13px;
  border: none;
  background: var(--lime);
  color: var(--on-lime);
  font-size: 13.5px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s;
}

.btn-log .icon { width: 16px; height: 16px; }
.btn-log:active { transform: scale(0.98); }

.exercise-card.done .btn-log {
  background: transparent;
  color: var(--text-muted);
  border: 1px dashed var(--border-light);
}

.btn-history {
  width: 44px;
  border-radius: 13px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.btn-history:active { background: var(--bg-card-hover); }

.btn-small {
  padding: 7px 12px;
  border-radius: 10px;
  border: none;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--lime);
  color: var(--on-lime);
  flex-shrink: 0;
}

.btn-small:active { opacity: 0.7; }

.btn-danger-full {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--danger-soft);
  background: transparent;
  color: var(--danger);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 12px;
  transition: all 0.2s;
}

.btn-danger-full:active { background: var(--danger-soft); }

/* ============ MODAL ============ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 200;
  align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(6px);
}

.modal-overlay.active { display: flex; }

.modal {
  background: var(--bg-card);
  width: 100%;
  max-width: 500px;
  border-radius: 24px 24px 0 0;
  padding: 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  max-height: 85dvh;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
  border: 1px solid var(--border);
  border-bottom: none;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-handle {
  width: 36px;
  height: 4px;
  background: var(--border-light);
  border-radius: 4px;
  margin: 0 auto 16px;
}

.modal h2 {
  font-size: 18px;
  margin-bottom: 16px;
  font-weight: 800;
  letter-spacing: -0.3px;
}

.modal h3 {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 800;
}

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

.form-group label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--accent-ink);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Series rows */
.series-header {
  display: grid;
  grid-template-columns: 54px 1fr 20px 1fr;
  gap: 8px;
  align-items: center;
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 800;
  margin-bottom: 8px;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.series-row {
  display: grid;
  grid-template-columns: 54px 1fr 20px 1fr;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.series-label {
  font-size: 12px;
  font-weight: 800;
  color: var(--text-muted);
}

.series-weight,
.series-reps {
  width: 100%;
  padding: 12px 8px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  outline: none;
  transition: all 0.2s;
}

.series-weight:focus,
.series-reps:focus {
  border-color: var(--accent-ink);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.series-x {
  text-align: center;
  color: var(--text-muted);
  font-weight: 800;
  font-size: 13px;
}

/* Buttons */
.btn-primary {
  width: 100%;
  padding: 14px;
  border-radius: 14px;
  border: none;
  background: var(--lime);
  color: var(--on-lime);
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  margin-top: 8px;
  transition: all 0.2s;
}

.btn-primary:active {
  transform: scale(0.98);
  opacity: 0.9;
}

.btn-secondary {
  width: 100%;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
}

/* ============ BACKUPS ============ */
.modal-text {
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

.modal h3.modal-section { margin: 18px 0 10px; }

.backup-actions {
  display: flex;
  gap: 8px;
}

.backup-actions .btn-secondary {
  margin-top: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* ============ HISTORY / LISTS ============ */
.history-list {
  max-height: 400px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-radius: 12px;
  background: var(--bg-input);
}

.history-item > div { min-width: 0; }

.history-date {
  font-size: 14px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.history-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.empty-list {
  color: var(--text-muted);
  text-align: center;
  padding: 20px;
}

.history-table {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.history-table-head {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 30px;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.history-table-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 30px;
  padding: 10px 12px;
  background: var(--bg-input);
  border-radius: 12px;
  align-items: center;
  font-variant-numeric: tabular-nums;
}

.history-cell-date {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 700;
}

.history-cell-series {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.history-cell-weight {
  font-size: 13px;
  font-weight: 800;
  color: var(--accent-ink);
}

.history-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.history-delete .icon { width: 15px; height: 15px; }

/* ============ CHART SECTION ============ */
.chart-section {
  margin-top: 14px;
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  border-radius: var(--radius-lg);
}

.chart-section-title {
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 12px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.chart-exercise-select {
  width: 100%;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background-color: var(--bg-input);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 12px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23737A70' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.chart-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  background: var(--bg-input);
  border-radius: 12px;
  padding: 4px;
}

.chart-tab {
  flex: 1;
  padding: 8px 4px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s;
}

.chart-tab.active {
  background: var(--tab-active-bg);
  color: var(--tab-active-fg);
}

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

/* ============ BOTTOM NAV ============ */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 90;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 8px 24px calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--nav-bg);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  padding: 2px 0;
}

.bottom-nav-icon {
  display: flex;
  padding: 5px 18px;
  border-radius: 999px;
  transition: background 0.2s, color 0.2s;
}

.bottom-nav-icon .icon { width: 21px; height: 21px; }

.bottom-nav-item.active { color: var(--text); }

.bottom-nav-item.active .bottom-nav-icon {
  background: var(--lime);
  color: var(--on-lime);
}

/* ============ FAB ============ */
.fab {
  width: 56px;
  height: 56px;
  margin-top: -30px;
  border-radius: 18px;
  background: var(--lime);
  color: var(--on-lime);
  border: none;
  cursor: pointer;
  box-shadow: 0 10px 24px -8px rgba(18, 20, 17, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.fab .icon { width: 24px; height: 24px; }
.fab:active { transform: scale(0.92); }

/* ============ CALENDAR ============ */
.calendar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 16px 12px;
}

.calendar-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.4px;
  text-transform: capitalize;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 0;
}

.calendar-nav {
  display: flex;
  gap: 6px;
}

.month-summary {
  margin: 0 16px;
  padding: 16px;
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 16px;
}

.month-total {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.month-total b {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.month-total span {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  margin-top: 4px;
}

.month-compare {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-width: 0;
}

.month-compare-note {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-muted);
}

.trend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.trend .icon { width: 15px; height: 15px; }

.trend-up { background: var(--good-soft); color: var(--good); }
.trend-down { background: var(--danger-soft); color: var(--danger); }
.trend-flat { background: var(--bg-input); color: var(--text-muted); }

.act-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.calendar-card {
  margin: 12px 16px 0;
  padding: 12px;
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

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

.cal-weekday {
  text-align: center;
  font-size: 11px;
  font-weight: 800;
  color: var(--text-muted);
  padding: 2px 0 6px;
}

/* Each day is a circle; trained days get a colored ring (--ring, set inline) */
.cal-day {
  aspect-ratio: 1;
  width: 100%;
  max-width: 52px;
  justify-self: center;
  border-radius: 50%;
  border: none;
  padding: 5px;
  background: transparent;
  background-clip: content-box;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  isolation: isolate;
  transition: transform 0.15s;
}

.cal-day:active { transform: scale(0.92); }
.cal-day.future { color: var(--text-muted); }
.cal-day.trained { font-weight: 800; }
.cal-day.selected.trained { color: var(--tab-active-fg); }

.cal-day.trained::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--ring);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3.5px), #000 calc(100% - 3px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 3.5px), #000 calc(100% - 3px));
  z-index: -1;
}

.cal-day.today { background-color: var(--bg-input); }

.cal-day.selected {
  background-color: var(--tab-active-bg);
  color: var(--tab-active-fg);
}

.cal-day:focus-visible {
  outline: 2px solid var(--accent-ink);
  outline-offset: 1px;
}

.calendar-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

.calendar-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.day-detail {
  margin: 12px 16px 0;
  padding: 16px;
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.day-detail-title {
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 4px;
}

.day-detail-title::first-letter { text-transform: uppercase; }

.day-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 12px;
  background: var(--bg-input);
}

.day-item-info {
  flex: 1;
  min-width: 0;
}

.day-item-title {
  font-size: 14px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.day-item-sub {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 2px;
  overflow-wrap: anywhere;
}

.day-empty {
  font-size: 13px;
  color: var(--text-muted);
  padding: 4px 0;
}

.day-detail .btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.day-detail .btn-primary .icon { width: 18px; height: 18px; }

/* Month report: bars per routine / workout, and last 6 months */
.month-report {
  margin: 12px 16px 0;
  padding: 16px;
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.report-title {
  font-size: 16px;
  font-weight: 800;
}

.report-title::first-letter { text-transform: uppercase; }

.report-subtitle {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 6px;
}

.report-rows {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.report-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.report-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13.5px;
  font-weight: 800;
}

.report-row-name {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.report-row-value {
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.report-row-value small {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.report-track {
  height: 8px;
  border-radius: 4px;
  background: var(--bg-input);
  overflow: hidden;
}

.report-bar {
  height: 100%;
  border-radius: 4px;
  min-width: 8px;
}

.month-chart {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  height: 160px;
}

.month-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 0;
  height: 100%;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 0;
}

.month-col-plot {
  flex: 1;
  width: 100%;
  max-width: 34px;
  display: flex;
  flex-direction: column-reverse;
  gap: 2px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 2px;
}

.month-col-seg {
  width: 100%;
  border-radius: 4px;
  flex-shrink: 0;
}

.month-col-total {
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  font-variant-numeric: tabular-nums;
  padding-bottom: 2px;
}

.month-col-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
}

.month-col.current .month-col-label {
  color: var(--text);
  font-weight: 800;
}

.month-col:not(.current) .month-col-seg { opacity: 0.55; }

/* Add workout: type picker */
.type-picker {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.type-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  transition: border-color 0.2s;
}

.type-option.active { border-color: var(--text); }
.type-option .act-dot { width: 14px; height: 14px; }

/* ============ EMPTY STATE ============ */
.empty-state {
  text-align: center;
  padding: 56px 20px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.empty-state .empty-icon {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}

.empty-state .empty-icon .icon { width: 26px; height: 26px; }

.empty-state strong {
  color: var(--text);
  font-size: 15px;
}

/* ============ TOAST ============ */
.toast {
  position: fixed;
  bottom: calc(100px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--tab-active-bg);
  color: var(--tab-active-fg);
  padding: 12px 22px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 800;
  z-index: 300;
  opacity: 0;
  transition: all 0.3s;
  box-shadow: var(--shadow-lg);
  max-width: calc(100% - 32px);
  text-align: center;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ============ LOGIN SCREEN ============ */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.login-logo {
  width: 64px;
  height: 64px;
  background: var(--lime);
  color: var(--on-lime);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 28px;
  margin: 0 auto 16px;
}

.login-logo .icon { width: 30px; height: 30px; }

/* The app logo carries its own tile and corners */
img.login-logo {
  width: 80px;
  height: 80px;
  background: none;
  display: block;
}

.login-title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}

.login-subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 32px;
}

.login-form {
  display: flex;
  flex-direction: column;
}

.login-input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
  margin-bottom: 12px;
}

.login-input:focus {
  border-color: var(--accent-ink);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.login-input::placeholder { color: var(--text-muted); }

.login-error {
  color: var(--danger);
  font-size: 13px;
  font-weight: 700;
  min-height: 20px;
  margin-top: 8px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
  }
}
