:root {
  --bg: #f6f3ee;
  --surface: #fffaf2;
  --surface-strong: #ffffff;
  --ink: #20211f;
  --muted: #6b6f68;
  --line: #ded7cc;
  --green: #26735d;
  --green-dark: #185445;
  --coral: #c9583f;
  --gold: #b8871f;
  --mist: #e7f0ea;
  --shadow: 0 12px 30px rgba(40, 35, 26, 0.08);

  /* Completed-workout activity colors (see README "Calendar workout colors").
     Each category is a single accent used for the border / status badge; the
     soft workout background is derived from it. These defaults are overridden
     per user via inline custom properties on the calendar grid. */
  --activity-swim: #1f6f8b;
  --activity-bike: #5f6b66;
  --activity-run: #2e7d32;
  --activity-other: #c2772b;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  letter-spacing: 0;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.68), rgba(255, 255, 255, 0)),
    var(--bg);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 68px;
  padding: 12px clamp(16px, 4vw, 42px);
  border-bottom: 1px solid rgba(222, 215, 204, 0.8);
  background: rgba(246, 243, 238, 0.94);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  white-space: nowrap;
}

.brand-mark {
  display: block;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  object-fit: contain;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  flex-wrap: wrap;
  /* overflow must stay visible so the Exercises dropdown isn't clipped */
  overflow: visible;
}

.main-nav a,
.ghost-button {
  min-height: 38px;
  padding: 9px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
}

.main-nav a:hover,
.ghost-button:hover {
  color: var(--ink);
  background: rgba(38, 115, 93, 0.09);
}

.logout-form {
  margin: 0;
}

.lang-switcher {
  margin: 0;
}

.lang-switcher select {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.3);
  color: inherit;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.8rem;
  cursor: pointer;
}

.lang-switcher select option {
  background: #2c2c2c;
  color: #fff;
}

.page {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: clamp(18px, 4vw, 44px);
}

.stack {
  display: grid;
  gap: 18px;
}

.hero-panel,
.panel,
.card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 242, 0.88);
  box-shadow: var(--shadow);
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: clamp(22px, 4vw, 42px);
  padding: clamp(24px, 5vw, 56px);
}

.hero-copy {
  align-content: center;
}

.hero-copy h1,
.page-header h1 {
  margin: 0;
  font-size: clamp(2rem, 6vw, 4.6rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.hero-copy p,
.page-header p,
.muted {
  color: var(--muted);
}

.hero-copy p {
  max-width: 58ch;
  font-size: 1.08rem;
  line-height: 1.6;
}

.hero-metrics {
  display: grid;
  align-content: center;
  gap: 12px;
}

.metric-strip {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.metric-strip strong {
  display: block;
  font-size: 1.45rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.button,
button.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 15px;
  border: 1px solid var(--green);
  border-radius: 8px;
  color: #fff;
  background: var(--green);
  cursor: pointer;
  font-weight: 800;
}

.button:hover,
button.button:hover {
  background: var(--green-dark);
}

.button.secondary {
  border-color: var(--line);
  color: var(--ink);
  background: var(--surface-strong);
}

.button.warning {
  border-color: var(--coral);
  background: var(--coral);
}

.button.small {
  min-height: 36px;
  padding: 8px 12px;
  font-size: 0.92rem;
}

.button.danger {
  border-color: #c0392b;
  background: #c0392b;
  color: #fff;
}

.button.danger:hover,
.button.danger:focus {
  background: #a5281b;
  border-color: #a5281b;
}

.list-row-wrapper {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.list-row-wrapper .list-row {
  margin: 0;
}

.confirm-dialog {
  width: min(420px, calc(100% - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-strong);
  color: inherit;
}

.confirm-dialog::backdrop {
  background: rgba(20, 20, 20, 0.45);
}

.confirm-dialog form {
  display: grid;
  gap: 14px;
  padding: 20px;
  margin: 0;
}

.confirm-dialog h2 {
  margin: 0;
  font-size: 1.15rem;
}

.confirm-dialog p {
  margin: 0;
  color: var(--muted);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.page-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.page-header h1 {
  font-size: clamp(2rem, 5vw, 3.4rem);
}

.grid {
  display: grid;
  gap: 14px;
}

.grid.stats {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.grid.cards {
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

.panel,
.card {
  padding: 18px;
}

.stat {
  border-left: 5px solid var(--green);
}

.stat:nth-child(2) {
  border-left-color: var(--coral);
}

.stat:nth-child(3) {
  border-left-color: var(--gold);
}

.stat strong {
  display: block;
  margin-top: 6px;
  font-size: 2rem;
}

.card-title {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.card h2,
.card h3,
.panel h2,
.panel h3 {
  margin: 0 0 8px;
  font-size: 1.05rem;
  line-height: 1.25;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.badge.green {
  color: var(--green-dark);
  background: var(--mist);
  border-color: #bad5c8;
}

.filter-form,
.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.form-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

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

.pagination .pagination-links {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.pagination .pagination-status {
  color: var(--muted);
  font-weight: 600;
}

.form-card {
  width: min(760px, 100%);
}

.field {
  display: grid;
  gap: 7px;
}

.field label {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.field-check {
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
}

.field-check label {
  order: 2;
}

.form-control,
.form-select,
input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
input[type="search"],
input[type="email"],
input[type="url"],
input[type="tel"],
select,
textarea {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--surface-strong);
  color: var(--ink);
}

.field-hidden {
  display: none;
}

textarea {
  min-height: 104px;
  resize: vertical;
}

input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--green);
}

.help-text,
.field-error {
  font-size: 0.82rem;
}

.help-text {
  color: var(--muted);
}

.field-error,
.form-errors {
  color: #9c2f20;
}

.messages {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.message {
  padding: 12px 14px;
  border: 1px solid #bad5c8;
  border-radius: 8px;
  background: var(--mist);
}

.message.error {
  border-color: #e4b0a6;
  background: #fff0ed;
}

/* Advisor profile questionnaire ----------------------------------------- */
.advisor-section {
  margin: 0;
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.advisor-section > legend {
  margin-left: -4px;
  padding: 0 8px;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--ink);
}

.advisor-section .group-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 24px;
}

.advisor-section .group-fields > .field {
  flex: 1 1 100%;
  min-width: 0;
}

.advisor-section .group-fields > .field-check {
  flex: 0 1 240px;
}

/* Single checkbox: keep [box] [label] on one line, help text full-width below. */
.advisor-section .field-check {
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 10px;
  row-gap: 4px;
}

.advisor-section .field-check > label {
  order: 0;
  grid-row: 1;
  grid-column: 2;
}

.advisor-section .field-check > input[type="checkbox"] {
  grid-row: 1;
  grid-column: 1;
}

.advisor-section .field-check > .help-text,
.advisor-section .field-check > .field-error {
  grid-column: 1 / -1;
}

.field-label {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.field-disabled {
  opacity: 0.5;
}

.field-disabled .help-text {
  font-style: italic;
}

/* Multi-select checkbox groups rendered as readable selectable chips. */
.field-checkgroup .check-options > div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.field-checkgroup .check-options label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.field-checkgroup .check-options label:hover {
  border-color: var(--green);
}

.field-checkgroup .check-options label:focus-within {
  border-color: var(--green);
  box-shadow: 0 0 0 2px rgba(38, 115, 93, 0.25);
}

.field-checkgroup .check-options input[type="checkbox"] {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin: 0;
}

.field-checkgroup .check-options label:has(input:checked) {
  border-color: var(--green);
  background: var(--mist);
  color: var(--green-dark);
}

.form-error-summary {
  display: grid;
  gap: 4px;
}

.form-error-summary ul {
  margin: 4px 0 0;
  padding-left: 18px;
}

.table-list {
  display: grid;
  gap: 10px;
}

.list-row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(120px, 0.55fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.list-row strong {
  display: block;
}

.log-grid {
  display: grid;
  gap: 10px;
}

.log-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  overflow: hidden;
}

.log-group[open] {
  background: var(--surface-strong);
}

.log-group-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.log-group-summary::-webkit-details-marker {
  display: none;
}

.log-group-summary::before {
  content: "";
  flex: 0 0 auto;
  width: 0;
  height: 0;
  margin-right: 4px;
  border-left: 6px solid currentColor;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  transition: transform 0.15s ease;
}

.log-group[open] > .log-group-summary::before {
  transform: rotate(90deg);
}

.workout-map-panel {
  margin-bottom: 18px;
  padding: 0;
  overflow: hidden;
}

.workout-map-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  cursor: pointer;
  font-weight: 700;
  list-style: none;
}

.workout-map-summary::-webkit-details-marker {
  display: none;
}

.workout-map-summary::before {
  content: "▸";
  color: var(--muted);
  font-size: 0.9rem;
  transition: transform 0.15s ease;
}

.workout-map-panel[open] .workout-map-summary::before {
  transform: rotate(90deg);
}

.workout-map-title {
  flex: 1 1 auto;
}

.workout-map {
  height: 380px;
  width: 100%;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.workout-map .leaflet-container {
  font: inherit;
}

.log-group-name {
  flex: 1 1 auto;
  font-weight: 700;
}

.log-group-readout {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.log-readout-item {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.log-group-meta {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.88rem;
}

.log-group-remove {
  flex: 0 0 auto;
  color: var(--muted);
}

.log-group-remove:hover {
  color: var(--danger, #d6453d);
  border-color: var(--danger, #d6453d);
}

.log-group-body {
  display: grid;
  gap: 10px;
  padding: 0 12px 12px;
}

.log-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.log-row .field {
  min-width: 0;
}

.log-row .field label {
  font-size: 0.76rem;
}

.log-row .field input,
.log-row .field select,
.log-row .field textarea {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.log-row .field-check {
  align-self: end;
  padding-bottom: 8px;
}

.log-row .field-check input[type="checkbox"] {
  width: auto;
}

.log-exercise {
  grid-column: 1 / -1;
}

.log-notes {
  grid-column: 1 / -1;
}

.log-notes textarea {
  min-height: 76px;
}

.sequence-label {
  min-height: 18px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.empty-state {
  display: grid;
  gap: 12px;
  place-items: start;
  padding: 26px;
  border: 1px dashed #c8beb0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.42);
}

.empty-state p {
  margin: 0;
  color: var(--muted);
}

.inline-form {
  display: inline;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.42fr);
  gap: 16px;
  align-items: start;
}

/* Tabbed pane (used by the Review plans page). */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0 0 20px;
  border-bottom: 1px solid var(--line);
}

.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  margin-bottom: -1px;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: 0.01em;
  text-decoration: none;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.tab:hover {
  color: var(--ink);
  border-bottom-color: rgba(38, 115, 93, 0.35);
}

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

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

.tab.disabled:hover {
  color: var(--muted);
  border-bottom-color: transparent;
}

.tab-panel {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.tab-panel[hidden] {
  display: none;
}

/* Grid/flex children must allow shrinking so inner scrollers can clip. */
.tab-panel > * {
  min-width: 0;
}

.tab-panel .table-scroll {
  max-width: 100%;
}

/* Compact segmented toggle (Extended / Simplified). */
.segmented {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-strong);
}

.segmented a {
  padding: 6px 16px;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.92rem;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.segmented a:hover {
  color: var(--ink);
}

.segmented a.active {
  color: #fff;
  background: var(--green);
}

/* Plan picker row. */
.plan-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.checkpoint-form {
  display: grid;
  gap: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.5);
}

.checkpoint-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.checkbox-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.hard-checkpoint-fields {
  display: grid;
  gap: 6px;
  max-width: 320px;
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.42);
}

.hard-checkpoint-fields .field-hint {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.row-actions {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

@media (max-width: 820px) {
  .topbar {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
  }

  .main-nav {
    grid-column: 1 / -1;
    margin-left: 0;
    padding-bottom: 2px;
  }

  .logout-form {
    justify-self: end;
  }

  .hero-panel,
  .split,
  .grid.stats,
  .filter-form,
  .form-grid,
  .form-grid.two {
    grid-template-columns: 1fr;
  }

  .page-header {
    align-items: start;
    flex-direction: column;
  }

  .list-row {
    grid-template-columns: 1fr;
  }

  .log-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .page {
    padding: 16px;
  }

  .panel,
  .card,
  .hero-panel {
    padding: 16px;
  }

  .log-row {
    grid-template-columns: 1fr;
  }

  .actions .button,
  .actions button {
    width: 100%;
  }
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.calendar-day {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-strong);
  min-height: 200px;
}

.calendar-day.is-weekend {
  background: rgba(255, 255, 255, 0.55);
}

.calendar-day.is-past {
  opacity: 0.78;
}

.calendar-day.is-today {
  border-color: var(--accent, #c0392b);
  box-shadow: 0 0 0 1px var(--accent, #c0392b) inset;
}

.calendar-day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.calendar-day-weekday {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.calendar-day-date {
  display: block;
  font-size: 1.05rem;
}

.calendar-day-body {
  flex: 1 1 auto;
}

.calendar-workout {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.calendar-workout-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--line);
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1;
  color: var(--muted);
  background: var(--surface-strong);
}

.calendar-workout.is-completed {
  /* Default completed accent is the run green; activity modifiers below
     override it per category. The soft background is derived from the accent
     so user-customized colors work without a second stored value. */
  --activity-accent: var(--activity-run);
  border-color: var(--activity-accent);
  background: color-mix(in srgb, var(--activity-accent) 14%, var(--surface-strong));
}

.calendar-workout.is-completed .calendar-workout-status {
  color: #fff;
  background: var(--activity-accent);
  border-color: var(--activity-accent);
}

/* Activity color categories for completed workouts. */
.calendar-workout--swim.is-completed {
  --activity-accent: var(--activity-swim);
}

.calendar-workout--bike.is-completed {
  --activity-accent: var(--activity-bike);
}

.calendar-workout--run.is-completed {
  --activity-accent: var(--activity-run);
}

.calendar-workout--other.is-completed {
  --activity-accent: var(--activity-other);
}

/* Per-entry color picker (opens from a completed calendar workout). It sits
   on its own full-width row beneath the workout's status/name row. */
.calendar-color-picker {
  grid-column: 1 / -1;
}

.calendar-color-picker > summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--muted);
}

.calendar-color-picker > summary::-webkit-details-marker {
  display: none;
}

.calendar-color-picker > summary .calendar-color-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.15);
  background: var(--activity-accent, var(--line));
}

/* Activity tag shown as the picker label, colored with the entry's accent. */
.calendar-activity-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--activity-accent, var(--line));
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.calendar-color-options {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.calendar-color-swatch {
  width: 20px;
  height: 20px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  background: var(--swatch);
  cursor: pointer;
}

.calendar-color-swatch.is-active {
  border-color: var(--ink);
}

.calendar-color-auto {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  cursor: pointer;
}

.calendar-color-auto:disabled {
  opacity: 0.5;
  cursor: default;
}

/* Profile: the four user-customizable activity colors, laid out as a row. */
.color-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.color-fields .field {
  flex: 0 0 auto;
}

.color-fields input[type="color"] {
  width: 56px;
  height: 36px;
  padding: 2px;
  cursor: pointer;
}

.calendar-workout.is-in-progress {
  border-color: #d68910;
  background: #fff8ec;
}

.calendar-workout.is-in-progress .calendar-workout-status {
  color: #d68910;
  border-color: #d68910;
}

.calendar-status-pill {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.06);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.calendar-workout.is-completed .calendar-status-pill {
  background: var(--activity-accent);
  color: #fff;
}

.calendar-workout.is-in-progress .calendar-status-pill {
  background: #d68910;
  color: #fff;
}

.calendar-workout-link {
  display: grid;
  gap: 2px;
  min-width: 0;
  text-decoration: none;
  color: inherit;
}

.calendar-workout-link strong {
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.calendar-workout-link .muted {
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.calendar-empty {
  margin: 0;
  font-size: 0.88rem;
}

.calendar-assign-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  margin-top: auto;
}

.calendar-assign-form .form-select {
  min-width: 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  border: 0;
}

@media (max-width: 1100px) {
  .calendar-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .calendar-grid {
    grid-template-columns: 1fr;
  }
}

/* --- Circuit movement drag-and-drop --------------------------------- */
.circuit-items .circuit-item {
  grid-template-columns: 28px minmax(0, 1.2fr) minmax(120px, 0.55fr) auto;
  align-items: center;
  cursor: grab;
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}

.circuit-items .circuit-item:active {
  cursor: grabbing;
}

.circuit-items .circuit-item-main {
  justify-self: start;
  text-align: left;
  min-width: 0;
}

.circuit-items .circuit-item-main strong {
  display: block;
  margin: 0;
}

.circuit-items .circuit-item-measure {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  justify-self: end;
  text-align: right;
}

.circuit-items .drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted, #8a8a8a);
  font-size: 18px;
  line-height: 1;
  user-select: none;
}

.circuit-items .circuit-item.is-dragging {
  opacity: 0.45;
  border-style: dashed;
}

.circuit-items .circuit-item.drop-before {
  box-shadow: 0 -3px 0 0 var(--accent, #2e7d32);
}

.circuit-items .circuit-item.drop-after {
  box-shadow: 0 3px 0 0 var(--accent, #2e7d32);
}

.circuit-items.reorder-error {
  outline: 2px solid #c0392b;
  outline-offset: 4px;
}

/* --- Session exercise editor (circuit-style, expandable rows) -------- */
.session-exercises .session-exercise {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  overflow: hidden;
}

.session-exercises .session-exercise[open] {
  box-shadow: 0 1px 0 0 var(--line);
}

.session-exercises .session-exercise-summary {
  border: 0;
  border-radius: 0;
  cursor: pointer;
  list-style: none;
}

.session-exercises .session-exercise-summary::-webkit-details-marker {
  display: none;
}

.session-exercises .session-exercise[open] > .session-exercise-summary {
  border-bottom: 1px solid var(--line);
}

.session-exercises .session-exercise-body {
  padding-top: 12px;
}

/* --- Nav dropdown + icon button ------------------------------------- */
.nav-dropdown {
  position: relative;
}

.nav-dropdown > summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 9px 12px;
  border-radius: 8px;
  font: inherit;
  font-weight: 700;
  color: var(--muted);
  user-select: none;
}

.nav-dropdown > summary:hover {
  color: var(--ink);
}

.nav-dropdown > summary::-webkit-details-marker {
  display: none;
}

.nav-dropdown[open] > summary {
  color: var(--ink);
  background: rgba(38, 115, 93, 0.09);
}

.nav-dropdown .caret {
  font-size: 0.75em;
  transition: transform 120ms ease;
}

.nav-dropdown[open] .caret {
  transform: rotate(180deg);
}

.nav-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 180px;
  background: var(--surface-strong, #fff);
  border: 1px solid var(--line, #ded7cc);
  border-radius: 8px;
  box-shadow: var(--shadow, 0 12px 30px rgba(0, 0, 0, 0.08));
  padding: 6px;
  z-index: 30;
}

.main-nav .nav-dropdown-menu a {
  display: block;
  width: 100%;
  min-height: 0;
  padding: 8px 12px;
  border-radius: 6px;
  white-space: nowrap;
  font-weight: 600;
  color: var(--ink);
}

.main-nav .nav-dropdown-menu a:hover {
  background: rgba(38, 115, 93, 0.09);
}

/* Reusable visual separator for any nav dropdown menu. */
.nav-dropdown-menu .nav-dropdown-separator {
  height: 1px;
  margin: 6px 8px;
  background: var(--line, #ded7cc);
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  line-height: 0;
}

.icon-button svg {
  display: block;
}

.icon-button--xs {
  width: 1.2em;
  height: 1.2em;
  border-width: 1px;
}

.icon-button--xs svg {
  width: 0.85em;
  height: 0.85em;
}

.icon-button--sm {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
}

.input-with-action {
  display: flex;
  align-items: stretch;
  gap: 6px;
}

.input-with-action > input,
.input-with-action > select,
.input-with-action > textarea {
  flex: 1 1 auto;
  min-width: 0;
}

.input-with-action > .icon-button {
  align-self: stretch;
  height: auto;
}

.label-with-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* --- Outdoor / GPX --------------------------------------------------- */
.outdoor-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  text-decoration: none;
  color: inherit;
}

.outdoor-row-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.outdoor-row-stats {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.badge.warn {
  background: rgba(200, 120, 0, 0.12);
  color: #8a5a00;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin: 0;
}

.metric {
  background: var(--mist, rgba(0, 0, 0, 0.03));
  border: 1px solid var(--line, #ded7cc);
  border-radius: 10px;
  padding: 10px 12px;
}

.metric dt {
  font-size: 0.78em;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.metric dd {
  margin: 4px 0 0;
  font-size: 1.05em;
  font-weight: 700;
}

/* --- Data tables + sortable headers --------------------------------- */
.table-scroll {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95em;
}

.data-table th,
.data-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--line, #ded7cc);
  text-align: right;
  white-space: nowrap;
}

.data-table th:first-child,
.data-table td:first-child,
.data-table th:last-child,
.data-table td:last-child {
  text-align: left;
}

.data-table thead th {
  background: var(--mist, rgba(0, 0, 0, 0.04));
  font-weight: 700;
  position: sticky;
  top: 0;
}

.th-sortable {
  cursor: pointer;
  user-select: none;
}

.th-sortable::after {
  content: " ↕";
  opacity: 0.35;
  font-size: 0.85em;
}

.th-sortable[aria-sort="ascending"]::after {
  content: " ▲";
  opacity: 1;
}

.th-sortable[aria-sort="descending"]::after {
  content: " ▼";
  opacity: 1;
}

.grad-up { color: #1f7a3a; font-weight: 700; }
.grad-down { color: #b04a1a; font-weight: 700; }

/* Inline unit toggle inside a sortable header */
.th-speed { white-space: nowrap; }
.speed-toggle {
  margin-left: 6px;
  border: 1px solid var(--line, #ded7cc);
  background: transparent;
  border-radius: 4px;
  padding: 0 6px;
  font-size: 0.9em;
  line-height: 1.4;
  cursor: pointer;
  color: inherit;
}
.speed-toggle:hover { background: rgba(0, 0, 0, 0.06); }
.speed-toggle:focus-visible { outline: 2px solid currentColor; outline-offset: 1px; }

/* --- Advisor briefing sections (analysis + draft training plan) ------ */
.briefing-section {
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.briefing-section > h2,
.briefing-section > h3 {
  margin: 0 0 10px;
}

.briefing-section > h3 {
  margin-top: 14px;
}

.briefing-section > p {
  margin: 0 0 8px;
}

.briefing-section ul {
  margin: 0;
  padding-left: 18px;
}

.briefing-section ul li + li {
  margin-top: 4px;
}

/* These tables mix prose with numbers, so override the numeric-table
   defaults of .data-table: wrap text and left-align it, while keeping
   numeric columns compact and right-aligned. */
.briefing-section .data-table th,
.briefing-section .data-table td {
  text-align: left;
  white-space: normal;
  vertical-align: top;
}

.briefing-section .data-table th.num,
.briefing-section .data-table td.num {
  text-align: right;
  white-space: nowrap;
}

.briefing-section .data-table th.nowrap,
.briefing-section .data-table td.nowrap {
  white-space: nowrap;
}

.briefing-section .data-table td.workout-cell {
  min-width: 260px;
}

.briefing-section .data-table td.workout-cell strong {
  display: inline-block;
  margin-bottom: 2px;
}

/* --- Filters and admin panels ------------------------------------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: .75rem;
}
.form-grid label {
  display: flex;
  flex-direction: column;
  font-weight: 600;
  font-size: .9em;
  gap: .25rem;
}
.form-grid input,
.form-grid select {
  font: inherit;
  box-sizing: border-box;
  width: 100%;
  line-height: 1.25;
}
.form-grid input[type="date"] {
  font-family: inherit;
}
.form-grid input[type="date"]::-webkit-calendar-picker-indicator {
  padding: 0;
  margin-left: .25rem;
  cursor: pointer;
  opacity: .65;
}
.form-grid input[type="date"]::-webkit-datetime-edit {
  padding: 0;
  line-height: 1.25;
}
.button.danger { background: #b04a1a; border-color: #b04a1a; color: #fff; }
.button.danger:hover { background: #93390f; }
.badge.danger { background: #b04a1a; color: #fff; }
.badge.green { background: #1f7a3a; color: #fff; }


/* ------------------------------------------------------------------ */
/* Strava integration UI                                              */
/* ------------------------------------------------------------------ */

.button.strava,
.button.strava:visited {
  background: #FC4C02;
  border-color: #FC4C02;
  color: #fff;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.button.strava:hover,
.button.strava:focus {
  background: #e34402;
  border-color: #e34402;
  color: #fff;
}

.button.strava .strava-logo {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  fill: currentColor;
}

.strava-info {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem 1.25rem;
  margin: 0.5rem 0 1rem;
}

.strava-info .strava-info-item dt {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0 0 0.15rem;
}

.strava-info .strava-info-item dd {
  margin: 0;
  font-weight: 600;
  color: var(--ink);
}

/* ------------------------------------------------------------------ */
/* Lightweight modal                                                  */
/* ------------------------------------------------------------------ */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal-backdrop.is-open {
  display: flex;
}

.modal {
  background: var(--surface, #fff);
  color: var(--ink);
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  width: min(520px, 100%);
  max-height: 90vh;
  overflow: auto;
  padding: 1.25rem 1.5rem 1.5rem;
}

.modal.modal-large {
  width: 80vw;
  max-width: 80vw;
}

@media (max-width: 820px) {
  .modal.modal-large {
    width: calc(100vw - 2rem);
    max-width: calc(100vw - 2rem);
  }
}

.strava-sync-table-wrap {
  max-height: min(62vh, 560px);
  border: 1px solid var(--line, #ded7cc);
  border-radius: 8px;
}

.strava-sync-table-wrap .data-table thead th {
  top: 0;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.modal-header h3 {
  margin: 0;
}

.modal-close {
  background: none;
  border: 0;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
}

.modal-close:hover {
  background: var(--surface-strong);
  color: var(--ink);
}

.code-block {
  margin: 0;
  padding: 0.75rem 0.9rem;
  background: var(--mist, #e7f0ea);
  border: 1px solid var(--line, #ded7cc);
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--ink);
  max-height: 50vh;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---------------------------------------------------------------------------
   Hyrox results
   --------------------------------------------------------------------------- */
.hyrox-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.hyrox-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-strong);
  overflow: hidden;
}

.hyrox-card-open {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: none;
  padding: 12px 14px;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.hyrox-card-open:hover {
  background: var(--mist);
}

.hyrox-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.hyrox-card-event {
  font-size: 0.85rem;
  margin-top: 2px;
}

.hyrox-card-time {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--green-dark);
  margin: 8px 0 4px;
}

.hyrox-card-ranks {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: 0.82rem;
  color: var(--muted);
}

.hyrox-card-name {
  font-size: 0.8rem;
  margin-top: 6px;
}

.hyrox-card-actions {
  border-top: 1px solid var(--line);
  padding: 8px 14px;
  gap: 8px;
  flex-wrap: wrap;
}

.hyrox-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px 18px;
  margin: 0;
}

.hyrox-summary dt {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.hyrox-summary dd {
  margin: 2px 0 0;
  font-size: 1.05rem;
  font-weight: 600;
}

/* ----- Collapsible "Set a goal" ----- */
.hyrox-goal-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  font-size: 1.05rem;
  font-weight: 600;
}

.hyrox-goal-summary::-webkit-details-marker {
  display: none;
}

.hyrox-goal-summary > span:first-child::before {
  content: "";
  display: inline-block;
  width: 0;
  height: 0;
  margin-right: 8px;
  border-left: 6px solid currentColor;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  transition: transform 0.15s ease;
  vertical-align: middle;
}

.hyrox-goal-details[open] > .hyrox-goal-summary > span:first-child::before {
  transform: rotate(90deg);
}

.hyrox-goal-details > .hyrox-goal-form {
  margin-top: 14px;
}

/* ----- Analysis tab ----- */
.hyrox-analysis-selector {
  align-items: center;
  gap: 8px;
}

.hyrox-analysis-selector label {
  font-size: 0.8rem;
  color: var(--muted);
}

.hyrox-bar {
  display: flex;
  width: 100%;
  height: 16px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--line);
  margin-bottom: 12px;
}

.hyrox-bar span {
  display: block;
  height: 100%;
}

.hyrox-bar-run,
.hyrox-key-run {
  background: #2f80ed;
}

.hyrox-bar-station,
.hyrox-key-station {
  background: #27ae60;
}

.hyrox-bar-roxzone,
.hyrox-key-roxzone {
  background: #e2a23b;
}

.hyrox-key {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 6px;
  vertical-align: baseline;
}

.hyrox-opportunities,
.hyrox-data-quality {
  list-style: none;
  margin: 0;
  padding: 0;
}

.hyrox-opportunities li {
  padding: 8px 0;
}

.hyrox-opportunities li + li {
  border-top: 1px solid var(--line);
}

.hyrox-disclaimer {
  font-size: 0.8rem;
  font-style: italic;
}

/* ----- Benchmark + goal (phase 2) ----- */
.hyrox-target-picker a {
  margin: 0 2px;
}

.hyrox-benchmark-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 8px;
}

.hyrox-benchmark-cols h4 {
  margin: 0 0 4px;
  font-size: 0.85rem;
}

.hyrox-goal-form .form-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}

.hyrox-goal-form .form-row label {
  font-size: 0.8rem;
  color: var(--muted);
}

.hyrox-goal-form select,
.hyrox-goal-form input[type="text"],
.hyrox-goal-form input[type="number"],
.hyrox-goal-form input[type="date"],
.hyrox-goal-form textarea {
  max-width: 360px;
}

.hyrox-llm-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.hyrox-llm-title {
  margin-top: 0;
}

.hyrox-llm h4 {
  margin-bottom: 4px;
}
