:root {
  --bg: #141816;
  --panel: #1e2420;
  --panel-2: #262e29;
  --line: #3a463e;
  --text: #e7ece8;
  --muted: #9aa89e;
  --gold: #d4b36a;
  --gold-dim: #8a7038;
  --danger: #d9786a;
  --ok: #7fb069;
  --map-h: 58%;
  font-family: "Segoe UI", "IBM Plex Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
}

body {
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: 100%;
}

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 1.1rem 1rem 1.5rem;
  overflow: auto;
}

.brand h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 650;
  letter-spacing: 0.02em;
}

.brand p {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.disclaimer {
  margin: 0.9rem 0;
  padding: 0.55rem 0.65rem;
  background: #2a2218;
  border: 1px solid #5a4a2a;
  color: #e6d3a4;
  font-size: 0.75rem;
  line-height: 1.4;
}

.card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.85rem;
  margin-bottom: 0.75rem;
}

.card h2 {
  margin: 0 0 0.7rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold);
}

label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.55rem;
}

select, input[type="text"] {
  display: block;
  width: 100%;
  margin-top: 0.28rem;
  background: #141816;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0.42rem 0.5rem;
  font-size: 0.88rem;
}

select:disabled { opacity: 0.45; }

.check {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0.65rem 0 0.2rem;
  color: var(--text);
  font-size: 0.82rem;
  cursor: pointer;
}

.check input {
  width: auto;
  margin: 0;
  accent-color: #ff1a1a;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.actions {
  display: flex;
  gap: 0.45rem;
  margin-top: 0.35rem;
}

button {
  flex: 1;
  border: 0;
  border-radius: 5px;
  padding: 0.48rem 0.4rem;
  font-size: 0.82rem;
  cursor: pointer;
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

button.primary {
  background: var(--gold);
  color: #1a160c;
  font-weight: 650;
}

button.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

.file-btn {
  display: block;
  background: #141816;
  border: 1px dashed var(--gold-dim);
  border-radius: 5px;
  padding: 0.55rem;
  text-align: center;
  color: var(--gold);
  cursor: pointer;
  font-size: 0.85rem;
}

.file-btn input { display: none; }

.tune {
  margin-top: 0.55rem;
  padding-top: 0.45rem;
  border-top: 1px solid var(--line);
}

.hint {
  margin: 0.35rem 0 0;
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--muted);
}

.hidden {
  display: none !important;
}

.pin-opts {
  margin-top: 0.55rem;
  padding-top: 0.45rem;
  border-top: 1px solid var(--line);
}

.pin-icon-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0.45rem 0 0.15rem;
}

.pin-icon-label {
  font-size: 0.75rem;
  color: var(--muted);
  min-width: 2.2rem;
}

.pin-icons {
  display: flex;
  gap: 0.4rem;
}

.pin-icon-btn {
  position: relative;
  flex: 0 0 auto;
  width: 2.7rem;
  height: 2.7rem;
  padding: 0.22rem;
  background: #141816;
  color: var(--gold);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.pin-icon-btn.active {
  border-color: var(--gold);
  background: #2a2618;
}

.pin-icon-btn img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.pin-icon-btn span {
  display: none;
  font-size: 0.95rem;
  font-weight: 700;
}

.pin-icon-btn img.missing {
  display: none;
}

.pin-icon-btn img.missing + span {
  display: grid;
  place-items: center;
  height: 100%;
}

.tune input[type="range"] {
  width: 100%;
  margin-top: 0.2rem;
}

.card label span {
  float: right;
  color: var(--gold);
}

.style-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.6rem;
  align-items: end;
  margin-bottom: 0.45rem;
}

.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  margin-bottom: 0.65rem;
}

.seg-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

.seg-3 .seg-btn {
  font-size: 0.72rem;
  padding: 0.42rem 0.15rem;
}

.seg-btn {
  flex: 1;
  background: #141816;
  color: var(--muted);
  border: 1px solid var(--line);
  font-weight: 600;
}

.seg-btn.active {
  background: var(--gold);
  color: #1a160c;
  border-color: var(--gold);
}

.photo-pane.pin-cursor canvas {
  cursor: crosshair;
  touch-action: none;
}

input[type="color"] {
  display: block;
  width: 2.4rem;
  height: 1.7rem;
  padding: 0;
  border: 1px solid var(--line);
  background: #141816;
  cursor: pointer;
}

input[type="range"] {
  width: 100%;
  margin-top: 0.2rem;
}

.exif-box {
  margin-top: 0.55rem;
  font-size: 0.75rem;
  line-height: 1.45;
  color: var(--text);
  background: #141816;
  border-radius: 5px;
  padding: 0.5rem 0.6rem;
  white-space: pre-line;
}

.exif-box.hidden { display: none; }

.gcp-list {
  margin: 0.5rem 0 0;
  padding-left: 1.2rem;
  font-size: 0.75rem;
  color: var(--muted);
  max-height: 8rem;
  overflow: auto;
}

.status {
  min-height: 2.4rem;
  font-size: 0.8rem;
  line-height: 1.4;
  margin: 0.4rem 0 0;
  color: var(--muted);
}

.status.ok { color: var(--ok); }
.status.err { color: var(--danger); }

.workspace {
  display: grid;
  grid-template-rows: var(--map-h) 1fr;
  min-width: 0;
  min-height: 100vh;
}

.map-pane, .photo-pane {
  position: relative;
  min-height: 0;
  border-bottom: 1px solid var(--line);
}

.photo-pane { border-bottom: 0; }

.pane-label {
  position: absolute;
  z-index: 500;
  top: 8px;
  left: 8px;
  background: rgba(20, 24, 22, 0.82);
  padding: 0.22rem 0.5rem;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  border-radius: 4px;
  pointer-events: none;
}

.mode-chip {
  position: absolute;
  z-index: 500;
  top: 8px;
  right: 8px;
  background: rgba(20, 24, 22, 0.82);
  padding: 0.22rem 0.5rem;
  font-size: 0.72rem;
  border-radius: 4px;
  color: var(--gold);
}

#map, #photoWrap {
  width: 100%;
  height: 100%;
  background: #0d100e;
}

#photoWrap {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#photoCanvas {
  max-width: 100%;
  max-height: 100%;
  cursor: crosshair;
}

.empty {
  color: var(--muted);
  font-size: 0.9rem;
}

.leaflet-container { background: #0d100e; }

.nav {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.7rem;
}

.nav a {
  flex: 1;
  text-align: center;
  text-decoration: none;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0.32rem 0.2rem;
  font-size: 0.75rem;
}

.nav a.active, .nav a:hover {
  color: var(--gold);
  border-color: var(--gold-dim);
}

.video-workspace {
  grid-template-rows: 1fr auto;
}

.video-stage {
  position: relative;
  min-height: 0;
  background: #0d100e;
}

#viewCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

#vid {
  position: absolute;
  left: -80px;
  top: 0;
  width: 160px;
  height: 90px;
  opacity: 0;
  pointer-events: none;
}

.timeline-bar {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.8rem;
  background: var(--panel);
  border-top: 1px solid var(--line);
}

.timeline-bar input[type="range"] {
  flex: 1;
  margin: 0;
}

.timeline-bar span {
  font-size: 0.75rem;
  color: var(--muted);
  min-width: 7.5rem;
  text-align: right;
}

.cv-wait {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(13, 16, 14, 0.72);
  z-index: 20;
  color: var(--gold);
  font-size: 0.9rem;
}

.cv-wait.hidden { display: none; }

@media (max-width: 900px) {
  body {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .sidebar { max-height: 46vh; }
  .workspace { min-height: 54vh; }
}
