/* One stylesheet for every page. The interface is ink on paper; strong
   colours are kept for what they mean on a page: hold colours, green for
   near your target, red and blue for harder and easier than graded. */

@font-face { font-family: Barlow; font-weight: 400; src: url(/static/fonts/barlow-400.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: Barlow; font-weight: 500; src: url(/static/fonts/barlow-500.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: Barlow; font-weight: 600; src: url(/static/fonts/barlow-600.woff2) format("woff2"); font-display: swap; }

:root {
  color-scheme: light dark;
  --paper: #ffffff;
  --sunk: #f1f2f2;
  --ink: #17191a;
  --soft: #5d6466;
  --rule: #d5d9da;
  --bar: #17191a;
  --bar-ink: #ffffff;
  --bar-soft: #a9b0b2;
  --near: #14783c;
  --harder: #b3261e;
  --easier: #1d5fae;
  --s1: 4px;
  --s2: 8px;
  --s3: 16px;
  --s4: 24px;
  --s5: 40px;
  --gutter: 24px;
  --control: 36px;
  --radius: 3px;
  font: 400 16px/1.45 Barlow, system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #17191a;
    --sunk: #222627;
    --ink: #eceeee;
    --soft: #9aa3a5;
    --rule: #373d3f;
    --bar: #0c0d0e;
    --bar-ink: #eceeee;
    --bar-soft: #8d9698;
    --near: #58c283;
    --harder: #f2827a;
    --easier: #7db3f2;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--paper); color: var(--ink); }
h1, h2, p, ul, ol, dl, dd { margin: 0; }
h1 { font-size: 28px; line-height: 1.2; font-weight: 600; }
h2 { font-size: 19px; line-height: 1.3; font-weight: 600; }
a { color: inherit; text-underline-offset: 3px; text-decoration-color: var(--soft); }
a:hover { text-decoration-color: currentColor; }
code, pre { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.85em; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--soft); }
.hint { color: var(--soft); font-size: 14px; max-width: 70ch; }
.harder { color: var(--harder); font-weight: 500; }
.easier { color: var(--easier); font-weight: 500; }
.range { font-weight: 500; white-space: nowrap; }
.headline { font-size: 20px; line-height: 1.35; max-width: 60ch; }
.headline strong { font-weight: 600; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---- Header ---- */

#header {
  display: flex;
  align-items: stretch;
  gap: var(--s4);
  min-height: 52px;
  padding: 0 var(--gutter);
  background: var(--bar);
  color: var(--bar-ink);
}
#header a { color: var(--bar-soft); text-decoration: none; display: flex; align-items: center; }
#header a:hover, #header a[aria-current] { color: var(--bar-ink); }
#header :focus-visible { outline-color: var(--bar-ink); outline-offset: -2px; }
#header .wordmark { color: var(--bar-ink); font-weight: 600; font-size: 18px; white-space: nowrap; }
#header nav { display: flex; gap: var(--s3); }
#header nav a { border-block: 3px solid transparent; font-weight: 500; }
#header nav a[aria-current] { border-bottom-color: var(--bar-ink); }
.header-end { display: flex; align-items: center; gap: var(--s3); margin-left: auto; min-width: 0; }
#header select { background-color: transparent; color: inherit; border-color: var(--bar-soft); max-width: 220px; }
#header select option { color: var(--ink); background: var(--paper); }
.account-link { max-width: 16ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.view-as { display: flex; gap: var(--s3); justify-content: center; padding: var(--s2) var(--gutter); background: var(--sunk); border-bottom: 1px solid var(--rule); }

main { padding: var(--s4) var(--gutter) var(--s5); display: grid; gap: var(--s3); grid-template-columns: minmax(0, 1fr); }
main.narrow { max-width: 760px; margin-inline: auto; }
section { display: grid; gap: var(--s3); margin-top: var(--s3); grid-template-columns: minmax(0, 1fr); }
section > h2:not(:first-child) { margin-top: var(--s4); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.stack { display: grid; gap: var(--s3); max-width: 420px; }
.stack > button { justify-self: start; }
#run, #run-list, #skill, #updating { display: grid; gap: var(--s2); grid-template-columns: minmax(0, 1fr); }
#skill .facts { margin-top: var(--s2); }
section > button { justify-self: start; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.spacer { flex: 1; }

/* ---- Controls ---- */

button, select, input:not([type="checkbox"], [type="range"]) {
  font: inherit;
  color: inherit;
  min-height: var(--control);
  padding: 0 12px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background-color: var(--paper);
}
input:not([type="checkbox"], [type="range"]), select { border-color: color-mix(in srgb, var(--soft) 60%, var(--paper)); width: 100%; min-width: 0; }
input::placeholder { color: var(--soft); opacity: 1; }
select {
  appearance: none;
  padding-right: 30px;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(-45deg, transparent 50%, currentColor 50%);
  background-size: 5px 5px;
  background-position: calc(100% - 16px) 55%, calc(100% - 11px) 55%;
  background-repeat: no-repeat;
}
button { cursor: pointer; font-weight: 500; white-space: nowrap; }
button:hover:not(:disabled) { border-color: var(--ink); }
button:disabled { opacity: 0.45; cursor: default; }
button.primary { background: var(--ink); border-color: var(--ink); color: var(--paper); }
button.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--ink) 85%, var(--paper)); }
button.danger { color: var(--harder); border-color: currentColor; }
button.link { min-height: 0; padding: 0; border: 0; background: none; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--soft); }
button.link:hover:not(:disabled) { text-decoration-color: currentColor; }
input[type="range"] { accent-color: var(--ink); width: 150px; height: var(--control); margin: 0; }
input[type="checkbox"] { accent-color: var(--ink); width: 17px; height: 17px; margin: 0; flex: none; }

.field { display: grid; gap: var(--s1); font-size: 14px; color: var(--soft); }
.field > input, .field > select { font-size: 16px; color: var(--ink); }
.field output { color: var(--ink); font-weight: 500; }
.field.grow { flex: 1 1 200px; max-width: 340px; }
.check { display: flex; align-items: center; gap: var(--s2); min-height: var(--control); }
.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s3) var(--s4); }

.toolbar .more { display: flex; flex-wrap: wrap; align-items: flex-end; gap: inherit; }
#more-filters { display: none; }
.segmented { display: flex; }
.segmented button { border-radius: 0; margin-left: -1px; }
.segmented button:first-child { border-radius: var(--radius) 0 0 var(--radius); margin-left: 0; }
.segmented button:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.segmented button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }

.statusline { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--s1) var(--s3); color: var(--soft); font-size: 14px; }
.statusline .end { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s3); }
.statusline button { color: var(--ink); font-size: 14px; }

.notice { padding: 10px 14px; border-left: 3px solid var(--ink); background: var(--sunk); max-width: 75ch; }
.form-error { color: var(--harder); font-weight: 500; }
.form-ok { color: var(--near); font-weight: 500; }
.tag { font-size: 13px; color: var(--soft); border: 1px solid var(--rule); border-radius: var(--radius); padding: 0 5px; white-space: nowrap; }
.tag.sent { color: var(--near); border-color: currentColor; }
.status { font-weight: 500; }
.status.done { color: var(--near); }
.status.error { color: var(--harder); }

.has-options { position: relative; }
.options { position: absolute; z-index: 10; top: 100%; inset-inline: 0; max-height: 260px; overflow-y: auto; margin-top: 2px; padding: var(--s1) 0; list-style: none; background: var(--paper); border: 1px solid var(--ink); border-radius: var(--radius); }
.options li { padding: 6px 12px; cursor: pointer; }
.options li.active, .options li:hover:not([aria-disabled]) { background: var(--sunk); }

dialog { color: inherit; background: var(--paper); border: 1px solid var(--ink); border-radius: var(--radius); padding: var(--s4); width: min(480px, calc(100vw - 32px)); overflow: visible; }
dialog .stack { max-width: none; }
dialog::backdrop { background: rgb(0 0 0 / 0.5); }
code.big { font-size: 24px; user-select: all; }

.facts { display: flex; flex-wrap: wrap; gap: var(--s3) var(--s5); }
.facts dt { font-size: 14px; color: var(--soft); }
.facts dd { font-size: 19px; font-weight: 500; }

.tabs { display: flex; flex-wrap: wrap; gap: 0 var(--s4); border-bottom: 1px solid var(--rule); }
.tabs a { padding: var(--s2) 0; text-decoration: none; color: var(--soft); border-bottom: 3px solid transparent; margin-bottom: -1px; font-weight: 500; }
.tabs a[aria-current] { color: var(--ink); border-bottom-color: var(--ink); }

/* ---- Tables ---- */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 7px 16px 7px 0; border-bottom: 1px solid var(--rule); vertical-align: middle; }
th { font-size: 14px; font-weight: 500; color: var(--soft); border-bottom-color: var(--ink); white-space: nowrap; }
th button { min-height: 0; padding: 0; border: 0; background: none; color: inherit; font-size: inherit; }
th button:hover { color: var(--ink); }
th[aria-sort="ascending"] button, th[aria-sort="descending"] button { color: var(--ink); }
th[aria-sort="ascending"] button::after { content: " ↑"; }
th[aria-sort="descending"] button::after { content: " ↓"; }
td.num { text-align: left; }
tbody tr:hover { background: var(--sunk); }
tr.selected td { background: var(--sunk); box-shadow: inset 0 2px var(--ink), inset 0 -2px var(--ink); }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions .link + .link { margin-left: var(--s3); }
.row-status { font-size: 14px; white-space: normal; }
.row-status:empty { display: none; }

.hold { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 1px solid color-mix(in srgb, var(--ink) 35%, transparent); margin-right: var(--s2); vertical-align: -2px; flex: none; }
.hold.none { border-style: dashed; }

.prob { display: flex; align-items: center; gap: var(--s2); }
.prob .num { min-width: 4ch; }
.bar { position: relative; flex: none; width: 84px; height: 8px; background: color-mix(in srgb, var(--ink) 12%, var(--paper)); }
.bar i { display: block; height: 100%; background: var(--soft); }
.bar b { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: var(--ink); }
.prob.near .bar i { background: var(--near); }
.prob.near .num, .card-chance.near .num { color: var(--near); font-weight: 600; }

/* ---- Climbs on a phone ---- */

.sortbar, .cards { display: none; }
.cards { list-style: none; padding: 0; border-top: 1px solid var(--rule); }
.card { border-bottom: 1px solid var(--rule); }
.card.selected { box-shadow: inset 3px 0 var(--ink); }
.card summary { display: flex; align-items: center; gap: 12px; padding: 10px 0; cursor: pointer; list-style: none; }
.card.selected summary, .card.selected dl { padding-left: 12px; }
.card summary::-webkit-details-marker { display: none; }
.tape { flex: none; display: grid; place-items: center; width: 44px; height: 36px; font-weight: 600; border: 1px solid color-mix(in srgb, var(--ink) 25%, transparent); }
.card-name { flex: 1; min-width: 0; display: grid; }
.card-name > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-name span { font-weight: 500; }
.card small { color: var(--soft); font-size: 14px; }
.card-chance { display: grid; justify-items: end; line-height: 1.25; }
.card-chance .num { font-size: 18px; font-weight: 500; }
.card dl { padding: 0 0 12px 56px; display: grid; gap: 6px; }
.card dl > div { display: flex; gap: 12px; }
.card dt { flex: none; width: 92px; color: var(--soft); font-size: 14px; }

/* ---- Map ---- */

.map-viewport { position: relative; width: 100%; height: 72vh; overflow: hidden; background: var(--sunk); border: 1px solid var(--rule); touch-action: none; cursor: grab; }
.map-viewport.grabbing { cursor: grabbing; }
.map-container { position: absolute; top: 0; left: 0; transform-origin: 0 0; }
.map-container img { display: block; }
.map-overlay { position: absolute; inset: 0; }
.map-zoom { position: absolute; right: 12px; top: 12px; display: grid; z-index: 3; }
.map-zoom button { width: 44px; min-height: 44px; padding: 0; border-radius: 0; margin-top: -1px; }
/* Sizes are in floorplan pixels, so a dot grows on screen as the map is
   zoomed; .zoomed-in (see applyMapTransform) grows it further, once there is
   room for a readable label in it. */
.map-dot { position: absolute; width: 28px; height: 28px; border-radius: 50%; border: 3px solid rgb(0 0 0 / 0.4); transform: translate(-50%, -50%); cursor: pointer; box-shadow: 0 0 0 3px rgb(255 255 255 / 0.6); display: grid; place-items: center; transition: width 0.15s ease, height 0.15s ease; }
.map-dot span { display: none; font-size: 16px; font-weight: 600; line-height: 1; white-space: nowrap; pointer-events: none; }
.map-dot.near { border-color: #14783c; box-shadow: 0 0 0 6px #2aa35c; }
.map-dot.located { z-index: 2; width: 40px; height: 40px; border: 5px solid #17191a; animation: locate 1.1s ease-out 2; }
.zoomed-in .map-dot { width: 52px; height: 52px; }
.zoomed-in .map-dot.located { width: 60px; height: 60px; }
.zoomed-in .map-dot span { display: block; }
@keyframes locate {
  from { box-shadow: 0 0 0 0 rgb(23 25 26 / 0.6); }
  to { box-shadow: 0 0 0 28px rgb(23 25 26 / 0); }
}
.map-wall { position: absolute; transform: translate(-50%, -50%); font-size: 12px; color: #5d6466; background: rgb(255 255 255 / 0.85); padding: 1px 4px; pointer-events: none; white-space: nowrap; }
.map-tooltip { position: absolute; z-index: 20; transform: translate(-50%, -50%); background: var(--ink); color: var(--paper); padding: 4px 10px; border-radius: var(--radius); font-size: 14px; pointer-events: none; white-space: nowrap; }

/* ---- Charts ---- */

svg { display: block; max-width: 100%; }
svg text { font-size: 13px; fill: var(--soft); }
#chart .band { fill: color-mix(in srgb, var(--ink) 12%, var(--paper)); }
#chart .line { fill: none; stroke: var(--ink); stroke-width: 2; stroke-linejoin: round; }
#chart .end { fill: var(--ink); }
#chart .grid { stroke: var(--soft); stroke-dasharray: 2 4; }
.grade-chart .hit { fill: transparent; }
.grade-chart .row { cursor: pointer; outline: none; }
.grade-chart .row:hover .hit, .grade-chart .row:focus-visible .hit { fill: var(--sunk); }
.grade-chart .row.current .hit { fill: var(--rule); }
.grade-chart .row.current text, .grade-chart .row:hover text { fill: var(--ink); font-weight: 600; }
.grade-chart .range { fill: color-mix(in srgb, var(--ink) 14%, var(--paper)); }
.grade-chart circle { stroke: color-mix(in srgb, var(--ink) 45%, transparent); stroke-width: 1; }
.grade-chart circle.harder { stroke: var(--harder); stroke-width: 2.5; }
.grade-chart circle.easier { stroke: var(--easier); stroke-width: 2.5; }

.suggestion { display: flex; align-items: flex-start; padding: var(--s3) 0; border-block: 1px solid var(--rule); }
.suggestion .hold { margin-top: 4px; }

#run-log { margin: 0; padding: 12px 14px; max-height: 65vh; overflow: auto; background: var(--sunk); border: 1px solid var(--rule); white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; font-size: 13px; }

/* ---- Signing in ---- */

body.signin { min-height: 100vh; display: grid; place-items: center; background: var(--sunk); }
.signin-box { width: min(380px, calc(100vw - 32px)); padding: var(--s4); background: var(--paper); border-top: 6px solid var(--bar); }
.signin-box form { display: grid; gap: var(--s3); }

/* ---- Phone ---- */

@media (max-width: 720px) {
  :root { --gutter: 16px; --control: 44px; }
  #header { flex-wrap: wrap; gap: 0 var(--s3); padding-top: var(--s1); }
  #header .wordmark { min-height: 44px; }
  #header nav { order: 3; width: 100%; gap: var(--s4); overflow-x: auto; }
  #header nav a { min-height: 44px; }
  #header select { max-width: 42vw; min-height: 36px; }
  .toolbar { gap: var(--s3); }
  .toolbar .grow { flex-basis: 100%; max-width: none; }
  .toolbar .field:not(.grow) { flex: 1 1 40%; }
  .toolbar .field.target { flex-basis: 100%; }
  #browse .segmented { flex: 1; width: auto; }
  #more-filters { display: block; }
  .toolbar .more { width: 100%; gap: var(--s3); }
  .toolbar .more:not(.open) { display: none; }
  .toolbar .segmented { width: 100%; overflow-x: auto; }
  .toolbar .segmented button { flex: 1; padding: 0 10px; }
  input[type="range"] { width: 100%; }
  button.link, td a { padding: 6px 0; }

  #list-panel .table-wrap { display: none; }
  .cards { display: block; }
  .sortbar { display: flex; align-items: flex-end; gap: var(--s2); padding-bottom: var(--s3); }
  .sortbar .field { flex: 1; }

  /* Other tables become a list of labelled lines per row. */
  .stacked thead { display: none; }
  .stacked table, .stacked tbody, .stacked tr, .stacked td { display: block; }
  .stacked tr { padding: 10px 0; border-bottom: 1px solid var(--rule); }
  .stacked td { border: 0; padding: 2px 0; text-align: left; }
  .stacked td:first-child { font-weight: 500; }
  .stacked td[data-label]::before { content: attr(data-label); display: inline-block; width: 92px; color: var(--soft); font-size: 14px; font-weight: 400; }
  .row-actions { display: flex !important; flex-wrap: wrap; gap: var(--s1) var(--s3); }
  .row-actions .link + .link { margin: 0; }
  .row-status { flex-basis: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
