:root {
  --blue: #0052CC;
  --blue-dark: #003F9E;
  --cyan: #1AC8ED;
  --green: #22A06B;
  --red: #D93025;
  --bg: #F7F8FA;
  --card: #FFFFFF;
  --text: #172B4D;
  --muted: #5E6C84;
  --line: #DFE1E6;
  --topbar-h: 60px;
  --radius: 12px;
  --shadow: 0 6px 24px rgba(9, 30, 66, .14);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); }
.hidden { display: none !important; }

/* ---- top bar -------------------------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 24px;
  padding: 0 20px;
  background: var(--card);
  border-top: 3px solid var(--blue);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 700; font-size: 19px; }
.brand img { display: block; border-radius: 8px; }
.nav { display: flex; gap: 4px; flex: 1; min-width: 0; }
.nav a {
  padding: 8px 12px; border-radius: 8px;
  color: var(--muted); text-decoration: none; font-weight: 500; white-space: nowrap;
}
.nav a:hover { background: var(--bg); color: var(--text); }
.nav a[aria-current="page"] { color: var(--blue); background: #E9F2FF; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.lang { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.lang button { border: 0; background: none; padding: 6px 10px; font: inherit; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
.lang button[aria-pressed="true"] { background: var(--blue); color: #fff; }
.menu-toggle { display: none; margin-left: auto; border: 0; background: none; font-size: 24px; cursor: pointer; color: var(--text); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px; border: 1px solid transparent;
  font: inherit; font-weight: 600; font-size: 15px; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-primary:disabled { opacity: .6; cursor: default; }
.btn-ghost { background: var(--card); color: var(--text); border-color: var(--line); }
.btn-ghost:hover { background: var(--bg); }
.btn-danger { background: var(--card); color: var(--red); border-color: var(--red); }
.btn-danger:hover { background: #FFEBE6; }
.btn-block { width: 100%; }
.btn-small { padding: 4px 10px; font-size: 13px; }

/* ---- map ------------------------------------------------------------------------------------ */
.map-view { position: relative; height: calc(100vh - var(--topbar-h)); height: calc(100dvh - var(--topbar-h)); }
.map { position: absolute; inset: 0; }
.map-hint {
  position: absolute; left: 50%; bottom: 28px; transform: translateX(-50%);
  max-width: min(520px, calc(100% - 32px));
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 10px 16px; font-size: 14px; color: var(--muted); text-align: center;
}
.map-error { color: var(--red); }

.pin-marker {
  width: 46px; height: 46px; border-radius: 50%;
  border: 3px solid #fff; box-shadow: 0 2px 8px rgba(9, 30, 66, .35);
  background: var(--blue) center / cover no-repeat;
  cursor: pointer; position: relative; padding: 0;
}
.pin-marker.is-video::after {
  content: "▶"; position: absolute; inset: 0; display: grid; place-items: center;
  color: #fff; font-size: 15px; text-shadow: 0 1px 3px rgba(0, 0, 0, .6);
}
.pin-marker.is-mine { border-color: var(--cyan); }
.pin-marker.is-active { outline: 3px solid var(--blue); }

.pin-panel {
  position: absolute; top: 16px; right: 16px; bottom: 16px; z-index: 5;
  width: min(400px, calc(100% - 32px));
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  border-top: 3px solid var(--blue);
  overflow-y: auto; padding: 16px;
}
.panel-close {
  position: absolute; top: 8px; right: 10px; z-index: 2;
  border: 0; background: rgba(255, 255, 255, .9); border-radius: 50%;
  width: 32px; height: 32px; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted);
}
.pin-media { width: 100%; border-radius: 8px; background: #000; display: block; max-height: 60vh; object-fit: contain; }
.pin-meta { margin: 12px 0 4px; font-size: 14px; color: var(--muted); }
.pin-meta strong { color: var(--text); }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.badge { background: #E9F2FF; color: var(--blue); border-radius: 999px; padding: 2px 10px; font-size: 13px; font-weight: 600; }
.badge.cyan { background: #E3FAFC; color: #0B7A93; }
.owner-actions { display: flex; gap: 8px; margin: 10px 0; flex-wrap: wrap; }

.comments { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 10px; }
.comments h3 { font-size: 15px; margin: 0 0 8px; }
.comment { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.comment .who { font-weight: 600; }
.comment .when { color: var(--muted); font-size: 12px; margin-left: 6px; }
.comment p { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.comment-form { display: flex; gap: 8px; margin-top: 10px; }
.comment-form textarea { flex: 1; resize: vertical; min-height: 40px; }

input, textarea {
  font: inherit; color: inherit; width: 100%;
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff;
}
input:focus, textarea:focus { outline: 2px solid var(--blue); outline-offset: -1px; border-color: transparent; }

/* ---- pages ---------------------------------------------------------------------------------- */
.page-view { min-height: calc(100vh - var(--topbar-h)); display: flex; flex-direction: column; }
.page {
  flex: 1; width: 100%; max-width: 820px; margin: 32px auto; padding: 32px 40px;
  background: var(--card); border-radius: var(--radius); border-top: 3px solid var(--blue);
  box-shadow: 0 1px 3px rgba(9, 30, 66, .08);
}
.page h1 { margin: 0 0 8px; font-size: 30px; line-height: 1.25; }
.page h2 { margin: 32px 0 8px; font-size: 21px; }
.page h3 { margin: 22px 0 6px; font-size: 17px; }
.page .lead { color: var(--muted); font-size: 18px; margin-top: 0; }
.page .updated { color: var(--muted); font-size: 14px; }
.page li { margin: 4px 0; }
.page table { border-collapse: collapse; width: 100%; font-size: 14px; margin: 12px 0; }
.page th, .page td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; vertical-align: top; }
.page th { background: var(--bg); }
.note { background: #E9F2FF; border-left: 4px solid var(--blue); padding: 10px 14px; border-radius: 6px; margin: 16px 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin: 20px 0; }
.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card h3 { margin-top: 0; }
.card .price { font-size: 22px; font-weight: 700; color: var(--blue); }
.card ul { padding-left: 18px; }
.settings { display: grid; gap: 14px; max-width: 460px; }
.footer {
  display: flex; flex-wrap: wrap; gap: 8px 20px; justify-content: center;
  padding: 20px; font-size: 14px; color: var(--muted);
}
.footer a { color: var(--muted); }

/* ---- dialog --------------------------------------------------------------------------------- */
.dialog {
  border: 0; border-radius: var(--radius); box-shadow: var(--shadow); border-top: 3px solid var(--blue);
  padding: 22px; width: min(420px, calc(100% - 32px));
}
.dialog::backdrop { background: rgba(9, 30, 66, .45); }
.dialog form { position: relative; display: grid; gap: 12px; }
.dialog .panel-close { top: -10px; right: -8px; }
.tabs { display: flex; gap: 4px; margin-right: 30px; }
.tabs button {
  flex: 1; border: 0; background: var(--bg); padding: 8px; border-radius: 8px;
  font: inherit; font-weight: 600; color: var(--muted); cursor: pointer;
}
.tabs button[aria-selected="true"] { background: #E9F2FF; color: var(--blue); }
.field { display: grid; gap: 4px; font-size: 14px; font-weight: 600; }
.field input { font-weight: 400; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; }
.check input { width: auto; margin-top: 4px; }
.hint { margin: 0; font-size: 13px; color: var(--muted); }
.form-error { margin: 0; color: var(--red); font-size: 14px; min-height: 0; }
.form-error:empty { display: none; }
.dialog:not(.is-register) .reg-only { display: none; }

/* ---- small screens -------------------------------------------------------------------------- */
@media (max-width: 1100px) {
  .menu-toggle { display: block; }
  .topbar { gap: 12px; }
  .nav {
    display: none; position: absolute; top: var(--topbar-h); left: 0; right: 0;
    flex-direction: column; background: var(--card); border-bottom: 1px solid var(--line);
    padding: 8px 12px; box-shadow: var(--shadow);
  }
  .nav.open { display: flex; }
  .top-actions { order: 3; }
  .menu-toggle { order: 2; }
}
@media (max-width: 640px) {
  .topbar { padding: 0 12px; }
  .brand span { display: none; }
  .page { margin: 0; padding: 22px 16px; border-radius: 0; }
  .page h1 { font-size: 25px; }
  .pin-panel { top: auto; left: 0; right: 0; bottom: 0; width: 100%; max-height: 70%; border-radius: var(--radius) var(--radius) 0 0; }
  .btn { padding: 7px 12px; }
}
