:root {
  --ink: #1b1b1f;
  --paper: #f7f4ef;
  --accent: #bc002d; /* hinomaru red */
  --ok: #1a7f4b;
  --bad: #c0392b;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  display: grid;
  place-items: center;
}
.shell { text-align: center; padding: 2rem; }
.shell h1 { font-size: 2.4rem; margin: 0 0 .25rem; }
.tagline { color: #6b6b72; margin: 0 0 2rem; }
.badge {
  display: inline-block;
  padding: .15em .6em;
  border-radius: 999px;
  font-weight: 600;
  font-size: .9rem;
  background: #e6e2da;
}
.badge.ok  { background: rgba(26,127,75,.15);  color: var(--ok); }
.badge.bad { background: rgba(192,57,43,.15);   color: var(--bad); }

/* --- Login card --- */
.card {
  background: #fff;
  padding: 2.5rem;
  border-radius: 14px;
  box-shadow: 0 10px 40px rgba(0,0,0,.08);
  width: min(92vw, 380px);
  text-align: center;
}
.card h1 { font-size: 2rem; margin: 0 0 .15rem; }
.card form { display: grid; gap: .75rem; margin-top: 1.5rem; text-align: left; }
.card label { font-weight: 600; font-size: .9rem; }
.card input {
  padding: .7rem .8rem; font-size: 1rem;
  border: 1px solid #d8d3ca; border-radius: 8px;
}
.card input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.card button {
  padding: .7rem 1rem; font-size: 1rem; font-weight: 600;
  color: #fff; background: var(--accent); border: 0; border-radius: 8px; cursor: pointer;
}
.card button:hover { filter: brightness(1.05); }
.msg, .alert { padding: .6rem .8rem; border-radius: 8px; font-size: .9rem; margin-top: 1rem; }
.msg.ok, .alert { background: rgba(26,127,75,.12); color: var(--ok); }
.msg.bad { background: rgba(192,57,43,.12); color: var(--bad); }
.alert.bad { background: rgba(192,57,43,.12); color: var(--bad); }
.dev { margin-top: 1rem; font-size: .9rem; }

/* --- App shell --- */
/* place-items:stretch cancels the login page's centering so the layout fills the screen */
body.app { display: flex; flex-direction: column; height: 100vh; place-items: stretch; }
.topbar {
  display: flex; align-items: center; gap: 1rem;
  padding: .75rem 1.25rem; background: #fff;
  border-bottom: 1px solid #e6e2da;
  flex: 0 0 auto;
}
.topbar strong { font-size: 1.1rem; }
.topbar .who { margin-left: auto; display: inline-flex; align-items: center; gap: .45rem; font-weight: 600; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex: 0 0 auto; }
.link-btn { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }
.link-btn:hover { text-decoration: underline; }

.layout { flex: 1; display: flex; min-height: 0; }
.sidebar {
  width: 340px; flex: 0 0 340px; overflow-y: auto;
  background: #fff; border-right: 1px solid #e6e2da; padding: 1rem;
}
#map { flex: 1; min-width: 0; }

/* hamburger + drawer scrim — hidden on desktop, shown via the mobile breakpoint */
.menu-btn {
  display: none; background: none; border: 0; font-size: 1.5rem; line-height: 1;
  cursor: pointer; color: var(--ink); padding: 0 .2rem;
}
.scrim { display: none; }

/* search */
#search-form { display: flex; gap: .5rem; }
#search-form input { flex: 1; min-width: 0; padding: .55rem .7rem; border: 1px solid #d8d3ca; border-radius: 8px; font-size: .95rem; }
#search-form button {
  flex: 0 0 auto; width: 44px; padding: 0; border: 0; border-radius: 8px;
  background: var(--accent); color: #fff; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
#search-form button:hover { filter: brightness(1.05); }
#search-form button svg { width: 19px; height: 19px; }
.cat-buttons { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .6rem; }
.cat-btn {
  display: inline-flex; align-items: center; gap: .3rem;
  background: #f4f1ea; border: 1px solid #e2ddd2; border-radius: 999px;
  padding: .25rem .6rem; font-size: .8rem; cursor: pointer; color: #444;
}
.cat-btn:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.cat-btn .ico { width: 14px; height: 14px; flex: 0 0 auto; }
.clear-btn { background: #fff; color: #999; border-style: dashed; }
.clear-btn:hover { background: #777; border-color: #777; color: #fff; }

.results { list-style: none; padding: 0; margin: .75rem 0 0; }
.result { padding: .6rem; border: 1px solid #eee5da; border-radius: 8px; margin-bottom: .5rem; }
.result-name { font-weight: 600; font-size: .95rem; }
.result-addr { color: #777; font-size: .8rem; margin: .15rem 0 .4rem; }
.result-add { background: none; border: 1px solid var(--accent); color: var(--accent); border-radius: 6px; padding: .2rem .6rem; cursor: pointer; font-size: .85rem; }
.result-add:hover { background: var(--accent); color: #fff; }
.hint { color: #888; font-size: .85rem; min-height: 1em; }

/* saved POI list — grouped per person */
.poi-panel { margin-top: 1.5rem; }
.poi-panel h2 { font-size: 1rem; display: flex; align-items: center; gap: .5rem; }
.count { background: #eee5da; border-radius: 999px; padding: .05em .55em; font-size: .8rem; font-weight: 600; }

.person-group { margin-top: .85rem; }
.person-head { display: flex; align-items: center; gap: .5rem; padding-bottom: .25rem; border-bottom: 2px solid #efeae1; }
.person-toggle { display: inline-flex; align-items: center; gap: .45rem; cursor: pointer; flex: 1; font-weight: 700; font-size: .92rem; }
.person-toggle input { cursor: pointer; }
.person-name { user-select: none; }

.poi-list { list-style: none; padding: 0; margin: .35rem 0 0; }
.poi-item { padding: .35rem 0; border-bottom: 1px solid #f3efe8; }
.poi-row { display: flex; align-items: center; gap: .4rem; }
.poi-name { flex: 1; font-weight: 600; color: var(--ink); font-size: .9rem; }
.poi-go {
  background: none; border: 1px solid var(--accent); color: var(--accent);
  border-radius: 6px; padding: .12rem .6rem; font-size: .76rem; font-weight: 600; cursor: pointer;
}
.poi-go:hover { background: var(--accent); color: #fff; }
.poi-edit, .poi-del { color: #b3b0a8; font-size: .9rem; padding: 0 .1rem; }
.poi-edit:hover { color: var(--accent); }
.poi-del:hover { color: var(--bad); }

/* slide-down editor */
.poi-edit-wrap { max-height: 0; overflow: hidden; transition: max-height .25s ease; }
.poi-edit-wrap.open { max-height: 360px; }
.poi-edit-form { display: grid; gap: .3rem; padding: .5rem 0 .35rem; }
.edit-label { font-size: .72rem; color: #999; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.poi-edit-form input, .poi-edit-form textarea {
  width: 100%; padding: .4rem .5rem; border: 1px solid #d8d3ca; border-radius: 6px; font: inherit; font-size: .85rem;
}
.poi-edit-form textarea { min-height: 3.2em; resize: vertical; }
.edit-actions { display: flex; gap: .5rem; align-items: center; margin-top: .15rem; }
.edit-actions button[type="submit"] { background: var(--accent); color: #fff; border: 0; border-radius: 6px; padding: .3rem .8rem; cursor: pointer; font-size: .82rem; }

/* discovery (category search) pins */
.disc-icon { background: none; border: 0; }
.disc-pin {
  width: 28px; height: 28px; border-radius: 50%;
  background: #fff; border: 1.5px solid #6b6b72; color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  line-height: 1; box-shadow: 0 1px 5px rgba(0,0,0,.25);
}
.disc-pin .ico { width: 16px; height: 16px; }
.disc-add {
  display: inline-block; margin-top: .4rem;
  background: var(--accent); color: #fff; border: 0; border-radius: 6px;
  padding: .28rem .75rem; cursor: pointer; font-size: .82rem; font-weight: 600;
}
.disc-add:hover { filter: brightness(1.05); }

/* popups */
.popup strong { font-size: .98rem; }
.popup-meta { display: flex; align-items: center; gap: .35rem; color: #555; font-size: .82rem; margin: .25rem 0; }
.popup-addr { color: #888; font-size: .78rem; margin-bottom: .35rem; }
.popup-notes { font-size: .85rem; margin-bottom: .35rem; }
.popup-like { margin-top: .15rem; }
.popup-maps {
  display: inline-block; margin-top: .45rem; font-size: .82rem; font-weight: 600;
  color: #1a73e8; text-decoration: none;
}
.popup-maps:hover { text-decoration: underline; }
.poi-delete { color: var(--bad); font-size: .82rem; }

/* interest "likes" */
.like-btn {
  background: none; border: 1px solid #e2c0c8; color: #b06; border-radius: 999px;
  padding: .08rem .5rem; font-size: .78rem; line-height: 1.4; cursor: pointer; white-space: nowrap;
}
.like-btn:hover { background: #fbeef1; border-color: var(--accent); }
.like-btn.liked { background: var(--accent); border-color: var(--accent); color: #fff; }
.like-count { color: var(--accent); font-size: .78rem; font-weight: 600; white-space: nowrap; }

/* topbar notes button */
.notes-btn {
  background: var(--accent); border: 0; border-radius: 999px;
  padding: .3rem .9rem; font-size: .85rem; font-weight: 600; cursor: pointer; color: #fff;
}
.notes-btn:hover { filter: brightness(1.05); }

/* search result actions */
.result-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.result-base {
  background: none; border: 1px solid #b58a00; color: #8a6d00; border-radius: 6px;
  padding: .2rem .6rem; cursor: pointer; font-size: .85rem;
}
.result-base:hover { background: #b58a00; color: #fff; }

/* bases panel */
.bases-panel { margin-top: 1.5rem; }
.bases-panel h2 { font-size: 1rem; display: flex; align-items: center; gap: .5rem; }
.base-item { border-bottom: 1px solid #f3efe8; padding: .35rem 0; }
.base-row { display: flex; align-items: center; gap: .4rem; }
.base-name { flex: 1; font-weight: 600; font-size: .9rem; }
.base-opt {
  background: none; border: 1px solid var(--accent); color: var(--accent);
  border-radius: 6px; padding: .12rem .6rem; font-size: .76rem; font-weight: 600; cursor: pointer;
}
.base-opt:hover:not(:disabled) { background: var(--accent); color: #fff; }
.base-opt:disabled { opacity: .4; cursor: not-allowed; }
.base-del { color: #b3b0a8; font-size: .9rem; }
.base-del:hover { color: var(--bad); }

.route-info { margin: .4rem 0 .25rem; padding: .5rem .6rem; background: #eef2ff; border-radius: 8px; }
.route-totals { font-weight: 700; font-size: .85rem; color: #1d4ed8; }
.route-list { margin: .35rem 0; padding-left: 1.4rem; font-size: .85rem; }
.route-list li { margin: .12rem 0; display: flex; align-items: center; gap: .4rem; }
.route-list li span { flex: 1; }
.route-stop-del { color: #9aa3c0; font-size: .8rem; }
.route-stop-del:hover { color: var(--bad); }
.route-excluded { font-size: .78rem; color: #777; margin: .3rem 0; }
.route-restore {
  background: #fff; border: 1px dashed #c3c9da; border-radius: 999px;
  padding: .05rem .5rem; margin: .1rem .15rem 0 0; font-size: .76rem; color: #555; cursor: pointer;
}
.route-restore:hover { border-color: #1d4ed8; color: #1d4ed8; }
.route-clear { font-size: .8rem; }
.route-remove {
  display: inline-block; margin-top: .4rem;
  background: var(--bad); color: #fff; border: 0; border-radius: 6px;
  padding: .25rem .7rem; cursor: pointer; font-size: .8rem; font-weight: 600;
}
.route-remove:hover { filter: brightness(1.05); }

/* base + numbered route markers */
.base-icon, .num-icon { background: none; border: 0; }
.base-pin {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; line-height: 1; color: #ffd23f; background: var(--ink);
  border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.4);
}
.num-pin {
  width: 26px; height: 26px; border-radius: 50%;
  background: #1d4ed8; color: #fff; border: 2px solid #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; box-shadow: 0 1px 5px rgba(0,0,0,.35);
}

/* "locate me" map control */
.locate-btn {
  width: 34px; height: 34px; background: #fff; border: 0; cursor: pointer;
  display: flex; align-items: center; justify-content: center; color: #444;
}
.locate-btn:hover { background: #f4f4f4; }
.locate-btn.active { color: #1d72e8; }
.locate-btn svg { width: 18px; height: 18px; }

/* "back to base" — bold, stand-out map button */
.btb-btn {
  display: inline-flex; align-items: center; gap: .4rem;
  background: var(--accent); color: #fff; border: 0; border-radius: 8px;
  padding: .45rem .7rem; font: inherit; font-size: .85rem; font-weight: 700;
  cursor: pointer; box-shadow: 0 1px 6px rgba(0,0,0,.4); white-space: nowrap;
}
.btb-btn:hover { filter: brightness(1.05); }
.btb-btn svg { width: 16px; height: 16px; flex: 0 0 auto; }
.btb-btn.busy { opacity: .6; pointer-events: none; }

/* notes overlay / modal */
.overlay {
  position: fixed; inset: 0; z-index: 1500;
  background: rgba(27,27,31,.45);
  display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.overlay[hidden] { display: none; }
.overlay-card {
  background: #fff; border-radius: 14px; box-shadow: 0 16px 50px rgba(0,0,0,.25);
  width: min(94vw, 640px); max-height: 88vh; padding: 1.5rem;
  display: flex; flex-direction: column;
}
.overlay-head { display: flex; align-items: center; margin-bottom: .75rem; }
.overlay-head h2 { font-size: 1.2rem; margin: 0; flex: 1; }
.overlay-x { background: none; border: 0; font-size: 1.1rem; color: #999; cursor: pointer; line-height: 1; }
.overlay-x:hover { color: var(--accent); }
.notes-meta { color: #999; font-size: .8rem; margin: 0 0 .6rem; }
#notes-body {
  flex: 1; min-height: 50vh; resize: vertical;
  padding: .8rem; border: 1px solid #d8d3ca; border-radius: 8px;
  font: inherit; font-size: .95rem; line-height: 1.5;
}
#notes-body:focus { outline: 2px solid var(--accent); border-color: transparent; }
.overlay-actions { display: flex; align-items: center; gap: .75rem; margin-top: .85rem; }
.overlay-actions .hint { flex: 1; margin: 0; }
.btn-primary {
  background: var(--accent); color: #fff; border: 0; border-radius: 8px;
  padding: .5rem 1.1rem; font-weight: 600; font-size: .92rem; cursor: pointer;
}
.btn-primary:hover { filter: brightness(1.05); }

/* ------------------------------------------------------------------ mobile */
@media (max-width: 768px) {
  .menu-btn { display: inline-flex; align-items: center; justify-content: center; }
  .topbar { gap: .55rem; padding: .55rem .7rem; }
  .topbar strong { font-size: 1rem; }
  .notes-btn { padding: .28rem .7rem; }

  /* sidebar becomes an overlay drawer that slides in over the full-screen map */
  .layout { position: relative; }
  .sidebar {
    position: absolute; top: 0; left: 0; bottom: 0;
    width: min(86vw, 340px); flex-basis: auto; border-right: 0;
    transform: translateX(-100%); transition: transform .25s ease;
    z-index: 1200; box-shadow: 2px 0 18px rgba(0,0,0,.28);
  }
  body.drawer-open .sidebar { transform: translateX(0); }

  .scrim { position: absolute; inset: 0; z-index: 1100; background: rgba(0,0,0,.35); }
  body.drawer-open .scrim { display: block; }
}

@media (max-width: 460px) {
  .topbar .jp, .who-name { display: none; }
  .notes-btn { font-size: .8rem; }
  .topbar strong { font-size: .95rem; }
}
