/* Tokens. White pages and navy ink; the only colour comes from metro lines,
   which are data. One typeface, Onest, carries every level of hierarchy. */
:root {
  --page: #FFFFFF;
  --tile: #F2F4F7;
  --plate: #FFFFFF;
  --ink: #13213D;
  --ink-hover: #22365E;
  --ink-soft: #5E6A7E;
  --rule: #E2E6EC;
  --pulled: #E9ECF1;
  --ok: #17663F;
  --bad: #B3261E;
  --wait: #1F4E8C;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --gutter: clamp(16px, 3vw, 40px);
  --body: "Onest", "Segoe UI", system-ui, sans-serif;
  --display: var(--body);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
/* No double-tap zoom: taps on buttons answer at once; pinching still zooms. */
body { touch-action: manipulation; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 400 16px/1.5 var(--body);
}
h1, h2, h3, p, ul, ol, dl, dd, figure, fieldset { margin: 0; padding: 0; }
fieldset { border: 0; min-width: 0; }
ul, ol { list-style: none; }
img { display: block; max-width: 100%; }
a { color: inherit; text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
[hidden] { display: none !important; }
small { font-size: 0.8125rem; color: var(--ink-soft); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.muted, .note { color: var(--ink-soft); font-size: 0.875rem; }
.pre { white-space: pre-line; }
.prose { max-width: 68ch; line-height: 1.6; }

/* Header */
.site-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 28px;
  padding: 16px var(--gutter);
  border-bottom: 1px solid var(--rule);
  background: var(--plate);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font: 700 1.1875rem/1 var(--body);
  letter-spacing: -0.015em;
  color: inherit;
  text-decoration: none;
}
/* A line with a station on it, the site's only ornament. */
.brand-mark {
  position: relative;
  width: 28px;
  height: 4px;
  background: var(--ink);
  border-radius: 2px;
}
.brand-mark::after {
  content: "";
  position: absolute;
  left: 8px;
  top: -5px;
  width: 14px;
  height: 14px;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: var(--plate);
}
.brand-note { color: var(--ink-soft); font-size: 0.875rem; }
.head-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
/* Shown to logged-in agents only: back to the panel. */
.to-admin {
  display: inline-block;
  padding: 6px 14px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 0.9375rem;
  text-decoration: none;
}
.to-admin:hover { background: var(--ink-hover); }
.lang-switch { font-size: 0.9375rem; }
.head-logout .link-button { color: var(--ink-soft); font-size: 0.9375rem; }
/* Shown to agents and staff only. */
.flat-address { margin-top: 8px; font-size: 1.0625rem; }

/* Sign-in and invite pages. */
.auth-box { display: grid; gap: 16px; width: min(400px, 100%); margin: 48px auto; padding: 28px; border: 1px solid var(--rule); border-radius: var(--r-lg); }
.auth-box h1 { font: 700 1.5rem/1.2 var(--body); letter-spacing: -0.01em; }
.auth-box .notice-bad { padding: 10px 14px; border-radius: var(--r-sm); background: #FBE9E7; color: var(--bad); }
.auth-form { display: grid; gap: 14px; }
.auth-box .or { color: var(--ink-soft); font-size: 0.875rem; text-align: center; }
.lang-switch a {
  display: inline-block;
  padding: 6px 14px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  text-decoration: none;
}
.lang-switch a:hover { border-color: var(--ink); }

/* Onest has no Chinese: on Chinese pages the characters come from the
   system's own font, while digits, Latin and Cyrillic stay in Onest. */
html[lang|="zh"] { --body: "Onest", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif; }

/* Controls */
/* Phones zoom into a field with text under 16px and stay zoomed in. */
@media (pointer: coarse) {
  input, select, textarea { font-size: max(16px, 1em) !important; }
}
input, select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid var(--rule);
  border-radius: var(--r-sm);
  background: var(--plate);
  color: var(--ink);
  font: inherit;
}
input:hover, select:hover, textarea:hover { border-color: #C8CFD9; }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 1px var(--ink);
}
textarea { resize: vertical; }
input[type="checkbox"], input[type="radio"] {
  width: 18px;
  height: 18px;
  min-height: 0;
  padding: 0;
  margin: 0;
  flex: none;
  accent-color: var(--ink);
}
input[type="checkbox"]:focus-visible, input[type="radio"]:focus-visible { box-shadow: none; outline: 2px solid var(--ink); }
input[type="file"] { padding: 8px; }
.field > .affix { font-size: 1rem; font-weight: 400; }

.field { display: grid; gap: 6px; font-size: 0.875rem; font-weight: 500; }
.field > input, .field > select, .field > textarea { font-size: 1rem; font-weight: 400; }
.field > small { font-weight: 400; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 9px 20px;
  border: 1px solid var(--rule);
  border-radius: var(--r-sm);
  background: var(--plate);
  color: var(--ink);
  font: 500 0.9375rem/1.2 var(--body);
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { border-color: var(--ink); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-main { border-color: var(--ink); background: var(--ink); color: #fff; }
.btn-main:hover { border-color: var(--ink-hover); background: var(--ink-hover); }
.btn-wide { width: 100%; }
.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-size: 0.875rem;
  text-decoration: underline;
  text-underline-offset: 0.2em;
  cursor: pointer;
}
.link-button:disabled { opacity: 0.5; cursor: default; }
.link-danger { color: var(--bad); }
.link-quiet { display: block; text-align: center; font-size: 0.875rem; color: var(--ink-soft); }

/* Metro line colours next to a station name: one dot per line, so an
   interchange shows them side by side, slightly overlapping. */
.dots { display: inline-flex; flex: none; align-items: center; }
.dot {
  display: inline-block;
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--line, #8391A5);
}
.dot + .dot { margin-left: -2px; box-shadow: 0 0 0 1.5px var(--plate); }

/* Catalog */
.catalog {
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
  gap: 40px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px var(--gutter) 72px;
  align-items: start;
}
.filters {
  position: sticky;
  top: 20px;
  padding: 20px;
  border-radius: var(--r-lg);
  background: var(--tile);
}
.filters summary { display: none; }
.filters form { display: grid; gap: 20px; }
.filters legend { padding: 0 0 6px; font-size: 0.875rem; font-weight: 500; }
.filters .btn-main { margin-top: 4px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.chips { display: grid; grid-template-columns: auto repeat(4, minmax(0, 1fr)); gap: 4px; }
.chips label { cursor: pointer; }
.chips input { position: absolute; opacity: 0; }
.chips span {
  display: block;
  padding: 8px 10px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--plate);
  text-align: center;
  font-size: 0.9375rem;
}
.chips label:hover span { border-color: #C8CFD9; }
.chips input:checked + span { border-color: var(--ink); background: var(--ink); color: #fff; }
.chips input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 2px; }
.checks { display: grid; gap: 10px; font-size: 0.9375rem; }
.checks label { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.checks input { margin-top: 3px; }

.results-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 24px;
  margin-bottom: 20px;
}
.results-head h1 { font: 700 1.75rem/1.2 var(--body); letter-spacing: -0.02em; }
.sort label { display: flex; align-items: center; gap: 8px; font-size: 0.875rem; color: var(--ink-soft); white-space: nowrap; }
.sort select { width: auto; min-height: 38px; padding: 6px 10px; color: var(--ink); }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  gap: 36px 24px;
}
.flat { position: relative; display: grid; align-content: start; gap: 14px; }
.flat-photo {
  display: block;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: var(--r-md);
  background: var(--pulled);
}
.flat-photo img { width: 100%; height: 100%; object-fit: cover; }
.no-photo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: var(--pulled);
  color: var(--ink-soft);
  font-size: 0.875rem;
}
.no-photo-large { aspect-ratio: 16 / 10; border-radius: var(--r-lg); }
.flat-body { display: grid; align-content: start; gap: 4px; }
.price {
  font: 700 1.375rem/1.2 var(--body);
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.price a { text-decoration: none; }
/* The whole card opens the flat; the price link stretches over it. */
.flat .price a::after { content: ""; position: absolute; inset: 0; border-radius: var(--r-md); }
.flat:hover .price a { text-decoration: underline; }
.price small { margin-left: 2px; font: 400 0.875rem var(--body); letter-spacing: 0; }
.flat-body h2 { font-size: 1rem; font-weight: 500; }

/* Stations: the line colour, the name, and the walk as the figure that
   matters most. */
.stops { display: grid; gap: 6px; margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--rule); }
.stops li { display: flex; align-items: center; gap: 8px; font-size: 0.9375rem; }
.stop-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stop-time { margin-left: auto; color: var(--ink-soft); font-size: 0.875rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.facts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.facts span {
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--tile);
  font-size: 0.8125rem;
}
.facts:empty { display: none; }

.empty { padding: 48px 0; display: grid; gap: 10px; justify-items: start; }
.empty h2, .empty h1 { font: 700 1.375rem/1.3 var(--body); letter-spacing: -0.01em; }
.empty p { color: var(--ink-soft); }
.empty .btn { margin-top: 6px; }
.empty-page { max-width: 640px; margin: 0 auto; padding: 72px 16px; }
.pager { display: flex; justify-content: space-between; gap: 12px; padding-top: 40px; }

/* Flat page */
.card-page { max-width: 1280px; margin: 0 auto; padding: 24px var(--gutter) 72px; }
.back { display: inline-block; margin-bottom: 14px; font-size: 0.875rem; color: var(--ink-soft); }
.back::before { content: "‹ "; }
.card-page h1 { font: 700 clamp(1.625rem, 3vw, 2.375rem)/1.15 var(--body); letter-spacing: -0.025em; }
.card-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 40px;
  margin-top: 24px;
  align-items: start;
}
.card-main { display: grid; gap: 44px; min-width: 0; }

.gallery { position: relative; }
.gallery-track {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  border-radius: var(--r-lg);
  background: var(--tile);
}
.gallery-track::-webkit-scrollbar { display: none; }
.gallery-track img {
  flex: 0 0 100%;
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: contain;
  scroll-snap-align: start;
}
.gallery-nav {
  position: absolute;
  top: 50%;
  width: 44px;
  height: 44px;
  transform: translateY(-50%);
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(19, 33, 61, 0.16);
}
.gallery-nav:hover { background: #fff; }
.gallery-prev { left: 14px; }
.gallery-next { right: 14px; }
.gallery-count {
  position: absolute;
  right: 14px;
  bottom: 14px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(19, 33, 61, 0.78);
  color: #fff;
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}

.info h2 { margin-bottom: 16px; font: 700 1.375rem/1.3 var(--body); letter-spacing: -0.01em; }

/* Metro, in the side column under the price. */
.route {
  padding: 20px 24px 22px;
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  background: var(--plate);
}
.route h2 { margin-bottom: 10px; font: 700 1.125rem/1.3 var(--body); }
.route table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
.route th, .route td { padding: 10px 0; border-top: 1px solid var(--rule); text-align: left; font-weight: 400; vertical-align: baseline; }
.route th + th, .route td { padding-left: 12px; text-align: right; }
.route thead th { padding-top: 0; border-top: 0; color: var(--ink-soft); font-size: 0.8125rem; }
.route tbody th { font-weight: 500; }
.route thead svg { display: inline-block; width: 1.4em; height: 1.4em; fill: currentColor; vertical-align: -0.35em; }
/* A long name wraps under itself, not under the line colour. */
.route .st { display: flex; align-items: flex-start; gap: 8px; }
.route .st .dots { margin-top: 0.42em; }
.route .native { display: block; color: var(--ink-soft); font-size: 0.8125rem; font-weight: 400; }
.route td { white-space: nowrap; font-variant-numeric: tabular-nums; }
.route td:nth-of-type(1) { font-weight: 500; }
.route .none { color: var(--ink-soft); font-size: 0.875rem; }
.route .note { margin-top: 10px; font-size: 0.8125rem; }

.info dl { display: grid; }
.info dl > div {
  display: grid;
  grid-template-columns: minmax(150px, 240px) minmax(0, 1fr);
  gap: 4px 24px;
  padding: 13px 0;
  border-top: 1px solid var(--rule);
}
.info dt { color: var(--ink-soft); font-size: 0.9375rem; }

.flat-side { position: sticky; top: 20px; display: grid; gap: 16px; }
.flat-summary {
  display: grid;
  gap: 14px;
  padding: 24px;
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  background: var(--plate);
}
.price-large { font-size: 2rem; letter-spacing: -0.02em; }
.avail { font-weight: 500; }
.flat-id {
  display: grid;
  gap: 2px;
  padding: 14px 16px;
  border-radius: var(--r-md);
  background: var(--tile);
  color: var(--ink-soft);
  font-size: 0.875rem;
}
.flat-id b {
  color: var(--ink);
  font: 700 1.625rem/1.2 var(--body);
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
  user-select: all;
}

@media (max-width: 900px) {
  .catalog { grid-template-columns: minmax(0, 1fr); gap: 20px; padding-top: 20px; }
  .filters { position: static; padding: 14px 16px; border-radius: var(--r-md); }
  .filters summary { display: flex; align-items: center; justify-content: space-between; cursor: pointer; font-weight: 500; list-style: none; }
  .filters summary::-webkit-details-marker { display: none; }
  .filters summary::after {
    content: "";
    width: 8px;
    height: 8px;
    margin: 0 4px 4px 0;
    border: solid var(--ink);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
  }
  .filters[open] summary::after { margin-bottom: -4px; transform: rotate(-135deg); }
  .filters[open] summary { margin-bottom: 16px; }
  .card-grid { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  /* One column: price, photos, metro, then the rest. */
  .card-main, .flat-side { display: contents; }
  .flat-summary { order: -3; }
  .gallery, .no-photo-large { order: -2; }
  .route { order: -1; }
  .info dl > div { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .gallery-nav { display: none; }
  .brand-note { order: 2; width: 100%; }
  .results-head h1 { font-size: 1.5rem; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
