:root {
  --bg: #f7f7f5;
  --panel: #ffffff;
  --ink: #18181b;
  --muted: #71717a;
  --faint: #a1a1aa;
  --line: #e7e5e1;
  --accent: #e4572e;
  --accent-strong: #c2410c;
  --accent-soft: #fdece6;
  --accent-ink: #ffffff;
  --chip: #f1f0ed;
  --hover: #f6f5f2;
  --ok: #15803d;
  --shadow: 0 1px 2px rgba(24, 24, 27, .06), 0 8px 24px rgba(24, 24, 27, .08);
  --bar-h: 56px;
  --filters-h: 124px;
  --tray-h: 60px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111113;
    --panel: #19191c;
    --ink: #f4f4f5;
    --muted: #a1a1aa;
    --faint: #71717a;
    --line: #2a2a2e;
    --accent: #ff7a50;
    --accent-strong: #ff9a76;
    --accent-soft: #3a2117;
    --accent-ink: #18181b;
    --chip: #242428;
    --hover: #212125;
    --ok: #4ade80;
    --shadow: 0 1px 2px rgba(0, 0, 0, .6), 0 8px 24px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Arabic", sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; color: inherit; }
.muted { color: var(--muted); }

/* top bar */
.bar {
  height: var(--bar-h);
  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: 1000;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 750; font-size: 16px; letter-spacing: -.01em; }
.brand svg { width: 22px; height: 22px; fill: var(--accent); }
.tabs { display: flex; gap: 2px; background: var(--chip); padding: 3px; border-radius: 10px; }
.tab { border: 0; background: transparent; color: var(--muted); padding: 6px 12px; border-radius: 8px; font-weight: 600; font-size: 13px; white-space: nowrap; }
.tab[aria-selected="true"] { background: var(--panel); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }

/* filters */
.find { height: calc(100% - var(--bar-h)); display: flex; flex-direction: column; }
.filters {
  padding: 12px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
  display: grid; gap: 10px; position: relative; z-index: 900;
}
.searchbox { position: relative; }
.searchbox svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; fill: var(--faint); }
input, textarea {
  width: 100%; padding: 8px 11px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--ink); font: inherit;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; background: var(--panel); }
.searchbox input { padding: 10px 12px 10px 38px; font-size: 15px; }

.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.combo { position: relative; }
.combo label { display: block; font-size: 11px; font-weight: 650; letter-spacing: .02em; text-transform: uppercase; color: var(--faint); margin: 0 0 3px 2px; }
.combo input { font-size: 13px; padding: 7px 10px; }
.combo.set input { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); font-weight: 650; }
.combo.locked { opacity: .45; }
.combo.locked input { cursor: not-allowed; }
.menu {
  position: absolute; z-index: 1100; left: 0; top: 100%;
  min-width: 100%; width: max-content; max-width: min(320px, 92vw);
  margin: 4px 0 0; padding: 4px; list-style: none; max-height: 320px; overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
  display: none;
}
.combo.open .menu { display: block; }
.menu li { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; padding: 7px 9px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.menu li:hover, .menu li.active { background: var(--hover); }
.menu li .n { color: var(--faint); font-size: 12px; font-variant-numeric: tabular-nums; }
.menu li.clear { color: var(--accent-strong); font-weight: 650; }
.menu .none { color: var(--muted); cursor: default; }

/* list + map */
.split { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(340px, 420px) 1fr; }
.side { overflow: auto; padding: 4px 12px calc(var(--tray-h) + 12px); background: var(--panel); border-right: 1px solid var(--line); }
.map { min-height: 0; background: var(--chip); }
.status { color: var(--muted); font-size: 12px; margin: 10px 4px 4px; min-height: 1.4em; }
.add-all {
  display: flex; align-items: center; gap: 10px; width: 100%; margin: 10px 0 2px; padding: 11px 12px;
  border: 1.5px dashed var(--accent); border-radius: 12px; background: var(--accent-soft); color: var(--ink);
  text-align: left; font-weight: 600; font-size: 13px;
}
.add-all .plus { flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-size: 17px; }
.add-all small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; }
.add-all.added { border-style: solid; }
.add-all.added .plus { background: var(--ink); }
.list li.area span::before { content: "📍 "; }
.results { list-style: none; margin: 0; padding: 0; }
.results li {
  display: flex; gap: 10px; align-items: center;
  padding: 10px 8px; border-radius: 10px; cursor: pointer;
  border: 1px solid transparent;
}
.results li + li { margin-top: 2px; }
.results li:hover, .results li.hot { background: var(--hover); border-color: var(--line); }
.dot { flex: none; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--accent); background: transparent; }
.results li.in .dot { background: var(--accent); }
.place { flex: 1; min-width: 0; }
.place .name { font-weight: 650; font-size: 14px; overflow-wrap: anywhere; }
.place .meta { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.place .meta .cat { color: var(--ink); opacity: .7; }
.add {
  flex: none; width: 32px; height: 32px; border-radius: 50%;
  border: 1.5px solid var(--accent); background: var(--panel); color: var(--accent);
  font-size: 18px; line-height: 1; font-weight: 600; display: grid; place-items: center;
}
.add:hover { background: var(--accent-soft); }
.add.added { background: var(--accent); color: var(--accent-ink); font-size: 14px; }
.more { display: block; margin: 12px auto; border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 7px 18px; font-weight: 600; font-size: 13px; }

/* map pins and popups */
.leaflet-container { font: inherit; background: var(--chip); }
.pop { min-width: 180px; }
.pop b { display: block; font-size: 14px; }
.pop small { display: block; color: #71717a; margin: 2px 0 8px; }
.pop button { border: 0; border-radius: 8px; padding: 6px 12px; background: #e4572e; color: #fff; font-weight: 650; width: 100%; }
.pop button.added { background: #18181b; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .leaflet-tile-pane { filter: brightness(.72) invert(1) contrast(.9) hue-rotate(200deg) saturate(.35); }
}

/* bottom tray */
.tray {
  position: fixed; left: 12px; bottom: 12px; z-index: 1000;
  width: min(396px, calc(100% - 24px));
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
  display: grid; grid-template-columns: 1fr auto; align-items: center;
}
.tray-toggle { display: flex; align-items: center; gap: 8px; min-width: 0; border: 0; background: none; padding: 12px 10px 12px 14px; text-align: left; }
.tray-title { font-weight: 700; white-space: nowrap; }
.count { min-width: 22px; padding: 1px 7px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 700; text-align: center; }
.tray-hint { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.chev { flex: none; width: 16px; height: 16px; fill: none; stroke: var(--muted); stroke-width: 2; margin-left: auto; transition: transform .15s; }
.tray-toggle[aria-expanded="true"] .chev { transform: rotate(180deg); }
.tray-actions { display: flex; gap: 6px; padding-right: 8px; }
.primary { border: 0; border-radius: 10px; padding: 9px 14px; background: var(--accent); color: var(--accent-ink); font-weight: 700; white-space: nowrap; }
.primary:hover:not(:disabled) { background: var(--accent-strong); }
.primary:disabled { opacity: .4; cursor: default; }
.ghost { border: 0; background: none; color: var(--muted); padding: 9px 6px; font-weight: 600; }
.tray-body { grid-column: 1 / -1; border-top: 1px solid var(--line); padding: 4px 14px 12px; }
.list { list-style: none; margin: 0; padding: 0; max-height: 38vh; overflow: auto; }
.list li { display: flex; gap: 8px; align-items: start; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.list li span { flex: 1; min-width: 0; font-weight: 650; overflow-wrap: anywhere; }
.list li small { display: block; color: var(--muted); font-weight: 400; }
.list .x { border: 0; background: none; color: var(--faint); font-size: 18px; line-height: 1; padding: 0 2px; }
.list .x:hover { color: var(--accent); }
.hint { color: var(--muted); font-size: 12px; margin: 10px 0 0; }

/* request tab */
.request-wrap { padding: 32px 16px; }
.request { max-width: 600px; margin: 0 auto; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 24px; }
.request h2 { margin: 0 0 4px; font-size: 22px; letter-spacing: -.01em; }
.request form { display: grid; gap: 8px; margin-top: 14px; }
.request label { font-size: 13px; font-weight: 650; margin-top: 6px; }
.request .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.request .primary { margin-top: 10px; padding: 11px; }
textarea { resize: vertical; min-height: 110px; }
.req { color: var(--accent-strong); font-weight: 500; font-size: 12px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
#r-status.ok { color: var(--ok); }

/* small screens: map on top, list below */
@media (max-width: 900px) {
  .steps { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .find { height: auto; }
  .split { grid-template-columns: 1fr; }
  .map { height: 42vh; order: -1; }
  .side { border-right: 0; overflow: visible; }
}
@media (max-width: 560px) {
  .brand span { display: none; }
  .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tray-hint { display: none; }
  .request .row { grid-template-columns: 1fr; }
}
