:root {
  --bg: #0f172a;
  --bg-soft: #1e293b;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --border: #e2e8f0;
  --radius: 12px;
  --shadow: 0 6px 24px rgba(15, 23, 42, 0.08);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: linear-gradient(135deg, #eff6ff 0%, #e0e7ff 100%);
  color: var(--text);
  min-height: 100vh;
}

/* ---------- Auth screen ---------- */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
}
.auth-card h1 {
  margin: 0 0 .25rem;
  font-size: 1.5rem;
}
.auth-card p.subtitle {
  margin: 0 0 1.5rem;
  color: var(--muted);
  font-size: .9rem;
}

/* ---------- Form ---------- */
.field { margin-bottom: 1rem; }
.field label {
  display: block;
  margin-bottom: .35rem;
  font-size: .85rem;
  font-weight: 600;
  color: #334155;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  padding: .7rem .85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  background: #fff;
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .7rem 1.1rem;
  border: 0;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  font-size: .95rem;
  cursor: pointer;
  transition: background .15s, transform .05s;
}
.btn:hover { background: var(--primary-dark); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.ghost {
  background: #f1f5f9;
  color: var(--text);
}
.btn.ghost:hover { background: #e2e8f0; }
.btn.danger { background: var(--danger); }

.alert {
  padding: .7rem .85rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: .9rem;
  display: none;
}
.alert.show { display: block; }
.alert.error { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.alert.success { background: #f0fdf4; color: var(--success); border: 1px solid #bbf7d0; }

/* ---------- App shell ---------- */
.app-header {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: .9rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}
.app-header .brand {
  font-weight: 700;
  font-size: 1.05rem;
}
.app-header .meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: var(--muted);
  font-size: .9rem;
}
.app-header .clock {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--text);
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.25rem;
  display: grid;
  gap: 1.25rem;
}

.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}
.card h2 {
  margin: 0 0 1rem;
  font-size: 1.05rem;
}

/* ---------- Map ---------- */
.map-search {
  position: relative;
  margin-bottom: .75rem;
}
.map-search input { padding-right: 7rem; }
.map-search .use-loc {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  padding: .4rem .6rem;
  font-size: .8rem;
}
.map-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin-top: 4px;
  max-height: 240px;
  overflow-y: auto;
  z-index: 1000;
  display: none;
}
.map-results.show { display: block; }
.map-results .item {
  padding: .55rem .75rem;
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
  font-size: .9rem;
}
.map-results .item:last-child { border-bottom: 0; }
.map-results .item:hover { background: #f8fafc; }

#map {
  width: 100%;
  height: 320px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.coord-row {
  display: flex;
  gap: 1rem;
  margin-top: .6rem;
  font-size: .85rem;
  color: var(--muted);
  flex-wrap: wrap;
}
.coord-row strong { color: var(--text); font-variant-numeric: tabular-nums; }

.coord-edit { align-items: center; }
.coord-edit label {
  display: inline-flex;
  flex-direction: column;
  font-size: .75rem;
  color: var(--muted);
  gap: 2px;
}
.coord-edit input {
  width: 10rem;
  padding: .4rem .55rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .85rem;
  font-variant-numeric: tabular-nums;
}
.coord-edit input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}

/* ---------- Photo tabs ---------- */
.tabs {
  display: inline-flex;
  background: #f1f5f9;
  border-radius: 8px;
  padding: 3px;
  margin-bottom: .85rem;
}
.tabs button {
  border: 0;
  background: transparent;
  padding: .45rem .9rem;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: .85rem;
  color: var(--muted);
}
.tabs button.active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
}

.photo-pane { display: none; }
.photo-pane.active { display: block; }

#video, #preview, #canvas {
  width: 100%;
  max-width: 360px;
  aspect-ratio: 3 / 4;
  background: #0f172a;
  border-radius: 10px;
  display: block;
  object-fit: cover;
}
#canvas { display: none; }

.photo-controls {
  margin-top: .75rem;
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}

/* ---------- Submit ---------- */
.submit-row {
  display: flex;
  justify-content: flex-end;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  background: #0f172a;
  color: #fff;
  padding: .7rem 1rem;
  border-radius: 8px;
  box-shadow: var(--shadow);
  font-size: .9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 100;
  max-width: 90vw;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(-4px);
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

@media (max-width: 520px) {
  .container { padding: .85rem; }
  .card { padding: 1rem; }
  #map { height: 280px; }
}
