/* Emergent Almanac — utility-first, earthy, mobile-first */
:root {
  --bg: #f4f1ea;
  --ink: #1f2a24;
  --ink-dim: #5b6660;
  --accent: #3d6a4a;
  --accent-2: #b8643a;
  --warn: #c43d3d;
  --line: #d4cdbf;
  --card: #ffffff;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.04);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; cursor: pointer; }
input, textarea, select { font: inherit; }
a { color: var(--accent); }

/* Topbar */
#topbar {
  position: sticky; top: 0; z-index: 500;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  background: var(--ink);
  color: #f4f1ea;
  border-bottom: 1px solid #000;
}
#topbar .brand { font-weight: 700; letter-spacing: 0.02em; flex: 0 0 auto; }
#topbar nav { display: flex; gap: 4px; flex: 1; justify-content: center; flex-wrap: wrap; }
#topbar nav button {
  background: transparent;
  color: #f4f1ea;
  border: 1px solid transparent;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 14px;
}
#topbar nav button.active { background: var(--accent); border-color: var(--accent); }
#topbar nav button:hover:not(.active) { border-color: #444; }
#topbar .who { font-size: 12px; color: #b6b2a8; }
#topbar .who a { color: #b6b2a8; margin-left: 6px; text-decoration: none; }

/* Main / tabs */
main { position: absolute; top: 49px; bottom: 0; left: 0; right: 0; }
.tab { display: none; width: 100%; height: 100%; overflow-y: auto; }
.tab.active { display: block; }
.panel-head {
  padding: 16px 18px 8px;
  display: flex; align-items: baseline; gap: 12px;
}
.panel-head h2 { margin: 0; font-size: 18px; }
.panel-head small { color: var(--ink-dim); }

/* Map */
#tab-map { position: relative; }
#map { width: 100%; height: 100%; }
#map-fab {
  position: absolute; bottom: 18px; right: 18px; z-index: 400;
}
#map-fab { display: flex; flex-direction: column; gap: 10px; align-items: flex-end; }
#map-fab button {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent); color: #fff; border: 0;
  font-size: 28px; font-weight: 600;
  box-shadow: var(--shadow);
}
#map-fab button.armed { background: var(--accent-2); }
#map-fab button.secondary {
  background: #fff; color: var(--ink);
  font-size: 22px;
  border: 1px solid var(--line);
}
#map-fab button.secondary.active { background: var(--accent-2); color: #fff; border-color: var(--accent-2); }
#inat-status {
  position: absolute; bottom: 18px; left: 18px; z-index: 400;
  background: rgba(255,255,255,0.95); padding: 6px 12px;
  border-radius: 6px; font-size: 12px; color: var(--ink-dim);
  box-shadow: var(--shadow);
}

.inat-popup img { max-width: 200px; max-height: 150px; border-radius: 4px; display: block; margin-bottom: 6px; }
.inat-popup .sci { font-style: italic; color: var(--ink-dim); font-size: 12px; }
.inat-popup .meta { font-size: 11px; color: var(--ink-dim); margin-top: 4px; }
.inat-popup a { color: var(--accent); }

.leaflet-popup-content { font-size: 13px; min-width: 180px; }
.leaflet-popup-content strong { display: block; margin-bottom: 4px; font-size: 14px; }
.leaflet-popup-content .edit-link {
  display: inline-block; margin-top: 8px;
  background: var(--accent); color: #fff;
  padding: 4px 10px; border-radius: 4px;
  text-decoration: none; font-size: 12px;
}

/* List view */
.list { list-style: none; margin: 0; padding: 0 14px 24px; }
.list li {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 8px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}
.list li .meta { font-size: 12px; color: var(--ink-dim); margin-top: 2px; }
.list li .due { font-weight: 600; color: var(--accent-2); }

.cat-group { padding: 0 14px 24px; }
.cat-group h3 {
  margin: 16px 4px 6px;
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--ink-dim);
}

/* Modals */
.modal {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(31, 42, 36, 0.6);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal.hidden { display: none; }
.modal-body {
  background: var(--card);
  border-radius: 12px;
  padding: 20px;
  width: 100%; max-width: 360px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.modal-body.wide { max-width: 520px; max-height: 90vh; overflow-y: auto; }
.modal-body h2 { margin: 0 0 12px; font-size: 18px; }
.modal-body input, .modal-body select, .modal-body textarea {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 6px;
  margin-bottom: 10px;
  background: #fff;
}
.modal-body label { display: block; font-size: 12px; color: var(--ink-dim); margin-bottom: 4px; }
.modal-body label input,
.modal-body label textarea,
.modal-body label select { margin-top: 4px; }
.modal-body button {
  background: var(--accent); color: #fff; border: 0;
  padding: 10px 16px; border-radius: 6px;
  font-weight: 600;
}
.modal-body button.danger { background: var(--warn); }
.modal-body button.ghost { background: transparent; color: var(--ink); }
.modal-body .error { color: var(--warn); font-size: 13px; margin: 6px 0 0; }
.modal-body fieldset { border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; margin: 12px 0; }
.modal-body fieldset legend { padding: 0 6px; font-size: 12px; color: var(--ink-dim); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }

.schedule-row, .note-row {
  display: flex; gap: 6px; align-items: center;
  margin-bottom: 6px;
}
.schedule-row input, .schedule-row select { margin: 0; flex: 1; }
.schedule-row button.remove,
.note-row button.remove {
  background: transparent; color: var(--warn); border: 0; padding: 4px 8px;
  font-size: 18px; line-height: 1;
}
.note-row {
  background: #f9f7f1; padding: 6px 8px; border-radius: 4px;
  font-size: 13px;
}
.note-row .note-text { flex: 1; }
.note-row .note-meta { font-size: 11px; color: var(--ink-dim); }

.hidden { display: none !important; }
