:root {
  --bg: #0b1210;
  --bg-2: #121a17;
  --surface: rgba(24, 34, 30, 0.88);
  --surface-strong: #1a2521;
  --line: rgba(164, 196, 180, 0.14);
  --text: #e7f0ea;
  --muted: #8fa39a;
  --accent: #5fd4a4;
  --accent-dim: rgba(95, 212, 164, 0.16);
  --green: #49d18a;
  --amber: #e2b44c;
  --red: #e86b6b;
  --danger: #ff8f8f;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
  --radius: 18px;
  --tap: 52px;
  --font-display: "Barlow Condensed", "Arial Narrow", sans-serif;
  --font-body: "Manrope", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  max-width: 100%;
  overflow-x: hidden;
  overflow-x: clip;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100dvh;
}

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

button {
  cursor: pointer;
}

.atmosphere {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 55% at 15% -10%, rgba(95, 212, 164, 0.18), transparent 55%),
    radial-gradient(ellipse 70% 45% at 100% 8%, rgba(56, 120, 98, 0.22), transparent 50%),
    linear-gradient(180deg, #0e1714 0%, var(--bg) 42%, #0a100e 100%);
  z-index: 0;
}

.atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.35;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.45'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
}

.app {
  position: relative;
  z-index: 1;
  width: min(440px, 100%);
  max-width: 100%;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 18px max(36px, env(safe-area-inset-bottom));
  overflow-x: hidden;
  overflow-x: clip;
}

.top {
  padding: 6px 2px 12px;
  animation: rise 520ms ease both;
}

.brand {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.6rem, 11vw, 3.4rem);
  font-weight: 800;
  line-height: 0.9;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text);
}

.module-title {
  margin: 8px 0 0;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
}

.tagline {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.4;
  max-width: 28ch;
}

.races {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
  animation: rise 620ms ease both;
}

.race {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 14px 12px;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  column-gap: 8px;
  row-gap: 2px;
  backdrop-filter: blur(10px);
}

.race-name {
  grid-column: 1;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text);
}

.race-date {
  grid-column: 1;
  font-size: 0.78rem;
  color: var(--muted);
}

.race-days {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  font-family: var(--font-display);
  font-size: 2.1rem;
  font-weight: 700;
  line-height: 1;
  color: var(--accent);
}

.race-unit {
  display: none;
}

.form-panel,
.result-panel,
.history-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  padding: 18px;
  margin-bottom: 16px;
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  animation: rise 700ms ease both;
}

.hidden {
  display: none !important;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.field.full {
  margin-bottom: 12px;
}

.field > span,
.slider-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.84rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
}

.field em {
  font-style: normal;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  opacity: 0.8;
}

.slider-label strong {
  font-family: var(--font-display);
  font-size: 1.45rem;
  color: var(--text);
  min-width: 1.4ch;
  text-align: right;
}

input[type="number"],
textarea {
  width: 100%;
  min-height: var(--tap);
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(8, 12, 10, 0.55);
  padding: 12px 14px;
  font-size: 1.15rem;
  font-weight: 600;
  outline: none;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

textarea {
  min-height: 84px;
  resize: vertical;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.4;
}

input[type="number"]:focus,
textarea:focus {
  border-color: rgba(95, 212, 164, 0.55);
  background: rgba(8, 12, 10, 0.78);
}

input[type="range"] {
  width: 100%;
  height: 44px;
  appearance: none;
  background: transparent;
  margin: 0;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(95, 212, 164, 0.18), rgba(95, 212, 164, 0.55));
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 28px;
  height: 28px;
  margin-top: -10px;
  border-radius: 50%;
  background: var(--text);
  border: 3px solid var(--accent);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

input[type="range"]::-moz-range-track {
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(95, 212, 164, 0.18), rgba(95, 212, 164, 0.55));
}

input[type="range"]::-moz-range-thumb {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--text);
  border: 3px solid var(--accent);
}

.range-ends {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.75rem;
  margin-top: -4px;
}

.primary-btn,
.secondary-btn,
.ghost-btn {
  width: 100%;
  min-height: var(--tap);
  border-radius: 16px;
  border: 1px solid transparent;
  padding: 14px 18px;
  font-weight: 700;
  letter-spacing: 0.02em;
  transition: transform 140ms ease, background 160ms ease, border-color 160ms ease, opacity 160ms ease;
}

.primary-btn {
  background: var(--accent);
  color: #062118;
  font-size: 1.05rem;
  margin-top: 4px;
}

.primary-btn:active,
.secondary-btn:active,
.ghost-btn:active,
.chart-tab:active {
  transform: scale(0.985);
}

.secondary-btn {
  background: var(--accent-dim);
  border-color: rgba(95, 212, 164, 0.28);
  color: var(--accent);
}

.ghost-btn {
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
  margin-top: 12px;
}

.ghost-btn.danger {
  color: var(--danger);
  border-color: rgba(232, 107, 107, 0.28);
}

.result-panel {
  text-align: center;
  overflow: hidden;
}

.score-ring {
  --level: var(--green);
  width: 180px;
  height: 180px;
  margin: 4px auto 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at center, rgba(11, 18, 16, 0.92) 58%, transparent 59%),
    conic-gradient(var(--level) calc(var(--pct, 0) * 1%), rgba(255, 255, 255, 0.08) 0);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  animation: pop 480ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.score-ring[data-level="green"] { --level: var(--green); }
.score-ring[data-level="amber"] { --level: var(--amber); }
.score-ring[data-level="red"] { --level: var(--red); }

.score-inner {
  width: 132px;
  height: 132px;
  border-radius: 50%;
  background: var(--surface-strong);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.score-label {
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.score-value {
  font-family: var(--font-display);
  font-size: 4rem;
  font-weight: 800;
  line-height: 0.9;
}

.score-max {
  font-size: 0.85rem;
  color: var(--muted);
}

.traffic {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  text-align: left;
  padding: 14px;
  border-radius: 16px;
  background: rgba(8, 12, 10, 0.45);
  border: 1px solid var(--line);
  animation: rise 560ms ease both;
}

.traffic-light {
  width: 18px;
  height: 18px;
  margin-top: 4px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--green);
  box-shadow: 0 0 0 6px rgba(73, 209, 138, 0.12);
  animation: pulse 1.8s ease-in-out infinite;
}

.traffic[data-level="amber"] .traffic-light {
  background: var(--amber);
  box-shadow: 0 0 0 6px rgba(226, 180, 76, 0.14);
}

.traffic[data-level="red"] .traffic-light {
  background: var(--red);
  box-shadow: 0 0 0 6px rgba(232, 107, 107, 0.14);
}

.traffic-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.traffic-copy {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.45;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.sample-flag {
  margin: 0;
  font-size: 0.75rem;
  color: var(--amber);
  font-weight: 600;
}

.sample-flag.hidden {
  display: none;
}

.chart-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}

.chart-tab {
  min-height: 40px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(8, 12, 10, 0.35);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.chart-tab.active {
  background: var(--accent-dim);
  border-color: rgba(95, 212, 164, 0.35);
  color: var(--accent);
}

.chart-wrap {
  width: 100%;
  border-radius: 14px;
  background: rgba(8, 12, 10, 0.4);
  border: 1px solid var(--line);
  padding: 10px 8px 4px;
  margin-bottom: 14px;
}

#trend-chart {
  width: 100%;
  height: auto;
  display: block;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 12px;
  border-radius: 14px;
  background: rgba(8, 12, 10, 0.38);
  border: 1px solid transparent;
}

.history-item.today {
  border-color: rgba(95, 212, 164, 0.28);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
}

.dot.amber { background: var(--amber); }
.dot.red { background: var(--red); }

.history-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.history-date {
  font-weight: 700;
  font-size: 0.92rem;
}

.history-stats {
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-score {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
}

.actions {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.footer {
  padding: 8px 4px 20px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
  text-align: center;
}

.footer p {
  margin: 0 0 4px;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.08); opacity: 0.85; }
}

@media (max-width: 360px) {
  .field-row {
    grid-template-columns: 1fr;
  }

  .race-days {
    font-size: 1.75rem;
  }
}

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

.training-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.training-totals { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 10px 0 12px; }
.training-totals div { background: var(--accent-dim); border-radius: 12px; padding: 8px 4px; text-align: center; }
.training-totals strong { display: block; font-family: var(--font-display); font-size: 1.4rem; }
.training-totals span { font-size: 0.68rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.training-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.training-list li { display: grid; grid-template-columns: 56px 1fr; gap: 2px 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.training-list .t-date { grid-row: span 2; color: var(--muted); font-size: 0.8rem; align-self: center; }
.training-list .t-name { font-weight: 600; font-size: 0.92rem; min-width: 0; overflow-wrap: anywhere; }
.training-list .t-meta { color: var(--muted); font-size: 0.8rem; min-width: 0; overflow-wrap: anywhere; }
.training-list .t-empty { display: block; color: var(--muted); }
.sync-status { font-size: 0.75rem; color: var(--muted); }
.sync-status[data-ok="1"] { color: var(--green); }

/* ---- Plan calendar + race score ---- */
.plan-panel, .training-panel, .form-panel, .history-panel, .result-panel { max-width: 100%; }
.plan-panel { background: var(--surface); border: 1px solid var(--line); border-radius: calc(var(--radius) + 4px); padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.plan-panel.hidden { display: none; }
html[data-rb-signed="1"] #signin-card { display: none !important; }
.signin-card {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}
.signin-copy {
  margin: 0 0 12px;
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.45;
}
.signin-card textarea {
  width: 100%;
  min-height: 88px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  font-size: 16px; /* keeps iPhone from zooming on focus */
  line-height: 1.35;
  resize: vertical;
}
.signin-card #signin-msg:not(:empty) { color: var(--amber); }
.signin-card .primary-btn { width: 100%; min-height: var(--tap); margin-top: 4px; }

:root { --c-cycling: #f2c14e; --c-running: #ff8a5b; --c-swimming: #4fd1e8; --c-gym: #b58cff; --c-golf: #a3d65c; --c-race: #e07a9a; }
.sp { --sc: var(--muted); }
.sp-cycling { --sc: var(--c-cycling); } .sp-running { --sc: var(--c-running); } .sp-swimming { --sc: var(--c-swimming); } .sp-gym { --sc: var(--c-gym); } .sp-golf { --sc: var(--c-golf); } .sp-race { --sc: var(--c-race); }
.plan-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.plan-item { display: grid; grid-template-columns: 44px minmax(0, 1fr) 48px; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 14px; background: rgba(255,255,255,0.03); border: 1px solid var(--line); border-left: 4px solid var(--sc); min-width: 0; }
.plan-item.optional { opacity: 0.78; border-left-style: dashed; }
.sp-ico { width: 44px; height: 44px; min-width: 44px; flex-shrink: 0; border-radius: 50%; display: grid; place-items: center; font-size: 1.35rem; background: color-mix(in srgb, var(--sc) 20%, transparent); border: 1px solid color-mix(in srgb, var(--sc) 55%, transparent); }
.plan-main { min-width: 0; }
.plan-title { margin: 0; font-weight: 700; font-size: 0.95rem; line-height: 1.25; overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.plan-sub { margin: 2px 0 0; color: var(--muted); font-size: 0.78rem; overflow-wrap: anywhere; }
.plan-actual { margin: 3px 0 0; color: var(--green); font-size: 0.8rem; font-weight: 600; overflow-wrap: anywhere; }
.tick { width: 48px; height: 48px; min-width: 48px; flex-shrink: 0; justify-self: end; border-radius: 50%; border: 2px solid var(--line); background: transparent; color: var(--muted); font-size: 1.3rem; font-weight: 800; cursor: pointer; display: grid; place-items: center; padding: 0; -webkit-tap-highlight-color: transparent; }
.tick[data-s="done"] { background: var(--green); border-color: var(--green); color: #07140d; }
.tick[data-s="missed"] { border-color: var(--red); color: var(--red); }
.tick[data-s="skipped"] { color: var(--muted); }
.tick[data-by="manual"]::after { content: ""; }
.plan-empty { color: var(--muted); margin: 0; font-size: 0.9rem; }
.plan-extra { margin: 10px 0 0; color: var(--muted); font-size: 0.8rem; }
.week-nav { display: grid; grid-template-columns: 48px minmax(0, 1fr) 48px; align-items: center; gap: 8px; margin-bottom: 12px; min-width: 0; }
.wk-btn { height: 48px; min-width: 48px; flex-shrink: 0; border-radius: 14px; border: 1px solid var(--line); background: var(--accent-dim); color: var(--accent); font-size: 1.6rem; cursor: pointer; }
.wk-title { text-align: center; display: grid; gap: 2px; min-width: 0; }
.wk-title strong { font-family: var(--font-display); font-size: 1.25rem; letter-spacing: 0.03em; text-transform: uppercase; }
.wk-title span { color: var(--muted); font-size: 0.78rem; overflow-wrap: anywhere; }
.wk-days { display: grid; gap: 6px; touch-action: pan-y; min-width: 0; }
.wk-days .wk-day { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 8px; padding: 8px 4px; border-top: 1px solid var(--line); min-width: 0; max-width: 100%; }
.wk-days .wk-day:first-child { border-top: 0; }
.wk-days .wk-day.today { background: var(--accent-dim); border-radius: 12px; border-top-color: transparent; }
.wk-dn { text-align: center; line-height: 1.1; align-self: start; padding-top: 4px; }
.wk-dn b { display: block; font-family: var(--font-display); font-size: 1.3rem; }
.wk-dn span { color: var(--muted); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em; }
.wk-sessions { display: grid; gap: 6px; min-width: 0; }
.wk-s { display: grid; grid-template-columns: 22px minmax(0, 1fr) 36px; gap: 6px; align-items: center; border-left: 3px solid var(--sc); padding: 2px 0 2px 6px; min-width: 0; }
.wk-s.optional { opacity: 0.75; }
.wk-s .e { font-size: 1.05rem; text-align: center; flex-shrink: 0; }
.wk-s .n { min-width: 0; font-size: 0.85rem; font-weight: 600; line-height: 1.2; overflow-wrap: anywhere; white-space: normal; }
.wk-s .n .t { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; }
.wk-s .n small { display: block; color: var(--muted); font-weight: 500; font-size: 0.72rem; overflow-wrap: anywhere; }
.wk-s .n small.ok { color: var(--green); }
.tick.sm { width: 36px; height: 36px; min-width: 36px; flex-shrink: 0; font-size: 1rem; }
.wk-rest { color: var(--muted); font-size: 0.8rem; align-self: center; }
/* Send to Garmin — sits inside the title cell so the week grid columns stay put */
.sess-detail { min-width: 0; margin-top: 4px; }
.sess-desc { margin: 0 0 6px; color: var(--muted); font-size: 0.72rem; font-weight: 500; white-space: pre-wrap; overflow-wrap: anywhere; }
.wk-s .sess-desc { display: none; }
.wk-s.open .sess-desc { display: block; }
.gm-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px; min-width: 0; }
.gm-btn { appearance: none; margin: 0; padding: 5px 10px; min-height: 32px; border-radius: 999px; border: 1px solid var(--line); background: rgba(255,255,255,0.04); color: var(--text); font: inherit; font-size: 0.72rem; font-weight: 700; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.gm-btn:disabled { opacity: 0.7; cursor: default; }
.gm-btn.sent { color: #07140d; background: var(--green); border-color: var(--green); }
.gm-msg { color: var(--red); font-size: 0.7rem; font-weight: 600; overflow-wrap: anywhere; }
.wk-s.has-detail .n { cursor: pointer; }
.wk-s.movable { touch-action: pan-y; cursor: grab; }
.wk-s.dragging-src { opacity: 0.35; }
.wk-s-ghost { position: fixed; pointer-events: none; z-index: 80; margin: 0; box-shadow: 0 10px 28px rgba(0,0,0,.45); background: var(--card, #161b22); border-radius: 12px; padding: 6px 8px; transform: scale(1.03); transition: transform .12s ease; }
.wk-s-ghost.lift { transform: scale(1.07) rotate(1.2deg); }
.wk-day.drop-ok { outline: 2px solid var(--accent); background: var(--accent-dim); border-radius: 12px; border-top-color: transparent; }
.wk-day.drop-no { outline: 2px solid var(--red); background: rgba(220, 70, 70, 0.12); border-radius: 12px; }
body.wk-dragging, body.wk-dragging .wk-days { touch-action: none; user-select: none; -webkit-user-select: none; overflow: hidden; }
.wk-drag-msg { margin-top: 10px; padding: 8px 12px; border-radius: 12px; background: rgba(255,255,255,0.08); border: 1px solid var(--line); font-size: 0.82rem; font-weight: 600; }
.wk-drag-msg[hidden] { display: none; }

.wk-legend { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 12px; font-size: 0.72rem; color: var(--muted); }
.wk-legend span::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--sc); margin-right: 5px; }
.wk-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; min-width: 0; }
.ghost-btn.small { min-height: 40px; padding: 0 16px; font-size: 0.8rem; width: auto; }
/* race score */
.rs-top { display: flex; align-items: center; gap: 16px; }
.rs-big { display: flex; align-items: baseline; gap: 6px; }
.rs-big strong { font-family: var(--font-display); font-size: 4rem; line-height: 1; color: var(--amber); }
.rs-big span { color: var(--muted); font-weight: 600; }
.rs-meta p { margin: 0; }
.rs-change { font-weight: 700; font-size: 0.95rem; }
.rs-change.up { color: var(--green); } .rs-change.down { color: var(--red); }
.rs-date { color: var(--muted); font-size: 0.8rem; margin-top: 2px !important; }
.rs-bar { position: relative; height: 10px; border-radius: 6px; background: rgba(255,255,255,0.08); margin: 14px 0; overflow: visible; }
.rs-bar span { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--red), var(--amber), var(--green)); }
.rs-bar i { position: absolute; top: -4px; bottom: -4px; width: 3px; left: 90%; background: var(--text); border-radius: 2px; opacity: 0.8; }
.rs-comps { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 7px; }
.rs-comps li { display: grid; grid-template-columns: 88px minmax(0, 1fr) 38px; gap: 8px; align-items: center; font-size: 0.8rem; min-width: 0; }
.rs-comps .cb { height: 7px; border-radius: 4px; background: rgba(255,255,255,0.08); overflow: hidden; }
.rs-comps .cb i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.rs-comps b { text-align: right; font-weight: 700; }
.rs-spark { width: 100%; height: 70px; display: block; margin-top: 6px; }
.rs-note { color: var(--muted); font-size: 0.8rem; margin: 8px 0 0; }

/* ---- Insights: fitness / fuel / weight / golf / pelvic ---- */
input[type="text"], input[type="date"], select {
  width: 100%; min-height: var(--tap); border-radius: 14px; border: 1px solid var(--line); background: rgba(8, 12, 10, 0.55);
  padding: 12px 14px; font-size: 1rem; font-weight: 600; color: var(--text); font-family: inherit; outline: none;
}
input[type="text"]:focus, input[type="date"]:focus, select:focus { border-color: rgba(95, 212, 164, 0.55); }
input[type="text"] { font-weight: 500; }
.in-tabs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-bottom: 14px; }
.in-tab { min-height: 44px; border-radius: 12px; border: 1px solid var(--line); background: transparent; color: var(--muted); font-weight: 700; font-size: 0.8rem; padding: 0 2px; cursor: pointer; }
.in-tab.active { background: var(--accent-dim); border-color: rgba(95, 212, 164, 0.4); color: var(--accent); }
.in-pane.hidden { display: none; }
.status-chip { padding: 5px 12px; border-radius: 999px; font-weight: 700; font-size: 0.8rem; background: var(--accent-dim); color: var(--accent); white-space: nowrap; }
.status-chip[data-k="Overreaching"] { background: rgba(232,107,107,.18); color: var(--red); }
.status-chip[data-k="Building"] { background: rgba(226,180,76,.16); color: var(--amber); }
.status-chip[data-k="Fresh"], .status-chip[data-k="Very fresh"] { background: rgba(111,179,255,.16); color: #6fb3ff; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 4px 0 12px; }
.stat-row div { background: var(--accent-dim); border-radius: 12px; padding: 8px 4px; text-align: center; }
.stat-row strong { display: block; font-family: var(--font-display); font-size: 1.5rem; }
.stat-row span { font-size: 0.68rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.in-text { margin: 0 0 12px; font-size: 0.9rem; line-height: 1.45; }
.in-note { color: var(--muted); font-size: 0.78rem; margin: 8px 0 0; line-height: 1.4; }
.range-row { display: flex; gap: 8px; align-items: center; margin: 4px 0 8px; flex-wrap: wrap; }
.mini-btn { min-height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--muted); font-weight: 600; font-size: 0.78rem; cursor: pointer; }
.mini-btn.active { background: var(--accent-dim); color: var(--accent); border-color: rgba(95,212,164,.4); }
.chart-svg { width: 100%; height: auto; display: block; margin: 6px 0; }
.chart-svg text { fill: #8fa39a; font-size: 9px; font-family: var(--font-body); }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 0.72rem; color: var(--muted); margin-bottom: 6px; }
.chart-legend span::before { content: ""; display: inline-block; width: 14px; height: 3px; border-radius: 2px; background: var(--lc); margin: 0 6px 2px 0; vertical-align: middle; }
.mini-form { margin: 6px 0 12px; }
.mini-form.inline { display: grid; grid-template-columns: 1fr 140px; gap: 10px; align-items: end; }
.mini-form.inline .field { margin-bottom: 0; }
.mini-form.inline .secondary-btn { min-height: var(--tap); }
.field-row.three { grid-template-columns: 1fr 1fr 1fr; }
.sub-h { font-family: var(--font-display); font-size: 1.1rem; letter-spacing: .04em; text-transform: uppercase; margin: 14px 0 4px; color: var(--muted); }
.round-list, .in-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.round-list li { display: grid; grid-template-columns: 1fr 44px; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); align-items: center; }
.round-list b { font-size: 0.95rem; } .round-list small { display: block; color: var(--muted); font-size: 0.76rem; }
.round-del { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: transparent; color: var(--muted); font-size: 1rem; cursor: pointer; }
.in-list li { font-size: 0.82rem; color: var(--text); padding: 6px 0; border-top: 1px solid var(--line); }
.pelvic-panel > summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: baseline; gap: 10px; min-height: 28px; }
.pelvic-panel > summary::-webkit-details-marker { display: none; }
.pelvic-panel > summary span { font-family: var(--font-display); font-size: 1.55rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; }
.pelvic-panel > summary em { color: var(--muted); font-style: normal; font-size: .78rem; }
.pelvic-panel > summary::after { content: "▾"; color: var(--accent); margin-left: auto; padding-left: 10px; }
.pelvic-panel[open] > summary::after { content: "▴"; }
.pelvic-panel[open] > summary { margin-bottom: 12px; }

/* ---- AI Coach ---- */
.coach-fab { position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 40; height: 56px; padding: 0 20px; border-radius: 28px; border: 0; background: var(--accent); color: #062118; font-weight: 800; font-size: 1rem; letter-spacing: .02em; box-shadow: 0 10px 28px rgba(0,0,0,.45); display: flex; align-items: center; gap: 8px; cursor: pointer; }
.coach-sheet { position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column; background: var(--bg); transform: translateY(100%); transition: transform 220ms ease; padding-top: env(safe-area-inset-top); }
.coach-sheet.open { transform: translateY(0); }
.coach-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.coach-head h2 { margin: 0; flex: 1; font-family: var(--font-display); font-size: 1.5rem; letter-spacing: .04em; text-transform: uppercase; }
.coach-head h2 small { display: block; font-family: var(--font-body); font-size: .68rem; letter-spacing: 0; text-transform: none; color: var(--muted); font-weight: 500; }
.coach-ibtn { min-width: 44px; height: 44px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line); background: transparent; color: var(--text); font-size: .8rem; font-weight: 700; cursor: pointer; }
.coach-set { display: none; padding: 10px 14px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.03); gap: 10px; flex-direction: column; font-size: .85rem; }
.coach-set.show { display: flex; }
.coach-set label { display: flex; align-items: center; gap: 10px; }
.coach-set input { width: 22px; height: 22px; accent-color: var(--accent); }
.coach-set small { color: var(--muted); display: block; font-size: .72rem; }
.coach-msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; -webkit-overflow-scrolling: touch; }
.cm { max-width: 88%; padding: 10px 14px; border-radius: 18px; line-height: 1.45; font-size: .95rem; overflow-wrap: anywhere; }
.cm.user { align-self: flex-end; background: var(--accent); color: #062118; border-bottom-right-radius: 6px; font-weight: 600; }
.cm.coach { align-self: flex-start; background: var(--surface-strong); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.cm.coach p { margin: 0 0 8px; } .cm.coach p:last-child { margin-bottom: 0; }
.cm.coach ul { margin: 4px 0 8px; padding-left: 18px; }
.cm.err { align-self: stretch; max-width: 100%; background: rgba(232,107,107,.12); border: 1px solid rgba(232,107,107,.35); color: var(--danger); font-size: .85rem; }
.cm .dots span { display: inline-block; width: 7px; height: 7px; margin-right: 4px; border-radius: 50%; background: var(--muted); animation: cdot 1s infinite; }
.cm .dots span:nth-child(2) { animation-delay: .2s; } .cm .dots span:nth-child(3) { animation-delay: .4s; }
@keyframes cdot { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.coach-chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 14px 10px; scrollbar-width: none; }
.coach-chips::-webkit-scrollbar { display: none; }
.cchip { flex: 0 0 auto; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid rgba(95,212,164,.35); background: var(--accent-dim); color: var(--accent); font-weight: 600; font-size: .82rem; cursor: pointer; white-space: nowrap; }
.coach-bar { display: flex; gap: 8px; align-items: flex-end; padding: 8px 12px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--bg-2); }
.coach-bar textarea { flex: 1; min-height: 48px; max-height: 120px; resize: none; border-radius: 24px; padding: 13px 16px; font-size: 1rem; }
.coach-bar button { width: 48px; height: 48px; border-radius: 50%; border: 0; flex: 0 0 auto; font-size: 1.15rem; cursor: pointer; }
.coach-mic { background: var(--accent-dim); color: var(--accent); border: 1px solid rgba(95,212,164,.35) !important; }
.coach-mic.rec { background: var(--red); color: #fff; animation: pulse 1s infinite; }
.coach-send { background: var(--accent); color: #062118; font-weight: 800; }
.coach-send:disabled { opacity: .45; }
.coach-photo { position: relative; width: 48px; height: 48px; flex: 0 0 auto; border-radius: 50%; background: var(--accent-dim); color: var(--accent); border: 1px solid rgba(95,212,164,.35); display: grid; place-items: center; font-size: 1.15rem; cursor: pointer; overflow: hidden; }
.coach-photo input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.coach-preview { display: flex; align-items: center; gap: 10px; padding: 8px 14px 0; }
.coach-preview[hidden] { display: none; }
.coach-preview img { height: 64px; width: auto; max-width: 160px; border-radius: 10px; object-fit: cover; border: 1px solid var(--line); }
.coach-preview button { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: rgba(255,255,255,.06); color: inherit; cursor: pointer; }
.cm.user { display: grid; gap: 6px; }
.cm.user p { margin: 0; }
.cm.user .cm-photo { display: block; max-width: 180px; max-height: 180px; width: auto; height: auto; border-radius: 12px; object-fit: cover; }
.coach-hint { color: var(--muted); font-size: .72rem; padding: 0 16px 6px; margin: 0; }
body.coach-open { overflow: hidden; }

/* ---- ride builder ---- */
.rd-suggest { background: var(--accent-dim); border: 1px solid rgba(95,212,164,.3); border-radius: 14px; padding: 10px 12px; font-size: .85rem; line-height: 1.45; margin-bottom: 12px; }
.rd-suggest .rd-btn { margin-top: 8px; }
.rd-card { background: var(--surface-strong); border: 1px solid var(--line); border-radius: 16px; padding: 12px; margin: 10px 0; width: 100%; box-sizing: border-box; }
.rd-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; } .rd-head strong { font-size: 1rem; } .rd-head span { color: var(--muted); font-size: .8rem; }
.rd-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 8px; }
.rd-stats span { display: flex; flex-direction: column; background: rgba(255,255,255,.04); border-radius: 10px; padding: 6px 4px; text-align: center; font-size: .66rem; color: var(--muted); } .rd-stats b { font-size: .88rem; color: var(--text, #eef5f1); }
.rd-chart { width: 100%; height: auto; display: block; background: rgba(0,0,0,.2); border-radius: 10px; } .rd-ftp { font-size: 8px; fill: rgba(255,255,255,.55); }
.rd-sum { font-size: .78rem; color: var(--muted); margin: 8px 0 2px; line-height: 1.4; } .rd-meta { font-size: .72rem; color: var(--muted); margin: 0 0 8px; }
.rd-note { border-radius: 12px; padding: 8px 10px; font-size: .8rem; line-height: 1.4; margin: 8px 0; background: rgba(242,201,76,.1); border: 1px solid rgba(242,201,76,.3); }
.rd-note.warn { background: rgba(242,153,74,.12); border-color: rgba(242,153,74,.4); } .rd-note.ok { background: var(--accent-dim); border-color: rgba(95,212,164,.35); }
.rd-note .rd-btn { display: block; margin-top: 8px; width: 100%; }
.rd-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.rd-btn { min-height: 44px; flex: 1 1 auto; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255,255,255,.06); color: inherit; font-weight: 700; font-size: .82rem; cursor: pointer; }
.rd-btn.primary { background: var(--accent); color: #062118; border-color: transparent; } .rd-btn.ghost { background: transparent; } .rd-btn:disabled { opacity: .55; }
.rd-msg { font-size: .8rem; min-height: 1em; margin: 6px 0 0; color: var(--accent); } .rd-msg.err { color: var(--danger); }
.rd-help { font-size: .7rem; color: var(--muted); margin: 6px 0 0; line-height: 1.4; }
.cm.coach .rd-card { margin: 8px -6px; width: calc(100% + 12px); }
.cm.coach.has-card { max-width: 96%; width: 96%; }

/* ---- week rework card ---- */
.wk-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 8px 0 3px; }
.wk-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; min-width: 0; }
.wk-grid .wk-day { background: rgba(255,255,255,.04); border-radius: 8px; padding: 4px 2px; text-align: center; font-size: .62rem; min-height: 46px; display: flex; flex-direction: column; gap: 2px; align-items: center; min-width: 0; }
.wk-grid .wk-day b { color: var(--muted); font-weight: 700; }
.wk-grid .wk-day span { display: block; white-space: nowrap; }
.wk-grid .wk-day i { color: var(--muted); font-style: normal; }
.wk-grid.after .wk-day span.chg { background: var(--accent-dim); border-radius: 6px; padding: 1px 3px; color: var(--accent); font-weight: 700; }
.wk-list { list-style: none; padding: 0; margin: 10px 0 0; font-size: .82rem; } .wk-list li { padding: 6px 0; border-top: 1px solid var(--line); } .wk-list small { color: var(--muted); }
.plan-title .mv { color: var(--accent); font-weight: 600; font-size: .7em; }
.rv-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.rv-card .rd-meta { margin-top: 8px; }

.gf-loss{display:grid;gap:6px;margin:8px 0 2px}
.gf-row{display:grid;grid-template-columns:78px 1fr 32px;align-items:center;gap:8px;font-size:12px}
.gf-row i{display:block;height:8px;border-radius:4px;background:rgba(255,255,255,.08);overflow:hidden}
.gf-row u{display:block;height:100%;border-radius:4px}
.gf-row u.lost{background:#ff8d8d}.gf-row u.gain{background:#5fd4a4}
.gf-row b,.gm-row b{font-size:12px;text-align:right}
.gm-row{display:grid;grid-template-columns:1fr auto;gap:2px 8px;font-size:12px;align-items:baseline}
.gm-row span{font-weight:600}.gm-row em{font-style:normal;opacity:.7}
.gm-row b{grid-column:1/-1;text-align:left;opacity:.9}.gm-row b.up{color:#5fd4a4}.gm-row b.dn{color:#ff8d8d}

.coach-set #coach-push { margin: 8px 0 4px; width: auto; min-height: 36px; padding: 6px 12px; font-size: 0.85rem; }
.coach-set #coach-push-msg { display: block; color: var(--muted); margin: 0 0 6px; line-height: 1.3; }
