:root {
  --paper: #fbf3e5;
  --paper-shade: #f0e2cd;
  --ink: #2e2c29;
  --muted: #625b51;
  --line: #cdbd9f;
  --brick: #823926;
  --brick-ink: #fff7eb;
  --water: #bfd3cd;
  --visited: #a9be8f;
  --pending: #fff3ce;
  --rebuild: #dd9977;
  --new: #acc7c4;
  --type: system-ui, "PingFang HK", "Microsoft JhengHei", sans-serif;
  --display: Georgia, "Songti TC", PMingLiU, "Microsoft JhengHei", serif;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--type);
  line-height: 1.55;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body, h1, h2, h3, p, dl, ol, ul, fieldset { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .6; cursor: default; }
a { color: var(--brick); }
:focus-visible { outline: 2px solid var(--brick); outline-offset: 3px; }
h1, h2, h3 { font-family: var(--display); line-height: 1.2; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  z-index: 5;
  top: 1rem;
  left: 1rem;
  padding: 8px 12px;
  background: var(--paper);
  transform: translateY(-200%);
}

.skip-link:focus { transform: none; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 7px 13px;
  border: 1px solid transparent;
  border-radius: 2px;
  background: transparent;
  color: var(--ink);
  font-weight: 700;
}

.button--primary { background: var(--brick); border-color: var(--brick); color: var(--brick-ink); }
.button--primary:not(:disabled):hover { background: #672b1d; }
.button--secondary { border-color: var(--brick); color: var(--brick); }
.button--secondary:not(:disabled):hover,
.button--quiet:not(:disabled):hover { background: var(--paper-shade); }
.button--quiet { border-color: var(--line); }
.button--text { min-height: 37px; padding-inline: 3px; color: var(--brick); font-weight: 650; }
.button--text:not(:disabled):hover,
.link:hover { color: #5c2217; text-decoration: underline; }
.link { display: inline-flex; align-items: center; min-height: 42px; text-underline-offset: 3px; }

input:not([type="checkbox"], [type="radio"]), select {
  min-width: 0;
  min-height: 43px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #fffaf0;
}

input::placeholder { color: var(--muted); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--brick); }

.app-page {
  display: flex;
  flex-direction: column;
  min-height: 100svh;
  height: 100dvh;
  overflow: hidden;
}

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: none;
  gap: 16px;
  min-height: 88px;
  padding: 12px clamp(16px, 3vw, 42px);
  border-bottom: 3px double var(--ink);
}

.brand { display: flex; align-items: center; gap: 13px; }
.brand h1 { font-size: clamp(25px, 4vw, 39px); letter-spacing: -.045em; }
.brand-mark {
  position: relative;
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  color: var(--brick-ink);
  background: var(--brick);
  border: 1px solid #723323;
  border-radius: 1px;
}

.brand-mark::before {
  content: "";
  width: 13px;
  height: 16px;
  margin-top: -3px;
  border: 2px solid currentColor;
  border-radius: 9px 9px 9px 1px;
  transform: rotate(-45deg);
}

.brand-mark::after {
  content: "";
  position: absolute;
  top: 43%;
  left: 47%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
}

.masthead-actions { display: flex; align-items: center; gap: clamp(10px, 2vw, 25px); }
.progress { display: flex; align-items: baseline; gap: 7px; font-size: .82rem; color: var(--muted); white-space: nowrap; }
.progress strong { color: var(--ink); font-weight: 800; font-variant-numeric: tabular-nums; }
.app-error { padding: 7px clamp(16px, 3vw, 42px); border-bottom: 1px solid var(--line); color: var(--brick); }

.workspace {
  display: grid;
  flex: 1;
  min-height: 0;
  grid-template-columns: minmax(0, 1fr) clamp(315px, 30vw, 405px);
  gap: 22px;
  padding: 18px clamp(16px, 3vw, 42px) 20px;
}

.map-pane {
  position: relative;
  isolation: isolate;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--water);
}

.map-canvas { position: absolute; inset: 0; }
.map-message { position: absolute; inset: 45% 14px auto; text-align: center; font-weight: 700; pointer-events: none; }
.map-reset, .map-legend {
  position: absolute;
  left: 12px;
  background: var(--paper);
  border: 1px solid var(--line);
}
.map-reset { top: 12px; }
.map-legend {
  bottom: 30px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px 12px;
  max-width: calc(100% - 72px);
  padding: 6px 10px;
  list-style: none;
  font-size: .76rem;
  font-weight: 650;
  pointer-events: none;
}
.map-legend li { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.legend-mark { display: inline-grid; place-items: center; width: 13px; height: 13px; border: 1px solid var(--ink); border-radius: 50%; font: 800 10px/1 var(--type); }
.legend-mark[data-tone="visited"] { background: var(--visited); }
.legend-mark[data-tone="open"] { background: var(--pending); }
.legend-mark[data-tone="rebuild"] { border-radius: 2px; background: var(--rebuild); }
.legend-mark[data-tone="new"] { border-radius: 2px; background: var(--new); }

.side-panel { display: flex; min-width: 0; min-height: 0; flex-direction: column; padding-left: 18px; border-left: 1px solid var(--line); }
.side-navigation, .mobile-navigation { display: flex; flex: none; gap: 2px; border-bottom: 1px solid var(--line); }
.side-navigation button, .mobile-navigation button, .segmented button {
  min-height: 42px;
  padding: 6px 13px;
  background: transparent;
  border: 0;
  font-weight: 750;
  white-space: nowrap;
}
.side-navigation button { flex: 1; }
.side-navigation button[aria-pressed="true"] { color: var(--brick); box-shadow: inset 0 -3px var(--brick); }
.side-navigation button:hover, .mobile-navigation button:hover { background: var(--paper-shade); }
.mobile-navigation { display: none; }
.side-content { min-height: 0; overflow: auto; flex: 1 1 auto; padding: 14px 4px 4px 0; scrollbar-color: var(--line) transparent; scrollbar-width: thin; }
.side-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding-bottom: 10px; margin-bottom: 11px; border-bottom: 1px solid var(--ink); }
.side-heading h2 { font-size: 27px; }
.side-heading span { color: var(--muted); font-size: .81rem; white-space: nowrap; }
#estate-search { width: 100%; }
.filter-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin: 8px 0; }
.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid var(--line);
  padding: 0;
  min-inline-size: 0;
}
.segmented button + button, .segmented label + label { border-left: 1px solid var(--line); }
.segmented button[aria-pressed="true"], .travel-modes input:checked + span { background: var(--brick); color: var(--brick-ink); }
.status-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 13px;
  padding: 0;
  margin: 3px 0;
  border: 0;
}
.status-filters label { display: inline-flex; align-items: center; min-height: 39px; gap: 5px; font-size: .85rem; cursor: pointer; }
.status-filters input { width: 16px; height: 16px; margin: 0; }
.estate-list { padding: 0; list-style: none; border-top: 1px solid var(--line); }
.estate-list li { border-bottom: 1px solid var(--line); }
.estate-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 63px;
  padding: 8px 4px;
  border: 0;
  background: transparent;
  text-align: left;
}
.estate-row:hover { background: var(--paper-shade); }
.estate-row strong { display: block; font-size: 1rem; }
.estate-row small { display: block; color: var(--muted); font-size: .81rem; overflow-wrap: anywhere; }
.estate-row .estate-statuses { justify-content: flex-end; max-width: 85px; }
.estate-statuses { display: flex; flex-wrap: wrap; gap: 4px; }
.estate-status {
  display: inline-block;
  padding: 2px 5px;
  border: 1px solid color-mix(in srgb, var(--ink) 25%, transparent);
  border-radius: 1px;
  color: var(--ink);
  background: var(--paper-shade);
  font-size: .73rem;
  font-weight: 650;
  white-space: nowrap;
}
.estate-status[data-tone="visited"] { background: var(--visited); }
.estate-status[data-tone="rebuild"] { background: #edc6ae; }
.estate-status[data-tone="new"] { background: var(--new); }
.empty-state, .form-message { padding: 8px 0; color: var(--muted); font-size: .9rem; }
.form-message[data-error="true"] { color: var(--brick); }
.data-sources { margin-top: 14px; color: var(--muted); font-size: .81rem; }
.data-sources summary { min-height: 34px; cursor: pointer; }
.data-sources p + p { margin-top: 5px; }
.data-sources ul { padding-inline-start: 18px; }
.text-back { margin-bottom: 13px; }
.detail-name { margin-bottom: 10px; font-size: 31px; overflow-wrap: anywhere; }
.detail-name small { display: block; margin-top: 5px; color: var(--muted); font: 500 .84rem/1.5 var(--type); }
.detail-metadata { margin: 13px 0 3px; padding-top: 9px; border-top: 1px solid var(--line); font-size: .91rem; }
.detail-metadata div { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 10px; }
.detail-metadata dt { color: var(--muted); }
.detail-metadata dd { margin: 0; }
.estate-actions { margin: 13px 0 17px; padding: 12px 0; border-block: 1px solid var(--line); }
.visit-form { display: grid; gap: 8px; }
.visit-form input { width: 100%; }
.action-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 11px; }
.estate-route-actions { margin-top: 12px; }
.estate-lifecycle-title { margin-bottom: 8px; font-size: 1.25rem; }
.lifecycle-item { padding: 10px 0; border-top: 1px solid var(--line); font-size: .88rem; }
.lifecycle-item > strong { display: block; margin: 4px 0 2px; }
.lifecycle-item > a { display: inline-flex; align-items: center; min-height: 35px; }

.travel-modes label { position: relative; text-align: center; cursor: pointer; }
.travel-modes input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.travel-modes span { display: block; min-height: 43px; padding: 9px 3px; font-weight: 750; }
.travel-modes input:focus-visible + span { position: relative; z-index: 1; outline: 2px solid var(--brick); outline-offset: 3px; }
.route-stops { padding: 12px 0 0; list-style: none; }
.route-stop { display: grid; grid-template-columns: 23px minmax(0, 1fr); gap: 8px; position: relative; margin-bottom: 8px; }
.route-stop:not(:last-child)::before { content: ""; position: absolute; top: 31px; left: 10px; bottom: -13px; width: 2px; background: var(--line); }
.route-node { z-index: 1; display: grid; place-items: center; margin-top: 10px; width: 22px; height: 22px; background: var(--paper); border: 1px solid var(--brick); border-radius: 50%; color: var(--brick); font-size: .69rem; font-weight: 750; }
.route-stop:first-child .route-node, .route-stop:last-child .route-node { background: var(--brick); color: var(--brick-ink); }
.route-field { display: grid; min-width: 0; gap: 4px; }
.route-field label { color: var(--muted); font-size: .82rem; font-weight: 750; }
.route-field input { width: 100%; }
.route-field .action-row { gap: 8px; margin-top: -1px; }
.route-field .button { font-size: .81rem; }
.route-tools { justify-content: space-between; }
.route-submit { width: 100%; margin-top: 7px; }
.route-results, .route-links { margin-top: 14px; border-top: 1px solid var(--line); padding: 11px 0 4px; }
.route-results h3, .route-links h3 { margin-bottom: 7px; font-size: 1.2rem; }
.route-summary { color: var(--brick); font-weight: 750; }
.route-credit { margin-top: 8px; color: var(--muted); font-size: .81rem; }
.route-warning { margin: 7px 0; padding-inline-start: 8px; border-inline-start: 2px solid var(--brick); color: var(--muted); font-size: .83rem; }
.route-leg { padding: 9px 0; border-bottom: 1px solid var(--line); }
.route-leg h4 { margin: 0 0 6px; font-size: .9rem; }
.route-leg label { display: block; margin-bottom: 4px; color: var(--muted); font-size: .83rem; }
.route-leg select { width: 100%; margin-bottom: 5px; }
.route-step-list { padding-inline-start: 24px; font-size: .84rem; }
.route-step-list li { margin: 4px 0; }
.route-leg details { font-size: .87rem; }
.route-leg summary { padding: 7px 0; cursor: pointer; }
.route-links ul { list-style: none; padding: 0; }
.route-links a { overflow-wrap: anywhere; }

.login-page { min-height: 100svh; display: grid; place-items: center; padding: 22px; }
.login-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(315px, 390px); gap: 25px; width: min(100%, 1030px); }
.login-art { min-height: 490px; position: relative; isolation: isolate; overflow: hidden; border: 1px solid var(--line); background: var(--water); }
.login-artwork { position: absolute; inset: 0; background-image: linear-gradient(90deg, #75938e38 1px, transparent 1px), linear-gradient(#75938e38 1px, transparent 1px); background-size: 38px 38px; }
.login-shore {
  position: absolute;
  background: repeating-linear-gradient(114deg, #e8d5ab 0 30px, #fff0cb 31px 32px, #e8d5ab 33px 49px);
  border: 1px solid #a4aa88;
}
.login-shore--north { inset: -44% 3% 36% -36%; border-radius: 35% 63% 53% 27%; transform: rotate(21deg); }
.login-shore--south { inset: 63% -24% -41% 33%; border-radius: 36% 7% 42% 63%; transform: rotate(-15deg); }
.login-site-mark { position: absolute; width: 16px; height: 16px; outline: 4px solid #82392640; border: 2px solid var(--brick-ink); border-radius: 50%; background: var(--brick); }
.login-site-mark--west { top: 34%; left: 28%; }
.login-site-mark--east { right: 32%; bottom: 27%; }
.login-title { position: absolute; bottom: 24px; left: 22px; display: flex; align-items: center; gap: 10px; padding: 10px 13px; border-block: 3px double var(--ink); background: var(--paper); }
.login-title p { font: 800 clamp(23px, 4vw, 36px)/1.2 var(--display); }
.login-panel { display: flex; align-items: center; padding: clamp(17px, 3vw, 35px); border-block: 3px double var(--ink); }
.login-panel form { display: grid; width: 100%; gap: 7px; }
.login-panel h1 { margin-bottom: 12px; font-size: 45px; }
.login-panel label { margin-top: 4px; font-size: .9rem; font-weight: 750; }
.login-panel button { margin-top: 13px; }
.login-privacy-link { justify-self: start; padding-block: 5px; font-size: .84rem; text-underline-offset: 3px; }
.login-privacy { grid-column: 1 / -1; padding: 12px 2px 18px; border-top: 1px solid var(--line); font-size: .85rem; color: var(--muted); }
.login-privacy h2 { margin-bottom: 6px; font-size: 1.05rem; color: var(--ink); }
.login-privacy p + p { margin-top: 5px; }
.login-privacy ul { display: flex; gap: 7px 14px; flex-wrap: wrap; padding: 7px 0 0; list-style: none; }

@media (max-width: 760px) {
  .masthead { min-height: 59px; gap: 8px; padding: 6px 10px; }
  .brand { gap: 7px; }
  .brand h1 { font-size: clamp(18px, 5vw, 24px); white-space: nowrap; }
  .brand-mark { width: 28px; height: 28px; }
  .brand-mark::before { width: 11px; height: 13px; }
  .masthead-actions { gap: 7px; }
  .progress { flex-direction: column; gap: 0; align-items: end; font-size: .73rem; line-height: 1.2; }
  .masthead .button { min-height: 44px; padding: 4px 8px; font-size: .82rem; }
  .workspace { display: flex; flex-direction: column; gap: 7px; padding: 7px; }
  .map-pane { flex: 1 1 0; }
  .side-panel { display: none; flex: 1 1 0; min-height: 0; padding: 0 5px; border: 0; }
  .side-content { padding: 9px 3px 5px; }
  .map-reset { min-height: 44px; top: 8px; left: 8px; font-size: .83rem; }
  .map-legend { left: 8px; padding-inline: 7px; }
  .side-navigation { display: none; }
  .mobile-navigation { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); padding-bottom: env(safe-area-inset-bottom); border-top: 1px solid var(--line); }
  .mobile-navigation button { min-height: 47px; }
  .mobile-navigation button[aria-pressed="true"] { color: var(--brick); box-shadow: inset 0 3px var(--brick); }
  .app-page[data-view="estates"] .map-pane { display: none; }
  .app-page[data-view="estates"] .side-panel, .app-page[data-view="routes"] .side-panel { display: flex; }
  .app-page[data-view="routes"] .map-pane { flex: 0 0 30%; min-height: 147px; }
  .app-page[data-view="routes"] .map-legend { display: none; }
  .button, .segmented button, .travel-modes span { min-height: 44px; }
  .login-page { display: block; padding: 12px; }
  .login-layout { margin-inline: auto; grid-template-columns: minmax(0, 1fr); gap: 15px; }
  .login-art { min-height: 185px; }
  .login-title { bottom: 12px; left: 11px; padding: 7px 10px; }
  .login-panel h1 { font-size: 35px; }
}

@media (min-width: 761px) and (max-height: 550px) {
  .masthead { min-height: 61px; }
  .workspace { padding-block: 9px; }
}
