* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  background: #fff; color: #1e293b;
  -webkit-user-select: none; user-select: none;
  display: flex; flex-direction: column; overflow: hidden;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid #f1f5f9; flex: 0 0 auto;
}
.topbar .title { font-size: 17px; font-weight: 800; }
.syncwrap { display: flex; align-items: center; gap: 6px; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: #94a3b8; }
.dot.green { background: #16a34a; } .dot.yellow { background: #eab308; } .dot.red { background: #dc2626; }
.syncwrap .lbl { font-size: 12px; color: #64748b; }
.clock { font-size: 12px; color: #64748b; text-align: right; line-height: 1.2; }
.clock .t { font-size: 15px; font-weight: 600; color: #334155; }

main { flex: 1 1 auto; position: relative; overflow-y: auto; }
.screen { display: none; padding: 18px 18px 110px; min-height: 100%; }
.screen.active { display: block; }
h1 { font-size: 20px; font-weight: 700; text-align: center; margin: 8px 0 18px; }

.digits { display: flex; justify-content: center; gap: 10px; margin-bottom: 10px; }
.digit {
  width: 52px; height: 64px; border: 2px solid #cbd5e1; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; font-size: 30px; font-weight: 800;
}
.digit.active { border-color: #0f172a; }
.err { color: #dc2626; font-weight: 600; min-height: 20px; text-align: center; margin-bottom: 8px; font-size: 14px; }
.warn { color: #92400e; background: #fef3c7; border-radius: 10px; padding: 8px 12px; font-size: 13px; margin: 10px 0; }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 320px; margin: 0 auto; }
.key { border: none; border-radius: 12px; font-size: 24px; font-weight: 700; padding: 18px 0; background: #f1f5f9; }
.key:active { background: #e2e8f0; }
.key.amber { background: #fef3c7; } .key.slate { background: #e2e8f0; font-size: 20px; }

.bigname { font-size: 24px; font-weight: 800; text-align: center; }
.muted { color: #64748b; font-size: 15px; text-align: center; margin: 10px 0 4px; }
.muted b { color: #1e293b; }

label { display: block; font-size: 13px; font-weight: 600; color: #475569; margin: 12px 0 4px; }
select {
  width: 100%; border: 2px solid #cbd5e1; border-radius: 12px;
  padding: 14px; font-size: 17px; background: #fff;
}

#map { width: 100%; height: 230px; border-radius: 14px; background: #e2e8f0; margin: 12px 0; }
.coords { font-family: ui-monospace, monospace; font-size: 14px; color: #334155; text-align: center; }
.locname { text-align: center; font-size: 15px; font-weight: 600; margin-top: 6px; }

.check {
  width: 92px; height: 92px; border-radius: 50%; background: #dcfce7;
  display: flex; align-items: center; justify-content: center; margin: 6px auto 14px;
  font-size: 52px; color: #16a34a;
}
.action { font-size: 18px; color: #334155; text-align: center; margin-top: 6px; }
.savetag { display: block; width: max-content; margin: 14px auto 0; padding: 7px 16px; border-radius: 999px; font-weight: 700; font-size: 13px; }
.savetag.offline { background: #fef3c7; color: #92400e; }
.savetag.synced { background: #dcfce7; color: #166534; }
.pinnote { text-align: center; color: #475569; font-size: 13px; margin-top: 10px; }
.pending { text-align: center; color: #92400e; font-weight: 600; margin-top: 12px; font-size: 13px; }

/* Bottom-anchored, thumb-friendly action bar */
.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, #fff 70%, rgba(255,255,255,0));
  display: flex; flex-direction: column; gap: 10px;
}
.btn { border: none; border-radius: 14px; color: #fff; font-size: 19px; font-weight: 800; padding: 18px 0; width: 100%; }
.btn:active { filter: brightness(0.92); }
.btn.green { background: #16a34a; } .btn.red { background: #dc2626; }
.btn.blue { background: #2563eb; } .btn.dark { background: #0f172a; }
.btn.ghost { background: #e2e8f0; color: #334155; font-size: 15px; padding: 12px 0; font-weight: 700; }
.screen:not(.active) ~ .actionbar { display: none; }
