* { box-sizing: border-box; }
:root {
  --bg: #f4f1ec;
  --paper: #fff;
  --ink: #2b2a26;
  --muted: #6b6a64;
  --line: #e2dcd1;
  --accent: #c0532b;
  --accent-soft: #f3d6c8;
  --planned: #c0532b;
  --actual: #2563a6;
  --photo: #4a7a3a;
  --danger: #b53a3a;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 6px 24px rgba(0,0,0,.05);
}
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; background: var(--paper); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 100;
}
.brand a { color: var(--ink); font-weight: 700; letter-spacing: .2px; font-size: 17px; }
.nav { display: flex; gap: 16px; align-items: center; }
.nav .user { color: var(--muted); font-size: 13px; }
.nav .lang select { font: inherit; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.inline { display: inline; margin: 0; }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; font: inherit; }

main { min-height: calc(100vh - 56px); }
.container { max-width: 880px; margin: 24px auto; padding: 0 16px; }
.row { display: flex; gap: 12px; align-items: center; }
.row.spread { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: 10px;
  padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.card h1, .card h2, .card h3 { margin: 0 0 10px; }
.card.empty { text-align: center; color: var(--muted); padding: 40px; }
.flash { background: var(--accent-soft); border: 1px solid var(--accent); padding: 10px 14px; border-radius: 8px; margin: 12px 16px; }
.error { background: #f8d7d7; border: 1px solid #b53a3a; color: #6b1a1a; padding: 10px; border-radius: 8px; margin-bottom: 10px; }

.grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.grid.small { grid-template-columns: 1fr 1fr; }
.grid label, .grid .full { display: flex; flex-direction: column; gap: 4px; }
.grid .full { grid-column: 1 / -1; }
label input, label textarea, label select, input, textarea {
  font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink);
}
label input:focus, label textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

.btn { background: #ece8e0; color: var(--ink); border: 1px solid var(--line); padding: 8px 14px; border-radius: 8px; cursor: pointer; font: inherit; }
.btn:hover { background: #e2dcd1; }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { background: #a64321; }
.btn.danger { background: #fff; color: var(--danger); border-color: #e9c5c5; }
.btn.danger:hover { background: #f8e7e7; }
.btn.small { padding: 5px 10px; font-size: 13px; }

.auth-wrap { display: grid; place-items: center; min-height: calc(100vh - 56px); padding: 20px; }
.card.auth { width: 100%; max-width: 400px; }
.card.auth form { display: flex; flex-direction: column; gap: 12px; }

.trip-list { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.trip-card { display: block; padding: 16px; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; color: var(--ink); box-shadow: var(--shadow); }
.trip-card:hover { transform: translateY(-1px); transition: transform .1s; text-decoration: none; }
.trip-card h3 { margin: 0 0 6px; }
.trip-card .meta { color: var(--muted); font-size: 13px; margin: 8px 0 0; }

.trip-page { display: grid; grid-template-columns: 360px 1fr; height: calc(100vh - 56px); }
.sidebar { padding: 16px; overflow-y: auto; background: var(--bg); border-right: 1px solid var(--line); }
.sidebar .card { margin-bottom: 12px; padding: 12px; }
.sidebar .back { margin-bottom: 12px; }
.map-wrap { position: relative; }
#map { position: absolute; inset: 0; }
.btn.fit { position: absolute; top: 12px; right: 12px; z-index: 1000; box-shadow: var(--shadow); }

.fab-camera {
  position: absolute; right: 18px; bottom: 24px; z-index: 1000;
  width: 60px; height: 60px; border-radius: 50%;
  background: var(--photo, #c0532b); color: #fff; border: 0; cursor: pointer;
  display: grid; place-items: center;
  box-shadow: 0 4px 12px rgba(0,0,0,.3);
  transition: transform .12s ease, background .12s ease;
}
.fab-camera:hover { transform: scale(1.05); }
.fab-camera:active { transform: scale(.95); }
.fab-camera:disabled { opacity: .6; cursor: progress; }
.fab-status {
  position: absolute; right: 18px; bottom: 92px; z-index: 1000;
  background: rgba(0,0,0,.78); color: #fff; padding: 6px 12px; border-radius: 16px;
  font-size: 12px; box-shadow: var(--shadow);
}

.caption-prompt {
  position: absolute; right: 18px; bottom: 96px; z-index: 1001;
  background: var(--paper); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,.18);
  padding: 10px; display: flex; gap: 10px; align-items: stretch;
  width: 320px; max-width: calc(100% - 36px);
  animation: caption-pop .15s ease-out;
}
@keyframes caption-pop { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.caption-prompt-thumb { margin: 0; width: 64px; height: 64px; border-radius: 8px; overflow: hidden; flex-shrink: 0; background: #ddd; }
.caption-prompt-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.caption-prompt-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.caption-prompt-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.caption-prompt-input { width: 100%; padding: 6px 8px; font-size: 14px; }
.caption-prompt-actions { display: flex; gap: 6px; justify-content: flex-end; }

@media (max-width: 800px) {
  .caption-prompt { right: 12px; left: 12px; width: auto; bottom: 86px; }
}

.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.list li { display: flex; gap: 8px; align-items: center; padding: 6px 8px; background: #faf7f1; border: 1px solid var(--line); border-radius: 6px; }
.list .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .num { width: 22px; height: 22px; display: grid; place-items: center; background: var(--planned); color: #fff; border-radius: 50%; font-size: 12px; font-weight: 600; }
.list button.del { color: var(--danger); background: none; border: 0; cursor: pointer; font-size: 16px; line-height: 1; }
.list .drag-handle { cursor: grab; color: var(--muted); font-size: 14px; user-select: none; padding: 0 2px; letter-spacing: -2px; }
.list li[draggable="true"] { transition: background .1s; }
.list li.dragging { opacity: .55; cursor: grabbing; }
.list li.dragging .drag-handle { cursor: grabbing; }

.place-search { display: flex; gap: 6px; margin-bottom: 6px; }
.place-search input { flex: 1; min-width: 0; padding: 6px 8px; font-size: 13px; }
.place-search-results { list-style: none; margin: 0 0 8px; padding: 0; max-height: 260px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); }
.place-search-item { padding: 8px 10px; cursor: pointer; border-bottom: 1px solid var(--line); }
.place-search-item:last-child { border-bottom: 0; }
.place-search-item:hover { background: #faf3ec; }
.place-search-name { font-weight: 600; font-size: 13px; }
.place-search-meta { font-size: 11px; line-height: 1.3; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.place-search-status { padding: 8px 10px; }

.place-popup .leaflet-popup-content { margin: 10px 12px; }
.place-picker { display: flex; flex-direction: column; gap: 6px; min-width: 220px; }
.place-picker-label { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
.place-picker .place-name { width: 100%; padding: 6px 8px; font-size: 14px; }
.place-picker-actions { display: flex; gap: 6px; justify-content: flex-end; }

.live-qr-wrap { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-top: 12px; padding: 10px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.live-qr-wrap canvas,
.live-qr-wrap #live-qr svg { width: 200px; height: 200px; max-width: 100%; display: block; }
.live-qr-wrap p { margin: 0; text-align: center; }

.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 8px; }
.photo-grid figure { margin: 0; position: relative; aspect-ratio: 1; overflow: hidden; border-radius: 6px; cursor: pointer; background: #ddd; }
.photo-grid img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-grid .badge { position: absolute; bottom: 4px; left: 4px; background: rgba(0,0,0,.6); color: #fff; padding: 1px 5px; border-radius: 4px; font-size: 10px; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; padding: 8px 4px; font-size: 12px; color: var(--muted); }
.legend .dot { display: inline-block; width: 12px; height: 4px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.legend .dot.planned { background: var(--planned); }
.legend .dot.actual { background: var(--actual); }
.legend .dot.photo { background: var(--photo); border-radius: 50%; height: 10px; width: 10px; }

.popup-img { max-width: 240px; max-height: 240px; display: block; margin-bottom: 6px; border-radius: 4px; }
.popup-meta { font-size: 12px; color: var(--muted); }

.leaflet-marker-icon.photo-marker {
  background: var(--photo);
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,.4);
  width: 14px !important; height: 14px !important;
  margin-left: -7px !important; margin-top: -7px !important;
}
.leaflet-div-icon.wp-marker {
  background: var(--planned);
  color: #fff; font-weight: 700; font-size: 12px;
  border: 2px solid #fff; border-radius: 50%;
  width: 26px !important; height: 26px !important;
  display: grid; place-items: center;
  margin-left: -13px !important; margin-top: -13px !important;
  box-shadow: 0 1px 3px rgba(0,0,0,.4);
}

@media (max-width: 800px) {
  .trip-page { grid-template-columns: 1fr; height: auto; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); max-height: 50vh; }
  .map-wrap { height: 60vh; position: relative; }
  .grid, .grid.small { grid-template-columns: 1fr; }
}
