:root {
  color-scheme: light;
  --paper: #f5f6f2;
  --panel: #fcfdf9;
  --ink: #17221f;
  --muted: #66736e;
  --line: #d8ded9;
  --green: #0d6254;
  --green-dark: #08473e;
  --night: #254f6d;
  --danger: #b83f3a;
  font-family: "PingFang SC", "Noto Sans CJK SC", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--green-dark); }

.topbar {
  min-height: 104px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 32px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.eyebrow { margin: 0 0 6px; color: var(--green); font: 700 11px/1.2 ui-monospace, monospace; letter-spacing: .13em; }
h1 { margin: 0; font-size: clamp(27px, 3vw, 42px); line-height: 1; letter-spacing: -.04em; }
.source-summary { display: flex; align-items: baseline; gap: 8px; color: var(--muted); white-space: nowrap; }
.source-summary strong { color: var(--green); font: 700 32px/1 ui-monospace, monospace; }

.layout { display: grid; grid-template-columns: minmax(350px, 410px) 1fr; grid-template-rows: auto minmax(0, 1fr); height: calc(100vh - 104px); min-height: 620px; }
.decision-panel, .results-panel { min-width: 0; border-right: 1px solid var(--line); background: var(--panel); }
.decision-panel { border-bottom: 1px solid var(--line); }
.decision-intro { padding: 20px 20px 0; }
.decision-intro h2 { margin: 4px 0 7px; font-size: 21px; letter-spacing: -.02em; }
.decision-intro > p:last-child { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.step-label { margin: 0; color: var(--green); font-size: 11px; font-weight: 800; letter-spacing: .08em; }
.controls { padding: 14px 20px 18px; }
.primary-button { width: 100%; min-height: 48px; border: 0; border-radius: 8px; background: var(--green); color: white; font-weight: 700; cursor: pointer; }
.primary-button:hover { background: var(--green-dark); }
.primary-button:disabled { opacity: .65; cursor: wait; }
.status { min-height: 18px; margin: 8px 0 12px; color: var(--muted); font-size: 12px; }
input, select { width: 100%; min-height: 44px; border: 1px solid var(--line); border-radius: 7px; background: white; color: var(--ink); padding: 0 11px; }
select:disabled { background: #f1f3ef; color: #89928e; }
input:focus, select:focus, button:focus-visible, a:focus-visible { outline: 3px solid rgba(13, 98, 84, .24); outline-offset: 2px; }
.preference-grid { display: grid; gap: 10px; }
.preference-grid label > span { display: block; margin: 0 0 5px; color: var(--muted); font-size: 11px; font-weight: 700; }
.manual-tools { border-top: 1px solid var(--line); }
.manual-tools summary { padding: 13px 20px; color: var(--green-dark); font-size: 13px; font-weight: 700; cursor: pointer; }
.manual-tools summary::marker { color: var(--green); }
.manual-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 0 20px 18px; }

.results-panel { display: flex; min-height: 0; flex-direction: column; }
.list-heading { display: flex; justify-content: space-between; gap: 12px; padding: 12px 20px; color: var(--muted); font-size: 12px; border-bottom: 1px solid var(--line); }
.list-heading strong { color: var(--ink); }
.hospital-list { flex: 1; min-height: 0; overflow: auto; }
.hospital-card { width: 100%; display: grid; grid-template-columns: 32px 1fr auto; gap: 11px; align-items: start; padding: 15px 20px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: inherit; text-align: left; cursor: pointer; }
.hospital-card:hover, .hospital-card[aria-current="true"] { background: #edf3ef; }
.rank { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: #dbe9e4; color: var(--green-dark); font: 700 12px/1 ui-monospace, monospace; }
.rank.is-nearest { background: var(--green); color: white; box-shadow: 0 0 0 5px rgba(13, 98, 84, .11); }
.hospital-name { margin: 0 0 5px; font-size: 14px; line-height: 1.4; font-weight: 700; }
.hospital-meta { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.hospital-hours { margin: 3px 0 0; color: var(--green-dark); font-size: 12px; line-height: 1.5; }
.distance { color: var(--night); font: 700 12px/1.4 ui-monospace, monospace; white-space: nowrap; }
.empty-state { display: grid; justify-items: center; padding: 40px 28px; text-align: center; }
.empty-state h3 { margin: 8px 0 6px; font-size: 16px; }
.empty-state p { max-width: 290px; margin: 0 0 14px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.empty-icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: #e2eee9; color: var(--green); font-size: 26px; }
.secondary-button { min-height: 42px; padding: 0 14px; border: 1px solid var(--green); border-radius: 7px; background: white; color: var(--green-dark); font-weight: 700; cursor: pointer; }

.map-shell { grid-column: 2; grid-row: 1 / 3; position: relative; height: 100%; min-height: 580px; overflow: hidden; background: #e6ebe7; }
.map { width: 100%; height: 100%; }
.map-setup { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; padding: 32px; text-align: center; background: radial-gradient(circle at 50% 46%, #f9fbf6 0 15%, transparent 16%), linear-gradient(135deg, #e1eae4, #f4f6f1); }
.map-setup[hidden] { display: none; }
.map-setup h2 { margin: 12px 0 6px; font-size: 24px; }
.map-setup p { max-width: 450px; margin: 0 0 18px; color: var(--muted); line-height: 1.6; }
.map-setup code { padding: 9px 12px; border: 1px solid var(--line); border-radius: 6px; background: rgba(255,255,255,.72); font-size: 12px; }
.setup-number { display: grid; place-items: center; width: 88px; height: 88px; border: 2px solid var(--green); border-radius: 50%; color: var(--green); font: 700 30px/1 ui-monospace, monospace; box-shadow: 0 0 0 12px rgba(13, 98, 84, .08); }
.map-status, .map-legend { position: absolute; left: 18px; z-index: 5; padding: 8px 10px; border: 1px solid rgba(23,34,31,.12); border-radius: 6px; background: rgba(252,253,249,.92); color: var(--muted); font-size: 12px; box-shadow: 0 6px 24px rgba(23,34,31,.08); }
.map-status { top: 18px; }
.map-legend { bottom: 18px; display: flex; align-items: center; gap: 7px; }
.map-legend i { width: 10px; height: 10px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(13,98,84,.15); }

.detail-panel { position: absolute; right: 18px; bottom: 18px; z-index: 6; width: min(360px, calc(100% - 36px)); padding: 18px; border: 1px solid rgba(23,34,31,.13); border-radius: 10px; background: rgba(252,253,249,.96); box-shadow: 0 16px 50px rgba(23,34,31,.18); backdrop-filter: blur(9px); }
.detail-panel h2 { margin: 0 28px 8px 0; font-size: 18px; line-height: 1.35; }
.detail-panel p { margin: 5px 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.detail-panel strong { color: var(--ink); }
.detail-actions { display: flex; gap: 8px; margin-top: 14px; }
.detail-actions a { flex: 1; padding: 9px 10px; border-radius: 6px; background: var(--green); color: white; text-align: center; text-decoration: none; font-size: 13px; font-weight: 700; }
.detail-actions a.secondary { background: #e7ece8; color: var(--green-dark); }
.detail-close { position: absolute; top: 2px; right: 2px; display: grid; place-items: center; width: 44px; height: 44px; border: 0; background: transparent; color: var(--muted); font-size: 22px; cursor: pointer; }

.hospital-marker, .user-marker { display: grid; place-items: center; border-radius: 50%; color: white; font: 700 10px/1 ui-monospace, monospace; }
.hospital-marker { width: 20px; height: 20px; border: 2px solid white; background: var(--green); box-shadow: 0 2px 8px rgba(23,34,31,.32); }
.hospital-marker.is-top { width: 27px; height: 27px; background: var(--night); box-shadow: 0 0 0 6px rgba(37,79,109,.14), 0 3px 10px rgba(23,34,31,.28); }
.hospital-marker.is-selected { background: var(--danger); transform: scale(1.16); }
.user-marker { width: 18px; height: 18px; border: 4px solid white; background: #2f72d6; box-shadow: 0 0 0 7px rgba(47,114,214,.2); }

footer { padding: 18px 32px 26px; border-top: 1px solid var(--line); background: var(--panel); color: var(--muted); font-size: 12px; line-height: 1.6; }
footer p { margin: 2px 0; }
footer strong { color: var(--danger); }
.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; }

@media (max-width: 760px) {
  .topbar { min-height: auto; align-items: center; padding: 18px 18px 16px; }
  .source-summary span { display: none; }
  .layout { display: grid; grid-template-columns: 1fr; grid-template-rows: auto 48vh auto; height: auto; min-height: 0; }
  .decision-panel { grid-row: 1; border-right: 0; }
  .map-shell { grid-column: 1; grid-row: 2; height: 48vh; min-height: 360px; }
  .results-panel { grid-row: 3; min-height: 280px; border-right: 0; }
  .hospital-list { max-height: none; }
  .decision-intro { padding: 18px 16px 0; }
  .controls { padding: 14px 16px 16px; }
  .manual-tools summary { padding-left: 16px; padding-right: 16px; }
  .manual-fields { padding-left: 16px; padding-right: 16px; }
  .list-heading, .hospital-card { padding-left: 16px; padding-right: 16px; }
  .detail-panel { left: 12px; right: 12px; bottom: 12px; width: auto; }
  .map-legend { display: none; }
  footer { padding: 16px 18px 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
