:root {
  --bg: #f6f5f2; --surface: #ffffff; --text: #1f2328; --muted: #6b7078; --line: #e3e1dc;
  --accent: #2f6f5e; --accent-text: #ffffff; --accent-soft: #e3efe9;
  --danger: #b4372f; --warn-bg: #fff4d6; --warn: #7a5a00; --err-bg: #fde8e6; --info-bg: #e8f0fb;
  --sent: #2f6f5e; --notsent: #8a8f96; --parts: #a26a12;
  --board: #e9e4f6; --board-text: #4b3c84; --outdoor: #e6f1e1; --outdoor-text: #3c6a2e;
  --radius: 8px;
  /* Chart palette: categorical slots in fixed order (validated: adjacent CVD and normal-vision
     separation pass in both modes; light slots 3-5 need the legend/table relief, which every chart has). */
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100; --series-5: #e87ba4;
  --viz-grid: #e1e0d9; --viz-axis: #c3c2b7; --viz-ink: #52514e; --viz-muted: #898781;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a; --surface: #1d2024; --text: #e6e6e3; --muted: #9aa0a8; --line: #2e3237;
    --accent: #5fb39a; --accent-text: #0e1513; --accent-soft: #1f3530;
    --danger: #ef7a70; --warn-bg: #3a3014; --warn: #f0cd6e; --err-bg: #43211e; --info-bg: #1d2a3b;
    --sent: #6cc4a8; --notsent: #8a8f96; --parts: #e0a84a;
    --board: #2c2742; --board-text: #c4b8f2; --outdoor: #22311d; --outdoor-text: #a9d79a;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --series-5: #d55181;
    --viz-grid: #2c2c2a; --viz-axis: #383835; --viz-ink: #c3c2b7; --viz-muted: #898781;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: .2rem 0 1rem; }
h2 { font-size: 1.1rem; margin: 1.4rem 0 .6rem; }
h3 { font-size: .85rem; margin: 0 0 .3rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.card h2:first-child { margin-top: 0; }
.muted { color: var(--muted); font-weight: normal; }
.hint { color: var(--muted); font-size: .88rem; margin: .2rem 0 .6rem; }
code { font-size: .85em; background: var(--bg); padding: 1px 4px; border-radius: 4px; }

.top { display: flex; align-items: center; gap: 1rem; padding: .7rem max(16px, calc((100vw - 1100px) / 2));
  background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; color: var(--text); }
.top nav { display: flex; gap: .2rem; flex: 1; overflow-x: auto; }
.top nav a { padding: .35rem .65rem; border-radius: 6px; color: var(--muted); white-space: nowrap; }
.top nav a.on { color: var(--text); background: var(--bg); }
main { max-width: 1100px; margin: 0 auto; padding: 1rem 16px 4rem; }

.button, button { display: inline-block; font: inherit; padding: .42rem .85rem; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.button:hover, button:hover { text-decoration: none; border-color: var(--muted); }
.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
.primary:hover { filter: brightness(1.08); border-color: var(--accent); }
.danger { color: var(--danger); }
button.link { border: 0; background: none; padding: 0; color: var(--accent); }
button.link.danger { color: var(--danger); }

input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line);
  border-radius: 6px; padding: .4rem .55rem; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
input[type=checkbox], input[type=radio] { width: auto; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; margin: 1rem 0; }
.form label { display: block; font-size: .85rem; color: var(--muted); }
.form label > input, .form label > select, .form label > textarea, .form label > output { margin-top: .2rem; display: block; color: var(--text); font-size: .95rem; }
.form > label { margin-top: .8rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .75rem 1rem; }
.grid .wide { grid-column: span 2; }
.form label.check { display: flex; align-items: center; gap: .4rem; padding-top: 1.4rem; color: var(--text); }
.actions { display: flex; gap: .8rem; align-items: center; margin-top: 1rem; flex-wrap: wrap; }
.actions form { margin: 0; }
.actions.sticky { position: sticky; bottom: 0; background: var(--surface); padding: .7rem 0; border-top: 1px solid var(--line); }
.row { display: flex; gap: .5rem; max-width: 480px; }
.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.head .actions { margin-top: .4rem; }
fieldset.feel { border: 1px solid var(--line); border-radius: var(--radius); margin: 1rem 0 0; padding: .6rem .9rem .9rem; }
fieldset.feel legend { color: var(--muted); font-size: .85rem; padding: 0 .3rem; }
.notes-block.pain { border-left-color: var(--danger); }
.tag.pain { background: var(--err-bg); color: var(--danger); }
.notes-block { white-space: pre-wrap; background: var(--surface); border-left: 3px solid var(--line); padding: .4rem .8rem; max-width: 70ch; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; background: var(--surface); }
.seg label { margin: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: .38rem .8rem; cursor: pointer; color: var(--muted); }
.seg input:checked + span { background: var(--accent); color: var(--accent-text); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }
.seg.big { margin-bottom: 1rem; }
.seg.big span { padding: .5rem 1.2rem; font-weight: 600; }

.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.filters select, .filters input[type=search] { width: auto; }
.filters input[type=search] { min-width: 180px; }
.filters .inline { display: flex; align-items: center; gap: .3rem; color: var(--muted); font-size: .88rem; }
.filters .inline input { width: auto; }

table.list { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.list th { text-align: left; font-size: .78rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; padding: .5rem .7rem; border-bottom: 1px solid var(--line); }
table.list td { padding: .5rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list tr:last-child td { border-bottom: 0; }
table.list tbody tr[onclick] { cursor: pointer; }
table.list tbody tr:hover { background: color-mix(in srgb, var(--accent-soft) 40%, transparent); }
table.list tr.editing { background: var(--accent-soft); }
table.compact td, table.compact th { padding: .3rem .6rem; }
table.mapping input { padding: .2rem .4rem; }
td.notes { color: var(--muted); font-size: .9rem; max-width: 380px; }
td.grade, .grade { font-weight: 600; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.sub { font-size: .85rem; color: var(--muted); }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions form { display: inline; margin-left: .6rem; }
table.tally { border-collapse: collapse; width: 100%; }
table.tally th, table.tally td { text-align: left; padding: .3rem .5rem .3rem 0; vertical-align: top; }
.chip { display: inline-block; margin: 0 .35rem .25rem 0; padding: .05rem .45rem; border-radius: 5px; background: var(--bg); font-size: .88rem; }

.tag { display: inline-block; font-size: .72rem; padding: .05rem .4rem; border-radius: 4px; background: var(--bg); color: var(--muted); margin-left: .25rem; vertical-align: 1px; white-space: nowrap; }
.tag.board { background: var(--board); color: var(--board-text); }
.tag.outdoor { background: var(--outdoor); color: var(--outdoor-text); }
.tag.indoor { display: none; }
.tag.bench { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.tag.project, .tag.new { background: var(--warn-bg); color: var(--warn); }
.outcome { font-weight: 600; }
.stars { color: var(--parts); letter-spacing: 1px; margin-right: .3rem; white-space: nowrap; }
.outcome.sent { color: var(--sent); }
.outcome.not_sent { color: var(--notsent); }
.outcome.in_parts { color: var(--parts); }
.status { font-size: .8rem; padding: .1rem .5rem; border-radius: 10px; background: var(--bg); }
.status.committed { background: var(--accent-soft); color: var(--accent); }
.status.preview { background: var(--warn-bg); color: var(--warn); }

.flash { padding: .6rem .9rem; border-radius: 6px; margin-bottom: .6rem; background: var(--info-bg); }
.flash.error { background: var(--err-bg); color: var(--danger); }
.flash.warning { background: var(--warn-bg); color: var(--warn); }
.empty { padding: 2rem; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }
.pager { display: flex; gap: 1rem; justify-content: center; margin: 1rem 0; color: var(--muted); }

.stats { display: flex; gap: 2rem; flex-wrap: wrap; }
.stat b { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.issues { padding-left: 1.1rem; }
.issues li { margin: .2rem 0; }
.issues li.warning b { color: var(--warn); }
.issues li.error b { color: var(--danger); }
.steps li.done { color: var(--muted); }
.aliases { list-style: none; padding: 0; display: flex; gap: .4rem; flex-wrap: wrap; }
.aliases li { background: var(--bg); padding: .15rem .5rem; border-radius: 5px; display: flex; gap: .4rem; align-items: center; }
.aliases form { margin: 0; }
details summary { cursor: pointer; color: var(--accent); margin: .5rem 0; }
.js-table-filter { max-width: 280px; margin-bottom: .6rem; }

/* Climb form: board fields vs wall/rock fields */
.climb-form:not(.is-board) .only-board, .climb-form.is-board .no-board { display: none; }
#session-form:not(.is-board) .only-board, #session-form.is-board .only-place { display: none; }
.problem-field { position: relative; }
.suggest { position: absolute; left: 0; right: 0; top: 100%; z-index: 10; list-style: none; margin: 2px 0 0; padding: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px; max-height: 320px; overflow-y: auto; box-shadow: 0 6px 18px rgb(0 0 0 / .12); }
.suggest li { padding: .4rem .6rem; cursor: pointer; color: var(--text); display: flex; justify-content: space-between; gap: .6rem; }
.suggest li.active, .suggest li:hover { background: var(--accent-soft); }
.suggest .meta { color: var(--muted); font-size: .82rem; white-space: nowrap; }

/* Diary */
.pager-inline { display: flex; gap: .4rem; }
.diary-week { margin-bottom: 1.2rem; }
.diary-week h2 { display: flex; flex-wrap: wrap; gap: .2rem .6rem; align-items: baseline; }
.week-sum { font-size: .85rem; font-weight: normal; }
.diary-week.current h2 { color: var(--accent); }
.diary-days { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.diary-day { display: grid; grid-template-columns: 7.5rem 1fr; gap: .8rem; padding: .45rem .8rem; border-bottom: 1px solid var(--line);
  border-left: 3px solid transparent; scroll-margin-top: 5rem; }
.diary-day:last-child { border-bottom: 0; }
.diary-day.climb { border-left-color: var(--accent); }
.diary-day.rest { border-left-color: var(--line); }
.diary-day.flag-injury, .diary-day.flag-ill { border-left-color: var(--danger); }
.diary-day.today { background: var(--accent-soft); }
.diary-day.future .day-date { color: var(--muted); }
.day-date { color: var(--text); white-space: nowrap; }
.day-date .wd { display: inline-block; width: 2.2rem; font-weight: 600; }
.day-body { min-width: 0; font-size: .92rem; }
.day-plan { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; }
.day-plan .tag { margin-left: 0; }
.day-text { color: var(--text); }
.day-line { color: var(--muted); margin-top: .15rem; }
.day-line .label { font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; margin-right: .3rem; }
.notes-line { color: var(--text); }
.session-link { font-weight: 600; }
.tag.kind-climb { background: var(--accent-soft); color: var(--accent); }
.tag.kind-rest { background: var(--bg); color: var(--muted); }
.tag.cond-injury, .tag.cond-ill { background: var(--err-bg); color: var(--danger); }
.tag.today-tag { background: var(--accent); color: var(--accent-text); }
.quick { display: flex; gap: .9rem; margin: 0; }
.quick a, .quick button { font-size: .85rem; }
#diary-form:not(.is-climb) .only-climb { display: none; }
.notes-block.diary-note { border-left-color: var(--accent); }

.from-diary tr.covered td { color: var(--muted); }
.from-diary input[name^=title_] { min-width: 12rem; }

/* Account menu and sign-in pages */
.account { position: relative; }
.account summary { list-style: none; cursor: pointer; padding: .35rem .65rem; border-radius: 6px; color: var(--muted);
  max-width: 14rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account summary::-webkit-details-marker { display: none; }
.account summary::after { content: " ▾"; font-size: .75em; }
.account summary.on, .account[open] summary { color: var(--text); background: var(--bg); }
.account ul { position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; list-style: none; margin: 0; padding: .4rem 0;
  min-width: 14rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 6px 18px rgb(0 0 0 / .14); }
.account li { padding: .35rem .9rem; }
.account li form { margin: 0; }
.auth-box { max-width: 26rem; margin: 2rem auto; }
.auth-box .form label { margin-top: .7rem; }
code.break { word-break: break-all; }
.row-inline { display: flex; gap: .4rem; align-items: center; margin: 0; }
.row-inline select { width: auto; }

/* Outside links (map, theTopo) */
.ext-links { display: inline-flex; gap: .55rem; margin-left: .4rem; font-size: .82rem; font-weight: normal; white-space: nowrap; }
.sub .ext-links { margin-left: .3rem; }
a.plain { color: inherit; }

/* Rain map: one blue ramp from dry to heavy rain (sequential, light to dark); grey ring keeps dry visible */
:root {
  --rain-0: #f0efec; --rain-1: #b7d3f6; --rain-2: #86b6ef; --rain-3: #3987e5; --rain-4: #1c5cab; --rain-5: #0d366b;
  --rain-nodata: #c3c2b7; --rain-ring-dry: #52514e;
}
.rain-map { scroll-margin-top: 4.5rem; height: min(62vh, 560px); border: 1px solid var(--line); border-radius: var(--radius); margin: .4rem 0; z-index: 0; }
.rain-metrics { margin-bottom: .3rem; }
.rain-legend { list-style: none; display: flex; flex-wrap: wrap; gap: .3rem 1rem; padding: 0; margin: .3rem 0; font-size: .85rem; color: var(--muted); }
.sw { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: .35rem; vertical-align: -1px;
  box-shadow: 0 0 0 1px rgb(0 0 0 / .25); }
.sw.b0 { background: var(--rain-0); } .sw.b1 { background: var(--rain-1); } .sw.b2 { background: var(--rain-2); }
.sw.b3 { background: var(--rain-3); } .sw.b4 { background: var(--rain-4); } .sw.b5 { background: var(--rain-5); }
.sw.nodata { background: var(--rain-nodata); }
.rain-table tbody tr { cursor: pointer; }
.rain-table td.on { font-weight: 600; }
.rain-pop { font: 13px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif; color: #1f2328; min-width: 220px; }
.rain-pop p { margin: .3rem 0; }
.rain-pop .muted { color: #6b7078; }
.rain-pop-title { font-weight: 700; font-size: 14px; }
.rain-pop-dry { font-weight: 600; }
.rain-bars { display: flex; gap: 4px; align-items: flex-end; height: 86px; margin: .4rem 0; }
.rain-bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.rain-bar-fill { width: 100%; max-width: 22px; border-radius: 4px 4px 0 0; }
.rain-bar-fill.b0 { background: var(--rain-0); box-shadow: inset 0 0 0 1px #c3c2b7; }
.rain-bar-fill.b1 { background: var(--rain-1); } .rain-bar-fill.b2 { background: var(--rain-2); }
.rain-bar-fill.b3 { background: var(--rain-3); } .rain-bar-fill.b4 { background: var(--rain-4); }
.rain-bar-fill.b5 { background: var(--rain-5); }
.rain-bar-val { font-size: 10px; color: #52514e; font-variant-numeric: tabular-nums; }
.rain-bar-day { font-size: 10px; color: #898781; border-top: 1px solid #c3c2b7; width: 100%; text-align: center; }

/* Stats */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem .9rem; }
.tile-label { color: var(--muted); font-size: .85rem; }
.tile-value { font-size: 1.6rem; font-weight: 600; line-height: 1.3; }
.tile-sub { color: var(--muted); font-size: .8rem; }
.multiples { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 0 1rem; }
.multiples .card { margin: .5rem 0; }
.multiples h3, .card h3 { text-transform: none; letter-spacing: 0; font-size: .95rem; color: var(--text); margin-bottom: .4rem; }
.viz { margin: 0; }
.viz svg { width: 100%; height: auto; display: block; overflow: visible; }
.viz .grid { stroke: var(--viz-grid); stroke-width: 1; }
.viz .baseline { stroke: var(--viz-axis); stroke-width: 1; }
.viz .crosshair { stroke: var(--viz-muted); stroke-width: 1; }
.viz .tick { fill: var(--viz-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.viz .value { fill: var(--viz-ink); font-size: 11px; font-variant-numeric: tabular-nums; }
.viz .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.viz .dot { stroke: var(--surface); stroke-width: 2; }
.viz .hit { fill: transparent; cursor: default; outline: none; }
.viz .col:hover .bar, .viz .col:focus-within .bar { opacity: .8; }
.viz .hit:focus-visible { stroke: var(--viz-muted); stroke-width: 1; }
.s1 { fill: var(--series-1); stroke: var(--series-1); } .s2 { fill: var(--series-2); stroke: var(--series-2); }
.s3 { fill: var(--series-3); stroke: var(--series-3); } .s4 { fill: var(--series-4); stroke: var(--series-4); }
.s5 { fill: var(--series-5); stroke: var(--series-5); }
.viz .bar { stroke: none; }
.viz .line.s1, .viz .line.s2, .viz .line.s3, .viz .line.s4, .viz .line.s5 { fill: none; }
.viz-legend { list-style: none; display: flex; flex-wrap: wrap; gap: .3rem 1rem; padding: 0; margin: 0 0 .4rem; font-size: .85rem; color: var(--muted); }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: .4rem; vertical-align: -1px; }
.key.s1 { background: var(--series-1); } .key.s2 { background: var(--series-2); } .key.s3 { background: var(--series-3); }
.key.s4 { background: var(--series-4); } .key.s5 { background: var(--series-5); }
.viz-table summary { font-size: .85rem; }
.viz-table table { max-width: 480px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.viz-tip { position: fixed; z-index: 20; pointer-events: none; background: var(--surface); border: 1px solid var(--line);
  border-radius: 6px; padding: .45rem .6rem; box-shadow: 0 6px 18px rgb(0 0 0 / .14); font-size: .85rem; min-width: 120px; }
.viz-tip .t { font-weight: 600; }
.viz-tip .r { display: flex; align-items: center; gap: .45rem; color: var(--muted); }
.viz-tip .r b { color: var(--text); font-variant-numeric: tabular-nums; }
.viz-tip .lk { width: 12px; height: 2px; border-radius: 1px; }
.pain-list li { margin: .2rem 0; }
.angle-summary { padding-left: 1.1rem; }
ul.links li { margin: .3rem 0; }

@media (max-width: 700px) {
  .hide-sm { display: none; }
  .top { flex-wrap: wrap; gap: .5rem; }
  .top nav { order: 3; flex-basis: 100%; }
  .grid .wide { grid-column: span 1; }
  .diary-day { grid-template-columns: 1fr; gap: .1rem; }
  .grid { grid-template-columns: 1fr 1fr; }
  .problem-field, .grid label.wide { grid-column: 1 / -1; }
}

/* Injuries and illness */
.tag.ongoing { background: var(--warn-bg); color: var(--warn); }
a.tag.cond-injury, a.tag.cond-ill { text-decoration: none; }
.timeline { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--line); }
.timeline li { display: grid; grid-template-columns: 6.5rem 1fr; gap: .8rem; padding: .5rem 0 .5rem .9rem; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: .85rem; width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.timeline li.ev-start::before { background: var(--danger); }
.timeline li.ev-note::before, .timeline li.ev-end::before { background: var(--accent); }
form.inline { display: inline; }
.ev-date { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.ev-body .label { font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.ev-body .notes-block { margin-top: .25rem; }
.inline-end { display: flex; flex-wrap: wrap; gap: .6rem; align-items: end; margin-top: .8rem; }
.issue-on-day + .issue-on-day { border-top: 1px solid var(--line); margin-top: .6rem; padding-top: .3rem; }
.add-note { display: flex; gap: .5rem; margin-top: .4rem; }
.add-note input[name=note] { flex: 1; min-width: 0; }
@media (max-width: 600px) { .timeline li { grid-template-columns: 1fr; gap: .1rem; } }
pre { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: .6rem .8rem; overflow-x: auto; margin: .4rem 0 .8rem; }
pre code { background: none; padding: 0; font-size: .85rem; }
