* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; font: 16px/1.35 system-ui, sans-serif; color: #1d2733; }
#map { position: fixed; inset: 0; }

#controls {
  position: fixed; right: 12px; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 1000;
  display: flex; flex-direction: column; gap: 8px;
}
body.sheet-open #controls { bottom: calc(var(--sheet-h, 0px) + 12px); }
.fab {
  width: 52px; height: 52px; border-radius: 50%; border: 0;
  background: #fff; color: #1a73e8; box-shadow: 0 2px 8px #0004;
  display: grid; place-items: center; cursor: pointer;
}
.fab.active { background: #1a73e8; color: #fff; }
#quick {
  font: 700 14px system-ui, sans-serif; color: #fff; touch-action: manipulation; user-select: none; -webkit-user-select: none;
  background: linear-gradient(90deg, #d62828 0 40%, #1f9d55 60%);
}
#quick.active { outline: 3px solid #ff9800; outline-offset: 2px; }
#quick:active { filter: brightness(0.85); }

#status {
  position: fixed; left: 8px; bottom: calc(8px + env(safe-area-inset-bottom)); z-index: 1000;
  font-size: 12px; background: #fffc; padding: 2px 6px; border-radius: 4px; pointer-events: none;
}
#hint {
  position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 1000;
  background: #1d2733e0; color: #fff; padding: 6px 12px; border-radius: 16px; font-size: 14px;
  pointer-events: none;
}
#pick {
  position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 1000;
  background: #ff9800; color: #1d2733; font-weight: 600; font-size: 14px; border-radius: 16px;
  padding: 4px 4px 4px 14px; display: flex; align-items: center; gap: 8px; box-shadow: 0 2px 8px #0004;
  max-width: 94vw;
}
#pick-cancel { border: 0; background: none; font-size: 22px; line-height: 1; padding: 2px 8px; cursor: pointer; color: inherit; }

#sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1001;
  max-height: 45vh; overflow-y: auto;
  background: #fff; border-radius: 14px 14px 0 0; box-shadow: 0 -2px 12px #0003;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  max-width: 560px; margin: 0 auto;
}
#sheet header { display: flex; align-items: center; gap: 10px; }
#sheet .titles { flex: 1; min-width: 0; }
#sheet-title { font-weight: 600; font-size: 17px; }
#sheet-sub { font-size: 12px; color: #667; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#sheet-sub a { color: inherit; }
#sheet-close { border: 0; background: none; font-size: 28px; line-height: 1; cursor: pointer; color: #667; }
.arrow { display: inline-block; font-size: 24px; font-weight: 700; color: #ff9800; }

.actions { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin: 10px 0; }
.rec {
  border: 0; border-radius: 10px; font-weight: 700; color: #fff;
  cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
.rec.r2g { padding: 20px 8px; font-size: 18px; background: linear-gradient(90deg, #d62828 0 40%, #1f9d55 60%); }
.rec.g2r { padding: 8px 12px; font-size: 13px; background: linear-gradient(90deg, #1f9d55 0 40%, #d62828 60%); opacity: 0.8; }
.rec:active { filter: brightness(0.85); }

#events { list-style: none; margin: 0; padding: 0; font-size: 14px; font-variant-numeric: tabular-nums; }
#events li { display: flex; gap: 10px; padding: 4px 0; border-top: 1px solid #eee; }
#events .k { width: 4.5em; font-weight: 600; }
#events .k.r2g { color: #1f9d55; }
#events .k.g2r { color: #d62828; }
#events .d { margin-left: auto; color: #667; }
#events .pending { color: #999; font-style: italic; }
#events .empty { color: #999; border: 0; }

dialog { border: 0; border-radius: 12px; padding: 16px; box-shadow: 0 4px 24px #0005; max-width: 90vw; }
dialog::backdrop { background: #0006; }
dialog p { margin: 0 0 16px; font-size: 17px; }
.dialog-buttons { display: flex; justify-content: flex-end; gap: 10px; }
.dialog-buttons button { padding: 12px 20px; font-size: 16px; border-radius: 8px; border: 1px solid #ccd; background: #fff; }
.dialog-buttons .primary { background: #1a73e8; color: #fff; border-color: #1a73e8; }

#toast {
  position: fixed; left: 50%; top: 12px; transform: translateX(-50%); z-index: 1002;
  background: #1d2733; color: #fff; border-radius: 8px; padding: 8px 8px 8px 14px;
  display: flex; align-items: center; gap: 12px; box-shadow: 0 2px 8px #0005; max-width: 94vw;
}
#toast-undo { background: none; border: 0; color: #8ab4f8; font-weight: 700; font-size: 15px; padding: 6px 8px; cursor: pointer; }
