:root {
  --bg: #f6f5f2;
  --panel: #ffffff;
  --text: #1c1d1f;
  --muted: #6b6e73;
  --line: #e2e0db;
  --accent: #c8109a;   /* magenta, darkened enough for readable links on white */
  --accent-text: #ffffff;
  --ebike: #2a6fb0;
  --warn: #9a6400;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141517;
    --panel: #1d1f22;
    --text: #ececec;
    --muted: #9a9ea5;
    --line: #2f3236;
    --accent: #f45cc9;
    --ebike: #5c9ee0;
    --warn: #e0a84a;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent); text-decoration: none; }
/* Dates on My rides open that month in the calendar: plain text that shows it is a link on hover. */
a.date-link { color: inherit; text-decoration: underline dotted color-mix(in srgb, var(--muted) 60%, transparent); text-underline-offset: 3px; }
a.date-link:hover { color: var(--accent); text-decoration: underline; }
a:hover { text-decoration: underline; }
header { display: flex; align-items: center; gap: 24px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
.brand { font-weight: 800; letter-spacing: 0.08em; color: var(--text); font-size: 18px; }
nav { display: flex; gap: 16px; }
nav a { color: var(--muted); }
nav a:hover { color: var(--text); text-decoration: none; }
header a[data-tab] { padding: 12px 2px 10px; margin-top: -12px; margin-bottom: -12px; border-bottom: 2px solid transparent; }
header a[data-tab][aria-current="page"] { color: var(--text); font-weight: 600; border-bottom-color: var(--accent); }
main { max-width: 1280px; margin: 0 auto; padding: 16px 24px; }
h1 { font-size: 24px; margin: 8px 0 4px; }
h2 { font-size: 17px; margin: 24px 0 8px; }
.muted { color: var(--muted); }
.warn { color: var(--warn); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 16px; }
.map { height: 380px; border-radius: 8px; border: 1px solid var(--line); margin: 12px 0; }
.stats { display: flex; flex-wrap: wrap; gap: 8px 28px; margin: 8px 0; }
.stat b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 13px; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; font-size: 13px; }
td.num, th.num { text-align: right; }
.boards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 700px) { .boards { grid-template-columns: 1fr; } }
.tabs { display: flex; gap: 8px; margin: 16px 0 8px; }
button, .button { font: inherit; padding: 7px 14px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--text); cursor: pointer; }
button.primary, .button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button[aria-pressed="true"] { border-color: var(--text); font-weight: 600; }
input[type="text"] { font: inherit; padding: 7px 10px; border-radius: 6px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
input[type="range"] { width: 100%; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.tag { font-size: 12px; padding: 1px 7px; border-radius: 10px; border: 1px solid currentColor; }
.tag.ebike { color: var(--ebike); }
.kom { font-size: 13px; color: var(--muted); }
.profile { width: 100%; height: 120px; display: block; }
.profile path { fill: color-mix(in srgb, var(--m-climb) 25%, transparent); stroke: var(--m-climb); stroke-width: 1.5; }   /* elevation green, as on the calendar */
.profile .sel { fill: color-mix(in srgb, var(--text) 10%, transparent); stroke: none; }
.error { color: var(--warn); }
#me-page.drop { outline: 2px dashed var(--accent); outline-offset: 8px; border-radius: 8px; }
label.button { display: inline-block; }
button:disabled { opacity: 0.45; cursor: default; }
header .account { margin-left: auto; }
.narrow { max-width: 420px; margin: 24px auto; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; }
input[type="email"], input[type="password"] { font: inherit; padding: 7px 10px; border-radius: 6px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
details.panel > summary { cursor: pointer; font-weight: 600; }
details.panel[open] > summary { margin-bottom: 12px; }
button.sort { background: none; border: none; padding: 0; font: inherit; font-weight: 600; color: inherit; cursor: pointer; }
button.sort .arrow { font-size: 0.8em; opacity: 0.35; }
button.sort.on .arrow, button.sort:hover .arrow { opacity: 1; }
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.title-row h1 { margin: 0; }
#add-msg:empty { display: none; }
button.link, label.link { background: none; border: none; padding: 0; font: inherit; color: var(--accent); cursor: pointer; }
button.link:hover, label.link:hover { text-decoration: underline; }
.settings { max-width: 520px; }
.settings .panel { margin-bottom: 16px; }
.settings h2 { margin-top: 0; font-size: 16px; }
.home-totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; margin: 12px 0; }
.home-totals .panel { margin: 0; }
.home-totals h2 { margin: 0 0 4px; font-size: 15px; color: var(--muted); font-weight: 600; }
table.records td:first-child { color: var(--muted); white-space: nowrap; }
.welcome { margin-top: 32px; }
/* bikes */
.ride-top { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: start; }
@media (max-width: 700px) { .ride-top { grid-template-columns: 1fr; } }
.bike-card { margin: 8px 0 0; width: 280px; max-width: 100%; }
.bike-card img, .bike-none { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); display: block; }
.bike-none { display: flex; align-items: center; justify-content: center; background: var(--panel); }
.bike-card figcaption { margin-top: 6px; }
.bike-card select { width: 100%; }
a.bike-add { display: flex; align-items: center; justify-content: center; aspect-ratio: 4 / 3; border: 2px dashed var(--line); border-radius: 10px; padding: 12px; text-align: center; }
.bike-row, .bike-form { display: flex; gap: 14px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.bike-form { border-bottom: none; align-items: start; }
.bike-thumb { width: 120px; flex: none; aspect-ratio: 4 / 3; border-radius: 8px; border: 1px solid var(--line); overflow: hidden; display: flex; align-items: center; justify-content: center; font-size: 12px; }
.bike-thumb img { width: 100%; height: 100%; object-fit: cover; }
/* friends */
.friend-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.friend-row:last-child { border-bottom: none; }
#friend-form input { flex: 1; min-width: 220px; }
/* privacy choices */
.stack.choices label.choice { display: flex; flex-direction: row; gap: 10px; align-items: flex-start; padding: 6px 0; cursor: pointer; }
.stack.choices label.choice input { width: auto; flex: none; }
.choices .choice input { margin-top: 4px; }
/* profile pictures and gallery */
.who { display: flex; align-items: center; gap: 12px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex: none; }
.avatar.small { width: 24px; height: 24px; vertical-align: middle; margin-right: 6px; }
.avatar.big { width: 72px; height: 72px; }
.avatar-none { display: inline-flex; align-items: center; justify-content: center; background: var(--line); color: var(--muted); font-weight: 700; }
.avatar-none.big { font-size: 28px; }
.avatar-edit { cursor: pointer; position: relative; }
.avatar-edit::after { content: "✎"; position: absolute; right: -2px; bottom: -2px; background: var(--panel); border: 1px solid var(--line); border-radius: 50%; width: 22px; height: 22px; font-size: 12px; display: flex; align-items: center; justify-content: center; }
.gallery-box { margin: 16px 0; }
/* Every photo whole: boxes share one height, each as wide as its photo. */
.gallery { display: flex; flex-wrap: wrap; gap: 8px; --row: 170px; }
@media (max-width: 600px) { .gallery { --row: 120px; } }
.gallery .thumb { padding: 0; border: none; background: var(--line); cursor: zoom-in; height: var(--row); min-width: calc(var(--row) * 0.5); overflow: hidden; border-radius: 8px; }
.gallery .thumb img { height: 100%; width: auto; display: block; transition: transform .2s; }
.gallery .thumb:hover img { transform: scale(1.04); }
#lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.88); z-index: 1000; display: flex; align-items: center; justify-content: center; }
#lightbox figure { margin: 0; max-width: 92vw; max-height: 92vh; display: flex; flex-direction: column; align-items: center; gap: 10px; }
#lightbox img { max-width: 92vw; max-height: 80vh; object-fit: contain; border-radius: 6px; }
#lightbox figcaption { color: #eee; text-align: center; }
#lightbox figcaption input { min-width: 260px; }
#lightbox figcaption .link { color: #ff9b7a; }
#lightbox button.lb-close, #lightbox button.lb-prev, #lightbox button.lb-next { position: absolute; background: none; border: none; color: #fff; font-size: 44px; cursor: pointer; padding: 8px 16px; }
#lightbox .lb-close { top: 8px; right: 12px; }
#lightbox .lb-prev { left: 8px; top: 50%; transform: translateY(-50%); }
#lightbox .lb-next { right: 8px; top: 50%; transform: translateY(-50%); }
.brand { display: inline-flex; align-items: center; gap: 8px; }
.brand img { border-radius: 6px; }
/* calendar */
:root { --m-distance: #e5179e; --m-time: #06aed5; --m-climb: #16b364; --m-calories: #e11d2a; }   /* magenta, cyan, green, red */
@media (prefers-color-scheme: dark) { :root { --m-distance: #f43fbf; --m-time: #22d3ee; --m-climb: #34d399; --m-calories: #ff4d57; } }
.m-distance { background: var(--m-distance); } .m-time { background: var(--m-time); }
.m-climb { background: var(--m-climb); } .m-calories { background: var(--m-calories); }
main:has(.cal) { max-width: 1800px; }   /* nearly full width; capped so the day boxes don't grow huge on very wide screens */
.cal { display: grid; grid-template-columns: 172px 1fr; gap: 20px; align-items: start; }
.cal-months { position: sticky; top: 12px; max-height: calc(100vh - 90px); overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding-right: 4px; }
.cal-mini { display: block; text-align: left; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: inherit; cursor: pointer; font: inherit; }
.cal-mini:hover { border-color: var(--muted); }
.cal-mini.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.cal-mini-name { display: block; font-size: 12px; font-weight: 600; margin-bottom: 4px; }
.cal-mini-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-mini-grid i { aspect-ratio: 1; border-radius: 2px; background: var(--line); opacity: .45; }
.cal-mini-grid i.ride { opacity: 1; }   /* its rainbow colour is set on the page */
.cal-nav h1 { margin: 0; min-width: 9em; text-align: center; }
.cal-nav .link { font-size: 28px; line-height: 1; padding: 0 6px; }
.cal-pick { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; flex-wrap: wrap; }
.cal-pick button { border: none; border-radius: 0; background: var(--panel); color: var(--muted); padding: 6px 12px; display: inline-flex; align-items: center; gap: 6px; }
.cal-pick button.on { background: var(--text); color: var(--bg); }
.cal-pick .dot { width: .72em; height: .72em; border-radius: 2px; display: inline-block; }   /* square, as tall as the capital letters */
.cal-totals { margin: 12px 0; }
.cal-main { min-width: 0; position: relative; }
.cal-pop { position: absolute; z-index: 5; width: 280px; max-width: calc(100vw - 32px); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 24px rgb(0 0 0 / .18); padding: 6px; }
.cal-pop-head { font-size: 13px; font-weight: 600; color: var(--muted); padding: 4px 8px 6px; }
.cal-pop-ride { display: block; padding: 7px 8px; border-radius: 6px; color: var(--text); }
.cal-pop-ride:hover, .cal-pop-ride:focus { background: color-mix(in srgb, var(--accent) 10%, transparent); text-decoration: none; outline: none; }
.cal-pop-ride b { color: var(--accent); }
.cal-pop-stats { display: block; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
/* Seven days, an empty 0-wide column (so the week box sits two gaps from Sunday), then the week. */
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)) 0 minmax(0, 1fr); gap: 6px; }
/* Year: two rows of six small month calendars, each with its totals underneath. */
.cal-year { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.cal-ym { display: flex; flex-direction: column; gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: inherit; font: inherit; text-align: left; cursor: pointer; }
.cal-ym:hover { border-color: var(--muted); }
.cal-ym.now { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.cal-ym-name { font-size: 14px; font-weight: 600; }
/* The month's effort as a rainbow bar beside its name, ending at the colour its square has in the side list. */
.cal-ym-head { display: flex; align-items: center; gap: 8px; }
.cal-ym-head .cal-ym-name { flex: none; width: 2.6em; }   /* same width for every month, so the bars line up and compare fairly */
.effort-bar { flex: 1; height: 12px; border-radius: 6px; background: color-mix(in srgb, var(--line) 60%, transparent); overflow: hidden; }
.effort-bar i { display: block; height: 100%; border-radius: 6px; }
/* Standing up: a column filled from the bottom (the side list of years). */
.effort-bar.up { flex: none; width: 72%; height: auto; aspect-ratio: 1 / 1.5; display: flex; align-items: flex-end; border-radius: 5px; }
.effort-bar.up i { width: 100%; aspect-ratio: auto; opacity: 1; border-radius: 5px; }
.cal-ym-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-ym-grid b { font-size: 9px; font-weight: 500; color: var(--muted); text-align: center; }
.cal-ym-grid i { aspect-ratio: 1; border-radius: 2px; background: var(--line); opacity: .45; }
.cal-ym-grid i.blank { background: none; }
.cal-ym-grid i.ride { opacity: 1; }   /* rainbow colour set on the page */
/* Days in the year view's months: standing rainbow bars filling each day's square. */
.cal-ym-grid .effort-bar.day { width: 100%; aspect-ratio: 1; border-radius: 2px; }
.cal-ym-grid .effort-bar.day i { border-radius: 2px; }
.cal-ym-grid .effort-bar.today { outline: 2px solid var(--accent); outline-offset: 1px; }
.cal-ym-totals { display: flex; flex-direction: column; gap: 2px; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cal-ym-totals span { overflow: hidden; text-overflow: ellipsis; }
.cal-ym-totals span:first-child { color: var(--muted); font-weight: 500; font-size: 12px; }
.cal-ym-totals .key { width: .85em; height: .85em; border-radius: 2px; display: inline-block; margin-right: .3em; vertical-align: -.08em; }
.cal-mini-grid.year { grid-template-columns: repeat(3, 1fr); gap: 6px 8px; padding: 2px 4px 0; }   /* four rows of three, each square labelled */
.cal-mini-month { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .03em; }
.cal-mode { margin-right: 8px; }
.cal-week { cursor: default; contain: size; }   /* its text never makes the row taller; it is sized to fit instead */
.cal-week.has:hover { border-color: var(--line); }
.cal-week .cal-date { color: var(--muted); font-weight: 500; }
/* The page sets --week-font to the biggest size at which every week's totals fit (fitWeekText). */
.cal-week-list { flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: flex-end; font-size: var(--week-font, 12px); line-height: 1.15; font-weight: 600; white-space: nowrap; overflow: hidden; }
.cal-week-list span { display: block; overflow: hidden; }
.cal-week-list .key { width: .85em; height: .85em; border-radius: 2px; display: inline-block; margin-right: .3em; vertical-align: -.08em; }   /* a little taller than the digits */
.cal-head { font-size: 12px; color: var(--muted); text-align: center; padding-bottom: 2px; }
.cal-day { position: relative; min-height: 108px; aspect-ratio: 1 / .9; padding: 6px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: inherit; font: inherit; text-align: left; display: flex; flex-direction: column; cursor: default; }
.cal-day.blank { background: transparent; border-color: transparent; }
.cal-day.has { cursor: pointer; }
.cal-day.has:hover { border-color: var(--muted); }
.cal-day.picked { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.cal-day.today .cal-date { background: var(--accent); color: var(--accent-text); border-radius: 10px; padding: 0 6px; }
.cal-date { font-size: 12px; font-weight: 600; align-self: flex-start; }
.cal-bars { flex: 1; display: flex; align-items: flex-end; gap: 3px; padding: 4px 2px 0; }
.cal-bars .bar { flex: 1; border-radius: 3px 3px 0 0; min-height: 0; }
.cal-bars.one { flex-direction: column; align-items: stretch; justify-content: flex-end; }
.cal-bars.one .bar { flex: none; width: 70%; margin: 0 auto; }
.cal-value { font-size: 11px; font-weight: 600; text-align: center; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 800px) {
  .cal { grid-template-columns: 1fr; }
  .cal-months { position: static; flex-direction: row; overflow-x: auto; max-height: none; }
  .cal-mini { flex: none; width: 128px; }
  .cal-grid { gap: 3px; }
  .cal-day { min-height: 62px; aspect-ratio: auto; padding: 3px; border-radius: 6px; }
  .cal-year { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }   /* phones: three months a row */
  .cal-ym { padding: 6px; gap: 5px; }
  .cal-ym-totals { font-size: 11px; }
  .cal-ym-head { flex-direction: column; align-items: stretch; gap: 4px; }   /* phones: bar under the name */
  .cal-ym-head .cal-ym-name { width: auto; }
  .effort-bar { flex: none; }
  .cal-date { font-size: 10px; }
  .cal-value { font-size: 8px; }
  .cal-bars { gap: 1px; padding: 2px 0 0; }
  .cal-nav h1 { font-size: 20px; min-width: 0; }
  .cal-pick button { padding: 5px 8px; font-size: 13px; }
}
/* small screens: keep the header on one line */
@media (max-width: 600px) {
  main { padding: 16px; }   /* phones keep their old margins */
  header { gap: 12px; padding: 10px 12px; }
  .brand { font-size: 0; gap: 0; }
  .brand img { width: 28px; height: 28px; }
  nav { gap: 12px; font-size: 14px; }
  nav a, header .account { white-space: nowrap; }
  header .account { max-width: 26vw; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
}
