:root {
  --paper: #f3efe7;
  --ink: #1d1916;
  --muted: #635e57;
  --line: #e3dbd0;
  --card: #fffdf9;
  --accent: #8e1c1c;
  --shadow: 0 10px 30px rgba(60, 40, 20, 0.08);
  --sidebar: 26.5rem;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  grid-template-rows: auto auto minmax(0, 1fr);
  height: 100vh;
  overflow: hidden;
  color: var(--ink);
  background: var(--paper);
  font-family: "Source Sans 3", "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

.brand {
  grid-column: 1;
  grid-row: 1;
  padding: 1.25rem 1.25rem 0.35rem;
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 1.65rem;
  line-height: 1.12;
  letter-spacing: -0.02em;
}

.lead {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.search-panel {
  grid-column: 1;
  grid-row: 2;
  position: relative;
  z-index: 20;
  padding: 0.85rem 1.25rem 0.35rem;
}

.search-form { position: relative; }

.search-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.search-row {
  display: flex;
  gap: 0.45rem;
}

input[type="search"] {
  flex: 1;
  min-width: 0;
  height: 2.8rem;
  padding: 0 0.9rem;
  border: 1px solid #d9cfc2;
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

input[type="search"]:focus {
  outline: 2px solid #e7b4b4;
  border-color: var(--accent);
}

input[type="search"]::-webkit-search-cancel-button {
  cursor: pointer;
}

input[type="search"]::-webkit-search-decoration {
  cursor: pointer;
}

input[type="search"]::-ms-clear {
  cursor: pointer;
}

button, .text-button {
  font: inherit;
  cursor: pointer;
}

.search-row button,
.sede-button,
.chip,
.frame-button {
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: white;
  font-weight: 600;
}

.search-row button {
  padding: 0 0.95rem;
}

.search-row button:hover,
.sede-button:hover,
.chip:hover,
.frame-button:hover { background: #731616; }

.suggestions {
  position: absolute;
  z-index: 30;
  top: calc(100% + 0.35rem);
  left: 0;
  right: 0;
  max-height: 18rem;
  margin: 0;
  padding: 0.35rem;
  overflow: auto;
  list-style: none;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.suggestions[hidden] { display: none; }

.suggestion {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.15rem 0.65rem;
  padding: 0.55rem 0.65rem;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: inherit;
  text-align: left;
}

.suggestion strong { grid-column: 2; font-weight: 700; }
.suggestion span { grid-column: 2; color: var(--muted); font-size: 0.86rem; }

.suggestion .swatch { grid-row: 1 / span 2; align-self: center; }

.suggestion[aria-selected="true"],
.suggestion:hover { background: #f6f0e7; }

.swatch {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
}

.hint, .status {
  margin: 0.7rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.sidebar {
  grid-column: 1;
  grid-row: 3;
  min-height: 0;
  overflow: auto;
  padding: 0.4rem 1.25rem 1.4rem;
}

.result {
  margin-bottom: 0.9rem;
  padding: 0.95rem 1rem 1rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 6px solid var(--accent);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.result h2 {
  margin: 0.1rem 0 0;
  font-size: 1.35rem;
  line-height: 1.15;
}

.kicker {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.place {
  margin: 0.35rem 0 0.8rem;
  font-weight: 600;
}

.meta {
  display: grid;
  gap: 0.45rem;
  margin: 0;
}

.meta div { display: grid; gap: 0.05rem; }
.meta dt { color: var(--muted); font-size: 0.75rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.meta dd { margin: 0; }
.meta a { color: var(--accent); }

.sede-button, .frame-button {
  margin-top: 0.8rem;
  padding: 0.55rem 0.8rem;
  background: var(--ink);
}

.sede-button:hover, .frame-button:hover { background: #3a312b; }

.note, .special {
  margin-top: 0.85rem;
  padding: 0.7rem 0.75rem;
  border-radius: 12px;
  font-size: 0.9rem;
}

.note { background: #fff6e8; }
.special { background: #f7efe6; }
.note strong, .special strong { display: block; margin-bottom: 0.15rem; }

.outside {
  border-left-color: #8a8178;
}

.legend-title {
  margin: 0.2rem 0 0.45rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.polo {
  border-top: 1px solid var(--line);
}

.polo summary {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.72rem 0.15rem;
  cursor: pointer;
  font-weight: 700;
  list-style: none;
}

.polo summary::-webkit-details-marker { display: none; }

.polo summary:hover { color: var(--accent); }

.polo.is-active summary { background: rgba(255, 255, 255, 0.7); border-radius: 10px; }

.polo p, .zone-list {
  margin: 0 0 0.8rem 1.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.zone-list {
  line-height: 1.55;
}

.zone-list-title {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.zone-list .territory-list {
  margin: 0;
}

.footer {
  margin-top: 1rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.footer a { color: var(--accent); }

.map-wrap {
  grid-column: 2;
  grid-row: 1 / span 3;
  position: relative;
  min-width: 0;
  min-height: 0;
}

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

.chip {
  position: absolute;
  z-index: 500;
  top: 0.8rem;
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 6rem);
  padding: 0.45rem 0.8rem;
  box-shadow: var(--shadow);
}

.leaflet-tooltip {
  font-family: "Source Sans 3", "Segoe UI", sans-serif;
  font-size: 0.85rem;
  line-height: 1.3;
}

.leaflet-container path,
.leaflet-container .leaflet-interactive,
.leaflet-container .leaflet-interactive:focus,
.leaflet-container svg:focus {
  outline: none !important;
}

.territories {
  margin-top: 0.85rem;
  padding: 0.7rem 0.75rem;
  border-radius: 12px;
  background: #f3efe7;
  font-size: 0.9rem;
}

.territories strong {
  display: block;
  margin-bottom: 0.25rem;
}

.territories p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.territory-link {
  display: inline;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 0.12em;
  cursor: pointer;
}

.territory-link:hover {
  color: #731616;
}

.leaflet-div-icon.map-pin {
  background: transparent;
  border: 0;
}

.map-tools {
  position: absolute;
  z-index: 500;
  left: 0.8rem;
  bottom: 1.6rem;
}

.frame-button {
  margin: 0;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.frame-button:hover { background: white; }

@media (max-width: 860px) {
  body {
    display: flex;
    flex-direction: column;
    height: auto;
    overflow: auto;
  }

  .map-wrap {
    order: 3;
    height: 68vh;
    min-height: 420px;
  }

  .sidebar { order: 4; overflow: visible; }

  .brand, .search-panel { padding-right: 1rem; padding-left: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
