* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; font-family: -apple-system, "Segoe UI", Roboto, sans-serif; }
#map { position: fixed; inset: 0; top: 48px; }
#topbar {
  position: fixed; top: 0; left: 0; right: 0; height: 48px; z-index: 1000;
  background: #184428; color: #fff; display: flex; align-items: center; gap: 6px;
  padding: 0 8px; box-shadow: 0 1px 4px rgba(0,0,0,.35);
}
#title { font-weight: 600; font-size: 17px; flex: 1; text-align: center; white-space: nowrap; overflow: hidden; }
.hbtn {
  background: rgba(255,255,255,.12); color: #fff; border: 0; border-radius: 8px;
  width: 40px; height: 36px; font-size: 19px; cursor: pointer;
}
.hbtn.wide { width: auto; padding: 0 13px; font-size: 16px; font-weight: 600; }
#recordbar {
  position: fixed; top: 48px; left: 0; right: 0; z-index: 999; background: #7a1f1f; color: #fff;
  display: flex; align-items: center; gap: 12px; padding: 8px 12px; font-size: 15px;
}
#recordbar.hidden, .hidden { display: none !important; }
#rec-stats { font-variant-numeric: tabular-nums; font-weight: 600; }
#follow-wrap { font-size: 14px; }
#btn-stop { margin-left: auto; background: #fff; color: #7a1f1f; border: 0; border-radius: 8px; padding: 7px 12px; font-weight: 700; cursor: pointer; }
#btn-trails-float {
  position: fixed; top: 57px; left: 50%; transform: translateX(-50%); z-index: 997;
  background: #184428; color: #fff; border: 2px solid #fff; border-radius: 999px;
  padding: 10px 20px; font-size: 16px; font-weight: 700; cursor: pointer;
  box-shadow: 0 3px 10px rgba(0,0,0,.45); white-space: nowrap;
}
body.recording #btn-trails-float { display: none; }
#app-version { padding: 8px 12px 12px; color: #999; font-size: 12px; text-align: center; }
.trail-label {
  background: rgba(255,255,255,.85); border: 0; box-shadow: 0 1px 3px rgba(0,0,0,.3);
  color: #184428; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 8px;
}
.trail-label::before { display: none; }
#btn-record {
  position: fixed; right: 12px; bottom: 22px; z-index: 998; background: #c22f2f; color: #fff;
  border: 0; border-radius: 999px; padding: 13px 18px; font-size: 16px; font-weight: 600;
  box-shadow: 0 3px 10px rgba(0,0,0,.4); cursor: pointer;
}
#btn-record.recording { background: #555; }
#panel {
  position: fixed; z-index: 1001; background: #fff; display: flex; flex-direction: column;
  left: 0; right: 0; bottom: 0; height: 62%; border-radius: 14px 14px 0 0;
  box-shadow: 0 -3px 14px rgba(0,0,0,.3); transition: transform .25s ease;
}
#panel.closed { transform: translateY(105%); }
@media (min-width: 760px) {
  #panel { left: 0; right: auto; top: 48px; bottom: 0; width: 350px; height: auto; border-radius: 0; }
  #panel.closed { transform: translateX(-105%); }
}
#panel-tabs { display: flex; align-items: center; gap: 6px; padding: 10px 10px 4px; }
.tab {
  flex: 1; padding: 9px; border: 1px solid #ccc; background: #f2f2f2; border-radius: 8px;
  font-size: 15px; cursor: pointer;
}
.tab.active { background: #184428; color: #fff; border-color: #184428; }
#btn-close-panel { background: none; border: 0; font-size: 26px; line-height: 1; cursor: pointer; padding: 2px 8px; }
#view-trails, #view-mine { overflow-y: auto; padding: 8px 12px 16px; }
#search { width: 100%; padding: 10px; font-size: 16px; border: 1px solid #bbb; border-radius: 8px; margin-bottom: 8px; }
#area-filter { width: 100%; padding: 9px; font-size: 15px; border: 1px solid #bbb; border-radius: 8px; background: #fff; }
#trail-count { color: #555; font-size: 13px; margin: 8px 2px; }
.area-head { font-weight: 700; margin: 14px 0 4px; color: #184428; font-size: 15px; }
.trail-item { padding: 8px 6px; border-bottom: 1px solid #eee; cursor: pointer; font-size: 15px; }
.trail-item:active { background: #eef5ee; }
.trail-item .meta { color: #666; font-size: 13px; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 7px; }
.hint { color: #555; font-size: 13px; }
.my-item { padding: 9px 6px; border-bottom: 1px solid #eee; font-size: 15px; }
.my-item .meta { color: #666; font-size: 13px; display: block; }
.my-item button {
  margin: 6px 6px 2px 0; padding: 6px 10px; border: 1px solid #999; background: #fff;
  border-radius: 7px; font-size: 13px; cursor: pointer;
}
.my-item button.danger { border-color: #b33; color: #b33; }
#toast {
  position: fixed; left: 50%; bottom: 86px; transform: translateX(-50%); z-index: 1200;
  background: rgba(20,20,20,.92); color: #fff; padding: 10px 16px; border-radius: 10px;
  font-size: 14px; max-width: 88%; text-align: center;
}
.leaflet-popup-content { font-size: 14px; line-height: 1.45; }
.leaflet-popup-content b { font-size: 15px; }
.pop-detail {
  margin-top: 7px; background: #184428; color: #fff; border: 0; border-radius: 7px;
  padding: 7px 12px; font-size: 14px; cursor: pointer;
}
#detail {
  position: fixed; inset: 0; z-index: 1100; background: #fff; display: flex; flex-direction: column;
}
#detail-head {
  background: #184428; color: #fff; display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top));
}
#btn-detail-back {
  background: rgba(255,255,255,.14); color: #fff; border: 0; border-radius: 8px;
  padding: 8px 12px; font-size: 15px; cursor: pointer; white-space: nowrap;
}
#detail-title { font-weight: 600; font-size: 16px; overflow: hidden; text-overflow: ellipsis; }
#detail-body { overflow-y: auto; padding: 14px 16px 30px; font-size: 15px; line-height: 1.5; }
#detail-body h3 { margin: 18px 0 6px; color: #184428; font-size: 15px; text-transform: uppercase; letter-spacing: .04em; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.stat { background: #f2f6f2; border: 1px solid #dde7dd; border-radius: 10px; padding: 9px 11px; }
.stat .k { font-size: 12px; color: #557; text-transform: uppercase; letter-spacing: .03em; }
.stat .v { font-size: 17px; font-weight: 700; margin-top: 2px; }
.stat .s { font-size: 12px; color: #666; }
.dbtn {
  display: inline-block; margin: 6px 8px 2px 0; padding: 9px 13px; border-radius: 8px;
  background: #184428; color: #fff; border: 0; font-size: 14px; cursor: pointer; text-decoration: none;
}
.dbtn.secondary { background: #fff; color: #184428; border: 1px solid #184428; }
#detail-notes {
  width: 100%; min-height: 84px; font-size: 15px; padding: 9px; border: 1px solid #bbb;
  border-radius: 8px; font-family: inherit;
}
#notes-saved { color: #2e7d32; font-size: 12px; height: 15px; }
.photo-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.photo-cell { position: relative; width: 104px; height: 104px; }
.photo-cell img { width: 104px; height: 104px; object-fit: cover; border-radius: 9px; display: block; }
.photo-del {
  position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%;
  border: 0; background: rgba(0,0,0,.65); color: #fff; font-size: 14px; cursor: pointer; line-height: 1;
}
.fineprint { color: #777; font-size: 12px; margin-top: 4px; }
.club-block {
  background: #f7faf7; border: 1px solid #dde7dd; border-radius: 10px;
  padding: 10px 12px; margin: 8px 0; font-size: 14px;
}
.club-block .club-src { font-weight: 700; color: #184428; margin-bottom: 4px; font-size: 15px; }
.club-block div { margin: 2px 0; }
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.tag-chip {
  background: #e3efe3; color: #184428; border: 1px solid #b9d2b9; border-radius: 999px;
  padding: 4px 6px 4px 11px; font-size: 13px; display: inline-flex; align-items: center; gap: 5px;
}
.tag-chip button {
  border: 0; background: rgba(0,0,0,.12); color: #184428; width: 18px; height: 18px;
  border-radius: 50%; font-size: 12px; cursor: pointer; line-height: 1; padding: 0;
}
.tag-chip.suggest { background: #fff; border-style: dashed; cursor: pointer; padding-right: 11px; }
.tag-add { display: flex; gap: 6px; margin-top: 6px; }
.tag-add input {
  flex: 1; padding: 9px; font-size: 15px; border: 1px solid #bbb; border-radius: 8px;
}
.tag-add button {
  background: #184428; color: #fff; border: 0; border-radius: 8px; padding: 0 14px;
  font-size: 14px; cursor: pointer;
}
.mini-tags { margin-top: 3px; }
.mini-tags .tag-chip { padding: 1px 8px; font-size: 11px; }
