* {
  box-sizing: border-box;
}
:root {
  /* dark is the default theme; the light block below overrides for
     users whose OS/browser prefers light */
  --bg: #101014;
  --panel: #1a1a20;
  --panel-border: #2c2c34;
  --text: #e8e8ea;
  --text-dim: #c8c8d0;
  --text-faint: #8a8a94;
  --input-bg: #24242c;
  --input-border: #34343e;
  --chip-bg: #2c2c34;
  --chip-hover: #3b3b46;
  --btn: #3b6fd4;
  --btn-hover: #4a7ee4;
  --accent: #7fa5e8;
  --fitinfo: #9fd09f;
  --canvas-bg: #101014;
  --compass-bg: rgb(41, 41, 41);
  --compass-fg: rgb(217, 217, 217);
  --compass-divider: rgb(82, 82, 82);
  --popover-bg: #1e1e26;
  --popover-border: #3a3a46;
  --popover-shadow: rgba(0, 0, 0, 0.5);
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #e9eaf0;
    --panel: #ffffff;
    --panel-border: #d6d8de;
    --text: #1e1e26;
    --text-dim: #44464e;
    --text-faint: #7c7e88;
    --input-bg: #f0f1f5;
    --input-border: #c9ccd4;
    --chip-bg: #e2e3e9;
    --chip-hover: #d0d2da;
    --btn: #3b6fd4;
    --btn-hover: #2f5fbd;
    --accent: #2b5cb8;
    --fitinfo: #2e7d32;
    --canvas-bg: #d9dbe2;
    --compass-bg: rgb(240, 241, 245);
    --compass-fg: rgb(40, 40, 48);
    --compass-divider: rgb(170, 173, 182);
    --popover-bg: #ffffff;
    --popover-border: #c9ccd4;
    --popover-shadow: rgba(40, 40, 60, 0.25);
  }
}
html,
body {
  margin: 0;
  height: 100%;
  font-family: system-ui, sans-serif;
}
.app {
  display: flex;
  height: 100vh;
  /* dynamic viewport height: on mobile browsers 100vh includes the
     area behind the collapsing URL bar, pushing the compass below the
     fold; dvh tracks the actually visible area */
  height: 100dvh;
  background: var(--bg);
  color: var(--text);
}
.sidebar {
  width: 300px;
  padding: 16px;
  background: var(--panel);
  border-right: 1px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  position: relative;
}
.sidebar.collapsed {
  display: none;
}
.sidebar .collapse-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  padding: 0;
  background: var(--chip-bg);
  color: var(--text);
  font-size: 12px;
  border-radius: 5px;
}
.sidebar .collapse-btn:hover {
  background: var(--chip-hover);
}
.nav-toggle {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 5;
  width: 36px;
  height: 36px;
  padding: 0;
  background: rgba(26, 26, 32, 0.85);
  color: #e8e8ea;
  border: 1px solid #2c2c34;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
}
.nav-toggle:hover {
  background: rgba(59, 111, 212, 0.9);
}
/* sits on top of the photo, so it stays dark in both themes */
.canvasstatus {
  position: absolute;
  bottom: 6px;
  left: 8px;
  right: 8px;
  /* do NOT let long status text widen the flex container (that
     stretched the canvas and re-anchored the fit on every update) */
  width: min-content;
  max-width: calc(100% - 16px);
  font-size: 11px;
  color: #e8e8ea;
  background: rgba(16, 16, 20, 0.7);
  padding: 3px 8px;
  border-radius: 5px;
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar h1 {
  margin: 0;
  font-size: 22px;
}
.tag {
  display: block;
  margin: 0 0 12px;
  color: var(--text-faint);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  text-decoration: none;
}
.tag:hover {
  color: var(--accent);
  text-decoration: underline;
}
.sidebar button {
  padding: 8px 12px;
  background: var(--btn);
  color: #fff;
  border: 0;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
}
.sidebar button:hover {
  background: var(--btn-hover);
}
.sidebar button.secondary {
  background: var(--chip-bg);
  color: var(--text);
  font-size: 13px;
  padding: 6px 10px;
}
.sidebar button.secondary:hover {
  background: var(--chip-hover);
}
.status {
  font-size: 13px;
  color: var(--text-dim);
  word-break: break-word;
}
.hint {
  font-size: 12px;
  color: var(--text-faint);
}
.row {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 13px;
  cursor: pointer;
}
.fitinfo {
  font-size: 12px;
  color: var(--fitinfo);
  font-variant-numeric: tabular-nums;
}
.hover {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.dim {
  opacity: 0.6;
}
.hidden-file {
  display: none;
}
.infofoot {
  /* pins the info texts to the bottom of the sidebar */
  margin-top: auto;
}
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.canvaswrap {
  flex: 1;
  position: relative;
  min-height: 0;
  background: var(--canvas-bg);
}
canvas.viewport {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
canvas.compass {
  display: block;
  width: 100%;
  touch-action: none;
  cursor: ew-resize;
}
.section {
  margin-top: 14px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-faint);
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 3px;
}
.slider {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 8px;
}
.sliderhead {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-dim);
}
.slider input[type="range"] {
  width: 100%;
  accent-color: var(--btn);
}
.numrow {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  margin-top: 6px;
}
.numrow input {
  width: 130px;
  padding: 4px 6px;
  background: var(--input-bg);
  color: var(--text);
  border: 1px solid var(--input-border);
  border-radius: 4px;
}
.numrow input[type="text"] {
  width: 150px;
}
.fpbackdrop {
  position: absolute;
  inset: 0;
  z-index: 9;
}
.findpeak {
  position: absolute;
  z-index: 10;
  width: 280px;
  background: var(--popover-bg);
  border: 1px solid var(--popover-border);
  border-radius: 6px;
  box-shadow: 0 8px 24px var(--popover-shadow);
  display: flex;
  flex-direction: column;
}
.fpsearch {
  padding: 8px;
  border-bottom: 1px solid var(--panel-border);
}
.fpsearch input {
  width: 100%;
  padding: 5px 8px;
  background: var(--input-bg);
  border: 1px solid var(--popover-border);
  border-radius: 4px;
  color: var(--text);
  font-size: 13px;
}
.fplist {
  max-height: 320px;
  overflow-y: auto;
}
.fpempty {
  padding: 8px 10px;
  font-size: 13px;
  color: var(--text-faint);
  margin: 0;
}
.fpfoot {
  padding: 6px 8px;
  border-top: 1px solid var(--panel-border);
  text-align: right;
}
.fpcancel {
  padding: 4px 12px;
  background: var(--chip-bg);
  color: var(--text);
  border: 0;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
}
.fphead {
  padding: 6px 10px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-faint);
  border-bottom: 1px solid var(--panel-border);
}
.fpitem {
  display: block;
  width: 100%;
  text-align: left;
  padding: 6px 10px;
  background: none;
  border: 0;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}
.fpitem:hover {
  background: var(--btn);
  color: #fff;
}
