:root {
  color-scheme: light;
  --bg: #ffffff;
  --panel: #ffffff;
  --text: #171717;
  --muted: #666666;
  --line: #e9e9e9;
  --accent: #171717;
  --accent-dark: #000000;
  --sidebar-width: 360px;
  --sidebar-handle-size: 40px;
  --mobile-header-offset: 16px;
  --mobile-footer-offset: 16px;
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, sans-serif;
}

.layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  transition: grid-template-columns 220ms cubic-bezier(0.22, 1, 0.36, 1);
}

.layout.sidebar-collapsed {
  grid-template-columns: 0 1fr;
}

.sidebar {
  position: relative;
  overflow: visible;
  z-index: 1001;
}

.sidebar-inner {
  display: flex;
  width: var(--sidebar-width);
  min-height: 100vh;
  height: 100vh;
  flex-direction: column;
  padding: 2rem 1.5rem;
  background: var(--panel);
  border-right: 1px solid var(--line);
  transition:
    transform 220ms cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 220ms cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: 0 0 0 rgba(0, 0, 0, 0);
  overflow: hidden;
}

.sidebar-top {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
}

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

h1 {
  margin: 0;
  font-size: 2rem;
  line-height: 1;
}

.sidebar-copy {
  margin: 1rem 0 1.5rem;
  color: var(--muted);
  line-height: 1.6;
}

.sidebar-body {
  display: grid;
  min-height: 0;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.search-form {
  display: grid;
  gap: 0.75rem;
}

.search-form input,
.search-form button,
.marker-form input,
.marker-form textarea,
.marker-form button {
  min-height: 48px;
  border-radius: 0;
  font: inherit;
}

.search-form input,
.marker-form input,
.marker-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  padding: 0 0.9rem;
  background: #fff;
  color: var(--text);
}

.marker-form textarea {
  padding-top: 0.85rem;
  resize: vertical;
}

.search-form button,
.marker-form button {
  border: 0;
  padding: 0 1rem;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

.marker-form .icon-button,
.modal-head .icon-button {
  min-height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

.search-form button:hover,
.marker-form button:hover {
  background: var(--accent-dark);
}

.secondary-button {
  min-height: 44px;
  border: 1px solid var(--line);
  padding: 0 1rem;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font: inherit;
}

.secondary-button:hover {
  border-color: #d9d9d9;
}

.status {
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.results {
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.75rem;
  overflow: auto;
  max-height: 220px;
}

.results li {
  margin: 0;
}

.result-button {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  padding: 0.9rem;
  text-align: left;
  cursor: pointer;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.result-button:hover {
  border-color: rgba(22, 32, 25, 0.28);
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(23, 23, 23, 0.05);
}

.result-title {
  display: block;
  color: var(--text);
  font-weight: 700;
  line-height: 1.4;
}

.result-subtitle {
  display: block;
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.section-heading h2 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.2;
}

.section-heading p {
  margin: 0.45rem 0 1rem;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.marker-form {
  display: grid;
  gap: 0.75rem;
}

.form-cluster {
  display: grid;
  gap: 0.45rem;
}

.field-label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.custom-blocks-section {
  display: grid;
  gap: 0.75rem;
}

.custom-blocks {
  display: grid;
  gap: 0.75rem;
}

.custom-block {
  display: grid;
  gap: 0.75rem;
  padding: 0.9rem;
  border: 1px solid var(--line);
  background: #fff;
  animation: fadeSlideIn 220ms cubic-bezier(0.22, 1, 0.36, 1);
}

.custom-block-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.custom-block-top strong {
  font-size: 0.95rem;
}

.days-fieldset {
  margin: 0;
  padding: 0.7rem;
  border: 1px solid var(--line);
}

.days-fieldset legend {
  padding: 0 0.35rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.days-grid {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.4rem;
  overflow-x: auto;
  padding-bottom: 0.15rem;
  scrollbar-width: none;
}

.days-grid::-webkit-scrollbar {
  display: none;
}

.day-chip {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
}

.day-chip input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.day-chip span {
  display: inline-flex;
  min-width: 48px;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  padding: 0 0.7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

.day-chip input[type="checkbox"]:checked + span {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.day-chip:hover span {
  transform: translateY(-1px);
}

.saved-markers {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}

.saved-markers-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.75rem;
}

.saved-marker-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.85rem 0.9rem;
  border: 1px solid var(--line);
  background: #fff;
  animation: fadeSlideIn 220ms cubic-bezier(0.22, 1, 0.36, 1);
}

.saved-marker-meta {
  min-width: 0;
}

.saved-marker-name {
  display: block;
  color: var(--text);
  font-weight: 700;
  line-height: 1.35;
}

.saved-marker-address {
  display: block;
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

.saved-marker-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.icon-button {
  display: inline-flex;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.icon-button:hover {
  border-color: #d9d9d9;
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(23, 23, 23, 0.06);
}

.icon-button svg {
  width: 16px;
  height: 16px;
  stroke-width: 2.2;
}

.color-field {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 0.75rem;
  align-items: center;
}

#marker-color {
  width: 100%;
  min-height: 48px;
  padding: 0.2rem;
  cursor: pointer;
  border: 1px solid var(--line);
  background: #fff;
}

#marker-color-hex {
  font-family: inherit;
  text-transform: uppercase;
}

#map {
  width: 100%;
  height: 100vh;
  min-height: 100vh;
}

.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(23, 23, 23, 0.28);
  backdrop-filter: blur(4px);
  opacity: 0;
  animation: fadeIn 180ms ease forwards;
}

.modal-panel {
  position: relative;
  width: min(560px, 100%);
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
  padding: 1.25rem;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 24px 64px rgba(23, 23, 23, 0.16);
  opacity: 0;
  transform: translateY(16px) scale(0.985);
  animation: modalIn 220ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.toggle-button {
  display: inline-flex;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  flex: 0 0 auto;
  position: absolute;
  top: 24px;
  right: -20px;
  z-index: 1000;
  border-radius: 999px;
  box-shadow: 0 8px 20px rgba(23, 23, 23, 0.08);
  pointer-events: auto;
}

.toggle-button svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.2;
}

.toggle-button:hover {
  border-color: #d9d9d9;
  transform: translateY(-1px);
}

.is-closing .modal-backdrop {
  animation: fadeOut 160ms ease forwards;
}

.is-closing .modal-panel {
  animation: modalOut 160ms ease forwards;
}

.layout.sidebar-collapsed .sidebar-body,
.layout.sidebar-collapsed .sidebar-top > div {
  opacity: 0;
  pointer-events: none;
}

.layout.sidebar-collapsed .sidebar-inner {
  transform: translateX(calc(-1 * var(--sidebar-width)));
  box-shadow: 0 12px 30px rgba(23, 23, 23, 0.08);
}

.layout.sidebar-collapsed .toggle-button {
  right: calc(-1 * (var(--sidebar-handle-size) + 16px));
  background: #fff;
  border-color: var(--line);
  box-shadow: 0 12px 24px rgba(23, 23, 23, 0.12);
  z-index: 3000;
}

.floating-toggle[hidden] {
  display: none;
}

.floating-toggle {
  position: fixed;
  top: 24px;
  left: 20px;
  z-index: 4000;
  display: inline-flex;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(23, 23, 23, 0.12);
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.floating-toggle:hover {
  border-color: #d9d9d9;
  transform: translateY(-1px);
}

.floating-toggle svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.2;
}

.leaflet-popup-content-wrapper {
  border-radius: 18px;
  box-shadow: 0 20px 42px rgba(23, 23, 23, 0.14);
}

.leaflet-popup-content {
  margin: 0;
  min-width: 250px;
}

.marker-popup {
  display: grid;
  gap: 0.8rem;
  padding: 1rem;
}

.marker-popup-title {
  margin: 0;
  color: var(--text);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
}

.marker-popup-address {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.marker-popup-section {
  display: grid;
  gap: 0.45rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}

.marker-popup-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.marker-popup-description,
.marker-popup-custom-text {
  margin: 0;
  color: var(--text);
  font-size: 0.94rem;
  line-height: 1.45;
}

.marker-popup-custom-entry {
  display: grid;
  gap: 0.55rem;
}

.marker-popup-days {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.marker-popup-day {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 0.7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f7f7f7;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1;
}

.leaflet-control-attribution {
  display: none;
}

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

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
  }
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.985);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes modalOut {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }

  to {
    opacity: 0;
    transform: translateY(10px) scale(0.99);
  }
}

@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

@media (max-width: 820px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    min-height: 100dvh;
  }

  .layout.sidebar-collapsed {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    z-index: 2500;
    inset: 0 auto 0 0;
    width: min(88vw, var(--sidebar-width));
    pointer-events: auto;
  }

  .sidebar-inner {
    width: min(88vw, var(--sidebar-width));
    min-height: 100dvh;
    height: 100dvh;
    padding: 1.25rem;
    box-shadow: 14px 0 34px rgba(23, 23, 23, 0.12);
  }

  .layout.sidebar-collapsed .sidebar {
    pointer-events: none;
  }

  .layout.sidebar-collapsed .sidebar-inner {
    transform: translateX(calc(-1 * var(--sidebar-width)));
  }

  .layout.sidebar-collapsed .toggle-button {
    opacity: 0;
    pointer-events: none;
  }

  .floating-toggle {
    top: var(--mobile-header-offset);
    left: var(--mobile-header-offset);
  }

  #map {
    height: 100dvh;
    min-height: 100dvh;
    touch-action: pan-x pan-y;
  }

  .modal {
    align-items: end;
    padding: 0;
  }

  .modal-panel {
    width: 100%;
    max-height: min(88dvh, 820px);
    padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom, 0px));
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 24px 24px 0 0;
    transform: translateY(22px) scale(0.995);
  }

  .modal-head {
    gap: 0.75rem;
    margin-bottom: 0.9rem;
  }

  .marker-form {
    gap: 0.9rem;
  }

  .marker-form input,
  .marker-form textarea,
  .marker-form button,
  .secondary-button {
    min-height: 52px;
  }

  .marker-form textarea {
    min-height: 110px;
    padding-top: 0.95rem;
  }

  .custom-block {
    padding: 1rem;
  }

  .color-field {
    grid-template-columns: 64px 1fr;
  }

  .status {
    padding-bottom: 0.25rem;
  }

  .saved-marker-item {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .saved-marker-actions {
    justify-content: flex-start;
  }
}
