/* Station wayfinding: warm paper by day, a quiet departure board by night. */
:root {
  color-scheme: light;
  --paper:#f3f1eb; --surface:#fffefb; --surface-soft:#eceeea; --board:#e9edf0;
  --ink:#202e3e; --muted:#5f6b75; --line:#d6dcd9; --line-strong:#a7b4be;
  --blue:#2567a6; --blue-dark:#23578d; --blue-soft:#e5eff8;
  --purple:#794995; --purple-soft:#f0e9f5;
  --action:#253d55; --action-text:#fffefb; --action-hover:#365673;
  --chat-user:#235b91; --chat-user-text:#ffffff; --chat-assistant:#fffefb;
  --track:#bac7cd; --track-range:#86a9c4; --point:#fffefb;
  --warning:#79531f; --warning-bg:#f5ebd7; --error:#a33440; --success:#267b68;
  --shadow:0 12px 32px #25374905;
  --sans:"Bahnschrift","Microsoft JhengHei","PingFang TC",sans-serif;
  --display:"Iowan Old Style","Noto Serif TC","PMingLiU",serif;
  --mono:"Bahnschrift","Consolas",monospace;
  font-family:var(--sans); color:var(--ink); background:var(--paper); font-synthesis:none;
}
:root[data-theme="dark"] {
  color-scheme:dark;
  --paper:#111923; --surface:#192430; --surface-soft:#202d3a; --board:#16212c;
  --ink:#e8eef4; --muted:#a3b2c0; --line:#344453; --line-strong:#586e80;
  --blue:#85b9ee; --blue-dark:#a0c9f3; --blue-soft:#213b51;
  --purple:#c2a0e2; --purple-soft:#382e4c;
  --action:#b7d4f0; --action-text:#152434; --action-hover:#d2e5f7;
  --chat-user:#295987; --chat-user-text:#ffffff; --chat-assistant:#243241;
  --track:#485e70; --track-range:#789cb9; --point:#192430;
  --warning:#edc790; --warning-bg:#3a3227; --error:#ffa4b0; --success:#84c9b5;
  --shadow:0 16px 40px #00000012;
}
*{box-sizing:border-box}
body{margin:0}
button,input,textarea{font:inherit;color:inherit}
button,a{-webkit-tap-highlight-color:transparent;touch-action:manipulation}
button{cursor:pointer;border:0;transition:background .18s,color .18s,border-color .18s,transform .18s}
button:disabled{cursor:wait;opacity:.48}
a{color:inherit;text-decoration:none}
button:focus-visible,a:focus-visible,input:focus-visible,textarea:focus-visible,summary:focus-visible{outline:3px solid var(--purple);outline-offset:4px}
button:active:not(:disabled){transform:translateY(1px)}
::selection{background:var(--blue);color:var(--paper)}
.icon{width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round;flex-shrink:0}
.icon-definitions{position:absolute;width:0;height:0;overflow:hidden}
.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}

/* Compact journey workspace with the route map directly in the planner. */
.header-inner,.shell{max-width:1200px;margin:auto;padding-left:28px;padding-right:28px}
.site-header{border-bottom:1px solid var(--line)}
.header-inner{min-height:62px;display:flex;align-items:center;justify-content:space-between;gap:16px}
.brand{display:flex;align-items:center;gap:10px}
.brand-icon{display:grid;place-items:center;width:30px;height:34px;border:1px solid var(--ink);border-radius:12px 12px 3px 3px}
.brand-icon .icon{width:19px;height:19px}
.brand strong{font-size:16px;letter-spacing:.04em;font-weight:600}
.brand-divider{font-weight:400;color:var(--line-strong);margin:0 7px}
.brand small{display:none}
nav{display:flex;align-items:center;gap:18px}
.official-link{font-size:11px;color:var(--muted);padding:8px 0}
.theme-switch{display:flex;padding:3px;border:1px solid var(--line);border-radius:24px}
.theme-switch button{display:flex;align-items:center;justify-content:center;gap:6px;min-height:32px;padding:0 10px;background:transparent;border-radius:20px;font-size:11px;color:var(--muted)}
.theme-switch .icon{width:16px;height:16px}
.theme-switch button[aria-pressed="true"]{background:var(--ink);color:var(--paper)}
.theme-switch button:hover:not([aria-pressed="true"]){background:var(--surface-soft)}
.page-heading{display:flex;align-items:center;justify-content:space-between;gap:14px;padding:18px 0}
h1{font-family:var(--display);font-size:25px;font-weight:600;letter-spacing:.04em;line-height:1.25;margin:0}
.model-status{font-size:10px;color:var(--muted);display:flex;align-items:center;gap:7px;white-space:nowrap}
.model-status:before{content:"";width:6px;height:6px;border-radius:50%;background:var(--line-strong)}
.model-status.ready:before{background:var(--success)}
.model-status.failed:before{background:var(--error)}
.workspace{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:20px;align-items:start;padding-bottom:18px}
.planner,.results-panel{min-width:0;padding:20px;border:1px solid var(--line);border-radius:5px}
.planner{background:var(--surface)}
.results-panel{background:var(--board)}
.panel-heading{display:flex;justify-content:space-between;align-items:center;gap:10px;margin-bottom:15px}
.panel-heading h2{font-size:15px;letter-spacing:.02em;font-weight:600;margin:0}
.small-note,.scheduled-tag{font-size:10px;color:var(--muted)}
.journey-summary{display:flex;align-items:center;gap:12px;cursor:pointer;list-style:none;font-size:15px;font-weight:600;min-height:24px}
.journey-summary::-webkit-details-marker{display:none}
.journey-summary-values{margin-left:auto;text-align:right}
.journey-summary strong{display:block;font-size:12px;color:var(--ink);font-weight:400}
.journey-summary small{display:block;font-size:10px;color:var(--muted);font-weight:400;margin-top:4px}
.journey-toggle{font-size:10px;color:var(--muted);font-weight:400}
.journey-toggle:after{content:"修改 ＋"}
#journey-panel[open]>.journey-summary{margin-bottom:14px}
#journey-panel[open]>.journey-summary .journey-summary-values{display:none}
#journey-panel[open] .journey-toggle{margin-left:auto}
#journey-panel[open] .journey-toggle:after{content:"收合 −"}
.route-fields{display:grid;grid-template-columns:minmax(0,1fr) 34px minmax(0,1fr);gap:8px;align-items:center;margin-bottom:18px}
.route-field{background:var(--surface);text-align:left;border:1px solid var(--line-strong);border-radius:4px;padding:12px;min-width:0;align-self:stretch}
.route-field:hover,.route-field.is-editing{border-color:var(--blue);background:var(--blue-soft)}
.route-field.destination:hover,.route-field.destination.is-editing{border-color:var(--purple);background:var(--purple-soft)}
.field-label{font-size:11px;color:var(--muted);display:flex;align-items:center;gap:6px}
.field-label i,.map-legend i{width:5px;height:5px;border-radius:50%;background:var(--blue)}
.destination .field-label i,.map-legend i:last-child{background:var(--purple)}
.selected-station{display:flex;flex-wrap:wrap;align-items:center;gap:7px;margin-top:9px;min-height:24px}
.selected-station b{font-family:var(--mono);color:var(--blue);font-size:13px;font-weight:500}
.destination .selected-station b{color:var(--purple)}
.selected-station strong{font-size:17px;line-height:1.35;font-weight:600}
.swap-button{width:34px;height:34px;border:1px solid var(--line);border-radius:50%;background:var(--surface);display:grid;place-items:center;color:var(--muted)}
.swap-button .icon{width:18px}
.swap-button:hover{color:var(--blue);background:var(--blue-soft)}
.train-filter{min-width:0;border:0;padding:0;margin:0 0 15px}
.train-filter legend,.time-heading label{font-size:11px;font-weight:600;margin-bottom:7px}
.train-options{display:flex;gap:7px}
.train-options label{flex:1;position:relative;cursor:pointer;min-width:0}
.train-options input{position:absolute;inset:0;width:100%;height:100%;margin:0;opacity:0;cursor:pointer}
.train-options span{min-height:37px;border:1px solid var(--line);border-radius:3px;display:flex;align-items:center;justify-content:center;gap:6px;font-size:12px}
.train-options i{width:5px;height:5px;border-radius:50%;background:var(--blue)}
.train-options .express-option i{background:var(--purple)}
.train-options input:checked+span{background:var(--surface-soft);border-color:var(--ink);font-weight:600}
.commuter-option input:checked+span{background:var(--blue-soft);border-color:var(--blue);color:var(--blue-dark)}
.express-option input:checked+span{background:var(--purple-soft);border-color:var(--purple);color:var(--purple)}
.train-options input:focus-visible+span{outline:3px solid var(--purple);outline-offset:3px}
.train-options input:disabled+span{opacity:.5;cursor:wait}
.time-heading{display:flex;justify-content:space-between;align-items:center;margin-bottom:7px}
.time-heading label{margin:0}
.time-heading button{background:transparent;color:var(--blue);font-size:11px;padding:4px 0}
.query-controls,.datetime-fields{display:flex;gap:8px;min-width:0}
.datetime-fields{flex:1;gap:6px}
input[type=date],input[type=time]{min-width:0;border:1px solid var(--line);border-radius:3px;background:var(--surface);padding:8px;font-size:12px;height:42px}
input[type=date]{width:60%}input[type=time]{width:40%}
.primary-button{display:flex;align-items:center;justify-content:center;gap:10px;height:42px;padding:0 13px;white-space:nowrap;border-radius:3px;background:var(--action);color:var(--action-text);font-size:12px;font-weight:600}
.primary-button:hover:not(:disabled){background:var(--action-hover)}
.primary-button .icon{width:16px}
.form-foot{display:flex;flex-wrap:wrap;justify-content:space-between;gap:4px 8px;margin-top:10px;font-size:10px;color:var(--muted);line-height:1.5}
.form-error{color:var(--error);font-size:12px;line-height:1.7;margin-bottom:0}

/* Results keep the time prominent; repeated explanations stay in history. */
.empty-result{display:flex;align-items:center;gap:12px;min-height:68px;padding:10px 0 20px;color:var(--muted)}
.empty-symbol{display:grid;place-items:center;width:33px;height:33px;flex-shrink:0;border:1px solid var(--line-strong);border-radius:50%}
.empty-symbol .icon{width:18px;height:18px}
.empty-result p{font-size:12px;line-height:1.8;margin:0}
.result-route{display:flex;align-items:center;justify-content:space-between;gap:10px;font-size:17px;font-weight:600;line-height:1.4}
.result-route strong{font-family:var(--mono);font-size:11px;color:var(--blue);display:block;margin-bottom:3px;font-weight:500}
.result-route>div:last-child{text-align:right}
.result-route>div:last-child strong{color:var(--purple)}
.result-route .icon{width:17px;color:var(--muted)}
.result-query{font-size:10px;color:var(--muted);line-height:1.6;margin:9px 0 0}
.dirty-note,.result-warning{font-size:12px;line-height:1.8;color:var(--warning);background:var(--warning-bg);padding:9px 10px;border-radius:3px;margin:10px 0}
.train-row{display:grid;grid-template-columns:1fr auto;gap:7px 10px;align-items:center;border-bottom:1px solid var(--line);padding:13px 0 11px}
.train-time{font-family:var(--mono);font-variant-numeric:tabular-nums;font-size:40px;font-weight:400;letter-spacing:-1px;line-height:1}
.train-time small{font-family:var(--sans);font-size:10px;letter-spacing:0;color:var(--muted);display:block;margin-top:6px}
.train-wait{font-size:10px;color:var(--muted);text-align:right;align-self:start;padding-top:4px;max-width:150px;line-height:1.7}
.train-wait b{font-family:var(--mono);font-size:17px;font-weight:400;color:var(--ink);margin-right:3px}
.train-row-bottom{grid-column:1/-1;display:flex;justify-content:space-between;align-items:center;gap:8px}
.train-type{display:inline-flex;align-items:center;gap:6px;font-size:11px;line-height:1.5;color:var(--blue-dark);font-weight:600}
.train-type:before{content:"";width:5px;height:5px;flex-shrink:0;border-radius:50%;background:var(--blue)}
.express .train-type{color:var(--purple)}.express .train-type:before{background:var(--purple)}
.train-detail{font-size:10px;color:var(--muted);text-align:right;line-height:1.6}
.alight-note{font-size:12px;line-height:1.7;margin:10px 0}
.result-answer,.error-message{font-size:13px;line-height:1.8;margin:12px 0;overflow-wrap:anywhere}
.error-message{color:var(--error)}
.evidence{font-size:10px;color:var(--muted);margin:7px 0 12px}
.evidence summary{cursor:pointer;padding:4px 0}
.evidence pre{background:var(--surface);color:var(--muted);font:10px/1.8 var(--mono);white-space:pre-wrap;word-break:break-all;max-height:200px;overflow:auto;padding:10px;border:1px solid var(--line);border-radius:3px}
.evidence p{font-size:11px;line-height:1.8}
.loading-result{display:flex;align-items:center;justify-content:center;gap:10px;min-height:95px;color:var(--blue-dark);font-size:13px;flex-wrap:wrap}
.loading-result small{font-size:10px;color:var(--muted)}
.spinner{width:19px;height:19px;border:2px solid var(--line);border-top-color:var(--blue);border-radius:50%;animation:spin .9s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}
.chat-section{border-top:1px solid var(--line);padding-top:12px}
.chat-heading{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:8px}
.chat-heading h3{font-size:12px;font-weight:600;margin:0}
.chat-heading button{font-size:10px;color:var(--muted);background:transparent;padding:5px 0 5px 8px}
.composer{display:flex;gap:7px;align-items:center;padding:8px 9px;border:1px solid var(--line-strong);border-radius:4px;background:var(--surface)}
.composer:focus-within{border-color:var(--blue)}
.composer textarea{resize:vertical;width:100%;min-width:0;min-height:34px;max-height:100px;padding:6px 0;border:0;background:transparent;font-size:13px;line-height:1.6}
.composer textarea:focus-visible{outline:none}
.composer textarea::placeholder{font-size:12px;color:var(--muted);opacity:1}
.composer button{display:grid;place-items:center;width:34px;height:34px;flex-shrink:0;border-radius:3px;background:var(--action);color:var(--action-text)}
.composer button:hover:not(:disabled){background:var(--action-hover)}
.composer .icon{width:17px}
.chat-caption{font-size:10px;line-height:1.6;color:var(--muted);margin:7px 0 0}
.conversation-history{font-size:11px;color:var(--muted);margin:0 0 12px}
.conversation-history summary{cursor:pointer;padding:4px 0}
.chat-log{max-height:340px;overflow:auto;overscroll-behavior:contain;scrollbar-width:thin;scrollbar-color:var(--line-strong) transparent;margin-top:8px;padding:4px 7px 2px 2px;color:var(--ink)}
.chat-log:focus-visible{outline:2px solid var(--blue);outline-offset:3px}
.chat-message{display:flex;flex-direction:column;align-items:flex-start;gap:5px;margin:0 0 16px;padding-right:20px}
.chat-message:last-child{margin-bottom:4px}
.chat-author{font-size:11px;font-weight:600;color:var(--purple);padding:0 3px}
.chat-bubble{max-width:100%;margin:0;border:1px solid var(--line-strong);border-radius:3px 13px 13px 13px;background:var(--chat-assistant);color:var(--ink);padding:11px 13px;font-size:14px;line-height:1.85;white-space:pre-wrap;overflow-wrap:anywhere}
.chat-message.user{align-items:flex-end;padding-right:0;padding-left:28px}
.chat-message.user .chat-author{color:var(--blue-dark)}
.chat-message.user .chat-bubble{border-color:var(--chat-user);border-radius:13px 3px 13px 13px;background:var(--chat-user);color:var(--chat-user-text)}
.candidate-buttons{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:10px}
.candidate-buttons button,.retry{border:1px solid var(--line-strong);background:var(--surface);padding:9px 12px;border-radius:3px;font-size:12px;color:var(--blue-dark)}
footer{display:flex;align-items:center;justify-content:space-between;gap:8px;border-top:1px solid var(--line);padding:12px 0 16px;color:var(--muted);font-size:10px;line-height:1.7}
footer p{margin:0}footer>div{display:flex;gap:16px}footer button,footer a{background:transparent;font-size:10px;padding:0;color:var(--muted)}
footer button:hover,footer a:hover{text-decoration:underline;text-underline-offset:3px}

/* Help dialog and the inline route map. */
body:has(dialog[open]){overflow:hidden}
dialog{width:min(calc(100vw - 28px),480px);max-height:calc(100dvh - 28px);overflow:auto;padding:22px;border:1px solid var(--line-strong);border-radius:7px;background:var(--surface);color:var(--ink);box-shadow:0 24px 70px #00000033}
dialog::backdrop{background:#07111b99;backdrop-filter:blur(3px)}
.dialog-heading{display:flex;align-items:center;justify-content:space-between;margin-bottom:15px;gap:10px}
.dialog-heading h2{font-size:18px;font-weight:600;margin:0}
.dialog-close{display:grid;place-items:center;width:34px;height:34px;background:transparent;border:1px solid var(--line);border-radius:50%;flex-shrink:0}
dialog p{color:var(--muted);font-size:12px;line-height:1.8}
.route-map-panel{margin:0 0 16px;padding:0 0 12px;border-bottom:1px solid var(--line)}
.map-heading{display:flex;align-items:center;justify-content:space-between;gap:8px;margin:0 2px 14px}
.map-heading p{margin:0;font-size:11px;color:var(--muted)}
.map-legend{display:flex;align-items:center;gap:5px;color:var(--muted);font-size:10px;white-space:nowrap}
.station-map{position:relative;display:grid;grid-template-columns:repeat(8,minmax(0,1fr));grid-template-rows:repeat(3,82px);isolation:isolate}
.map-track{position:absolute;inset:0;width:100%;height:100%;z-index:-1;overflow:visible;pointer-events:none}
.track-base,.track-selected{fill:none;stroke:var(--track);stroke-width:3;stroke-linecap:round;stroke-linejoin:round}
.track-selected{stroke:var(--track-range);stroke-width:4}
.map-station{padding:8px 2px 0;display:flex;flex-direction:column;align-items:center;gap:3px;background:transparent;border-radius:4px;position:relative;min-width:0;align-self:start;height:70px}
.map-station:hover{background:var(--surface-soft)}
.station-point{width:12px;height:12px;border-radius:50%;border:2px solid var(--track);background:var(--point);display:block;flex-shrink:0}
.map-station.in-range .station-point{border-color:var(--track-range);background:var(--blue-soft)}
.map-station.is-origin .station-point{border-color:var(--blue);background:var(--blue);box-shadow:0 0 0 3px var(--blue-soft)}
.map-station.is-destination .station-point{border-color:var(--purple);background:var(--purple);box-shadow:0 0 0 3px var(--purple-soft)}
.map-station.is-origin:after,.map-station.is-destination:after{content:"起";position:absolute;top:-5px;left:calc(50% + 8px);font-size:8px;color:var(--blue)}
.map-station.is-destination:after{content:"迄";color:var(--purple)}
.station-code{font-family:var(--mono);font-size:10px;font-weight:500;color:var(--muted)}
.station-name{font-size:12px;line-height:1.35;max-width:72px;overflow-wrap:anywhere}
.map-station.is-origin .station-name,.map-station.is-origin .station-code{color:var(--blue-dark);font-weight:700}
.map-station.is-destination .station-name,.map-station.is-destination .station-code{color:var(--purple);font-weight:700}
.map-caption{color:var(--muted);font-size:10px;line-height:1.6;margin:8px 0 0}

@media(max-width:1080px){.query-controls{flex-direction:column}.primary-button{width:100%}}
@media(max-width:920px){.workspace{grid-template-columns:1fr}.query-controls{flex-direction:row}.primary-button{width:auto}}
@media(max-width:600px){
 .header-inner,.shell{padding-left:16px;padding-right:16px}.header-inner{min-height:56px;gap:10px}.brand{gap:8px}.brand strong{font-size:14px}.brand-icon{width:27px;height:30px}.brand-divider{margin:0 5px}
 .official-link{display:none}.theme-switch button{padding:0 9px;min-height:30px}.theme-switch button span{display:none}
 .page-heading{padding:14px 0}h1{font-size:22px}.model-status{font-size:9px}
 .workspace{gap:12px;padding-bottom:12px}.planner,.results-panel{padding:16px}.panel-heading{margin-bottom:12px}
 .route-fields{gap:6px;grid-template-columns:minmax(0,1fr) 30px minmax(0,1fr);margin-bottom:14px}.route-field{padding:10px}.swap-button{width:30px;height:30px}.selected-station strong{font-size:16px}.selected-station{gap:5px}.selected-station b{font-size:12px}
 .primary-button{padding:0 10px;gap:6px;font-size:11px}.primary-button .icon{display:none}.train-time{font-size:37px}.train-filter{margin-bottom:12px}.form-foot{font-size:9px}
 .station-name{font-size:11px}.map-heading p{font-size:10px}
 footer{flex-wrap:wrap;font-size:9px;padding-bottom:12px}footer button,footer a{font-size:9px}
}
@media(max-width:520px){
 .query-controls{flex-direction:column}.primary-button{width:100%}.primary-button .icon{display:block}
 .station-map{grid-template-columns:repeat(4,minmax(0,1fr));grid-template-rows:repeat(6,72px)}.station-name{font-size:12px}.map-legend{font-size:9px}
 .map-caption{font-size:9px}
}
@media(max-width:380px){
 .header-inner,.shell{padding-left:12px;padding-right:12px}.brand-icon{display:none}.planner,.results-panel{padding:13px}.route-field{padding:9px}.selected-station{flex-direction:column;align-items:flex-start;gap:4px}.selected-station strong{font-size:15px}.selected-station b{font-size:11px}.train-options span{font-size:11px}.small-note{font-size:9px}.form-foot{font-size:8px}.map-legend{display:none}
 .train-wait{max-width:125px}.train-detail{font-size:9px}
}
@media(prefers-reduced-motion:reduce){*,*::before,*::after{animation:none!important;transition:none!important;scroll-behavior:auto!important}}
