:root {
  --panel: #f7f5ef;
  --panel-strong: #ebe7dd;
  --ink: #1d2422;
  --muted: #5f6963;
  --accent: #006d77;
  --accent-dark: #074f57;
  --map-bg: #d9ded7;
  --line: #d5d0c4;
  --white: #ffffff;
  font-family:
    "Noto Sans TC",
    "Microsoft JhengHei",
    system-ui,
    -apple-system,
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--map-bg);
}

.theme-expressway {
  --panel: #e7f3e5;
  --panel-strong: #cfe4c8;
  --accent: #16834a;
  --accent-dark: #0d5f33;
  --line: #afcaa5;
  --map-bg: #c8ddc2;
}

.theme-provincial {
  --panel: #e2f0fb;
  --panel-strong: #c4dff2;
  --accent: #176fb3;
  --accent-dark: #0c4d82;
  --line: #a6c9e3;
  --map-bg: #bfd7ea;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(360px, 1fr) 180px;
}

.control-panel {
  z-index: 2;
  padding: 28px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  box-shadow: 0 18px 50px rgb(31 45 37 / 18%);
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.theme-expressway .control-panel {
  background:
    linear-gradient(180deg, rgb(231 243 229 / 96%), rgb(213 232 207 / 96%)),
    var(--panel);
}

.theme-provincial .control-panel {
  background:
    linear-gradient(180deg, rgb(226 240 251 / 96%), rgb(207 226 241 / 96%)),
    var(--panel);
}

.brand {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: var(--white);
  font-weight: 800;
}

.theme-expressway .brand-mark {
  background: #0f7a43;
}

.theme-provincial .brand-mark {
  background: #126aa5;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.28;
}

.brand p {
  color: var(--muted);
  margin-top: 8px;
  line-height: 1.55;
}

.seo-summary {
  border-left: 3px solid var(--accent);
  padding-left: 12px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.home-content {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgb(255 255 255 / 62%);
  padding: 14px;
  display: grid;
  gap: 10px;
}

.home-content h2 {
  color: var(--ink);
  font-size: 18px;
}

.home-content p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.page-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.page-tabs a {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--white);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  text-align: center;
  text-decoration: none;
  font-size: 14px;
  font-weight: 800;
}

.page-tabs a.active {
  color: var(--white);
  border-color: var(--accent);
  background: var(--accent);
}

.theme-expressway .page-tabs a.active,
.theme-expressway button,
.theme-expressway .primary-link {
  background: #16834a;
}

.theme-provincial .page-tabs a.active,
.theme-provincial button,
.theme-provincial .primary-link {
  background: #176fb3;
}

.theme-expressway button:hover,
.theme-expressway .primary-link:hover {
  background: #0d5f33;
}

.theme-provincial button:hover,
.theme-provincial .primary-link:hover {
  background: #0c4d82;
}

.search-form {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

select,
input,
button {
  width: 100%;
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid var(--line);
  font: inherit;
}

select,
input {
  background: var(--white);
  color: var(--ink);
  padding: 0 12px;
}

.mileage-input {
  display: grid;
  grid-template-columns: 1fr 58px;
  align-items: center;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.mileage-input input {
  border: 0;
  border-radius: 0;
}

.mileage-input span {
  color: var(--muted);
  font-weight: 700;
  text-align: center;
  border-left: 1px solid var(--line);
}

button,
.primary-link,
.secondary-link {
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 8px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

button,
.primary-link {
  background: var(--accent);
  color: var(--white);
}

button:hover,
.primary-link:hover {
  background: var(--accent-dark);
}

.secondary-link {
  background: var(--panel-strong);
  color: var(--ink);
}

.secondary-link:hover {
  background: #ded8cb;
}

.result-panel,
.data-note {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgb(255 255 255 / 70%);
}

.result-panel {
  padding: 18px;
  display: grid;
  gap: 16px;
}

.eyebrow {
  display: block;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  margin-bottom: 6px;
}

#resultTitle {
  font-size: 20px;
}

#resultMeta {
  color: var(--muted);
  margin-top: 8px;
  line-height: 1.6;
}

.actions {
  display: grid;
  gap: 10px;
}

.streetview-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.data-note {
  padding: 14px;
  margin-top: auto;
  display: grid;
  gap: 6px;
  color: var(--muted);
  line-height: 1.5;
}

.data-note strong {
  color: var(--ink);
}

.data-note a {
  color: var(--accent-dark);
  font-weight: 800;
}

.view-counter {
  color: var(--accent-dark);
  font-weight: 900;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding-top: 4px;
}

.footer-links a {
  font-size: 13px;
}

.content-page {
  min-height: 100vh;
  background: var(--panel);
  color: var(--ink);
}

.content-shell {
  width: min(920px, calc(100% - 32px));
  margin: 0 auto;
  padding: 40px 0;
}

.content-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 24px;
}

.content-nav a {
  color: var(--accent-dark);
  font-weight: 800;
}

.content-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgb(255 255 255 / 78%);
  padding: 28px;
}

.content-card h1 {
  margin-bottom: 12px;
}

.content-card h2 {
  margin-top: 28px;
  margin-bottom: 10px;
  font-size: 20px;
}

.content-card p,
.content-card li {
  color: var(--muted);
  line-height: 1.75;
}

.content-card ul {
  padding-left: 20px;
}

.content-card a {
  color: var(--accent-dark);
  font-weight: 800;
}

.map-area,
#map {
  min-height: 100vh;
}

.map-area {
  position: relative;
}

#map {
  width: 100%;
  height: 100%;
}

.address-search {
  position: absolute;
  top: 16px;
  left: 50%;
  z-index: 5;
  width: min(520px, calc(100% - 32px));
  transform: translateX(-50%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgb(255 255 255 / 94%);
  box-shadow: 0 10px 30px rgb(0 0 0 / 16%);
  padding: 10px;
}

.address-search-row {
  display: grid;
  grid-template-columns: 1fr 112px;
  gap: 8px;
}

.address-search input,
.address-search button {
  min-height: 40px;
}

.address-search p {
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.address-search a {
  color: var(--accent-dark);
  font-weight: 800;
}

.ad-rail {
  min-height: 100vh;
  padding: 16px 12px;
  background: rgb(255 255 255 / 74%);
  border-left: 1px solid var(--line);
}

.ad-slot {
  position: sticky;
  top: 16px;
  min-height: 600px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgb(255 255 255 / 78%);
  color: var(--muted);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgb(23 31 28 / 34%);
  backdrop-filter: blur(2px);
  transition:
    opacity 180ms ease,
    visibility 180ms ease;
}

.loading-overlay.hidden {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.loading-box {
  width: min(320px, calc(100vw - 40px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgb(255 255 255 / 94%);
  box-shadow: 0 18px 50px rgb(0 0 0 / 22%);
  padding: 22px;
  display: grid;
  gap: 8px;
  text-align: center;
}

.loading-box strong {
  color: var(--accent-dark);
  font-size: 20px;
}

.loading-box span {
  color: var(--muted);
  line-height: 1.5;
}

.loading-overlay.error .loading-box {
  border-color: #bf4a43;
}

.loading-overlay.error .loading-box strong {
  color: #9f2f2a;
}

.marker {
  width: 18px;
  height: 18px;
  border: 3px solid var(--white);
  border-radius: 50%;
  background: #c7352d;
  box-shadow: 0 4px 16px rgb(0 0 0 / 28%);
}

.address-marker {
  width: 22px;
  height: 22px;
  border: 3px solid var(--white);
  border-radius: 50% 50% 50% 0;
  background: #176fb3;
  box-shadow: 0 4px 16px rgb(0 0 0 / 30%);
  transform: rotate(-45deg);
}

.address-marker::after {
  content: "";
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--white);
  inset: 5px;
}

@media (max-width: 820px) {
  .app-shell {
    min-height: 100dvh;
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(420px, 1fr) auto;
  }

  .control-panel {
    padding: 18px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .map-area,
  #map {
    min-height: 420px;
  }

  .address-search {
    top: 12px;
    width: calc(100% - 24px);
  }

  .address-search-row {
    grid-template-columns: 1fr;
  }

  .ad-rail {
    min-height: auto;
    padding: 12px;
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .ad-slot {
    position: static;
    min-height: 96px;
  }
}
