:root {
  --bg: #f7f7f4;
  /* what stands over the view: the header, the panes, the menus */
  --surface: #ffffff;
  --sunk: #efeee9;
  --fg: #1f2328;
  --muted: #646a72;
  --line: #dcdad3;
  --line-strong: #bfbcb2;
  --accent: #3d6b4f;
  --on-accent: #ffffff;
  --accent-soft: color-mix(in srgb, var(--accent) 12%, transparent);
  --error: #b42318;
  --reset: #9a5a12;
  --drop: #e8f0ea;
  --float: rgba(255, 255, 255, 0.92);
  --shadow: 0 1px 2px rgba(31, 35, 40, 0.06), 0 8px 24px rgba(31, 35, 40, 0.08);
  --radius: 8px;
  --control: 28px;
  --mono: ui-monospace, 'Cascadia Mono', Menlo, Consolas, monospace;
  /* the operations of the timeline, as in jfr-web */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #6250d6;
  --series-8: #e34948;
  --series-other: #a3a29c;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181b;
    --surface: #1e2125;
    --sunk: #111315;
    --fg: #e6e4df;
    --muted: #9a9ea5;
    --line: #34383d;
    --line-strong: #4a4f56;
    --accent: #8fc4a1;
    --on-accent: #10261a;
    --error: #ff8a7a;
    --reset: #e0a85c;
    --drop: #1f2a23;
    --float: rgba(30, 33, 37, 0.92);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-8: #e66767;
    --series-other: #6e6d68;
    color-scheme: dark;
  }
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.5 system-ui, sans-serif;
}

body.dropping {
  background: var(--drop);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

svg {
  flex: none;
}

/* the header: one row in a fixed order, what does not fit cut short rather than wrapped */
header {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 48px;
  box-sizing: border-box;
  padding: 0 12px 0 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

h1 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 8px 0 0;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

h1 .mark {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.6;
}

#bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

#tools:empty {
  display: none;
}

.file-name {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  height: var(--control);
  padding: 0 6px 0 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: none;
  color: inherit;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.file-name span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-name svg {
  width: 14px;
  height: 14px;
  color: var(--muted);
}

.file-name:hover, .file-name:has(+ .brief + :popover-open) {
  border-color: var(--line);
  background: var(--sunk);
}

#bar .brief {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

/* the file's menu: all that is known of it, under its name */
.file-menu {
  position: fixed;
  inset: auto;
  width: min(560px, calc(100vw - 16px));
  max-height: calc(100vh - 72px);
  box-sizing: border-box;
  margin: 0;
  padding: 14px 16px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--fg);
  box-shadow: var(--shadow);
}

.file-menu h2 {
  font-size: 14px;
  overflow-wrap: anywhere;
}

.file-menu p {
  margin: 0 0 10px;
}

.file-menu h3 {
  margin: 16px 0 8px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.file-menu .actions {
  display: flex;
  gap: 8px;
}

/* what saves the file: the loss and the button on one line, the file's name, what else to keep, what it comes to */
.file-menu .save-section {
  display: grid;
  gap: 8px;
}

.file-menu .save-section h3 {
  margin-bottom: 0;
}

.file-menu .save-row {
  display: flex;
  gap: 8px;
}

.file-menu .save-row select {
  flex: 1;
  min-width: 0;
}

.file-menu .save-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
}

.file-menu .save-section .check:has(input:disabled) {
  color: var(--muted);
}

.file-menu .save-section p {
  margin: 0;
}

/* the recording's timeline, under the header: an interval dragged on it sets the samples in focus */
#timeline {
  padding: 4px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.timeline-plot {
  display: block;
  width: 100%;
  height: 48px;
  cursor: crosshair;
  touch-action: none;
}

.timeline-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 12px;
  font-size: 12px;
}

.timeline-key {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0 4px;
  border: 1px solid transparent;
  border-radius: 4px;
  font: inherit;
  background: transparent;
  color: inherit;
  max-width: 32em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

button.timeline-key {
  cursor: pointer;
}

button.timeline-key:hover, .timeline-key.on {
  border-color: var(--accent);
}

.timeline-key i {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.timeline-key.other {
  color: var(--muted);
}

.timeline-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 28px;
  font-size: 12px;
}

.timeline-bar .button {
  --control: 22px;
  font-size: 12px;
}

.timeline-bar label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* a profile open: the view fills the window under the header, the settings docked at its right */
body:has(main.stage) {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

body:has(main.stage) #workspace {
  position: relative;
  display: flex;
  flex: 1;
  min-height: 0;
}

/* looking around in 3D (terrain3d.js): nothing but the view, and none of the popups */
body.playing header,
body.playing #timeline,
body.playing #settings,
body.playing .map-info,
body.playing .map-dock,
body.playing .flame-tip,
body.playing .tip-bubble,
body.playing .toast {
  display: none !important;
}

main.stage {
  position: relative;
  flex: 1;
  min-width: 0;
  padding: 0;
}

main.stage .stage-view {
  position: absolute;
  inset: 0;
}

/* nothing to set without a view */
#settings-toggle {
  display: none;
}

body:has(main.stage) #settings-toggle {
  display: inline-flex;
}

body:not(:has(main.stage)) #settings {
  display: none;
}

#settings-toggle[aria-expanded=true] {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* wider with the window, within reason; the overlay of a narrow window keeps its own width, below */
#settings {
  flex: 0 0 clamp(320px, 28vw, 400px);
  box-sizing: border-box;
  overflow-y: auto;
  border-left: 1px solid var(--line);
  background: var(--surface);
}

.settings-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px 6px 16px;
  background: var(--surface);
}

.settings-head h2 {
  margin: 0;
  font-size: 14px;
}

#settings-body {
  padding: 0 16px 16px;
}

#settings-body > .button {
  margin-top: 14px;
}

.settings-section {
  display: grid;
  gap: 8px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.settings-section:first-child {
  border-top: none;
  padding-top: 4px;
}

.settings-section h3 {
  margin: 0;
  font-size: 12px;
  font-weight: 650;
  color: var(--muted);
}

details.settings-section {
  display: block;
}

details.settings-section > summary {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  list-style: none;
}

details.settings-section > summary::-webkit-details-marker {
  display: none;
}

details.settings-section > summary::before {
  content: '';
  width: 6px;
  height: 6px;
  border: solid var(--muted);
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(-45deg);
  transition: transform 0.15s;
}

details.settings-section[open] > summary::before {
  transform: rotate(45deg);
}

details.settings-section[open] > summary {
  margin-bottom: 8px;
}

/* what a section holds: its rows, a gap apart; one that is hidden leaves no gap */
.settings-body {
  display: grid;
  gap: 8px;
}

/* the end of a section: its own settings back to their defaults. Its own colour, neither the green of the
   controls nor the grey of the labels, and a plain underline, which the labels with a tip do not have */
.settings-section .reset {
  display: block;
  justify-self: start;
  margin-top: 10px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--reset);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.settings-section .reset:hover {
  text-decoration-thickness: 2px;
}

/* a setting: its label at the left, the control filling the rest */
.field {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.field-label {
  color: var(--muted);
}

.field:has(.pattern) {
  grid-template-columns: 1fr;
  gap: 2px;
}

.check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.unit {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}

/* a few values all in sight, one chosen */
.segmented {
  display: flex;
  padding: 2px;
  border-radius: 7px;
  background: var(--sunk);
}

.segmented label {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  flex: 1;
  padding: 2px 6px;
  border-radius: 5px;
  text-align: center;
  white-space: nowrap;
  color: var(--muted);
  font-size: 13px;
  line-height: 20px;
  cursor: pointer;
}

.segmented span:hover {
  color: var(--fg);
}

.segmented input:checked + span {
  background: var(--surface);
  color: var(--fg);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.segmented input:focus-visible + span {
  outline: 2px solid var(--accent);
}

input:not([type=checkbox], [type=radio], [type=range]), select, textarea {
  box-sizing: border-box;
  min-height: var(--control);
  padding: 2px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: inherit;
  font: inherit;
  font-size: 13px;
}

input[type=checkbox], input[type=range] {
  accent-color: var(--accent);
}

input[type=number] {
  width: 5em;
}

input.pattern {
  width: 100%;
  font-family: var(--mono);
  font-size: 11px;
}

input.invalid {
  border-color: var(--error);
}

/* the panes floating over the view at the top left, one under the other */
.floats {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  max-width: min(720px, 45%);
  max-height: calc(100% - 24px);
  pointer-events: none;
}

.floats > * {
  pointer-events: auto;
}

.floating {
  max-width: 100%;
  min-height: 0;
  box-sizing: border-box;
  overflow: auto;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--float);
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}

.floating > summary {
  cursor: pointer;
  font-weight: 600;
  line-height: 26px;
}

h2 {
  margin: 0 0 4px;
  font-size: 15px;
}

main {
  padding: 16px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-sizing: border-box;
  height: var(--control);
  white-space: nowrap;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: inherit;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.button:hover {
  border-color: var(--accent);
}

.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}

.button.primary:hover {
  filter: brightness(1.08);
}

.button.icon {
  width: var(--control);
  padding: 0;
}

/* a filled mark, GitHub's, not a stroked outline like the others */
.button.solid svg {
  fill: currentColor;
  stroke: none;
}

.button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
}

.button input {
  display: none;
}

.muted {
  color: var(--muted);
}

/* narrower: the file's line, then the labels of the buttons, give way to the view; the settings over it */
@media (max-width: 900px) {
  #bar .brief {
    display: none;
  }
}

@media (max-width: 720px) {
  h1 {
    font-size: 0;
    margin: 0;
  }

  #settings-toggle span {
    display: none;
  }

  /* a file open: Close is enough, a new file is opened once it is closed (the header's own button: the file menu,
     inside it, has a primary button too) */
  header:has(#close:not([hidden])) > .button.primary {
    display: none;
  }

  #settings {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(320px, 100%);
    box-shadow: var(--shadow);
    z-index: 2;
  }
}

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

/* a landscape of the page's own making behind the landing, dimmed to the page's colour and blurred; the scale hides the blur's soft edge */
body:has(.landing)::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(color-mix(in srgb, var(--bg) 55%, transparent), color-mix(in srgb, var(--bg) 55%, transparent)),
    url('../img/landing.jpg') center / cover;
  filter: saturate(1.2);
  pointer-events: none;
}

/* the choice between the page that reads files and the gallery */
.landing-choice {
  display: flex;
  justify-content: center;
  margin: 24px 16px -16px;
}

.landing-choice .segmented {
  width: 260px;
}

.landing[hidden] {
  display: none;
}

.landing {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 12px 16px;
  max-width: 880px;
  margin: 32px auto;
}

.landing > h2,
.landing > p {
  grid-column: 1 / -1;
  margin: 0;
  /* a halo of the page's colour, to read over the picture */
  text-shadow: 0 0 2px var(--bg), 0 0 6px var(--bg);
}

.landing > p.muted {
  color: var(--fg);
}

/* each kind of file has its tint: the time in blue, the memory in orange, Flamepack, which holds either, in violet */
.landing .profiles {
  --tint: var(--series-1);
}

.landing .heap {
  --tint: var(--series-2);
}

.landing .flamepack {
  --tint: var(--series-7);
}

.landing .chip {
  display: inline-block;
  margin-left: 4px;
  padding: 0 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--tint) 14%, transparent);
  color: color-mix(in srgb, var(--tint) 55%, var(--fg));
  font-size: 11px;
  font-weight: 600;
  vertical-align: 2px;
}

.landing > h2:first-child {
  font-size: 28px;
  letter-spacing: -0.02em;
}

.landing > h2:not(:first-child) {
  margin-top: 16px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--tint, var(--accent)) 55%, var(--fg));
}

.landing a {
  color: var(--accent);
  text-underline-offset: 2px;
}

.landing code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--drop);
  font-size: 12px;
}

.landing .kind {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--tint, var(--accent));
  border-radius: 10px;
  /* opaque, so the text does not compete with the picture behind */
  background: color-mix(in srgb, var(--tint, var(--accent)) 5%, var(--surface));
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.landing .kind:hover {
  border-color: var(--tint, var(--accent));
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
}

/* the lone heap dump card spans both columns rather than leaving one empty */
.landing .kind.heap {
  grid-column: 1 / -1;
}

/* a profile of the gallery is a card that opens it, and does not span the grid whatever its tint */
.landing button.kind.gallery {
  grid-column: auto;
  width: 100%;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.landing .kind h3 {
  margin: 0 0 4px;
  font-size: 15px;
}

.landing .kind p {
  margin: 0;
  color: var(--muted);
}

.error {
  color: var(--error);
}

h3 {
  margin: 16px 0 4px;
  font-size: 14px;
}

table {
  border-collapse: collapse;
}

th, td {
  padding: 2px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

th {
  font-weight: 600;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.peaks .name {
  font-family: ui-monospace, monospace;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.peaks tr.peak {
  cursor: pointer;
}

.peaks tr.peak:hover, .peaks tr.peak.open {
  background: var(--drop);
}

.peaks tr.mountain > td {
  padding: 4px 8px 8px;
}

.callers, .callers ul {
  margin: 0;
  padding-left: 16px;
  list-style: none;
  font-family: ui-monospace, monospace;
  font-size: 13px;
}

.callers {
  padding-left: 0;
}

.callers li.leaf {
  padding-left: 14px;
}

.callers summary {
  cursor: pointer;
}

.callers .entry {
  color: var(--accent);
  font-weight: 600;
}

/* the map: the plain, then the land from low to high */
:root {
  --plain: #f3f0e8;
  --land-1: #d3e5c3;
  --land-2: #a9cb8e;
  --land-3: #e0c77f;
  --land-4: #c48a52;
  --land-5: #7f4f2c;
  --contour: rgba(90, 70, 45, 0.45);
  --lit: #d9480f;
}

@media (prefers-color-scheme: dark) {
  :root {
    --plain: #1c1f22;
    --land-1: #233528;
    --land-2: #2f5236;
    --land-3: #6a5a34;
    --land-4: #8c6a48;
    --land-5: #e8c9a0;
    --contour: rgba(225, 215, 195, 0.3);
    --lit: #ff8a50;
  }
}

canvas.map {
  display: block;
  cursor: grab;
  touch-action: none;
}

canvas.map.dragging {
  cursor: grabbing;
}

/* the flame graph: the root at the bottom of the view, the search on the right under the panes */
.flame {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
}

.flame-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 8px 12px;
}

.flame-body {
  position: relative;
  flex: 1;
  min-height: 0;
}

.flame-scroll {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

/* a short graph stands on the bottom, not hangs from the top */
canvas.flame-canvas {
  display: block;
  width: 100%;
  flex: none;
  margin-top: auto;
  cursor: pointer;
}

.flame-tip {
  position: absolute;
  z-index: 2;
  max-width: 480px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 12px;
  pointer-events: none;
}

.flame-tip-name {
  font-family: var(--mono);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.map-info {
  position: absolute;
  left: 12px;
  bottom: 12px;
  max-width: min(640px, calc(100% - 24px));
  max-height: 40%;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--float);
  box-shadow: var(--shadow);
  pointer-events: none;
  overflow: auto;
  font-size: 13px;
}

.map-info.top {
  top: 12px;
  bottom: auto;
}

.map-info.right {
  left: auto;
}

.map-info b {
  color: var(--fg);
  font-family: ui-monospace, monospace;
}

.map-info .path {
  margin: 4px 0 0;
  padding-left: 28px;
  font-family: ui-monospace, monospace;
}

.map-info .path li {
  color: var(--fg);
}

.map-info .path li.here {
  color: var(--lit);
  font-weight: 600;
}

.map-info .path li.on {
  color: var(--muted);
}

.terrain {
  position: relative;
  height: 100%;
}

.terrain.entering {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.terrain.entering.shown {
  opacity: 1;
  transition: opacity 250ms ease-in;
}

.terrain > .map-holder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* the panel floating at the right, its left edge dragged */
.map-dock {
  position: absolute;
  top: 12px;
  right: 12px;
  bottom: 12px;
  display: flex;
  max-width: calc(100% - 24px);
  pointer-events: none;
}

.map-dock > * {
  pointer-events: auto;
}

.map-split {
  flex: 0 0 6px;
  cursor: col-resize;
  border-radius: 3px;
  touch-action: none;
}

.map-split:hover {
  background: var(--line);
}

.map-panel .panel-tabs {
  display: flex;
  gap: 4px;
  margin: 6px 0;
}

.map-panel .panel-tabs .button.on {
  font-weight: 600;
  border-color: var(--fg);
}

.map-panel .tops {
  margin: 4px 0 10px;
  padding-left: 18px;
  font-family: ui-monospace, monospace;
  font-size: 12px;
}

.map-panel .groups {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 4px 0 8px;
}

.map-panel .groups .kind {
  margin-left: 0;
  font-size: 12px;
}

.map-panel .kind {
  margin-left: 6px;
  padding: 0 5px;
  border-radius: 3px;
  background: rgba(200, 120, 40, 0.2);
  font-family: system-ui, sans-serif;
  font-size: 11px;
}

.map-panel {
  align-self: flex-start;
  min-width: 240px;
  max-width: 100%;
  max-height: 100%;
  box-sizing: border-box;
  overflow: auto;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--float);
  box-shadow: var(--shadow);
}

.map-panel .panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  font-family: ui-monospace, monospace;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.map-panel .callers {
  margin-top: 6px;
}

.map-holder.three {
  overflow: hidden;
}

.map-holder.three canvas {
  display: block;
  cursor: grab;
}

/* what looking around aims with (key F): a cross in the middle of the view, white with a dark edge to show on
   the sky, the sea and the land alike */
.crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 22px;
  height: 22px;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.crosshair::before,
.crosshair::after {
  content: '';
  position: absolute;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.55);
}

.crosshair::before {
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
}

.crosshair::after {
  top: 50%;
  left: 0;
  right: 0;
  height: 2px;
  margin-top: -1px;
}

.peak-labels span.trail {
  font-style: italic;
  font-size: 10px;
}

/* the 3D view's own controls, a toolbar over it: they act on the terrain shown, not on what it is made of */
.map-holder.three .relief {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 16px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--float);
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
  font-size: 12px;
  white-space: nowrap;
  color: var(--fg);
}

.map-holder.three .relief label {
  display: flex;
  align-items: center;
  gap: 6px;
}

.map-holder.three .relief input[type=range] {
  width: 100px;
}

.hue-legend {
  position: absolute;
  right: 12px;
  bottom: 12px;
  max-width: 40%;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--float);
  box-shadow: var(--shadow);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: 12px;
}

.hue-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.hue-legend i {
  width: 12px;
  height: 12px;
  border-radius: 2px;
}

.peak-labels span {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: 11px;
  white-space: nowrap;
  pointer-events: none;
  color: var(--fg);
  text-shadow: 0 0 3px var(--bg), 0 0 3px var(--bg), 0 0 2px var(--bg);
}

/* the colours of a sign, the same in either theme: a plate and the ink of its text and its rule; the signs are
   of the colour the container says (data-sign), a swatch of the settings is its own (data-colour) */
.peak-labels[data-sign=white], .swatches [data-colour=white] {
  --plate: #f7f6f1;
  --ink: #1d1d1b;
}

.peak-labels[data-sign=yellow], .swatches [data-colour=yellow] {
  --plate: #f4c430;
  --ink: #1d1a0c;
}

.peak-labels[data-sign=blue], .swatches [data-colour=blue] {
  --plate: #1f5fae;
  --ink: #ffffff;
}

.peak-labels[data-sign=red], .swatches [data-colour=red] {
  --plate: #c0392b;
  --ink: #ffffff;
}

.peak-labels[data-sign=green], .swatches [data-colour=green] {
  --plate: #1f7a4d;
  --ink: #ffffff;
}

/* a peak's name and weight: a road sign with no pole, a rule inside its plate, over the summit and always
   facing the camera, larger when it is near (--scale, set as it is placed) */
.peak-labels span.sign {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 4px 9px 5px;
  border-radius: 6px;
  background: var(--plate);
  color: var(--ink);
  text-shadow: none;
  outline: 1px solid var(--ink);
  outline-offset: -3px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  transform: translate(-50%, calc(-100% - 4px)) scale(var(--scale, 1));
  transform-origin: 50% 100%;
}

.peak-labels span.sign b {
  font-weight: 600;
}

/* the choice of a sign's colour: a row of small plates, the one chosen ringed */
.swatches {
  display: flex;
  align-items: center;
  gap: 8px;
}

.swatches label {
  display: flex;
}

.swatches input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.swatches span {
  width: 24px;
  height: 18px;
  border-radius: 4px;
  background: var(--plate);
  outline: 1px solid var(--ink);
  outline-offset: -3px;
  box-shadow: 0 0 0 1px var(--line-strong);
  cursor: pointer;
}

.swatches input:checked + span {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent);
}

.swatches input:focus-visible + span {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--fg);
}

.peak-labels span.sign small {
  font-size: 10px;
  opacity: 0.85;
}

/* a frame and its ms on one line: the panel scrolls sideways rather than wrap */
.map-panel .callers li, .map-panel .callers summary, .map-panel .tops li {
  white-space: nowrap;
}

/* each slider under its label: the pane is narrow */
.knobs {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 22px 3.5em;
  align-items: center;
  gap: 0 6px;
  font-size: 12px;
}

/* the line above the sliders, across the whole row, not in the narrow column of a button */
.knobs > :first-child {
  grid-column: 1 / -1;
}

.knobs .knob {
  display: contents;
}

.knobs .knob > span:first-child {
  grid-column: 1 / -1;
  margin-top: 6px;
  color: var(--muted);
}

.knobs .invert {
  grid-column: 1 / -1;
  margin-top: 8px;
}

.knobs input[type=range] {
  width: 100%;
  margin: 0;
}

.knobs .nudge {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface);
  color: var(--fg);
  font: inherit;
  line-height: 1;
  cursor: pointer;
}

.knobs .nudge:hover {
  border-color: var(--accent);
}

.knobs .value {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

/* its Reset, as in the other sections, across the row of the grid */
.knobs .reset {
  grid-column: 1 / -1;
}

.toast {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--float);
  box-shadow: var(--shadow);
  color: var(--fg);
  font-size: 12px;
  z-index: 10;
}

/* over the tour's bar while it shows: the message, and the box telling the frame hovered at the foot of the view */
body:has(.tour-player:not([hidden])) .toast {
  bottom: calc(28px + var(--tour-bar, 96px));
}

body:has(.tour-player:not([hidden])) .map-info:not(.top) {
  bottom: calc(32px + var(--tour-bar, 96px));
  max-height: calc(100% - 56px - var(--tour-bar, 96px));
}

/* the tour's section of the settings: its views in order, a number that shows the view, its caption, and what
   moves, takes again or removes it */
.tour-actions {
  display: flex;
  gap: 8px;
}

.tour-empty {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
}

/* a long tour scrolls in its own box, so that the settings under it stay within reach */
.tour-list {
  position: relative;
  display: grid;
  gap: 6px;
  max-height: min(40vh, 360px);
  margin: 0;
  padding: 0 4px 0 0;
  overflow-y: auto;
  list-style: none;
}

.tour-list:empty {
  display: none;
}

.tour-slide {
  display: grid;
  grid-template-columns: var(--control) minmax(0, 1fr) auto;
  align-items: start;
  gap: 6px;
}

.tour-number {
  height: var(--control);
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.tour-number:hover {
  border-color: var(--accent);
  color: var(--fg);
}

.tour-slide[aria-current] .tour-number {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}

.tour-slide textarea {
  width: 100%;
  min-height: var(--control);
  padding: 4px 8px;
  resize: vertical;
  field-sizing: content;
  line-height: 1.4;
}

.tour-tools {
  display: flex;
}

.tour-tools .button.icon,
.tour-steps .button.icon {
  border-color: transparent;
  background: none;
}

.tour-tools .button.icon {
  width: 22px;
  color: var(--muted);
}

.tour-tools .button.icon:hover:not(:disabled) {
  color: var(--fg);
}

.tour-tools .button.icon:disabled {
  opacity: 0.3;
  cursor: default;
}

.tour-times {
  display: grid;
  gap: 6px;
  margin-top: 4px;
}

.tour-times + .reset {
  margin-top: 4px;
}

/* the tour shown: the caption of the view, read first, the steps under it, and the time left before the next view
   run down along its foot */
.tour-player {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9;
  display: grid;
  gap: 4px;
  box-sizing: border-box;
  width: min(36rem, calc(100vw - 32px));
  padding: 12px 8px 6px 16px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--float);
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
  color: var(--fg);
}

.tour-caption {
  margin: 0;
  padding-right: 8px;
  max-height: 55vh;
  overflow-y: auto;
  font-size: 15px;
  line-height: 1.45;
  white-space: pre-line;
}

.tour-caption:empty {
  display: none;
}

.tour-caption a {
  color: var(--accent);
  text-decoration: underline;
  overflow-wrap: anywhere;
}

.tour-steps {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: -8px;
}

.tour-count {
  flex: 1;
  margin-left: 8px;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.tour-time {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  width: 0;
  background: var(--accent);
}

@keyframes tour-time {
  from { width: 0; }
  to { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .tour-time {
    display: none;
  }
}

body.playing .tour-player {
  display: none;
}

.anonymizing {
  display: grid;
  gap: 16px;
  font-size: 13px;
}

.anonymizing label {
  display: grid;
  gap: 2px;
}

.anonymizing label.inline {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* a transform and its settings, which are indented under the switch and dimmed while it is off */
.anon-group {
  display: grid;
  gap: 8px;
}

.anon-fields {
  display: grid;
  gap: 8px;
  margin-left: 22px;
}

.anon-fields.off {
  opacity: 0.5;
}

.anonymizing textarea {
  width: 100%;
  font-family: var(--mono);
  font-size: 11px;
  resize: vertical;
}

.anonymizing .button {
  justify-self: start;
}

/* Progress indicator for heap dump loading */
#progress {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--float);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  min-width: 300px;
}
.progress-text {
  margin-bottom: 8px;
  text-align: center;
  font-size: 13px;
}
.progress-bar {
  height: 6px;
  background: var(--line);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.2s ease;
  width: 0;
}

/* The parse report: what a heap dump parse read and cost */
.report {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 13px;
}

.report-section .report-title {
  font-weight: 600;
  margin-bottom: 2px;
}

.report-table {
  border-collapse: collapse;
}

.report-table td {
  padding: 1px 12px 1px 0;
  white-space: nowrap;
}

.report-table td:last-child {
  font-variant-numeric: tabular-nums;
}

.report-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}

.report-status {
  font-size: 12px;
}

.report-copy {
  width: 100%;
  box-sizing: border-box;
  font: 12px/1.4 ui-monospace, monospace;
}

/* a frame in a panel that can be clicked to show that object instead */
.callers .pick {
  cursor: pointer;
}

.callers .pick:hover {
  text-decoration: underline;
}

.file-menu .report-table {
  width: 100%;
}

.file-menu .report-table td:first-child {
  width: 45%;
}

.settings-rows {
  display: grid;
  gap: 8px;
}

/* a few checkboxes on one line, wrapping when the pane is narrow */
.toggles {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 16px;
}

.field input[type=range] {
  width: 100%;
  margin: 0;
}
