:root {
  --bg: #f7f5f2;          /* warm paper rather than cold grey */
  --panel: #fffefc;
  --ink: #23201f;
  --muted: #7a7370;
  --line: #e6e1da;
  --accent: #2b2724;
  --radius: 10px;
  --topbar: 56px;
  --tone: rgba(35, 32, 31, .05);   /* manga screentone dots */
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
}

/* Serif for headings — a little ink-and-paper against the sans body text. */
h1 {
  font-family: "Iowan Old Style", Georgia, "Hiragino Mincho ProN",
    "Yu Mincho", serif;
  font-weight: 600;
  letter-spacing: .01em;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background-color: var(--bg);
  background-image: radial-gradient(var(--tone) 1px, transparent 1px);
  background-size: 7px 7px;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* Small kana caption that sits under or beside a title. */
.kana {
  font-size: .62em;
  letter-spacing: .18em;
  color: var(--muted);
  font-weight: 400;
  font-family: "Hiragino Sans", "Yu Gothic", sans-serif;
}

/* A person's mark, drawn in their colour. */
.emblem {
  color: var(--who, var(--muted));
  font-size: 1.05em;
  line-height: 1;
}

button, input, select { font: inherit; color: inherit; }

button {
  cursor: pointer;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 12px;
}
button:hover { border-color: #c9ced6; }
button.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 600;
}
button.primary:hover { background: #33363c; }
button.primary:disabled { opacity: .55; cursor: default; }
button.danger { color: #c62828; }

input, select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
input:focus, select:focus { outline: 2px solid #b9c6ff; outline-offset: 1px; }

/* --- login ---------------------------------------------------------------- */

/* A daybreak sky: pale gold at the horizon into a soft blue overhead. */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(120% 80% at 50% 100%, #fdeee2 0%, transparent 55%),
    linear-gradient(180deg, #dfe9f3 0%, #f4eee9 55%, #fbf6f1 100%);
  padding: 24px;
}
.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 40px 36px;
  max-width: 380px;
  width: 100%;
  text-align: center;
  box-shadow: 0 14px 40px rgba(60, 45, 40, .10);
}
.login-pin { font-size: 40px; }
.login-card h1 { margin: 8px 0 2px; font-size: 27px; }
.login-card .kana { margin: 0 0 14px; font-size: 12px; }
.login-sub { margin: 0 0 26px; color: var(--muted); }
.login-error {
  background: #fff4f4;
  border: 1px solid #f3cfcf;
  color: #a12b2b;
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 14px;
  text-align: left;
  margin-bottom: 20px;
}
.google-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 18px;
  font-weight: 600;
  background: #fff;
}
.google-btn:hover { border-color: #c9ced6; background: #fafbfc; }

/* --- app shell ------------------------------------------------------------ */

.topbar {
  height: var(--topbar);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { margin: 0; font-size: 18px; display: flex; align-items: baseline; gap: 10px; }
.topbar .kana { font-size: 11px; }
.who { display: flex; align-items: center; gap: 7px; font-size: 14px; }
.who-name { font-weight: 600; }
.signout { color: var(--muted); text-decoration: none; margin-left: 6px; }
.signout:hover { color: var(--ink); text-decoration: underline; }
.dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  display: inline-block;
  background: var(--who, #999);
}

.layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  height: calc(100vh - var(--topbar));
}
.sidebar {
  overflow-y: auto;
  padding: 14px;
  /* Screentone behind the panel colour, so the list reads as ink on paper. */
  background-color: var(--panel);
  background-image: radial-gradient(var(--tone) 1px, transparent 1px);
  background-size: 7px 7px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#map { width: 100%; height: 100%; background: #e8eaed; }

/* Control pushed into the map's own top-right slot. */
.map-ctrl {
  margin: 10px 10px 0 0;
  padding: 8px 13px;
  font-size: 13px;
  font-weight: 600;
  border: 0;
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 2px 6px rgba(60, 45, 40, .3);
}
.map-ctrl:hover { background: #f4efe9; }
.map-ctrl:disabled { color: #b3aca7; cursor: default; background: var(--panel); }
.map-ctrl span { margin-right: 4px; opacity: .65; }

/* --- filters -------------------------------------------------------------- */

.seg { display: flex; gap: 6px; }
.seg button {
  flex: 1;
  padding: 6px 4px;
  font-size: 13px;
  border-bottom: 3px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: background .15s ease, color .15s ease;
}
.seg button[data-person]:not([data-person="all"]) { border-bottom-color: var(--who); }
.seg button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.seg button.on .emblem { color: #fff; }

.types { display: flex; flex-wrap: wrap; gap: 6px; }
.chip input { display: none; }
.chip span {
  display: inline-block;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 13px;
  cursor: pointer;
  color: var(--muted);
  user-select: none;
}
.chip input:checked + span {
  background: #eef1f6;
  border-color: #c9ced6;
  color: var(--ink);
}

/* --- form ----------------------------------------------------------------- */

#place-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #fbfcfd;
}
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; font-weight: 600; color: var(--muted); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hint { margin: 0; font-size: 12px; color: var(--muted); }
.hint.warn { color: #a15c2b; }
.coords { margin: 0; font-size: 12px; color: var(--muted); }
.form-error {
  margin: 0;
  font-size: 13px;
  color: #a12b2b;
  background: #fff4f4;
  border-radius: 6px;
  padding: 6px 8px;
}
.actions { display: flex; gap: 8px; }
.actions button { flex: 1; }

/* Google's autocomplete widget and its dropdown */
gmp-place-autocomplete { width: 100%; }
.pac-container { z-index: 10000; }

/* --- place list ----------------------------------------------------------- */

.readonly-note {
  margin: 0;
  padding: 9px 11px;
  font-size: 12.5px;
  color: var(--muted);
  background: #f3efe9;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.count { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.places { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.place {
  border: 1px solid var(--line);
  border-left: 4px solid var(--who);
  border-radius: var(--radius);
  padding: 10px 12px;
  cursor: pointer;
  background: var(--panel);
  transition: transform .12s ease, box-shadow .12s ease;
}
.place:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(60, 45, 40, .09);
}
.place-head { display: flex; align-items: baseline; gap: 8px; }
.glyph { font-size: 15px; }
.place-name { font-weight: 600; }
.place-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}
.owner { display: inline-flex; align-items: center; gap: 4px; }
.addr { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.notes { margin: 6px 0 0; font-size: 13px; }
.place-actions { display: flex; gap: 8px; margin-top: 8px; align-items: center; }
.place-actions a, .place-actions button {
  font-size: 12px;
  padding: 3px 8px;
  text-decoration: none;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}
.place-actions a:hover, .place-actions button:hover { color: var(--ink); }

/* Somewhere we've already been: fades back, but stays readable. */
.place.is-seen { border-left-color: #a8a29e; opacity: .62; }
.place.is-seen .place-name { text-decoration: line-through; text-decoration-thickness: 1px; }
.place.is-seen:hover { opacity: 1; }

.seen-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.seen-toggle input { width: auto; margin: 0; accent-color: #7a7370; cursor: pointer; }
.seen-toggle:hover { color: var(--ink); }
.seen-tag { margin-left: auto; font-size: 12px; color: var(--muted); }

/* --- info window ---------------------------------------------------------- */

.iw { font-size: 14px; max-width: 240px; }
.iw-meta { font-size: 12px; margin: 2px 0 6px; font-weight: 600; }
.iw p { margin: 0 0 6px; }

/* --- small screens -------------------------------------------------------- */

@media (max-width: 780px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: 45vh 1fr;
    height: calc(100dvh - var(--topbar));
  }
  .sidebar { order: 2; border-right: 0; border-top: 1px solid var(--line); }
  #map { order: 1; }
}
