.app-layout {
  display: grid;
  grid-template-columns:
    clamp(180px, 22vw, var(--sidebar-width))
    minmax(0, 1fr)
    clamp(260px, 34vw, var(--right-panel-width));
  height: 100vh;
  min-width: 0;
}

.sidebar {
  min-width: 0;
  width: 100%;
  max-width: none;
}

.events-pane {
  min-width: 0;
}

.right-panel {
  min-width: 0;
  width: 100%;
  max-width: none;
}

.sidebar,
.right-panel {
  height: 100vh;
  background: var(--panel-bg);
}

.sidebar {
  border-right: 1px solid var(--line-soft);
  overflow-y: auto;
  padding: 22px 18px 16px;
}

.sidebar-inner {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.right-panel {
  border-left: 1px solid var(--line-soft);
  overflow-y: auto;
  padding: 22px 18px 22px;
}

.right-panel-inner {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.mobile-topbar {
  display: none;
}

#bottom-spacer {
  height: 0px;
}

.jump-to-top {
  display: none
}

/* first collapse: move only the left sidebar below */
@media (max-width: 1200px) {
  body {
    overflow: auto;
  }

  .app-layout {
    grid-template-columns:
      minmax(0, 72fr)
      minmax(0, 50fr);
    grid-template-areas:
      "events right"
      "sidebar sidebar";
    height: auto;
  }

  .jump-to-top {
    display: block
  }

  .events-pane {
    grid-area: events;
  }

  .right-panel {
    grid-area: right;
  }

  .sidebar {
    grid-area: sidebar;
  }

  .sidebar,
  .events-pane,
  .right-panel {
    min-width: 0;
    height: auto;
  }

  .events-pane {
    padding-top: 6px;
  }

  .sidebar {
    max-width: none;
    width: 100%;
    border-right: none;
    border-top: 1px solid var(--line-soft);
    overflow: visible;
  }

  .sidebar-inner {
    width: 100%;
    max-width: none;
    min-height: 0;
  }

  .right-panel {
    overflow-y: auto;
  }
}

/* second collapse: stack everything */
@media (max-width: 980px) {

  html {
    font-size: 90%;
  }

  .app-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "events"
      "right"
      "sidebar";
  }

  #header {
    margin-top: 66px;
  }

  .jump-to-top {
    display: none;
  }

  .sidebar,
  .events-pane,
  .right-panel {
    width: 100%;
    max-width: none;
    min-width: 0;
    height: auto;
    overflow: visible;
    border: none;
    padding-left: 14px;
    padding-right: 14px;
  }

  .sidebar-inner,
  .right-panel-inner {
    width: 100%;
    max-width: none;
    min-height: 0;
  }

  :root {
    --map-height: 300px;
  }

  .mobile-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1200;
    max-width: none;
    margin: 0;
    padding: 14px 14px 14px;
    background: var(--panel-bg);
    border-bottom: 2px solid var(--line-strong);
    box-shadow: 0 8px 12px rgba(0, 0, 0, 0.16);
    transform: translateY(0);
    transition: transform 0.22s ease;
  }

  .mobile-topbar.is-hidden {
    transform: translateY(-100%);
  }

  .mobile-site-title {
    margin: 0;
    font-size: 1.2rem;
    line-height: 1.0;
    letter-spacing: -0.03em;
    font-weight: 800;
    color: var(--text-mid);
  }

  .mobile-subtitle {
    display: none;
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.35;
    color: var(--text-muted);
  }

  .events-pane {
    padding-top: 55px;
  }

  .mobile-top-links {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0;
  }

  .mobile-top-links a {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    text-decoration: none;
  }

  .mobile-top-links svg {
    width: 20px;
    height: 20px;
    opacity: 0.85;
    stroke-width: 2.2;
  }

  .mobile-top-links a:active svg {
    transform: scale(1.08);
  }

  #bottom-spacer {
    height: 1000px;
  }
}