:root {
  --bg: #ecebe6;
  --pane: #fbfbf8;
  --line: #c9c5ba;
  --ink: #232629;
  --muted: #646b70;
  --accent: #2f6f7c;
  --accent-strong: #174e5d;
  --active: #b93f2a;
  --match: #f3b340;
  --shadow: 0 12px 32px rgba(31, 34, 36, 0.16);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button,
select,
input {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

button {
  min-height: 36px;
  padding: 0 12px;
  cursor: pointer;
}

button:hover,
button:focus,
select:focus,
input:focus,
a:focus {
  outline: 2px solid rgba(47, 111, 124, 0.38);
  outline-offset: 2px;
}

.topbar {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 18px;
  background: #263238;
  color: #fff;
  border-bottom: 4px solid #c5a84c;
}

.brand h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.05;
}

.brand p {
  margin: 5px 0 0;
  color: #d9dfdf;
  font-size: 14px;
}

.document-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.document-links a {
  color: #fff;
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.08);
}

.workspace {
  min-height: calc(100vh - 78px);
  display: grid;
  grid-template-columns: minmax(320px, 390px) minmax(0, 1fr);
}

.sidepane {
  border-right: 1px solid var(--line);
  background: var(--pane);
  min-height: calc(100vh - 78px);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
}

.controls,
.result-block,
.details {
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.controls {
  display: grid;
  gap: 8px;
}

.controls label,
.map-toolbar label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.controls input,
.controls select,
.map-toolbar select {
  min-height: 36px;
  padding: 0 10px;
  width: 100%;
}

.control-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 4px;
}

.result-block {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.result-block.collapsed {
  min-height: 0;
}

.result-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

#resultLimit {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.result-list {
  overflow: auto;
  display: grid;
  gap: 6px;
  padding-right: 4px;
  max-height: 260px;
}

.result-item {
  text-align: left;
  width: 100%;
  min-height: 0;
  padding: 8px 9px;
  border-color: #d8d4ca;
  background: #fff;
}

.result-item strong {
  display: block;
  font-size: 14px;
}

.result-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  margin-top: 2px;
}

.result-item.active {
  border-color: var(--active);
  box-shadow: inset 4px 0 0 var(--active);
}

.details {
  max-height: none;
  overflow: auto;
  border-bottom: 0;
}

.details h2 {
  margin: 0 0 10px;
  font-size: 18px;
}

.record-nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.record-nav button {
  min-width: 0;
}

.record-nav span {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.empty-note {
  color: var(--muted);
  margin: 0;
  line-height: 1.45;
}

.detail-table {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 7px 10px;
  font-size: 13px;
}

.detail-table dt {
  color: var(--muted);
  font-weight: 700;
}

.detail-table dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.media-link,
.media-audio {
  margin-top: 12px;
}

.media-link a {
  color: var(--accent-strong);
}

.record-image {
  margin: 14px 0 0;
}

.record-image img {
  display: block;
  max-width: min(100%, 280px);
  height: auto;
  border: 1px solid var(--line);
  background: #fff;
}

.record-image figcaption {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.map-pane {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.map-toolbar {
  min-height: 56px;
  display: grid;
  grid-template-columns: auto minmax(130px, 180px) auto minmax(240px, 1fr) auto;
  align-items: center;
  gap: 8px 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: #f7f7f2;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.toggle input {
  width: 18px;
  height: 18px;
}

.map-stage {
  min-height: 0;
  overflow: auto;
  padding: 18px;
  background: #dcd8ce;
}

.image-frame {
  position: relative;
  width: min(100%, 920px);
  margin: 0 auto;
  background: #fff;
  box-shadow: var(--shadow);
}

.image-frame.large {
  width: min(100%, 1120px);
}

.image-frame img {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
}

.marker-layer {
  position: absolute;
  inset: 0;
}

.marker {
  position: absolute;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  padding: 0;
  min-height: 0;
  border-radius: 50%;
  border: 1px solid rgba(35, 38, 41, 0.8);
  background: rgba(47, 111, 124, 0.62);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.72);
}

.marker.filtered {
  background: var(--match);
  border-color: #553700;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  z-index: 2;
}

.marker.active {
  background: var(--active);
  border-color: #fff;
  width: 15px;
  height: 15px;
  margin: -7px 0 0 -7px;
  z-index: 3;
}

.marker-layer.hidden {
  display: none;
}

@media (max-width: 860px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .document-links {
    justify-content: flex-start;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .sidepane {
    min-height: 0;
    border-right: 0;
  }

  .result-block {
    max-height: 320px;
  }

  .details {
    max-height: none;
  }

  .map-toolbar {
    grid-template-columns: 1fr;
  }

  .map-stage {
    padding: 10px;
  }
}
