@font-face {
  font-family: "Syne";
  src: url("../fonts/syne-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Syne";
  src: url("../fonts/syne-800.woff2") format("woff2");
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --night: #0b0f0d;
  --night-2: #111713;
  --night-3: #18201b;
  --route: #b6ff3b;
  --aid: #ff7a1a;
  --paper: #efeee6;
  --paper-ink: #121512;
  --paper-muted: #4a514b;
  --muted: #a3aba4;
  --line: rgba(239, 238, 230, 0.14);
  --contour: rgba(182, 255, 59, 0.06);
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  --display: "Syne", system-ui;
  --text: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  --header: 68px;
  --rail: 64px;
  --gutter: 128px;
  --contour-map: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='900' height='900' fill='none' stroke='rgba(182,255,59,.06)' stroke-width='1.2'%3E%3Cpath d='M294 300C296 306 294 317 288 322C283 328 270 329 262 330C253 331 246 328 239 326C232 324 224 322 219 318C214 313 210 306 209 300C208 293 209 284 213 278C218 272 228 266 236 265C244 264 254 269 260 273C267 276 270 279 276 284C281 288 292 293 294 300ZM343 300C346 312 336 334 324 344C312 354 289 356 273 358C257 359 242 357 228 354C214 350 197 346 187 337C177 328 169 313 167 300C165 286 166 266 175 255C185 244 208 235 223 234C239 232 256 243 270 248C283 254 292 258 305 267C317 275 340 287 343 300ZM400 300C404 320 380 351 361 366C342 381 309 385 285 388C260 391 238 391 215 386C193 381 167 373 150 358C134 344 122 321 119 300C116 278 117 246 132 229C147 213 186 203 211 202C235 200 258 215 280 222C302 229 321 232 341 245C361 258 397 279 400 300ZM458 300C459 327 421 366 394 385C367 405 329 413 297 418C265 424 233 425 202 419C172 412 136 401 113 381C91 361 72 329 68 300C64 270 67 225 89 204C111 183 166 176 200 174C234 173 260 187 291 195C322 202 356 202 384 220C411 237 456 272 458 300ZM512 300C511 335 456 378 423 403C389 428 348 441 309 450C270 458 228 460 189 452C150 444 104 429 75 404C45 378 19 337 14 300C10 262 19 205 49 180C78 155 149 154 191 152C233 149 263 158 303 165C343 171 395 169 430 192C465 214 514 264 512 300ZM723 690C722 694 715 699 711 702C707 706 703 710 698 711C693 713 687 712 681 711C675 710 668 709 663 705C659 701 655 695 655 690C655 684 660 677 664 674C669 671 677 673 682 672C688 671 692 667 698 667C704 668 714 669 718 673C722 676 725 685 723 690ZM766 690C763 701 748 710 739 719C730 728 721 737 710 741C698 744 683 743 669 740C655 738 637 735 627 727C617 718 608 701 610 690C611 678 623 663 634 656C645 650 660 652 673 649C686 645 698 634 711 634C725 634 747 641 756 650C765 659 768 678 766 690ZM810 690C805 708 785 723 770 738C756 752 742 768 723 774C704 781 679 778 656 774C633 771 599 767 583 753C567 739 557 709 561 690C564 670 587 650 604 638C621 627 642 629 663 621C683 614 705 592 728 592C751 593 785 609 798 625C812 641 814 671 810 690ZM851 690C845 715 821 737 802 756C783 776 763 800 737 808C710 817 675 814 642 809C609 805 558 800 537 780C516 760 509 716 516 690C523 663 555 639 577 623C600 606 622 603 650 591C679 578 715 545 746 547C777 548 820 578 837 601C855 625 856 664 851 690ZM783 190C783 193 780 197 777 200C774 203 772 207 767 209C763 211 756 212 751 211C746 210 738 207 736 204C734 200 738 194 739 190C740 185 740 183 742 179C744 176 747 171 751 169C756 167 764 164 769 166C773 168 776 174 779 178C781 182 784 186 783 190ZM812 190C811 197 804 205 798 213C792 220 787 230 777 234C768 239 751 241 740 238C729 236 713 227 710 219C706 211 716 198 718 190C719 181 715 173 719 166C723 158 731 146 741 142C751 138 769 135 779 139C789 143 795 156 801 165C806 173 812 182 812 190ZM845 190C845 202 832 215 823 227C814 240 806 258 790 265C774 273 745 276 727 271C710 266 688 249 683 235C677 222 692 204 693 190C694 175 683 161 689 148C695 134 711 116 728 110C745 104 775 103 791 110C807 116 817 137 826 150C835 163 846 177 845 190ZM212 770C213 775 204 783 199 787C193 791 186 793 179 794C173 795 166 795 160 794C153 793 146 790 141 786C137 782 133 776 132 770C131 763 132 754 137 750C141 746 153 744 159 744C166 744 172 746 178 748C184 749 192 749 197 753C203 756 212 764 212 770ZM261 770C260 782 241 796 229 805C217 814 204 819 190 822C177 825 162 825 148 823C135 820 118 815 108 806C98 797 89 783 87 770C86 756 89 736 100 728C110 719 135 720 149 719C164 718 174 720 188 722C202 724 221 724 233 731C245 739 262 757 261 770Z'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header) + 16px); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--paper);
  font: 16px/1.65 var(--text);
  background-color: var(--night);
  background-image:
    radial-gradient(ellipse at 80% -10%, rgba(182, 255, 59, 0.07), transparent 55%),
    radial-gradient(ellipse at 0% 110%, rgba(255, 122, 26, 0.05), transparent 50%),
    var(--contour-map),
    linear-gradient(rgba(239, 238, 230, 0.022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(239, 238, 230, 0.022) 1px, transparent 1px);
  background-size: auto, auto, 900px 900px, 120px 120px, 120px 120px;
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--route); color: var(--night); }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 2px solid var(--route); outline-offset: 3px; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.skip {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 100;
  padding: 8px 14px;
  background: var(--route);
  color: var(--night);
  font-weight: 700;
  transform: translateY(-160%);
}
.skip:focus { transform: none; }

/* Route */
#routeLine {
  position: fixed;
  top: 0;
  left: calc(var(--rail) - 12px);
  z-index: 1;
  width: 24px;
  height: 100vh;
  height: 100dvh;
  overflow: visible;
  pointer-events: none;
}
.route-base { stroke: rgba(239, 238, 230, 0.2); stroke-width: 2; stroke-dasharray: 7 9; }
.route-lit {
  stroke: var(--route);
  stroke-width: 3;
  stroke-dasharray: 1 1;
  stroke-dashoffset: 1;
  filter: drop-shadow(0 0 4px rgba(182, 255, 59, 0.55));
}
.route-runner {
  fill: var(--night);
  stroke: var(--route);
  stroke-width: 3;
  filter: drop-shadow(0 0 8px rgba(182, 255, 59, 0.8));
}

/* Top bar */
#topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 28px;
  height: var(--header);
  padding: 0 clamp(16px, 3vw, 40px) 0 calc(var(--rail) - 17px);
  background: rgba(11, 15, 13, 0.82);
  border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font: 800 22px/1 var(--display);
  letter-spacing: 0.02em;
  text-decoration: none;
}
.brand img { display: block; }
#site-nav { display: flex; align-items: center; gap: 4px; margin-left: 12px; }
#site-nav a {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 15px;
  text-decoration: none;
  transition: color .2s, background-color .2s;
}
#site-nav a small { font: 600 11px/1 var(--mono); letter-spacing: 0.04em; color: rgba(239, 238, 230, 0.55); }
#site-nav a:hover { color: var(--paper); background: rgba(239, 238, 230, 0.06); }
#site-nav a.is-on { color: var(--paper); }
#site-nav a.is-on small { color: var(--route); }
#site-nav #adminLink { color: var(--aid); border: 1px solid rgba(255, 122, 26, 0.45); }
.top-tools { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.language-picker select {
  height: 38px;
  padding: 0 30px 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--night-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23a3aba4' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 11px center;
  font-size: 14px;
  appearance: none;
}
.account { position: relative; }
#authButton {
  height: 38px;
  padding: 0 16px;
  border: 1px solid var(--route);
  border-radius: 999px;
  background: transparent;
  color: var(--route);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  transition: background-color .2s, color .2s;
}
#authButton:hover { background: var(--route); color: var(--night); }
#authButton.is-avatar {
  width: 38px;
  padding: 0;
  background: var(--route);
  color: var(--night);
  font: 800 16px/1 var(--display);
}
#userMenu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 180px;
  padding: 12px;
  background: var(--night-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}
#userName { padding: 2px 4px 10px; color: var(--muted); font-size: 13px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
#logoutButton {
  width: 100%;
  margin-top: 8px;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  text-align: start;
}
#logoutButton:hover { background: rgba(239, 238, 230, 0.08); }
.menu {
  display: none;
  width: 40px;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
}
.menu span { display: block; height: 2px; background: var(--paper); transition: transform .2s, opacity .2s; }
.nav-open .menu span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-open .menu span:nth-child(2) { opacity: 0; }
.nav-open .menu span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Sections & milestones */
.km {
  position: relative;
  z-index: 2;
  padding: 96px max(24px, calc(100% - var(--gutter) - 1160px)) 96px var(--gutter);
}
.milestone {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 36px;
  font-family: var(--mono);
}
.milestone::before {
  content: "";
  position: absolute;
  top: 50%;
  left: calc(var(--rail) - var(--gutter) - 9px);
  width: 18px;
  height: 18px;
  border: 4px solid var(--night);
  border-radius: 50%;
  background: var(--route);
  box-shadow: 0 0 0 2px var(--route);
  transform: translateY(-50%);
  transition: box-shadow .4s;
}
.is-reached > .milestone::before { box-shadow: 0 0 0 2px var(--route), 0 0 0 9px rgba(182, 255, 59, 0.16), 0 0 28px rgba(182, 255, 59, 0.7); }
.milestone::after { content: ""; flex: 1; border-top: 1px dashed var(--line); }
.km-no { display: inline-flex; align-items: baseline; gap: 6px; color: var(--route); font-size: 44px; font-weight: 700; line-height: 1; letter-spacing: -0.02em; }
.km-no small { font-size: 13px; font-weight: 600; letter-spacing: 0.1em; color: var(--muted); }
.km-name {
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font: 600 14px/1.3 var(--text);
  letter-spacing: 0.2em;
}
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}
.section-head h2 { font-size: clamp(30px, 4vw, 52px); line-height: 1.12; letter-spacing: -0.01em; }
.section-head p { max-width: 60ch; margin-top: 12px; color: var(--muted); }

/* Buttons */
.ui-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 22px;
  border: 1.5px solid transparent;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  transition: transform .2s, background-color .2s, color .2s, border-color .2s;
}
.ui-button.primary { background: var(--route); color: var(--night); }
.ui-button.primary:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(182, 255, 59, 0.22); }
.ui-button.ghost { background: transparent; border-color: rgba(239, 238, 230, 0.35); color: var(--paper); }
.ui-button.ghost:hover { border-color: var(--paper); }
.ui-button:disabled { cursor: default; opacity: 0.6; transform: none; box-shadow: none; }

/* KM 0 */
#start { min-height: calc(100vh - var(--header)); padding-top: 64px; }
#start h1 { display: grid; gap: 18px; }
.wordmark {
  font: 800 min(196px, 13.5vw, calc((100vw - 180px) / 6.2))/0.8 var(--display);
  letter-spacing: -0.045em;
  color: var(--paper);
}
.wordmark i { font-style: normal; color: var(--route); }
.slogan {
  justify-self: start;
  padding: 6px 14px 8px;
  background: var(--route);
  color: var(--night);
  font-size: clamp(22px, 3.2vw, 42px);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: 0.02em;
  transform: rotate(-1.2deg);
  transform-origin: left center;
}
.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  align-items: end;
  gap: clamp(28px, 5vw, 72px);
  margin-top: 48px;
}
.lede { max-width: 34em; font-size: clamp(17px, 1.6vw, 20px); color: var(--paper); }
.cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }
.profile { position: relative; margin: 0; padding-bottom: 26px; }
.profile svg { display: block; width: 100%; height: 150px; }
.profile-fill { fill: rgba(182, 255, 59, 0.08); }
.profile-line { fill: none; stroke: var(--route); stroke-width: 2.5; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.profile figcaption { position: absolute; inset: 0; font: 600 11px/1 var(--mono); color: var(--muted); }
.profile figcaption span { position: absolute; bottom: 0; transform: translateX(-50%); white-space: nowrap; }
.profile figcaption span::before {
  content: "";
  position: absolute;
  bottom: 18px;
  left: 50%;
  height: 150px;
  border-left: 1px dashed rgba(239, 238, 230, 0.22);
}
.profile figcaption span:nth-child(1) { left: 0; transform: none; }
.profile figcaption span:nth-child(1)::before { left: 0; }
.profile figcaption span:nth-child(2) { left: 30%; }
.profile figcaption span:nth-child(3) { left: 70%; }
.profile figcaption span:nth-child(4) { right: 0; transform: none; }
.profile figcaption span:nth-child(4)::before { left: auto; right: 0; }

#publicStats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 64px;
  background: rgba(8, 11, 9, 0.72);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
#publicStats > div {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: end;
  column-gap: 10px;
  padding: 18px 22px 20px;
  border-left: 1px solid var(--line);
}
#publicStats > div:first-child { border-left: 0; }
#publicStats span {
  grid-column: 1 / -1;
  margin-bottom: 12px;
  font: 600 12px/1.2 var(--text);
  letter-spacing: 0.12em;
  color: var(--muted);
}
#publicStats b {
  position: relative;
  padding: 4px 10px;
  border-radius: 5px;
  background: linear-gradient(#1b231e 50%, #141a16 50%);
  font: 700 clamp(28px, 3.4vw, 44px)/1 var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
#publicStats b::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background: rgba(0, 0, 0, 0.7);
}
#publicStats i { font: 600 13px/1 var(--mono); font-style: normal; color: var(--route); }

.prep-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 72px 0 18px;
  font-size: 15px;
  letter-spacing: 0.2em;
  color: var(--aid);
}
.prep-title::before { content: ""; width: 10px; height: 10px; background: var(--aid); transform: rotate(45deg); }
.prep { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.prep article {
  position: relative;
  padding: 22px 22px 24px;
  background: rgba(17, 23, 19, 0.8);
  border: 1px solid var(--line);
  border-top: 3px solid var(--aid);
  border-radius: 4px 4px 10px 10px;
}
.prep .cp {
  display: inline-block;
  padding: 3px 8px;
  border: 1px solid rgba(255, 122, 26, 0.6);
  border-radius: 3px;
  font: 700 11px/1.2 var(--mono);
  letter-spacing: 0.12em;
  color: var(--aid);
}
.prep h3 { margin: 14px 0 8px; font-size: 21px; }
.prep p { color: var(--muted); font-size: 15px; }

/* Sport filter */
.sport-filter { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.sport-filter button {
  min-height: 36px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(17, 23, 19, 0.7);
  color: var(--muted);
  font-size: 14px;
  transition: background-color .2s, color .2s, border-color .2s;
}
.sport-filter button:hover { color: var(--paper); border-color: rgba(239, 238, 230, 0.4); }
.sport-filter button[aria-pressed="true"] { background: var(--paper); border-color: var(--paper); color: var(--night); font-weight: 700; }

/* KM 3 */
.log-board {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 18px;
}
.calendar {
  padding: 18px;
  background: rgba(10, 14, 12, 0.85);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.calendar-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
#calendarTitle { font: 700 18px/1.2 var(--mono); letter-spacing: 0.02em; }
.icon-button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  font-size: 18px;
  transition: border-color .2s, color .2s;
}
.icon-button:hover { border-color: var(--route); color: var(--route); }
.calendar-week, .calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.calendar-week span { padding: 0 0 8px; text-align: center; font: 600 12px/1 var(--mono); color: var(--muted); }
.calendar-grid { gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.calendar-day {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  min-height: 96px;
  padding: 6px;
  background: var(--night);
}
.calendar-day.is-other { background: #090c0a; }
.calendar-day.is-other .day-number { color: rgba(163, 171, 164, 0.5); }
.day-number { font: 600 12px/22px var(--mono); color: var(--muted); }
.is-today .day-number {
  align-self: flex-start;
  width: 24px;
  border-radius: 50%;
  background: var(--route);
  color: var(--night);
  text-align: center;
}
.workout-chip {
  min-width: 0;
  padding: 3px 6px;
  border: 0;
  border-left: 2px solid var(--route);
  border-radius: 3px;
  background: rgba(182, 255, 59, 0.13);
  font-size: 12px;
  line-height: 1.35;
  text-align: start;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.workout-chip:hover { background: rgba(182, 255, 59, 0.24); }
.chip-short { display: none; }
.day-add {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid rgba(182, 255, 59, 0.5);
  border-radius: 50%;
  background: var(--night);
  color: var(--route);
  font: 600 15px/1 var(--mono);
  opacity: 0;
  transition: opacity .15s;
}
.calendar-day:hover .day-add, .day-add:focus-visible { opacity: 1; }
@media (hover: none) { .day-add { opacity: 0.75; } }
#monthSummary {
  display: flex;
  flex-direction: column;
  padding: 22px;
  background: var(--paper);
  color: var(--paper-ink);
  border-radius: 12px;
}
#monthSummary h3 { font-size: 15px; letter-spacing: 0.2em; }
#monthSummary dl { display: grid; gap: 14px; margin: 18px 0 0; }
#monthSummary dl > div { padding-top: 12px; border-top: 2px dashed rgba(18, 21, 18, 0.2); }
#monthSummary dt { font-size: 13px; color: var(--paper-muted); }
#monthSummary dd { margin: 2px 0 0; font: 700 40px/1.05 var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.03em; }
.summary-hint { margin-top: auto; padding-top: 18px; font-size: 13px; color: var(--paper-muted); }
#logLocked {
  position: absolute;
  inset: -1px;
  z-index: 3;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 16px;
  padding: 24px;
  border-radius: 12px;
  background: rgba(11, 15, 13, 0.55);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  text-align: center;
}
#logLocked p { font: 600 13px/1.4 var(--mono); letter-spacing: 0.08em; color: var(--paper); }

/* KM 7 */
.party-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 26px 22px; }
.empty-state {
  grid-column: 1 / -1;
  padding: 40px 24px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  color: var(--muted);
  text-align: center;
}
.bib {
  --hole: radial-gradient(circle, var(--night) 4px, rgba(0, 0, 0, 0.25) 4.5px, transparent 5.5px);
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 30px 28px 22px;
  border-radius: 6px;
  background:
    var(--hole) 14px 14px / 22px 22px no-repeat,
    var(--hole) calc(100% - 14px) 14px / 22px 22px no-repeat,
    var(--hole) 14px calc(100% - 14px) / 22px 22px no-repeat,
    var(--hole) calc(100% - 14px) calc(100% - 14px) / 22px 22px no-repeat,
    var(--paper);
  color: var(--paper-ink);
  box-shadow: 0 22px 44px rgba(0, 0, 0, 0.4);
  transform: rotate(-0.6deg);
  transition: transform .25s;
}
.bib:nth-child(even) { transform: rotate(0.5deg); }
.bib:hover { transform: rotate(0) translateY(-3px); }
.bib :focus-visible { outline-color: var(--paper-ink); }
.bib.is-past, .bib.is-past:nth-child(even) { transform: none; box-shadow: 0 10px 24px rgba(0, 0, 0, 0.3); }
.bib.is-past .bib-top { border-bottom-style: dashed; border-bottom-color: var(--paper-muted); }
.bib.is-past .bib-sport { color: var(--paper-muted); }
.bib.is-past .bib-progress span { background: var(--paper-muted); }
.bib-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px 10px;
  border-bottom: 3px solid var(--paper-ink);
  font: 700 11px/1.3 var(--mono);
  letter-spacing: 0.14em;
  color: var(--paper-muted);
}
.bib-sport {
  margin: 14px 0 2px;
  font: 800 clamp(40px, 4.6vw, 56px)/1 var(--mono);
  letter-spacing: -0.03em;
  overflow-wrap: anywhere;
}
.bib h3 { font-size: 19px; line-height: 1.35; overflow-wrap: anywhere; }
.bib-meta { display: grid; gap: 4px; margin: 14px 0 0; padding: 0; list-style: none; font-size: 14px; color: var(--paper-muted); }
.bib-meta li { overflow-wrap: anywhere; }
.bib-meta .bib-when { color: var(--paper-ink); font-family: var(--mono); font-weight: 700; }
.bib-count { display: flex; justify-content: space-between; margin-top: 16px; font: 700 13px/1 var(--mono); }
.bib-members {
  display: grid;
  gap: 4px;
  margin: 10px 0 0;
  padding: 10px 12px;
  list-style: none;
  border-radius: 4px;
  background: rgba(18, 21, 18, 0.06);
  font-size: 13px;
  color: var(--paper-ink);
}
.bib-members-label { color: var(--paper-muted); font: 700 11px/1.2 var(--mono); letter-spacing: 0.04em; text-transform: uppercase; }
.bib-contact-hint { margin: 8px 0 0; font-size: 12px; color: var(--paper-muted); }
.bib-progress { height: 8px; margin: 8px 0 18px; border-radius: 99px; background: rgba(18, 21, 18, 0.12); overflow: hidden; }
.bib-progress span { display: block; height: 100%; border-radius: inherit; background: var(--paper-ink); }
.bib.is-full .bib-progress span { background: #8a3b0a; }
.bib-note { margin-top: 12px; padding: 10px 12px; border-radius: 4px; background: rgba(18, 21, 18, 0.06); font-size: 14px; overflow-wrap: anywhere; }
.bib-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
  padding: 16px 14px 0;
  border-top: 2px dashed rgba(18, 21, 18, 0.25);
}
.bib .ui-button { min-height: 38px; padding: 0 16px; font-size: 14px; }
.bib .ui-button.primary { background: var(--paper-ink); color: var(--route); }
.bib .ui-button.ghost { border-color: rgba(18, 21, 18, 0.35); color: var(--paper-ink); }
.bib .ui-button.ghost:hover { border-color: var(--paper-ink); }
.bib-tag {
  position: absolute;
  top: 64px;
  right: -8px;
  padding: 5px 12px;
  background: var(--aid);
  color: var(--night);
  font: 800 12px/1.2 var(--text);
  letter-spacing: 0.1em;
  box-shadow: 0 6px 14px rgba(255, 122, 26, 0.35);
}
.bib-ended { background: var(--paper-muted); color: var(--paper); box-shadow: none; }
.bib-tag::after {
  content: "";
  position: absolute;
  top: 100%;
  right: 0;
  border-top: 6px solid rgba(0, 0, 0, 0.45);
  border-right: 8px solid transparent;
}

/* KM 10 */
#finish { padding-top: 120px; padding-bottom: 56px; }
#finish::before {
  content: "";
  position: absolute;
  top: 40px;
  left: var(--gutter);
  right: max(24px, calc(100% - var(--gutter) - 1160px));
  height: 24px;
  background: conic-gradient(var(--paper) 25%, var(--night) 0 50%, var(--paper) 0 75%, var(--night) 0) 0 0 / 24px 24px;
  border: 1px solid rgba(239, 238, 230, 0.3);
  opacity: 0.8;
}
.finish-line { font-size: clamp(28px, 5vw, 64px); font-weight: 800; line-height: 1.1; letter-spacing: -0.01em; }
.privacy { max-width: 52ch; margin-top: 20px; color: var(--muted); font-size: 14px; }
#finish nav { margin-top: 28px; }
.colophon { margin-top: 48px; font: 600 12px/1 var(--mono); letter-spacing: 0.2em; color: var(--muted); }

/* 404 */
.lost { display: flex; flex-direction: column; justify-content: center; min-height: 100vh; }
.lost h1 { font-size: clamp(44px, 9vw, 120px); line-height: 1; letter-spacing: -0.02em; }
.lost .milestone .km-no { color: var(--aid); }
.lost .milestone::before { background: var(--aid); box-shadow: 0 0 0 2px var(--aid); }
.lost .lede { margin-top: 20px; color: var(--muted); }

/* Dialogs */
.app-dialog {
  width: min(520px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  padding: 30px 28px 26px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--route);
  border-radius: 14px;
  background: var(--night-2);
  color: var(--paper);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
.app-dialog::backdrop { background: rgba(4, 6, 5, 0.72); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.app-dialog form { display: grid; gap: 14px; }
.app-dialog h3 { font-size: 24px; line-height: 1.25; }
.dialog-head { display: grid; gap: 6px; margin-bottom: 4px; }
.dialog-lead { color: var(--muted); font-size: 14px; }
.dialog-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
}
.dialog-close:hover { background: rgba(239, 238, 230, 0.08); color: var(--paper); }
.dialog-tabs { display: flex; gap: 4px; margin-bottom: 22px; border-bottom: 1px solid var(--line); }
.dialog-tabs button {
  margin-bottom: -1px;
  padding: 8px 14px 10px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}
.dialog-tabs button.is-active { color: var(--paper); border-bottom-color: var(--route); }
.app-dialog label { display: grid; gap: 6px; min-width: 0; font-size: 13px; font-weight: 600; color: var(--paper); }
.app-dialog input, .app-dialog select {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid rgba(239, 238, 230, 0.22);
  border-radius: 8px;
  background: var(--night);
  font-size: 15px;
  font-weight: 400;
  color-scheme: dark;
  transition: border-color .2s;
}
.app-dialog input:focus, .app-dialog select:focus { border-color: var(--route); }
.app-dialog input::placeholder { color: rgba(163, 171, 164, 0.75); }
.field-hint { font-size: 12px; font-weight: 400; color: var(--muted); }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-field { display: grid; gap: 6px; }
.form-label { font-size: 13px; font-weight: 600; }
.form-error { min-height: 1.2em; color: #ffb07a; font-size: 14px; }
.form-error:empty { min-height: 0; }
.app-dialog button[type="submit"] { width: 100%; margin-top: 4px; }
.dialog-switch { color: var(--muted); font-size: 14px; text-align: center; }
.dialog-switch button { padding: 2px 4px; border: 0; background: none; color: var(--route); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }

/* Entrance */
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
#start > * { animation: rise .8s cubic-bezier(.2, .7, .2, 1) both; }
#start > :nth-child(2) { animation-delay: .08s; }
#start > :nth-child(3) { animation-delay: .2s; }
#start > :nth-child(4) { animation-delay: .32s; }
#start > :nth-child(n+5) { animation-delay: .42s; }

/* Mobile */
@media (max-width: 1080px) {
  #site-nav a small { display: none; }
  .hero-grid { grid-template-columns: 1fr; }
  .log-board { grid-template-columns: 1fr; }
  #monthSummary dl { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #monthSummary dl > div { padding-top: 10px; }
}

@media (max-width: 760px) {
  :root { --rail: 16px; --gutter: 40px; --header: 60px; }
  body { font-size: 15px; }
  #topbar { gap: 8px; padding: 0 12px 0 calc(var(--rail) + 8px); }
  .brand span { display: none; }
  .menu { display: inline-flex; }
  #site-nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    margin: 0;
    padding: 8px 16px 16px var(--gutter);
    background: rgba(11, 15, 13, 0.97);
    border-bottom: 1px solid var(--line);
  }
  .nav-open #site-nav { display: flex; }
  #site-nav a { padding: 14px 4px; border-bottom: 1px solid var(--line); border-radius: 0; font-size: 17px; }
  #site-nav a small { display: inline; }
  #site-nav #adminLink { border: 0; border-bottom: 1px solid var(--line); }
  .top-tools { gap: 6px; }
  .language-picker select { height: 36px; padding: 0 24px 0 8px; background-position: right 8px center; font-size: 13px; }
  #authButton { height: 36px; padding: 0 12px; font-size: 13px; }
  #authButton.is-avatar { width: 36px; }
  .km { padding: 64px 16px 64px var(--gutter); }
  .milestone { margin-bottom: 26px; gap: 12px; }
  .milestone::before { width: 16px; height: 16px; left: calc(var(--rail) - var(--gutter) - 8px); border-width: 3px; }
  .km-no { font-size: 34px; }
  #start { padding-top: 40px; }
  .wordmark { font-size: calc((100vw - 64px) / 6.2); }
  .slogan { font-size: 21px; }
  .hero-grid { margin-top: 32px; }
  .profile svg { height: 96px; }
  .profile figcaption span::before { height: 96px; }
  #publicStats { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 44px; }
  #publicStats > div { padding: 14px 14px 16px; }
  #publicStats > div:nth-child(3) { border-left: 0; }
  #publicStats > div:nth-child(n+3) { border-top: 1px solid var(--line); }
  #publicStats b { font-size: 28px; }
  .prep-title { margin-top: 52px; }
  .prep { grid-template-columns: 1fr; }
  .section-head { flex-direction: column; align-items: stretch; }
  .section-head .ui-button { align-self: flex-start; }
  .sport-filter { flex-wrap: nowrap; overflow-x: auto; margin-right: -16px; padding: 2px 16px 6px 2px; scrollbar-width: none; }
  .sport-filter button { flex: none; }
  .calendar { padding: 10px; }
  .calendar-day { min-height: 62px; padding: 3px; gap: 3px; }
  .day-number { font-size: 11px; line-height: 20px; }
  .is-today .day-number { width: 20px; }
  .workout-chip { padding: 2px 3px; font-size: 11px; text-align: center; }
  .chip-full { display: none; }
  .chip-short { display: inline; }
  .day-add { top: 3px; right: 3px; width: 20px; height: 20px; font-size: 13px; }
  #monthSummary { padding: 18px; }
  #monthSummary dd { font-size: 26px; }
  .party-grid { grid-template-columns: 1fr; }
  .bib, .bib:nth-child(even) { transform: none; }
  .bib { padding: 28px 20px 20px; }
  #finish { padding-top: 96px; }
  #finish::before { right: 16px; }
  .form-row { grid-template-columns: 1fr; }
  .form-field .form-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .app-dialog { padding: 26px 18px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .route-lit { stroke-dashoffset: 0 !important; }
  .route-runner { display: none; }
  .slogan { transform: none; }
}
