:root {
  --bg: #0f172a;          /* slate-950 */
  --surface: #1e293b;     /* slate-800 */
  --surface-2: #334155;   /* slate-700 */
  --line: #334155;
  --text: #f1f5f9;        /* slate-100 */
  --muted: #94a3b8;       /* slate-400 */
  --accent: #14b8a6;      /* teal-500 */
  --accent-press: #0d9488;/* teal-600 */
  --danger: #f43f5e;      /* rose-500 */
  --radius: 16px;
  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior-y: none;
}
h1 { font-size: 1.4rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 0 0 .6rem; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[hidden] { display: none !important; }

/* ---------- Login ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px 22px; }
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.brand-mark { font-size: 28px; }
.brand-mark.sm { font-size: 22px; }

/* ---------- App shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: calc(12px + var(--safe-t)) 16px 12px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-title { font-weight: 600; }
.icon-btn { margin-left: auto; background: none; border: 0; color: var(--muted); font-size: 20px; padding: 6px 10px; border-radius: 10px; }
.icon-btn:active { background: var(--surface); }

main { padding: 16px; padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 24px); max-width: 560px; margin: 0 auto; }

/* ---------- Cards / lists ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.section-h { margin: 4px 2px 10px; }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.row { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.row .row-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.row .who { font-weight: 600; }
.row .when { color: var(--muted); font-size: .85rem; white-space: nowrap; }
.row .body { margin-top: 4px; white-space: pre-wrap; word-break: break-word; }
.row.mine { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.empty { color: var(--muted); text-align: center; padding: 28px 12px; }

/* ---------- Forms ---------- */
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 12px; }
input, textarea {
  width: 100%; margin-top: 6px; padding: 12px 14px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--surface-2); border-radius: 12px; font: inherit;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
textarea { resize: vertical; min-height: 64px; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 13px 16px; border: 1px solid var(--surface-2); border-radius: 12px;
  background: var(--surface-2); color: var(--text); font: inherit; font-weight: 600;
  text-decoration: none; cursor: pointer; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #032520; }
.btn.primary:active { background: var(--accent-press); }
.btn.big { padding: 16px; font-size: 1.05rem; }
.btn.link { width: auto; background: none; border: 0; color: var(--danger); font-weight: 500; padding: 4px 6px; }

.error { color: var(--danger); font-size: .85rem; margin: 8px 0 0; min-height: 1em; }
.hint { font-size: .8rem; margin: 10px 2px 0; }

/* ---------- Location ---------- */
.hero-loc .loc-label { font-size: 1.25rem; font-weight: 700; }
.hero-loc .loc-meta { margin-top: 4px; }
.map-wrap { position: relative; margin: 14px 0; }
.map-wrap.picking .map { height: 300px; }
.map { height: 200px; border-radius: 12px; overflow: hidden; background: var(--surface-2); }
.loc-actions { margin-top: 12px; }
.loc-actions .btn { width: 100%; }
.loc-choices { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
/* draggable place-mode pin (Leaflet divIcon) */
.pick-pin-wrap { background: none; border: none; }
.pick-pin { font-size: 32px; line-height: 1; filter: drop-shadow(0 2px 3px rgba(0,0,0,.55)); cursor: grab; }
/* recent-locations log */
.history { margin-top: 16px; }
.history summary { cursor: pointer; color: var(--muted); font-size: .9rem; padding: 8px 2px; list-style: none; }
.history summary::-webkit-details-marker { display: none; }
.history summary::before { content: "▸ "; }
.history[open] summary::before { content: "▾ "; }
.history .list { margin-top: 10px; }
.badge { display: inline-block; font-size: .7rem; font-weight: 700; color: #032520; background: var(--accent); border-radius: 999px; padding: 1px 8px; margin-right: 6px; vertical-align: middle; }
#revert-btn { margin-top: 6px; }

/* ---------- Bottom tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.tabbtn { background: none; border: 0; color: var(--muted); font: inherit; font-size: .72rem;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; }
.tabbtn span { font-size: 21px; line-height: 1; }
.tabbtn.active { color: var(--accent); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px);
  transform: translateX(-50%); z-index: 20;
  background: var(--surface); border: 1px solid var(--line); color: var(--text);
  padding: 12px 18px; border-radius: 999px; box-shadow: 0 8px 30px rgba(0,0,0,.45);
  font-size: .9rem; max-width: 90vw;
}
