:root {
  color-scheme: light;
  --ink: #18313f;
  --muted: #5e7480;
  --navy: #123f5a;
  --teal: #0f766e;
  --paper: #f7faf9;
  --line: #d8e3e4;
  --white: #ffffff;
  --shadow: 0 18px 50px rgba(15, 47, 63, 0.14);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  background: #eaf1f1;
  font-family: "Noto Sans TC", "Microsoft JhengHei", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, select { font: inherit; }
button { color: inherit; }
a { color: inherit; }

.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;
}

.topbar {
  height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 28px;
  color: var(--white);
  background: linear-gradient(110deg, #10384f 0%, #155b68 72%, #167065 100%);
  box-shadow: 0 2px 14px rgba(7, 41, 56, 0.2);
  position: relative;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand-mark {
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  padding: 3px;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,.94);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 4px 14px rgba(4,30,44,.24);
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 50%;
}

.eyebrow, .section-label, .detail-kicker {
  margin: 0;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.eyebrow { color: rgba(255,255,255,.72); }
.brand h1 { margin: 2px 0 0; font-size: 24px; line-height: 1.15; letter-spacing: .04em; }

.privacy-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 999px;
  background: rgba(255,255,255,.1);
  font-size: 13px;
  font-weight: 700;
}
.privacy-chip span { color: #72e3b4; font-size: 10px; }

.app-shell {
  height: calc(100vh - 82px);
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
}

.sidebar {
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 24px 20px 26px;
  border-right: 1px solid var(--line);
  background: rgba(250, 252, 251, .97);
  z-index: 15;
}

.sidebar-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.section-label { color: var(--teal); }
.sidebar h2 { margin: 5px 0 0; font-size: 18px; }
.drawer-close { display: none; }

.preset-row { display: flex; gap: 6px; margin: 18px 0 14px; flex-wrap: wrap; }
.text-button {
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--white);
  color: #385460;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.text-button:hover, .text-button:focus-visible { border-color: #73a6a1; background: #eff8f6; }

.layer-list { display: grid; gap: 7px; padding-bottom: 20px; }
.layer-control {
  position: relative;
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 50px;
  padding: 7px 9px;
  border: 1px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  transition: border-color .18s, background .18s;
}
.layer-control:hover { background: #f0f6f5; }
.layer-control:has(input:focus-visible) { outline: 3px solid rgba(23, 126, 137, .2); }
.layer-control:has(input:checked) { border-color: #dce9e7; background: #f4f9f8; }
.layer-control input { position: absolute; opacity: 0; pointer-events: none; }
.layer-symbol {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: var(--layer-color);
  background: color-mix(in srgb, var(--layer-color) 12%, white);
  font-size: 17px;
}
.layer-copy strong { display: block; font-size: 14px; }
.layer-copy small { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }
.switch {
  width: 34px;
  height: 20px;
  padding: 2px;
  border-radius: 999px;
  background: #c7d2d4;
  transition: .2s;
}
.switch::after {
  content: "";
  display: block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 4px rgba(0,0,0,.22);
  transition: transform .2s;
}
.layer-control:has(input:checked) .switch { background: var(--layer-color); }
.layer-control:has(input:checked) .switch::after { transform: translateX(14px); }

.contact-card {
  width: 100%;
  margin-top: auto;
  padding: 16px;
  border-radius: 14px;
  color: #effbfa;
  background: linear-gradient(150deg, #123f5a, #13685f);
  box-shadow: 0 10px 30px rgba(18,63,90,.14);
}
.contact-card .section-label { color: #83e6ca; }
.contact-card p { margin: 4px 0 0; color: rgba(255,255,255,.74); font-size: 12px; line-height: 1.55; }
.contact-card a { text-decoration-thickness: 1px; text-underline-offset: 2px; }
.emergency-number { display: inline-block; margin-top: 5px; color: white; font-size: 20px; font-weight: 800; text-decoration: none; letter-spacing: .02em; }
.contact-divider { height: 1px; margin: 12px 0 10px; background: rgba(255,255,255,.16); }

.map-workspace { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; padding: 14px; gap: 10px; }
.map-toolbar { display: flex; align-items: center; gap: 8px; min-width: 0; }
.mobile-layer-button { display: none !important; }
.toolbar-button, .zoom-button, .quick-find select {
  min-height: 38px;
  border: 1px solid #cad9db;
  border-radius: 10px;
  background: rgba(255,255,255,.9);
  box-shadow: 0 3px 12px rgba(18,63,90,.06);
  cursor: pointer;
}
.toolbar-button { padding: 7px 12px; font-size: 13px; font-weight: 700; }
.toolbar-button:hover, .zoom-button:hover, .quick-find select:hover { border-color: #79a5a2; background: white; }
.toolbar-button:focus-visible, .zoom-button:focus-visible, .quick-find select:focus-visible, .hotspot:focus-visible { outline: 3px solid rgba(15,118,110,.24); outline-offset: 2px; }

.quick-find { min-width: 0; flex: 1 1 260px; max-width: 330px; }
.quick-find select { width: 100%; padding: 7px 34px 7px 12px; color: #2b4855; }
.view-controls { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.zoom-button { width: 38px; padding: 0; font-size: 22px; line-height: 1; }

.map-viewport {
  min-width: 0;
  min-height: 380px;
  overflow: hidden;
  position: relative;
  border: 1px solid #c9d8d9;
  border-radius: 18px;
  background:
    radial-gradient(circle at 20% 20%, rgba(20, 109, 105, .08), transparent 36%),
    #dfe9e8;
  box-shadow: var(--shadow);
  touch-action: none;
  cursor: grab;
}
.map-viewport.is-dragging { cursor: grabbing; }
.map-viewport:focus-visible { outline: 3px solid rgba(15,118,110,.25); outline-offset: 2px; }

.map-canvas {
  position: absolute;
  left: 0;
  top: 0;
  width: 2048px;
  height: 1608px;
  transform-origin: 0 0;
  will-change: transform;
  user-select: none;
}
.map-canvas > .map-base,
.psd-overlay {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.psd-overlay-layer, .hotspot-layer { position: absolute; inset: 0; }
.psd-overlay { position: absolute; inset: 0; transition: opacity .18s ease; }
.psd-overlay[hidden], .hotspot[hidden] { display: none; }

.hotspot {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 46px;
  height: 46px;
  padding: 0;
  transform: translate(-50%, -50%) scale(var(--hotspot-compensate, 1));
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}
.hotspot::before {
  content: "";
  position: absolute;
  inset: 1px;
  border: 3px solid white;
  border-radius: 50%;
  background: color-mix(in srgb, var(--hotspot-color) 20%, transparent);
  box-shadow: 0 0 0 3px var(--hotspot-color), 0 5px 14px rgba(16,45,58,.24);
  opacity: 0;
  transform: scale(.84);
  transition: opacity .15s, transform .15s;
}
.hotspot:hover, .hotspot:focus-visible, .hotspot.is-active { z-index: 5; }
.hotspot:hover::before, .hotspot:focus-visible::before, .hotspot.is-active::before { opacity: 1; transform: scale(1); }
.hotspot-label {
  position: absolute;
  left: 50%;
  top: calc(100% + 8px);
  width: max-content;
  max-width: 190px;
  padding: 6px 8px;
  transform: translateX(-50%);
  border-radius: 7px;
  color: #17333f;
  background: rgba(255,255,255,.96);
  box-shadow: 0 5px 14px rgba(15,47,63,.2);
  font-size: 12px;
  line-height: 1.25;
  font-weight: 800;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
}
.hotspot:hover .hotspot-label, .hotspot:focus-visible .hotspot-label { opacity: 1; }

.map-hint {
  position: absolute;
  left: 14px;
  bottom: 14px;
  padding: 8px 11px;
  border: 1px solid rgba(255,255,255,.68);
  border-radius: 9px;
  color: #244956;
  background: rgba(255,255,255,.88);
  box-shadow: 0 5px 16px rgba(16,48,61,.12);
  backdrop-filter: blur(8px);
  font-size: 12px;
  font-weight: 700;
  pointer-events: none;
}

.detail-card {
  position: absolute;
  right: 16px;
  bottom: 16px;
  width: min(350px, calc(100% - 32px));
  max-height: calc(100% - 32px);
  overflow-y: auto;
  padding: 18px 20px 18px 72px;
  border: 1px solid rgba(211,225,226,.92);
  border-radius: 16px;
  background: rgba(255,255,255,.96);
  box-shadow: 0 18px 55px rgba(12,46,62,.24);
  backdrop-filter: blur(12px);
  cursor: default;
  animation: detail-in .18s ease-out;
}
.detail-card[hidden] { display: none; }
@keyframes detail-in { from { opacity: 0; transform: translateY(8px); } }
.detail-icon {
  position: absolute;
  top: 18px;
  left: 18px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: white;
  background: var(--detail-color, var(--teal));
  font-size: 19px;
  font-weight: 900;
}
.detail-close {
  position: absolute;
  top: 8px;
  right: 9px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 9px;
  color: #60757e;
  background: transparent;
  font-size: 24px;
  cursor: pointer;
}
.detail-close:hover { background: #eef4f3; }
.detail-kicker { color: var(--detail-color, var(--teal)); }
.detail-card h3 { margin: 4px 26px 5px 0; font-size: 19px; }
.detail-card > p:not(.detail-kicker) { margin: 0; color: #526b75; font-size: 13px; line-height: 1.58; }
.detail-card ul { margin: 10px 0 0; padding-left: 18px; color: #284652; font-size: 12px; line-height: 1.55; }

.map-footnote { display: flex; justify-content: space-between; gap: 20px; color: #60757e; font-size: 11px; }
.drawer-backdrop { display: none; }

@media (max-width: 1050px) {
  .app-shell { grid-template-columns: 284px minmax(0, 1fr); }
  .sidebar { padding-inline: 16px; }
  .orientation-chip { display: none; }
  .toolbar-button { padding-inline: 9px; }
}

@media (max-width: 760px) {
  body { overflow: hidden; }
  .topbar { height: 68px; padding: 0 14px; }
  .brand-mark { width: 42px; height: 42px; padding: 2px; }
  .eyebrow { display: none; }
  .brand h1 { font-size: 18px; }
  .privacy-chip { padding: 7px 9px; font-size: 11px; }
  .app-shell { height: calc(100vh - 68px); display: block; }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(88vw, 360px);
    padding: max(22px, env(safe-area-inset-top)) 18px max(24px, env(safe-area-inset-bottom));
    border-right: 0;
    box-shadow: 18px 0 50px rgba(9,35,49,.28);
    transform: translateX(-104%);
    transition: transform .24s ease;
    z-index: 60;
  }
  .sidebar.is-open { transform: translateX(0); }
  .drawer-close { display: grid; }
  .drawer-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(7,32,45,.45);
    backdrop-filter: blur(2px);
    z-index: 50;
  }
  .drawer-backdrop[hidden] { display: none; }
  .icon-button {
    width: 38px;
    height: 38px;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: white;
    font-size: 24px;
    cursor: pointer;
  }

  .map-workspace { height: 100%; padding: 9px; gap: 7px; }
  .map-toolbar { gap: 6px; }
  .mobile-layer-button { display: inline-flex !important; align-items: center; gap: 6px; }
  .quick-find { flex: 1 1 auto; max-width: none; }
  .view-controls .toolbar-button { display: none; }
  .zoom-button { width: 36px; min-height: 36px; }
  .map-viewport { min-height: 0; border-radius: 14px; }
  .map-hint { left: 10px; bottom: 10px; font-size: 10px; padding: 7px 9px; }
  .map-footnote { display: block; padding: 0 3px; font-size: 10px; line-height: 1.35; }
  .map-footnote span:last-child { display: none; }

  .detail-card {
    right: 8px;
    bottom: 8px;
    width: calc(100% - 16px);
    max-height: 44%;
    padding: 16px 44px 16px 64px;
    border-radius: 14px;
  }
  .detail-icon { top: 15px; left: 14px; width: 38px; height: 38px; }
  .detail-card h3 { font-size: 17px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
