:root {
  --bg: #fbfaf7; --panel: #fff; --ink: #1b1b1a; --muted: #6b6a66;
  --line: #e2dfd8; --accent: #2f6f4e; --accent-soft: #e6f0ea; --warn: #a8632a;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16171a; --panel: #1e2024; --ink: #e8e6e1; --muted: #93918b;
    --line: #2e3137; --accent: #67b98d; --accent-soft: #21332a; --warn: #d3945c;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.6 system-ui, "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  -webkit-text-size-adjust: 100%;
}
header {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel);
  position: sticky; top: 0; z-index: 10;
}
h1 { font-size: 17px; margin: 0; letter-spacing: .08em; }
#whoami { margin-left: auto; color: var(--muted); font-size: 13px; }
#whoami button { margin-left: 8px; }

nav#tabs { display: flex; gap: 2px; padding: 8px 16px 0; background: var(--panel); border-bottom: 1px solid var(--line); }
nav#tabs button {
  border: 1px solid transparent; border-bottom: none; background: none; color: var(--muted);
  padding: 7px 16px; border-radius: 8px 8px 0 0; cursor: pointer; font-size: 14px;
}
nav#tabs button.on { background: var(--bg); border-color: var(--line); color: var(--ink); font-weight: 600; margin-bottom: -1px; }

main { padding: 16px; max-width: 900px; margin: 0 auto; }
.bar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.bar span { color: var(--muted); font-size: 13px; margin-left: auto; }
input[type=text], input:not([type]), select {
  padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel); color: var(--ink); font: inherit; font-size: 14px;
}
#search { flex: 1 1 260px; }
button { font: inherit; }

details.pref { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 8px; background: var(--panel); overflow: hidden; }
details.pref > summary {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; cursor: pointer;
  list-style: none; font-weight: 600;
}
details.pref > summary::-webkit-details-marker { display: none; }
summary .count { margin-left: auto; font-weight: 400; color: var(--muted); font-size: 13px; }
summary .track { width: 70px; height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; flex: none; }
summary .track i { display: block; height: 100%; background: var(--accent); }

.spot { display: flex; align-items: center; gap: 10px; padding: 7px 14px 7px 16px; border-top: 1px solid var(--line); }
.spot label { display: flex; align-items: center; gap: 10px; flex: 1; cursor: pointer; }
.spot input { width: 17px; height: 17px; accent-color: var(--accent); flex: none; }
.spot .city { color: var(--muted); font-size: 12px; margin-left: auto; padding-left: 10px; flex: none; }
.spot.done { background: var(--accent-soft); }
.spot .tag { font-size: 11px; padding: 1px 6px; border-radius: 4px; border: 1px solid var(--line); color: var(--muted); flex: none; }
.spot .tag.solo { color: var(--warn); border-color: var(--warn); }

table#ranking { border-collapse: collapse; width: 100%; margin-bottom: 28px; }
#ranking th, #ranking td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: left; }
#ranking th { color: var(--muted); font-weight: 500; font-size: 13px; }
#ranking td.num { text-align: right; font-variant-numeric: tabular-nums; }
#ranking tr.me td { font-weight: 700; }

.prefbar { display: flex; align-items: center; gap: 10px; padding: 4px 0; font-size: 13px; }
.prefbar b { width: 4.5em; font-weight: 400; }
.prefbar .track { flex: 1; height: 7px; background: var(--line); border-radius: 4px; overflow: hidden; }
.prefbar .track i { display: block; height: 100%; background: var(--accent); }
.prefbar .n { width: 5.5em; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

#whoami button { background: none; color: var(--muted); border-color: var(--line); font-size: 12px; padding: 3px 10px; }
.empty { color: var(--muted); padding: 30px 0; text-align: center; }

/* --- 白地図 --- */
:root { --map-base: #f2efe8; --map-line: #b9b4a8; }
@media (prefers-color-scheme: dark) { :root { --map-base: #262a2f; --map-line: #4a4f57; } }

.mapwrap {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 10px 6px; margin-bottom: 16px;
}
#map { display: block; width: 100%; max-width: min(100%, 66vh); height: auto;
       aspect-ratio: 800 / 806; margin: 0 auto; }
#map .pref {
  stroke: var(--map-line); stroke-width: 1.1; stroke-linejoin: round;
  cursor: pointer; transition: opacity .12s, stroke .12s;
  vector-effect: non-scaling-stroke;
}
#map .pref.dim { opacity: .38; }
/* 強調の輪郭は最前面の専用パスで描く。県のパスに直接かけると隣県が上書きして太さが揃わない */
#map .hl {
  fill: none; pointer-events: none; stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}
#map .hl-sel   { stroke: var(--ink); stroke-width: 2.2; }
#map .hl-hover { stroke: var(--ink); stroke-width: 1.8; }
#map .okibox { fill: none; stroke: var(--line); stroke-width: 1; stroke-dasharray: 4 3; }

.maplegend {
  display: flex; align-items: center; gap: 10px;
  font-size: 12px; color: var(--muted); padding-top: 4px;
}
.maplegend .scale { margin-left: auto; display: flex; align-items: center; gap: 3px; }
.maplegend .scale i { width: 13px; height: 9px; border-radius: 2px; border: 1px solid var(--map-line); }
.maplegend .scale i:nth-child(1) { background: color-mix(in srgb, var(--accent) 6%,  var(--map-base)); }
.maplegend .scale i:nth-child(2) { background: color-mix(in srgb, var(--accent) 30%, var(--map-base)); }
.maplegend .scale i:nth-child(3) { background: color-mix(in srgb, var(--accent) 53%, var(--map-base)); }
.maplegend .scale i:nth-child(4) { background: color-mix(in srgb, var(--accent) 77%, var(--map-base)); }
.maplegend .scale i:nth-child(5) { background: color-mix(in srgb, var(--accent) 100%, var(--map-base)); }

#clear-pref {
  padding: 6px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel); color: var(--ink); cursor: pointer; font-size: 13px;
}
.credit { color: var(--muted); font-size: 11px; margin-top: 26px; }

/* --- 訪問日と廃止駅 --- */
.datefield { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.datefield input { padding: 6px 8px; }
.spot .visitdate {
  padding: 2px 6px; font-size: 12px; border-radius: 6px; flex: none;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.spot.retired label > span:not(.tag) { text-decoration: line-through; text-decoration-color: var(--muted); }
.spot.retired { opacity: .8; }
.spot .tag.ret { color: var(--warn); border-color: var(--warn); }


/* --- 登録・グループ --- */
.note { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.ok {
  margin: 0; padding: 8px 10px; border-radius: 8px; font-size: 13px;
  color: var(--accent); border: 1px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}
dialog .links { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
dialog h2 { margin: 0 0 12px; font-size: 16px; }
dialog label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
dialog hr { border: none; border-top: 1px solid var(--line); margin: 6px 0; width: 100%; }

#group-btn {
  padding: 5px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink); cursor: pointer; font-size: 13px;
}
#group-list { display: flex; flex-direction: column; gap: 2px; }
.grouprow {
  display: flex; flex-direction: row; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 8px; cursor: pointer; color: var(--ink); font-size: 14px;
}
.grouprow:hover { background: var(--accent-soft); }
.grouprow input { accent-color: var(--accent); }
.grouprow .count { margin-left: auto; color: var(--muted); font-size: 12px; }
.grouprow code {
  font-size: 12px; padding: 1px 6px; border-radius: 4px;
  border: 1px solid var(--line); color: var(--muted);
}

/* --- ログイン画面 ---
   map.osato-acid.com と同じ作り。全画面の覆い、角形のカード、Google 系の配色。
   色はトークン越しに引き、暗い配色でも破綻しないようにしてある。 */
:root { --lg-bg: #e8eaed; --lg-card: #fff; --lg-line: #dadce0;
        --lg-ink: #202124; --lg-sub: #5f6368; --lg-link: #1a73e8; --lg-danger: #d93025; }
@media (prefers-color-scheme: dark) {
  :root { --lg-bg: #16171a; --lg-card: #1e2024; --lg-line: #3a3f46;
          --lg-ink: #e8e6e1; --lg-sub: #93918b; --lg-link: #8ab4f8; --lg-danger: #f28b82; }
}

#login-view[hidden] { display: none !important; }
#login-view {
  position: fixed; inset: 0; z-index: 90; background: var(--lg-bg);
  display: flex; align-items: center; justify-content: center;
}
#login-card, #signup-card, #forgot-card {
  background: var(--lg-card); width: 320px; max-width: calc(100vw - 48px);
  padding: 28px 28px 24px; box-shadow: 0 1px 4px rgba(0,0,0,.3);
  display: flex; flex-direction: column; gap: 12px;
}
#login-card[hidden], #signup-card[hidden], #forgot-card[hidden] { display: none !important; }

.lg-title { font-size: 20px; color: var(--lg-ink); margin-bottom: 4px; }
.lg-sub { font-size: 12px; color: var(--lg-sub); line-height: 1.5; }

#login-view input {
  border: 1px solid var(--lg-line); border-radius: 0; padding: 9px 10px;
  font-size: 14px; outline: none; background: var(--lg-card); color: var(--lg-ink);
  font-family: inherit;
}
#login-view input:focus { border-color: var(--lg-link); }

/* 高さを確保しておく。文言が出たときに下の要素がずれない */
.lg-error { color: var(--lg-danger); font-size: 12px; min-height: 14px; line-height: 1.4; }

#login-view button[type=submit] {
  background: var(--lg-link); color: #fff; border: none; border-radius: 0;
  padding: 9px 0; font-size: 14px; cursor: pointer; font-family: inherit;
}
#login-view button[type=submit]:disabled { opacity: .55; cursor: default; }

#login-view .lg-link {
  background: none; border: none; color: var(--lg-link); font-size: 13px;
  cursor: pointer; padding: 2px 0; text-align: center; font-family: inherit;
}

/* ログイン中は後ろのアプリを見せない */
html.login-open header, html.login-open nav#tabs, html.login-open main { display: none !important; }

/* --- グループの選択（ログイン画面とは別。アプリ内の小窓） --- */
dialog {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  padding: 22px; box-shadow: 0 1px 4px rgba(0,0,0,.3);
}
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog form { display: flex; flex-direction: column; gap: 10px; min-width: 280px; }
dialog input {
  padding: 7px 10px; border: 1px solid var(--line); background: var(--bg);
  color: var(--ink); font: inherit; font-size: 14px;
}
dialog button[type=button] {
  padding: 7px 14px; border: 1px solid var(--accent);
  background: var(--accent); color: #fff; cursor: pointer; font: inherit; font-size: 13px;
}
