
:root {
  --green: #1b3a2a;
  --green-2: #245c3b;
  --accent: #2e8b57;
  --paper: #efe6cf;
  --ink: #1a1a1a;
  --muted: #5c5c5c;
  --danger: #b42318;
  --warn: #9a6700;
  --ok: #1b7a3d;
  --sheet: #fffdf7;
  --btn: #f4f1e8;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--green); color: var(--ink); }
body { position: fixed; inset: 0; overflow: hidden; }
#app { display: flex; flex-direction: column; height: 100%; height: 100dvh; }
header.app-bar {
  background: var(--green); color: #fff;
  padding: calc(0.45rem + var(--safe-top)) 0.75rem 0.4rem;
  display: flex; align-items: center; gap: 0.5rem; z-index: 500;
}
header.app-bar h1 { font-size: 1.05rem; margin: 0; font-weight: 650; letter-spacing: 0.02em; flex: 1; }
header .sub { font-size: 0.72rem; opacity: 0.85; display: block; font-weight: 400; }
#map { flex: 1; width: 100%; background: var(--paper); }
.leaflet-container { background: var(--paper); font: inherit; }
.plot-armed { cursor: crosshair; }

#crosshair {
  position: absolute; left: 50%; top: 50%; width: 44px; height: 44px;
  margin: -22px 0 0 -22px; pointer-events: none; z-index: 400;
}
#crosshair::before, #crosshair::after {
  content: ""; position: absolute; background: #b42318; opacity: 0.9;
}
#crosshair::before { left: 21px; top: 6px; width: 2px; height: 32px; }
#crosshair::after { left: 6px; top: 21px; width: 32px; height: 2px; }

#gps-chip {
  position: absolute; top: calc(3.6rem + var(--safe-top)); right: 10px;
  background: #fff; border-radius: 999px; padding: 0.25rem 0.6rem;
  font-size: 0.75rem; font-weight: 600; box-shadow: 0 1px 4px rgba(0,0,0,.25);
  z-index: 450;
}
#gps-chip.ok { color: var(--ok); }
#gps-chip.warn { color: var(--warn); }

#btn-place-crosshair {
  position: absolute; left: 50%; bottom: calc(5.2rem + var(--safe-bot));
  transform: translateX(-50%); z-index: 450;
}

nav.toolbar {
  background: var(--green);
  display: flex; justify-content: space-around; align-items: stretch;
  padding: 0.2rem 0.2rem calc(0.25rem + var(--safe-bot));
  z-index: 500;
}
nav.toolbar button {
  flex: 1; background: none; border: 0; color: #fff;
  padding: 0.45rem 0.15rem; font-size: 0.68rem; font-weight: 600;
  min-height: 44px;
}
nav.toolbar button.armed, nav.toolbar button:active { background: var(--green-2); }
nav.toolbar button .ic { display: block; font-size: 1.1rem; line-height: 1.1; }

.sheet-backdrop {
  position: absolute; inset: 0; background: rgba(0,0,0,.35); z-index: 600;
}
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 92%;
  background: var(--sheet); z-index: 700; border-radius: 16px 16px 0 0;
  box-shadow: 0 -8px 24px rgba(0,0,0,.25);
  display: flex; flex-direction: column;
  padding-bottom: var(--safe-bot);
}
.sheet header {
  display: flex; align-items: center; padding: 0.7rem 0.9rem 0.4rem;
  border-bottom: 1px solid #e4dcc8;
}
.sheet header h2 { margin: 0; font-size: 1.05rem; flex: 1; }
.sheet .body { overflow: auto; padding: 0.7rem 0.9rem 1.2rem; -webkit-overflow-scrolling: touch; }

.btn, button.btn {
  appearance: none; border: 1px solid #c9c0a8; background: var(--btn);
  border-radius: 10px; padding: 0.55rem 0.8rem; font: inherit; font-weight: 600;
  min-height: 44px; color: var(--ink);
}
.btn-primary { background: var(--green); color: #fff; border-color: var(--green); }
.btn-primary:disabled { opacity: 0.45; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--danger); }
.btn-mic.listening { background: #b42318; color: #fff; }

.form-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.55rem 0.6rem;
}
.form-grid .span-2 { grid-column: 1 / -1; }
.form-grid label, .file-btn {
  display: flex; flex-direction: column; font-size: 0.72rem; font-weight: 650;
  color: var(--muted); gap: 0.2rem;
}
.form-grid input, .form-grid select, .form-grid textarea, .voice-row input {
  font: inherit; font-size: 1rem; font-weight: 400; color: var(--ink);
  border: 1px solid #c9c0a8; border-radius: 8px; padding: 0.45rem 0.5rem;
  background: #fff; width: 100%; min-height: 40px;
}
.form-grid label.missing { color: var(--danger); }
.form-grid label.missing input,
.form-grid label.missing select,
.pos-row.missing { outline: 2px solid var(--danger); border-radius: 8px; }
.form-actions { display: flex; gap: 0.4rem; margin-top: 0.8rem; flex-wrap: wrap; }
.missing-list { font-size: 0.8rem; color: var(--danger); margin: 0.5rem 0 0; }
.pos-row { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; font-size: 0.85rem; padding: 0.35rem; }
.pos-row .muted { color: var(--muted); margin-left: 0.3rem; }
.voice-row { display: flex; gap: 0.35rem; align-items: stretch; }
.voice-row input { flex: 1; }
.hint, .muted { color: var(--muted); font-size: 0.8rem; }
.photos { display: flex; gap: 0.4rem; overflow-x: auto; }
.photos figure { margin: 0; }
.photos img { height: 88px; border-radius: 8px; display: block; }

.tree-row {
  width: 100%; text-align: left; background: #fff; border: 1px solid #e4dcc8;
  border-radius: 10px; padding: 0.6rem 0.7rem; margin-bottom: 0.4rem;
  display: flex; flex-direction: column; gap: 0.1rem; min-height: 44px;
}
.tree-row.complete { border-left: 4px solid var(--ok); }
.tree-row em { font-style: normal; color: var(--muted); font-size: 0.75rem; }

.overlay-row { display: grid; grid-template-columns: 1fr 120px 3rem; gap: 0.4rem; align-items: center; margin: 0.5rem 0; }
#bg-choices label { display: block; padding: 0.45rem 0; min-height: 44px; }

.tree-pin-wrap { background: none !important; border: 0 !important; }
.tree-pin {
  --c: #5c5c5c;
  background: var(--c); color: #fff; border-radius: 14px 14px 14px 2px;
  transform: rotate(-45deg);
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 4px rgba(0,0,0,.35);
}
.tree-pin span { transform: rotate(45deg); font-size: 9px; font-weight: 700; line-height: 1; }
.tree-pin.existing { opacity: 0.7; background: #fff; color: var(--c); border: 2px solid var(--c); }
.tree-pin.existing span { color: var(--c); }
.tree-pin.draft { box-shadow: 0 0 0 2px #b42318; }
.tree-pin.selected { box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--c); }

#toast {
  position: absolute; left: 50%; bottom: calc(6.2rem + var(--safe-bot));
  transform: translateX(-50%); background: #1a1a1a; color: #fff;
  padding: 0.5rem 0.8rem; border-radius: 10px; font-size: 0.85rem;
  z-index: 800; max-width: 90%; text-align: center;
}

.file-btn { background: var(--btn); border: 1px dashed #c9c0a8; border-radius: 10px; padding: 0.7rem; text-align: center; }
#summary-text { width: 100%; min-height: 10rem; font: inherit; font-size: 1rem; padding: 0.5rem; border-radius: 8px; border: 1px solid #c9c0a8; }

[hidden] { display: none !important; }

.tree-dot {
  --c: #5c5c5c;
  width: 10px; height: 10px; margin: 2px;
  border-radius: 50%; background: #fff; border: 2px solid var(--c);
  box-shadow: 0 0 0 1px rgba(255,255,255,.6);
}
.tree-dot.selected { box-shadow: 0 0 0 3px var(--c); }

.btn-record { background: var(--green); color: #fff; border-color: var(--green); }
.btn-record.recording { background: #b42318; border-color: #b42318; color: #fff; }
.memo-row { display: flex; gap: 0.5rem; align-items: center; }
.memos { display: flex; flex-direction: column; gap: 0.35rem; }
.memo-item { display: flex; gap: 0.4rem; align-items: center; background: #fff; border: 1px solid #e4dcc8; border-radius: 10px; padding: 0.35rem 0.5rem; }
.memo-item audio { flex: 1; height: 36px; max-width: 100%; }
#memo-timer, #sum-memo-timer { font-variant-numeric: tabular-nums; font-weight: 650; color: #b42318; }
