:root {
  color-scheme: light;
  --ground: #f5f6f2;
  --white: #fff;
  --ink: #18251f;
  --muted: #53645b;
  --quiet: #65746c;
  --line: #dfe5de;
  --accent: #e86136;
  --accent-ink: #a93617;
  --accent-soft: #fbedE6;
  --map: #263b32;
  --hud: #152d27;
  font-family: "Helvetica Neue", Arial, sans-serif;
  font-synthesis: none;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--ground); color: var(--ink); font-size: 16px; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .35; }
button, select { touch-action: manipulation; }
button, input, select { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid #bd431e; outline-offset: 3px; }
[hidden] { display: none !important; }
h1, h2, p { margin: 0; }
.sprite, .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.icon, .brand-icon svg {
  width: 19px; height: 19px; flex: none; fill: none; stroke: currentColor;
  stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round;
}

.topbar { background: var(--white); border-bottom: 1px solid var(--line); }
.topbar-inner { height: 65px; max-width: 1600px; margin: auto; padding: 0 clamp(20px, 4.15vw, 66px); display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 9px; font-size: 26px; font-weight: 800; letter-spacing: -.08em; user-select: none; }
.brand-icon { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: #23372c; color: #fff; }
.brand-icon svg { width: 22px; height: 22px; stroke-width: 1.45; }
.brand-period { color: var(--accent-ink); }
.topbar-actions, .course-actions, .toolbar-end { display: flex; align-items: center; gap: 11px; }
.save-state { display: flex; align-items: center; gap: 8px; margin-right: 9px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.save-state > span { width: 7px; height: 7px; border-radius: 50%; background: #47835d; }
.save-state.is-unsaved > span { background: var(--accent); }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 39px; padding: 0 13px; border: 1px solid #dce3db; border-radius: 8px; background: var(--white); color: var(--ink); font-weight: 700; font-size: 14px; white-space: nowrap; }
.button:enabled:hover { background: #f0f3ee; border-color: #cbd4ca; }
.primary { color: #fff; background: #b83c1b; border-color: #b83c1b; padding-inline: 16px; }
.primary:enabled:hover { background: #a53517; border-color: #a53517; }
.primary .icon { width: 18px; height: 18px; }
.header-button { min-height: 35px; }

.page { max-width: 1600px; margin: 0 auto; padding: 25px clamp(20px, 4.15vw, 66px) 16px; }
.course-header { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 23px; }
.overline { font-size: 11px; font-weight: 800; letter-spacing: .15em; color: #54695d; margin-bottom: 7px; }
h1 { font-size: clamp(35px, 3.25vw, 51px); letter-spacing: -.065em; line-height: 1; overflow-wrap: anywhere; }
.course-description { margin-top: 9px; color: var(--muted); font-size: 15px; line-height: 1.4; }
.course-actions { padding-bottom: 2px; flex: none; }

.workspace { border: 1px solid #dce2da; border-radius: 14px; background: var(--white); box-shadow: 0 3px 4px #23382b06, 0 12px 40px #23382b09; }
.toolbar { min-height: 56px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 13px; border-bottom: 1px solid var(--line); }
.tools { display: flex; align-items: center; gap: 4px; }
.tool, .icon-button { background: transparent; border: 1px solid transparent; color: #42544a; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; }
.tool { min-height: 35px; gap: 7px; padding: 0 9px; font-size: 14px; font-weight: 700; white-space: nowrap; }
.tool:enabled:hover, .icon-button:enabled:hover { background: #eff2ed; }
.tool.active { --icon-bg: #e7eee7; color: #263b2e; background: #e7eee7; border-color: #dce6dc; }
.tool .icon { width: 18px; height: 18px; }
.icon-button { width: 34px; height: 34px; padding: 0; }
.history { display: flex; gap: 1px; border-right: 1px solid var(--line); padding-right: 9px; }
.add-keypoint { color: var(--accent-ink); background: #fff6f1; border-color: #f3d6c9; min-height: 35px; }
.add-keypoint:enabled:hover, .add-keypoint.active { color: #8e2e14; background: #f9e5db; border-color: #eec3b0; }

.workspace-body { display: grid; grid-template-columns: minmax(0, 1fr) 306px; min-width: 0; }
.map { position: relative; min-width: 0; overflow: hidden; background: var(--map); height: clamp(505px, 59vh, 645px); isolation: isolate; }
#map-svg { display: block; width: 100%; height: 100%; overflow: hidden; touch-action: none; user-select: none; }
.map[data-tool="gate"] #map-svg, .map[data-tool="rock"] #map-svg, .map[data-tool="point"] #map-svg { cursor: crosshair; }
.map.is-dragging #map-svg { cursor: grabbing; }
.map-caption, .map-compass, .map-legend, .zoom, .map-instruction {
  position: absolute; background: #142a25ed; color: #f3f7ef; border: 1px solid #adc3b23d; border-radius: 7px;
  box-shadow: 0 3px 10px #112f2638; font-size: 12px;
}
.map-caption, .map-compass { top: 16px; display: flex; align-items: center; gap: 7px; min-height: 33px; padding: 0 10px; font-weight: 700; letter-spacing: .01em; }
.map-caption { left: 16px; }
.map-caption-dot { width: 6px; height: 6px; border-radius: 50%; background: #9bc5af; }
.map-compass { right: 16px; font-size: 11px; color: #e2eae2; }
.map-compass svg { width: 13px; height: 13px; fill: none; stroke: #bce7ce; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.map-legend { left: 16px; bottom: 16px; display: flex; align-items: center; flex-wrap: wrap; gap: 7px 15px; padding: 9px 10px; }
.map-legend span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.map-legend i { width: 15px; height: 3px; border-radius: 3px; }
.legend-line { background: #f88654; }
.legend-down { background: #b8f487; }
.legend-up { background: #ff8d95; }
.zoom { right: 16px; bottom: 16px; display: flex; overflow: hidden; }
.zoom button { width: 36px; height: 36px; background: transparent; color: #f3f7ef; border: 0; display: grid; place-items: center; }
.zoom button:enabled:hover { background: #3a5347; }
.zoom button + button { border-left: 1px solid #b7ddbd3a; }
.zoom button:focus-visible { outline-color: #f6a784; outline-offset: -3px; }
.zoom .icon { width: 17px; height: 17px; }
.map-instruction { top: 58px; left: 16px; max-width: calc(100% - 32px); padding: 9px 11px; pointer-events: none; line-height: 1.35; }

.inspector { border-left: 1px solid var(--line); min-width: 0; display: flex; flex-direction: column; max-height: clamp(505px, 59vh, 645px); min-height: 0; }
.inspector-header { padding: 20px 17px 13px; }
.inspector-title { display: flex; align-items: center; gap: 8px; }
.inspector h2 { font-size: 20px; line-height: 1.15; letter-spacing: -.04em; }
.count { border-radius: 6px; background: #eff2ee; color: #42554a; min-width: 24px; padding: 3px 5px; text-align: center; font-size: 12px; font-weight: 800; }
.inspector-header p { margin-top: 6px; color: var(--muted); font-size: 13px; line-height: 1.35; }
.point-list { list-style: none; padding: 0 12px; margin: 0 0 10px; overflow: auto; min-height: 60px; }
.point-list li + li { margin-top: 3px; }
.point-row { width: 100%; min-height: 46px; padding: 6px; display: flex; align-items: center; gap: 9px; text-align: left; border: 1px solid transparent; border-radius: 8px; color: var(--ink); background: var(--white); }
.point-row:hover { background: #f1f4ef; }
.point-row[aria-current="step"] { background: #fdf0e9; border-color: #f3d6c8; }
.point-number { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 6px; background: #ebf0eb; color: #41594a; font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums; flex: none; }
.point-row[aria-current="step"] .point-number { background: #f5d1be; color: #983716; }
.point-name { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.point-angle { margin-left: auto; color: #627169; font-size: 12px; font-variant-numeric: tabular-nums; }
.point-row .icon { width: 14px; height: 14px; color: #76887c; }
.point-row[aria-current="step"] .icon { color: var(--accent-ink); }
.empty-points { font-size: 14px; color: var(--muted); padding: 10px 4px; line-height: 1.45; }
.selection { margin-top: auto; border-top: 1px solid var(--line); padding: 13px 16px 14px; background: #fafbf8; min-height: 153px; }
.selection-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; min-height: 23px; }
.selection-label { color: #486052; font-size: 11px; letter-spacing: .09em; font-weight: 800; }
.selection .icon-button { width: 26px; height: 26px; color: #65756c; }
.selection .icon-button .icon { width: 15px; height: 15px; }
.selection-empty { font-size: 14px; color: var(--muted); line-height: 1.45; }
.selection input[type="text"], .field input, .selection select { display: block; min-width: 0; width: 100%; height: 34px; border: 1px solid #dbe4da; border-radius: 6px; background: #fff; color: var(--ink); padding: 0 8px; font-size: 14px; }
.heading-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; color: var(--muted); font-size: 13px; }
.heading-value { display: flex; align-items: center; font-variant-numeric: tabular-nums; color: var(--ink); white-space: nowrap; }
.heading-value input { appearance: textfield; width: 34px; padding: 1px 1px 1px 2px; text-align: right; font: inherit; color: inherit; background: var(--white); border: 1px solid #dbe4da; border-radius: 4px; }
.heading-value input::-webkit-inner-spin-button, .heading-value input::-webkit-outer-spin-button { appearance: none; margin: 0; }
.selection input[type="range"] { display: block; width: 100%; margin: 7px 0 0; accent-color: #ba4524; height: 16px; cursor: pointer; }
.selection .field { margin-bottom: 7px; }

.timeline { min-height: 69px; padding: 9px 15px; display: flex; align-items: center; gap: 16px; border-top: 1px solid var(--line); }
.transport { display: flex; align-items: center; gap: 4px; }
.transport .icon-button { width: 30px; }
.transport .icon-button .icon { width: 15px; height: 15px; }
.transport-play { width: 34px; height: 34px; border: 1px solid #264534; background: #263f31; color: #fff; border-radius: 8px; display: grid; place-items: center; }
.transport-play:enabled:hover { background: #365541; }
.transport-play .icon { width: 18px; height: 18px; }
.timeline-main { flex: 1; min-width: 0; }
.timeline-label { display: flex; justify-content: space-between; gap: 7px; font-size: 12px; font-weight: 700; color: #41564a; }
#timeline-status { color: var(--quiet); font-weight: 500; }
.timeline-track { --progress: 50%; margin: 7px 7px 0; height: 16px; display: flex; justify-content: space-between; align-items: center; position: relative; }
.timeline-track::before { content: ""; position: absolute; top: 7px; height: 3px; inset-inline: 0; background: linear-gradient(90deg,#cd603a var(--progress),#dfe7df var(--progress)); border-radius: 20px; }
.timeline-track:empty::before { background: #dfe7df; }
.timeline-dot { z-index: 1; position: relative; width: 18px; height: 18px; margin-inline: -8px; background: transparent; border: none; padding: 0; display: grid; place-items: center; }
.timeline-dot::after { content: ""; width: 8px; height: 8px; border: 2px solid #aabbaf; border-radius: 50%; background: #fff; }
.timeline-dot.reached::after { background: #b84a27; border-color: #b84a27; }
.timeline-dot[aria-current="step"]::after { width: 12px; height: 12px; background: #bb4925; border-color: #fff; box-shadow: 0 0 0 1px #ba4926; }
.timeline-dot:hover::after { box-shadow: 0 0 0 2px #c46342; }
.speed { margin-left: 1px; }
.speed select { appearance: none; min-width: 60px; padding: 0 22px 0 9px; height: 33px; border: 1px solid var(--line); border-radius: 7px; font-weight: 700; font-size: 13px; color: #3e5046; background: #f7f8f5; cursor: pointer; }
.speed { position: relative; }
.speed::after { content: ""; position: absolute; right: 10px; top: 13px; width: 6px; height: 6px; transform: rotate(45deg); border-right: 1.5px solid #51695a; border-bottom: 1.5px solid #51695a; pointer-events: none; }
.page-footer { display: flex; justify-content: space-between; gap: 14px; color: #586b5e; padding: 11px 2px 0; font-size: 12px; line-height: 1.4; }
#course-stats { white-space: nowrap; }
#course-stats span { margin: 0 3px; }
#map-route, .map-raft-body, .map-marker-label { pointer-events: none; }
.map-target { cursor: grab; }
.map.is-dragging .map-target { cursor: grabbing; }
.map-point { cursor: pointer; }
.map-rotation-handle { cursor: crosshair; }
.map-target:focus-visible { outline: none; filter: drop-shadow(0 0 3px #fff); }

dialog { width: min(420px, calc(100% - 32px)); border: 1px solid var(--line); border-radius: 13px; padding: 21px; color: var(--ink); box-shadow: 0 20px 80px #13291e50; }
dialog::backdrop { background: #152d25a0; }
.dialog-heading, .dialog-actions, .settings-files { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dialog-heading { margin-bottom: 14px; }
.dialog-heading h2 { font-size: 22px; letter-spacing: -.035em; }
.dialog-actions { justify-content: end; margin-top: 18px; }
.settings-files { justify-content: start; margin-top: 14px; }
.field { display: block; font-size: 13px; color: var(--muted); font-weight: 700; }
.field input, .field select { margin-top: 5px; }
.settings-error { font-size: 13px; color: var(--accent-ink); margin-top: 10px; }

@media (max-width: 1050px) {
  .workspace-body { grid-template-columns: minmax(0, 1fr) 265px; }
  .map-caption, .map-compass, .map-legend, .zoom { --inset: 11px; }
  .map-caption, .map-legend, .map-instruction { left: var(--inset, 11px); }
  .map-compass, .zoom { right: var(--inset); }
  .map-legend { gap: 6px 9px; }
}
@media (min-width: 736px) and (max-height: 800px) {
  .topbar-inner { height: 56px; }
  .page { padding-top: 18px; }
  .course-header { margin-bottom: 16px; }
  h1 { font-size: clamp(33px, 3vw, 46px); }
  .map { height: clamp(350px, calc(100dvh - 296px), 505px); }
  .inspector { max-height: clamp(350px, calc(100dvh - 296px), 505px); }
  .inspector-header { padding-block: 14px 9px; }
  .point-row { min-height: 39px; padding-block: 4px; }
  .point-number { width: 27px; height: 27px; }
  .selection { min-height: 137px; padding-block: 9px 10px; }
  .timeline { min-height: 60px; }
}
@media (max-width: 735px) {
  .topbar-inner { height: 57px; }
  .page { padding-top: 19px; }
  .course-header { display: block; margin-bottom: 16px; }
  .course-actions { margin-top: 13px; padding: 0; }
  .course-description { font-size: 14px; }
  .workspace-body { display: contents; }
  .workspace { display: flex; flex-direction: column; }
  .toolbar { padding: 6px; flex-wrap: wrap; gap: 5px; min-height: 45px; }
  .tools { gap: 1px; }
  .tool { padding-inline: 5px; gap: 4px; font-size: 12px; }
  .tool .icon { width: 15px; height: 15px; }
  .toolbar-end { gap: 3px; }
  .history { padding-right: 3px; }
  .history .icon-button { width: 23px; }
  .history .icon { width: 14px; height: 14px; }
  .add-keypoint { font-size: 12px; padding-inline: 6px; gap: 3px; }
  .add-keypoint .icon { width: 15px; height: 15px; }
  .map { height: 415px; order: 1; }
  .timeline { order: 2; padding: 7px; min-height: 60px; gap: 9px; }
  .timeline-label { font-size: 11px; }
  .inspector { order: 3; max-height: none; border: 0; border-top: 1px solid var(--line); border-radius: 0 0 13px 13px; overflow: hidden; }
  .inspector-header { padding-top: 14px; }
  .point-list { max-height: 290px; }
}
@media (max-width: 430px) {
  .topbar-inner, .page { padding-inline: 12px; }
  .save-state { font-size: 11px; margin-right: 0; gap: 4px; }
  .header-button { padding-inline: 8px; font-size: 12px; }
  .map { height: 358px; }
  .map-legend { bottom: 10px; gap: 4px 7px; padding: 6px; max-width: calc(100% - 114px); font-size: 10px; }
  .map-legend i { width: 9px; height: 2px; }
  .zoom { bottom: 10px; }
  .zoom button { width: 29px; height: 30px; }
}
@media (max-width: 370px) {
  .topbar-inner { gap: 8px; }
  .topbar-actions { gap: 5px; }
  .brand { font-size: 23px; }
  .brand-icon { width: 30px; height: 30px; }
  #export span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .toolbar { justify-content: flex-start; }
}
.selection-label { margin: 0; }

.settings-files { flex-wrap: wrap; }
.map-gate-pole { cursor: grab; }
