:root {
  --bg: #f6f7f9; --panel: #ffffff; --ink: #1c2430; --muted: #6b7686;
  --line: #e3e7ed; --accent: #f5b301; --accent-ink: #3a2e00;
  --primary: #2b6cad; --danger: #c0392b; --ok: #2e7d32;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink); background: var(--bg); display: flex; flex-direction: column; }

#topbar { display: flex; align-items: center; justify-content: space-between;
  padding: 10px 18px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 18px; }
.brand span { color: var(--muted); font-weight: 500; }
#userbox { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); }

.view { flex: 1; min-height: 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }

.btn { border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 9px 14px; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 600; }
.btn:hover { border-color: #c9d0da; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-ghost { background: #fff; }
.btn-danger { color: var(--danger); border-color: #e6c3bf; }
.btn.small { padding: 7px 10px; font-size: 13px; }

/* AUTH */
.auth-card { max-width: 360px; margin: 8vh auto; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 22px; }
.auth-card h2 { margin: 0 0 4px; }
.auth-card label { display: block; margin: 14px 0 0; font-size: 13px; font-weight: 600; }
.auth-card input { width: 100%; margin-top: 6px; padding: 10px; border: 1px solid var(--line);
  border-radius: 8px; font-size: 15px; }
.auth-card .btn { width: 100%; margin-top: 8px; }
.or { text-align: center; color: var(--muted); margin: 8px 0 0; font-size: 12px; }
.sso { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.sso .btn { margin-top: 0; }
.sso-btn { display: flex; align-items: center; gap: 9px; width: 100%; justify-content: flex-start;
  background: #fff; color: #444; font-weight: 600; }
.sso-btn[disabled] { opacity: .65; cursor: not-allowed; background: #fafbfc; }
.sso-ico { flex: 0 0 auto; }
.soon { margin-left: auto; font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: #8a7300; background: #fdf3cf; border: 1px solid #f2e2a0;
  padding: 2px 7px; border-radius: 999px; }
.signing-as { font-size: 13px; color: var(--muted); margin: 14px 0 2px; }
.signing-as strong { color: var(--ink); }
.linkbtn { border: none; background: none; color: var(--primary); cursor: pointer;
  font-size: 13px; font-weight: 600; padding: 0 0 0 4px; }
.linkbtn:hover { text-decoration: underline; }
.msg { min-height: 18px; font-size: 13px; margin: 10px 0 0; }
.msg.err { color: var(--danger); } .msg.ok { color: var(--ok); }

/* Read-only account profile (P3) */
.acct-panel { background: #fbfcfe; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; margin-bottom: 12px; }
.acct-head { font-weight: 700; font-size: 13px; margin-bottom: 6px; }
.acct-body { margin: 0; display: flex; flex-direction: column; gap: 4px; }
.acct-row { display: flex; gap: 8px; font-size: 13px; }
.acct-row dt { flex: 0 0 128px; color: var(--muted); }
.acct-row dd { margin: 0; color: var(--ink); }

/* LIST (in the sidebar) */
.list-head { display: flex; align-items: center; justify-content: space-between; }
.pub-head { margin-top: 24px; }
.tour-list { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.tour-card { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; cursor: pointer; transition: border-color .12s, box-shadow .12s; }
.tour-card:hover { border-color: #c9d0da; box-shadow: 0 1px 6px rgba(0,0,0,.06); }
.tour-card h3 { margin: 0 0 6px; font-size: 15px; padding-right: 24px; }
.tour-del { position: absolute; top: 8px; right: 8px; border: none; background: none; cursor: pointer;
  color: var(--muted); padding: 3px; border-radius: 6px; line-height: 0; opacity: 0; transition: opacity .12s; }
.tour-card:hover .tour-del { opacity: 1; }
.tour-del:hover { background: #fdecea; color: var(--danger); }
.tour-card .meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; }
.tour-card .desc { font-size: 13px; color: #48505c; margin: 8px 0 0; }
.tour-card .row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.badge { font-size: 11px; padding: 2px 7px; border-radius: 999px; background: #eef1f5; color: #556; }
.badge.pub { background: #e6f4ea; color: var(--ok); }
.badge.walking { background: #eaf1fb; color: #2b6cad; }
.badge.driving { background: #fbeee0; color: #a15a10; }

/* WORKSPACE: sidebar (list ⇄ editor) + map */
#workspace { display: flex; height: 100%; min-height: 0; }
#sidebar { width: 360px; min-width: 320px; background: var(--panel); border-right: 1px solid var(--line);
  padding: 14px; overflow: auto; display: flex; flex-direction: column; gap: 10px; }
#mapWrap { flex: 1; position: relative; min-width: 0; }
#map { position: absolute; inset: 0; }
.map-err { display: flex; align-items: center; justify-content: center; height: 100%;
  color: var(--muted); padding: 24px; text-align: center; }

/* Place search + "my location", floating top-center over the map (TR11a) */
#mapSearchBar { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 6;
  display: flex; gap: 8px; align-items: center; width: min(420px, calc(100% - 24px)); }
#placeSearch { flex: 1; min-width: 0; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; font-size: 14px; font-family: inherit; background: #fff;
  box-shadow: 0 2px 12px rgba(0,0,0,.14); }
#myLocBtn { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  box-shadow: 0 2px 12px rgba(0,0,0,.14); }
/* Keep the Google Places dropdown above the map controls */
.pac-container { z-index: 9999; }

/* Category filter floating over the map */
#filterOverlay { position: absolute; top: 12px; left: 12px; width: 246px; z-index: 5;
  max-height: calc(100% - 24px); overflow: auto; background: #fff; border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; box-shadow: 0 2px 12px rgba(0,0,0,.14); font-size: 13px; }
.filter-head { display: flex; align-items: baseline; gap: 6px; }
#sidebar label { font-size: 13px; font-weight: 600; display: block; }
#sidebar input[type=text], #sidebar textarea { width: 100%; margin-top: 5px; padding: 9px;
  border: 1px solid var(--line); border-radius: 8px; font-size: 14px; font-family: inherit; }
#sidebar textarea { resize: vertical; }
.editor-top { display: flex; align-items: center; justify-content: space-between; }
.type-row { display: flex; gap: 16px; }
.radio { font-weight: 500; display: flex; align-items: center; gap: 5px; }
.stops-head { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.pill { font-size: 12px; background: #eef1f5; padding: 2px 8px; border-radius: 999px; color: #556; }
.stops { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.stop { border: 1px solid var(--line); border-radius: 10px; padding: 9px; background: #fbfcfe; }
.stop .st-top { display: flex; align-items: center; gap: 6px; }
.stop .seq { width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: var(--accent-ink);
  font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.stop .st-title { font-size: 14px; font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stop .st-title.custom::after { content: ' ·custom'; color: var(--muted); font-weight: 400; font-size: 11px; }
.stop .st-btns { display: flex; gap: 2px; }
.icon-btn { border: none; background: none; cursor: pointer; font-size: 14px; padding: 2px 5px; color: var(--muted); border-radius: 6px; }
.icon-btn:hover { background: #eef1f5; color: var(--ink); }
.stop textarea { width: 100%; margin-top: 7px; padding: 7px; border: 1px solid var(--line); border-radius: 7px;
  font-size: 13px; font-family: inherit; resize: vertical; }
.note-count { font-size: 11px; color: var(--muted); text-align: right; }
.note-count.over { color: var(--danger); }
.btn-col { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.cat-count { color: var(--primary); font-weight: 700; }
.cat-actions { display: flex; align-items: center; gap: 12px; margin: 6px 0; }
#catFilterBody { max-height: 46vh; overflow: auto; }
.cat-group-h { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
  margin: 8px 0 2px; }
.cat-row { display: flex; align-items: center; gap: 6px; padding: 2px 0; font-weight: 500; cursor: pointer; }
.cat-row input { margin: 0; }
.path-row { display: flex; gap: 8px; }
.path-row .btn { flex: 1; }
.owner-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* LOADING */
.loading { position: fixed; inset: 0; background: rgba(255,255,255,.55); display: flex;
  align-items: center; justify-content: center; z-index: 50; }
.spinner { width: 34px; height: 34px; border: 4px solid #d8dee7; border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
