/* Deliberately plain styling. Change the variables below to restyle the whole app. */
:root {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --text: #1c1c1c;
  --muted: #666a70;
  --border: #dcdcd8;
  --accent: #1d4e89;
  --accent-text: #ffffff;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a;
    --surface: #1f2226;
    --text: #ececec;
    --muted: #a0a4ab;
    --border: #34383e;
    --accent: #7fb0e6;
    --accent-text: #10141a;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
}

.top {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px 0;
}

.top h1 { margin: 0 0 8px; font-size: 1.25rem; }

.tabs { display: flex; gap: 4px; overflow-x: auto; }

.tabs button {
  flex: none;
  padding: 10px 14px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: none;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}

.tabs button[aria-selected="true"] {
  color: var(--text);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.count:not(:empty) {
  display: inline-block;
  min-width: 1.4em;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 0.75rem;
  text-align: center;
}

main { max-width: 1100px; margin: 0 auto; padding: 16px; }

.muted { color: var(--muted); }

.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

#search {
  flex: 1 1 240px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.check { display: flex; align-items: center; gap: 6px; white-space: nowrap; }

.btn {
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }

.chips { display: flex; gap: 8px; margin: 12px 0 4px; overflow-x: auto; padding-bottom: 4px; }

.chip {
  flex: none;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}

.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
}

.card:hover, .card:focus-visible { border-color: var(--accent); outline: none; }
.card h3 { margin: 0; padding-right: 36px; font-size: 1.05rem; }
.card p { margin: 0; font-size: 0.92rem; }

.meta { display: flex; flex-wrap: wrap; gap: 6px; font-size: 0.8rem; }

.tag {
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  white-space: nowrap;
}

.tag.free { border-color: #2e7d4f; color: #2e7d4f; }
@media (prefers-color-scheme: dark) { .tag.free { border-color: #6fcf97; color: #6fcf97; } }

.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

.star {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--muted);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}

.star[aria-pressed="true"] { color: #d99a00; }

#map { height: calc(100vh - 150px); min-height: 360px; border: 1px solid var(--border); border-radius: var(--radius); }

.pin {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  font-size: 15px;
}

.popup-btn { margin-top: 6px; padding: 4px 10px; font: inherit; cursor: pointer; }

.panel {
  margin-bottom: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.panel h2 { margin: 0 0 4px; font-size: 1.1rem; }
.panel > p { margin: 0 0 10px; }
.panel ul { margin: 8px 0 0; padding-left: 20px; }
.panel li { margin-bottom: 6px; }

.stops { list-style: none; margin: 0; padding: 0; }

.stop {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
}

.stop .when { color: var(--muted); font-size: 0.85rem; padding-top: 2px; }

.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.link:hover { text-decoration: underline; }
.stop .note { display: block; font-size: 0.9rem; color: var(--muted); }

dialog {
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

dialog::backdrop { background: rgba(0, 0, 0, 0.5); }

#detail-body { padding: 18px; }
#detail-body h2 { margin: 0 0 6px; padding-right: 40px; font-size: 1.3rem; }
#detail-body dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 12px 0; font-size: 0.92rem; }
#detail-body dt { color: var(--muted); }
#detail-body dd { margin: 0; }

.tipbox { padding: 10px 12px; border-left: 3px solid var(--accent); background: var(--bg); font-size: 0.92rem; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

.close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 36px;
  height: 36px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 1.4rem;
  cursor: pointer;
}

/* "hidden" must win over any display rule, or hidden rows show up anyway. */
[hidden] { display: none !important; }

.toolbar { margin: 0 0 8px; }
.routes { margin: 0 0 8px; }
.routes .btn { text-align: left; }
.tour-pick { width: 100%; padding: 12px; border: 2px solid var(--accent); border-radius: var(--radius); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; }
.notice { margin: 0 0 8px; padding: 8px 12px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); color: var(--muted); font-size: 0.9rem; }
.toolbar .btn { flex: 1 1 auto; padding: 10px 8px; }

/* Nothing may be wider than the phone screen. */
html, body { max-width: 100%; overflow-x: hidden; }
select, input, button, fieldset { max-width: 100%; min-width: 0; }
.check { white-space: normal; }

/* ---------- walking guide ---------- */
.form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; margin: 12px 0; }
.form label, .form fieldset { min-width: 0; }
.form select, .form input[type="text"], .form input[type="password"] { width: 100%; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem; }
.form .wide { grid-column: 1 / -1; }
.form .check { flex-direction: row; align-items: center; font-size: 1rem; }
.form fieldset { margin: 0; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); }
.form legend { padding: 0 4px; font-size: 0.9rem; }
.form fieldset .check { display: inline-flex; margin-right: 16px; }

.keys { margin-top: 14px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); }
.keys summary { cursor: pointer; font-weight: 600; }
.keys .actions { margin-top: 0; align-items: center; }

.form select, .form input[type="text"], .form input[type="password"], .controls select, #ask-text {
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

#ask-text { flex: 1 1 200px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.big { padding: 14px 26px; font-size: 1.1rem; font-weight: 600; }
.speakers { display: contents; }
.speakers .btn { padding: 12px 14px; font-size: 1rem; font-weight: 600; }
#talk:not(.big) { padding: 12px 14px; font-weight: 600; }
.transcript { max-height: 30vh; }
#code-input { padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); font: inherit; }
#guide-setup .meta { margin-top: 12px; }
.btn.primary[aria-pressed="true"] { background: #b3261e; border-color: #b3261e; color: #fff; }

.status { flex: 1; margin: 0 0 10px; font-weight: 600; min-height: 1.5em; }

#guide-map { height: 46vh; min-height: 280px; border: 1px solid var(--border); border-radius: var(--radius); }
#guide-live .controls { margin-top: 10px; }

.walker {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: #1a73e8;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
  font-size: 17px;
}

.nav {
  margin-bottom: 8px;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: #1a73e8;
  color: #fff;
}
.nav-step { font-size: 1.15rem; font-weight: 700; }
.nav-target { font-size: 0.9rem; opacity: 0.9; }

.stop-pin {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #1a73e8;
  color: #fff;
  font: 700 13px var(--font);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}
.stop-pin.done { background: #8a8f98; }

.transcript {
  margin-top: 12px;
  max-height: 40vh;
  overflow-y: auto;
  padding: 4px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.transcript:empty { display: none; }
.line { padding: 8px 0; border-top: 1px solid var(--border); }
.line:first-child { border-top: 0; }
.line strong { margin-right: 8px; }
.line.you strong { color: var(--accent); }
.line.system { color: var(--muted); font-size: 0.88rem; }

@media (max-width: 600px) {
  .form { grid-template-columns: minmax(0, 1fr); }
  .form fieldset .check { display: flex; margin: 6px 0; }
  .btn.big { width: 100%; }
  #guide-map { height: 38vh; }
  .stop { grid-template-columns: 1fr; gap: 0; }
}

/* ---------- themed map layers ---------- */
.map-theme select {
  padding: 8px 10px;
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: 600 0.95rem var(--font);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}
.map-hint {
  margin-top: 4px;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 0.8rem;
  text-align: center;
}
.theme-pin {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 2px solid;
  border-radius: 50%;
  background: #fff;
  font-size: 15px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

/* The panel that slides up when a place on the map is tapped. */
.place-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3000;
  max-height: 60vh;
  overflow-y: auto;
  padding: 16px 16px 20px;
  border-top: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.25);
  animation: sheet-up 0.2s ease-out;
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.place-sheet h3 { margin: 2px 40px 8px 0; font-size: 1.2rem; }
.sheet-kind { color: var(--muted); font-size: 0.85rem; }
.sheet-img { width: 100%; max-height: 180px; object-fit: cover; border-radius: var(--radius); margin-bottom: 8px; }
.place-sheet p { margin: 0 0 8px; font-size: 0.95rem; }
.place-sheet dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 8px 0; font-size: 0.9rem; }
.place-sheet dt { color: var(--muted); }
.place-sheet dd { margin: 0; }
.sheet-actions { display: flex; gap: 8px; margin-top: 12px; }
.sheet-actions .btn { flex: 1; padding: 12px; font-weight: 600; }
.sheet-close { position: absolute; top: 8px; right: 10px; width: 36px; height: 36px; border: 0; background: none; color: var(--muted); font-size: 1.5rem; cursor: pointer; }
.start-note { margin: 8px 0 0; padding: 10px 12px; border-radius: var(--radius); background: #fff4e5; color: #8a4b00; font-weight: 600; }
