/* 東部社会資源マップ
 * UI は Google マップの構成に寄せる。
 *   - 地図は画面いっぱい。UI はその上に浮かべる
 *   - 左に検索バー → 絞り込みチップ → 結果一覧のカード
 *   - 場所を選ぶと、その位置に詳細カードが差し替わる
 *   - 右下に拡大・縮小
 */

:root{
  --surface:#FFFFFF;
  --surface-2:#F8F9FA;
  --surface-3:#F1F3F4;
  --ink:#202124;
  --ink-2:#3C4043;
  --ink-3:#5F6368;
  --ink-4:#80868B;
  --line:#DADCE0;
  --blue:#1A73E8;
  --blue-soft:#E8F0FE;
  --red:#D93025;
  --green:#188038;
  --amber:#E37400;
  --shadow-1:0 1px 2px rgba(60,64,67,.3), 0 1px 3px 1px rgba(60,64,67,.15);
  --shadow-2:0 1px 3px rgba(60,64,67,.3), 0 4px 8px 3px rgba(60,64,67,.15);
  --map-bg:#FCFCFC;
  --region:#F7DAD2;
  --region-edge:#D98A78;
  --region-ink:#3B3230;
  --outside:#E6E4D6;
  --outside-edge:#CFCCBA;
  --outside-ink:#8C8A7A;
  --radius:8px;
}
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){
    --surface:#292A2D;
    --surface-2:#35363A;
    --surface-3:#3C4043;
    --ink:#E8EAED;
    --ink-2:#DADCE0;
    --ink-3:#9AA0A6;
    --ink-4:#80868B;
    --line:#3C4043;
    --blue:#8AB4F8;
    --blue-soft:#1F3A5F;
    --red:#F28B82;
    --green:#81C995;
    --amber:#FDD663;
    --shadow-1:0 1px 2px rgba(0,0,0,.6), 0 1px 3px 1px rgba(0,0,0,.4);
    --shadow-2:0 1px 3px rgba(0,0,0,.6), 0 4px 8px 3px rgba(0,0,0,.4);
    --map-bg:#202124;
    --region:#4A3B37;
    --region-edge:#B0705E;
    --region-ink:#F2E3DE;
    --outside:#33342E;
    --outside-edge:#45463D;
    --outside-ink:#8B8A7C;
  }
}
:root[data-theme="dark"]{
  --surface:#292A2D; --surface-2:#35363A; --surface-3:#3C4043;
  --ink:#E8EAED; --ink-2:#DADCE0; --ink-3:#9AA0A6; --ink-4:#80868B;
  --line:#3C4043; --blue:#8AB4F8; --blue-soft:#1F3A5F;
  --red:#F28B82; --green:#81C995; --amber:#FDD663;
  --shadow-1:0 1px 2px rgba(0,0,0,.6), 0 1px 3px 1px rgba(0,0,0,.4);
  --shadow-2:0 1px 3px rgba(0,0,0,.6), 0 4px 8px 3px rgba(0,0,0,.4);
  --map-bg:#202124;
  --region:#4A3B37;
  --region-edge:#B0705E;
  --region-ink:#F2E3DE;
  --outside:#33342E;
  --outside-edge:#45463D;
  --outside-ink:#8B8A7C;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0; background:var(--surface-3); color:var(--ink);
  font-family:"Noto Sans JP",Roboto,-apple-system,"Segoe UI","Hiragino Kaku Gothic ProN",sans-serif;
  font-size:16px; line-height:1.65; -webkit-font-smoothing:antialiased;
}
button,input,select,textarea{font:inherit; color:inherit}
:focus-visible{outline:3px solid var(--blue); outline-offset:2px}

#app{position:fixed; inset:0}

/* ============ 地図 ============ */
#mapwrap{position:absolute; inset:0; background:var(--map-bg)}
#map{position:absolute; inset:0; display:grid; place-items:center}
.dmap{width:100%; height:100%; touch-action:none; cursor:grab; display:block}
.dmap:active{cursor:grabbing}
.dmap.picking{cursor:crosshair}

/* 面（ご提供の図の配色に合わせる。東部地域を目立たせ、その外は沈める） */

/* 東部地域の外 ― 位置関係のための背景 */
.dmap-outside-fill{fill:var(--outside); stroke:none}
.dmap-outside-edge{fill:none; stroke:var(--outside-edge); stroke-width:1.4; stroke-linejoin:round}
.dmap-outside-label{font-size:17px; font-weight:500; fill:var(--outside-ink); letter-spacing:.08em}
.dmap-outside-sub{font-size:12.5px; fill:var(--outside-ink); opacity:.8}

/* 東部地域 ― ここが主役 */
.dmap-region-shadow{fill:none; stroke:rgba(0,0,0,.16); stroke-width:9; stroke-linejoin:round}
.dmap-region-fill{fill:var(--region); stroke:none}
.dmap-region-edge{fill:none; stroke:var(--region-edge); stroke-width:3.4; stroke-linejoin:round}

/* 7地区の区切り（目安） */
.dmap-district{cursor:pointer}
.dmap-district-fill{stroke:none; opacity:.42}
.dmap-district-fill.tone0{fill:#E9A493}
.dmap-district-fill.tone1{fill:#EFC0A6}
.dmap-district-fill.tone2{fill:#E2B0B8}
.dmap-district-fill.tone3{fill:#D9A9A0}
.dmap-district-fill.tone4{fill:#F0B9AA}
.dmap-district-edge{fill:none; stroke:#FFFFFF; stroke-width:1.8;
  stroke-dasharray:7 5; stroke-linejoin:round; opacity:.95}
.dmap-district:hover .dmap-district-fill{opacity:.72}
.dmap-district:hover .dmap-district-edge{stroke-width:2.6; stroke-dasharray:none}
.dmap-district:focus-visible .dmap-district-fill{opacity:.8}
:root[data-theme="dark"] .dmap-district-fill{opacity:.34}
:root[data-theme="dark"] .dmap-district-edge{stroke:#1A1512}
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]) .dmap-district-fill{opacity:.34}
  :root:not([data-theme="light"]) .dmap-district-edge{stroke:#1A1512}
}

.dmap-credit{display:none}
.dmap-arealabel{cursor:pointer}
.dmap-label{font-size:20px; font-weight:700; fill:var(--region-ink); letter-spacing:.06em;
  paint-order:stroke; stroke:#fff; stroke-width:4.5px; stroke-linejoin:round;
  dominant-baseline:middle}
:root[data-theme="dark"] .dmap-label{stroke:#2A211E}
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]) .dmap-label{stroke:#2A211E}
}
.dmap-arealabel:hover .dmap-label{fill:var(--blue)}

/* ピン */
.dmap-pin{cursor:pointer}
.dmap-mark{stroke:#FFFFFF; stroke-width:1.6}
.dmap-mark-in{fill:#FFFFFF; stroke:none}
.dmap-dot{stroke:#FFFFFF; stroke-width:1.6}
.dmap-pin.hover .dmap-mark{stroke:var(--ink); stroke-width:2.2}
.dmap-pin.hover{filter:drop-shadow(0 2px 4px rgba(0,0,0,.35))}
.dmap-pin.active{filter:drop-shadow(0 4px 7px rgba(0,0,0,.45))}
.dmap-pinlabel{
  font-size:13px; font-weight:500; fill:var(--ink); text-anchor:middle;
  paint-order:stroke; stroke:#fff; stroke-width:4px; stroke-linejoin:round; pointer-events:none;
}
:root[data-theme="dark"] .dmap-pinlabel{stroke:#202124}
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]) .dmap-pinlabel{stroke:#202124}
}

/* 地図まわりの操作 */
.map-ctrl{position:absolute; right:12px; bottom:24px; z-index:6;
  display:flex; flex-direction:column; gap:12px; align-items:center}
.zoomgroup{display:flex; flex-direction:column; background:var(--surface);
  border-radius:var(--radius); box-shadow:var(--shadow-1); overflow:hidden}
.zoomgroup .iconbtn{border-radius:0; box-shadow:none}
.zoomgroup .iconbtn + .iconbtn{border-top:1px solid var(--line)}
.iconbtn{
  width:44px; height:44px; display:grid; place-items:center; padding:0;
  background:var(--surface); color:var(--ink-2); border:0; border-radius:var(--radius);
  box-shadow:var(--shadow-1); cursor:pointer;
}
.iconbtn:hover{background:var(--surface-2)}
.iconbtn svg{width:20px; height:20px; fill:none; stroke:currentColor;
  stroke-width:2; stroke-linecap:round; stroke-linejoin:round}
.iconbtn.ghost{box-shadow:none; background:transparent; width:36px; height:36px}
.iconbtn.ghost:hover{background:var(--surface-2)}

.legend{
  position:absolute; left:12px; bottom:10px; z-index:6; max-width:min(360px,52%);
  background:var(--surface); border-radius:var(--radius); box-shadow:var(--shadow-1);
  padding:4px 10px; font-size:11.5px; color:var(--ink-3);
}
.legend:not([open]){opacity:.82}
.legend:not([open]):hover{opacity:1}
.legend summary{cursor:pointer; list-style:none; color:var(--ink-2); font-size:12.5px; padding:2px 0}
.legend summary::-webkit-details-marker{display:none}
.legend summary::after{content:" ▴"; color:var(--ink-4)}
.legend:not([open]) summary::after{content:" ▾"}
.legend p{margin:6px 0; line-height:1.55}
.legend b{color:var(--ink-2)}

/* ============ 左に浮かぶ UI ============ */
#ui{
  position:absolute; left:12px; top:12px; bottom:12px; width:392px; z-index:10;
  display:flex; flex-direction:column; gap:10px; pointer-events:none;
}
#ui > *{pointer-events:auto}

.searchbar{
  display:flex; align-items:center; gap:10px; background:var(--surface);
  border-radius:24px; box-shadow:var(--shadow-1); padding:4px 6px 4px 16px; flex:none;
}
.searchbar .si{width:20px; height:20px; flex:none; fill:none; stroke:var(--ink-3);
  stroke-width:2; stroke-linecap:round}
.searchbar input{flex:1; min-width:0; border:0; background:transparent; padding:10px 0; font-size:16px}
.searchbar input::placeholder{color:var(--ink-4)}
.searchbar input:focus{outline:none}

.chiprow{display:flex; gap:8px; overflow-x:auto; flex:none; padding-bottom:2px; scrollbar-width:none}
.chiprow::-webkit-scrollbar{display:none}

.chip{
  font-size:13.5px; line-height:1.2; white-space:nowrap; cursor:pointer;
  padding:8px 14px; min-height:36px; border-radius:18px;
  border:1px solid var(--line); background:var(--surface); color:var(--ink-2);
  display:inline-flex; align-items:center; gap:7px;
}
.chip.solid{box-shadow:var(--shadow-1); border-color:transparent}
.chip:hover{background:var(--surface-2)}
.chip[aria-pressed="true"],.chip[aria-expanded="true"]{
  background:var(--blue-soft); color:var(--blue); border-color:transparent; font-weight:500}
.chip .dot{width:10px; height:10px; border-radius:50%; flex:none}
.chip-group{display:flex; flex-wrap:wrap; gap:6px}

.filterpanel{
  background:var(--surface); border-radius:var(--radius); box-shadow:var(--shadow-1);
  padding:12px 14px; display:flex; flex-direction:column; gap:12px; flex:none;
  max-height:44vh; overflow-y:auto;
}
.fgroup{display:flex; flex-direction:column; gap:7px}
.flabel{font-size:12px; color:var(--ink-3); font-weight:500; letter-spacing:.04em}

/* ============ 一覧 ============ */
#panel{
  background:var(--surface); border-radius:var(--radius); box-shadow:var(--shadow-1);
  display:flex; flex-direction:column; min-height:0; flex:1; overflow:hidden;
}
.panel-head{
  padding:12px 16px 10px; border-bottom:1px solid var(--line); flex:none;
  display:flex; flex-direction:column; gap:2px;
}
.panel-head .count{font-size:13px; color:var(--ink-3)}
.panel-head .count b{font-size:16px; color:var(--ink); font-weight:500}
.hint-sm{font-size:12px; color:var(--ink-4)}
#list{overflow-y:auto; overscroll-behavior:contain}

.card{
  padding:13px 16px; border-bottom:1px solid var(--line); cursor:pointer;
  display:grid; grid-template-columns:1fr auto; gap:3px 12px; align-items:start;
}
.card:hover{background:var(--surface-2)}
/* 地図で指している資源の行。どれを指しているか一目で分かるようにする */
.card.hover{background:var(--blue-soft); box-shadow:inset 4px 0 0 var(--blue)}
.card.active{background:var(--blue-soft)}
.card > *{grid-column:1}
.card .thumb{
  grid-column:2; grid-row:1 / span 4; width:76px; height:76px; object-fit:cover;
  border-radius:var(--radius); background:var(--surface-3);
}
.card h3{margin:0; font-size:15.5px; font-weight:500; line-height:1.45; color:var(--ink)}
.card .cat{
  font-size:12px; color:var(--ink-3); display:inline-flex; align-items:center; gap:6px;
}
.card .cat .dot{width:9px; height:9px; border-radius:50%; flex:none}
.card .row{font-size:13px; color:var(--ink-3); display:flex; gap:6px; align-items:flex-start; line-height:1.5}
.card .row .ic{flex:none; opacity:.75; margin-top:3px}
.card .warn{font-size:12px; color:var(--amber)}
.card .outside-note{font-size:12px; color:var(--ink-4)}
.empty{padding:28px 16px; text-align:center; color:var(--ink-3); font-size:14px}

/* ============ 詳細（場所カード） ============ */
#detail{
  position:absolute; left:0; right:0; top:0; bottom:0; z-index:12;
  background:var(--surface); border-radius:var(--radius); box-shadow:var(--shadow-2);
  overflow-y:auto; padding:0 0 22px;
}
#detail .dhead{padding:14px 20px 0; position:relative}
#detail .backbar{
  position:sticky; top:0; z-index:2; background:var(--surface);
  display:flex; align-items:center; gap:8px; padding:8px 10px;
  border-bottom:1px solid var(--line);
}
#detail .back{
  display:inline-flex; align-items:center; gap:8px; border:0; background:transparent;
  color:var(--ink-2); font-size:14px; cursor:pointer; padding:8px 12px; border-radius:18px;
}
#detail .back:hover{background:var(--surface-2)}
#detail .back svg{width:18px; height:18px; fill:none; stroke:currentColor;
  stroke-width:2; stroke-linecap:round; stroke-linejoin:round}
#detail h2{font-size:22px; font-weight:500; margin:2px 0 2px; line-height:1.35}
#detail .cat{font-size:13px; color:var(--ink-3); display:inline-flex; align-items:center; gap:7px}
#detail .cat .dot{width:10px; height:10px; border-radius:50%}
#detail .photos{display:flex; gap:2px; overflow-x:auto; margin:14px 0 0}
#detail .photos figure{margin:0; flex:none; position:relative}
#detail .photos img{height:150px; display:block; background:var(--surface-3)}
#detail .photos figcaption{
  position:absolute; left:0; right:0; bottom:0; padding:14px 8px 5px; font-size:11px; color:#fff;
  background:linear-gradient(transparent,rgba(0,0,0,.72));
}
#detail .actions{display:flex; gap:8px; padding:14px 20px 4px; flex-wrap:wrap}
.act{
  display:inline-flex; align-items:center; gap:6px; padding:8px 16px; min-height:40px;
  border-radius:20px; font-size:14px; cursor:pointer; text-decoration:none;
  border:1px solid var(--line); background:var(--surface); color:var(--blue);
}
.act:hover{background:var(--surface-2)}
.act.primary{background:var(--blue); color:#fff; border-color:transparent}
.act.primary:hover{filter:brightness(1.08)}
#detail dl{display:grid; grid-template-columns:24px 1fr; gap:0; margin:12px 0 0}
#detail dt{
  grid-column:1; padding:11px 0 0; color:var(--ink-3); font-size:11px;
  display:flex; justify-content:center;
}
#detail dd{
  grid-column:2; margin:0; padding:11px 20px 11px 12px; font-size:14.5px;
  border-bottom:1px solid var(--line); color:var(--ink-2); word-break:break-word;
}
#detail dd .k{display:block; font-size:11.5px; color:var(--ink-4); margin-bottom:1px}
#detail a{color:var(--blue); text-decoration:none}
#detail a:hover{text-decoration:underline}
#detail .links{display:flex; flex-wrap:wrap; gap:8px; padding:14px 20px 0}
.note-box{
  margin:14px 20px 0; padding:11px 14px; border-radius:var(--radius);
  background:var(--surface-2); font-size:13px; color:var(--ink-2); line-height:1.6;
}
.note-box.warn{background:#FEF7E0; color:#7A5900}
:root[data-theme="dark"] .note-box.warn{background:#3A2F00; color:#FDD663}
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]) .note-box.warn{background:#3A2F00; color:#FDD663}
}
.note-box b{display:block; margin-bottom:2px}
.disclaimer{margin:14px 20px 0; font-size:11.5px; color:var(--ink-4); line-height:1.6}

/* ============ モーダル ============ */
.modal-back{position:fixed; inset:0; background:rgba(32,33,36,.55); z-index:100;
  display:grid; place-items:center; padding:16px}
.modal{
  background:var(--surface); border-radius:12px; box-shadow:var(--shadow-2);
  width:min(680px,100%); max-height:88dvh; overflow-y:auto; padding:22px 24px 24px; position:relative;
}
.modal h2{font-size:20px; font-weight:500; margin:0 0 4px; padding-right:44px}
.modal .close{
  position:absolute; top:14px; right:16px; width:36px; height:36px; border:0; border-radius:50%;
  background:var(--surface-2); color:var(--ink-2); cursor:pointer; display:grid; place-items:center; font-size:18px;
}
.modal .lede{color:var(--ink-3); font-size:14px; margin:0 0 18px}
.steps{display:flex; gap:6px; flex-wrap:wrap; margin:0 0 18px; padding:0; list-style:none}
.steps li{font-size:12.5px; padding:5px 12px; border-radius:16px;
  background:var(--surface-2); color:var(--ink-3); cursor:default}
.steps li[aria-current="step"]{background:var(--blue); color:#fff; font-weight:500}
.steps li.done{background:var(--blue-soft); color:var(--blue); cursor:pointer}

.field{display:flex; flex-direction:column; gap:5px; margin:0 0 16px}
.field label{font-size:13.5px; font-weight:500; color:var(--ink-2)}
.field .hint{font-size:12.5px; color:var(--ink-3); line-height:1.55}
.field input[type=text],.field input[type=url],.field input[type=tel],.field select,.field textarea{
  background:var(--surface); border:1px solid var(--line); border-radius:4px;
  padding:10px 12px; min-height:44px; width:100%; color:var(--ink);
}
.field input:focus,.field select:focus,.field textarea:focus{
  outline:none; border-color:var(--blue); box-shadow:0 0 0 1px var(--blue)}
.field textarea{min-height:90px; resize:vertical}
.grid2{display:grid; gap:0 16px}
@media(min-width:560px){ .grid2{grid-template-columns:1fr 1fr} }
.pickmap{
  height:330px; border:1px solid var(--line); border-radius:var(--radius);
  overflow:hidden; margin-bottom:8px; background:var(--surface-3); display:grid; place-items:center;
}
.preview-card{border:1px solid var(--line); border-radius:var(--radius); padding:14px 16px;
  display:flex; flex-direction:column; gap:5px; background:var(--surface-2)}
.preview-card h3{margin:0; font-size:16px; font-weight:500}
.preview-card .row{font-size:13.5px; color:var(--ink-3); display:flex; gap:6px; align-items:flex-start}
.preview-card .row .ic{flex:none; opacity:.75; margin-top:3px}
.preview-card .cat{font-size:12px; color:var(--ink-3)}
.modal-foot{display:flex; gap:10px; justify-content:flex-end; flex-wrap:wrap; margin-top:20px}
.btn{
  padding:9px 20px; min-height:40px; border-radius:4px; border:1px solid var(--line);
  background:var(--surface); color:var(--blue); font-size:14px; font-weight:500; cursor:pointer;
}
.btn:hover{background:var(--surface-2)}
.btn.primary{background:var(--blue); color:#fff; border-color:transparent}
.btn.primary:hover{filter:brightness(1.08)}
.btn.danger{color:var(--red)}
.btn.small{min-height:34px; padding:5px 12px; font-size:13px}
.photo-strip{display:flex; gap:10px; flex-wrap:wrap; margin-top:10px}
.photo-strip figure{margin:0; width:132px; display:flex; flex-direction:column; gap:5px}
.photo-strip img{width:132px; height:96px; object-fit:cover; border-radius:4px; border:1px solid var(--line)}
.photo-strip input{width:132px; font-size:12px; padding:5px 7px; border:1px solid var(--line);
  border-radius:4px; background:var(--surface); color:var(--ink)}
.linkrow{display:grid; grid-template-columns:9.5em 1fr auto; gap:8px; margin-bottom:8px; align-items:center}
@media(max-width:560px){ .linkrow{grid-template-columns:1fr} }
.pending-item{display:flex; gap:10px; align-items:center; justify-content:space-between;
  flex-wrap:wrap; padding:10px 0; border-bottom:1px solid var(--line)}
.pending-item .nm{font-size:14.5px}
.pending-item .ad{font-size:12.5px; color:var(--ink-3)}
.toast{
  position:fixed; left:50%; bottom:26px; transform:translateX(-50%); z-index:200;
  background:#323236; color:#fff; padding:12px 22px; border-radius:4px;
  font-size:14px; box-shadow:var(--shadow-2); max-width:88vw;
}
.hint-banner{
  position:absolute; top:16px; left:50%; transform:translateX(-50%); z-index:20;
  background:var(--blue); color:#fff; border-radius:20px; padding:9px 18px;
  font-size:14px; box-shadow:var(--shadow-2); max-width:92%; text-align:center;
}

/* ============ せまい画面（下からせり上がるシート） ============ */
@media(max-width:900px){
  #ui{left:8px; right:8px; width:auto; top:8px; bottom:8px}
  #panel{flex:none; max-height:38dvh; margin-top:auto}
  #detail{top:auto; height:62dvh}
  .filterpanel{max-height:34vh}
  .legend{display:none}
  .map-ctrl{bottom:calc(38dvh + 20px)}
}

/* ============ 印刷 ============ */
@media print{
  body{background:#fff}
  #mapwrap,.map-ctrl,.legend,.searchbar,.chiprow,.filterpanel,.hint-sm,#detail,.modal-back{display:none !important}
  #app{position:static}
  #ui{position:static; width:auto; display:block}
  #panel{box-shadow:none; border-radius:0; max-height:none; overflow:visible}
  #list{overflow:visible}
  .card{break-inside:avoid; page-break-inside:avoid; border-bottom:1px solid #999}
  .card .thumb{display:none}
}
@media (prefers-reduced-motion: reduce){ *{transition:none !important; animation:none !important} }

/* hidden 属性を display より優先させる */
.filterpanel[hidden]{display:none}
#detail[hidden]{display:none}
.region-panel{flex:none;background:var(--surface);border-radius:12px;padding:12px 14px;box-shadow:var(--shadow-1)}
.region-panel h1{font-size:19px;margin:0;font-weight:700}
.region-panel p{font-size:14px;margin:4px 0 10px;color:var(--ink-3)}
.region-panel .chip{min-height:44px}
.region-panel .cafe-shortcut{margin-top:8px}
.resource-shortcuts{display:flex;gap:8px;flex-wrap:wrap;margin-top:8px}
.resource-shortcuts select{width:100%;min-height:44px;border:1px solid var(--line);border-radius:8px;background:var(--surface);padding:6px}
.list-only #mapwrap{display:none}
.list-only #ui{width:auto;right:12px;max-width:1000px;margin:auto;pointer-events:auto}
.list-only #panel{flex:1;max-height:none;margin-top:0}
.list-only #list{display:grid;grid-template-columns:repeat(auto-fit,minmax(280px,1fr));align-content:start}
.list-only #detail{top:0;height:100%}
@media(max-width:900px){
 .region-panel{padding:8px 10px}
 .region-panel h1{font-size:17px}
 .region-panel p{display:none}
 .region-panel #area-chips{flex-wrap:nowrap;overflow-x:auto;margin-top:6px}
 .region-panel #area-chips .chip{flex:none}
 .resource-shortcuts{margin-top:6px}
 #panel{max-height:30dvh}
 .map-ctrl{bottom:calc(30dvh + 20px)}
}
@media print{.region-panel{box-shadow:none}.region-panel .chip-group,.resource-shortcuts,.cafe-shortcut{display:none!important}}
.location-summary{font-size:13px;color:var(--ink-3);margin:0;padding:6px 14px;border-bottom:1px solid var(--line)}
.cluster-resource{display:block;width:100%;text-align:left;margin:10px 0;min-height:44px}
@media(min-width:901px){#mapwrap{left:416px}}
.location-summary{flex:none}
@media(max-width:900px){
 #mapwrap{top:320px;bottom:calc(30dvh + 18px)}
 #mapwrap .map-ctrl{bottom:44px;right:4px}
 #panel .hint-sm{display:none}
}
@media(max-width:900px) and (max-height:650px){
 .region-panel .cafe-shortcut{display:none}
 #mapwrap{top:265px}
}
.card h3,.card .row{font-size:16px}
:root[data-theme="light"]{--surface:#fff;--map-bg:#fff;--surface-3:#fff}
:root[data-theme="light"] body{background:#fff}
/* 地名が分かる広域地図と、PC・タッチ共通の地点カード */
.map-mode{position:absolute;top:12px;left:12px;right:12px;display:flex;align-items:center;gap:8px;pointer-events:none;flex-wrap:wrap}
.map-mode button{pointer-events:auto;min-height:44px;background:#fff}
.map-mode span{font-size:12px;background:var(--surface);color:var(--ink-2);padding:4px 8px;border-radius:4px}
#map.preview-open ~ .map-mode span{opacity:.55}
.map-attribution{position:absolute;right:8px;bottom:4px;background:#fff;font-size:12px;padding:2px 5px;color:#175b9d;z-index:3}
.tile-status{position:absolute;left:8px;right:8px;bottom:30px;background:#fff4d5;color:#694300;font-size:14px;z-index:4}
.tile-status:empty{display:none}
/* 地点カード。左は地区パネル、左下は「固定所在地なし」ボタンと凡例が居るので右に置く。
   下は拡大縮小ボタンの上で止める。 */
.map-preview{position:absolute;top:70px;right:12px;left:auto;width:min(365px,calc(100% - 80px));max-height:calc(100% - 230px);overflow:auto;background:var(--surface);color:var(--ink);border:2px solid var(--blue);border-radius:12px;box-shadow:var(--shadow-2);padding:16px;z-index:9;line-height:1.5}
.map-preview[hidden]{display:none}
.preview-bar{display:flex;align-items:center;gap:6px;margin:-16px -16px 10px;padding:8px 8px 8px 12px;
  border-bottom:1px solid var(--line);background:var(--surface-2);border-radius:10px 10px 0 0;cursor:grab;
  touch-action:none;user-select:none}
.map-preview.dragging .preview-bar{cursor:grabbing}
.preview-grip{color:var(--ink-4);font-size:15px;letter-spacing:-2px}
.preview-title{flex:1;min-width:0;font-size:15px;font-weight:700;color:var(--ink);
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.preview-min{width:36px;height:36px;flex:none;border:0;border-radius:50%;background:var(--surface);
  color:var(--ink-2);font-size:18px;line-height:1;cursor:pointer}
.preview-min:hover{background:var(--surface-3)}
.map-preview.collapsed{max-height:none;height:auto;overflow:visible;padding-bottom:0}
.map-preview.collapsed .preview-body{display:none}
.map-preview.collapsed .preview-bar{margin-bottom:-16px;border-bottom:0;border-radius:10px}
.map-preview h2{font-size:18px;margin:0 44px 10px 0;overflow-wrap:anywhere;line-height:1.4}
.map-preview h3{font-size:16px;margin:0 0 6px}
.preview-close{position:static;width:36px;height:36px;flex:none;background:var(--surface);
  color:var(--ink-2);border:0;border-radius:50%;font-size:19px;line-height:1;cursor:pointer}
.preview-close:hover{background:var(--surface-3)}
.preview-resource + .preview-resource{border-top:1px solid var(--line);margin-top:16px;padding-top:16px}
.preview-address{font-size:14.5px;margin:8px 0;color:var(--ink-2)}
.preview-resource strong{font-size:14px}
.coverage-chips{display:flex;flex-wrap:wrap;gap:6px;margin:8px 0}
.coverage-chips span{font-size:14px;padding:5px 9px;border-radius:5px}
.coverage-chips .eligible{background:#e5f2ea;color:#155b35;border:1px solid #68a380;font-weight:700}
.coverage-chips .not-listed{background:#f4f4f4;color:#666;border:1px solid #ddd}
.coverage-note{font-size:12px;color:#555;margin:6px 0 10px}
.detail-coverage{margin:16px 20px;padding:12px;background:#f5faf7;border:1px solid #c5dccd;border-radius:8px}
.detail-coverage h3{font-size:16px;margin:0}
.area-filter-title{display:block;font-size:15px;margin:8px 0}
.real-district{font-size:16px;font-weight:700;fill:#713a30;paint-order:stroke;stroke:#fff;stroke-width:4px;pointer-events:none}
.real-district.service-area{fill:#126137;stroke:#e5ffec;stroke-width:6px}
.dmap-district.service-area .dmap-district-fill{fill:#7bc99a}
.map-preview .btn{min-height:44px;width:100%;font-size:14px;padding:8px}
@media(max-width:900px){
 #app{display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:auto auto auto auto minmax(360px,50dvh) minmax(240px,auto);overflow-y:auto;gap:8px;padding:8px;align-content:start}
 #ui{display:contents}
 .region-panel{grid-row:1}
 .region-panel p{display:block;font-size:12px;margin:2px 0}
 .region-panel .cafe-shortcut{display:none}
 .region-panel #area-chips{flex-wrap:wrap;overflow:visible}
 .region-panel #area-chips .chip{min-height:44px;padding:6px 10px}
 .searchbar{grid-row:2}
 .chiprow{grid-row:3;min-width:0}
 .filterpanel{grid-row:4;max-height:280px}
 #mapwrap{position:relative;grid-row:5;inset:auto;height:100%;min-height:360px;border:1px solid #ddd;border-radius:10px;overflow:hidden}
 #mapwrap .map-ctrl{bottom:44px}
 .map-mode{top:6px;left:6px;gap:4px}
 .map-mode span{display:none}
 /* 狭い画面では下からのシート。地図の操作と重ならないよう、左下のボタンと凡例は引っ込める */
 .map-preview{top:auto;bottom:8px;left:6px;right:6px;width:auto;max-height:58%;padding:12px}
  #map.preview-open ~ .legend,
 #map.preview-open ~ .map-ctrl{display:none}
 #panel{grid-row:6;margin:0;max-height:none;min-height:240px}
 #list{max-height:60dvh}
 #detail{position:fixed;top:auto;bottom:0;height:70dvh;left:0;right:0;border:1px solid #ccc}
 .list-only#app{display:block}
 .list-only #ui{display:flex;position:static;width:auto;margin:0;gap:8px}
 .list-only #panel{max-height:none}
 .list-only #detail{height:85dvh;top:auto}
}
@media print{#app{display:block;overflow:visible}.map-preview{display:none}.area-filter-title{display:none}}
.dmap-pin.preview-target .dmap-mark{stroke:#172f50;stroke-width:3.5}
.dmap-pin.preview-target{filter:drop-shadow(0 0 5px #174e91)}
@media(max-width:900px){
  .map-preview{top:auto;bottom:8px;left:6px;right:6px;width:auto;max-height:56%}
    #map.preview-open ~ .legend,
  #map.preview-open ~ .map-ctrl{display:none}
}

/* ============================================================
   左の列を詰めて、一覧（126件）の見える範囲を広げる
   ------------------------------------------------------------
   直す前: 上の地区パネルが 323px（画面の 42%）を占め、
           一覧の本体が 225px しか残っていなかった。
   ここは全部あとから足した指定なので、戻すときはこの塊を消せばよい。
   ============================================================ */
#ui{gap:8px}

.region-panel{padding:10px 12px}
.region-panel h1{font-size:16px;line-height:1.35}
/* 「利用したい地区を選択」は、すぐ下の見出しと同じことを言っているので出さない */
.region-panel p{display:none}
.area-filter-title{font-size:13px;margin:6px 0 4px}
.region-panel #area-chips{gap:5px}
.region-panel .chip{min-height:36px;padding:5px 11px;font-size:13px}
.resource-shortcuts{margin-top:6px}
.resource-shortcuts select{min-height:38px}
.region-panel .cafe-shortcut{margin-top:6px;min-height:36px}

/* 件数は1行にまとめ、説明は小さく添える */
.panel-head{padding:8px 14px;flex-direction:row;align-items:baseline;gap:4px 10px;flex-wrap:wrap}
.panel-head .count b{font-size:17px}
.panel-head .hint-sm{font-size:11.5px}
.location-summary{padding:4px 14px;font-size:12px}

/* 指で押す画面では、当たりの大きさを 44px に戻す */
@media(max-width:900px){
  .region-panel .chip{min-height:44px;font-size:13.5px}
  .resource-shortcuts select{min-height:44px}
}


/* ============================================================
   左下の説明を読みやすくする／地点カードの大きさを変えられるようにする
   ============================================================ */


/* 出典は左下の説明と重ならないよう、右下のズームの左に置く */
.map-attribution{right:70px; bottom:14px; left:auto; font-size:11.5px}

/* 地点カード：右下の角をつまんで大きさを変えられる */
.map-preview{
  resize:both;
  min-width:260px; min-height:120px;
  max-width:min(560px, calc(100% - 24px));
}
.map-preview.collapsed{resize:none; min-height:0}

/* 指で操作する画面では、つまむ角より上下シートのほうが扱いやすい */
@media(max-width:900px){
  .map-preview{resize:vertical; max-width:none}
}


/* ============================================================
   近いピンをまとめた丸（押すと拡大、同じ地点なら一覧）
   ============================================================ */
.dmap-cluster-pin{cursor:pointer}
.dmap-cluster-halo{fill:#1A73E8;opacity:.22}
.dmap-cluster-body{fill:#1A73E8;stroke:#fff;stroke-width:2}
.dmap-cluster-pin.same-point .dmap-cluster-body{fill:#5F6368}
.dmap-cluster-count{fill:#fff;font-size:13px;font-weight:700;pointer-events:none}
.dmap-cluster-pin:hover .dmap-cluster-halo{opacity:.4}
.dmap-cluster-pin:focus-visible .dmap-cluster-halo{opacity:.5}


/* 地点カード：重なっている資源をプルダウンで選ぶ */
.preview-pick{display:flex;flex-direction:column;gap:4px;margin:0 0 12px}
.preview-pick label{font-size:12.5px;color:var(--ink-3)}
.preview-pick select{width:100%;min-height:42px;padding:6px 10px;font-size:14px;
  border:1px solid var(--line);border-radius:6px;background:var(--surface);color:var(--ink)}
.preview-pick select:focus{outline:none;border-color:var(--blue);box-shadow:0 0 0 1px var(--blue)}
.map-preview h3{margin:0 0 6px;font-size:16px}

/* ============================================================
   スマホ幅の作り直し
   ------------------------------------------------------------
   直す前の不具合
     - ボタン列が高さ 2px に潰れ、6個のボタンが押せなかった。
       横スクロール（overflow-x:auto）の要素は grid の中で最小高さが 0 になるため。
       スマホでは横スクロールより折り返しのほうが見つけやすいので、折り返しにする。
     - 下の一覧が 240px しかなく、126件に対して1件半しか見えなかった。
   ============================================================ */
@media(max-width:900px){
  /* grid の行が中身の高さを拾わないので、確定した高さを与える。
     折り返すと2行目が地図の下に隠れるため、横に送る形にする（指で払える）。 */
  .chiprow{flex-wrap:nowrap; overflow-x:auto; height:48px; min-height:48px;
           align-items:center; padding-bottom:0; -webkit-overflow-scrolling:touch}
  .chiprow .chip{min-height:40px; flex:none}

  /* 地図と一覧の取り分を決め直す（一覧を 240px → 50dvh へ） */
  #app{grid-template-rows:auto auto auto auto minmax(300px,40dvh) minmax(340px,50dvh)}
  #panel{min-height:340px}
  #list{max-height:none}

  /* 地区パネルの見出しは短く */
  .region-panel h1{font-size:16px}
  .area-filter-title{font-size:12.5px;margin:4px 0 2px}
}

/* スマホの地点カードは、地図の枠に閉じ込めず画面下のシートにする
   （地図枠が 360px しかなく、22件のプルダウンを開くと何も読めなかった） */
@media(max-width:900px){
  .map-preview{
    position:fixed; left:8px; right:8px; bottom:8px; top:auto; width:auto;
    max-height:62dvh; z-index:40; border-radius:14px; resize:none;
  }
  .preview-pick select{min-height:46px; font-size:15px}
  .map-preview .btn{min-height:46px}
  .preview-bar{position:sticky; top:-12px}
}



/* 一覧を項目ごとに区切る見出し */
.list-group{
  position:sticky; top:0; z-index:1;
  display:flex; align-items:center; gap:7px;
  padding:7px 16px; background:var(--surface-2);
  border-bottom:1px solid var(--line);
  font-size:12.5px; font-weight:700; color:var(--ink-2); letter-spacing:.02em;
}
.list-group .dot{width:9px; height:9px; border-radius:50%; flex:none}

/* ============================================================
   スマホ：Google マップと同じ組み立て
   ------------------------------------------------------------
   地図を画面いっぱいに敷き、上に検索と地区、
   一覧は下から引き上げるシートにして、地図と重ねて見せる。
   ============================================================ */
.sheet-grip{display:none}

@media(max-width:900px){
  #app{position:fixed; inset:0; display:block; padding:0; overflow:hidden}

  /* 地図は全面 */
  #mapwrap{position:absolute; inset:0; height:auto; min-height:0;
           border:0; border-radius:0; grid-row:auto}

  /* 上に浮かぶのは検索と地区だけ */
  #ui{position:absolute; left:8px; right:8px; top:8px; bottom:auto; width:auto;
      display:flex; flex-direction:column; gap:8px; pointer-events:none; z-index:20}
  #ui > *{pointer-events:auto}
  .searchbar{order:1}
  .region-panel{order:2; padding:6px 8px; grid-row:auto}
  .region-panel h1, .area-filter-title, .region-panel p{display:none}
  .region-panel #area-chips{flex-wrap:nowrap; overflow-x:auto; gap:6px; margin:0}
  .region-panel #area-chips .chip{flex:none}
  /* 項目のプルダウンは一覧シートの中に出す */
  .resource-shortcuts{display:flex; margin:0; padding:2px 14px 8px;
    border-bottom:1px solid var(--line)}
  .resource-shortcuts select{min-height:44px; font-size:14.5px}
  .chiprow{order:3; height:44px; min-height:44px}
  .filterpanel{order:4}

  /* 一覧は下から引き上げるシート */
  #panel{
    position:fixed; left:0; right:0; bottom:0; top:auto; z-index:30;
    height:var(--sheet, 26dvh); max-height:92dvh; min-height:80px;
    border-radius:16px 16px 0 0; box-shadow:0 -2px 14px rgba(0,0,0,.2);
    grid-row:auto; margin:0;
  }
  .sheet-grip{
    display:block; width:100%; border:0; background:none; cursor:grab;
    padding:8px 0 4px; touch-action:none;
  }
  .sheet-grip span{display:block; width:40px; height:4px; margin:0 auto;
    border-radius:2px; background:var(--ink-4)}
  .panel-head{padding:4px 14px 8px}
  #list{max-height:none}

  /* 詳細と地点カードもシートの上に重ねる */
  #detail{position:fixed; left:0; right:0; bottom:0; top:auto; height:76dvh;
    border-radius:16px 16px 0 0; z-index:35}
  .map-preview{bottom:8px; max-height:56dvh; z-index:40}
}

/* スマホ：地図の操作ボタンを一覧シートの上に置く（シートの高さに合わせて動く） */
@media(max-width:900px){
  /* 先に #mapwrap 付きの指定があるので、こちらも ID を付けて上書きする */
  #mapwrap .map-ctrl{
    bottom:calc(var(--sheet, 26dvh) + 14px);
    right:10px; z-index:32;
  }
  #mapwrap .map-ctrl .iconbtn{width:48px; height:48px}
  #mapwrap .map-attribution{bottom:calc(var(--sheet, 26dvh) + 4px); right:8px; z-index:31}
}

/* 登録：住所から探し直す欄 */
.geo-again{display:flex; gap:8px; margin:0 0 8px}
.geo-again input{flex:1; min-width:0; min-height:44px; padding:8px 12px;
  border:1px solid var(--line); border-radius:6px; background:var(--surface); color:var(--ink)}
.geo-again .btn{flex:none; min-height:44px; white-space:nowrap}

/* 登録：いつ開くか */
.when{display:flex; flex-direction:column; gap:2px}
.when .chip-group{gap:6px}
.when-days .chip{min-width:46px; justify-content:center}
.when-time{display:flex; align-items:center; gap:8px}
.when-time input{flex:1; min-width:0; min-height:44px; padding:8px 10px;
  border:1px solid var(--line); border-radius:6px; background:var(--surface); color:var(--ink)}
.when-tilde{color:var(--ink-3)}
.when-preview{margin:2px 0 16px; padding:8px 12px; border-radius:6px;
  background:var(--blue-soft); color:var(--ink-2); font-size:13px}
