:root {
  color-scheme: light;
  --bg: #eef2ee;
  --panel: #ffffff;
  --soft: #f4f7f3;
  --text: #15211a;
  --muted: #69766d;
  --line: #e2e8e1;
  --brand: #1f6b45;
  --brand-2: #2e8a59;
  --brand-soft: #e2f2e8;
  --blue: #2563eb;
  --blue-soft: #e4edfe;
  --red: #c0392b;
  --red-soft: #fce6e3;
  --amber: #a86412;
  --amber-soft: #fcf0dc;
  --purple: #6d3fd8;
  --purple-soft: #efe8fd;
  --teal: #0f766e;
  --teal-soft: #dcf4f1;
  --route: #e8590c;
  --radius: 14px;
  --shadow: 0 8px 28px rgba(18, 38, 26, .14);
  --header-h: 56px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

body {
  font-family: Manrope, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- Шапка ---------- */
.topbar {
  height: var(--header-h);
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 1100;
}
.brand { display: flex; align-items: center; gap: 8px; }
.logo {
  width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center; font-size: 19px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
}
.name { font-weight: 800; font-size: 19px; letter-spacing: -.02em; }
.badge {
  font-size: 11px; font-weight: 700; color: var(--amber);
  background: var(--amber-soft); padding: 2px 8px; border-radius: 999px;
}
.user {
  display: flex; align-items: center; gap: 6px; margin: 0;
  background: var(--soft); border-radius: 999px; padding: 4px 10px 4px 4px; cursor: pointer;
}
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
  background: var(--brand); color: #fff;
}
.user select {
  border: 0; background: transparent; padding: 0; width: auto; max-width: 140px;
  font-weight: 600; cursor: pointer;
}
.user select:focus { outline: none; }

/* ---------- Розкладка ---------- */
/* clip, а не hidden: hidden дозволяє браузеру програмно прокрутити розкладку (фокус, scrollIntoView),
   і тоді висувна панель «з'їжджає» разом із картою. */
.layout { flex: 1; position: relative; min-height: 0; display: flex; overflow: hidden; overflow: clip; }
.mapwrap { position: relative; flex: 1; min-width: 0; order: 2; }
#map { position: absolute; inset: 0; background: #dfe6dc; }

.sidebar {
  order: 1;
  width: 420px;
  flex: none;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--line);
  z-index: 1000;
}
.sheet-grab { display: none; }
.sheet-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; }

.mode-hint {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  z-index: 1000; background: var(--text); color: #fff; font-weight: 600;
  padding: 8px 14px; border-radius: 999px; font-size: 13px; pointer-events: none;
  box-shadow: var(--shadow); white-space: nowrap; max-width: calc(100% - 24px);
  overflow: hidden; text-overflow: ellipsis;
}
.hidden { display: none !important; }

/* ---------- Блоки ---------- */
.section { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.section:last-child { border-bottom: 0; }
.section h2 { font-size: 21px; line-height: 1.25; margin: 6px 0 4px; letter-spacing: -.02em; }
.section h3 {
  font-size: 12px; margin: 0 0 10px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
}
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.error { color: var(--red); }
p { margin: 8px 0; }

input, select, textarea {
  font: inherit; width: 100%; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand-2); }
textarea { resize: vertical; min-height: 70px; }
label { display: block; margin-bottom: 10px; font-weight: 600; font-size: 13px; }
label > input, label > select, label > textarea { margin-top: 4px; font-weight: 400; font-size: 14px; }
label.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
label.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--brand); }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }

.btn {
  font: inherit; font-weight: 700; cursor: pointer; padding: 9px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: #fff; color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:hover { background: var(--soft); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #185a3a; }
.btn.danger { color: var(--red); border-color: #f1cfca; }
.btn.ghost { border-color: transparent; background: transparent; padding-left: 0; color: var(--brand); }
.btn.active { background: var(--text); color: #fff; border-color: var(--text); }
.btn.small { padding: 6px 10px; font-size: 12.5px; border-radius: 8px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .45; cursor: default; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

/* ---------- Пошук і фільтри ---------- */
.search { position: relative; }
.search span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); opacity: .6; }
.search input { padding: 12px 12px 12px 38px; border-radius: 12px; background: var(--soft); border-color: transparent; font-size: 15px; }

.chips {
  display: flex; gap: 8px; overflow-x: auto; margin: 12px -16px 4px; padding: 0 16px 4px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; font: inherit; font-weight: 600; font-size: 13px; cursor: pointer;
  padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--text);
}
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }

details.more { margin: 8px 0 12px; }
details.more summary { cursor: pointer; font-weight: 700; color: var(--brand); font-size: 13px; padding: 4px 0; }
details.more[open] summary { margin-bottom: 10px; }

/* ---------- Картки поїздок ---------- */
.list-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.list-head h3 { margin: 0; }
.card {
  display: flex; gap: 12px; padding: 12px; margin-bottom: 10px; cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--radius); background: #fff;
  transition: box-shadow .15s, border-color .15s;
}
.card:hover { border-color: #c9d6cc; box-shadow: 0 4px 16px rgba(18, 38, 26, .08); }
.card-icon {
  flex: none; width: 46px; height: 46px; border-radius: 12px;
  display: grid; place-items: center; font-size: 22px;
}
.card-main { min-width: 0; flex: 1; }
.card .title { font-weight: 800; font-size: 15px; line-height: 1.3; }
.card .meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.cat-mountains { background: var(--brand-soft); }
.cat-castles { background: var(--amber-soft); }
.cat-water { background: var(--blue-soft); }
.cat-city { background: var(--purple-soft); }
.cat-nature { background: var(--teal-soft); }

.tags { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 8px; }
.tag { font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--soft); color: var(--text); }
.tag.green { background: var(--brand-soft); color: var(--brand); }
.tag.blue { background: var(--blue-soft); color: #1d4ed8; }
.tag.red { background: var(--red-soft); color: var(--red); }

/* ---------- Деталі ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 12px 0 8px; }
.stat { background: var(--soft); border-radius: 12px; padding: 8px 6px; text-align: center; }
.stat b { display: block; font-size: 15px; font-weight: 800; }
.stat span { font-size: 11px; color: var(--muted); }

.profile { width: 100%; height: 130px; display: block; margin-top: 6px; background: var(--soft); border-radius: 12px; }

.item { border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 8px; }
.item .row { align-items: center; }
.item label { margin-bottom: 6px; }
.list-plain { margin: 0; padding-left: 20px; }
.list-plain li { margin-bottom: 4px; }

.member { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.member:last-child { border-bottom: 0; }

.chat { max-height: 260px; overflow-y: auto; border-radius: 12px; padding: 10px; margin-bottom: 8px; background: var(--soft); }
.msg { margin-bottom: 8px; background: #fff; border-radius: 10px; padding: 6px 10px; }
.msg .who { font-weight: 700; font-size: 12.5px; }
.msg .when { font-size: 11px; color: var(--muted); margin-left: 6px; }

.note {
  margin: 14px 16px 18px; padding: 12px; border-radius: 12px;
  background: var(--amber-soft); color: #6b4a12; font-size: 12.5px;
}

/* ---------- Мітки на карті ---------- */
.pin { font-size: 22px; line-height: 22px; text-align: center; filter: drop-shadow(0 1px 2px rgba(0,0,0,.45)); }
.wp { width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 3px solid var(--route); box-shadow: 0 1px 3px rgba(0,0,0,.35); }
.wp.first { border-color: var(--brand); }
.leaflet-container { font-family: inherit; }
.leaflet-popup-content-wrapper { border-radius: 12px; }

/* ---------- Телефон: карта на весь екран, панель знизу ---------- */
@media (max-width: 760px) {
  .topbar { padding: 0 12px; }
  .mapwrap { position: absolute; inset: 0; }
  .sidebar {
    position: absolute; left: 0; right: 0; top: 0; height: 100%; width: auto;
    border-right: 0; border-radius: 20px 20px 0 0;
    box-shadow: 0 -6px 28px rgba(18, 38, 26, .18);
    will-change: transform;
  }
  .sheet-grab {
    display: flex; justify-content: center; align-items: center; flex: none;
    height: 26px; cursor: grab; touch-action: none;
  }
  .sheet-grab span { width: 44px; height: 5px; border-radius: 999px; background: #cfd7d0; }
  .section { padding: 12px 16px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .mapwrap .leaflet-bottom { bottom: var(--sheet-covered, 0px); }
  .leaflet-control-attribution { font-size: 9px; line-height: 1.3; max-width: 100vw; }
  .leaflet-control-scale { display: none; }
  .name { font-size: 18px; }
}
