:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --ink: #16181d;
  --ink-2: #5a5e66;
  --line: #e2e0da;
  --accent: #e5562a;
  --accent-ink: #ffffff;
  --good: #1f7a4d;
  --bad: #b3261e;
  --radius: 14px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317;
    --surface: #1b1e24;
    --ink: #f1f1ee;
    --ink-2: #a3a7ae;
    --line: #2c3038;
    --accent: #f06a3d;
    --accent-ink: #14100e;
    --good: #5fc892;
    --bad: #f2867f;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: inherit; }
h1 { font-size: 1.45rem; line-height: 1.2; margin: 0 0 4px; text-wrap: balance; }
h2 { font-size: 1.05rem; margin: 28px 0 10px; }
p { margin: 0 0 10px; }
.muted { color: var(--ink-2); }
.small { font-size: 0.87rem; }

.bar {
  position: sticky; top: 0; z-index: 5;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 12px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.brand { grid-column: 2; font-weight: 700; text-decoration: none; letter-spacing: -0.01em; }
.back { grid-column: 1; grid-row: 1; justify-self: start; font-size: 0.95rem; color: var(--ink-2);
        text-decoration: none; padding: 6px 12px 6px 0; }
.back[hidden] { display: none; }

main { max-width: 720px; margin: 0 auto; padding: 20px 16px 120px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.stack > * + * { margin-top: 12px; }

/* buttons and inputs */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; width: 100%;
  border: 0; border-radius: 12px;
  background: var(--accent); color: var(--accent-ink);
  font: inherit; font-weight: 650; text-decoration: none; cursor: pointer;
}
.button.quiet { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.button.danger { background: transparent; color: var(--bad); border: 1px solid var(--line); }
.button[disabled] { opacity: 0.5; cursor: default; }
label { display: block; font-size: 0.9rem; font-weight: 600; margin-bottom: 6px; }
input[type="text"], input[type="password"] {
  width: 100%; min-height: 48px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--ink); font: inherit;
}
select {
  width: 100%; min-height: 48px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--ink); font: inherit;
}
input[hidden] { display: none; }
input[type="file"] { width: 100%; font: inherit; color: var(--ink-2); }
input[type="file"]::file-selector-button {
  min-height: 44px; margin-right: 12px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--ink); font: inherit; font-weight: 600;
}
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.link { background: none; border: 0; padding: 8px 0; color: var(--accent); font: inherit;
        text-decoration: underline; cursor: pointer; }
.rename { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.rename[hidden] { display: none; }
.rename input { flex: 1 1 100%; }
.rename .button { flex: 1; width: auto; }
.login { max-width: 380px; margin: 12vh auto 0; }

/* route list */
.route-row {
  display: grid; grid-template-columns: 64px 1fr auto; gap: 14px; align-items: center;
  text-decoration: none; padding: 10px;
}
.route-row img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; }
.route-row strong { display: block; }
.chev { color: var(--ink-2); font-size: 1.3rem; }
.empty { text-align: center; padding: 36px 16px; color: var(--ink-2); }

/* hold picker */
.picker {
  position: relative; border-radius: var(--radius); overflow: hidden;
  background: #000; line-height: 0; touch-action: pan-x pan-y pinch-zoom;
}
.picker img { width: 100%; height: auto; display: block; }
.picker svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.hold { fill: transparent; stroke: rgba(255, 255, 255, 0.55); stroke-width: 1.5; cursor: pointer;
        vector-effect: non-scaling-stroke; paint-order: stroke; }
.hold.on { fill: rgba(255, 255, 255, 0.12); stroke: #fff; stroke-width: 3;
           filter: drop-shadow(0 0 3px rgba(0, 0, 0, 0.9)); }
.hit { fill: transparent; stroke: transparent; stroke-width: 22; vector-effect: non-scaling-stroke;
       pointer-events: all; cursor: pointer; }
.hold.volume { stroke-dasharray: 7 5; }
/* where the route starts and ends: hands green, feet blue, top pink */
.hold.start-hand { stroke: #35d07f; fill: rgba(53, 208, 127, 0.28); stroke-width: 4; }
.hold.start-foot { stroke: #4aa8ff; fill: rgba(74, 168, 255, 0.28); stroke-width: 4; }
.hold.top { stroke: #ff4d8d; fill: rgba(255, 77, 141, 0.28); stroke-width: 4; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0 0 14px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i, .chip i.start-hand, .chip i.start-foot, .chip i.top { width: 14px; height: 14px; border-radius: 50%; }
i.start-hand { background: #35d07f; }
i.start-foot { background: #4aa8ff; }
i.top { background: #ff4d8d; }
.startcheck { margin: 12px 0 0; font-weight: 600; }
.check-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.chip.right[aria-pressed="true"] { background: var(--good); border-color: var(--good); color: #fff; }
.chip.wrong[aria-pressed="true"] { background: var(--bad); border-color: var(--bad); color: #fff; }
.trace { margin: 10px 0 0; font-size: 0.75rem; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 260px; overflow: auto; }
details.card summary { cursor: pointer; overflow-wrap: anywhere; }
.card.handled { opacity: 0.55; }
.startcheck.up { color: var(--good); }
.startcheck.down { color: var(--bad); }
.sketch { fill: rgba(229, 86, 42, 0.25); stroke: #fff; stroke-width: 2.5; pointer-events: none;
          vector-effect: non-scaling-stroke; }
.sketch.dot { stroke-width: 12; stroke-linecap: round; stroke-linejoin: round; }
svg.drawing { cursor: crosshair; }
svg.drawing .hit { pointer-events: none; }
.drawbar { margin-top: 12px; }
.drawbar .row { display: flex; gap: 8px; margin-top: 8px; }
.drawbar .row .button { flex: 1; width: auto; padding: 0 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--ink); font: inherit; cursor: pointer;
}
.chip[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.chip i { width: 16px; height: 16px; border-radius: 50%; border: 1px solid rgba(128, 128, 128, 0.5); }
.chip span { color: var(--ink-2); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.savebar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--bg); border-top: 1px solid var(--line);
}
.savebar > div { max-width: 688px; margin: 0 auto; }

/* climbs */
.climb-row { display: flex; justify-content: space-between; gap: 12px; align-items: center;
             text-decoration: none; padding: 14px 16px; }
.state { font-size: 0.85rem; font-weight: 600; white-space: nowrap; }
.state.done { color: var(--good); }
.state.failed { color: var(--bad); }

.progress { text-align: center; padding: 40px 16px; }
.spinner {
  width: 40px; height: 40px; margin: 0 auto 18px; border-radius: 50%;
  border: 4px solid var(--line); border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

/* results */
video { width: 100%; border-radius: var(--radius); background: #000; display: block; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 16px 0; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.tile b { display: block; font-size: 1.45rem; line-height: 1.2; font-variant-numeric: tabular-nums; }
.tile span { font-size: 0.82rem; color: var(--ink-2); }
.coach { margin-top: 16px; }
.coach p:last-child { margin-bottom: 0; }
.insight h3 { font-size: 1rem; margin: 0 0 4px; }
.insight .tip { border-left: 3px solid var(--accent); padding-left: 10px; margin-top: 8px; }
.shots { display: flex; gap: 8px; margin-top: 12px; }
.shots figure { margin: 0; flex: 0 1 140px; }
.shots img, .figure img { width: 100%; border-radius: 10px; display: block; }
.shots figcaption { font-size: 0.8rem; color: var(--ink-2); margin-top: 4px; }
.figure { background: #fcfcfb; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
.map { max-width: 420px; margin: 0 auto; }
ul.plain { margin: 0; padding-left: 18px; }
ul.plain li + li { margin-top: 6px; }
.sequence { font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.changes { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; margin: 4px 0 8px; }
.changes th, .changes td { text-align: left; padding: 8px 8px 8px 0; border-bottom: 1px solid var(--line); }
.changes thead th { font-size: 0.82rem; font-weight: 600; color: var(--ink-2); }
.changes tbody th { font-weight: 400; }
.changes td:last-child { text-align: right; padding-right: 0; font-size: 0.87rem; font-weight: 600; }
.changes .up { color: var(--good); }
.changes .down { color: var(--bad); }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: 96px; z-index: 10;
  max-width: 480px; margin: 0 auto; padding: 14px 16px;
  background: var(--ink); color: var(--bg); border-radius: 12px;
}

@media (min-width: 600px) {
  .tiles { grid-template-columns: repeat(4, 1fr); }
  .button { width: auto; }
  .savebar .button { width: 100%; }
}

/* header: language switch on the right */
.lang { grid-column: 3; justify-self: end; background: none; border: 0; padding: 6px 0 6px 12px;
        color: var(--ink-2); font: inherit; font-size: 0.9rem; cursor: pointer; text-decoration: underline; }
.bar { padding-top: calc(12px + env(safe-area-inset-top)); }

input[type="number"], textarea {
  width: 100%; min-height: 48px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--ink); font: inherit;
}
textarea { padding: 12px 14px; resize: vertical; }
.check { display: flex; gap: 12px; align-items: flex-start; font-weight: 400; margin: 0; }
.check[hidden] { display: none; }
.check input { flex: none; width: 24px; height: 24px; margin: 0; accent-color: var(--accent); }
.row { display: flex; gap: 8px; }
.row .button { flex: 1; width: auto; padding: 0 10px; }
.links { display: flex; flex-wrap: wrap; gap: 4px 20px; margin: 0; }
.foot { margin-top: 40px; }
.grade { display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 999px;
         border: 1px solid var(--line); font-size: 0.8rem; font-weight: 600; vertical-align: middle; }
.tag { display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 999px;
       background: var(--line); color: var(--ink); font-size: 0.8rem; }
.up { color: var(--good); }
.down { color: var(--bad); }
.note p { white-space: pre-wrap; }

/* a few seconds of video in place of two stills */
.clipbox { margin: 12px 0 0; max-width: 240px; }
.clipbox figcaption { font-size: 0.8rem; color: var(--ink-2); margin-top: 4px; }
.clip { border-radius: 10px; }

/* move by move */
.moves .wall { position: relative; max-width: 380px; margin: 0 auto 10px; border-radius: 10px;
               overflow: hidden; background: #000; line-height: 0; }
.moves .wall img { width: 100%; display: block; filter: brightness(0.6); }
.moves .wall svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.moves h3 { font-size: 1.05rem; margin: 2px 0 4px; }
.moves .how { color: var(--accent); font-weight: 600; margin-bottom: 4px; }
.moves .row { margin: 12px 0 4px; }
.rhold { fill: rgba(255, 255, 255, 0.08); stroke: rgba(255, 255, 255, 0.7); stroke-width: 1.2;
         vector-effect: non-scaling-stroke; }
.rhold.left_hand, .end.left_hand, .legend .left_hand { --limb: #4aa3ff; }
.rhold.right_hand, .end.right_hand, .legend .right_hand { --limb: #ff8a3d; }
.rhold.left_foot, .end.left_foot, .legend .left_foot { --limb: #5fd38d; }
.rhold.right_foot, .end.right_foot, .legend .right_foot { --limb: #f4d03f; }
.rhold.left_hand, .rhold.right_hand, .rhold.left_foot, .rhold.right_foot {
  fill: var(--limb); fill-opacity: 0.55; stroke: var(--limb); stroke-width: 2.5; }
.rhold.new { stroke: #fff; stroke-width: 3.5; fill-opacity: 0.85; }
.num { fill: #fff; font: 700 13px system-ui, sans-serif; paint-order: stroke; stroke: rgba(0, 0, 0, 0.7);
       stroke-width: 3px; }
.bone { stroke: #fff; stroke-width: 3; stroke-linecap: round; vector-effect: non-scaling-stroke;
        filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.9)); }
.head { fill: #fff; }
.end { fill: var(--limb); stroke: #fff; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 0.82rem; color: var(--ink-2); margin-bottom: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 50%; background: var(--limb); }

/* marking the climb before upload */
.trim video { max-height: 50vh; }
.trim[hidden] { display: none; }

/* side by side */
.pair { display: grid; grid-template-columns: 1fr; gap: 8px; margin-top: 14px; }
.pair figure { margin: 0; }
.pair figcaption { font-size: 0.82rem; color: var(--ink-2); margin-top: 4px; }
.scrub { display: flex; align-items: center; gap: 12px; }
.scrub input { flex: 1; min-height: 44px; accent-color: var(--accent); }
.clock { font-variant-numeric: tabular-nums; min-width: 4.5em; text-align: right; }
.versus td { vertical-align: top; }
.versus td:last-child { text-align: left; font-size: inherit; font-weight: inherit; }
.versus .best { font-weight: 700; }
.versus tr.differs td { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.versus thead th { font-size: 0.8rem; }

/* progress chart */
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--ink-2); font: 10px system-ui, sans-serif; }
.chart .trend { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--accent); stroke: var(--surface); stroke-width: 1.5; }

@media (min-width: 600px) {
  .pair { grid-template-columns: 1fr 1fr; }
  .row .button { flex: 0 1 auto; }
}

/* accounts, comments and route details */
.badge { display: inline-block; margin-top: 4px; padding: 1px 8px; border-radius: 999px;
  font-size: 0.78rem; font-weight: 600; color: var(--ink-2); border: 1px solid currentColor; }
.badge.new { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.route-row .line { display: block; }
.filters select { flex: 1; min-width: 0; }
.news { display: block; color: inherit; text-decoration: none; border-left: 4px solid var(--accent); }
.news p { margin: 4px 0; white-space: pre-wrap; }
.tag.off { color: var(--bad); }
.row input[type="text"] { flex: 2; min-width: 0; }
form.stack[hidden] { display: none; }

/* a PDF report shown inside the app */
.pdfview { position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; background: var(--bg); }
.pdfbar { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line);
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; }
.pdfbar .button { width: auto; margin: 0; }
.pdfpages { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; padding: 12px 12px calc(12px + env(safe-area-inset-bottom)); }
.pdfpages canvas { display: block; width: 100%; max-width: 900px; height: auto; margin: 0 auto 12px; background: #fff;
  border: 1px solid var(--line); }
