:root {
  color-scheme: light;
  --ink: #1c2a2a;
  --muted: #647574;
  --line: #dce5e2;
  --surface: #fff;
  --background: #f3f7f5;
  --green: #176b55;
  --green-dark: #10513f;
  --accent: #e7f2ed;
  --red: #a63c3c;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--background); color: var(--ink); font: 16px/1.5 system-ui, sans-serif; }
a { color: var(--green); }
.site-header { display: flex; align-items: center; gap: 2rem; padding: .8rem max(1.5rem, calc((100% - 1440px) / 2)); background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { color: var(--ink); font-weight: 800; font-size: 1.15rem; text-decoration: none; white-space: nowrap; }
nav { display: flex; align-items: center; gap: 1.2rem; }
nav a { color: var(--muted); font-weight: 600; text-decoration: none; }
nav a:hover, nav a:focus { color: var(--green); }
.athlete-control { display: flex; align-items: center; gap: .75rem; margin-left: auto; }
.athlete-control form { display: flex; align-items: center; gap: .5rem; }
.athlete-control label { color: var(--muted); font-size: .85rem; }
.container { width: min(1440px, calc(100% - 3rem)); margin: 2rem auto 4rem; }
.page-heading { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1.25rem; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: .15rem; font-size: clamp(1.7rem, 3vw, 2.25rem); letter-spacing: -.03em; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
.eyebrow { margin-bottom: .2rem; color: var(--green); font-size: .75rem; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
.muted, small { color: var(--muted); }
.panel { margin: 1rem 0; padding: 1.3rem; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 2px 6px #18372a08; }
.week-plan { background: var(--accent); }
.week-plan h2 { margin-bottom: .8rem; }
.focus-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.2rem; }
.focus-grid p { margin: .25rem 0 0; white-space: pre-line; }
.week-plan-description { display: block; margin-top: .2rem; color: var(--muted); font-size: .78rem; font-weight: 400; line-height: 1.35; white-space: pre-line; }
.week-nav, .form-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.button { display: inline-flex; min-height: 40px; align-items: center; justify-content: center; padding: .55rem .9rem; border: 1px solid var(--green); border-radius: 7px; background: var(--green); color: white; font: inherit; font-size: .9rem; font-weight: 650; text-decoration: none; cursor: pointer; }
.button:hover, .button:focus { background: var(--green-dark); color: white; }
.button-outline { background: transparent; color: var(--green); }
.button-outline:hover, .button-outline:focus { background: var(--accent); color: var(--green-dark); }
.button-small { min-height: 34px; padding: .35rem .65rem; font-size: .85rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.entry-form { display: flex; flex-direction: column; gap: .75rem; padding: 1rem; border: 1px solid var(--line); border-radius: 9px; }
.upload-form { display: flex; align-items: end; gap: .8rem; flex-wrap: wrap; }
.upload-form label { flex: 1; min-width: 260px; }
.form-busy-status { display: inline-flex; align-items: center; gap: .55rem; width: 100%; color: var(--green-dark); font-size: .9rem; font-weight: 650; }
.form-busy-status[hidden] { display: none; }
.loading-spinner { width: 1.15rem; height: 1.15rem; flex: 0 0 auto; border: 3px solid #b9d7cb; border-top-color: var(--green); border-radius: 50%; animation: loading-spin .8s linear infinite; }
@keyframes loading-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .loading-spinner { animation-duration: 2.5s; } }
.button:disabled { cursor: wait; opacity: .7; }
.entry-form h3 { margin-bottom: 0; }
label { display: flex; flex-direction: column; gap: .3rem; color: #354746; font-size: .88rem; font-weight: 600; }
input, select, textarea { width: 100%; min-height: 40px; padding: .55rem .65rem; border: 1px solid #cbd7d3; border-radius: 6px; background: white; color: var(--ink); font: inherit; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #86b9a6; outline-offset: 1px; border-color: var(--green); }
.two-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .75rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
thead th { background: #f6f9f8; color: var(--muted); font-size: .8rem; font-weight: 700; }
.calendar-table { min-width: 760px; }
.day-cell { width: 145px; white-space: nowrap; }
.day-cell span { display: block; color: var(--muted); font-size: .82rem; font-weight: 450; }
.session { display: grid; grid-template-columns: 90px minmax(80px, 1fr) minmax(68px, .6fr) minmax(65px, .65fr) minmax(70px, 1.3fr) max-content; align-items: center; gap: .35rem .6rem; padding: .45rem 0; border-bottom: 1px dashed var(--line); }
.session:last-child { border-bottom: 0; }
.key-session { padding-right: .4rem; padding-left: .4rem; border-radius: 6px; background: #fff3c4; }
.key-session-label { display: block; color: #795b00; font-size: .72rem; font-weight: 650; }
.checkbox-label { flex-direction: row; align-items: center; gap: .55rem; }
.checkbox-label input { width: 1.1rem; min-height: 1.1rem; height: 1.1rem; margin: 0; accent-color: var(--green); }
.session-time, .session-sport, .session-duration, .session-metric, .session-details { min-width: 0; }
.session-sport, .session-duration, .session-metric { white-space: nowrap; }
.session-details { color: var(--muted); font-size: .85rem; overflow-wrap: anywhere; }
.session-comment { display: block; white-space: pre-wrap; overflow-wrap: anywhere; }
.activity-tooltip-trigger { position: relative; color: var(--green); font-size: .82rem; text-decoration: underline dotted; cursor: help; }
.activity-tooltip { position: absolute; z-index: 5; left: 0; top: calc(100% + .35rem); display: flex; flex-direction: column; gap: .25rem; width: max-content; max-width: min(360px, 75vw); padding: .65rem .75rem; border: 1px solid var(--line); border-radius: 6px; background: white; box-shadow: 0 4px 14px #18352b24; color: var(--ink); text-decoration: none; visibility: hidden; opacity: 0; transition: opacity .12s ease; }
.activity-tooltip-trigger:hover .activity-tooltip, .activity-tooltip-trigger:focus .activity-tooltip { visibility: visible; opacity: 1; }
.tooltip-comment { white-space: pre-wrap; overflow-wrap: anywhere; }
.session-actions { display: flex; gap: .6rem; align-items: center; justify-self: end; font-size: .82rem; }
.time-badge { padding: .12rem .4rem; border-radius: 4px; background: var(--accent); color: var(--green-dark); font-size: .73rem; white-space: nowrap; }
.inline-form { display: inline; }
.link-button { padding: 0; border: 0; background: none; color: var(--green); font: inherit; cursor: pointer; }
.link-button:hover { text-decoration: underline; }
.danger-text { color: var(--red); }
.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); gap: .7rem; }
.summary-card { display: flex; flex-direction: column; gap: .15rem; padding: .9rem; border: 1px solid var(--line); border-radius: 8px; }
.summary-card span, .summary-card small { color: var(--muted); }
.summary-card strong { font-size: 1.2rem; }
.summary-total { background: var(--accent); border-color: #c9e0d5; }
.previous-week-summary { margin: .75rem 0 0; color: var(--muted); font-size: .78rem; line-height: 1.5; }
.copy-week-form, .pace-calculator { display: flex; align-items: end; gap: .75rem; flex-wrap: wrap; margin-top: 1rem; }
.copy-week-form label, .pace-calculator label { flex: 1; min-width: 220px; }
.pace-table-wrap { max-width: 760px; margin-bottom: 1rem; }
.pace-table-wrap th, .pace-table-wrap td { padding: .5rem .75rem; }
.pace-result { margin: 1rem 0 0; padding: .7rem .9rem; border-radius: 7px; background: var(--accent); font-weight: 650; }
.intensity-panel h2 { margin-bottom: .35rem; }
.intensity-table-wrap { margin-top: .9rem; }
.intensity-table { min-width: 760px; }
.intensity-table th, .intensity-table td { vertical-align: middle; }
.intensity-table tbody th { white-space: nowrap; }
.intensity-section-break th { border-top: 3px solid var(--ink); background: #f6f9f8; }
.percent-input { width: 90px; min-height: 34px; padding: .35rem .45rem; }
.inline-percent { flex-direction: row; align-items: center; gap: .3rem; }
.auth-form { display: grid; width: min(100%, 520px); gap: .9rem; }
.access-form { width: 100%; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); align-items: end; }
.access-link { display: inline-block; margin: .15rem .65rem .15rem 0; }
.phase-date-range { display: block; color: var(--muted); font-size: .82rem; font-weight: 450; }
.undefined-period { background: #fae9e7; color: var(--red); }
.undefined-period th, .undefined-period td { border-color: #edc7c3; }
.current-threshold-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .75rem; }
.threshold-entry-form, .required-threshold-form { display: flex; align-items: end; gap: .8rem; flex-wrap: wrap; }
.threshold-entry-form label, .required-threshold-form label { flex: 1; min-width: 180px; }
.required-threshold-form { padding: .8rem 0; border-top: 1px solid var(--line); }
.threshold-required { border-color: #e5c27b; background: #fffaf0; }
.threshold-charts { display: grid; grid-template-columns: 1fr; gap: 1.25rem; }
.chart-card { min-width: 0; padding: 1rem; border: 1px solid var(--line); border-radius: 9px; }
.chart-card h3 { margin-bottom: .3rem; }
.threshold-chart { display: block; width: 100%; height: auto; overflow: visible; }
.chart-gridline { stroke: var(--line); stroke-width: 1; }
.chart-axis-label, .chart-date-label { fill: var(--muted); font: 11px system-ui, sans-serif; }
.chart-line { fill: none; stroke: var(--green); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.chart-point { fill: white; stroke: var(--green); stroke-width: 3; }
.report-filter { display: flex; align-items: end; gap: .8rem; flex-wrap: wrap; }
.report-filter label { flex: 1; min-width: 180px; }
.report-chart-scroll { width: 100%; overflow-x: auto; }
.report-chart { display: block; width: 100%; min-width: 760px; height: auto; }
.report-legend { display: flex; flex-wrap: wrap; gap: .5rem 1rem; margin-bottom: .6rem; font-size: .85rem; }
.report-legend span { display: inline-flex; align-items: center; gap: .35rem; }
.report-legend i { width: .8rem; height: .8rem; border-radius: 2px; background: var(--legend-color); }
.field-help { margin: .8rem 0 0; color: var(--muted); font-size: .85rem; }
.profile-form { max-width: 900px; }
.full-width { grid-column: 1 / -1; }
.age-display { padding: .6rem 0; font-size: .95rem; }
.form-actions { margin-top: 1.25rem; }
.plan-row-heading { display: flex; justify-content: space-between; align-items: center; }
.plan-row-heading h2, .plan-row-heading p { margin-bottom: .15rem; }
.plan-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .85rem; align-items: end; }
.plan-form button { justify-self: start; }
.long-term-table { min-width: 1150px; }
.long-term-year .table-wrap { max-height: 72vh; overflow: auto; }
.long-term-table thead th { position: sticky; top: 0; z-index: 2; }
.long-term-year-heading { position: sticky; top: 0; z-index: 3; padding: .25rem 0 .75rem; background: var(--surface); font-size: 1.2rem; font-weight: 750; cursor: pointer; }
.long-term-year[open] .long-term-year-heading { margin-bottom: .75rem; }
.long-term-navigation { margin-bottom: 1rem; }
.long-term-table tr.current-week { outline: 2px solid var(--green); outline-offset: -2px; background: var(--accent); }
.long-term-description-cell[title], .long-term-table select[title] { cursor: help; }
.long-term-table input, .long-term-table select, .long-term-table textarea { min-width: 135px; }
.long-term-save { display: flex; justify-content: flex-end; margin: 0 0 1rem; }
.long-term-extend { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.long-term-extend p { margin: 0; }
.row-actions { white-space: nowrap; }
.row-actions > * + * { margin-left: .65rem; }
.empty-state { padding: 3rem 1.5rem; text-align: center; }
.notices { margin-bottom: 1rem; }
.notice { margin: .5rem 0; padding: .7rem 1rem; border-radius: 7px; }
.notice-success { background: #e4f3e9; color: #175c35; }
.notice-error { background: #fae9e7; color: #8d2925; }
.site-footer { padding: 1rem; color: var(--muted); text-align: center; font-size: .82rem; }

@media (max-width: 900px) {
  .site-header { flex-wrap: wrap; gap: .8rem 1.2rem; padding: .8rem 1rem; }
  nav { order: 3; width: 100%; overflow-x: auto; }
  .athlete-control { margin-left: auto; }
  .container { width: calc(100% - 1.5rem); margin-top: 1.25rem; }
  .focus-grid { grid-template-columns: 1fr; gap: .7rem; }
  .session { grid-template-columns: 65px minmax(55px, .9fr) 52px 55px minmax(0, 1fr) max-content; gap: .3rem; }
  .session-actions { gap: .35rem; font-size: .76rem; }
}
@media (max-width: 640px) {
  .page-heading { align-items: flex-start; flex-direction: column; }
  .form-grid, .plan-form { grid-template-columns: 1fr; }
  .panel { padding: 1rem; }
  .athlete-control label { display: none; }
  .session { grid-template-columns: 75px minmax(75px, 1fr) minmax(58px, auto) minmax(55px, auto); align-items: start; }
  .session-details { grid-column: 2 / 4; }
  .session-actions { grid-column: 2 / 5; justify-self: start; }
  .threshold-entry-form, .required-threshold-form { align-items: stretch; flex-direction: column; }
  .copy-week-form, .pace-calculator { align-items: stretch; flex-direction: column; }
}
