/* いまどこ Web — follows design/ui-prototype-03 (tokens, cards, type scale). Theme follows the system setting. */
:root{
  color-scheme:light;
  --green:#13775d;--dark:#1a302b;--muted:#73827b;--line:#e3e9e3;--mint:#edf6ef;--orange:#bd642f;--bg:#f5f7f3;
  --surface:#fff;--surface-subtle:#fafbf8;--soft:#edf4ed;--blue-soft:#edf2fa;--blue:#386a98;--amber-soft:#f8f1e2;--amber:#906b27;
  --grey-soft:#eceeea;--grey:#6b756f;--map-bg:#f2f4ed;--map-past:#a5b69b;--map-route:#779663;--marker:#13775d;--marker-ink:#fff;
  --focus:#86bdae;--danger:#b4442f;
}
@media (prefers-color-scheme:dark){
  :root{
    color-scheme:dark;
    --bg:#111918;--surface:#1b2523;--surface-subtle:#192220;--dark:#e0eae4;--muted:#94a79d;--line:#30413a;--green:#82c7a9;--mint:#243a30;
    --soft:#23332b;--orange:#e3ad76;--blue-soft:#24323c;--blue:#98b8d6;--amber-soft:#372f22;--amber:#d5ba81;--grey-soft:#2a3330;--grey:#a9b4ae;
    --map-bg:#1c2925;--map-past:#728978;--map-route:#82a977;--marker:#96d6b9;--marker-ink:#143426;--focus:#4f8f7b;--danger:#f0a08f;
  }
}
*{box-sizing:border-box}
html{-webkit-text-size-adjust:100%}
body{margin:0;background:var(--bg);color:var(--dark);font-family:'Hiragino Sans','Hiragino Kaku Gothic ProN','Noto Sans JP','Noto Sans CJK JP',system-ui,-apple-system,'Segoe UI',sans-serif;font-size:14px;-webkit-font-smoothing:antialiased;-webkit-tap-highlight-color:transparent}
button,input,select{font:inherit}
button{cursor:pointer}
button:focus-visible,input:focus-visible,select:focus-visible,a:focus-visible,summary:focus-visible{outline:3px solid var(--focus);outline-offset:3px}
a{color:var(--green)}
svg{width:24px;height:24px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
.icon-defs{position:absolute;width:0;height:0}
h1,h2,p{margin:0}
[hidden]{display:none!important}

.shell{max-width:520px;margin:auto;padding:0 18px calc(env(safe-area-inset-bottom) + 8px);padding-left:max(18px,env(safe-area-inset-left));padding-right:max(18px,env(safe-area-inset-right))}
.header{display:flex;align-items:center;justify-content:space-between;padding:calc(env(safe-area-inset-top) + 18px) 0 15px;border-bottom:1px solid var(--line)}
.brand{display:flex;align-items:center;gap:10px}
.brand-icon{display:grid;place-items:center;width:38px;height:38px;border-radius:11px;background:var(--marker);color:var(--marker-ink)}
.brand-icon svg{width:24px;height:24px}
h1{font-size:21px;font-weight:800;letter-spacing:.02em;line-height:1.2}
h1 span{display:block;font-size:10px;font-weight:500;color:var(--muted);margin-top:2px;letter-spacing:.04em}
.header-state{font-size:10px;color:var(--muted);display:flex;align-items:center;gap:6px;white-space:nowrap}
.header-state.on:before{content:'';width:7px;height:7px;border-radius:50%;background:var(--green);box-shadow:0 0 0 3px var(--mint)}

.card{background:var(--surface);border:1px solid var(--line);border-radius:17px;overflow:hidden}
.section-title{padding:15px 18px 6px;display:flex;align-items:baseline;justify-content:space-between;gap:10px}
.section-title h2{font-size:13px;font-weight:700;display:flex;align-items:center;gap:7px;white-space:nowrap}
.section-title svg{width:17px;height:17px;color:var(--green)}
.subtle{font-size:10px;color:var(--muted);text-align:right;line-height:1.5}
.text-button{background:none;border:0;color:var(--green);font-size:12px;font-weight:700;display:inline-flex;align-items:center;gap:6px;padding:8px 2px;min-height:36px}
.text-button:hover{text-decoration:underline}

/* 1) 経路を選択 */
.route-picker{padding:15px 0 0}
.route-picker-label{display:flex;justify-content:space-between;align-items:center;margin-bottom:4px}
.route-picker-label label{font-size:11px;color:var(--muted);font-weight:600}
#open-routes{border:1px solid var(--line);border-radius:9px;padding:6px 12px;background:var(--surface);font-size:12px;min-height:34px}
#open-routes:hover{text-decoration:none;border-color:var(--green)}
.route-picker select,.sheet input,.station-field{width:100%;min-height:46px;border:1px solid var(--line);border-radius:10px;background:var(--surface);color:var(--dark);padding:10px 12px;font-size:13px}
.route-picker select{padding-right:34px;cursor:pointer;appearance:none;-webkit-appearance:none;background-image:linear-gradient(45deg,transparent 50%,var(--muted) 50%),linear-gradient(135deg,var(--muted) 50%,transparent 50%);background-position:calc(100% - 18px) 50%,calc(100% - 13px) 50%;background-size:5px 5px;background-repeat:no-repeat}

/* 2) 経路全体 */
.route-overview{margin-top:12px;padding:13px 15px;border-radius:14px}
.route-overview>summary{list-style:none;cursor:pointer}
.route-overview>summary::-webkit-details-marker{display:none}
.route-overview-head{display:flex;justify-content:space-between;font-size:10px;color:var(--muted);gap:10px;align-items:center}
.route-overview-head strong{margin-left:6px;font-size:13px;color:var(--dark)}
.route-expand{display:inline-block;margin-left:10px;font-size:16px;color:var(--muted);transition:transform .2s}
.route-overview[open] .route-expand{transform:rotate(180deg)}
.route-path-summary{display:block;font-size:12px;margin-top:6px;color:var(--dark);line-height:1.7}
.route-legs{padding:0;margin:10px 0 0;list-style:none;display:flex;flex-direction:column;gap:7px}
.route-legs li{display:flex;gap:9px;align-items:center;border:1px solid var(--line);border-radius:10px;padding:9px 10px;min-width:0}
.route-legs li.active{background:var(--mint);border-color:var(--green)}
.route-legs li.completed{opacity:.65}
.leg-number{display:grid;place-items:center;width:22px;height:22px;flex-shrink:0;border-radius:50%;background:var(--soft);color:var(--muted);font-size:10px}
.active .leg-number{background:var(--marker);color:var(--marker-ink)}
.route-legs li>div{min-width:0;flex:1}
.route-legs strong{display:block;font-size:12px}
.route-legs strong>span{font-weight:400;margin:0 3px;color:var(--muted)}
.route-legs small{display:block;font-size:10px;color:var(--muted);line-height:1.6;margin-top:2px}
.leg-kind{font-size:9px;white-space:nowrap;color:var(--muted)}
.route-legs .through-note{font-size:9px;color:var(--green);margin-left:4px}

/* 3) 乗車中の駅 */
.journey-card{margin-top:12px}
.journey{list-style:none;display:flex;position:relative;margin:0;padding:24px 12px 18px;overflow-x:auto;scrollbar-width:none;scroll-behavior:smooth}
.journey::-webkit-scrollbar{display:none}
.journey li{flex:1 0 auto;min-width:58px;position:relative;text-align:center;padding:25px 4px 0;font-size:11px;font-weight:600}
.journey li>span{display:block;white-space:nowrap}
.journey li:before{content:'';position:absolute;top:4px;left:50%;width:100%;height:3px;background:var(--line)}
.journey li:last-child:before{display:none}
.journey li.past:before{background:var(--map-past)}
.journey li:after{content:'';position:absolute;left:calc(50% - 5px);top:0;width:10px;height:10px;border:2px solid var(--map-past);background:var(--surface);border-radius:50%}
.journey li.past{color:var(--muted)}
.journey li.past:after{background:var(--map-past);border-color:var(--map-past)}
.journey li.current{color:var(--green);font-weight:800}
.journey li.current:after{background:var(--green);border:3px solid var(--surface);box-shadow:0 0 0 3px var(--mint);width:12px;height:12px;top:-1px;left:calc(50% - 6px)}
.journey li.next{color:var(--green)}
.journey li.next:after{border-color:var(--green)}
.journey li.destination:after{border-color:var(--orange)}
.journey li small{display:block;color:var(--muted);font-size:9px;line-height:1.4;margin-top:4px;min-height:13px;font-weight:500;white-space:nowrap}
.journey li.destination small{color:var(--orange)}
.journey li.current small,.journey li.next small{color:var(--green)}
.journey-empty{font-size:11px;color:var(--muted);padding:6px 18px 18px;line-height:1.7}

/* 4) 今走っている区間 */
.trip-bar{padding:17px 1px 13px;display:flex;align-items:center;gap:11px;width:100%;text-align:left;color:var(--dark)}
.line-badge{flex-shrink:0;border:2px solid var(--map-route);color:var(--green);background:var(--surface);font-weight:900;font-size:11px;border-radius:8px;display:grid;place-items:center;min-width:33px;height:33px;padding:0 3px;letter-spacing:-.02em}
.trip-bar-text{min-width:0;flex:1}
.trip-bar strong{font-size:14px}
.direction{font-size:11px;font-weight:500;margin-left:4px;color:var(--muted)}
.trip-bar p{font-size:10px;color:var(--muted);margin-top:3px;line-height:1.6}
.route-confirmed{font-size:9px;color:var(--muted);white-space:nowrap}

.location-card{padding:17px 20px 0}
.location-top{display:flex;justify-content:space-between;align-items:center;gap:8px}
.status{display:inline-flex;align-items:center;gap:7px;color:var(--green);background:var(--mint);font-size:12px;font-weight:700;padding:6px 11px;border-radius:7px}
.status i{width:6px;height:6px;background:currentColor;border-radius:50%;display:inline-block}
.status.moving{background:var(--blue-soft);color:var(--blue)}
.status.unknown{background:var(--amber-soft);color:var(--amber)}
.status.paused{background:var(--grey-soft);color:var(--grey)}
.status.moving i{animation:blink 1.4s ease-in-out infinite}
.accuracy{font-size:10px;color:var(--muted);text-align:right}
.current-block{padding:13px 0 15px;min-height:160px}
.current-block>p:first-child{font-size:12px;color:var(--muted);font-weight:500}
.current-block h2{font-size:50px;letter-spacing:.04em;font-weight:800;line-height:1.45;overflow-wrap:anywhere}
.current-block h2.long-name{font-size:31px;letter-spacing:0;line-height:1.6}
.current-block h2.between{font-size:28px;letter-spacing:0;line-height:1.6;margin:6px 0 2px}
.current-block h2.uncertain{font-size:25px;letter-spacing:0;line-height:1.6;margin:8px 0}
.english{font-size:11px;letter-spacing:.05em;color:var(--muted);overflow-wrap:anywhere;min-height:1em}
.context{font-size:12px;margin-top:8px;color:var(--green);line-height:1.7}
.station-pair{display:grid;grid-template-columns:1fr 1.3fr;padding-bottom:16px;gap:10px}
.station-pair span,.station-pair small{display:block}
.station-pair span{font-size:11px;color:var(--muted)}
.station-pair strong{display:block;font-size:22px;margin:4px 0 2px;font-weight:700;overflow-wrap:anywhere;line-height:1.35}
.station-pair strong.long-name{font-size:16px;line-height:1.6}
.station-pair small{font-size:10px;letter-spacing:.07em;color:var(--muted);min-height:14px}
.prev-box{padding:12px 4px}
.next-box{border-radius:12px;background:var(--soft);padding:12px 14px}
.next-box strong{color:var(--green)}
.position-note{margin:0 -20px;padding:10px 20px;background:var(--surface-subtle);border-top:1px solid var(--line);display:flex;align-items:center;gap:6px;color:var(--muted);font-size:10px;line-height:1.6}
.position-note svg{width:14px;height:14px;flex-shrink:0}
.notice{border:1px solid var(--line);background:var(--amber-soft);color:var(--dark);border-radius:12px;padding:12px 14px;margin:0 0 14px;font-size:12px;line-height:1.75}
.notice strong{display:block;margin-bottom:4px;color:var(--amber)}
.notice ol,.notice ul{margin:6px 0 0;padding-left:18px}
.notice li{margin:2px 0}
.resume-button{margin:0 0 16px!important}

.primary-button{width:100%;background:var(--marker);color:var(--marker-ink);border:0;border-radius:10px;min-height:48px;padding:12px;margin-top:18px;font-weight:700;font-size:14px}
.primary-button:disabled{background:var(--soft);color:var(--muted);cursor:not-allowed}
.secondary-button{width:100%;background:var(--surface);color:var(--dark);border:1px solid var(--line);border-radius:10px;min-height:46px;padding:11px;font-weight:700;font-size:13px}
.secondary-button.start{background:var(--marker);color:var(--marker-ink);border-color:var(--marker)}

.transfer-panel{margin-top:12px;padding:18px;background:var(--mint);border-color:var(--green)}
.transfer-panel-head{display:flex;align-items:center;gap:12px}
.transfer-symbol{font-size:26px;color:var(--green);width:36px;text-align:center}
.transfer-panel-head p{font-size:11px;color:var(--green)}
.transfer-panel h2{font-size:26px;margin-top:2px}
.transfer-panel>p{font-size:12px;color:var(--dark);margin-top:10px;line-height:1.8}
.transfer-panel .primary-button{margin-top:13px}
.transfer-panel small{display:block;color:var(--muted);font-size:10px;margin-top:10px;line-height:1.8}

/* 5) 地図 */
.map-card{margin-top:12px}
.map-wrap{position:relative;margin:4px 10px 0;border-radius:12px;overflow:hidden;background:var(--map-bg)}
.map-container{height:300px;background:var(--map-bg)}
.map-follow{position:absolute;right:10px;bottom:26px;z-index:500;border:0;border-radius:999px;background:var(--marker);color:var(--marker-ink);font-weight:800;font-size:14px;padding:12px 18px;min-height:46px;box-shadow:0 4px 16px #0005}
.map-legend{display:flex;align-items:center;gap:13px;padding:10px 16px 13px;font-size:10px;color:var(--muted);flex-wrap:wrap}
.map-legend span{display:flex;align-items:center;gap:5px}
.map-legend i{width:9px;height:9px;border-radius:50%;display:inline-block}
.legend-current{background:var(--green)}
.legend-station{background:var(--surface);border:2px solid var(--map-route)}
.legend-destination{background:var(--orange)}
.map-legend small{margin-left:auto;font-size:9px}
.leaflet-container{font-family:inherit;background:var(--map-bg)}
.leaflet-control-attribution{font-size:9px}
@media (prefers-color-scheme:dark){
  .leaflet-tile-pane{filter:invert(1) hue-rotate(180deg) brightness(.82) contrast(.9) saturate(.6)}
  .leaflet-control-zoom a,.leaflet-control-attribution{background:var(--surface)!important;color:var(--dark)!important;border-color:var(--line)!important}
  .leaflet-control-attribution a{color:var(--green)}
}
.train-marker{display:grid;place-items:center}
.train-marker .halo{position:absolute;width:44px;height:44px;border-radius:50%;background:var(--green);opacity:.18}
.train-marker .dot{position:relative;width:30px;height:30px;border-radius:50%;background:var(--marker);border:3px solid var(--surface);display:grid;place-items:center;color:var(--marker-ink);box-shadow:0 2px 8px #0004}
.train-marker .dot svg{width:17px;height:17px;stroke-width:2}
.train-marker.stale .dot{background:var(--grey);color:var(--surface)}
.station-label{background:var(--surface);color:var(--dark);border:1px solid var(--line);border-radius:6px;padding:2px 6px;font-size:11px;font-weight:700;box-shadow:none;white-space:nowrap}
.station-label.next{color:var(--green);border-color:var(--green)}
.station-label.dest{color:var(--orange);border-color:var(--orange)}
.station-label:before{display:none}

.controls{margin-top:12px;padding:14px}
.switch-row{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-top:12px;cursor:pointer}
.switch-row strong{display:block;font-size:13px}
.switch-row small{display:block;font-size:10px;color:var(--muted);margin-top:3px;line-height:1.6}
.switch{position:relative;width:44px;height:26px;display:block;flex-shrink:0}
.switch input{position:absolute;opacity:0;width:100%;height:100%;margin:0;cursor:pointer}
.switch>span{display:block;width:44px;height:26px;background:#c9d2cc;border-radius:26px;pointer-events:none;transition:background .2s}
.switch>span:after{content:'';position:absolute;top:3px;left:3px;background:#fff;width:20px;height:20px;border-radius:50%;transition:transform .2s}
.switch input:checked+span{background:var(--marker)}
.switch input:checked+span:after{transform:translateX(18px)}
.switch input:focus-visible+span{outline:3px solid var(--focus);outline-offset:3px}
.switch input:disabled+span{opacity:.4}
.controls-note{font-size:10px;color:var(--muted);line-height:1.7;margin-top:12px}

footer{padding:18px 0 24px;display:flex;justify-content:space-between;color:var(--muted);font-size:10px;gap:10px}

.demo-banner{position:sticky;top:0;z-index:1000;display:flex;align-items:center;gap:8px;background:var(--dark);color:var(--bg);font-size:11px;padding:calc(env(safe-area-inset-top) + 8px) 14px 8px;line-height:1.5}
.demo-tag{font-size:9px;letter-spacing:.08em;border:1px solid currentColor;border-radius:4px;padding:2px 5px;opacity:.8}
.demo-banner #demo-text{flex:1}
.demo-exit{color:inherit;font-weight:700;white-space:nowrap}

/* dialogs */
dialog.sheet{border:1px solid var(--line);border-radius:20px;padding:20px;max-width:520px;width:calc(100% - 24px);max-height:calc(100dvh - 24px);overflow-y:auto;color:var(--dark);background:var(--surface);box-shadow:0 24px 100px #0006}
dialog::backdrop{background:#0b1a1460;backdrop-filter:blur(3px)}
.dialog-head{display:flex;justify-content:space-between;align-items:center;gap:10px}
.dialog-head p{color:var(--green);font-size:11px;margin-bottom:6px}
.dialog-head h2{font-size:19px}
.close-button{border:0;border-radius:50%;background:var(--soft);width:36px;height:36px;color:var(--muted);font-size:22px;flex-shrink:0}
.dialog-description{font-size:11px;color:var(--muted);margin:12px 0 4px;line-height:1.8}
.dialog-footnote{font-size:10px;color:var(--muted);margin-top:14px;line-height:1.8}
.form-label{display:block;font-size:11px;margin:15px 0 6px;color:var(--muted)}
.form-label span{font-size:9px;margin-left:4px}
.form-pair{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.station-field{text-align:left;font-weight:700;cursor:pointer}
.station-field.empty{color:var(--muted);font-weight:500}
.candidate-fieldset{padding:0;border:0;margin:18px 0 0;min-width:0}
.candidate-fieldset legend{font-size:11px;color:var(--muted);margin-bottom:8px}
.route-candidates{display:grid;gap:8px}
.candidate{border:1px solid var(--line);border-radius:10px;display:flex;gap:10px;padding:12px;cursor:pointer;align-items:flex-start}
.candidate.selected{background:var(--mint);border-color:var(--green)}
.candidate>span{flex:1;min-width:0}
.candidate strong{display:flex;justify-content:space-between;font-size:12px;line-height:1.7;gap:8px}
.candidate strong small{font-size:10px;color:var(--muted);white-space:nowrap;font-weight:400}
.candidate>span>span{display:block;font-size:11px;color:var(--muted);line-height:1.8;margin-top:4px}
.candidate input{width:18px;height:18px;margin:3px 0 0;flex-shrink:0;accent-color:var(--marker)}
.candidate-fieldset>p{font-size:10px;color:var(--muted);line-height:1.8;margin-top:8px}
.routes-list{list-style:none;margin:14px 0 0;padding:0;display:grid;gap:10px}
.routes-list li{border:1px solid var(--line);border-radius:12px;padding:12px 14px}
.routes-list li.in-use{border-color:var(--green);background:var(--mint)}
.routes-list .r-head{display:flex;align-items:center;gap:8px}
.routes-list .r-head strong{font-size:14px;flex:1;min-width:0;overflow-wrap:anywhere}
.chip{font-size:9px;font-weight:700;border-radius:5px;padding:2px 6px;background:var(--marker);color:var(--marker-ink);white-space:nowrap}
.routes-list p{font-size:12px;margin-top:5px;line-height:1.6}
.routes-list small{display:block;font-size:10px;color:var(--muted);margin-top:3px;line-height:1.6}
.r-actions{display:flex;gap:8px;margin-top:10px}
.r-actions button{flex:1;min-height:38px;border-radius:9px;border:1px solid var(--line);background:var(--surface);color:var(--dark);font-weight:700;font-size:12px}
.r-actions button.danger{color:var(--danger)}
.r-actions button.danger-solid{background:var(--danger);border-color:var(--danger);color:var(--surface)}
.r-confirm{font-size:12px;margin-top:10px;color:var(--danger)}
.station-sheet{min-height:min(560px,calc(100dvh - 24px))}
#station-search{margin-top:14px}
.station-hint{font-size:10px;color:var(--muted);margin:8px 2px}
.station-results{list-style:none;margin:6px 0 0;padding:0}
.station-results li+li{border-top:1px solid var(--line)}
.station-results button{width:100%;text-align:left;background:none;border:0;color:var(--dark);padding:11px 4px;min-height:48px}
.station-results button strong{display:block;font-size:15px}
.station-results button strong span{font-size:11px;font-weight:400;color:var(--muted);margin-left:4px}
.station-results button small{display:block;font-size:10px;color:var(--muted);margin-top:2px;line-height:1.5}
.station-results button:hover,.station-results button:focus-visible{background:var(--soft)}
.station-results button.selected strong{color:var(--green)}

@keyframes blink{0%,100%{opacity:1}50%{opacity:.35}}
@media (min-width:700px){.map-container{height:360px}.current-block h2{font-size:56px}}
@media (max-width:360px){.current-block h2{font-size:42px}.current-block h2.between{font-size:24px}.station-pair strong{font-size:19px}}
@media (prefers-reduced-motion:reduce){*{animation:none!important;transition:none!important;scroll-behavior:auto!important}}

/* 近くに複数の路線があるときのプルダウン */
.line-choice{margin:-4px 0 12px;padding:11px 12px;border:1.5px solid var(--blue);border-radius:14px;background:var(--blue-soft)}
.line-choice label{display:block;font-size:11px;font-weight:700;color:var(--blue);margin-bottom:7px}
.line-choice.manual{border-color:var(--amber);background:var(--amber-soft)}
.line-choice.manual label{color:var(--amber)}
.line-select-wrap{position:relative}
.line-select-wrap::after{content:"";position:absolute;right:14px;top:50%;width:8px;height:8px;margin-top:-6px;border-right:2px solid var(--dark);border-bottom:2px solid var(--dark);transform:rotate(45deg);pointer-events:none}
.line-choice select{width:100%;min-height:46px;padding:0 38px 0 13px;border:1px solid var(--line, rgba(0,0,0,.12));border-radius:11px;background:var(--surface);color:var(--dark);font:inherit;font-size:15px;font-weight:700;-webkit-appearance:none;appearance:none;cursor:pointer}
.line-choice select:focus-visible{outline:2px solid var(--blue);outline-offset:2px}

/* 乗車中の駅：電車マーク（右向き・駅間の進み具合の位置） */
.journey li.partial:before{background:linear-gradient(90deg,var(--map-past) var(--fill),var(--line) var(--fill))}
.journey li.jt{position:absolute;left:0;top:24px;min-width:0;width:40px;height:22px;padding:0;margin:-15px 0 0 -20px;flex:none;z-index:2;pointer-events:none;transition:transform .9s ease,top .3s}
.journey li.jt:before,.journey li.jt:after{display:none}
.journey li.jt svg{display:block;width:40px;height:22px;filter:drop-shadow(0 1px 1.5px rgba(0,0,0,.25))}
.jt-body{fill:var(--green)}
.jt-win{fill:var(--surface)}
.jt-stripe{fill:var(--surface);opacity:.55}
.jt-wheel{fill:var(--dark)}
.journey li.jt.nodir .jt-win{opacity:.6}

/* 左右にスクロールできることが分かるよう、端をぼかす */
.journey{-webkit-mask-image:linear-gradient(90deg,transparent 0,#000 18px,#000 calc(100% - 18px),transparent 100%);mask-image:linear-gradient(90deg,transparent 0,#000 18px,#000 calc(100% - 18px),transparent 100%);touch-action:pan-x pan-y;-webkit-overflow-scrolling:touch}
