/* 旅のしおりと同じ配色・書体。2つのサイトが並んで見えるように */
/* hidden 属性は必ず効かせる。
   ブラウザ標準の [hidden]{display:none} は、こちらが書いた
   .gate{display:grid} や .viewsw{display:flex} と同じ強さなので、
   後から読まれるこちらに負けてしまう（要素が消えない）。 */
[hidden] { display: none !important; }

:root {
  --paper:     #f4f6f3;
  --surface:   #ffffff;
  --surface-2: #eceff0;
  --ink:       #1b2220;
  --ink-soft:  #5e6a66;
  --ink-faint: #8d9893;
  --rule:      #d5dbd6;
  --rule-firm: #aeb7b2;
  --ai:        #1f3a5f;
  --ai-soft:   #e3eaf2;
  --on-ai:     #ffffff;
  --shu:       #a8402c;
  --shu-soft:  #f7e6e1;

  /* 区分の色。ここを変えればピンと凡例と一覧の印が全部ついてくる */
  --c-spot:    #a8402c;
  --c-lodging: #1f3a5f;
  --c-onsen:   #c2701c;
  --c-food:    #3f6b46;
  --c-station: #5a6b7a;

  --f-body: "BIZ UDPGothic", "Hiragino Sans", "Yu Gothic", "Meiryo", system-ui, sans-serif;
  --f-mono: "BIZ UDGothic", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --fs-body: 15px;
  --fs-small: 13px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:     #14181a;
    --surface:   #1c2225;
    --surface-2: #232b2f;
    --ink:       #e4e8e4;
    --ink-soft:  #a6b0ad;
    --ink-faint: #7d8886;
    --rule:      #2c3438;
    --rule-firm: #3f4a4f;
    --ai:        #8fb3d9;
    --ai-soft:   #1f2a35;
    --on-ai:     #0f1416;
    --shu:       #e2907a;
    --shu-soft:  #33211d;
    --c-spot:    #e2907a;
    --c-lodging: #8fb3d9;
    --c-onsen:   #d9a05c;
    --c-food:    #7fae86;
    --c-station: #93a4b2;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper:     #14181a;
  --surface:   #1c2225;
  --surface-2: #232b2f;
  --ink:       #e4e8e4;
  --ink-soft:  #a6b0ad;
  --ink-faint: #7d8886;
  --rule:      #2c3438;
  --rule-firm: #3f4a4f;
  --ai:        #8fb3d9;
  --ai-soft:   #1f2a35;
  --on-ai:     #0f1416;
  --shu:       #e2907a;
  --shu-soft:  #33211d;
  --c-spot:    #e2907a;
  --c-lodging: #8fb3d9;
  --c-onsen:   #d9a05c;
  --c-food:    #7fae86;
  --c-station: #93a4b2;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: var(--fs-body);
  line-height: 1.6;
  display: flex;
  flex-direction: column;
}

/* ===== 上の帯 ===== */
.top {
  flex: 0 0 auto;
  background: var(--surface);
  border-bottom: 1px solid var(--rule-firm);
  padding-block: 8px;
  padding-left: max(14px, env(safe-area-inset-left, 0px));
  padding-right: max(14px, env(safe-area-inset-right, 0px));
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.brand { font-weight: 700; letter-spacing: .04em; white-space: nowrap; }
.brand small { display: block; font-size: 10.5px; font-weight: 400; color: var(--ink-faint); letter-spacing: .08em; }
.top-spacer { flex: 1 1 auto; }

.viewsw { display: flex; border: 1px solid var(--rule-firm); border-radius: 3px; overflow: hidden; }
.viewsw button {
  font: inherit; font-size: var(--fs-small);
  padding: 6px 12px; border: 0; background: var(--surface); color: var(--ink-soft); cursor: pointer;
  border-right: 1px solid var(--rule);
}
.viewsw button:last-child { border-right: 0; }
.viewsw button[aria-pressed="true"] { background: var(--ai); color: var(--on-ai); font-weight: 700; }

.btn {
  font: inherit; font-size: var(--fs-small);
  padding: 6px 12px; border: 1px solid var(--rule-firm); border-radius: 3px;
  background: var(--surface); color: var(--ink); cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--ai); border-color: var(--ai); color: var(--on-ai); font-weight: 700; }
.btn-primary:hover { filter: brightness(1.12); background: var(--ai); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-soft); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn:disabled { opacity: .4; cursor: default; }
.btn-sm { padding: 3px 8px; font-size: 12px; }

/* ===== 目線の帯（共有のときだけ色が変わる） ===== */
.stance {
  flex: 0 0 auto;
  font-size: var(--fs-small);
  padding-block: 6px;
  padding-left: max(14px, env(safe-area-inset-left, 0px));
  padding-right: max(14px, env(safe-area-inset-right, 0px));
  background: var(--ai-soft);
  color: var(--ai);
  border-bottom: 1px solid var(--rule);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.stance.share { background: var(--shu-soft); color: var(--shu); }
.stance b { font-weight: 700; }
.stance .seed { color: var(--ink-faint); font-size: 11.5px; }

/* ===== 本体 ===== */
.main { flex: 1 1 auto; display: flex; min-height: 0; }
.side {
  flex: 0 0 390px; min-width: 0; display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--rule-firm);
}
.mapwrap { flex: 1 1 auto; min-width: 0; position: relative; }
#map { position: absolute; inset: 0; background: var(--surface-2); }

/* ===== 絞り込み ===== */
.filters {
  flex: 0 0 auto; padding: 10px 12px; border-bottom: 1px solid var(--rule);
  display: flex; flex-direction: column; gap: 8px;
}
.search {
  font: inherit; font-size: var(--fs-small); width: 100%;
  padding: 7px 10px; border: 1px solid var(--rule-firm); border-radius: 3px;
  background: var(--surface); color: var(--ink);
}
.search:focus { outline: 2px solid var(--ai); outline-offset: -2px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.chips-label { font-size: 11px; color: var(--ink-faint); letter-spacing: .06em; margin-right: 2px; }
.chip {
  font: inherit; font-size: 12px; line-height: 1;
  padding: 5px 9px; border: 1px solid var(--rule); border-radius: 999px;
  background: var(--surface); color: var(--ink-soft); cursor: pointer;
}
.chip:hover { border-color: var(--rule-firm); color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--ai); border-color: var(--ai); color: var(--on-ai); font-weight: 700; }
.chip .n { font-family: var(--f-mono); font-size: 10.5px; opacity: .75; margin-left: 3px; }
.chip.cat[aria-pressed="true"] { background: var(--cc); border-color: var(--cc); color: #fff; }

/* ===== 一覧 ===== */
.listhead {
  flex: 0 0 auto; display: flex; align-items: center; gap: 8px;
  padding: 7px 12px; border-bottom: 1px solid var(--rule); background: var(--surface-2);
  font-size: 11.5px; color: var(--ink-soft);
}
.listhead b { color: var(--ink); font-family: var(--f-mono); }
.list { flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; }
.row {
  display: grid; grid-template-columns: 24px 26px 1fr auto; gap: 8px; align-items: start;
  padding: 9px 12px; border-bottom: 1px solid var(--rule); cursor: pointer;
}
.row:hover, .row.hot { background: var(--ai-soft); }
.row.on { background: var(--ai-soft); box-shadow: inset 3px 0 0 var(--ai); }
.row input[type=checkbox] { margin: 3px 0 0; width: 16px; height: 16px; accent-color: var(--ai); }
.row-name { font-weight: 700; line-height: 1.4; overflow-wrap: anywhere; }
.row-meta { font-size: 11.5px; color: var(--ink-soft); font-family: var(--f-mono); margin-top: 1px; }
.row-memo { font-size: 12px; color: var(--ink-soft); margin-top: 3px; overflow-wrap: anywhere; }
.row-right { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.empty { padding: 26px 16px; text-align: center; color: var(--ink-soft); font-size: var(--fs-small); }
.empty b { display: block; color: var(--ink); margin-bottom: 4px; }

/* ===== 印 ===== */
.pill {
  font-size: 10.5px; line-height: 1; padding: 3px 6px; border-radius: 2px;
  border: 1px solid currentColor; white-space: nowrap; font-family: var(--f-mono);
}
.pill-rank { color: var(--c-spot); font-weight: 700; }
.pill-new { color: var(--shu); background: var(--shu-soft); }
.pill-visit { color: var(--ink-faint); }

/* ===== ピン ===== */
.pin {
  width: 26px; height: 26px; display: grid; place-items: center;
  font-family: var(--f-mono); font-size: 12px; font-weight: 700; line-height: 1;
  color: #fff; background: var(--pc); border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.45);
}
.pin.k-spot    { border-radius: 50%; }
.pin.k-onsen   { border-radius: 50% 50% 50% 4px; }
.pin.k-lodging { border-radius: 3px; clip-path: polygon(50% 0, 100% 32%, 100% 100%, 0 100%, 0 32%); }
.pin.k-food    { border-radius: 5px; }
.pin.k-station { border-radius: 1px; }
/* 未訪問は中抜き */
.pin.un { background: var(--surface); color: var(--pc); border-color: var(--pc); }
.pin.sel { outline: 3px solid var(--ai); outline-offset: 1px; }

.legend {
  position: absolute; left: 10px; bottom: 10px; z-index: 500;
  background: var(--surface); border: 1px solid var(--rule-firm); border-radius: 3px;
  padding: 7px 9px; font-size: 11.5px; color: var(--ink-soft);
  display: flex; flex-direction: column; gap: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,.14);
}
.legend-row { display: flex; align-items: center; gap: 6px; }
.legend .sw {
  width: 15px; height: 15px; flex: 0 0 auto; background: var(--pc); border: 1.5px solid var(--surface);
  display: grid; place-items: center; font-family: var(--f-mono); font-size: 8px; color: #fff; font-weight: 700;
}
.legend .sw.k-spot { border-radius: 50%; }
.legend .sw.k-onsen { border-radius: 50% 50% 50% 3px; }
.legend .sw.k-lodging { clip-path: polygon(50% 0, 100% 32%, 100% 100%, 0 100%, 0 32%); }
.legend .sw.k-food { border-radius: 3px; }
.legend .sw.k-station { border-radius: 1px; }
.legend .note { color: var(--ink-faint); font-size: 10.5px; border-top: 1px solid var(--rule); padding-top: 4px; }

.maptools {
  position: absolute; right: 10px; top: 10px; z-index: 500; display: flex; gap: 4px;
}
.maptools .btn { box-shadow: 0 2px 8px rgba(0,0,0,.14); }

/* ===== 下のバー（選択・共有） ===== */
.actionbar {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 900;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  display: flex; align-items: center; gap: 8px;
  padding: 7px 8px 7px 15px;
  background: var(--surface); border: 1px solid var(--rule-firm); border-radius: 999px;
  box-shadow: 0 6px 24px rgba(0,0,0,.2);
  max-width: calc(100vw - 24px);
}
.actionbar span { font-size: var(--fs-small); color: var(--ink-soft); white-space: nowrap; }

/* ===== 覆い（旅行の追加・スポットの追加・共有リンク） ===== */
.veil {
  position: fixed; inset: 0; z-index: 1000; background: rgba(16,22,24,.5);
  display: grid; place-items: center;
  padding: max(16px, env(safe-area-inset-left, 0px));
}
.sheet {
  background: var(--surface); border: 1px solid var(--rule-firm); border-radius: 4px;
  width: min(460px, 100%); max-height: min(80vh, 620px); overflow-y: auto;
  padding: 16px; display: flex; flex-direction: column; gap: 11px;
  box-shadow: 0 12px 40px rgba(0,0,0,.3);
}
.sheet h2 { margin: 0; font-size: 16px; letter-spacing: .02em; }
.sheet p { margin: 0; font-size: var(--fs-small); color: var(--ink-soft); }
.field { display: flex; flex-direction: column; gap: 3px; }
.field label { font-size: 11px; color: var(--ink-faint); letter-spacing: .06em; }
.field input, .field textarea, .field select {
  font: inherit; font-size: var(--fs-small);
  padding: 7px 9px; border: 1px solid var(--rule-firm); border-radius: 3px;
  background: var(--surface); color: var(--ink); width: 100%;
}
.field textarea { resize: vertical; min-height: 54px; }
.field input:focus, .field textarea:focus, .field select:focus { outline: 2px solid var(--ai); outline-offset: -2px; }
.sheet-foot { display: flex; gap: 7px; justify-content: flex-end; flex-wrap: wrap; }
.picklist { border: 1px solid var(--rule); border-radius: 3px; max-height: 280px; overflow-y: auto; }
.picklist .row { grid-template-columns: 24px 26px 1fr; padding: 7px 10px; }
.sharelink {
  font-family: var(--f-mono); font-size: 11.5px; word-break: break-all;
  background: var(--surface-2); border: 1px solid var(--rule); border-radius: 3px; padding: 8px 9px;
  color: var(--ink-soft);
}

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 1100;
  bottom: calc(78px + env(safe-area-inset-bottom, 0px));
  background: var(--ai); color: var(--on-ai); font-size: var(--fs-small);
  padding: 9px 16px; border-radius: 999px; box-shadow: 0 6px 20px rgba(0,0,0,.28);
}

.tabs2 { display: none; }

/* ===== 電話の幅 ===== */
@media (max-width: 760px) {
  .main { flex-direction: column; }
  .side { flex: 1 1 auto; border-right: 0; border-bottom: 1px solid var(--rule-firm); }
  .mapwrap { flex: 1 1 auto; min-height: 0; }
  .tabs2 {
    display: flex; flex: 0 0 auto; border-bottom: 1px solid var(--rule-firm); background: var(--surface);
  }
  .tabs2 button {
    flex: 1 1 0; font: inherit; font-size: var(--fs-small); padding: 9px 0;
    border: 0; border-right: 1px solid var(--rule); background: var(--surface); color: var(--ink-soft); cursor: pointer;
  }
  .tabs2 button:last-child { border-right: 0; }
  .tabs2 button[aria-pressed="true"] { color: var(--ai); font-weight: 700; box-shadow: inset 0 -2px 0 var(--ai); }
  body.phone-map .side { display: none; }
  body.phone-list .mapwrap { display: none; }
  .side { flex: 1 1 auto; }
  .legend { font-size: 10.5px; }
}

.leaflet-container { font-family: var(--f-body); background: var(--surface-2); }
.leaflet-control-attribution { font-size: 10.5px; }
.leaflet-control-attribution a { color: var(--ai); }
:focus-visible { outline: 2px solid var(--ai); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
/* ===== 合言葉の画面 ===== */

.gate { min-height: 100%; display: grid; place-items: center; padding: max(16px, env(safe-area-inset-left, 0px)); }
.gate-card {
  background: var(--surface); border: 1px solid var(--rule-firm); border-radius: 4px;
  padding: 28px 24px; width: min(340px, 100%); text-align: center;
}
.gate-eyebrow { margin: 0 0 4px; font-size: 11px; letter-spacing: .14em; color: var(--ink-faint); }
.gate-title { margin: 0 0 6px; font-size: 20px; letter-spacing: .06em; }
.gate-note { margin: 0 0 16px; font-size: var(--fs-small); color: var(--ink-soft); }
.gate-input {
  font: inherit; font-size: 20px; letter-spacing: .4em; text-align: center; width: 100%;
  padding: 10px; margin-bottom: 10px;
  border: 1px solid var(--rule-firm); border-radius: 3px;
  background: var(--surface); color: var(--ink);
}
.gate-input:focus { outline: 2px solid var(--ai); outline-offset: -2px; }
.gate .btn { width: 100%; }
.gate-error { margin: 12px 0 0; font-size: var(--fs-small); color: var(--shu); }

/* ===== ピンの絵 ===== */
/* 区分は漢字ではなく絵で示す。ランクだけは文字（S/A/B/C そのものが意味なので） */

.pin svg { width: 15px; height: 15px; display: block; }
.pin svg * { vector-effect: non-scaling-stroke; }
.legend .sw svg { width: 10px; height: 10px; display: block; }
.row .pin svg { width: 13px; height: 13px; }

#app { display: flex; flex-direction: column; height: 100%; }

.chips:empty { display: none; }
.pill-src { color: var(--ink-faint); }

/* 区分が増えたぶんの色 */
:root { --c-airport: #6b5a8a; --c-port: #2b6a73; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --c-airport: #a995c7; --c-port: #6fb3bc; }
}
:root[data-theme="dark"] { --c-airport: #a995c7; --c-port: #6fb3bc; }

.pin.k-airport { border-radius: 50% 4px 50% 50%; }
.pin.k-port    { border-radius: 4px 50% 50% 50%; }
.legend .sw.k-airport { border-radius: 50% 3px 50% 50%; }
.legend .sw.k-port    { border-radius: 3px 50% 50% 50%; }

/* いま動いているビルドの印 */
.gate-build { margin: 14px 0 0; font-size: 11px; color: var(--ink-faint); font-family: var(--f-mono); }
.stance .build { margin-left: auto; font-size: 11px; color: var(--ink-faint); font-family: var(--f-mono); }
