/* =========================================================================
   Theme tokens. Flip `data-tr-theme` on <html> to swap.
   ========================================================================= */
[data-tr-theme="dark"] {
  /* Surfaces */
  --tr-bg:               #0e1714;
  --tr-bg-grad-1:        #10231d;
  --tr-bg-grad-2:        #0a1411;
  --tr-bg-panel:         #16201d;
  --tr-bg-card:          #1a2520;
  --tr-bg-card-hi:       #243530;
  --tr-bg-card-past:     #121b18;
  --tr-rule-card-past:   #1f2a26;
  /* Ink */
  --tr-ink:              #ebe3cd;
  --tr-ink-soft:         #cabfa3;
  --tr-muted:            #8a9088;
  --tr-faint:            #5a625a;
  /* Rules / accents */
  --tr-rule:             #293530;
  --tr-rule-soft:        #1f2a26;
  --tr-gold:             #d4a155;
  --tr-gold-soft:        #b88a4a;
  /* Shadows */
  --tr-shadow-week:      0 2px 24px #0006;
  --tr-shadow-drawer:    0 24px 64px #0009;
  --tr-shadow-toggle:    0 4px 16px #0005;
  /* Type colors (saturated for dark bg) */
  --tr-type-rest:        #6b746e;
  --tr-type-recovery:    #5aa5b3;
  --tr-type-easy:        #8ec077;
  --tr-type-quality:     #e08a4a;
  --tr-type-long:        #b496e0;
  --tr-type-b2b:         #c97ad0;
  --tr-type-sim:         #e6a062;
  --tr-type-race:        #ec5c4a;
  --tr-type-event:       #d4a155;
  /* Flag tints */
  --tr-flag-check-accent:#8ec077;
  --tr-flag-check-bg:    linear-gradient(180deg, #1c3526 0%, #182721 100%);
  --tr-flag-check-border:#56865d;
  --tr-flag-check-badge: #244430;
  --tr-flag-rec-accent:  #5aa5b3;
  --tr-flag-rec-bg:      linear-gradient(180deg, #173a44 0%, #172621 100%);
  --tr-flag-rec-border:  #3f7a8c;
  --tr-flag-rec-badge:   #1f4854;
  --tr-flag-race-accent: #ec5c4a;
  --tr-flag-race-bg:     linear-gradient(180deg, #2c1715 0%, #1d2120 100%);
  --tr-flag-race-border: #7a2e25;
  --tr-flag-race-badge:  #3a1816;
  /* Deviation accents */
  --tr-deviation-bg:     #3a2418;
  --tr-deviation-border: #d97c4f;
  --tr-deviation-text:   #e08a4a;
  /* Ridge silhouette */
  --tr-ridge-back-top:   #2e4a3c;
  --tr-ridge-back-bot:   #16241e;
  --tr-ridge-fore-top:   #1d2f28;
  --tr-ridge-fore-bot:   #0a1310;
  /* Landscape palettes (warm / cool / dusk: 0 = bottom, 3 = top) */
  --tr-land-warm-0:      #3a2418;
  --tr-land-warm-1:      #5a3220;
  --tr-land-warm-2:      #824827;
  --tr-land-warm-3:      #c97a3a;
  --tr-land-cool-0:      #0e1f24;
  --tr-land-cool-1:      #163036;
  --tr-land-cool-2:      #1f4854;
  --tr-land-cool-3:      #3a8092;
  --tr-land-dusk-0:      #1a1226;
  --tr-land-dusk-1:      #2a1e3b;
  --tr-land-dusk-2:      #4a2a55;
  --tr-land-dusk-3:      #a05c80;
}

[data-tr-theme="light"] {
  /* Surfaces — warm cream paper */
  --tr-bg:               #ebe2c5;
  --tr-bg-grad-1:        #e2d6b4;
  --tr-bg-grad-2:        #f0e8cc;
  --tr-bg-panel:         #f3ecd2;
  --tr-bg-card:          #f8f1d8;
  --tr-bg-card-hi:       #fffae3;
  --tr-bg-card-past:     #e0d6b8;
  --tr-rule-card-past:   #c8bd9a;
  /* Ink — deep forest */
  --tr-ink:              #1f2a23;
  --tr-ink-soft:         #3e4a44;
  --tr-muted:            #6b746e;
  --tr-faint:            #909089;
  /* Rules / accents */
  --tr-rule:             #cabea0;
  --tr-rule-soft:        #ddd2b4;
  --tr-gold:             #9a6a2a;
  --tr-gold-soft:        #b58444;
  /* Shadows */
  --tr-shadow-week:      0 2px 16px #5a460026;
  --tr-shadow-drawer:    0 24px 64px #2a1e0033;
  --tr-shadow-toggle:    0 4px 14px #2a1e0022;
  /* Type colors */
  --tr-type-rest:        #7c8278;
  --tr-type-recovery:    #246b7a;
  --tr-type-easy:        #3e7a4a;
  --tr-type-quality:     #b85e2a;
  --tr-type-long:        #6448a0;
  --tr-type-b2b:         #84348e;
  --tr-type-sim:         #a85a1f;
  --tr-type-race:        #a02018;
  --tr-type-event:       #976820;
  /* Flag tints */
  --tr-flag-check-accent:#3e7a4a;
  --tr-flag-check-bg:    linear-gradient(180deg, #dceec6 0%, #ebebcd 100%);
  --tr-flag-check-border:#78a872;
  --tr-flag-check-badge: #d4e8ba;
  --tr-flag-rec-accent:  #246b7a;
  --tr-flag-rec-bg:      linear-gradient(180deg, #cee4ec 0%, #ebebd1 100%);
  --tr-flag-rec-border:  #6196a4;
  --tr-flag-rec-badge:   #c6dde6;
  --tr-flag-race-accent: #a02018;
  --tr-flag-race-bg:     linear-gradient(180deg, #f1d2cc 0%, #efe5d1 100%);
  --tr-flag-race-border: #c8665a;
  --tr-flag-race-badge:  #ecc6c0;
  /* Deviation accents */
  --tr-deviation-bg:     #f5e0c8;
  --tr-deviation-border: #b86a30;
  --tr-deviation-text:   #8e4a20;
  /* Ridge silhouette */
  --tr-ridge-back-top:   #b8a984;
  --tr-ridge-back-bot:   #ebe2c5;
  --tr-ridge-fore-top:   #948560;
  --tr-ridge-fore-bot:   #d4c8a4;
  /* Landscape palettes (lighter tonal versions) */
  --tr-land-warm-0:      #8a5a2a;
  --tr-land-warm-1:      #b07d44;
  --tr-land-warm-2:      #d4a06a;
  --tr-land-warm-3:      #ecc890;
  --tr-land-cool-0:      #345868;
  --tr-land-cool-1:      #4a7888;
  --tr-land-cool-2:      #6a9aaa;
  --tr-land-cool-3:      #9cc2d0;
  --tr-land-dusk-0:      #4a2a44;
  --tr-land-dusk-1:      #6a4868;
  --tr-land-dusk-2:      #946890;
  --tr-land-dusk-3:      #c094b8;
}

/* =========================================================================
   Page chrome
   ========================================================================= */
html, body { margin: 0; padding: 0; min-height: 100%; }
html { background: var(--tr-bg); color: var(--tr-ink); }
body {
  color: var(--tr-ink);
  font-family: "Outfit", "Inter Tight", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: color .25s;
  background:
    linear-gradient(180deg,
      var(--tr-bg-grad-1) 0%,
      var(--tr-bg)         22%,
      var(--tr-bg-grad-2) 100%);
  background-attachment: fixed;
  background-color: var(--tr-bg);
}
#root { min-height: 100vh; }
.tr-stage { max-width: 1480px; margin: 0 auto; }

.tr-calendar {
  position: relative;
  background: transparent;
  color: var(--tr-ink);
  min-height: 100%;
  padding: 40px 70px 56px 70px;
  font-family: "Outfit", "Inter Tight", system-ui, sans-serif;
  overflow: visible;
}
.tr-calendar-inner { position: relative; z-index: 1; }

/* =========================================================================
   Trail ribbon (left gutter)
   ========================================================================= */
.tr-trail-ribbon {
  position: absolute;
  left: -18px;
  top: 0;
  pointer-events: none;
}

/* =========================================================================
   Theme toggle
   ========================================================================= */
.tr-theme-toggle {
  position: fixed;
  top: 22px;
  right: 22px;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid var(--tr-rule);
  background: var(--tr-bg-panel);
  color: var(--tr-ink);
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--tr-shadow-toggle);
  transition: background-color .15s, border-color .15s, color .15s, transform .15s;
}
.tr-theme-toggle:hover {
  background: var(--tr-bg-card-hi);
  transform: translateY(-1px);
}
.tr-theme-toggle:focus-visible {
  outline: 2px solid var(--tr-gold);
  outline-offset: 2px;
}
.tr-theme-toggle:active { transform: translateY(0); }

/* =========================================================================
   Hero
   ========================================================================= */
.tr-hero {
  position: relative;
  border-radius: 20px;
  overflow: hidden;
  background: linear-gradient(180deg, var(--tr-bg-grad-1) 0%, var(--tr-bg-grad-2) 100%);
  border: 1px solid var(--tr-rule);
  margin-bottom: 24px;
}
.tr-hero-body {
  position: relative;
  padding: 34px 36px 0;
}
.tr-hero-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 0.22em;
  color: var(--tr-gold);
  text-transform: uppercase;
  margin-bottom: 18px;
}
.tr-hero-title {
  font-family: "Instrument Serif", "Fraunces", Georgia, serif;
  font-size: 86px;
  line-height: 0.96;
  color: var(--tr-ink);
  letter-spacing: -0.02em;
  font-style: italic;
  margin: 0;
  font-weight: 400;
  text-wrap: balance;
}
.tr-hero-sub {
  font-family: "Outfit", system-ui, sans-serif;
  font-size: 15px;
  color: var(--tr-ink-soft);
  line-height: 1.55;
  margin-top: 18px;
  margin-bottom: 22px;
  max-width: 800px;
  text-wrap: pretty;
}
.tr-hero-sub b { font-weight: 600; color: var(--tr-ink); }
.tr-hero-ridge { margin: 0 -36px; }
.tr-hero-ridge svg { display: block; }

/* =========================================================================
   HR caps + legend
   ========================================================================= */
.tr-caps-legend {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
  margin-bottom: 30px;
}
.tr-caps, .tr-legend {
  background: var(--tr-bg-panel);
  border: 1px solid var(--tr-rule);
  border-radius: 16px;
  padding: 16px 18px;
}
.tr-caps-title, .tr-legend-title {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--tr-gold);
  text-transform: uppercase;
  margin-bottom: 10px;
}
.tr-caps-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px 18px;
}
.tr-cap-label {
  font-family: "Outfit", system-ui, sans-serif;
  font-size: 11px;
  color: var(--tr-muted);
  letter-spacing: 0.04em;
}
.tr-cap-value {
  font-family: "Outfit", system-ui, sans-serif;
  font-weight: 300;
  font-size: 22px;
  line-height: 1.1;
  color: var(--tr-ink);
  letter-spacing: -0.01em;
  font-feature-settings: "tnum";
}
.tr-cap-note {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 9.5px;
  color: var(--tr-faint);
  margin-top: 2px;
}
.tr-legend-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 14px;
}
.tr-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: "Outfit", system-ui, sans-serif;
  font-size: 12.5px;
  color: var(--tr-ink-soft);
}
.tr-legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--type-c, var(--tr-muted));
  box-shadow: 0 0 8px color-mix(in srgb, var(--type-c, var(--tr-muted)) 47%, transparent);
}

/* =========================================================================
   Phase block
   ========================================================================= */
.tr-phase { margin-bottom: 36px; position: relative; }
.tr-phase-header {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  margin-bottom: 22px;
  border: 1px solid var(--tr-rule);
}
.tr-phase-landscape { display: block; width: 100%; height: 170px; }
.tr-phase-fade {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 0%, color-mix(in srgb, var(--tr-bg) 80%, transparent) 78%, var(--tr-bg) 100%);
  pointer-events: none;
}
.tr-phase-text {
  position: absolute;
  inset: 0;
  padding: 18px 24px 20px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.tr-phase-kicker {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 0.22em;
  color: var(--tr-gold);
  text-transform: uppercase;
}
.tr-phase-title {
  font-family: "Instrument Serif", "Fraunces", Georgia, serif;
  font-size: 44px;
  line-height: 1;
  font-style: italic;
  color: var(--tr-ink);
  margin: 6px 0 6px;
  letter-spacing: -0.01em;
  text-wrap: pretty;
  font-weight: 400;
}
.tr-phase-desc {
  font-family: "Outfit", system-ui, sans-serif;
  font-size: 13.5px;
  color: var(--tr-ink-soft);
  line-height: 1.5;
  margin: 0;
  max-width: 760px;
  text-wrap: pretty;
}

/* =========================================================================
   Week panel
   ========================================================================= */
.tr-week {
  position: relative;
  background: var(--tr-bg-panel);
  border: 1px solid var(--tr-rule);
  border-radius: 18px;
  padding: 20px 22px 22px;
  margin-bottom: 18px;
  box-shadow: var(--tr-shadow-week);
}
.tr-week[data-flag="checkpoint"] {
  background: var(--tr-flag-check-bg);
  border-color: var(--tr-flag-check-border);
  box-shadow: var(--tr-shadow-week), inset 0 0 0 1px color-mix(in srgb, var(--tr-flag-check-accent) 10%, transparent);
}
.tr-week[data-flag="recovery"] {
  background: var(--tr-flag-rec-bg);
  border-color: var(--tr-flag-rec-border);
  box-shadow: var(--tr-shadow-week), inset 0 0 0 1px color-mix(in srgb, var(--tr-flag-rec-accent) 10%, transparent);
}
.tr-week[data-flag="race"] {
  background: var(--tr-flag-race-bg);
  border-color: var(--tr-flag-race-border);
  box-shadow: var(--tr-shadow-week), inset 0 0 0 1px color-mix(in srgb, var(--tr-flag-race-accent) 10%, transparent);
}
.tr-week-node {
  position: absolute;
  left: -31px;
  top: 28px;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--tr-gold);
  border: 2px solid var(--tr-bg);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--tr-gold) 40%, transparent),
              0 0 12px  color-mix(in srgb, var(--tr-gold) 40%, transparent);
}
.tr-week[data-flag="checkpoint"] .tr-week-node {
  background: var(--tr-flag-check-accent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--tr-flag-check-accent) 40%, transparent),
              0 0 12px  color-mix(in srgb, var(--tr-flag-check-accent) 40%, transparent);
}
.tr-week[data-flag="recovery"] .tr-week-node {
  background: var(--tr-flag-rec-accent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--tr-flag-rec-accent) 40%, transparent),
              0 0 12px  color-mix(in srgb, var(--tr-flag-rec-accent) 40%, transparent);
}
.tr-week[data-flag="race"] .tr-week-node {
  background: var(--tr-flag-race-accent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--tr-flag-race-accent) 40%, transparent),
              0 0 12px  color-mix(in srgb, var(--tr-flag-race-accent) 40%, transparent);
}

.tr-week-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  align-items: flex-start;
  margin-bottom: 14px;
}
.tr-week-id {
  font-family: "Instrument Serif", "Fraunces", Georgia, serif;
  font-size: 26px;
  line-height: 1;
  font-style: italic;
  color: var(--tr-ink);
  letter-spacing: -0.005em;
  font-weight: 400;
}
.tr-week-dates {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10.5px;
  letter-spacing: 0.18em;
  color: var(--tr-gold);
  text-transform: uppercase;
  margin-top: 5px;
}
.tr-week[data-flag="checkpoint"] .tr-week-dates { color: var(--tr-flag-check-accent); }
.tr-week[data-flag="recovery"]   .tr-week-dates { color: var(--tr-flag-rec-accent); }
.tr-week[data-flag="race"]       .tr-week-dates { color: var(--tr-flag-race-accent); }

.tr-week-focus {
  font-family: "Outfit", system-ui, sans-serif;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--tr-ink-soft);
  margin-top: 8px;
  max-width: 760px;
  text-wrap: pretty;
}
.tr-week-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
  margin-top: 4px;
}
.tr-week-badge {
  font-family: "Outfit", system-ui, sans-serif;
  font-size: 10px;
  letter-spacing: 0.1em;
  padding: 5px 10px;
  border-radius: 999px;
  font-weight: 500;
  text-transform: uppercase;
}
.tr-week[data-flag="checkpoint"] .tr-week-badge {
  background: var(--tr-flag-check-badge);
  color: var(--tr-flag-check-accent);
  border: 1px solid color-mix(in srgb, var(--tr-flag-check-accent) 40%, transparent);
}
.tr-week[data-flag="recovery"] .tr-week-badge {
  background: var(--tr-flag-rec-badge);
  color: var(--tr-flag-rec-accent);
  border: 1px solid color-mix(in srgb, var(--tr-flag-rec-accent) 40%, transparent);
}
.tr-week[data-flag="race"] .tr-week-badge {
  background: var(--tr-flag-race-badge);
  color: var(--tr-flag-race-accent);
  border: 1px solid color-mix(in srgb, var(--tr-flag-race-accent) 40%, transparent);
}
.tr-week-numbers { text-align: right; }
.tr-week-mileage {
  font-family: "Outfit", system-ui, sans-serif;
  font-weight: 300;
  font-size: 19px;
  line-height: 1;
  color: var(--tr-ink);
  font-feature-settings: "tnum";
}
.tr-week-mileage-unit {
  font-size: 11px;
  color: var(--tr-muted);
  margin-left: 3px;
}
.tr-week-load {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10px;
  color: var(--tr-muted);
  margin-top: 4px;
  font-feature-settings: "tnum";
}
.tr-week-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

/* =========================================================================
   Day cell
   ========================================================================= */
.tr-day {
  position: relative;
  background: var(--tr-bg-card);
  border: 1px solid var(--tr-rule);
  border-radius: 14px;
  padding: 12px 13px 14px;
  min-height: 190px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: transform .15s, box-shadow .15s, background-color .15s, border-color .15s;
}
.tr-day[data-status="today"] {
  background: var(--tr-bg-card-hi);
  border-color: var(--type-c, var(--tr-rule));
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--type-c, var(--tr-rule)) 33%, transparent),
    0 8px 24px color-mix(in srgb, var(--type-c, var(--tr-rule)) 13%, transparent);
}
.tr-day[data-status="past"] { opacity: 0.5; }
.tr-day[data-status="past"][data-logged="true"] {
  opacity: 1;
  background: var(--tr-bg-card-past);
  border-color: var(--tr-rule-card-past);
}
.tr-day[data-clickable="true"] { cursor: pointer; }
.tr-day[data-clickable="true"]:hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
}
[data-tr-theme="light"] .tr-day[data-clickable="true"]:hover { filter: brightness(0.97); }
.tr-day[data-clickable="true"]:active {
  transform: translateY(0);
  filter: brightness(1.02);
}
.tr-day[data-clickable="true"]:focus-visible {
  outline: 2px solid var(--tr-gold);
  outline-offset: 2px;
}
.tr-day[data-clickable="false"] { cursor: default; }

.tr-day-plan {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}
.tr-day[data-status="past"][data-logged="true"] .tr-day-plan { opacity: 0.55; }
.tr-day-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}
.tr-day-dow {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--tr-muted);
  text-transform: uppercase;
}
.tr-day-date {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10px;
  color: var(--tr-faint);
  margin-left: 6px;
}
.tr-day-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  white-space: nowrap;
  font-family: "Outfit", system-ui, sans-serif;
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: 999px;
  color: var(--type-c, var(--tr-muted));
  background: color-mix(in srgb, var(--type-c, var(--tr-muted)) 11%, transparent);
}
.tr-day-pill-dot {
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: var(--type-c, var(--tr-muted));
}

.tr-day-title {
  font-family: "Instrument Serif", "Fraunces", Georgia, serif;
  font-size: 17px;
  line-height: 1.15;
  color: var(--tr-ink);
  font-style: italic;
  margin-top: 2px;
  text-wrap: pretty;
}
.tr-day-headline { margin-top: 2px; }
.tr-day-title + .tr-day-headline { margin-top: 0; }
.tr-day-amount {
  font-family: "Outfit", system-ui, sans-serif;
  font-weight: 300;
  font-size: 30px;
  line-height: 1;
  color: var(--tr-ink);
  letter-spacing: -0.02em;
  font-feature-settings: "tnum";
}
.tr-day-amount--pace {
  font-size: 24px;
  line-height: 1.05;
  letter-spacing: -0.015em;
}
.tr-day-effort {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 12px;
  color: var(--tr-gold);
  margin-top: 4px;
  font-feature-settings: "tnum";
}
.tr-day-effort-label {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10px;
  color: var(--tr-gold);
  margin-top: 4px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.tr-day-rest {
  font-family: "Instrument Serif", "Fraunces", Georgia, serif;
  font-style: italic;
  font-size: 18px;
  color: var(--tr-muted);
  margin-top: 4px;
}
.tr-day-extras {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
  color: var(--tr-ink-soft);
  line-height: 1.55;
  font-feature-settings: "tnum";
}
.tr-day-structure {
  color: var(--tr-ink);
  margin-bottom: 3px;
}
.tr-day-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 8px;
  color: var(--tr-muted);
}
.tr-day-spacer { flex: 1; }
.tr-day-est {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11.5px;
  color: var(--tr-ink-soft);
  padding-top: 9px;
  border-top: 1px solid var(--tr-rule-soft);
  line-height: 1.5;
  font-feature-settings: "tnum";
}
.tr-day-est-label {
  color: var(--tr-faint);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-right: 5px;
  font-size: 10px;
}

.tr-day-logged {
  padding: 8px 9px;
  background: color-mix(in srgb, var(--type-c, var(--tr-muted)) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--type-c, var(--tr-muted)) 33%, transparent);
  border-radius: 8px;
}
.tr-day[data-deviation="true"] .tr-day-logged {
  background: var(--tr-deviation-bg);
  border-color: color-mix(in srgb, var(--tr-deviation-border) 33%, transparent);
}
.tr-day-logged-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: "Outfit", system-ui, sans-serif;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--type-c, var(--tr-muted));
}
.tr-day[data-deviation="true"] .tr-day-logged-label { color: var(--tr-deviation-text); }
.tr-day-logged-summary {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
  color: var(--tr-ink);
  margin-top: 5px;
  line-height: 1.55;
  font-feature-settings: "tnum";
}

/* =========================================================================
   Footer
   ========================================================================= */
.tr-footer {
  margin-top: 24px;
  padding-top: 18px;
  font-family: "Instrument Serif", "Fraunces", Georgia, serif;
  font-style: italic;
  font-size: 14px;
  color: var(--tr-muted);
  text-align: center;
  text-wrap: pretty;
}
.tr-footer b { font-weight: 600; color: var(--tr-ink-soft); font-style: normal; }

/* =========================================================================
   Drawer / modal
   ========================================================================= */
.tr-scrim {
  position: fixed;
  inset: 0;
  background: color-mix(in srgb, #000 64%, transparent);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 60;
  animation: tr-scrim-in 0.18s ease;
}
[data-tr-theme="light"] .tr-scrim {
  background: color-mix(in srgb, #2a1e00 38%, transparent);
}
.tr-drawer {
  position: relative;
  background: var(--tr-bg-panel);
  border: 1px solid var(--tr-rule);
  border-radius: 18px;
  padding: 30px 34px 28px;
  width: min(580px, 100%);
  max-height: 86vh;
  overflow-y: auto;
  color: var(--tr-ink);
  box-shadow: var(--tr-shadow-drawer);
  animation: tr-drawer-in 0.22s cubic-bezier(.16,.84,.44,1);
}
@keyframes tr-scrim-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes tr-drawer-in {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.tr-drawer-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid var(--tr-rule);
  background: var(--tr-bg-card);
  color: var(--tr-ink-soft);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: background-color .15s, color .15s, transform .15s;
}
.tr-drawer-close:hover {
  background: var(--tr-bg-card-hi);
  color: var(--tr-ink);
}
.tr-drawer-close:focus-visible {
  outline: 2px solid var(--tr-gold);
  outline-offset: 2px;
}

.tr-drawer-pillrow {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding-right: 36px;
}
.tr-drawer-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 999px;
  color: var(--type-c, var(--tr-muted));
  background: color-mix(in srgb, var(--type-c, var(--tr-muted)) 11%, transparent);
  border: 1px solid color-mix(in srgb, var(--type-c, var(--tr-muted)) 33%, transparent);
  font-family: "Outfit", system-ui, sans-serif;
}
.tr-drawer-pill-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--type-c, var(--tr-muted));
}
.tr-drawer-date {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--tr-muted);
}

.tr-drawer-title {
  font-family: "Instrument Serif", "Fraunces", Georgia, serif;
  font-style: italic;
  font-size: 32px;
  line-height: 1.15;
  color: var(--tr-ink);
  margin: 6px 0 14px;
  text-wrap: pretty;
  letter-spacing: -0.01em;
  font-weight: 400;
}

.tr-drawer-headline { margin: 8px 0 16px; }
.tr-drawer-amount {
  font-family: "Outfit", system-ui, sans-serif;
  font-weight: 300;
  font-size: 54px;
  line-height: 1;
  color: var(--tr-ink);
  letter-spacing: -0.025em;
  font-feature-settings: "tnum";
}
.tr-drawer-amount--pace { font-size: 36px; }
.tr-drawer-effort {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 14px;
  color: var(--tr-gold);
  margin-top: 6px;
  font-feature-settings: "tnum";
}
.tr-drawer-effort-label {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10px;
  color: var(--tr-gold);
  margin-top: 6px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.tr-drawer-rest {
  font-family: "Instrument Serif", "Fraunces", Georgia, serif;
  font-style: italic;
  font-size: 26px;
  color: var(--tr-muted);
  margin: 4px 0 14px;
}

.tr-drawer-est {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 10px 0 12px;
  border-top: 1px solid var(--tr-rule-soft);
  border-bottom: 1px solid var(--tr-rule-soft);
  margin-bottom: 14px;
}
.tr-drawer-est-label {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10px;
  color: var(--tr-faint);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.tr-drawer-est-value {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 13px;
  color: var(--tr-ink-soft);
  font-feature-settings: "tnum";
}

.tr-drawer-extras {
  margin-bottom: 14px;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 12px;
  color: var(--tr-ink-soft);
  line-height: 1.55;
  font-feature-settings: "tnum";
}
.tr-drawer-structure {
  color: var(--tr-ink);
  margin-bottom: 4px;
}
.tr-drawer-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  color: var(--tr-muted);
}

.tr-drawer-note {
  font-family: "Outfit", system-ui, sans-serif;
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--tr-ink-soft);
  text-wrap: pretty;
  margin: 0 0 18px;
}

.tr-drawer-cc, .tr-drawer-logged {
  border: 1px solid color-mix(in srgb, var(--type-c, var(--tr-muted)) 33%, transparent);
  background: color-mix(in srgb, var(--type-c, var(--tr-muted)) 6%, transparent);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 12px;
}
.tr-drawer-cc[data-deviation="true"],
.tr-drawer-logged[data-deviation="true"] {
  border-color: var(--tr-deviation-border);
  background: var(--tr-deviation-bg);
}
.tr-drawer-cc-label, .tr-drawer-logged-label {
  font-family: "Outfit", system-ui, sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 6px;
  color: var(--type-c, var(--tr-muted));
}
.tr-drawer-cc[data-deviation="true"] .tr-drawer-cc-label,
.tr-drawer-logged[data-deviation="true"] .tr-drawer-logged-label {
  color: var(--tr-deviation-text);
}
.tr-drawer-cc-text {
  font-family: "Outfit", system-ui, sans-serif;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--tr-ink);
  text-wrap: pretty;
}
.tr-drawer-logged-summary {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 12px;
  line-height: 1.5;
  color: var(--tr-ink);
  font-feature-settings: "tnum";
}
.tr-drawer-cc-divider {
  height: 1px;
  margin: 12px -14px;
  opacity: 0.55;
}
.tr-drawer-logged .tr-drawer-cc-label {
  margin-bottom: 5px;
}

/* =========================================================================
   Responsive
   ---------------------------------------------------------------------------
   Wide  (>1280px) : 7-col grid, trail ribbon + week-node dots visible,
                     calendar uses its full padding to leave room for the
                     ribbon in the left gutter.
   Mid   (961–1280): Ribbon + dots hidden so the week panels can claim the
                     full content width — fixes pill wrapping and Recovery
                     pill overflowing its cell at this width.
   Narrow (≤960)   : Day grid collapses to 1 column, caps + legend stack,
                     cells shrink to fit content (rest days collapse).
   Phone  (≤600)   : Drawer becomes a bottom sheet.
   ========================================================================= */
@media (max-width: 1280px) {
  .tr-trail-ribbon { display: none; }
  .tr-week-node    { display: none; }
  .tr-calendar     { padding: 40px 28px 56px 28px !important; }
}

@media (max-width: 960px) {
  .tr-calendar    { padding: 24px 16px 40px 16px !important; }
  .tr-week-days   { grid-template-columns: 1fr !important; }
  .tr-caps-legend { grid-template-columns: 1fr !important; }
  .tr-caps-grid   { grid-template-columns: repeat(2, 1fr); }
  /* Cells fit their content instead of enforcing the desktop card height.
     Rest days are content-light and shrink almost flat as a result. */
  .tr-day         { min-height: 0 !important; }
  .tr-hero-title  { font-size: 44px; line-height: 1; }
  .tr-phase-title { font-size: 30px; }
  .tr-drawer {
    padding: 24px 22px 22px;
    max-height: 92vh;
    border-radius: 16px;
  }
  .tr-drawer-amount { font-size: 42px; }
  .tr-drawer-title  { font-size: 26px; }
  .tr-theme-toggle {
    top: 14px;
    right: 14px;
    width: 40px;
    height: 40px;
  }
}

@media (max-width: 600px) {
  .tr-scrim { padding: 0; align-items: flex-end; }
  .tr-drawer {
    width: 100%;
    max-height: 92vh;
    border-radius: 18px 18px 0 0;
    border-bottom: none;
    animation: tr-sheet-in 0.24s cubic-bezier(.16,.84,.44,1);
  }
  @keyframes tr-sheet-in {
    from { transform: translateY(28px); opacity: 0.8; }
    to   { transform: translateY(0);    opacity: 1; }
  }
}
