:root {
  --bg: #161616;
  --panel: #1f1f1f;
  --panel-2: #282828;
  --line: #343434;
  --text: #f3f3f1;
  --muted: #a9a9a4;
  --accent: #ffc800;
  --booth: #ffd66b;
  --visited: #2ebd6b;
  --star: #4c8dff;
  --selected: #ff6b35;
  --danger: #ff6b6b;
  --radius: 12px;
  --side-w: 380px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: max(10px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) 10px max(18px, env(safe-area-inset-left));
  background: #1c1c1c;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand h1 { margin: 0; font-size: 16px; font-weight: 800; letter-spacing: -0.01em; white-space: nowrap; }
.brand p { margin: 0; color: var(--muted); font-size: 12px; }
.sub-short { display: none; }

.progress { margin-left: auto; text-align: right; }
.progress-text { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.progress-text strong { color: var(--text); }

.account { display: flex; align-items: center; gap: 8px; }
.share-btn { display: inline-flex; align-items: center; gap: 7px; }

/* Share window */
.modal { max-height: calc(100dvh - 24px); overflow: auto; }
.share-modal { width: min(400px, calc(100vw - 32px)); }
.share-modal h2 { margin-bottom: 4px; }
.share-modal .muted { margin: 0; font-size: 13.5px; }
.share-qr {
  display: block; width: 200px; height: 200px; margin: 16px auto 14px;
  border-radius: 12px; background: #fff;
}
.share-url { display: flex; gap: 8px; }
.share-url input {
  flex: 1; min-width: 0; padding: 9px 10px; border-radius: 9px;
  background: #121212; border: 1px solid #3a3a3a; color: var(--text); font-size: 13px;
}
.share-targets { display: grid; grid-template-columns: repeat(auto-fit, minmax(76px, 1fr)); gap: 8px; margin-top: 12px; }
.share-target {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 72px; padding: 10px 6px; border-radius: 11px;
  background: #262626; border: 1px solid #343434; color: var(--text);
  font: 600 12.5px var(--font); text-decoration: none;
}
.share-target:hover { background: #2f2f2f; border-color: #454545; }
.st-icon { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--c); }
.sync { font-size: 12px; color: var(--muted); white-space: nowrap; }
.sync.ok::before, .sync.busy::before, .sync.err::before {
  content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; vertical-align: 1px;
}
.sync.ok::before { background: var(--visited); }
.sync.busy::before { background: var(--accent); }
.sync.err::before { background: var(--danger); }

.btn {
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 9px;
  padding: 8px 14px;
  font-weight: 600;
  white-space: nowrap;
}
.btn:hover { border-color: #4a4a4a; background: #303030; }
.btn.primary { background: var(--accent); color: #1a1a1a; border-color: var(--accent); }
.btn.primary:hover { background: #ffd43a; }
.btn.primary:disabled { opacity: .6; cursor: wait; }
.btn.ghost { background: transparent; }
.btn.danger { background: #d64545; border-color: #d64545; color: #fff; }
.btn.danger:hover { background: #e05555; }
.btn.danger:disabled { opacity: .6; cursor: wait; }
.danger-link { color: #ff9a9a; margin-top: 4px; }
.danger-link:hover { color: #ffbcbc; }
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 20;
  max-width: calc(100% - 32px); padding: 11px 16px; border-radius: 10px;
  background: #262626; border: 1px solid #3c3c3c; color: var(--text); font-size: 13.5px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .45);
}
.btn.small { padding: 6px 10px; font-size: 12.5px; }

/* ---------- layout ---------- */
.layout { flex: 1 1 auto; display: flex; min-height: 0; }
.map-pane { position: relative; flex: 1 1 auto; min-width: 0; overflow: hidden; }
.map { position: absolute; inset: 0; }
.map canvas { display: block; width: 100%; height: 100%; touch-action: none; outline: none; }

.sidebar {
  flex: 0 0 var(--side-w);
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
  border-left: 1px solid var(--line);
}

/* ---------- map overlays ---------- */
.map-tools {
  position: absolute; top: 14px; left: 14px;
  display: flex; gap: 8px; align-items: center;
}
.seg {
  display: flex; padding: 3px; border-radius: 10px;
  background: rgba(28, 28, 28, .88); border: 1px solid var(--line);
  backdrop-filter: blur(8px);
}
.seg button {
  border: 0; background: transparent; padding: 6px 12px; border-radius: 7px; font-weight: 700; color: var(--muted);
}
.seg button.active { background: var(--accent); color: #1a1a1a; }
.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center;
  border-radius: 10px; border: 1px solid var(--line);
  background: rgba(28, 28, 28, .88); backdrop-filter: blur(8px);
  font-size: 19px; font-weight: 600; line-height: 1;
}
.icon-btn:hover, .seg button:not(.active):hover { color: var(--text); background: #333; }

.legend {
  position: absolute; right: 14px; bottom: 14px;
  display: flex; gap: 12px; flex-wrap: wrap;
  padding: 8px 12px; border-radius: 10px;
  background: rgba(28, 28, 28, .88); border: 1px solid var(--line); backdrop-filter: blur(8px);
  font-size: 12px; color: var(--muted);
}
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 11px; height: 11px; border-radius: 3px; background: var(--c); display: inline-block; }

.tooltip {
  position: absolute; pointer-events: none; z-index: 5;
  transform: translate(14px, 14px);
  max-width: 260px;
  padding: 7px 10px; border-radius: 8px;
  background: rgba(16, 16, 16, .94); border: 1px solid #3c3c3c;
  font-size: 12.5px; box-shadow: 0 6px 20px rgba(0, 0, 0, .35);
}
.tooltip b { display: block; font-size: 13px; }
.tooltip span { color: var(--muted); }

.name-tag {
  position: absolute; z-index: 4; pointer-events: none;
  transform: translate(-50%, -100%);
  padding: 5px 10px; border-radius: 99px;
  background: var(--selected); color: #fff; font-weight: 700; font-size: 13px;
  white-space: nowrap; box-shadow: 0 6px 18px rgba(0, 0, 0, .35);
}

.detail {
  position: absolute; left: 14px; bottom: 14px; z-index: 6;
  width: min(400px, calc(100% - 28px));
  max-height: calc(100% - 78px);
  overflow: auto;
  padding: 16px 16px 14px;
  border-radius: var(--radius);
  background: rgba(24, 24, 24, .97);
  border: 1px solid #3a3a3a;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .45);
}
.detail .close, .modal .close {
  position: absolute; top: 8px; right: 8px;
  width: 32px; height: 32px; border-radius: 8px; border: 0;
  background: transparent; color: var(--muted); font-size: 22px; line-height: 1;
}
.detail .close:hover, .modal .close:hover { background: #333; color: var(--text); }
.detail-head h2 { margin: 6px 36px 6px 0; font-size: 19px; line-height: 1.25; letter-spacing: -0.01em; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; padding-right: 30px; }
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600;
  background: #303030; color: var(--muted);
}
.tag.booth { background: rgba(255, 200, 0, .15); color: var(--accent); }
.tag.warn { background: rgba(255, 255, 255, .06); color: #c9c9c4; }
.detail-desc { margin: 4px 0 10px; color: #dcdcd8; }
.detail-desc.muted { color: var(--muted); font-style: italic; }
.detail-links { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.detail-links a { color: var(--accent); font-weight: 600; text-decoration: none; }
.detail-links a:hover { text-decoration: underline; }
.detail-actions { display: flex; gap: 8px; margin-bottom: 10px; }
/* A small secondary chip: starring is a side feature, not the card's main action. */
.toggle {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px 5px 10px; border-radius: 99px; font-size: 13px; font-weight: 600;
  border: 1px solid #3a3a3a; background: transparent; color: var(--muted); cursor: pointer;
}
.toggle:hover { color: var(--text); border-color: #555; }
.toggle.star[aria-pressed="true"] { color: #b9d2ff; border-color: rgba(76, 141, 255, .45); background: rgba(76, 141, 255, .12); }
.toggle.star[aria-pressed="true"] svg { color: var(--star); }
.name-tag .tag-star { margin-right: 4px; }
.notes-label { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
textarea, .modal input {
  width: 100%; resize: vertical; min-height: 64px;
  padding: 9px 10px; border-radius: 9px;
  background: #121212; border: 1px solid #3a3a3a; color: var(--text);
}
textarea:focus, .modal input:focus { border-color: var(--accent); outline: none; }

.loading {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--muted); background: var(--bg); z-index: 8; transition: opacity .3s;
}
.loading.gone { opacity: 0; pointer-events: none; }

/* ---------- sidebar ---------- */
.side-head { padding: 14px 14px 8px; border-bottom: 1px solid var(--line); }
.search {
  display: flex; align-items: center; gap: 8px;
  padding: 0 11px; border-radius: 10px; background: #121212; border: 1px solid #3a3a3a; color: var(--muted);
}
.search:focus-within { border-color: var(--accent); }
.search input { flex: 1; min-width: 0; padding: 10px 0; border: 0; background: transparent; outline: none; }
/* Our own clear button replaces the browser's (which iOS does not show at all). */
.search input::-webkit-search-cancel-button,
.search input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; display: none; }
.search-clear {
  position: relative; flex: 0 0 auto; display: grid; place-items: center;
  width: 22px; height: 22px; margin-right: -3px; padding: 0;
  border: 0; border-radius: 50%; background: #5a5a57; color: #121212; cursor: pointer;
}
.search-clear:hover { background: #7a7a76; }
.search-clear:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.search-clear::before { content: ''; position: absolute; inset: -10px; } /* bigger hit area */
.filters { display: flex; gap: 6px; flex-wrap: nowrap; overflow-x: auto; margin-top: 10px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  padding: 5px 11px; border-radius: 99px; font-size: 12.5px; font-weight: 600;
  border: 1px solid var(--line); background: transparent; color: var(--muted);
}
.chip:hover { color: var(--text); border-color: #4a4a4a; }
.chip.active { background: var(--text); color: #161616; border-color: var(--text); }
.list-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; font-size: 12px; color: var(--muted); }
.sort select { margin-left: 4px; padding: 3px 6px; border-radius: 7px; background: #121212; border: 1px solid #3a3a3a; }

.list { list-style: none; margin: 0; padding: 6px; overflow-y: auto; flex: 1 1 auto; min-height: 0; overscroll-behavior: contain; }
.item {
  display: flex; align-items: center; gap: 4px;
  padding: 3px 6px 3px 3px; border-radius: 10px;
  border: 1px solid transparent;
}
.item:hover { background: #262626; }
.item[aria-current="true"] { background: rgba(255, 107, 53, .12); border-color: rgba(255, 107, 53, .55); }
.item-main {
  flex: 1; min-width: 0;
  display: grid; grid-template-columns: 50px 1fr; align-items: center; gap: 10px;
  padding: 6px 7px; border: 0; border-radius: 8px; background: transparent; text-align: left;
}
.item .txt { display: flex; flex-direction: column; min-width: 0; }
.item .num {
  font-size: 12px; font-weight: 800; text-align: center;
  padding: 4px 0; border-radius: 7px; background: var(--booth); color: #262626;
  font-variant-numeric: tabular-nums;
}
.item.is-star .num { background: var(--star); color: #fff; }
.item .name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .marks { display: flex; gap: 2px; }
.mark-btn {
  width: 30px; height: 30px; display: grid; place-items: center;
  border: 0; border-radius: 8px; background: transparent; color: #5d5d5a;
}
.mark-btn:hover { background: #333; color: var(--text); }
.mark-btn.on.s { color: var(--star); }
.empty { padding: 30px 16px; text-align: center; color: var(--muted); }

.side-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); font-size: 12px; color: var(--muted);
}

/* ---------- sign-in dialog ---------- */
.modal {
  border: 1px solid #3a3a3a; border-radius: 14px; padding: 0;
  background: #1d1d1d; color: var(--text); width: min(420px, calc(100vw - 32px));
  box-shadow: 0 24px 70px rgba(0, 0, 0, .6);
}
.modal::backdrop { background: rgba(0, 0, 0, .6); backdrop-filter: blur(2px); }
.modal-body { position: relative; padding: 22px; }
.modal h2 { margin: 0 30px 6px 0; font-size: 18px; }
.modal label { display: block; font-size: 12.5px; color: var(--muted); margin: 12px 0 6px; }
.modal input { min-height: 0; font-size: 16px; }
.muted { color: var(--muted); }
.form-error { color: var(--danger); min-height: 1.2em; margin: 10px 0 0; font-size: 13px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

/* ---------- account-only features ---------- */
.private { color: var(--muted); font-weight: 400; font-size: 11.5px; margin-left: 4px; }
.private::before { content: "· "; }
.signin-prompt {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px; border-radius: 10px; background: #262626; border: 1px solid #343434;
}
.signin-prompt p { margin: 0; font-size: 13px; color: #d7d7d3; }
.tag.own { background: rgba(46, 189, 107, .16); color: #5fd894; }
.link-btn {
  display: block; margin: 12px 0 0; padding: 4px 0; border: 0; background: none;
  color: var(--muted); font-size: 12.5px; text-decoration: underline; text-underline-offset: 3px; text-align: left;
}
.link-btn:hover { color: var(--text); }
.item.mine .num { background: var(--visited); color: #fff; }
.item.mine { border-color: rgba(46, 189, 107, .35); margin-bottom: 4px; }
.no-backend .marks, .no-backend .chip:not([data-filter="all"]), .no-backend #exportBtn, .no-backend .link-btn { display: none !important; }

/* Visitor notes on your own booth (exhibitors) */
.booth-notes h3 { margin: 4px 0 2px; font-size: 14.5px; }
.booth-notes .count { color: var(--muted); font-weight: 500; }
.private-line { margin: 0 0 10px; font-size: 12.5px; color: var(--muted); }
.bn-form { display: grid; gap: 8px; }
.bn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.bn-form input, .bn-form textarea {
  width: 100%; padding: 9px 10px; border-radius: 9px; min-height: 0;
  background: #121212; border: 1px solid #3a3a3a; color: var(--text);
}
.bn-form input:focus, .bn-form textarea:focus { border-color: var(--accent); outline: none; }
.bn-actions { display: flex; justify-content: flex-end; gap: 8px; }
.bn-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.bn-list li { position: relative; padding: 9px 40px 9px 11px; border-radius: 10px; background: #262626; border: 1px solid #333; }
.bn-list li.bn-empty { padding: 10px 12px; color: var(--muted); font-size: 13px; text-align: center; background: transparent; border-style: dashed; }
.bn-head { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 0 4px; align-items: baseline; }
.bn-head strong { color: var(--text); }
.bn-head time { margin-left: auto; font-size: 11.5px; }
.bn-list p { margin: 4px 0 0; font-size: 13.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.bn-del {
  position: absolute; top: 4px; right: 4px; width: 32px; height: 32px; border: 0; border-radius: 8px;
  background: transparent; color: var(--muted); font-size: 18px;
}
.bn-del:hover { background: #333; color: var(--text); }

/* "Built with Langrove" tag, top right of the map */
.made-by {
  position: absolute; top: 14px; right: 14px; z-index: 4;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 99px;
  background: rgba(28, 28, 28, .82); border: 1px solid var(--line); backdrop-filter: blur(8px);
  color: #cfcfca; font-size: 11.5px; font-weight: 600; letter-spacing: .01em;
}
.made-by img { width: 14px; height: 14px; display: block; }
.made-by:hover { color: var(--text); border-color: #4a4a4a; }

/* First-login welcome */
.welcome {
  position: absolute; top: 66px; left: 50%; transform: translateX(-50%); z-index: 6;
  display: flex; align-items: center; gap: 14px;
  width: max-content; max-width: min(460px, calc(100% - 24px));
  padding: 12px 12px 12px 16px; border-radius: 12px;
  background: rgba(22, 22, 22, .96); border: 1px solid #3c3c3c; border-left: 3px solid var(--accent);
  box-shadow: 0 12px 34px rgba(0, 0, 0, .4);
}
.welcome p { margin: 0; font-size: 13.5px; line-height: 1.4; }
.map-pane:has(.welcome:not([hidden])) .legend { display: none; }
.welcome-close {
  flex: 0 0 auto; padding: 7px 12px; border-radius: 8px; border: 0;
  background: var(--accent); color: #1a1a1a; font-weight: 700; font-size: 13px;
}

/* ---------- search row with the My notes button ---------- */
.search-row { display: flex; gap: 8px; align-items: stretch; }
.search-row .search { flex: 1; min-width: 0; }
.notes-btn {
  flex: 0 0 auto; width: 44px; display: grid; place-items: center;
  border-radius: 10px; border: 1px solid #3a3a3a; background: #121212; color: var(--accent);
}
.notes-btn:hover { border-color: #5a5a5a; }
.notes-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #1a1a1a; }

/* ---------- general notes ---------- */
.notes-composer { padding: 10px 14px 12px; border-bottom: 1px solid var(--line); background: #1b1b1b; flex: 0 0 auto; }
.nc-label { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.nc-label .private::before { content: none; }
.notes-composer textarea { min-height: 72px; }
.nc-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
/* Short phones: keep the composer slim until it is used, so saved notes stay visible below it. */
@media (max-height: 700px) {
  .notes-composer { padding-top: 8px; padding-bottom: 8px; }
  .notes-composer textarea { min-height: 0; height: 68px; transition: height .15s ease; }
  .notes-composer textarea:focus, .notes-composer textarea:not(:placeholder-shown) { height: 112px; }
  .nc-actions { margin-top: 6px; }
}
.list .gnote { margin: 4px 6px 8px; padding: 10px 12px; border-radius: 10px; background: #262626; border: 1px solid #333; }
.list .gnote[aria-current="true"] { border-color: var(--accent); }
.gnote p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13.5px; line-height: 1.45; }
.gn-meta { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; font-size: 11.5px; color: var(--muted); }
.gn-actions { display: flex; gap: 2px; }
.gn-actions button { border: 0; background: none; color: var(--muted); padding: 4px 8px; font-size: 12px; font-weight: 600; border-radius: 6px; }
.gn-actions button:hover { color: var(--text); background: #333; }

/* ---------- places in the list ---------- */
.list .section {
  padding: 10px 10px 4px; font-size: 11.5px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted);
}
.item.place .num { background: #343434; color: #f3f3f1; display: grid; place-items: center; }
.item.place.kind-workshop .num { background: var(--accent); color: #1a1a1a; }
.item.place.kind-stage .num { background: #8b5cf6; color: #fff; }
.item.place.kind-bar .num, .item.place.kind-food .num { background: #e0784a; color: #fff; }
.item.place.kind-exit .num { background: #0f8a4b; color: #fff; }

/* ---------- list sheet handle (phones) ---------- */
.sheet-handle {
  display: none; flex: 0 0 auto; width: 100%; height: 30px;
  align-items: center; justify-content: center;
  border: 0; background: transparent; cursor: grab; touch-action: none;
}
.sheet-handle span { width: 44px; height: 5px; border-radius: 3px; background: #5c5c5a; }
.sheet-handle:focus-visible { outline-offset: -4px; }

/* ---------- detail card when it lives in the sidebar (phones, short landscape) ---------- */
.sidebar > .detail {
  position: absolute; left: 0; right: 0; bottom: 0; top: auto; width: auto;
  max-height: 100%; margin: 0; z-index: 7;
  padding-bottom: calc(14px + env(safe-area-inset-bottom));
  border-radius: 14px 14px 0 0; border: 0; border-top: 2px solid var(--selected);
  background: #1d1d1d;
  box-shadow: 0 -12px 30px rgba(0, 0, 0, .45);
}
.sidebar > .detail .detail-head h2 { font-size: 17px; }

/* ---------- gesture hint (touch screens, first visit) ---------- */
.gesture-hint {
  position: absolute; left: 50%; top: 66px; z-index: 5; transform: translateX(-50%);
  padding: 7px 12px; border-radius: 99px; pointer-events: none;
  background: rgba(16, 16, 16, .9); border: 1px solid #3c3c3c;
  font-size: 12.5px; color: #e8e8e4; text-align: center;
  width: max-content; max-width: calc(100% - 24px);
  transition: opacity .4s;
}
.gesture-hint.gone { opacity: 0; }

.map-error {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 24px;
  text-align: center; color: var(--muted);
}

.account .btn { max-width: 44vw; overflow: hidden; text-overflow: ellipsis; }
.btn-short { display: none; }
.btn-icon { display: none; vertical-align: middle; }

/* ---------- touch screens: 44px targets, no input zoom on iOS ---------- */
@media (pointer: coarse) {
  button, a, input, select, textarea, label { touch-action: manipulation; }
  body { -webkit-tap-highlight-color: transparent; }
  input, select, textarea, .search input { font-size: 16px; }
  .icon-btn { width: 44px; height: 44px; font-size: 21px; }
  .seg button { min-height: 42px; padding: 6px 15px; }
  .chip { min-height: 44px; padding: 6px 14px; font-size: 13.5px; }
  .mark-btn { width: 44px; height: 44px; }
  .detail .close, .modal .close { width: 44px; height: 44px; top: 4px; right: 4px; }
  .toggle { min-height: 40px; padding: 6px 14px 6px 12px; }
  .btn { min-height: 44px; }
  .btn.small { min-height: 44px; padding: 8px 12px; }
  .detail-links a { display: inline-block; padding: 12px 0; }
  .detail-links { margin-bottom: 4px; }
  .gn-actions button { min-height: 40px; padding: 8px 12px; font-size: 13px; }
  .sort select { min-height: 44px; padding: 4px 8px; }
  .search input { padding: 11px 0; }
  .item { padding: 2px 2px 2px 3px; }
  .item-main { min-height: 52px; }
  .made-by { min-height: 34px; padding: 6px 12px; }
  .link-btn { padding: 12px 0; }
  .bn-del { width: 44px; height: 44px; top: 0; right: 0; }
  .bn-list li { padding-right: 48px; }
  .bn-form input, .bn-form textarea { font-size: 16px; }
  .welcome-close { min-height: 40px; }
  .share-btn { min-width: 44px; justify-content: center; }
}

/* ---------- small screens: map on top, list below ---------- */
@media (max-width: 860px) {
  .topbar {
    gap: 4px 12px; flex-wrap: wrap;
    padding: max(8px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 7px max(12px, env(safe-area-inset-left));
  }
  .brand { gap: 9px; }
  .brand p { font-size: 11.5px; line-height: 1.25; }
  .sub-long { display: none; }
  .sub-short { display: inline; }
  .brand h1 { font-size: 15px; line-height: 1.25; }
  .progress { order: 3; flex: 1 0 100%; min-width: 0; margin: 0; display: flex; align-items: center; gap: 10px; }
  .progress-text { font-size: 12px; }
  .account { margin-left: auto; }
  .account .btn { padding: 5px 12px; font-size: 13px; }
  .layout { flex-direction: column; }
  .map-pane { flex: 0 0 44%; min-height: 200px; }
  .sidebar { position: relative; flex: 1 1 auto; min-height: 0; border-left: 0; border-top: 1px solid var(--line); }
  .legend { left: 8px; right: auto; bottom: 8px; gap: 8px; padding: 5px 8px; font-size: 11px; }
  .legend i { width: 9px; height: 9px; }
  .map-tools { top: 8px; left: 8px; gap: 6px; }
  .side-head { padding: 8px 10px 6px; }
  .filters { flex-wrap: nowrap; overflow-x: auto; margin: 8px -10px 0; padding: 0 10px; scrollbar-width: none; }
  .filters::-webkit-scrollbar { display: none; }
  .chip { flex: 0 0 auto; }
  .list-meta { margin-top: 6px; }
  .list { padding: 4px; }
  .side-foot { padding: 6px 12px calc(6px + env(safe-area-inset-bottom)); }
}

@media (max-width: 860px) {
  .made-by { top: 8px; right: 8px; }
  .welcome { top: auto; bottom: 8px; }
}
@media (max-width: 520px) {
  .made-long { display: none; }
  .bn-row { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .btn-long { display: none; }
  .btn-short { display: inline; }
  .share-label { display: none; }
  .share-btn { padding-left: 10px; padding-right: 10px; }
}
@media (max-width: 360px) {
  .topbar { padding-left: 10px; padding-right: 10px; column-gap: 6px; }
  .brand { gap: 8px; }
  .brand h1 { font-size: 14px; }
  .account { gap: 6px; }
  .account .btn { padding-left: 9px; padding-right: 9px; }
  #accountBtn .btn-short { display: none; }
  #accountBtn .btn-icon { display: inline-block; }
  .account .btn:has(.btn-icon) { min-width: 44px; }
}
@media (max-height: 560px) and (orientation: landscape) {
  .share-qr { width: 150px; height: 150px; margin: 10px auto; }
}
@media (max-width: 380px) {
  .made-by { top: 58px; }
}

/* Small phones: shorter labels, more room for the list. */
@media (max-width: 860px) and (max-height: 720px) {
  .map-pane { flex-basis: 40%; }
  .list-meta { display: none; }
}
@media (max-width: 420px) {

  .sync { display: none; }
  .legend { gap: 6px; padding: 4px 7px; font-size: 10.5px; }
}

/* Phones in landscape: map left, list right, compact header. */
@media (max-height: 560px) and (orientation: landscape) {
  .topbar { flex-wrap: nowrap; padding-top: 6px; padding-bottom: 6px; padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
  .brand p { font-size: 11px; line-height: 1.2; }
  .sub-long { display: none; }
  .sub-short { display: inline; }
  .brand h1 { font-size: 14px; line-height: 1.2; }
  .progress { order: 0; flex: 1 1 auto; margin-left: auto; display: flex; align-items: center; gap: 10px; min-width: 0; }
  .account { margin-left: 0; }
  .layout { flex-direction: row; }
  .map-pane { flex: 1 1 auto; min-height: 0; }
  .sidebar { position: relative; flex: 0 0 min(340px, 44vw); border-top: 0; border-left: 1px solid var(--line); padding-right: env(safe-area-inset-right); }
  .map-tools { left: max(8px, env(safe-area-inset-left)); }
  .legend { display: none; }
  .made-long { display: none; }
  .list-meta, .side-foot { display: none; }
  .side-head { padding: 6px 8px 4px; }
  .filters { margin-top: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .gesture-hint { transition: none; }
}

/* ---------- phones and tablets in portrait: the list is a sheet over a full-screen map ---------- */
@media (max-width: 860px) and (min-height: 561px) {
  .layout { position: relative; }
  .map-pane { flex: 1 1 auto; min-height: 0; }
  .sidebar {
    position: absolute; left: 0; right: 0; bottom: 0; z-index: 8;
    height: 50%;
    border-top: 0; border-radius: 16px 16px 0 0;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, .45);
    transition: height .28s cubic-bezier(.2, .8, .2, 1);
    overflow: hidden;
  }
  .sidebar.dragging { transition: none; }
  .sheet-handle { display: flex; }
  .side-head { padding-top: 0; }
  .sidebar > .detail { top: 30px; max-height: none; border-radius: 0; box-shadow: none; overscroll-behavior: contain; }
  .legend, .welcome { bottom: calc(var(--sheet-h, 50%) + 8px); transition: bottom .28s cubic-bezier(.2, .8, .2, 1), opacity .2s; }
  .layout.sheet-tall .legend { opacity: 0; pointer-events: none; }
  /* Folded down: only the handle and the search box show. */
  .sidebar[data-sheet="peek"] .side-head > :not(.search-row),
  .sidebar[data-sheet="peek"] .notes-composer,
  .sidebar[data-sheet="peek"] .list,
  .sidebar[data-sheet="peek"] .side-foot { visibility: hidden; }
}
@media (max-width: 860px) and (min-height: 561px) and (prefers-reduced-motion: reduce) {
  .sidebar, .legend, .welcome { transition: none; }
}

/* ---------- AI assistant ---------- */
.layout { position: relative; }
.chat-btn { position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 7px; }
.chat-btn svg { color: var(--accent); }
.chat-btn[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); }
.chat-btn-sm { display: none; position: relative; color: var(--accent); }

.chat {
  position: absolute; top: 0; right: 0; bottom: 0; z-index: 40; width: var(--side-w);
  display: flex; flex-direction: column; background: var(--panel);
  border-left: 1px solid var(--line); box-shadow: -14px 0 40px rgba(0, 0, 0, .35);
}
.chat-head {
  flex: 0 0 auto; display: flex; align-items: center; gap: 11px;
  padding: 10px 8px 10px 14px; border-bottom: 1px solid var(--line);
}
.ai-mark {
  flex: 0 0 auto; width: 34px; height: 34px; display: grid; place-items: center;
  border-radius: 10px; background: rgba(255, 200, 0, .14); color: var(--accent);
}
.chat-titles { flex: 1; min-width: 0; }
.chat-titles h2 { margin: 0; font-size: 16px; letter-spacing: -0.01em; }
.chat-titles p { margin: 1px 0 0; font-size: 12px; color: var(--muted); }
.chat .close {
  flex: 0 0 auto; width: 40px; height: 40px; border: 0; border-radius: 10px;
  background: transparent; color: var(--muted); font-size: 26px; line-height: 1; cursor: pointer;
}
.chat .close:hover { background: #333; color: var(--text); }

.chat-body { position: relative; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.chat-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 6px 12px 14px; }
.chat-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }

.msg { display: flex; flex-direction: column; align-items: flex-start; margin-top: 12px; }
.msg.mine { align-items: flex-end; }
.msg-bubble { max-width: 88%; min-width: 0; border-radius: 4px 16px 16px 16px; background: #2b2b2b; border: 1px solid #373737; }
.msg.mine .msg-bubble { border-radius: 16px 4px 16px 16px; background: #3a3214; border-color: #5c4c16; }
.msg.error .msg-bubble { border-color: rgba(255, 107, 107, .45); }
.msg-text { margin: 0; padding: 8px 12px 9px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.45; }
.msg-text a { color: #9cc0ff; }
.ai-cards { display: flex; flex-direction: column; gap: 6px; width: 88%; margin-top: 6px; }
.ai-card {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px;
  border-radius: 12px; border: 1px solid #3a3a3a; background: #232323; color: var(--text); text-align: left; cursor: pointer;
}
.ai-card:hover, .ai-card:focus-visible { border-color: var(--accent); }
.ai-card .num {
  flex: 0 0 auto; min-width: 46px; height: 28px; padding: 0 6px; display: grid; place-items: center;
  border-radius: 7px; background: var(--booth); color: #1a1a1a; font-weight: 800; font-size: 12px;
}
.ai-card .num.place { background: #343434; color: var(--text); }
.ai-card .txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ai-card b { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-card small { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-card .go { flex: 0 0 auto; font-size: 12px; font-weight: 700; color: var(--accent); white-space: nowrap; }
.ai-note { margin: 5px 6px 0; font-size: 12px; color: var(--muted); }
.ai-note.ok { color: #5fd894; }
.ai-thinking .msg-bubble { display: flex; gap: 5px; padding: 12px 14px; }
.ai-thinking i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: ai-dot 1.2s infinite ease-in-out; }
.ai-thinking i:nth-child(2) { animation-delay: .15s; }
.ai-thinking i:nth-child(3) { animation-delay: .3s; }
@keyframes ai-dot { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .ai-thinking i { animation: none; } }

.chat-foot { flex: 0 0 auto; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: #1b1b1b; }
.ai-suggest { display: flex; gap: 6px; overflow-x: auto; margin: 0 -12px 9px; padding: 0 12px; scrollbar-width: none; }
.ai-suggest::-webkit-scrollbar { display: none; }
.ai-suggest button {
  flex: 0 0 auto; padding: 6px 12px; border-radius: 99px; border: 1px solid #3a3a3a; background: #232323;
  color: var(--text); font-size: 12.5px; white-space: nowrap; cursor: pointer;
}
.ai-suggest button:hover { border-color: var(--accent); }
.chat-fine { margin: 7px 2px 0; font-size: 11.5px; color: var(--muted); }
.chat-fine .link-btn { display: inline; margin: 0; padding: 0; font-size: 11.5px; }
.chat-fine a { color: var(--muted); text-underline-offset: 3px; }
.chat-row { display: flex; align-items: flex-end; gap: 7px; }
.chat-row textarea {
  flex: 1; min-width: 0; height: 40px; min-height: 40px; max-height: 132px; resize: none;
  padding: 9px 13px; border-radius: 20px; line-height: 1.4;
}
.chat-send {
  flex: 0 0 auto; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%;
  border: 1px solid var(--accent); background: var(--accent); color: #1a1a1a; cursor: pointer;
}
.chat-send:disabled { opacity: .55; cursor: wait; }
.chat-error { margin: 6px 4px 0; }
.chat-error:empty { display: none; }

@media (pointer: coarse) {
  .chat-send { width: 44px; height: 44px; }
  .chat-row textarea { height: 44px; min-height: 44px; padding: 11px 14px; border-radius: 22px; }
  .chat .close { width: 44px; height: 44px; }
  .ai-suggest button { min-height: 38px; padding: 6px 14px; font-size: 13px; }
  .ai-card { min-height: 52px; }
}

/* Small laptops: a tighter header so Ask AI, Share and the account fit on one row. */
@media (min-width: 861px) and (max-width: 1100px) {
  .sub-long { display: none; }
  .sub-short { display: inline; }
  .share-label { display: none; }
  .share-btn { min-width: 40px; justify-content: center; padding-left: 10px; padding-right: 10px; }
  .account .btn { max-width: 220px; }
}
/* Tablets show "Account" instead of the email; on phones the AI button sits in the list bar. */
@media (max-width: 860px) {
  .btn-long { display: none; }
  .btn-short { display: inline; }
}
@media (max-width: 560px) {
  .chat-btn { display: none; }
  .chat-btn-sm { display: grid; }
}

/* Phones and landscape phones: the assistant opens full screen and follows the on-screen keyboard. */
@media (max-width: 860px), (max-height: 560px) {
  .chat {
    position: fixed; top: 0; left: 0; right: 0; bottom: auto; height: 100dvh; width: auto; z-index: 200;
    border-left: 0; box-shadow: none;
    padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right);
  }
  .chat-head { padding-top: max(8px, env(safe-area-inset-top)); }
}

/* ---------- terms, privacy and feedback ---------- */
.modal label.consent { margin-top: 14px; }
.modal label.check, label.check {
  display: flex; align-items: flex-start; gap: 9px; margin: 6px 0 0; font-size: 13px; color: var(--text); line-height: 1.4; cursor: pointer;
}
.check input { flex: 0 0 auto; width: 18px; height: 18px; min-height: 0; margin: 1px 0 0; accent-color: var(--accent); }
.consent a, .legal-links a, .foot-legal { color: #9cc0ff; text-underline-offset: 3px; }
.legal-links { margin: 8px 0 0; font-size: 12.5px; color: var(--muted); }
.foot-note { display: inline-flex; flex-direction: column; align-items: flex-end; gap: 1px; text-align: right; }
.foot-legal { font-size: 11.5px; }

.legal-modal { width: min(760px, calc(100vw - 24px)); height: min(86dvh, 900px); max-height: none; padding: 0; overflow: hidden; }
.legal-modal[open] { display: flex; flex-direction: column; }
.legal-head {
  flex: 0 0 auto; display: flex; align-items: center; gap: 12px; padding: 10px 8px 10px 18px; border-bottom: 1px solid var(--line);
}
.legal-head strong { flex: 1; font-size: 15px; }
.legal-open { font-size: 12.5px; color: var(--muted); text-underline-offset: 3px; }
.legal-modal .close { position: static; }
.legal-body { position: relative; flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 20px 28px; font-size: 14.5px; line-height: 1.6; }
.legal-doc h1 { font-size: 22px; line-height: 1.2; margin: 30px 0 4px; letter-spacing: -0.01em; }
.legal-doc h2 { font-size: 16px; margin: 22px 0 6px; }
.legal-doc p, .legal-doc li { color: #e2e2de; }
.legal-doc ul { padding-left: 20px; margin: 6px 0 12px; }
.legal-doc li { margin: 4px 0; }
.legal-doc a { color: #9cc0ff; }
.legal-doc .version { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
.legal-doc .box { border: 1px solid #4a4220; background: #2a2614; border-radius: 12px; padding: 10px 14px; margin: 14px 0; }
.legal-doc .box p { margin: 6px 0; }
.legal-doc .toc { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 4px; padding: 0; list-style: none; }
.legal-doc .toc a { display: inline-block; padding: 6px 12px; border: 1px solid #3a3a3a; border-radius: 99px; color: var(--text); text-decoration: none; font-size: 13px; font-weight: 600; }
.legal-doc hr { border: 0; border-top: 1px solid var(--line); margin: 30px 0 0; }

/* Feedback: stars and the hosts' inbox */
.stars { display: flex; gap: 2px; margin-top: 2px; }
.stars button { width: 38px; height: 38px; padding: 0; display: grid; place-items: center; border: 0; border-radius: 8px; background: none; color: #555; cursor: pointer; }
.stars button.on { color: var(--accent); }
.stars button:hover { background: #2a2a2a; }
#feedbackText { min-height: 96px; }
.modal input#feedbackContact { width: 100%; padding: 9px 10px; border-radius: 9px; background: #121212; border: 1px solid #3a3a3a; color: var(--text); }
.inbox-modal { width: min(560px, calc(100vw - 24px)); }
.inbox-list { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.inbox-list li { padding: 10px 12px; border: 1px solid #333; border-radius: 10px; background: #232323; }
.inbox-list p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; }
.inbox-meta { margin-top: 6px; font-size: 11.5px; color: var(--muted); }
.inbox-meta .stars-txt { color: var(--accent); letter-spacing: 1px; }

@media (pointer: coarse) {
  .check input { width: 22px; height: 22px; }
  .stars button { width: 44px; height: 44px; }
  .legal-head .close { width: 44px; height: 44px; }
}
@media (max-width: 560px) {
  .legal-modal { width: 100vw; height: 100dvh; max-width: none; margin: 0; border-radius: 0; border: 0; }
  .legal-head { padding-top: max(8px, env(safe-area-inset-top)); }
  .legal-body { padding: 0 16px calc(24px + env(safe-area-inset-bottom)); }
}

/* Long dialogs on small phones: keep the buttons in reach while the content scrolls. */
.modal .modal-actions { position: sticky; bottom: 0; z-index: 1; background: #1d1d1d; padding: 10px 0 2px; }
